[VNIC] Initial checkin of VNIC code. Not yet fully functional.
[mirror/winof/.git] / ulp / inic / kernel / vnic_control.h
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 #ifndef _VNIC_CONTROL_H_\r
33 #define _VNIC_CONTROL_H_\r
34 \r
35 #include "vnic_controlpkt.h"\r
36 #include "vnic_util.h"\r
37 \r
38 typedef enum {\r
39         TIMER_IDLE,\r
40         TIMER_ACTIVE,\r
41         TIMER_EXPIRED\r
42 }timerstate_t;\r
43 \r
44 typedef struct Control {\r
45         struct _viport       *p_viport;\r
46         struct ControlConfig *p_conf;\r
47         IbRegion_t           region;\r
48         IbQp_t              qp;\r
49         uint8_t              *pLocalStorage;\r
50         uint16_t             majVer;\r
51         uint16_t                         minVer;\r
52         Inic_LanSwitchAttributes_t lanSwitch;\r
53         SendIo_t             sendIo;\r
54         RecvIo_t             *pRecvIos;\r
55 \r
56         timerstate_t            timerstate;\r
57         cl_timer_t                      timer;\r
58         uint8_t                         reqRetryCounter;\r
59         uint8_t                         seqNum;\r
60         uint32_t                        reqOutstanding;\r
61         uint32_t                        rspExpected;\r
62         RecvIo_t                        *pResponse;\r
63         RecvIo_t                        *pInfo;\r
64         LIST_ENTRY                      failureList;\r
65         KSPIN_LOCK                      ioLock;\r
66 \r
67 #ifdef VNIC_STATISTIC\r
68         struct {\r
69                 uint64_t     requestTime; /* Intermediate value */\r
70                 uint64_t     responseTime;\r
71                 uint32_t     responseNum;\r
72                 uint64_t     responseMax;\r
73                 uint64_t     responseMin;\r
74                 uint32_t     timeoutNum;\r
75         } statistics;\r
76 #endif /* VNIC_STATISTIC */\r
77 } Control_t;\r
78 \r
79 void\r
80 control_construct(\r
81         IN              Control_t                       *pControl,\r
82         IN              struct _viport          *pViport );\r
83 \r
84 ib_api_status_t control_init(Control_t *pControl, struct _viport *pViport,\r
85                      struct ControlConfig *p_conf, uint64_t guid);\r
86 void    control_cleanup(Control_t *pControl);\r
87 void    control_processAsync(Control_t *pControl);\r
88 ib_api_status_t control_initInicReq(Control_t *pControl);\r
89 BOOLEAN control_initInicRsp(Control_t *pControl, uint32_t *pFeatures,\r
90                             uint8_t *pMacAddress, uint16_t *pNumAddrs, uint16_t *pVlan);\r
91 ib_api_status_t control_configDataPathReq(Control_t *pControl, uint64_t pathId,\r
92                                   struct Inic_RecvPoolConfig *pHost,\r
93                                   struct Inic_RecvPoolConfig *pEioc);\r
94 BOOLEAN control_configDataPathRsp(Control_t *pControl,\r
95                                   struct Inic_RecvPoolConfig *pHost,\r
96                                   struct Inic_RecvPoolConfig *pEioc,\r
97                                   struct Inic_RecvPoolConfig *pMaxHost,\r
98                                   struct Inic_RecvPoolConfig *pMaxEioc,\r
99                                   struct Inic_RecvPoolConfig *pMinHost,\r
100                                   struct Inic_RecvPoolConfig *pMinEioc);\r
101 ib_api_status_t control_exchangePoolsReq(Control_t *pControl, uint64_t addr, uint32_t rkey);\r
102 BOOLEAN control_exchangePoolsRsp(Control_t *pControl, uint64_t *pAddr,\r
103                                  uint32_t *pRkey);\r
104 ib_api_status_t control_configLinkReq(Control_t *pControl, uint8_t flags, uint16_t mtu);\r
105 BOOLEAN control_configLinkRsp(Control_t *pControl, uint8_t *pFlags, uint16_t *pMtu);\r
106 ib_api_status_t control_configAddrsReq(Control_t *pControl, Inic_AddressOp_t *pAddrs,\r
107                                uint16_t num, int32_t *pAddrQueryDone);\r
108 BOOLEAN control_configAddrsRsp(Control_t *pControl);\r
109 ib_api_status_t control_reportStatisticsReq(Control_t *pControl);\r
110 BOOLEAN control_reportStatisticsRsp(Control_t *pControl,\r
111                                     struct Inic_CmdReportStatisticsRsp *pStats);\r
112 ib_api_status_t control_resetReq( Control_t *pControl );\r
113 BOOLEAN control_resetRsp(Control_t *pControl);\r
114 ib_api_status_t control_heartbeatReq(Control_t *pControl, uint32_t hbInterval);\r
115 BOOLEAN control_heartbeatRsp(Control_t *pControl);\r
116 \r
117 #define control_packet(pIo) (Inic_ControlPacket_t *)(LONG_PTR)((pIo)->dsList.vaddr )\r
118 #define control_lastReq(pControl) control_packet(&(pControl)->sendIo)\r
119 #define control_features(pControl) (pControl)->featuresSupported\r
120 #define control_getMacAddress(pControl,addr) \\r
121         memcpy(addr,(pControl)->lanSwitch.hwMacAddress,MAC_ADDR_LEN)\r
122 \r
123 #endif /* _VNIC_CONTROL_H_ */\r