[VNIC] Initial checkin of VNIC code. Not yet fully functional.
[mirror/winof/.git] / ulp / inic / kernel / vnic_control.c
1 /*\r
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
3  *\r
4  * This software is available to you under the OpenIB.org BSD license\r
5  * below:\r
6  *\r
7  *     Redistribution and use in source and binary forms, with or\r
8  *     without modification, are permitted provided that the following\r
9  *     conditions are met:\r
10  *\r
11  *      - Redistributions of source code must retain the above\r
12  *        copyright notice, this list of conditions and the following\r
13  *        disclaimer.\r
14  *\r
15  *      - Redistributions in binary form must reproduce the above\r
16  *        copyright notice, this list of conditions and the following\r
17  *        disclaimer in the documentation and/or other materials\r
18  *        provided with the distribution.\r
19  *\r
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
23  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
24  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
25  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
27  * SOFTWARE.\r
28  *\r
29  * $Id$\r
30  */\r
31 \r
32 #include "vnic_adapter.h"\r
33 \r
34 static void\r
35 control_recv( Control_t *pControl, RecvIo_t *pRecvIo );\r
36 \r
37 static void\r
38 control_recvComplete(\r
39                 IN              Io_t            *pIo );\r
40 \r
41 static ib_api_status_t\r
42 control_send( Control_t *pControl );\r
43 \r
44 static void\r
45 control_sendComplete( Io_t *pIo );\r
46 static void\r
47 control_timeout( void * context );\r
48 \r
49 static void\r
50 control_timer( Control_t *pControl, int timeout );\r
51 \r
52 static void\r
53 control_timerStop( Control_t *pControl );\r
54 \r
55 static void\r
56 control_initHdr( Control_t *pControl, uint8_t cmd );\r
57 \r
58 static RecvIo_t *\r
59 control_getRsp( Control_t *pControl );\r
60 \r
61 static void\r
62 copyRecvPoolConfig( Inic_RecvPoolConfig_t *pSrc,\r
63                                         Inic_RecvPoolConfig_t *pDst );\r
64 \r
65 static BOOLEAN\r
66 checkRecvPoolConfigValue(\r
67                 IN              void            *pSrc,\r
68                 IN              void            *pDst,\r
69                 IN              void            *pMax,\r
70                 IN              void            *pMin,\r
71                 IN              char            *name );\r
72 \r
73 static BOOLEAN  checkRecvPoolConfig(\r
74                                         Inic_RecvPoolConfig_t *pSrc,\r
75                                         Inic_RecvPoolConfig_t *pDst,\r
76                                         Inic_RecvPoolConfig_t *pMax,\r
77                                         Inic_RecvPoolConfig_t *pMin);\r
78 \r
79 static void\r
80 __control_logControlPacket(\r
81                                         Inic_ControlPacket_t *pPkt );\r
82 \r
83 static inline char*\r
84 control_ifcfg_name( Control_t *pControl )\r
85 {\r
86         if (! pControl)\r
87                 return "NCtl";\r
88         return (pControl->p_viport->p_adapter->name );\r
89 }\r
90 \r
91 \r
92 void\r
93 control_construct(\r
94         IN              Control_t                       *pControl,\r
95         IN              viport_t                        *pViport )\r
96 {\r
97         VNIC_ENTER( VNIC_DBG_CTRL );\r
98 \r
99         cl_memclr(pControl, sizeof(Control_t));\r
100 \r
101         pControl->p_viport = pViport;\r
102 \r
103         pControl->reqOutstanding = FALSE;\r
104         pControl->seqNum         = 0;\r
105 \r
106         pControl->pResponse      = NULL;\r
107         pControl->pInfo          = NULL;\r
108 \r
109         pControl->p_viport->addrs_query_done = TRUE;\r
110 \r
111         InitializeListHead(&pControl->failureList);\r
112         KeInitializeSpinLock(&pControl->ioLock);\r
113 \r
114         cl_timer_construct( &pControl->timer );\r
115 \r
116         ibqp_construct( &pControl->qp, pViport );\r
117 \r
118         VNIC_EXIT( VNIC_DBG_CTRL );\r
119 }\r
120 \r
121 \r
122 ib_api_status_t\r
123 control_init(\r
124         IN              Control_t                       *pControl,\r
125         IN              viport_t                        *pViport,\r
126         IN              ControlConfig_t         *pConfig,\r
127         IN              uint64_t                        guid )\r
128 {\r
129         ib_api_status_t                 ib_status;\r
130         ib_pd_handle_t                  hPd;\r
131         Inic_ControlPacket_t    *pkt;\r
132         Io_t                                    *pIo;\r
133         int                                             sz;\r
134         unsigned int                    i;\r
135 \r
136         VNIC_ENTER( VNIC_DBG_CTRL );\r
137 \r
138         pControl->p_conf  = pConfig;\r
139 \r
140         hPd = pViport->p_adapter->ca.hPd;\r
141 \r
142         cl_timer_init( &pControl->timer, control_timeout, pControl );\r
143 \r
144         ib_status = ibqp_init(\r
145                 &pControl->qp, guid, &pConfig->ibConfig );\r
146         if( ib_status != IB_SUCCESS )\r
147         {\r
148                 VNIC_TRACE_EXIT( VNIC_DBG_ERROR, ("%s: ibqp_init returned %s\n",\r
149                         pViport->p_adapter->ifc.get_err_str( ib_status )) );\r
150                 goto failure;\r
151         }\r
152 \r
153         sz = (sizeof(RecvIo_t) * pConfig->numRecvs ) +\r
154                 (sizeof(Inic_ControlPacket_t) * (pConfig->numRecvs + 1));\r
155 \r
156         pControl->pLocalStorage = cl_zalloc( sz );\r
157 \r
158         if ( pControl->pLocalStorage == NULL )\r
159         {\r
160                 VNIC_TRACE_EXIT( VNIC_DBG_ERROR,\r
161                         ("%s: Failed allocating space for local storage\n",\r
162                                         control_ifcfg_name(pControl)) );\r
163 \r
164                 ibqp_cleanup(&pControl->qp);\r
165                 ib_status = IB_INSUFFICIENT_MEMORY;\r
166                 goto failure;\r
167         }\r
168 \r
169         pControl->pRecvIos = (RecvIo_t *)pControl->pLocalStorage;\r
170 \r
171         pkt = (Inic_ControlPacket_t *)(pControl->pLocalStorage +\r
172                              sizeof(SendIo_t) * pConfig->numRecvs);\r
173 \r
174         sz = sizeof(Inic_ControlPacket_t) * (pConfig->numRecvs + 1);\r
175 \r
176         ib_status = ibregion_init( pViport, &pControl->region, hPd,\r
177                 pkt, sz, IB_AC_LOCAL_WRITE );\r
178         if ( ib_status != IB_SUCCESS )\r
179         {\r
180                 /* NOTE: I'm allowing recvs into the send buffer as well\r
181                  * as the receive buffers. I'm doing this to combine them\r
182                  * into a single region, and conserve a region.\r
183                  */\r
184                 VNIC_TRACE_EXIT( VNIC_DBG_ERROR|VNIC_DBG_CTRL,\r
185                                         ("%s: Failed setting up control space region\n",\r
186                                                                         control_ifcfg_name(pControl)) );\r
187                 ibqp_cleanup( &pControl->qp );\r
188                 cl_free( pControl->pLocalStorage );\r
189                 goto failure;\r
190         }\r
191         pIo                                             = &pControl->sendIo.io;\r
192         pIo->pViport                    = pViport;\r
193         pIo->pRoutine                   = control_sendComplete;\r
194 \r
195         pIo->wrq.p_next                 = NULL;\r
196         pIo->wrq.wr_type                = WR_SEND;\r
197         pIo->wrq.send_opt               = IB_SEND_OPT_SIGNALED;\r
198         pIo->wrq.wr_id                  = (uint64_t)(pIo);\r
199         pIo->wrq.num_ds                 = 1;\r
200         pIo->wrq.ds_array               = &pControl->sendIo.dsList;\r
201         pIo->wrq.ds_array[0].length     = sizeof(Inic_ControlPacket_t);\r
202         pIo->wrq.ds_array[0].lkey  = pControl->region.lkey;\r
203         pIo->wrq.ds_array[0].vaddr = (uint64_t)(pkt++);\r
204 \r
205         for (i = 0; i < pConfig->numRecvs; i++ )\r
206         {\r
207                 pIo                                             = &pControl->pRecvIos[i].io;\r
208                 pIo->pViport                    = pViport;\r
209                 pIo->pRoutine                   = control_recvComplete;\r
210 \r
211                 pIo->r_wrq.wr_id                                = (uint64_t)(pIo);\r
212                 pIo->r_wrq.p_next                               = NULL;\r
213                 pIo->r_wrq.num_ds                               = 1;\r
214                 pIo->r_wrq.ds_array                             = &pControl->pRecvIos[i].dsList;\r
215                 pIo->r_wrq.ds_array[0].length   = sizeof(Inic_ControlPacket_t);\r
216                 pIo->r_wrq.ds_array[0].vaddr    = (uint64_t)(pkt++);\r
217                 pIo->r_wrq.ds_array[0].lkey             = pControl->region.lkey;\r
218         \r
219                 if ( ibqp_postRecv( &pControl->qp, pIo ) != IB_SUCCESS )\r
220                 {\r
221                         control_cleanup( pControl );\r
222                         ib_status = IB_ERROR;\r
223                         goto failure;\r
224                 }\r
225         }\r
226 \r
227 failure:\r
228         VNIC_EXIT( VNIC_DBG_CTRL );\r
229         return ib_status;\r
230 }\r
231 \r
232 \r
233 void\r
234 control_cleanup(\r
235         IN                      Control_t       *pControl )\r
236 {\r
237         VNIC_ENTER( VNIC_DBG_CTRL );\r
238 \r
239         control_timerStop( pControl );\r
240         ibqp_detach( &pControl->qp );\r
241         ibqp_cleanup( &pControl->qp );\r
242         ibregion_cleanup( pControl->p_viport, &pControl->region );\r
243 \r
244         if ( pControl->pLocalStorage )\r
245         {\r
246                 cl_free( pControl->pLocalStorage );\r
247                 pControl->pLocalStorage = NULL;\r
248         }\r
249 \r
250         cl_timer_destroy( &pControl->timer );\r
251 \r
252         VNIC_EXIT( VNIC_DBG_CTRL );\r
253         return;\r
254 }\r
255 \r
256 void\r
257 control_processAsync(\r
258                 IN                      Control_t               *pControl )\r
259 {\r
260         RecvIo_t                                *pRecvIo;\r
261         Inic_ControlPacket_t    *pPkt;\r
262         LIST_ENTRY                              *p_list_entry;\r
263 \r
264         VNIC_ENTER( VNIC_DBG_CTRL );\r
265 \r
266         pRecvIo = InterlockedExchangePointer( &pControl->pInfo, NULL );\r
267 \r
268         if ( pRecvIo != NULL )\r
269         {\r
270                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_INFO,\r
271                                 ("%s: processing info packet\n",\r
272                                                 control_ifcfg_name(pControl)) );\r
273         \r
274                 pPkt = control_packet( pRecvIo );\r
275 \r
276                 if ( pPkt->hdr.pktCmd == CMD_REPORT_STATUS )\r
277                 {\r
278                         switch( ntoh32(pPkt->cmd.reportStatus.statusNumber) )\r
279                         {\r
280                         case INIC_STATUS_LINK_UP:\r
281                                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_INFO,\r
282                                                         ("%s: Link Up\n",\r
283                                                                         control_ifcfg_name(pControl)) );\r
284 \r
285                                 viport_linkUp( pControl->p_viport );\r
286                                 break;\r
287 \r
288                         case INIC_STATUS_LINK_DOWN:\r
289                                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_INFO,\r
290                                                         ("%s: Link Down\n",\r
291                                                                         control_ifcfg_name(pControl)) );\r
292 \r
293                                 viport_linkDown( pControl->p_viport );\r
294                                 break;\r
295 \r
296                         default:\r
297                                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
298                                                 ("%s: Asynchronous status received from EIOC\n",\r
299                                                                         control_ifcfg_name(pControl)) );\r
300                                 __control_logControlPacket( pPkt );\r
301                                 break;\r
302                         }\r
303                 }\r
304 \r
305                 if (  pPkt->hdr.pktCmd != CMD_REPORT_STATUS ||\r
306                           pPkt->cmd.reportStatus.isFatal )\r
307                 {\r
308                         viport_failure( pControl->p_viport );\r
309                 }\r
310 \r
311                 control_recv( pControl, pRecvIo );\r
312         }\r
313 \r
314         while ( !IsListEmpty( &pControl->failureList ) )\r
315         {\r
316 \r
317                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_INFO,\r
318                                         ("%s: processing error packet\n",\r
319                                                                 control_ifcfg_name(pControl)) );\r
320 \r
321                 p_list_entry = ExInterlockedRemoveHeadList( &pControl->failureList, &pControl->ioLock );\r
322                 pRecvIo = (RecvIo_t *)p_list_entry;\r
323                 pPkt = control_packet( pRecvIo );\r
324 \r
325                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_INFO,\r
326                                         ("%s: Asynchronous error received from EIOC\n",\r
327                                                                 control_ifcfg_name(pControl)) );\r
328         \r
329                 __control_logControlPacket( pPkt );\r
330 \r
331                 if ( ( pPkt->hdr.pktType != TYPE_ERR ) ||\r
332                          ( pPkt->hdr.pktCmd != CMD_REPORT_STATUS ) ||\r
333                      ( pPkt->cmd.reportStatus.isFatal ) )\r
334                 {\r
335                         viport_failure( pControl->p_viport );\r
336                 }\r
337 \r
338                 control_recv( pControl, pRecvIo );\r
339         }\r
340 \r
341         VNIC_EXIT( VNIC_DBG_CTRL );\r
342 }\r
343 \r
344 \r
345 ib_api_status_t\r
346 control_initInicReq(\r
347         IN                      Control_t                *pControl )\r
348 {\r
349         ControlConfig_t                 *p_conf = pControl->p_conf;\r
350         Inic_ControlPacket_t    *pPkt;\r
351         Inic_CmdInitInicReq_t   *pInitInicReq;\r
352         ib_api_status_t                 ib_status;\r
353 \r
354         VNIC_ENTER( VNIC_DBG_CTRL );\r
355 \r
356         control_initHdr( pControl, CMD_INIT_INIC );\r
357 \r
358         pPkt                           = control_packet( &pControl->sendIo );\r
359         pInitInicReq                   = &pPkt->cmd.initInicReq;\r
360         pInitInicReq->inicMajorVersion = hton16( INIC_MAJORVERSION );\r
361         pInitInicReq->inicMinorVersion = hton16( INIC_MINORVERSION );\r
362         pInitInicReq->inicInstance = p_conf->inicInstance;\r
363         pInitInicReq->numDataPaths = 1;\r
364         pInitInicReq->numAddressEntries = hton16( p_conf->maxAddressEntries );\r
365 \r
366         ib_status = control_send( pControl );\r
367         VNIC_EXIT( VNIC_DBG_CTRL );\r
368         return ib_status;\r
369 }\r
370 \r
371 \r
372 BOOLEAN\r
373 control_initInicRsp(\r
374                 IN              Control_t               *pControl,\r
375                 IN              uint32_t                *pFeatures,\r
376                 IN              uint8_t                 *pMacAddress,\r
377                 IN              uint16_t                *pNumAddrs,\r
378                 IN              uint16_t                *pVlan )\r
379 {\r
380         RecvIo_t              *pRecvIo;\r
381         ControlConfig_t       *p_conf = pControl->p_conf;\r
382         Inic_ControlPacket_t  *pPkt;\r
383         Inic_CmdInitInicRsp_t *pInitInicRsp;\r
384         uint8_t               numDataPaths,\r
385                               numLanSwitches;\r
386 \r
387         VNIC_ENTER( VNIC_DBG_CTRL );\r
388 \r
389         pRecvIo = control_getRsp( pControl );\r
390         if (!pRecvIo)\r
391                 return FALSE;\r
392 \r
393         pPkt = control_packet( pRecvIo );\r
394 \r
395         if ( pPkt->hdr.pktCmd != CMD_INIT_INIC )\r
396         {\r
397         \r
398                 VNIC_TRACE( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
399                                         ("%s: Sent control request:\n",\r
400                                                 control_ifcfg_name(pControl)) );\r
401 \r
402                 __control_logControlPacket( control_lastReq( pControl ) );\r
403 \r
404                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
405                                         ("%s: Received control response:\n",\r
406                                                         control_ifcfg_name(pControl)) );\r
407         \r
408                 __control_logControlPacket( pPkt );\r
409                 goto failure;\r
410         }\r
411         pInitInicRsp     = &pPkt->cmd.initInicRsp;\r
412         pControl->majVer = ntoh16( pInitInicRsp->inicMajorVersion );\r
413         pControl->minVer = ntoh16( pInitInicRsp->inicMinorVersion );\r
414         numDataPaths     = pInitInicRsp->numDataPaths;\r
415         numLanSwitches   = pInitInicRsp->numLanSwitches;\r
416         *pFeatures       = ntoh32( pInitInicRsp->featuresSupported );\r
417         *pNumAddrs       = ntoh16( pInitInicRsp->numAddressEntries );\r
418 \r
419         if ( ( pControl->majVer > INIC_MAJORVERSION ) ||\r
420                  (( pControl->majVer == INIC_MAJORVERSION ) &&\r
421               ( pControl->minVer > INIC_MINORVERSION )) )\r
422         {\r
423                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
424                                 ("%s: Unsupported version\n",\r
425                                                 control_ifcfg_name(pControl)) );\r
426                 goto failure;\r
427         }\r
428 \r
429         if ( numDataPaths != 1 )\r
430         {\r
431                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
432                                         ("%s: EIOC returned too many datapaths\n",\r
433                                                         control_ifcfg_name(pControl)) );\r
434                 goto failure;\r
435         }\r
436 \r
437         if ( *pNumAddrs > p_conf->maxAddressEntries )\r
438         {\r
439                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
440                                 ("%s: EIOC returned more Address entries than requested\n",\r
441                                                 control_ifcfg_name(pControl)) );\r
442                 goto failure;\r
443         }\r
444         if ( *pNumAddrs < p_conf->minAddressEntries )\r
445         {\r
446                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
447                                         ("%s: Not enough address entries\n",\r
448                                                         control_ifcfg_name(pControl)) );\r
449                 goto failure;\r
450         }\r
451         if ( numLanSwitches < 1 )\r
452         {\r
453                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
454                                         ("%s: EIOC returned no lan switches\n",\r
455                                                         control_ifcfg_name(pControl)) );\r
456                 goto failure;\r
457         }\r
458         if ( numLanSwitches > 1 )\r
459         {\r
460                 VNIC_TRACE_EXIT( VNIC_DBG_CTRL | VNIC_DBG_ERROR,\r
461                                         ("%s: EIOC returned multiple lan switches\n",\r
462                                                         control_ifcfg_name(pControl)) );\r
463                 goto failure;\r
464         }\r
465 \r
466         pControl->lanSwitch.lanSwitchNum =\r
467                 pInitInicRsp->lanSwitch[0].lanSwitchNum ;\r
468         pControl->lanSwitch.numEnetPorts =\r
469                 pInitInicRsp->lanSwitch[0].numEnetPorts ;\r
470         pControl->lanSwitch.defaultVlan =\r
471                 ntoh16( pInitInicRsp->lanSwitch[0].defaultVlan );\r
472         *pVlan = pControl->lanSwitch.defaultVlan;\r
473         cl_memcpy( pControl->lanSwitch.hwMacAddress,\r
474                                 pInitInicRsp->lanSwitch[0].hwMacAddress, MAC_ADDR_LEN );\r
475         cl_memcpy( pMacAddress,\r
476                                 pInitInicRsp->lanSwitch[0].hwMacAddress, MAC_ADDR_LEN);\r
477 \r
478         control_recv( pControl, pRecvIo );\r
479 \r
480         VNIC_EXIT( VNIC_DBG_CTRL );\r
481         return TRUE;\r
482 failure:\r
483         viport_failure( pControl->p_viport );\r
484         return FALSE;\r
485 }\r
486 \r
487 \r
488 ib_api_status_t\r
489 control_configDataPathReq(\r
490                 IN              Control_t                               *pControl,\r
491                 IN              uint64_t                                pathId,\r
492                 IN              Inic_RecvPoolConfig_t   *pHost,\r
493                 IN              Inic_RecvPoolConfig_t   *pEioc )\r
494 {\r
495         Inic_ControlPacket_t            *pPkt;\r
496         Inic_CmdConfigDataPath_t        *pConfigDataPath;\r
497         ib_api_status_t                         ib_status;\r
498 \r
499         VNIC_ENTER( VNIC_DBG_CTRL );\r
500 \r
501         control_initHdr( pControl, CMD_CONFIG_DATA_PATH );\r
502 \r
503         pPkt                            = control_packet( &pControl->sendIo );\r
504         pConfigDataPath                 = &pPkt->cmd.configDataPathReq;\r
505         NdisZeroMemory( pConfigDataPath, sizeof( Inic_CmdConfigDataPath_t ) );\r
506         pConfigDataPath->dataPath       = 0;\r
507         pConfigDataPath->pathIdentifier = pathId;\r
508         copyRecvPoolConfig( pHost, &pConfigDataPath->hostRecvPoolConfig );\r
509         copyRecvPoolConfig( pEioc, &pConfigDataPath->eiocRecvPoolConfig );\r
510 \r
511         ib_status = control_send( pControl );\r
512         VNIC_EXIT( VNIC_DBG_CTRL );\r
513         return ib_status;\r
514 }\r
515 \r
516 \r
517 BOOLEAN\r
518 control_configDataPathRsp(\r
519                 IN              Control_t                               *pControl,\r
520                 IN              Inic_RecvPoolConfig_t   *pHost,\r
521                 IN              Inic_RecvPoolConfig_t   *pEioc,\r
522                 IN              Inic_RecvPoolConfig_t   *pMaxHost,\r
523                 IN              Inic_RecvPoolConfig_t   *pMaxEioc,\r
524                 IN              Inic_RecvPoolConfig_t   *pMinHost,\r
525                 IN              Inic_RecvPoolConfig_t   *pMinEioc )\r
526 {\r
527         RecvIo_t                 *pRecvIo;\r
528         Inic_ControlPacket_t     *pPkt;\r
529         Inic_CmdConfigDataPath_t *pConfigDataPath;\r
530 \r
531         VNIC_ENTER( VNIC_DBG_CTRL );\r
532 \r
533         pRecvIo = control_getRsp( pControl );\r
534         if ( !pRecvIo )\r
535                 return FALSE;\r
536 \r
537         pPkt = control_packet( pRecvIo );\r
538 \r
539         if ( pPkt->hdr.pktCmd != CMD_CONFIG_DATA_PATH )\r
540         {\r
541                 VNIC_TRACE( VNIC_DBG_ERROR,\r
542                         ("%s: Sent control request:\n",\r
543                                         control_ifcfg_name(pControl)) );\r
544 \r
545                 __control_logControlPacket( control_lastReq( pControl ) );\r
546 \r
547                 VNIC_TRACE( VNIC_DBG_ERROR,\r
548                         ("%s: Received control response:\n",\r
549                                                 control_ifcfg_name( pControl )) );\r
550         \r
551                 __control_logControlPacket( pPkt );\r
552                 goto failure;\r
553         }\r
554 \r
555         pConfigDataPath = &pPkt->cmd.configDataPathRsp;\r
556 \r
557         if ( pConfigDataPath->dataPath  != 0 )\r
558         {\r
559                 VNIC_TRACE( VNIC_DBG_ERROR,\r
560                         ("%s: Received CMD_CONFIG_DATA_PATH response for wrong data path: %u\n",\r
561                                         control_ifcfg_name( pControl ), pConfigDataPath->dataPath) );\r
562                 goto failure;\r
563         }\r
564 \r
565         if ( !checkRecvPoolConfig(&pConfigDataPath->hostRecvPoolConfig,\r
566                                  pHost, pMaxHost, pMinHost )\r
567                 || !checkRecvPoolConfig(&pConfigDataPath->eiocRecvPoolConfig,\r
568                                 pEioc, pMaxEioc, pMinEioc))\r
569         {\r
570                 goto failure;\r
571         }\r
572 \r
573         control_recv( pControl, pRecvIo );\r
574 \r
575         VNIC_EXIT( VNIC_DBG_CTRL );\r
576         return TRUE;\r
577 failure:\r
578         viport_failure( pControl->p_viport );\r
579         VNIC_EXIT( VNIC_DBG_CTRL );\r
580         return FALSE;\r
581 }\r
582 \r
583 \r
584 ib_api_status_t\r
585 control_exchangePoolsReq(\r
586                 IN                      Control_t               *pControl,\r
587                 IN                      uint64_t                 addr,\r
588                 IN                      uint32_t                rkey )\r
589 {\r
590         Inic_CmdExchangePools_t *pExchangePools;\r
591         Inic_ControlPacket_t    *pPkt;\r
592         ib_api_status_t                 ib_status;\r
593 \r
594         VNIC_ENTER( VNIC_DBG_CTRL );\r
595 \r
596         control_initHdr(pControl, CMD_EXCHANGE_POOLS );\r
597 \r
598         pPkt                     = control_packet( &pControl->sendIo );\r
599         pExchangePools           = &pPkt->cmd.exchangePoolsReq;\r
600         NdisZeroMemory( pExchangePools, sizeof( Inic_CmdExchangePools_t ) );\r
601         pExchangePools->dataPath =      0;\r
602         pExchangePools->poolRKey = rkey;\r
603         pExchangePools->poolAddr = hton64( addr );\r
604 \r
605         ib_status = control_send( pControl );\r
606         VNIC_EXIT( VNIC_DBG_CTRL );\r
607         return ib_status;\r
608 }\r
609 \r
610 \r
611 BOOLEAN\r
612 control_exchangePoolsRsp(\r
613                 IN                      Control_t                       *pControl,\r
614                 IN      OUT             uint64_t                        *pAddr,\r
615                 IN      OUT             uint32_t                        *pRkey )\r
616 {\r
617         RecvIo_t                *pRecvIo;\r
618         Inic_ControlPacket_t    *pPkt;\r
619         Inic_CmdExchangePools_t *pExchangePools;\r
620 \r
621         VNIC_ENTER( VNIC_DBG_CTRL );\r
622 \r
623         pRecvIo = control_getRsp( pControl );\r
624         if ( !pRecvIo )\r
625                 return FALSE;\r
626 \r
627         pPkt = control_packet( pRecvIo );\r
628 \r
629         if ( pPkt->hdr.pktCmd != CMD_EXCHANGE_POOLS )\r
630         {\r
631                 VNIC_TRACE( VNIC_DBG_ERROR,\r
632                         ("%s: Sent control request:\n",\r
633                                         control_ifcfg_name(pControl)) );\r
634 \r
635                 __control_logControlPacket( control_lastReq(pControl ) );\r
636 \r
637                 VNIC_TRACE( VNIC_DBG_ERROR,\r
638                         ("%s: Received control response:\n",\r
639                                         control_ifcfg_name(pControl)) );\r
640         \r
641                 __control_logControlPacket( pPkt );\r
642                 goto failure;\r
643         }\r
644 \r
645         pExchangePools = &pPkt->cmd.exchangePoolsRsp;\r
646         *pRkey         = pExchangePools->poolRKey;\r
647         *pAddr         = ntoh64( pExchangePools->poolAddr );\r
648 \r
649         if ( hton32( pExchangePools->dataPath ) != 0 )\r
650         {\r
651                 VNIC_TRACE_EXIT( VNIC_DBG_ERROR,\r
652                         ("%s: Received CMD_EXCHANGE_POOLS response for wrong data path: %u\n",\r
653                                         control_ifcfg_name(pControl), pExchangePools->dataPath ) );\r
654                 goto failure;\r
655         }\r
656 \r
657         control_recv( pControl, pRecvIo );\r
658 \r
659         VNIC_EXIT( VNIC_DBG_CTRL );\r
660         return TRUE;\r
661 \r
662 failure:\r
663         viport_failure( pControl->p_viport );\r
664         return FALSE;\r
665 }\r
666 \r
667 \r
668 ib_api_status_t\r
669 control_configLinkReq(\r
670                 IN              Control_t               *pControl,\r
671                 IN              uint8_t                 flags,\r
672                 IN              uint16_t                 mtu )\r
673 {\r
674         Inic_CmdConfigLink_t    *pConfigLinkReq;\r
675         Inic_ControlPacket_t    *pPkt;\r
676         ib_api_status_t                 ib_status;\r
677 \r
678         VNIC_ENTER( VNIC_DBG_CTRL );\r
679 \r
680         control_initHdr( pControl, CMD_CONFIG_LINK );\r
681 \r
682         pPkt                         = control_packet( &pControl->sendIo );\r
683         pConfigLinkReq               = &pPkt->cmd.configLinkReq;\r
684         NdisZeroMemory( pConfigLinkReq, sizeof( Inic_CmdConfigLink_t ) );\r
685         pConfigLinkReq->lanSwitchNum = pControl->lanSwitch.lanSwitchNum;\r
686         pConfigLinkReq->cmdFlags     = INIC_FLAG_SET_MTU;\r
687 \r
688         if ( flags & INIC_FLAG_ENABLE_NIC )\r
689         {\r
690                 pConfigLinkReq->cmdFlags |= INIC_FLAG_ENABLE_NIC;\r
691         }\r
692         else\r
693         {\r
694                 pConfigLinkReq->cmdFlags |= INIC_FLAG_DISABLE_NIC;\r
695         }\r
696 \r
697         if (flags & INIC_FLAG_ENABLE_MCAST_ALL )\r
698         {\r
699                 pConfigLinkReq->cmdFlags |= INIC_FLAG_ENABLE_MCAST_ALL;\r
700         }\r
701         else\r
702         {\r
703                 pConfigLinkReq->cmdFlags |= INIC_FLAG_DISABLE_MCAST_ALL;\r
704         }\r
705         if (flags & INIC_FLAG_ENABLE_PROMISC )\r
706         {\r
707                 pConfigLinkReq->cmdFlags |= INIC_FLAG_ENABLE_PROMISC;\r
708                 /* The EIOU doesn't really do PROMISC mode.\r
709                  * If PROMISC is set, it only receives unicast packets\r
710                  * I also have to set MCAST_ALL if I want real\r
711                  * PROMISC mode.\r
712                  */\r
713                 pConfigLinkReq->cmdFlags &= ~INIC_FLAG_DISABLE_MCAST_ALL;\r
714                 pConfigLinkReq->cmdFlags |= INIC_FLAG_ENABLE_MCAST_ALL;\r
715         }\r
716         else\r
717         {\r
718                 pConfigLinkReq->cmdFlags |= INIC_FLAG_DISABLE_PROMISC;\r
719         }\r
720         pConfigLinkReq->mtuSize      = hton16( mtu );\r
721 \r
722         ib_status = control_send( pControl );\r
723         VNIC_EXIT( VNIC_DBG_CTRL );\r
724         return ib_status;\r
725 }\r
726 \r
727 \r
728 BOOLEAN\r
729 control_configLinkRsp(\r
730                 IN                      Control_t               *pControl,\r
731                 IN      OUT             uint8_t         *pFlags,\r
732                 IN      OUT             uint16_t                *pMtu )\r
733 {\r
734         RecvIo_t             *pRecvIo;\r
735         Inic_ControlPacket_t *pPkt;\r
736         Inic_CmdConfigLink_t *pConfigLinkRsp;\r
737 \r
738         VNIC_ENTER( VNIC_DBG_CTRL );\r
739 \r
740         pRecvIo = control_getRsp( pControl );\r
741         if ( !pRecvIo )\r
742                 return FALSE;\r
743 \r
744         pPkt = control_packet( pRecvIo );\r
745         if ( pPkt->hdr.pktCmd != CMD_CONFIG_LINK )\r
746         {\r
747                 VNIC_TRACE( VNIC_DBG_ERROR,\r
748                         ("%s: Sent control request:\n",\r
749                                 control_ifcfg_name( pControl )) );\r
750 \r
751                 __control_logControlPacket( control_lastReq( pControl ) );\r
752 \r
753                 VNIC_TRACE( VNIC_DBG_ERROR,\r
754                         ("%s: Received control response:\n",\r
755                                         control_ifcfg_name( pControl ))  );\r
756         \r
757                 __control_logControlPacket( pPkt );\r
758                 goto failure;\r
759         }\r
760 \r
761         pConfigLinkRsp = &pPkt->cmd.configLinkRsp;\r
762 \r
763         *pFlags = pConfigLinkRsp->cmdFlags;\r
764         *pMtu   = ntoh16( pConfigLinkRsp->mtuSize );\r
765 \r
766         control_recv( pControl, pRecvIo );\r
767 \r
768         VNIC_EXIT( VNIC_DBG_CTRL );\r
769         return TRUE;\r
770 \r
771 failure:\r
772         viport_failure( pControl->p_viport );\r
773         VNIC_EXIT( VNIC_DBG_CTRL );\r
774         return FALSE;\r
775 }\r
776 \r
777 /* control_configAddrsReq:\r
778  * Return values:\r
779  *          -1: failure\r
780  *           0: incomplete (successful operation, but more address\r
781  *              table entries to be updated)\r
782  *           1: complete\r
783  */\r
784 ib_api_status_t\r
785 control_configAddrsReq(\r
786         IN                              Control_t                       *pControl,\r
787         IN                              Inic_AddressOp_t        *pAddrs,\r
788         IN                              uint16_t                        num,\r
789                 OUT                     int32_t                         *pAddrQueryDone )\r
790 {\r
791         Inic_CmdConfigAddresses_t       *pConfigAddrsReq;\r
792         Inic_ControlPacket_t            *pPkt;\r
793         uint16_t                                        i;\r
794         uint8_t                                         j;\r
795         ib_api_status_t                         ib_status;\r
796 \r
797         VNIC_ENTER( VNIC_DBG_CTRL );\r
798 \r
799         control_initHdr( pControl, CMD_CONFIG_ADDRESSES );\r
800 \r
801         pPkt                          = control_packet( &pControl->sendIo );\r
802         pConfigAddrsReq               = &pPkt->cmd.configAddressesReq;\r
803         NdisZeroMemory( pConfigAddrsReq, sizeof( Inic_CmdConfigAddresses_t ) );\r
804         pConfigAddrsReq->lanSwitchNum = pControl->lanSwitch.lanSwitchNum;\r
805 \r
806         for ( i=0, j = 0; ( i < num ) && ( j < 16 ); i++ )\r
807         {\r
808                 if ( !pAddrs[i].operation )\r
809                         continue;\r
810 \r
811                 pConfigAddrsReq->listAddressOps[j].index     = hton16(i);\r
812                 pConfigAddrsReq->listAddressOps[j].operation = INIC_OP_SET_ENTRY;\r
813                 pConfigAddrsReq->listAddressOps[j].valid = pAddrs[i].valid;\r
814         \r
815                 cl_memcpy( pConfigAddrsReq->listAddressOps[j].address,\r
816                         pAddrs[i].address, MAC_ADDR_LEN );\r
817                 pConfigAddrsReq->listAddressOps[j].vlan = hton16( pAddrs[i].vlan );\r
818                 pAddrs[i].operation = 0;\r
819                 j++;\r
820         }\r
821         pConfigAddrsReq->numAddressOps = j;\r
822 \r
823         for ( ; i < num; i++ )\r
824         {\r
825                 if ( pAddrs[i].operation )\r
826                         break;\r
827         }\r
828         *pAddrQueryDone = (i == num);\r
829 \r
830         ib_status = control_send( pControl );\r
831         VNIC_EXIT( VNIC_DBG_CTRL );\r
832         return ib_status;\r
833 }\r
834 \r
835 \r
836 BOOLEAN\r
837 control_configAddrsRsp(\r
838                 IN              Control_t               *pControl )\r
839 {\r
840         RecvIo_t                  *pRecvIo;\r
841         Inic_ControlPacket_t      *pPkt;\r
842         Inic_CmdConfigAddresses_t *pConfigAddrsRsp;\r
843 \r
844         VNIC_ENTER( VNIC_DBG_CTRL );\r
845 \r
846         pRecvIo = control_getRsp( pControl );\r
847         if ( !pRecvIo )\r
848                 return FALSE;\r
849 \r
850         pPkt = control_packet( pRecvIo );\r
851         if ( pPkt->hdr.pktCmd != CMD_CONFIG_ADDRESSES )\r
852         {\r
853                 VNIC_TRACE( VNIC_DBG_ERROR,\r
854                         ("%s: Sent control request:\n",\r
855                                 control_ifcfg_name( pControl )) );\r
856 \r
857                 __control_logControlPacket( control_lastReq( pControl ) );\r
858 \r
859                 VNIC_TRACE_EXIT(VNIC_DBG_ERROR,\r
860                         ("%s: Received control response:\n",\r
861                                 control_ifcfg_name( pControl )) );\r
862 \r
863                 __control_logControlPacket( pPkt );\r
864         \r
865                 goto failure;\r
866         }\r
867 \r
868         pConfigAddrsRsp = &pPkt->cmd.configAddressesRsp;\r
869 \r
870         control_recv( pControl, pRecvIo );\r
871         VNIC_EXIT( VNIC_DBG_CTRL );\r
872         return TRUE;\r
873 \r
874 failure:\r
875         viport_failure( pControl->p_viport );\r
876         return FALSE;\r
877 }\r
878 \r
879 \r
880 ib_api_status_t\r
881 control_reportStatisticsReq(\r
882                 IN              Control_t               *pControl )\r
883 {\r
884         Inic_ControlPacket_t                    *pPkt;\r
885         Inic_CmdReportStatisticsReq_t   *pReportStatisticsReq;\r
886         ib_api_status_t                                 ib_status;\r
887 \r
888         VNIC_ENTER( VNIC_DBG_CTRL );\r
889 \r
890         control_initHdr( pControl, CMD_REPORT_STATISTICS );\r
891 \r
892         pPkt                               = control_packet( &pControl->sendIo );\r
893         pReportStatisticsReq               = &pPkt->cmd.reportStatisticsReq;\r
894         pReportStatisticsReq->lanSwitchNum = pControl->lanSwitch.lanSwitchNum;\r
895 \r
896         ib_status = control_send( pControl );\r
897         VNIC_EXIT( VNIC_DBG_CTRL );\r
898         return ib_status;\r
899 }\r
900 \r
901 \r
902 BOOLEAN\r
903 control_reportStatisticsRsp(\r
904                 IN              Control_t                                               *pControl,\r
905                 IN              Inic_CmdReportStatisticsRsp_t   *pStats )\r
906 {\r
907         RecvIo_t                      *pRecvIo;\r
908         Inic_ControlPacket_t          *pPkt;\r
909         Inic_CmdReportStatisticsRsp_t *pRepStatRsp;\r
910 \r
911         VNIC_ENTER( VNIC_DBG_CTRL );\r
912 \r
913         pRecvIo = control_getRsp( pControl );\r
914         if (!pRecvIo)\r
915                 return FALSE;\r
916 \r
917         pPkt = control_packet( pRecvIo );\r
918         if ( pPkt->hdr.pktCmd != CMD_REPORT_STATISTICS )\r
919         {\r
920                 VNIC_TRACE(VNIC_DBG_ERROR,\r
921                         ("%s: Sent control request:\n",\r
922                                         control_ifcfg_name( pControl )) );\r
923 \r
924                 __control_logControlPacket( control_lastReq( pControl ) );\r
925 \r
926                 VNIC_TRACE_EXIT(VNIC_DBG_ERROR,\r
927                         ("%s: Received control response:\n",\r
928                                 control_ifcfg_name( pControl ) ) );\r
929 \r
930                 __control_logControlPacket( pPkt );\r
931         \r
932                 goto failure;\r
933         }\r
934 \r
935         pRepStatRsp                 = &pPkt->cmd.reportStatisticsRsp;\r
936         pStats->ifInBroadcastPkts   = ntoh64(pRepStatRsp->ifInBroadcastPkts);\r
937         pStats->ifInMulticastPkts   = ntoh64(pRepStatRsp->ifInMulticastPkts);\r
938         pStats->ifInOctets          = ntoh64(pRepStatRsp->ifInOctets);\r
939         pStats->ifInUcastPkts       = ntoh64(pRepStatRsp->ifInUcastPkts);\r
940         pStats->ifInNUcastPkts      = ntoh64(pRepStatRsp->ifInNUcastPkts);\r
941         pStats->ifInUnderrun        = ntoh64(pRepStatRsp->ifInUnderrun);\r
942         pStats->ifInErrors          = ntoh64(pRepStatRsp->ifInErrors);\r
943         pStats->ifOutErrors         = ntoh64(pRepStatRsp->ifOutErrors);\r
944         pStats->ifOutOctets         = ntoh64(pRepStatRsp->ifOutOctets);\r
945         pStats->ifOutUcastPkts      = ntoh64(pRepStatRsp->ifOutUcastPkts);\r
946         pStats->ifOutMulticastPkts  = ntoh64(pRepStatRsp->ifOutMulticastPkts);\r
947         pStats->ifOutBroadcastPkts  = ntoh64(pRepStatRsp->ifOutBroadcastPkts);\r
948         pStats->ifOutNUcastPkts     = ntoh64(pRepStatRsp->ifOutNUcastPkts);\r
949         pStats->ifOutOk             = ntoh64(pRepStatRsp->ifOutOk);\r
950         pStats->ifInOk              = ntoh64(pRepStatRsp->ifInOk);\r
951         pStats->ifOutUcastBytes     = ntoh64(pRepStatRsp->ifOutUcastBytes);\r
952         pStats->ifOutMulticastBytes = ntoh64(pRepStatRsp->ifOutMulticastBytes);\r
953         pStats->ifOutBroadcastBytes = ntoh64(pRepStatRsp->ifOutBroadcastBytes);\r
954         pStats->ifInUcastBytes      = ntoh64(pRepStatRsp->ifInUcastBytes);\r
955         pStats->ifInMulticastBytes  = ntoh64(pRepStatRsp->ifInMulticastBytes);\r
956         pStats->ifInBroadcastBytes  = ntoh64(pRepStatRsp->ifInBroadcastBytes);\r
957         pStats->ethernetStatus      = ntoh64(pRepStatRsp->ethernetStatus);\r
958 \r
959         control_recv(pControl, pRecvIo);\r
960 \r
961         VNIC_EXIT( VNIC_DBG_CTRL );\r
962         return TRUE;\r
963 failure:\r
964         viport_failure( pControl->p_viport );\r
965         return FALSE;\r
966 }\r
967 \r
968 \r
969 ib_api_status_t\r
970 control_resetReq(\r
971         IN              Control_t               *pControl )\r
972 {\r
973         ib_api_status_t         ib_status;\r
974 \r
975         VNIC_ENTER( VNIC_DBG_CTRL );\r
976 \r
977         control_initHdr( pControl, CMD_RESET );\r
978         ib_status = control_send( pControl );\r
979 \r
980         VNIC_EXIT( VNIC_DBG_CTRL );\r
981         return ib_status;\r
982 }\r
983 \r
984 BOOLEAN\r
985 control_resetRsp(\r
986                 IN              Control_t               *pControl )\r
987 {\r
988         RecvIo_t                      *pRecvIo;\r
989         Inic_ControlPacket_t          *pPkt;\r
990 \r
991         VNIC_ENTER( VNIC_DBG_CTRL );\r
992 \r
993         pRecvIo = control_getRsp( pControl );\r
994         if ( !pRecvIo ) return FALSE;\r
995 \r
996         pPkt = control_packet( pRecvIo );\r
997 \r
998         if ( pPkt->hdr.pktCmd != CMD_RESET )\r
999         {\r
1000                 VNIC_TRACE( VNIC_DBG_ERROR,\r
1001                         ("%s: Sent control request:\n",\r
1002                                 control_ifcfg_name( pControl )) );\r
1003 \r
1004                 __control_logControlPacket( control_lastReq( pControl ) );\r
1005         \r
1006                 VNIC_TRACE( VNIC_DBG_ERROR,\r
1007                         ("%s: Received control response:\n",\r
1008                                 control_ifcfg_name( pControl )) );\r
1009 \r
1010                 __control_logControlPacket( pPkt );\r
1011 \r
1012                 goto failure;\r
1013         }\r
1014 \r
1015         control_recv( pControl, pRecvIo );\r
1016         VNIC_EXIT( VNIC_DBG_CTRL );\r
1017         return TRUE;\r
1018 failure:\r
1019         viport_failure( pControl->p_viport );\r
1020         VNIC_EXIT( VNIC_DBG_CTRL );\r
1021         return FALSE;\r
1022 }\r
1023 \r
1024 \r
1025 ib_api_status_t\r
1026 control_heartbeatReq(\r
1027                 IN              Control_t       *pControl,\r
1028                 IN              uint32_t        hbInterval )\r
1029 {\r
1030         Inic_ControlPacket_t    *pPkt;\r
1031         Inic_CmdHeartbeat_t             *pHeartbeatReq;\r
1032         ib_api_status_t                 ib_status;\r
1033 \r
1034         VNIC_ENTER( VNIC_DBG_CTRL );\r
1035 \r
1036         control_initHdr(pControl, CMD_HEARTBEAT);\r
1037 \r
1038         pPkt                      = control_packet(&pControl->sendIo);\r
1039         pHeartbeatReq             = &pPkt->cmd.heartbeatReq;\r
1040 \r
1041         /* pass timeout for the target in microseconds */\r
1042         pHeartbeatReq->hbInterval = hton32( hbInterval*1000 );\r
1043 \r
1044         ib_status = control_send( pControl );\r
1045         ASSERT( ib_status == IB_SUCCESS );\r
1046         VNIC_EXIT( VNIC_DBG_CTRL );\r
1047         return ib_status;\r
1048 }\r
1049 \r
1050 BOOLEAN\r
1051 control_heartbeatRsp(\r
1052                 IN              Control_t               *pControl )\r
1053 {\r
1054         RecvIo_t             *pRecvIo;\r
1055         Inic_ControlPacket_t *pPkt;\r
1056         Inic_CmdHeartbeat_t  *pHeartbeatRsp;\r
1057 \r
1058         VNIC_ENTER( VNIC_DBG_CTRL );\r
1059 \r
1060         pRecvIo = control_getRsp( pControl );\r
1061 \r
1062         if (!pRecvIo)\r
1063                 return FALSE;\r
1064 \r
1065         pPkt = control_packet(pRecvIo);\r
1066 \r
1067         if ( pPkt->hdr.pktCmd != CMD_HEARTBEAT )\r
1068         {\r
1069                 VNIC_TRACE( VNIC_DBG_ERROR,\r
1070                                 ("%s: Sent control request:\n",\r
1071                                         control_ifcfg_name(pControl)) );\r
1072         \r
1073                 __control_logControlPacket( control_lastReq(pControl) );\r
1074         \r
1075                 VNIC_TRACE( VNIC_DBG_ERROR,\r
1076                         ("%s: Received control response:\n",\r
1077                                         control_ifcfg_name(pControl)) );\r
1078         \r
1079                 __control_logControlPacket( pPkt );\r
1080                 goto failure;\r
1081         }\r
1082 \r
1083         pHeartbeatRsp = &pPkt->cmd.heartbeatRsp;\r
1084 \r
1085         control_recv( pControl, pRecvIo );\r
1086         VNIC_EXIT ( VNIC_DBG_CTRL );\r
1087         return TRUE;\r
1088 \r
1089 failure:\r
1090         viport_failure( pControl->p_viport );\r
1091         VNIC_EXIT ( VNIC_DBG_CTRL );\r
1092         return FALSE;\r
1093 }\r
1094 \r
1095 static void\r
1096 control_recv(\r
1097                 IN              Control_t               *pControl,\r
1098                 IN              RecvIo_t                *pRecvIo )\r
1099 {\r
1100         VNIC_ENTER( VNIC_DBG_CTRL );\r
1101 \r
1102         if ( ibqp_postRecv( &pControl->qp, &pRecvIo->io ) != IB_SUCCESS )\r
1103                 viport_failure( pControl->p_viport );\r
1104 \r
1105         VNIC_EXIT ( VNIC_DBG_CTRL );\r
1106 }\r
1107 \r
1108 \r
1109 static void\r
1110 control_recvComplete(\r
1111                 IN              Io_t            *pIo )\r
1112 {\r
1113         RecvIo_t             *pRecvIo = (RecvIo_t *)pIo;\r
1114         RecvIo_t             *pLastRecvIo;\r
1115         BOOLEAN                         status = FALSE;\r
1116         Control_t            *pControl = &pIo->pViport->control;\r
1117         viport_t                        *p_viport = pIo->pViport;\r
1118         Inic_ControlPacket_t *pPkt = control_packet(pRecvIo);\r
1119         Inic_ControlHeader_t *pCHdr = &pPkt->hdr;\r
1120 \r
1121         switch ( pCHdr->pktType )\r
1122         {\r
1123                 case TYPE_INFO:\r
1124                         pLastRecvIo = InterlockedExchangePointer( &pControl->pInfo, pRecvIo );\r
1125 \r
1126                         control_processAsync( pControl );\r
1127 \r
1128                         if ( pLastRecvIo )\r
1129                         {\r
1130                                 control_recv( pControl, pLastRecvIo );\r
1131                         }\r
1132                         return;\r
1133 \r
1134                 case TYPE_RSP:\r
1135                         break;\r
1136 \r
1137                 default:\r
1138                         //TODO: Should we ever reach this?  Who processes the list entries?\r
1139                         ASSERT( pCHdr->pktType == TYPE_INFO || pCHdr->pktType == TYPE_RSP );\r
1140                         ExInterlockedInsertTailList( &pRecvIo->io.listPtrs,\r
1141                                                                                  &pControl->failureList,\r
1142                                                                                  &pControl->ioLock );\r
1143                         return;\r
1144         }\r
1145 \r
1146         if( (pCHdr->pktSeqNum != pControl->seqNum) ||\r
1147                 !InterlockedExchange( (volatile LONG*)&pControl->rspExpected, FALSE ) )\r
1148         {\r
1149                 return;\r
1150         }\r
1151 \r
1152         InterlockedExchangePointer( &pControl->pResponse, pRecvIo );\r
1153 \r
1154         switch ( pCHdr->pktCmd )\r
1155         {\r
1156         case CMD_INIT_INIC:\r
1157                 status = control_initInicRsp( pControl,\r
1158                         &p_viport->featuresSupported,\r
1159                         p_viport->hwMacAddress,\r
1160                         &p_viport->numMacAddresses,\r
1161                         &p_viport->defaultVlan );\r
1162                 if( status )\r
1163                 {\r
1164                         InterlockedExchange(\r
1165                                 (volatile LONG*)&p_viport->linkState,\r
1166                                 (LONG)LINK_INITINICRSP );\r
1167                 }\r
1168                 InterlockedOr( &p_viport->updates, SYNC_QUERY );\r
1169                 break;\r
1170 \r
1171         case CMD_CONFIG_DATA_PATH:\r
1172                 status = control_configDataPathRsp( &p_viport->control,\r
1173                         data_hostPool( &p_viport->data ),\r
1174                         data_eiocPool( &p_viport->data ),\r
1175                         data_hostPoolMax( &p_viport->data ),\r
1176                         data_eiocPoolMax( &p_viport->data ),\r
1177                         data_hostPoolMin( &p_viport->data ),\r
1178                         data_eiocPoolMin( &p_viport->data ));\r
1179                 if( status )\r
1180                 {\r
1181                         InterlockedExchange(\r
1182                                 (volatile LONG*)&p_viport->linkState,\r
1183                                 (LONG)LINK_CONFIGDATAPATHRSP );\r
1184                 }\r
1185                 InterlockedOr( &p_viport->updates, SYNC_QUERY );\r
1186                 break;\r
1187 \r
1188         case CMD_EXCHANGE_POOLS:\r
1189                 status = control_exchangePoolsRsp( &p_viport->control,\r
1190                         data_remotePoolAddr( &p_viport->data ),\r
1191                         data_remotePoolRkey( &p_viport->data ) );\r
1192                 if( status )\r
1193                 {\r
1194                         InterlockedExchange(\r
1195                                 (volatile LONG*)&p_viport->linkState,\r
1196                                 (LONG)LINK_XCHGPOOLRSP );\r
1197                 }\r
1198                 InterlockedOr( &p_viport->updates, SYNC_QUERY );\r
1199                 break;\r
1200 \r
1201                 /* process other responses */\r
1202         case CMD_CONFIG_LINK:\r
1203                 status = control_configLinkRsp( &p_viport->control,\r
1204                         &p_viport->flags,\r
1205                         &p_viport->mtu );\r
1206                 if( status )\r
1207                 {\r
1208                         InterlockedExchange(\r
1209                                 (volatile LONG*)&p_viport->linkState,\r
1210                                 (LONG)LINK_CONFIGLINKRSP );\r
1211 \r
1212                         if( p_viport->flags & INIC_FLAG_ENABLE_NIC )\r
1213                         {\r
1214                                 InterlockedExchange( &p_viport->p_netpath->carrier, TRUE );\r
1215                         }\r
1216                         else\r
1217                         {\r
1218                                 InterlockedExchange( &p_viport->p_netpath->carrier, FALSE );\r
1219                         }\r
1220                         InterlockedAnd( &p_viport->updates, ~NEED_LINK_CONFIG );\r
1221                 }\r
1222                 break;\r
1223 \r
1224         case CMD_HEARTBEAT:\r
1225                 status = control_heartbeatRsp( pControl );\r
1226                 if( status &&\r
1227                         !p_viport->errored &&\r
1228                         !p_viport->disconnect )\r
1229                 {\r
1230                         status = FALSE;\r
1231                         viport_timer( p_viport, p_viport->port_config.hbInterval );\r
1232                 }\r
1233                 // Don't signal any waiting thread or start processing other updates.\r
1234                 return;\r
1235 \r
1236         case CMD_CONFIG_ADDRESSES:\r
1237                 status = control_configAddrsRsp( pControl );\r
1238                 if( status == TRUE )\r
1239                 {\r
1240                         if(     pControl->p_viport->addrs_query_done == 0 )\r
1241                         {\r
1242                                 // need more entries to send\r
1243                                 // TODO: Handle a send failure.\r
1244                                 control_configAddrsReq( pControl,\r
1245                                         pControl->p_viport->macAddresses,\r
1246                                         pControl->p_viport->numMacAddresses,\r
1247                                         &pControl->p_viport->addrs_query_done );\r
1248                                 // Don't signal any waiting thread or start processing other updates.\r
1249                                 return;\r
1250                         }\r
1251 \r
1252                         InterlockedAnd( &p_viport->updates, ~NEED_ADDRESS_CONFIG );\r
1253                         InterlockedExchange( (volatile LONG*)&p_viport->linkState,\r
1254                                 (LONG)LINK_CONFIGADDRSRSP );\r
1255                 }\r
1256                 break;\r
1257 \r
1258         case CMD_REPORT_STATISTICS:\r
1259                 status = control_reportStatisticsRsp( pControl, &p_viport->stats );\r
1260                 if ( status )\r
1261                 {\r
1262                         if( p_viport->stats.ethernetStatus > 0 )\r
1263                         {\r
1264                                 viport_linkUp( p_viport );\r
1265                         }\r
1266                         else\r
1267                         {\r
1268                                 viport_linkDown( p_viport );\r
1269                         }\r
1270                 }\r
1271                 InterlockedAnd( &p_viport->updates, ~NEED_STATS );\r
1272                 break;\r
1273 \r
1274         case CMD_RESET:\r
1275                 status = control_resetRsp( pControl );\r
1276                 if( status )\r
1277                 {\r
1278                         status = FALSE;\r
1279                         InterlockedExchange(\r
1280                                 (volatile LONG*)&p_viport->linkState,\r
1281                                 (LONG)LINK_RESETRSP );\r
1282                 }\r
1283                 break;\r
1284 \r
1285         default:\r
1286                 break;\r
1287         }\r
1288 \r
1289         if( _viport_process_query( p_viport, FALSE ) == STATUS_SUCCESS )\r
1290         {\r
1291                 /* Complete any pending set OID. */\r
1292                 vnic_resume_set_oids( p_viport->p_adapter );\r
1293         }\r
1294 \r
1295         if(     InterlockedAnd( &p_viport->updates, ~SYNC_QUERY ) & SYNC_QUERY )\r
1296                 cl_event_signal( &p_viport->conn_event );\r
1297 }\r
1298 \r
1299 \r
1300 static ib_api_status_t\r
1301 control_send(\r
1302         IN              Control_t               *pControl )\r
1303 {\r
1304         ib_api_status_t ib_status;\r
1305         Inic_ControlPacket_t *pPkt = control_packet(&pControl->sendIo);\r
1306 \r
1307         VNIC_ENTER ( VNIC_DBG_CTRL );\r
1308 \r
1309         ASSERT( !pControl->reqOutstanding );\r
1310         if ( InterlockedCompareExchange( (volatile LONG*)&pControl->reqOutstanding,\r
1311                                                                         TRUE, FALSE ) == TRUE )\r
1312         {\r
1313                 /* IF WE HIT THIS WE ARE HOSED!!!\r
1314                  * by the time we detect this error, the send buffer has been\r
1315                  * overwritten, and if we retry we will send garbage data.\r
1316                  */\r
1317                 VNIC_TRACE_EXIT( VNIC_DBG_ERROR,\r
1318                         ("IB Send never completed\n" ) );\r
1319                 viport_failure( pControl->p_viport );\r
1320                 return IB_ERROR;\r
1321         }\r
1322 \r
1323 #ifdef _DEBUG_\r
1324         __control_logControlPacket( pPkt );\r
1325 #endif\r
1326 \r
1327         InterlockedExchange( (volatile LONG*)&pControl->rspExpected,\r
1328                                                                                 (LONG)pPkt->hdr.pktCmd );\r
1329 \r
1330         control_timer( pControl, pControl->p_conf->rspTimeout );\r
1331 \r
1332 #ifdef VNIC_STATISTIC\r
1333         pControl->statistics.requestTime = cl_get_time_stamp();\r
1334 #endif /* VNIC_STATISTIC */\r
1335 \r
1336         ib_status = ibqp_postSend( &pControl->qp, &pControl->sendIo.io );\r
1337         if( ib_status != IB_SUCCESS )\r
1338         {\r
1339                 InterlockedExchange((volatile LONG*)&pControl->reqOutstanding, FALSE );\r
1340 \r
1341                 VNIC_TRACE( VNIC_DBG_ERROR,\r
1342                         ("%s: Failed to post send\n", control_ifcfg_name(pControl)) );\r
1343                 viport_failure( pControl->p_viport );\r
1344         }\r
1345 \r
1346         VNIC_EXIT( VNIC_DBG_CTRL );\r
1347         return ib_status;\r
1348 }\r
1349 \r
1350 \r
1351 static void\r
1352 control_sendComplete(\r
1353                 IN              Io_t            *pIo )\r
1354 {\r
1355         Control_t *pControl = &pIo->pViport->control;\r
1356 \r
1357         VNIC_ENTER( VNIC_DBG_CTRL );\r
1358 \r
1359         InterlockedExchange((volatile LONG*)&pControl->reqOutstanding, FALSE );\r
1360 \r
1361         VNIC_EXIT( VNIC_DBG_CTRL );\r
1362         return;\r
1363 }\r
1364 \r
1365 static void\r
1366 control_timeout(\r
1367                 IN              void    *p_context )\r
1368 {\r
1369         Control_t *pControl;\r
1370 \r
1371         VNIC_ENTER( VNIC_DBG_CTRL );\r
1372 \r
1373         pControl = (Control_t *)p_context;\r
1374 \r
1375         InterlockedExchange( (LONG *)&pControl->timerstate, (LONG)TIMER_EXPIRED );\r
1376 \r
1377         InterlockedExchange( (volatile LONG*)&pControl->rspExpected, FALSE );\r
1378 \r
1379         VNIC_EXIT( VNIC_DBG_CTRL );\r
1380         return;\r
1381 }\r
1382 \r
1383 static void\r
1384 control_timer(\r
1385                 IN              Control_t       *pControl,\r
1386                 IN              int                     timeout )\r
1387 {\r
1388         VNIC_ENTER( VNIC_DBG_CTRL );\r
1389 \r
1390         InterlockedExchange( (LONG *)&pControl->timerstate, (LONG)TIMER_ACTIVE );\r
1391 \r
1392         cl_timer_start(&pControl->timer, timeout);\r
1393 \r
1394         VNIC_EXIT( VNIC_DBG_CTRL );\r
1395         return;\r
1396 }\r
1397 \r
1398 static void\r
1399 control_timerStop(\r
1400                 IN                      Control_t       *pControl )\r
1401 {\r
1402         VNIC_ENTER( VNIC_DBG_CTRL );\r
1403 \r
1404 \r
1405         if ( ( InterlockedExchange( (LONG *)&pControl->timerstate,\r
1406                                                                                 (LONG)TIMER_IDLE )) == TIMER_ACTIVE )\r
1407         {\r
1408                 cl_timer_stop( &pControl->timer );\r
1409         }\r
1410 \r
1411         VNIC_EXIT( VNIC_DBG_CTRL );\r
1412         return;\r
1413 }\r
1414 \r
1415 static void\r
1416 control_initHdr(\r
1417                 IN              Control_t *             pControl,\r
1418                 IN              uint8_t                 cmd )\r
1419 {\r
1420         ControlConfig_t      *p_conf;\r
1421         Inic_ControlPacket_t *pPkt;\r
1422         Inic_ControlHeader_t *pHdr;\r
1423 \r
1424         VNIC_ENTER( VNIC_DBG_CTRL );\r
1425 \r
1426         p_conf = pControl->p_conf;\r
1427 \r
1428         pPkt = control_packet( &pControl->sendIo );\r
1429         pHdr = &pPkt->hdr;\r
1430 \r
1431         pHdr->pktType = TYPE_REQ;\r
1432         pHdr->pktCmd = cmd;\r
1433         pHdr->pktSeqNum = ++pControl->seqNum;\r
1434         pControl->reqRetryCounter = 0;\r
1435         pHdr->pktRetryCount = 0;\r
1436 \r
1437         VNIC_EXIT( VNIC_DBG_CTRL );\r
1438 }\r
1439 \r
1440 static RecvIo_t*\r
1441 control_getRsp(\r
1442                 IN                      Control_t               *pControl )\r
1443 {\r
1444         RecvIo_t                *pRecvIo;\r
1445 \r
1446         VNIC_ENTER ( VNIC_DBG_CTRL );\r
1447 \r
1448         pRecvIo = InterlockedExchangePointer( &pControl->pResponse, NULL );\r
1449 \r
1450         if ( pRecvIo != NULL )\r
1451         {\r
1452                 control_timerStop(pControl);\r
1453                 return pRecvIo;\r
1454         }\r
1455 \r
1456         if ( ( pControl->timerstate =\r
1457                                 InterlockedCompareExchange( (LONG *)&pControl->timerstate,\r
1458                                 (LONG)TIMER_IDLE, (LONG)TIMER_EXPIRED )) == TIMER_EXPIRED )\r
1459         {\r
1460                 Inic_ControlPacket_t *pPkt = control_packet( &pControl->sendIo );\r
1461                 Inic_ControlHeader_t *pHdr = &pPkt->hdr;\r
1462 \r
1463                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1464                                 ("%s: No response received from EIOC\n",\r
1465                                                 control_ifcfg_name(pControl)) );\r
1466 #ifdef VNIC_STATISTIC\r
1467                 pControl->statistics.timeoutNum++;\r
1468 #endif /* VNIC_STATISTIC */\r
1469 \r
1470                 pControl->reqRetryCounter++;\r
1471 \r
1472                 if ( pControl->reqRetryCounter >= pControl->p_conf->reqRetryCount )\r
1473                 {\r
1474                         VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1475                                 ("%s: Control packet retry exceeded\n",\r
1476                                                 control_ifcfg_name(pControl)) );\r
1477                         viport_failure(pControl->p_viport );\r
1478                 }\r
1479                 else\r
1480                 {\r
1481                         pHdr->pktRetryCount = pControl->reqRetryCounter;\r
1482                         control_send( pControl );\r
1483                 }\r
1484         }\r
1485         return NULL;\r
1486 }\r
1487 \r
1488 static void\r
1489 copyRecvPoolConfig(\r
1490                 IN                      Inic_RecvPoolConfig_t           *pSrc,\r
1491                 IN OUT          Inic_RecvPoolConfig_t           *pDst )\r
1492 {\r
1493 \r
1494         pDst->sizeRecvPoolEntry            = hton32(pSrc->sizeRecvPoolEntry);\r
1495         pDst->numRecvPoolEntries           = hton32(pSrc->numRecvPoolEntries);\r
1496         pDst->timeoutBeforeKick            = hton32(pSrc->timeoutBeforeKick);\r
1497         pDst->numRecvPoolEntriesBeforeKick = hton32(pSrc->numRecvPoolEntriesBeforeKick);\r
1498         pDst->numRecvPoolBytesBeforeKick   = hton32(pSrc->numRecvPoolBytesBeforeKick);\r
1499         pDst->freeRecvPoolEntriesPerUpdate = hton32(pSrc->freeRecvPoolEntriesPerUpdate);\r
1500         return;\r
1501 }\r
1502 \r
1503 static BOOLEAN\r
1504 checkRecvPoolConfigValue(\r
1505                 IN              void            *pSrc,\r
1506                 IN              void            *pDst,\r
1507                 IN              void            *pMax,\r
1508                 IN              void            *pMin,\r
1509                 IN              char            *name )\r
1510 {\r
1511         uint32_t value;\r
1512         uint32_t *p_src = (uint32_t *)pSrc;\r
1513         uint32_t *p_dst = (uint32_t *)pDst;\r
1514         uint32_t *p_min = (uint32_t *)pMin;\r
1515         uint32_t *p_max = (uint32_t *)pMax;\r
1516 \r
1517         UNREFERENCED_PARAMETER( name );\r
1518 \r
1519         value = ntoh32( *p_src );\r
1520 \r
1521         if (value > *p_max )\r
1522         {\r
1523                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1524                                         ("Value %s too large\n", name) );\r
1525                 return FALSE;\r
1526         }\r
1527         else if (value < *p_min )\r
1528         {\r
1529                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1530                                 ("Value %s too small\n", name) );\r
1531                 return FALSE;\r
1532         }\r
1533 \r
1534         *p_dst = value;\r
1535         return TRUE;\r
1536 }\r
1537 \r
1538 static BOOLEAN\r
1539 checkRecvPoolConfig(\r
1540                 IN              Inic_RecvPoolConfig_t           *pSrc,\r
1541                 IN              Inic_RecvPoolConfig_t           *pDst,\r
1542                 IN              Inic_RecvPoolConfig_t           *pMax,\r
1543                 IN              Inic_RecvPoolConfig_t           *pMin )\r
1544 {\r
1545         if (!checkRecvPoolConfigValue(&pSrc->sizeRecvPoolEntry, &pDst->sizeRecvPoolEntry,\r
1546             &pMax->sizeRecvPoolEntry, &pMin->sizeRecvPoolEntry, "sizeRecvPoolEntry")\r
1547         || !checkRecvPoolConfigValue(&pSrc->numRecvPoolEntries, &pDst->numRecvPoolEntries,\r
1548             &pMax->numRecvPoolEntries, &pMin->numRecvPoolEntries, "numRecvPoolEntries")\r
1549         || !checkRecvPoolConfigValue(&pSrc->timeoutBeforeKick, &pDst->timeoutBeforeKick,\r
1550             &pMax->timeoutBeforeKick, &pMin->timeoutBeforeKick, "timeoutBeforeKick")\r
1551         || !checkRecvPoolConfigValue(&pSrc->numRecvPoolEntriesBeforeKick,\r
1552             &pDst->numRecvPoolEntriesBeforeKick, &pMax->numRecvPoolEntriesBeforeKick,\r
1553             &pMin->numRecvPoolEntriesBeforeKick, "numRecvPoolEntriesBeforeKick")\r
1554         || !checkRecvPoolConfigValue(&pSrc->numRecvPoolBytesBeforeKick,\r
1555             &pDst->numRecvPoolBytesBeforeKick, &pMax->numRecvPoolBytesBeforeKick,\r
1556             &pMin->numRecvPoolBytesBeforeKick, "numRecvPoolBytesBeforeKick")\r
1557         || !checkRecvPoolConfigValue(&pSrc->freeRecvPoolEntriesPerUpdate,\r
1558             &pDst->freeRecvPoolEntriesPerUpdate, &pMax->freeRecvPoolEntriesPerUpdate,\r
1559             &pMin->freeRecvPoolEntriesPerUpdate, "freeRecvPoolEntriesPerUpdate"))\r
1560                 return FALSE;\r
1561 \r
1562         if ( !IsPowerOf2( pDst->numRecvPoolEntries ) )\r
1563         {\r
1564                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1565                         ("numRecvPoolEntries (%d) must be power of 2\n",\r
1566                                         pDst->numRecvPoolEntries) );\r
1567                 return FALSE;\r
1568         }\r
1569         if ( !IsPowerOf2( pDst->freeRecvPoolEntriesPerUpdate ) )\r
1570         {\r
1571                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1572                         ("freeRecvPoolEntriesPerUpdate (%d) must be power of 2\n",\r
1573                                         pDst->freeRecvPoolEntriesPerUpdate) );\r
1574                 return FALSE;\r
1575         }\r
1576         if ( pDst->freeRecvPoolEntriesPerUpdate >= pDst->numRecvPoolEntries )\r
1577         {\r
1578                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1579                         ("freeRecvPoolEntriesPerUpdate (%d) must be less than numRecvPoolEntries (%d)\n",\r
1580                         pDst->freeRecvPoolEntriesPerUpdate, pDst->numRecvPoolEntries) );\r
1581                         return FALSE;\r
1582         }\r
1583         if ( pDst->numRecvPoolEntriesBeforeKick >= pDst->numRecvPoolEntries )\r
1584         {\r
1585                 VNIC_TRACE( VNIC_DBG_CTRL| VNIC_DBG_ERROR,\r
1586                         ("numRecvPoolEntriesBeforeKick (%d) must be less than numRecvPoolEntries (%d)\n",\r
1587                                 pDst->numRecvPoolEntriesBeforeKick, pDst->numRecvPoolEntries) );\r
1588                         return FALSE;\r
1589         }\r
1590 \r
1591         return TRUE;\r
1592 }\r
1593 \r
1594 static void\r
1595 __control_logControlPacket(\r
1596                         IN              Inic_ControlPacket_t            *pPkt )\r
1597 {\r
1598         char *type;\r
1599         int i;\r
1600 \r
1601         switch( pPkt->hdr.pktType  )\r
1602         {\r
1603         case TYPE_INFO:\r
1604                 type = "TYPE_INFO";\r
1605                 break;\r
1606         case TYPE_REQ:\r
1607                 type = "TYPE_REQ";\r
1608                 break;\r
1609         case TYPE_RSP:\r
1610                 type = "TYPE_RSP";\r
1611                 break;\r
1612         case TYPE_ERR:\r
1613                 type = "TYPE_ERR";\r
1614                 break;\r
1615         default:\r
1616                 type = "UNKNOWN";\r
1617         }\r
1618         switch( pPkt->hdr.pktCmd  )\r
1619         {\r
1620         case CMD_INIT_INIC:\r
1621                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1622                         ("ControlPacket: pktType = %s, pktCmd = CMD_INIT_INIC\n", type ) );\r
1623                 VNIC_PRINT( VNIC_DBG_CTRL| VNIC_DBG_INFO,\r
1624                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1625                                                                 pPkt->hdr.pktSeqNum,\r
1626                                                                 pPkt->hdr.pktRetryCount) );\r
1627                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1628                         ("               inicMajorVersion = %u, inicMinorVersion = %u\n",\r
1629                                                                 ntoh16(pPkt->cmd.initInicReq.inicMajorVersion),\r
1630                                                                 ntoh16(pPkt->cmd.initInicReq.inicMinorVersion)) );\r
1631                 if (pPkt->hdr.pktType == TYPE_REQ)\r
1632                 {\r
1633                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1634                                 ("               inicInstance = %u, numDataPaths = %u\n",\r
1635                                pPkt->cmd.initInicReq.inicInstance,\r
1636                                pPkt->cmd.initInicReq.numDataPaths) );\r
1637                         VNIC_PRINT( VNIC_DBG_CTRL_PKT| VNIC_DBG_INFO,\r
1638                                 ("               numAddressEntries = %u\n",\r
1639                                                                 ntoh16(pPkt->cmd.initInicReq.numAddressEntries)) );\r
1640                 }\r
1641                 else\r
1642                 {\r
1643                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1644                                 ("               numLanSwitches = %u, numDataPaths = %u\n",\r
1645                                                                 pPkt->cmd.initInicRsp.numLanSwitches,\r
1646                                                                 pPkt->cmd.initInicRsp.numDataPaths) );\r
1647                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1648                                 ("               numAddressEntries = %u, featuresSupported = %08x\n",\r
1649                                                                 ntoh16(pPkt->cmd.initInicRsp.numAddressEntries),\r
1650                                                                 ntoh32(pPkt->cmd.initInicRsp.featuresSupported)) );\r
1651                         if (pPkt->cmd.initInicRsp.numLanSwitches != 0)\r
1652                         {\r
1653                                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1654                                 ("lanSwitch[0]  lanSwitchNum = %u, numEnetPorts = %08x\n",\r
1655                                        pPkt->cmd.initInicRsp.lanSwitch[0].lanSwitchNum,\r
1656                                        pPkt->cmd.initInicRsp.lanSwitch[0].numEnetPorts) );\r
1657                                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1658                                         ("               defaultVlan = %u, hwMacAddress = %02x:%02x:%02x:%02x:%02x:%02x\n",\r
1659                                                                 ntoh16(pPkt->cmd.initInicRsp.lanSwitch[0].defaultVlan),\r
1660                                                                 pPkt->cmd.initInicRsp.lanSwitch[0].hwMacAddress[0],\r
1661                                                                 pPkt->cmd.initInicRsp.lanSwitch[0].hwMacAddress[1],\r
1662                                                                 pPkt->cmd.initInicRsp.lanSwitch[0].hwMacAddress[2],\r
1663                                                                 pPkt->cmd.initInicRsp.lanSwitch[0].hwMacAddress[3],\r
1664                                                                 pPkt->cmd.initInicRsp.lanSwitch[0].hwMacAddress[4],\r
1665                                                                 pPkt->cmd.initInicRsp.lanSwitch[0].hwMacAddress[5]) );\r
1666                         }\r
1667                 }\r
1668                 break;\r
1669         case CMD_CONFIG_DATA_PATH:\r
1670                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1671                         ( "ControlPacket: pktType = %s, pktCmd = CMD_CONFIG_DATA_PATH\n", type) );\r
1672                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1673                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1674                                                                 pPkt->hdr.pktSeqNum,\r
1675                                                                 pPkt->hdr.pktRetryCount) );\r
1676                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1677                         ("               pathIdentifier = %"PRIx64", dataPath = %u\n",\r
1678                                                         pPkt->cmd.configDataPathReq.pathIdentifier,\r
1679                                                         pPkt->cmd.configDataPathReq.dataPath) );\r
1680         \r
1681                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1682                         ("Host Config    sizeRecvPoolEntry = %u, numRecvPoolEntries = %u\n",\r
1683                                         ntoh32(pPkt->cmd.configDataPathReq.hostRecvPoolConfig.sizeRecvPoolEntry),\r
1684                                         ntoh32(pPkt->cmd.configDataPathReq.hostRecvPoolConfig.numRecvPoolEntries)) );\r
1685         \r
1686                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1687                         ("               timeoutBeforeKick = %u, numRecvPoolEntriesBeforeKick = %u\n",\r
1688                                         ntoh32(pPkt->cmd.configDataPathReq.hostRecvPoolConfig.timeoutBeforeKick),\r
1689                                         ntoh32(pPkt->cmd.configDataPathReq.hostRecvPoolConfig.numRecvPoolEntriesBeforeKick)) );\r
1690         \r
1691                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1692                         ("               numRecvPoolBytesBeforeKick = %u, freeRecvPoolEntriesPerUpdate = %u\n",\r
1693                        ntoh32(pPkt->cmd.configDataPathReq.hostRecvPoolConfig.numRecvPoolBytesBeforeKick),\r
1694                        ntoh32(pPkt->cmd.configDataPathReq.hostRecvPoolConfig.freeRecvPoolEntriesPerUpdate)) );\r
1695 \r
1696                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1697                         ("Eioc Config    sizeRecvPoolEntry = %u, numRecvPoolEntries = %u\n",\r
1698                        ntoh32(pPkt->cmd.configDataPathReq.eiocRecvPoolConfig.sizeRecvPoolEntry),\r
1699                        ntoh32(pPkt->cmd.configDataPathReq.eiocRecvPoolConfig.numRecvPoolEntries)) );\r
1700 \r
1701                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1702                         ("               timeoutBeforeKick = %u, numRecvPoolEntriesBeforeKick = %u\n",\r
1703                        ntoh32(pPkt->cmd.configDataPathReq.eiocRecvPoolConfig.timeoutBeforeKick),\r
1704                        ntoh32(pPkt->cmd.configDataPathReq.eiocRecvPoolConfig.numRecvPoolEntriesBeforeKick)) );\r
1705 \r
1706                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1707                         ("               numRecvPoolBytesBeforeKick = %u, freeRecvPoolEntriesPerUpdate = %u\n",\r
1708                        ntoh32(pPkt->cmd.configDataPathReq.eiocRecvPoolConfig.numRecvPoolBytesBeforeKick),\r
1709                        ntoh32(pPkt->cmd.configDataPathReq.eiocRecvPoolConfig.freeRecvPoolEntriesPerUpdate)) );\r
1710                 break;\r
1711         case CMD_EXCHANGE_POOLS:\r
1712                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1713                         ("ControlPacket: pktType = %s, pktCmd = CMD_EXCHANGE_POOLS\n", type ) );\r
1714                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1715                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1716                                                         pPkt->hdr.pktSeqNum,\r
1717                                                         pPkt->hdr.pktRetryCount) );\r
1718                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1719                         ("               datapath = %u\n",\r
1720                                                 pPkt->cmd.exchangePoolsReq.dataPath) );\r
1721                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1722                         ("               poolRKey = %08x poolAddr = %"PRIx64"\n",\r
1723                                                 ntoh32(pPkt->cmd.exchangePoolsReq.poolRKey),\r
1724                                                 ntoh64(pPkt->cmd.exchangePoolsReq.poolAddr)) );\r
1725                 break;\r
1726         case CMD_CONFIG_ADDRESSES:\r
1727                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1728                         ( "ControlPacket: pktType = %s, pktCmd = CMD_CONFIG_ADDRESSES\n", type ) );\r
1729                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1730                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1731                                                         pPkt->hdr.pktSeqNum,\r
1732                                                         pPkt->hdr.pktRetryCount) );\r
1733                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1734                         ("               numAddressOps = %x, lanSwitchNum = %d\n",\r
1735                                                         pPkt->cmd.configAddressesReq.numAddressOps,\r
1736                                                         pPkt->cmd.configAddressesReq.lanSwitchNum) );\r
1737                 for (i = 0; ( i < pPkt->cmd.configAddressesReq.numAddressOps) && (i < 16); i++)\r
1738                 {\r
1739                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1740                                 ("               listAddressOps[%u].index = %u\n",\r
1741                                         i, ntoh16(pPkt->cmd.configAddressesReq.listAddressOps[i].index)) );\r
1742                        \r
1743                         switch(pPkt->cmd.configAddressesReq.listAddressOps[i].operation)\r
1744                         {\r
1745                         case INIC_OP_GET_ENTRY:\r
1746                                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1747                                         ("               listAddressOps[%u].operation = INIC_OP_GET_ENTRY\n", i) );\r
1748                                 break;\r
1749                         case INIC_OP_SET_ENTRY:\r
1750                                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1751                                         ("               listAddressOps[%u].operation = INIC_OP_SET_ENTRY\n", i) );\r
1752                                 break;\r
1753                         default:\r
1754                                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1755                                         ("               listAddressOps[%u].operation = UNKNOWN(%d)\n",\r
1756                                        i, pPkt->cmd.configAddressesReq.listAddressOps[i].operation) );\r
1757                                 break;\r
1758                         }\r
1759                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1760                                 ("               listAddressOps[%u].valid = %u\n",\r
1761                                i, pPkt->cmd.configAddressesReq.listAddressOps[i].valid) );\r
1762                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1763                                 ("               listAddressOps[%u].address = %02x:%02x:%02x:%02x:%02x:%02x\n", i,\r
1764                                         pPkt->cmd.configAddressesReq.listAddressOps[i].address[0],\r
1765                                         pPkt->cmd.configAddressesReq.listAddressOps[i].address[1],\r
1766                                         pPkt->cmd.configAddressesReq.listAddressOps[i].address[2],\r
1767                                         pPkt->cmd.configAddressesReq.listAddressOps[i].address[3],\r
1768                                         pPkt->cmd.configAddressesReq.listAddressOps[i].address[4],\r
1769                                         pPkt->cmd.configAddressesReq.listAddressOps[i].address[5]) );\r
1770 \r
1771                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1772                                 ("               listAddressOps[%u].vlan = %u\n",\r
1773                                i, ntoh16(pPkt->cmd.configAddressesReq.listAddressOps[i].vlan)) );\r
1774                 }\r
1775                 break;\r
1776         case CMD_CONFIG_LINK:\r
1777                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1778                         ("ControlPacket: pktType = %s, pktCmd = CMD_CONFIG_LINK\n", type) );\r
1779                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1780                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1781                        pPkt->hdr.pktSeqNum,\r
1782                        pPkt->hdr.pktRetryCount) );\r
1783                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1784                         ("               cmdFlags = %x\n",\r
1785                        pPkt->cmd.configLinkReq.cmdFlags) );\r
1786 \r
1787                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_ENABLE_NIC )\r
1788                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1789                                 ("                       INIC_FLAG_ENABLE_NIC\n") );\r
1790 \r
1791                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_DISABLE_NIC )\r
1792         \r
1793                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1794                                 ("                       INIC_FLAG_DISABLE_NIC\n") );\r
1795 \r
1796                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_ENABLE_MCAST_ALL )\r
1797                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1798                                 ("                       INIC_FLAG_ENABLE_MCAST_ALL\n") );\r
1799 \r
1800                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_DISABLE_MCAST_ALL )\r
1801                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1802                                 ("                       INIC_FLAG_DISABLE_MCAST_ALL\n") );\r
1803 \r
1804                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_ENABLE_PROMISC )\r
1805                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1806                                 ("                       INIC_FLAG_ENABLE_PROMISC\n") );\r
1807         \r
1808                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_DISABLE_PROMISC )\r
1809                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1810                                 ("                       INIC_FLAG_DISABLE_PROMISC\n") );\r
1811                 if ( pPkt->cmd.configLinkReq.cmdFlags & INIC_FLAG_SET_MTU )\r
1812                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1813                                 ("                       INIC_FLAG_SET_MTU\n") );\r
1814                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1815                                 ("               lanSwitchNum = %x, mtuSize = %d\n",\r
1816                                                 pPkt->cmd.configLinkReq.lanSwitchNum,\r
1817                                                 ntoh16(pPkt->cmd.configLinkReq.mtuSize)) );\r
1818                 if ( pPkt->hdr.pktType == TYPE_RSP )\r
1819                 {\r
1820                         VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1821                                 ("               defaultVlan = %u, hwMacAddress = %02x:%02x:%02x:%02x:%02x:%02x\n",\r
1822                                 ntoh16(pPkt->cmd.configLinkReq.defaultVlan),\r
1823                                 pPkt->cmd.configLinkReq.hwMacAddress[0],\r
1824                                 pPkt->cmd.configLinkReq.hwMacAddress[1],\r
1825                                 pPkt->cmd.configLinkReq.hwMacAddress[2],\r
1826                                 pPkt->cmd.configLinkReq.hwMacAddress[3],\r
1827                                 pPkt->cmd.configLinkReq.hwMacAddress[4],\r
1828                                 pPkt->cmd.configLinkReq.hwMacAddress[5]) );\r
1829                 }\r
1830                 break;\r
1831         case CMD_REPORT_STATISTICS:\r
1832                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1833                         ("ControlPacket: pktType = %s, pktCmd = CMD_REPORT_STATISTICS\n", type ) );\r
1834                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1835                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1836                         pPkt->hdr.pktSeqNum,\r
1837                         pPkt->hdr.pktRetryCount) );\r
1838                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1839                         ("               lanSwitchNum = %u\n",\r
1840                         pPkt->cmd.reportStatisticsReq.lanSwitchNum) );\r
1841 \r
1842                 if (pPkt->hdr.pktType == TYPE_REQ)\r
1843                         break;\r
1844                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1845                         ("               ifInBroadcastPkts = %"PRIu64,\r
1846                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInBroadcastPkts)) );\r
1847                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1848                         (" ifInMulticastPkts = %"PRIu64"\n",\r
1849                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInMulticastPkts)) );\r
1850                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1851                         ("               ifInOctets = %"PRIu64,\r
1852                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInOctets)) );\r
1853                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1854                         (" ifInUcastPkts = %"PRIu64"\n",\r
1855                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInUcastPkts)) );\r
1856                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1857                         ("               ifInNUcastPkts = %"PRIu64,\r
1858                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInNUcastPkts)) );\r
1859                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1860                         (" ifInUnderrun = %"PRIu64"\n",\r
1861                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInUnderrun)) );\r
1862                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1863                         ("               ifInErrors = %"PRIu64,\r
1864                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInErrors)) );\r
1865                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1866                         (" ifOutErrors = %"PRIu64"\n",\r
1867                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutErrors)) );\r
1868                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1869                         ("               ifOutOctets = %"PRIu64,\r
1870                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutOctets)) );\r
1871                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1872                         (" ifOutUcastPkts = %"PRIu64"\n",\r
1873                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutUcastPkts)) );\r
1874                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1875                         ("               ifOutMulticastPkts = %"PRIu64,\r
1876                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutMulticastPkts)) );\r
1877                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1878                         (" ifOutBroadcastPkts = %"PRIu64"\n",\r
1879                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutBroadcastPkts)) );\r
1880                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1881                         ("               ifOutNUcastPkts = %"PRIu64,\r
1882                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutNUcastPkts)) );\r
1883                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1884                         (" ifOutOk = %"PRIu64"\n",\r
1885                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutOk)) );\r
1886                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1887                         ("               ifInOk = %"PRIu64,\r
1888                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInOk)) );\r
1889                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1890                         (" ifOutUcastBytes = %"PRIu64"\n",\r
1891                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutUcastBytes)) );\r
1892                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1893                         ("               ifOutMulticastBytes = %"PRIu64,\r
1894                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutMulticastBytes)) );\r
1895                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1896                         (" ifOutBroadcastBytes = %"PRIu64"\n",\r
1897                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifOutBroadcastBytes)) );\r
1898                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1899                         ("               ifInUcastBytes = %"PRIu64,\r
1900                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInUcastBytes)) );\r
1901                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1902                         (" ifInMulticastBytes = %"PRIu64"\n",\r
1903                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInMulticastBytes)) );\r
1904                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1905                         ("               ifInBroadcastBytes = %"PRIu64,\r
1906                         ntoh64(pPkt->cmd.reportStatisticsRsp.ifInBroadcastBytes)) );\r
1907                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1908                         (" ethernetStatus = %"PRIu64"\n",\r
1909                         ntoh64(pPkt->cmd.reportStatisticsRsp.ethernetStatus)) );\r
1910                 break;\r
1911         case CMD_CLEAR_STATISTICS:\r
1912                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1913                         ("ControlPacket: pktType = %s, pktCmd = CMD_CLEAR_STATISTICS\n", type ) );\r
1914                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1915                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1916                         pPkt->hdr.pktSeqNum,\r
1917                         pPkt->hdr.pktRetryCount) );\r
1918                 break;\r
1919         case CMD_REPORT_STATUS:\r
1920                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1921                         ("ControlPacket: pktType = %s, pktCmd = CMD_REPORT_STATUS\n",\r
1922                         type) );\r
1923                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1924                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1925                         pPkt->hdr.pktSeqNum,\r
1926                         pPkt->hdr.pktRetryCount) );\r
1927                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1928                         ("               lanSwitchNum = %u, isFatal = %u\n",\r
1929                         pPkt->cmd.reportStatus.lanSwitchNum,\r
1930                         pPkt->cmd.reportStatus.isFatal) );\r
1931                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1932                         ("               statusNumber = %u, statusInfo = %u\n",\r
1933                         ntoh32(pPkt->cmd.reportStatus.statusNumber),\r
1934                         ntoh32(pPkt->cmd.reportStatus.statusInfo)) );\r
1935                 pPkt->cmd.reportStatus.fileName[31] = '\0';\r
1936                 pPkt->cmd.reportStatus.routine[31] = '\0';\r
1937                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1938                         ("               filename = %s, routine = %s\n",\r
1939                         pPkt->cmd.reportStatus.fileName,\r
1940                         pPkt->cmd.reportStatus.routine) );\r
1941                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1942                         ("               lineNum = %u, errorParameter = %u\n",\r
1943                         ntoh32(pPkt->cmd.reportStatus.lineNum),\r
1944                         ntoh32(pPkt->cmd.reportStatus.errorParameter)) );\r
1945                 pPkt->cmd.reportStatus.descText[127] = '\0';\r
1946                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1947                         ("               descText = %s\n",\r
1948                         pPkt->cmd.reportStatus.descText) );\r
1949                 break;\r
1950         case CMD_RESET:\r
1951                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1952                         ("ControlPacket: pktType = %s, pktCmd = CMD_RESET\n", type ) );\r
1953                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1954                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1955                         pPkt->hdr.pktSeqNum,\r
1956                         pPkt->hdr.pktRetryCount) );\r
1957                 break;\r
1958         case CMD_HEARTBEAT:\r
1959                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1960                         ("ControlPacket: pktType = %s, pktCmd = CMD_HEARTBEAT\n", type ) );\r
1961                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1962                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1963                         pPkt->hdr.pktSeqNum,\r
1964                         pPkt->hdr.pktRetryCount) );\r
1965                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1966                         ("               hbInterval = %d\n",\r
1967                         ntoh32(pPkt->cmd.heartbeatReq.hbInterval)) );\r
1968                 break;\r
1969         default:\r
1970                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1971                         ("ControlPacket: pktType = %s, pktCmd = UNKNOWN (%u)\n",\r
1972                         type,pPkt->hdr.pktCmd) );\r
1973                 VNIC_PRINT( VNIC_DBG_CTRL_PKT | VNIC_DBG_INFO,\r
1974                         ("               pktSeqNum = %u, pktRetryCount = %u\n",\r
1975                         pPkt->hdr.pktSeqNum,\r
1976                         pPkt->hdr.pktRetryCount) );\r
1977                 break;\r
1978         }\r
1979         return;\r
1980 }\r