2 * Copyright (c) 2005 SilverStorm Technologies. All rights reserved.
\r
4 * This software is available to you under the OpenIB.org BSD license
\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
11 * - Redistributions of source code must retain the above
\r
12 * copyright notice, this list of conditions and the following
\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
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
33 #ifndef _IPOIB_ADAPTER_H_
\r
34 #define _IPOIB_ADAPTER_H_
\r
36 #include <iba/ipoib_ifc.h>
\r
37 #include <iba/ib_al.h>
\r
38 #include <complib/cl_obj.h>
\r
39 #include <complib/cl_spinlock.h>
\r
40 #include <complib/cl_mutex.h>
\r
41 #include <complib/cl_qpool.h>
\r
42 #include <complib/cl_atomic.h>
\r
43 #include <complib/cl_perf.h>
\r
44 #include <complib/cl_vector.h>
\r
45 #include "ip_packet.h"
\r
46 #include "ip_stats.h"
\r
52 #define MAX_MCAST 32
\r
54 #define IPV4_ADDR_SIZE 4
\r
56 #define PORT_NUM_INDEX_IN_GUID 3 /* 0 based index into big endian GUID to get port number */
\r
61 #define IPOIB_GET_PORT_NUM_FROM_GUID( __guid__ ) ( ((uint8_t *)&(__guid__))[PORT_NUM_INDEX_IN_GUID] + 1 )
\r
62 #define IPOIB_ADAPTER_GET_PORT_NUM(__p_adapter__) ( IPOIB_GET_PORT_NUM_FROM_GUID( (__p_adapter__)->guids.port_guid ) )
\r
65 typedef struct _ipoib_params
\r
69 boolean_t send_chksum_offload;
\r
70 boolean_t wsdp_enabled;
\r
71 uint16_t static_lid;
\r
72 uint32_t sa_timeout;
\r
73 uint32_t sa_retry_cnt;
\r
74 uint32_t recv_pool_ratio;
\r
75 boolean_t recv_growth;
\r
80 * Number of receive WQEs to allocate.
\r
83 * Number of send WQEs to allocate.
\r
85 * send_chksum_offload
\r
86 * Flag to indicate whether to offload send checksums. This will make it
\r
87 * so that IPoIB packets should never be forwarded out of the IB subnet
\r
88 * without recalculating the checksum.
\r
91 * Flag to indicate whether WSDP is enabled for an adapter adapter.
\r
94 * LID to assign to the port if that port is down (not init) and has none.
\r
95 * This feature allows a LID to be assigned, alowing locally targetted
\r
96 * traffic to occur even on ports that are not plugged in.
\r
99 * Time, in milliseconds, to wait for a response before retransmitting an
\r
100 * SA query request.
\r
103 * Number of times to retry an SA query request.
\r
106 * Initial ratio of receive pool size to receive queue depth.
\r
109 * Threshold at which to grow the receive pool. Valid values start are
\r
110 * powers of 2, excluding 1. When zero, grows only when the pool is
\r
111 * exhausted. Other values indicate fractional values
\r
112 * (i.e. 2 indicates 1/2, 4 indicates 1/4, etc.)
\r
116 typedef struct _pending_oid
\r
121 PULONG p_bytes_used;
\r
122 PULONG p_bytes_needed;
\r
127 typedef struct _ipoib_adapter
\r
130 NDIS_HANDLE h_adapter;
\r
131 ipoib_ifc_data_t guids;
\r
133 cl_list_item_t entry;
\r
135 ib_al_handle_t h_al;
\r
136 ib_pnp_handle_t h_pnp;
\r
138 ib_pnp_event_t state;
\r
141 boolean_t pending_query;
\r
142 pending_oid_t query_oid;
\r
143 boolean_t pending_set;
\r
144 pending_oid_t set_oid;
\r
146 struct _ipoib_port *p_port;
\r
150 ipoib_params_t params;
\r
151 cl_spinlock_t recv_stat_lock;
\r
152 ip_stats_t recv_stats;
\r
153 cl_spinlock_t send_stat_lock;
\r
154 ip_stats_t send_stats;
\r
156 boolean_t is_primary;
\r
157 struct _ipoib_adapter *p_primary;
\r
159 uint32_t packet_filter;
\r
162 mac_addr_t mcast_array[MAX_MCAST];
\r
163 uint8_t mcast_array_size;
\r
165 cl_qpool_t item_pool;
\r
169 cl_vector_t ip_vector;
\r
172 ib_al_ifc_t *p_ifc;
\r
178 * Complib object for reference counting and destruction synchronization.
\r
181 * NDIS adapter handle.
\r
184 * CA and port GUIDs returned by the bus driver.
\r
187 * AL handle for all IB resources.
\r
190 * PNP registration handle for port events.
\r
193 * State of the adapter. IB_PNP_PORT_ADD indicates that the adapter
\r
194 * is ready to transfer data.
\r
197 * Boolean flag used to return whether we are hung or not.
\r
200 * Pointer to an ipoib_port_t representing all resources for moving data
\r
201 * on the IB fabric.
\r
204 * Rate, in 100bps increments, of the link.
\r
207 * Configuration parameters.
\r
210 * Indicates that an query OID request is being processed asynchronously.
\r
213 * Information about the pended query OID request.
\r
214 * Valid only if pending_query is TRUE.
\r
217 * Indicates that an set OID request is being processed asynchronously.
\r
220 * Information about the pended set OID request.
\r
221 * Valid only if pending_set is TRUE.
\r
224 * Spinlock protecting receive processing.
\r
227 * Receive statistics.
\r
230 * Spinlock protecting send processing.
\r
236 * Boolean flag to indicate if an adapter is the primary adapter
\r
240 * Pointer to the primary adapter for a bundle.
\r
243 * Packet filter set by NDIS.
\r
246 * Ethernet MAC address reported to NDIS.
\r
249 * List of multicast MAC addresses programmed by NDIS.
\r
252 * Number of entries in the multicat MAC address array;
\r
255 * Pool of cl_pool_obj_t structures to use for queueing pending
\r
256 * packets for transmission.
\r
259 * Mutex to synchronized PnP callbacks with destruction.
\r
262 * Vector of assigned IP addresses.
\r
265 * Pointer to transport interface.
\r
270 typedef struct _ats_reg
\r
272 ipoib_adapter_t *p_adapter;
\r
273 ib_reg_svc_handle_t h_reg_svc;
\r
279 * Pointer to the adapter to which this address is assigned.
\r
282 * Service registration handle.
\r
286 typedef struct _net_address_item
\r
289 union _net_address_item_address
\r
292 UCHAR as_bytes[IPV4_ADDR_SIZE];
\r
295 } net_address_item_t;
\r
299 * Pointer to the ATS registration assigned to this address.
\r
302 * Union representing the IP address as an unsigned long or as
\r
303 * an array of bytes.
\r
306 * The IP address represented as an unsigned long. Windows stores
\r
310 * The IP address represented as an array of bytes.
\r
315 ipoib_create_adapter(
\r
316 IN NDIS_HANDLE wrapper_config_context,
\r
317 IN void* const h_adapter,
\r
318 OUT ipoib_adapter_t** const pp_adapter );
\r
322 ipoib_start_adapter(
\r
323 IN ipoib_adapter_t* const p_adapter );
\r
327 ipoib_destroy_adapter(
\r
328 IN ipoib_adapter_t* const p_adapter );
\r
331 /* Joins/leaves mcast groups based on currently programmed mcast MACs. */
\r
333 ipoib_refresh_mcast(
\r
334 IN ipoib_adapter_t* const p_adapter,
\r
335 IN mac_addr_t* const p_mac_array,
\r
336 IN const uint8_t num_macs );
\r
340 * Instance whose multicast MAC address list to modify.
\r
343 * Array of multicast MAC addresses assigned to the adapter.
\r
346 * Number of MAC addresses in the array.
\r
351 ipoib_get_recv_stat(
\r
352 IN ipoib_adapter_t* const p_adapter,
\r
353 IN const ip_stat_sel_t stat_sel,
\r
354 IN pending_oid_t* const p_oid_info );
\r
358 ipoib_inc_recv_stat(
\r
359 IN ipoib_adapter_t* const p_adapter,
\r
360 IN const ip_stat_sel_t stat_sel,
\r
361 IN const size_t bytes OPTIONAL );
\r
365 ipoib_get_send_stat(
\r
366 IN ipoib_adapter_t* const p_adapter,
\r
367 IN const ip_stat_sel_t stat_sel,
\r
368 IN pending_oid_t* const p_oid_info );
\r
372 ipoib_inc_send_stat(
\r
373 IN ipoib_adapter_t* const p_adapter,
\r
374 IN const ip_stat_sel_t stat_sel,
\r
375 IN const size_t bytes OPTIONAL );
\r
380 IN ipoib_adapter_t* const p_adapter,
\r
381 IN const uint8_t rate );
\r
386 IN ipoib_adapter_t* const p_adapter );
\r
390 ipoib_reset_adapter(
\r
391 IN ipoib_adapter_t* const p_adapter );
\r
395 IN ipoib_adapter_t* const p_adapter );
\r
397 #endif /* _IPOIB_ADAPTER_H_ */
\r