[VNIC] Initial checkin of VNIC code. Not yet fully functional.
[mirror/winof/.git] / ulp / inic / kernel / vnic_adapter.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 #if !defined _VNIC_ADAPTER_H_\r
33 #define _VNIC_ADAPTER_H_\r
34 \r
35 #include <complib/comp_lib.h>\r
36 #include <iba/ib_al.h>\r
37 #include <initguid.h>\r
38 #include <ip_packet.h>\r
39 #include "vnic_ib.h"\r
40 #include "vnic_controlpkt.h"\r
41 #include "vnic_config.h"\r
42 #include "vnic_control.h"\r
43 #include "vnic_data.h"\r
44 #include "vnic_viport.h"\r
45 #include <iba/ioc_ifc.h>\r
46 \r
47 typedef struct _pending_oid\r
48 {\r
49         NDIS_OID                        oid;\r
50         PVOID                           p_buf;\r
51         ULONG                           buf_len;\r
52         PULONG                          p_bytes_used;\r
53         PULONG                          p_bytes_needed;\r
54 \r
55 }       pending_oid_t;\r
56 \r
57 typedef struct _ipv4_address_item\r
58 {\r
59         union _net_address_item_address\r
60         {\r
61                 ULONG                   as_ulong;\r
62                 UCHAR                   as_bytes[4];\r
63         }       address;\r
64 \r
65 }       ipv4_address_item_t;\r
66 \r
67 typedef struct _vnic_params {\r
68         uint32_t        MaxAddressEntries;\r
69         uint32_t        MinAddressEntries;\r
70         uint32_t        MinMtu;\r
71         uint32_t        MaxMtu;\r
72         uint32_t        HostRecvPoolEntries;\r
73         uint32_t        MinHostPoolSz;\r
74         uint32_t        MinEiocPoolSz;\r
75         uint32_t        MaxEiocPoolSz;\r
76         uint32_t        MinHostKickTimeout;\r
77         uint32_t        MaxHostKickTimeout;\r
78         uint32_t        MinHostKickEntries;\r
79         uint32_t        MaxHostKickEntries;\r
80         uint32_t        MinHostKickBytes;\r
81         uint32_t        MaxHostKickBytes;\r
82         uint32_t        MinHostUpdateSz;\r
83         uint32_t        MaxHostUpdateSz;\r
84         uint32_t        MinEiocUpdateSz;\r
85         uint32_t        MaxEiocUpdateSz;\r
86         uint32_t        NotifyBundleSz;\r
87         uint32_t        ViportStatsInterval;\r
88         uint32_t        ViportHbInterval;\r
89         uint32_t        ViportHbTimeout;\r
90         uint32_t        ControlRspTimeout;\r
91         uint32_t        ControlReqRetryCount;\r
92         uint32_t        RetryCount;\r
93         uint32_t        MinRnrTimer;\r
94         uint32_t        MaxViportsPerNetpath;\r
95         uint32_t        DefaultViportsPerNetpath;\r
96         uint32_t        DefaultPkey;\r
97         uint32_t        DefaultNoPathTimeout;\r
98         uint32_t        DefaultPrimaryConnectTimeout;\r
99         uint32_t        DefaultPrimaryReconnectTimeout;\r
100         uint32_t        DefaultPrimarySwitchTimeout;\r
101         uint32_t        DefaultPreferPrimary;\r
102         uint32_t        UseRxCsum;\r
103         uint32_t        UseTxCsum;\r
104         mac_addr_t      conf_mac;\r
105 }       vnic_params_t;\r
106 \r
107 \r
108 typedef struct _vnic_adapter {\r
109         LIST_ENTRY                              list_entry;\r
110         NDIS_HANDLE                             h_handle;\r
111         PDRIVER_OBJECT                  p_drv_obj;\r
112 //      cl_obj_t                                obj;\r
113         NDIS_SPIN_LOCK                  lock;\r
114         ib_al_ifc_t                             ifc;\r
115         ioc_ifc_data_t                  ifc_data;\r
116         ib_ioc_info_t                   ioc_info;\r
117         vnic_path_record_t              path_record;\r
118         ib_al_handle_t                  h_al;\r
119         ib_ca_handle_t                  h_ca;\r
120         ib_pnp_handle_t                 h_pnp;\r
121         ib_pnp_event_t                  pnp_state;\r
122         IbCa_t                                  ca;\r
123         struct _viport                  *p_viport;\r
124         InicState_t                             state;\r
125         struct Netpath                  primaryPath;\r
126         struct Netpath                  secondaryPath;\r
127         struct Netpath                  *p_currentPath;\r
128         vnic_params_t                   params;\r
129         int                                             open;\r
130         int                                             macSet;\r
131         int                                             mc_count;\r
132         mac_addr_t                              mcast_array[MAX_MCAST];\r
133         LONG                                    xmitStarted;\r
134         LONG                                    carrier;\r
135         uint32_t                                packet_filter;\r
136         BOOLEAN                                 hung;\r
137         BOOLEAN                                 pending_set;\r
138         BOOLEAN                                 pending_query;\r
139         pending_oid_t                   query_oid;\r
140         pending_oid_t                   set_oid;\r
141         uint8_t                                 num_svc_entries;\r
142         ib_svc_entry_t                  *p_svc_entries;\r
143         char                                    name[65];\r
144         InicNPEvent_t                   np_event[INICNP_NUM_EVENTS];\r
145 #ifdef VNIC_STATISTIC\r
146         struct {\r
147                 uint64_t                        startTime;\r
148                 uint64_t                        connTime;\r
149                 uint64_t                        disconnRef;     /* Intermediate time */\r
150                 uint64_t                        disconnTime;\r
151                 uint32_t                        disconnNum;\r
152                 uint64_t                        xmitTime;\r
153                 uint32_t                        xmitNum;\r
154                 uint32_t                        xmitFail;\r
155                 uint64_t                        recvTime;\r
156                 uint32_t                        recvNum;\r
157                 uint64_t                        xmitRef;        /* Intermediate time */\r
158                 uint64_t                        xmitOffTime;\r
159                 uint32_t                        xmitOffNum;\r
160                 uint64_t                        carrierRef;     /* Intermediate time */\r
161                 uint64_t                        carrierOffTime;\r
162                 uint32_t                        carrierOffNum;\r
163         }   statistics;\r
164 #endif /* VNIC_STATISTIC */\r
165 \r
166 } vnic_adapter_t;\r
167 \r
168 ib_api_status_t\r
169 vnic_create_adapter(\r
170         IN              NDIS_HANDLE                     h_handle,\r
171         OUT             vnic_adapter_t**        const pp_adapter);\r
172 \r
173 void\r
174 vnic_destroy_adapter(\r
175         IN              vnic_adapter_t*         p_adapter);\r
176 \r
177 ib_api_status_t\r
178 vnic_construct_adapter(\r
179         IN              vnic_adapter_t          *p_adapter);\r
180 \r
181 NDIS_STATUS\r
182 vnic_set_mcast(\r
183         IN                              vnic_adapter_t* const           p_adapter,\r
184         IN                              mac_addr_t* const                       p_mac_array,\r
185         IN              const   uint8_t                                         mc_count );\r
186 \r
187 ib_api_status_t\r
188 vnic_viport_allocate(\r
189         IN                      vnic_adapter_t* const           p_adapter,\r
190         IN OUT          viport_t**              const           pp_viport );\r
191 \r
192 void\r
193 vnic_viport_cleanup(\r
194         IN                      vnic_adapter_t                  *p_adapter );\r
195 \r
196 void\r
197 vnic_resume_set_oids(\r
198         IN                              vnic_adapter_t* const           p_adapter );\r
199 \r
200 void\r
201 vnic_resume_oids(\r
202         IN                              vnic_adapter_t* const           p_adapter );\r
203 \r
204 ib_api_status_t\r
205 __vnic_pnp_cb(\r
206         IN                      ib_pnp_rec_t                    *p_pnp_rec );\r
207 \r
208 ib_api_status_t\r
209 ibregion_physInit(\r
210         IN                      struct _vnic_adapter*           p_adapter,\r
211                 OUT             IbRegion_t                                      *pRegion,\r
212         IN                      ib_pd_handle_t                          hPd,\r
213         IN                      uint64_t                                        *p_vaddr,\r
214         IN                      uint64_t                                        len );\r
215 \r
216 #endif  /* !defined _VNIC_ADAPTER_H_ */\r