[IPoIB NDIS 6.0 CM]
[mirror/winof/.git] / ulp / ipoib_NDIS6_CM / kernel / ipoib_port.h
1 /*\r
2  * Copyright (c) 2005 SilverStorm Technologies.  All rights reserved.\r
3  * Copyright (c) 2006 Mellanox Technologies.  All rights reserved.\r
4  * Portions Copyright (c) 2008 Microsoft Corporation.  All rights reserved.\r
5  *\r
6  * This software is available to you under the OpenIB.org BSD license\r
7  * below:\r
8  *\r
9  *     Redistribution and use in source and binary forms, with or\r
10  *     without modification, are permitted provided that the following\r
11  *     conditions are met:\r
12  *\r
13  *      - Redistributions of source code must retain the above\r
14  *        copyright notice, this list of conditions and the following\r
15  *        disclaimer.\r
16  *\r
17  *      - Redistributions in binary form must reproduce the above\r
18  *        copyright notice, this list of conditions and the following\r
19  *        disclaimer in the documentation and/or other materials\r
20  *        provided with the distribution.\r
21  *\r
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
25  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
26  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
27  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
28  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
29  * SOFTWARE.\r
30  *\r
31  * $Id: ipoib_port.h 4226 2009-04-06 06:01:03Z xalex $\r
32  */\r
33 \r
34 \r
35 \r
36 #ifndef _IPOIB_PORT_H_\r
37 #define _IPOIB_PORT_H_\r
38 \r
39 \r
40 #include <iba/ib_al.h>\r
41 #include <complib/cl_obj.h>\r
42 #include <complib/cl_qmap.h>\r
43 #include <complib/cl_fleximap.h>\r
44 #include <ip_packet.h>\r
45 #include "ipoib_xfr_mgr.h"\r
46 #include "ipoib_endpoint.h"\r
47 \r
48 \r
49 /*\r
50  * Define to place receive buffer inline in receive descriptor.\r
51  */\r
52 #define IPOIB_INLINE_RECV       1\r
53 \r
54 /* \r
55  *  Invalid pkey index\r
56  */\r
57 #define PKEY_INVALID_INDEX      0xFFFF\r
58 \r
59 /*\r
60  * Define to control how transfers are done.  When defined as 1, causes\r
61  * packets to be sent using NDIS DMA facilities (getting the SGL from the\r
62  * packet).  When defined as 0, uses the NDIS_BUFFER structures as MDLs\r
63  * to get the physical page mappings of the buffers.\r
64  */\r
65 #define IPOIB_USE_DMA   1\r
66 \r
67 \r
68 #define IPOIB_PORT_FROM_PACKET( P )     \\r
69         (((ipoib_port_t**)NET_BUFFER_LIST_MINIPORT_RESERVED(P))[0])\r
70 #define IPOIB_ENDPT_FROM_PACKET( P )    \\r
71         (((ipoib_endpt_t**)NET_BUFFER_LIST_MINIPORT_RESERVED(P))[1])\r
72 #define IPOIB_RECV_FROM_PACKET( P )     \\r
73         (((ipoib_recv_desc_t**)NET_BUFFER_LIST_MINIPORT_RESERVED(P))[1])\r
74         \r
75 //TODO to be renamed: IPOIB_NBL_FROM_LIST_ITEM\r
76 #define IPOIB_PACKET_FROM_LIST_ITEM( I ) \\r
77         (PARENT_STRUCT( I, NET_BUFFER_LIST, MiniportReserved ))\r
78 #define IPOIB_LIST_ITEM_FROM_PACKET( P ) \\r
79         ((cl_list_item_t*)NET_BUFFER_LIST_MINIPORT_RESERVED(P))\r
80 \r
81 #define IPOIB_NET_BUFFER_LIST_FROM_NETBUFFER( P )       \\r
82         (((NET_BUFFER_LIST**)NET_BUFFER_MINIPORT_RESERVED(P))[0])\r
83 #define IPOIB_FROM_QUEUE( P )   \\r
84         (((void**)NET_BUFFER_MINIPORT_RESERVED(P))[1])\r
85 #define IPOIB_SEND_FROM_NETBUFFER( P )  \\r
86         (((send_buf_t**)NET_BUFFER_MINIPORT_RESERVED(P))[2])\r
87 \r
88 \r
89 #define IPOIB_GET_NET_BUFFER_LIST_REF_COUNT(_NetBufferList)     ((NET_BUFFER_LIST_FIRST_NB(_NetBufferList))->MiniportReserved[3])\r
90 #define IPOIB_DEC_NET_BUFFER_LIST_REF_COUNT(_NetBufferList)     (*(PULONG)&(NET_BUFFER_LIST_FIRST_NB(_NetBufferList))->MiniportReserved[3])--\r
91 \r
92 \r
93 typedef struct _ipoib_ib_mgr\r
94 {\r
95         ib_ca_handle_t                  h_ca;\r
96         ib_pd_handle_t                  h_pd;\r
97         ib_cq_handle_t                  h_recv_cq;\r
98         ib_cq_handle_t                  h_send_cq;\r
99         ib_qp_handle_t                  h_qp;\r
100         ib_query_handle_t               h_query;\r
101         ib_srq_handle_t                 h_srq;\r
102         net32_t                                 qpn;\r
103 \r
104         ib_mr_handle_t                  h_mr;\r
105         net32_t                                 lkey;\r
106 \r
107         uint8_t                                 rate;\r
108         ib_member_rec_t                 bcast_rec;\r
109 \r
110 }       ipoib_ib_mgr_t;\r
111 /*\r
112 * FIELDS\r
113 *       h_ca\r
114 *               CA handle for all IB resources.\r
115 *\r
116 *       h_pd\r
117 *               PD handle for all IB resources.\r
118 *\r
119 *       h_recv_cq\r
120 *               Recv CQ handle.\r
121 *\r
122 *       h_send_cq\r
123 *               Send CQ handle.\r
124 *\r
125 *       h_qp\r
126 *               QP handle for data transfers.\r
127 *\r
128 *       h_query\r
129 *               Query handle for cancelling SA queries.\r
130 *\r
131 *       h_mr\r
132 *               Registration handle for all of physical memory.  Used for\r
133 *               send/receive buffers to simplify growing the receive pool.\r
134 *\r
135 *       lkey\r
136 *               LKey for the memory region.\r
137 *\r
138 *       bcast_rec\r
139 *               Cached information about the broadcast group, used to specify\r
140 *               parameters used to join other multicast groups.\r
141 *********/\r
142 \r
143 \r
144 #include <complib/cl_packon.h>\r
145 /****s* IPoIB Driver/ipoib_hdr_t\r
146 * NAME\r
147 *       ipoib_hdr_t\r
148 *\r
149 * DESCRIPTION\r
150 *       IPoIB packet header.\r
151 *\r
152 * SYNOPSIS\r
153 */\r
154 typedef struct _ipoib_hdr\r
155 {\r
156         net16_t                 type;\r
157         net16_t                 resv;\r
158 \r
159 }       PACK_SUFFIX ipoib_hdr_t;\r
160 /*\r
161 * FIELDS\r
162 *       type\r
163 *               Protocol type.\r
164 *\r
165 *       resv\r
166 *               Reserved portion of IPoIB header.\r
167 *********/\r
168 \r
169 typedef struct _ipoib_arp_pkt\r
170 {\r
171         net16_t                 hw_type;\r
172         net16_t                 prot_type;\r
173         uint8_t                 hw_size;\r
174         uint8_t                 prot_size;\r
175         net16_t                 op;\r
176         ipoib_hw_addr_t src_hw;\r
177         net32_t                 src_ip;\r
178         ipoib_hw_addr_t dst_hw;\r
179         net32_t                 dst_ip;\r
180 \r
181 }       PACK_SUFFIX ipoib_arp_pkt_t;\r
182 \r
183 \r
184 /****s* IPoIB Driver/ipoib_pkt_t\r
185 * NAME\r
186 *       ipoib_pkt_t\r
187 *\r
188 * DESCRIPTION\r
189 *       Represents an IPoIB packet with no GRH.\r
190 *\r
191 * SYNOPSIS\r
192 */\r
193 typedef struct _ipoib_pkt\r
194 {\r
195         ipoib_hdr_t             hdr;\r
196         union _payload\r
197         {\r
198                 uint8_t                 data[MAX_UD_PAYLOAD_MTU];\r
199                 ipoib_arp_pkt_t arp;\r
200                 ip_pkt_t                ip;\r
201 \r
202         }       PACK_SUFFIX type;\r
203 \r
204 }       PACK_SUFFIX ipoib_pkt_t;\r
205 /*\r
206 * FIELDS\r
207 *       hdr\r
208 *               IPoIB header.\r
209 *\r
210 *       type\r
211 *               Union for different types of payloads.\r
212 *\r
213 *       type.data\r
214 *               raw packet.\r
215 *\r
216 *       type.ib_arp\r
217 *               IPoIB ARP packet.\r
218 *\r
219 *       type.arp\r
220 *               Ethernet ARP packet.\r
221 *\r
222 *       type.ip\r
223 *               IP packet.\r
224 *********/\r
225 \r
226 \r
227 /****s* IPoIB Driver/recv_buf_t\r
228 * NAME\r
229 *       recv_buf_t\r
230 *\r
231 * DESCRIPTION\r
232 *       Represents a receive buffer, including the ethernet header\r
233 *       used to indicate the receive to the OS.\r
234 *\r
235 * SYNOPSIS\r
236 */\r
237 typedef union _recv_buf\r
238 {\r
239         struct _recv_buf_type_eth\r
240         {\r
241                 uint8_t                 pad[sizeof(ib_grh_t) +\r
242                                                         sizeof(ipoib_hdr_t) -\r
243                                                         sizeof(eth_hdr_t)];\r
244                 eth_pkt_t               pkt;    /* data starts at sizeof(grh)+sizeof(eth_hdr) */\r
245 \r
246         }       PACK_SUFFIX eth;\r
247 \r
248         struct _recv_buf_type_ib\r
249         {\r
250                 ib_grh_t                grh;    /* Must be same offset as lcl_rt.ib.pkt */\r
251                 ipoib_pkt_t             pkt;    /* data starts at 10+grh+4 */\r
252 \r
253         }       PACK_SUFFIX ib;\r
254 \r
255 }       PACK_SUFFIX recv_buf_t;\r
256 /*\r
257 * FIELDS\r
258 *       eth.pkt\r
259 *               Ethernet packet, used to indicate the receive to the OS.\r
260 *\r
261 *       ib.grh\r
262 *               GRH for a globally routed received packet.\r
263 *\r
264 *       ib.pkt\r
265 *               IPOIB packet representing a globally routed received packet.\r
266 *\r
267 * NOTES\r
268 *       When posting the work request, the address of ib.grh is used.\r
269 *\r
270 *       TODO: Do we need a pad to offset the header so that the data ends up\r
271 *       aligned on a pointer boundary?\r
272 *********/\r
273 \r
274 /****s* IPoIB Driver/send_buf_t\r
275 * NAME\r
276 *       send_buf_t\r
277 *\r
278 * DESCRIPTION\r
279 *       Represents a send buffer, used to convert packets to IPoIB format.\r
280 *\r
281 * SYNOPSIS\r
282 */\r
283 typedef union _send_buf\r
284 {\r
285         uint8_t                 data[MAX_UD_PAYLOAD_MTU];\r
286         ipoib_arp_pkt_t arp;\r
287         ip_pkt_t                ip;\r
288 \r
289 }       PACK_SUFFIX send_buf_t;\r
290 /*\r
291 * FIELDS\r
292 *       data\r
293 *               IP/ARP packet.\r
294 *\r
295 * NOTES\r
296 *       TODO: Do we need a pad to offset the header so that the data ends up\r
297 *       aligned on a pointer boundary?\r
298 *********/\r
299 #include <complib/cl_packoff.h>\r
300 \r
301 \r
302 typedef struct _ipoib_buf_mgr\r
303 {\r
304         cl_qpool_t                      recv_pool;\r
305 \r
306         NDIS_HANDLE                     h_packet_pool;\r
307         NDIS_HANDLE                     h_buffer_pool;\r
308 \r
309         NPAGED_LOOKASIDE_LIST   send_buf_list;\r
310         NDIS_HANDLE                     h_send_pkt_pool;\r
311         NDIS_HANDLE                     h_send_buf_pool;\r
312 \r
313 }       ipoib_buf_mgr_t;\r
314 /*\r
315 * FIELDS\r
316 *       recv_pool\r
317 *               Pool of ipoib_recv_desc_t structures.\r
318 *\r
319 *       h_packet_pool\r
320 *               NDIS packet pool, used to indicate receives to NDIS.\r
321 *\r
322 *       h_buffer_pool\r
323 *               NDIS buffer pool, used to indicate receives to NDIS.\r
324 *\r
325 *       send_buf_list\r
326 *               Lookaside list for dynamically allocating send buffers for send\r
327 *               that require copies (ARP, DHCP, and any with more physical pages\r
328 *               than can fit in the local data segments).\r
329 *********/\r
330 \r
331 \r
332 typedef enum _ipoib_pkt_type\r
333 {\r
334         PKT_TYPE_UCAST,\r
335         PKT_TYPE_BCAST,\r
336         PKT_TYPE_MCAST,\r
337         PKT_TYPE_CM_UCAST\r
338 \r
339 }       ipoib_pkt_type_t;\r
340 \r
341 typedef struct _ipoib_cm_desc\r
342 {\r
343         cl_pool_item_t                          item;   /* Must be first. */\r
344         uint32_t                                        len;\r
345         ipoib_pkt_type_t                        type;\r
346         ib_recv_wr_t                            wr;\r
347         ib_local_ds_t                           local_ds[2];\r
348         cl_list_item_t                          list_item;\r
349         uint8_t*                                        p_alloc_buf;\r
350         uint8_t*                                        p_buf;\r
351         uint32_t                                        alloc_buf_size;\r
352         uint32_t                                        buf_size;\r
353         net32_t                                         lkey;\r
354         ib_mr_handle_t                          h_mr;\r
355         NDIS_TCP_IP_CHECKSUM_PACKET_INFO        ndis_csum;\r
356 \r
357 }       ipoib_cm_desc_t;\r
358 \r
359 typedef struct _ipoib_recv_desc\r
360 {\r
361         cl_pool_item_t          item;   /* Must be first. */\r
362         uint32_t                        len;\r
363         ipoib_pkt_type_t        type;\r
364         ib_recv_wr_t            wr;\r
365         ib_local_ds_t           local_ds[2];\r
366         NDIS_TCP_IP_CHECKSUM_PACKET_INFO        ndis_csum;\r
367 #if IPOIB_INLINE_RECV\r
368         recv_buf_t                      buf;\r
369 #else\r
370         recv_buf_t                      *p_buf;\r
371 #endif\r
372 \r
373 }       ipoib_recv_desc_t;\r
374 /*\r
375 * FIELDS\r
376 *       item\r
377 *               Pool item for storing descriptors in a pool.\r
378 *\r
379 *       len\r
380 *               Length to indicate to NDIS.  This is different than the length of the\r
381 *               received data as some data is IPoIB specific and filtered out.\r
382 *\r
383 *       type\r
384 *               Type of packet, used in filtering received packets against the packet\r
385 *               filter.  Also used to update stats.\r
386 *\r
387 *       wr\r
388 *               Receive work request.\r
389 *\r
390 *       local_ds\r
391 *               Local data segments.  The second segment is only used if a buffer\r
392 *               spans physical pages.\r
393 *\r
394 *       buf\r
395 *               Buffer for the receive.\r
396 *\r
397 * NOTES\r
398 *       The pool item is always first to allow casting form a cl_pool_item_t or\r
399 *       cl_list_item_t to the descriptor.\r
400 *********/\r
401 typedef struct __ipoib_send_wr\r
402 {\r
403         ib_send_wr_t            wr;\r
404         ib_local_ds_t           local_ds[MAX_SEND_SGE]; /* Must be last. */\r
405 } ipoib_send_wr_t;\r
406 \r
407 typedef enum __send_dir\r
408 {\r
409         SEND_UD_QP = 1,\r
410         SEND_RC_QP = 2\r
411 } send_dir_t;\r
412 \r
413 typedef struct _ipoib_send_desc\r
414 {\r
415         PNET_BUFFER_LIST    p_netbuf_list;\r
416         ipoib_endpt_t           *p_endpt;\r
417         send_buf_t                      *p_buf;\r
418         ib_qp_handle_t          send_qp;\r
419         send_dir_t                      send_dir;\r
420         uint32_t                        num_wrs;\r
421         ipoib_send_wr_t         send_wr[MAX_WRS_PER_MSG];\r
422 \r
423 }       ipoib_send_desc_t;\r
424 /*\r
425 * FIELDS\r
426 *       p_pkt\r
427 *               Pointer to the NDIS_PACKET associated with the send operation.\r
428 *\r
429 *       p_endpt\r
430 *               Endpoint for this send.\r
431 *\r
432 *       p_buf\r
433 *               Buffer for the send, if allocated.\r
434 *\r
435 *       wr\r
436 *               Send work request.\r
437 *\r
438 *       pkt_hdr\r
439 *               IPoIB packet header, pointed to by the first local datasegment.\r
440 *\r
441 *       local_ds\r
442 *               Local data segment array.  Placed last to allow allocating beyond the\r
443 *               end of the descriptor for additional datasegments.\r
444 *\r
445 * NOTES\r
446 *       The pool item is always first to allow casting form a cl_pool_item_t or\r
447 *       cl_list_item_t to the descriptor.\r
448 *********/\r
449 \r
450 \r
451 typedef struct _ipoib_recv_mgr\r
452 {\r
453         int32_t                 depth;\r
454 \r
455         NET_BUFFER_LIST         **recv_pkt_array;\r
456 \r
457         cl_qlist_t              done_list;\r
458 \r
459 }       ipoib_recv_mgr_t;\r
460 /*\r
461 * FIELDS\r
462 *       depth\r
463 *               Current number of WRs posted.\r
464 *\r
465 *       p_head\r
466 *               Pointer to work completion in descriptor at the head of the QP.\r
467 *\r
468 *       p_tail\r
469 *               Pointer to the work completion in the descriptor at the tail of the QP.\r
470 *\r
471 *       recv_pkt_array\r
472 *               Array of pointers to NDIS_PACKET used to indicate receives.\r
473 *\r
474 *       done_list\r
475 *               List of receive descriptors that need to be indicated to NDIS.\r
476 *********/\r
477 \r
478 \r
479 typedef struct _ipoib_send_mgr\r
480 {\r
481         atomic32_t              depth;\r
482         cl_qlist_t              pending_list;\r
483         ipoib_send_desc_t desc;\r
484 \r
485 }       ipoib_send_mgr_t;\r
486 /*\r
487 * FIELDS\r
488 *       depth\r
489 *               Current number of WRs posted, used to queue pending requests.\r
490 *\r
491 *       pending_list\r
492 *               List of NDIS_PACKET structures that are awaiting available WRs to send.\r
493 *********/\r
494 \r
495 \r
496 typedef struct _ipoib_endpt_mgr\r
497 {\r
498         cl_qmap_t                               mac_endpts;\r
499         cl_fmap_t                               gid_endpts;\r
500         cl_qmap_t                               lid_endpts;\r
501         cl_fmap_t                               conn_endpts;\r
502         LIST_ENTRY                      pending_conns;\r
503         LIST_ENTRY                              remove_conns;\r
504         NDIS_SPIN_LOCK                  conn_lock;\r
505         NDIS_SPIN_LOCK                  remove_lock;\r
506         cl_thread_t                             h_thread;\r
507         cl_event_t                              event;\r
508         uint32_t                                thread_is_done;\r
509 }       ipoib_endpt_mgr_t;\r
510 /*\r
511 * FIELDS\r
512 *       mac_endpts\r
513 *               Map of enpoints, keyed by MAC address.\r
514 *\r
515 *       gid_endpts\r
516 *               Map of enpoints, keyed by GID.\r
517 *\r
518 *       lid_endpts\r
519 *               Map of enpoints, keyed by LID.  Only enpoints on the same subnet\r
520 *               are inserted in the LID map.\r
521 *\r
522 *       conn_endpts\r
523 *               Map of connected endpts, keyed by remote gid.\r
524 *********/\r
525 \r
526 #pragma warning(disable:4324)   // structure padded due to align()\r
527 typedef struct _ipoib_port\r
528 {\r
529         cl_obj_t                                obj;\r
530         cl_obj_rel_t                    rel;\r
531 \r
532         ib_qp_state_t                   state;\r
533 \r
534         cl_spinlock_t                   recv_lock;\r
535         cl_spinlock_t                   send_lock;\r
536 \r
537         struct _ipoib_adapter   *p_adapter;\r
538         uint8_t                                 port_num;\r
539 \r
540         KEVENT                                  sa_event;\r
541 \r
542         atomic32_t                              mcast_cnt;\r
543         KEVENT                                  leave_mcast_event;\r
544         \r
545         ipoib_ib_mgr_t                  ib_mgr;\r
546 \r
547         ipoib_buf_mgr_t                 buf_mgr;\r
548 \r
549         ipoib_recv_mgr_t                recv_mgr;\r
550         ipoib_send_mgr_t                send_mgr;\r
551 \r
552         KDPC                                    recv_dpc;\r
553 \r
554         ipoib_endpt_mgr_t               endpt_mgr;\r
555 \r
556         endpt_buf_mgr_t                 cm_buf_mgr;\r
557         endpt_recv_mgr_t                cm_recv_mgr;\r
558 \r
559         ipoib_endpt_t                   *p_local_endpt;\r
560         ib_ca_attr_t                    *p_ca_attrs;\r
561 #if DBG\r
562         atomic32_t                              ref[ref_array_size];\r
563 #endif\r
564 \r
565         atomic32_t                              endpt_rdr;\r
566 \r
567         atomic32_t                              hdr_idx;\r
568         uint16_t                                pkey_index;\r
569         KDPC                                    gc_dpc;\r
570         KTIMER                                  gc_timer;\r
571         uint32_t                                bc_join_retry_cnt;\r
572         ib_net16_t                              base_lid;\r
573         ipoib_hdr_t                             hdr[1]; /* Must be last! */\r
574 \r
575 }       ipoib_port_t;\r
576 #pragma warning(default:4324)\r
577 \r
578 /*\r
579 * FIELDS\r
580 *       obj\r
581 *               Complib object for reference counting, relationships,\r
582 *               and destruction synchronization.\r
583 *\r
584 *       rel\r
585 *               Relationship to associate the port with the adapter.\r
586 *\r
587 *       state\r
588 *               State of the port object.  Tracks QP state fairly closely.\r
589 *\r
590 *       recv_lock\r
591 *               Spinlock to protect receive operations.\r
592 *\r
593 *       send_lock\r
594 *               Spinlock to protect send operations.\r
595 *\r
596 *       p_adapter\r
597 *               Parent adapter.  Used to get AL handle.\r
598 *\r
599 *       port_num\r
600 *               Port number of this adapter.\r
601 *\r
602 *       ib_mgr\r
603 *               IB resource manager.\r
604 *\r
605 *       recv_mgr\r
606 *               Receive manager.\r
607 *\r
608 *       send_mgr\r
609 *               Send manager.\r
610 *\r
611 *       endpt_mgr\r
612 *               Endpoint manager.\r
613 *********/\r
614 typedef struct _sgl_context\r
615 {\r
616         MDL                                     *p_mdl;\r
617         NET_BUFFER_LIST         *p_netbuffer_list;\r
618         ipoib_port_t            *p_port;\r
619 }sgl_context_t;\r
620 \r
621 ib_api_status_t\r
622 ipoib_create_port(\r
623         IN                              struct _ipoib_adapter* const    p_adapter,\r
624         IN                              ib_pnp_port_rec_t* const        p_pnp_rec,\r
625                 OUT                     ipoib_port_t** const            pp_port );\r
626 \r
627 void\r
628 ipoib_port_destroy(\r
629         IN                              ipoib_port_t* const                     p_port );\r
630 \r
631 void\r
632 ipoib_port_up(\r
633         IN                              ipoib_port_t* const                     p_port,\r
634         IN              const   ib_pnp_port_rec_t* const        p_pnp_rec );\r
635 \r
636 void\r
637 ipoib_port_down(\r
638         IN                              ipoib_port_t* const                     p_port );\r
639 \r
640 ib_api_status_t\r
641 ipoib_port_join_mcast(\r
642         IN                              ipoib_port_t* const                     p_port,\r
643         IN              const   mac_addr_t                              mac,\r
644         IN              const   uint8_t                                 state );\r
645 \r
646 \r
647 void\r
648 ipoib_leave_mcast_cb(\r
649         IN                              void                            *context );\r
650 \r
651 \r
652 void\r
653 ipoib_port_remove_endpt(\r
654         IN                              ipoib_port_t* const                     p_port,\r
655         IN              const   mac_addr_t                                      mac );\r
656 \r
657 void\r
658 ipoib_port_send(\r
659         IN                              ipoib_port_t* const                     p_port,\r
660         IN                              NET_BUFFER_LIST                         *net_buffer_list,\r
661         IN                              ULONG                                           send_flags );\r
662 \r
663 void\r
664 ipoib_return_net_buffer_list(\r
665         IN                              NDIS_HANDLE                                     adapter_context,\r
666         IN                              PNET_BUFFER_LIST                        p_netbuffer_lists,\r
667         IN                              ULONG                                           return_flags);\r
668 \r
669 void\r
670 ipoib_port_resume(\r
671         IN                              ipoib_port_t* const                     p_port,\r
672         IN boolean_t                                                            b_pending );\r
673 \r
674 NTSTATUS\r
675 ipoib_mac_to_gid(\r
676         IN                              ipoib_port_t* const                     p_port,\r
677         IN              const   mac_addr_t                                      mac,\r
678                 OUT                     ib_gid_t*                                       p_gid );\r
679 \r
680 NTSTATUS\r
681 ipoib_mac_to_path(\r
682         IN                              ipoib_port_t* const                     p_port,\r
683         IN              const   mac_addr_t                                      mac,\r
684                 OUT                     ib_path_rec_t*                          p_path );\r
685 \r
686 void \r
687 ipoib_process_sg_list(\r
688     IN  PDEVICE_OBJECT          pDO,\r
689     IN  PVOID                   pIrp,\r
690     IN  PSCATTER_GATHER_LIST    pSGList,\r
691     IN  PVOID                   Context);\r
692     \r
693 inline void ipoib_port_ref(\r
694         IN                              ipoib_port_t *                          p_port, \r
695         IN                              int                                             type);\r
696 \r
697 inline void ipoib_port_deref(\r
698         IN                              ipoib_port_t *                          p_port,\r
699         IN                              int                                             type);\r
700 \r
701 #if 0\r
702 // This function is only used to monitor send failures\r
703 static inline VOID NdisMSendCompleteX(\r
704         IN NDIS_HANDLE  MiniportAdapterHandle,\r
705         IN PNDIS_PACKET  Packet,\r
706         IN NDIS_STATUS  Status\r
707         ) {\r
708         if (Status != NDIS_STATUS_SUCCESS) {\r
709                 IPOIB_PRINT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,\r
710                         ("Sending status other than Success to NDIS\n"));\r
711         }\r
712         NdisMSendComplete(MiniportAdapterHandle,Packet,Status);\r
713 }\r
714 #else\r
715 //#define NdisMSendCompleteX NdisMSendComplete\r
716 #endif\r
717 \r
718 ipoib_endpt_t*\r
719 ipoib_endpt_get_by_gid(\r
720         IN                              ipoib_port_t* const                     p_port,\r
721         IN              const   ib_gid_t* const                         p_gid );\r
722 \r
723 ipoib_endpt_t*\r
724 ipoib_endpt_get_by_lid(\r
725         IN                              ipoib_port_t* const                     p_port,\r
726         IN              const   net16_t                                         lid );\r
727 \r
728 ib_api_status_t\r
729 ipoib_port_srq_init(\r
730         IN              ipoib_port_t* const             p_port );\r
731 \r
732 void\r
733 ipoib_port_srq_destroy( \r
734         IN              ipoib_port_t* const             p_port );\r
735 \r
736 #if 0 //CM\r
737 ib_api_status_t\r
738 ipoib_port_listen(\r
739          IN             ipoib_port_t* const             p_port );\r
740 \r
741 ib_api_status_t\r
742 ipoib_port_cancel_listen(\r
743         IN              ipoib_port_t*   const   p_port,\r
744         IN              ipoib_endpt_t* const    p_endpt ) {\r
745         UNUSED_PARAM(p_port);\r
746         UNUSED_PARAM(p_endpt);\r
747         return IB_SUCCESS;\r
748 }\r
749 #endif \r
750 \r
751 ib_api_status_t\r
752 endpt_cm_buf_mgr_init(\r
753         IN              ipoib_port_t* const                     p_port );\r
754 \r
755 void\r
756 endpt_cm_buf_mgr_destroy(\r
757         IN              ipoib_port_t* const             p_port );\r
758 \r
759 void\r
760 endpt_cm_buf_mgr_reset(\r
761         IN              ipoib_port_t* const             p_port );\r
762 \r
763 void\r
764 endpt_cm_buf_mgr_put_recv(\r
765         IN              endpt_buf_mgr_t * const         p_buf_mgr,\r
766         IN              ipoib_cm_desc_t* const          p_desc );\r
767 \r
768 void\r
769 endpt_cm_buf_mgr_put_recv_list(\r
770         IN              endpt_buf_mgr_t * const         p_buf_mgr,\r
771         IN              cl_qlist_t* const                       p_list );\r
772 \r
773 uint32_t\r
774 endpt_cm_recv_mgr_build_pkt_array(\r
775         IN              ipoib_port_t* const                     p_port,\r
776         IN              ipoib_endpt_t* const            p_endpt,\r
777         IN              cl_qlist_t* const                       p_done_list,\r
778         IN OUT  uint32_t*                                       p_bytes_recv );\r
779 \r
780 ib_api_status_t\r
781 endpt_cm_post_recv(\r
782         IN              ipoib_port_t* const                     p_port );\r
783 \r
784 /*void\r
785 endpt_cm_destroy_conn(\r
786         IN              ipoib_port_t* const                     p_port,\r
787         IN              ipoib_endpt_t* const            p_endpt );\r
788 */\r
789 void\r
790 endpt_cm_disconnect(\r
791         IN              ipoib_port_t*   const           p_port,\r
792         IN              ipoib_endpt_t*  const           p_endpt );\r
793 void\r
794 endpt_cm_flush_recv(\r
795         IN                              ipoib_port_t* const             p_port,\r
796         IN                              ipoib_endpt_t* const    p_endpt );\r
797 \r
798 ib_api_status_t\r
799 ipoib_recv_dhcp(\r
800         IN                              ipoib_port_t* const                     p_port,\r
801         IN              const   ipoib_pkt_t* const                      p_ipoib,\r
802                 OUT                     eth_pkt_t* const                        p_eth,\r
803         IN                              ipoib_endpt_t* const            p_src,\r
804         IN                              ipoib_endpt_t* const            p_dst );\r
805 \r
806 void\r
807 ipoib_port_cancel_xmit(\r
808         IN                              ipoib_port_t* const             p_port,\r
809         IN                              PVOID                                    cancel_id );\r
810 \r
811 static inline uint32_t\r
812 __port_attr_to_mtu_size(uint32_t value)\r
813 {\r
814         switch (value) \r
815         {\r
816         default:\r
817         case IB_MTU_LEN_2048:\r
818                 return 2048;\r
819         case IB_MTU_LEN_4096:\r
820                 return 4096;\r
821         case IB_MTU_LEN_1024:\r
822                 return 1024;\r
823         case IB_MTU_LEN_512:\r
824                 return  512;\r
825         case IB_MTU_LEN_256:\r
826                 return  256;\r
827         }\r
828 }\r
829 #endif  /* _IPOIB_PORT_H_ */\r