2 * Copyright (c) 2006 - 2008 NetEffect, Inc. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39 #define NES_MANAGE_APBVT_DEL 0
40 #define NES_MANAGE_APBVT_ADD 1
42 /* IETF MPA -- defines, enums, structs */
43 #define IEFT_MPA_KEY_REQ "MPA ID Req Frame"
44 #define IEFT_MPA_KEY_REP "MPA ID Rep Frame"
45 #define IETF_MPA_KEY_SIZE 16
46 #define IETF_MPA_VERSION 1
49 IETF_MPA_FLAGS_MARKERS
= 0x80, /* receive Markers */
50 IETF_MPA_FLAGS_CRC
= 0x40, /* receive Markers */
51 IETF_MPA_FLAGS_REJECT
= 0x20, /* Reject */
54 struct ietf_mpa_frame
{
55 u8 key
[IETF_MPA_KEY_SIZE
];
62 #define ietf_mpa_req_resp_frame ietf_mpa_frame
66 __le32 DstIpAdrIndex
; /* Only most significant 5 bits are valid */
68 __be16 TcpPorts
[2]; /* src is low, dest is high */
75 NES_TIMER_NODE_CLEANUP
,
95 OPTION_NUMBER_WINDOW_SCALE
,
96 OPTION_NUMBER_SACK_PERM
,
98 OPTION_NUMBER_WRITE0
= 0xbc
107 struct option_windowscale
{
113 union all_known_options
{
115 struct option_base as_base
;
116 struct option_mss as_mss
;
117 struct option_windowscale as_windowscale
;
120 struct nes_timer_entry
{
121 struct list_head list
;
122 unsigned long timetosend
; /* jiffies */
130 int close_when_complete
;
131 struct net_device
*netdev
;
134 #define NES_DEFAULT_RETRYS 64
135 #define NES_DEFAULT_RETRANS 8
136 #ifdef CONFIG_INFINIBAND_NES_DEBUG
137 #define NES_RETRY_TIMEOUT (1000*HZ/1000)
139 #define NES_RETRY_TIMEOUT (3000*HZ/1000)
141 #define NES_SHORT_TIME (10)
142 #define NES_LONG_TIME (2000*HZ/1000)
144 #define NES_CM_HASHTABLE_SIZE 1024
145 #define NES_CM_TCP_TIMER_INTERVAL 3000
146 #define NES_CM_DEFAULT_MTU 1540
147 #define NES_CM_DEFAULT_FRAME_CNT 10
148 #define NES_CM_THREAD_STACK_SIZE 256
149 #define NES_CM_DEFAULT_RCV_WND 64240 // before we know that window scaling is allowed
150 #define NES_CM_DEFAULT_RCV_WND_SCALED 256960 // after we know that window scaling is allowed
151 #define NES_CM_DEFAULT_RCV_WND_SCALE 2
152 #define NES_CM_DEFAULT_FREE_PKTS 0x000A
153 #define NES_CM_FREE_PKT_LO_WATERMARK 2
155 #define NES_CM_DEFAULT_MSS 536
157 #define NES_CM_DEF_SEQ 0x159bf75f
158 #define NES_CM_DEF_LOCAL_ID 0x3b47
160 #define NES_CM_DEF_SEQ2 0x18ed5740
161 #define NES_CM_DEF_LOCAL_ID2 0xb807
163 typedef u32 nes_addr_t
;
165 #define nes_cm_tsa_context nes_qp_context
169 /* cm node transition states */
170 enum nes_cm_node_state
{
171 NES_CM_STATE_UNKNOWN
,
173 NES_CM_STATE_LISTENING
,
174 NES_CM_STATE_SYN_RCVD
,
175 NES_CM_STATE_SYN_SENT
,
176 NES_CM_STATE_ONE_SIDE_ESTABLISHED
,
177 NES_CM_STATE_ESTABLISHED
,
178 NES_CM_STATE_ACCEPTING
,
179 NES_CM_STATE_MPAREQ_SENT
,
181 NES_CM_STATE_FIN_WAIT1
,
182 NES_CM_STATE_FIN_WAIT2
,
183 NES_CM_STATE_CLOSE_WAIT
,
184 NES_CM_STATE_TIME_WAIT
,
185 NES_CM_STATE_LAST_ACK
,
186 NES_CM_STATE_CLOSING
,
190 /* type of nes connection */
191 enum nes_cm_conn_type
{
192 NES_CM_IWARP_CONN_TYPE
,
195 /* CM context params */
196 struct nes_cm_tcp_context
{
215 struct nes_cm_tsa_context tsa_cntxt
;
216 struct timeval sent_ts
;
220 enum nes_cm_listener_state
{
221 NES_CM_LISTENER_PASSIVE_STATE
=1,
222 NES_CM_LISTENER_ACTIVE_STATE
=2,
223 NES_CM_LISTENER_EITHER_STATE
=3
226 struct nes_cm_listener
{
227 struct list_head list
;
229 struct nes_cm_core
*cm_core
;
230 u8 loc_mac
[ETH_ALEN
];
233 struct iw_cm_id
*cm_id
;
234 enum nes_cm_conn_type conn_type
;
236 struct nes_vnic
*nesvnic
;
237 atomic_t pend_accepts_cnt
;
239 enum nes_cm_listener_state listener_state
;
243 /* per connection node and node state information */
248 nes_addr_t loc_addr
, rem_addr
;
249 u16 loc_port
, rem_port
;
251 u8 loc_mac
[ETH_ALEN
];
252 u8 rem_mac
[ETH_ALEN
];
254 enum nes_cm_node_state state
;
255 struct nes_cm_tcp_context tcp_cntxt
;
256 struct nes_cm_core
*cm_core
;
257 struct sk_buff_head resend_list
;
259 struct net_device
*netdev
;
261 struct nes_cm_node
*loopbackpartner
;
262 struct list_head retrans_list
;
263 spinlock_t retrans_list_lock
;
264 struct list_head recv_list
;
265 spinlock_t recv_list_lock
;
269 struct ietf_mpa_frame mpa_frame
;
270 u8 mpa_frame_buf
[NES_CM_DEFAULT_MTU
];
273 struct iw_cm_id
*cm_id
;
274 struct list_head list
;
276 struct nes_cm_listener
*listener
;
277 enum nes_cm_conn_type conn_type
;
278 struct nes_vnic
*nesvnic
;
283 /* structure for client or CM to fill when making CM api calls. */
284 /* - only need to set relevant data, based on op. */
287 struct iw_cm_id
*cm_id
;
288 struct net_device
*netdev
;
296 enum nes_cm_conn_type conn_type
;
301 enum nes_cm_event_type
{
302 NES_CM_EVENT_UNKNOWN
,
303 NES_CM_EVENT_ESTABLISHED
,
304 NES_CM_EVENT_MPA_REQ
,
305 NES_CM_EVENT_MPA_CONNECT
,
306 NES_CM_EVENT_MPA_ACCEPT
,
307 NES_CM_EVENT_MPA_ESTABLISHED
,
308 NES_CM_EVENT_CONNECTED
,
311 NES_CM_EVENT_DROPPED_PKT
,
312 NES_CM_EVENT_CLOSE_IMMED
,
313 NES_CM_EVENT_CLOSE_HARD
,
314 NES_CM_EVENT_CLOSE_CLEAN
,
315 NES_CM_EVENT_ABORTED
,
316 NES_CM_EVENT_SEND_FIRST
319 /* event to post to CM event handler */
320 struct nes_cm_event
{
321 enum nes_cm_event_type type
;
323 struct nes_cm_info cm_info
;
324 struct work_struct event_work
;
325 struct nes_cm_node
*cm_node
;
329 enum nes_cm_node_state state
;
332 atomic_t listen_node_cnt
;
333 struct nes_cm_node listen_list
;
334 spinlock_t listen_list_lock
;
339 struct sk_buff_head tx_free_list
;
340 atomic_t ht_node_cnt
;
341 struct list_head connected_nodes
;
342 /* struct list_head hashtable[NES_CM_HASHTABLE_SIZE]; */
345 struct timer_list tcp_timer
;
347 struct nes_cm_ops
*api
;
349 int (*post_event
)(struct nes_cm_event
*event
);
350 atomic_t events_posted
;
351 struct workqueue_struct
*event_wq
;
352 struct workqueue_struct
*disconn_wq
;
355 u64 aborted_connects
;
358 struct nes_cm_node
*current_listen_node
;
362 #define NES_CM_SET_PKT_SIZE (1 << 1)
363 #define NES_CM_SET_FREE_PKT_Q_SIZE (1 << 2)
365 /* CM ops/API for client interface */
367 int (*accelerated
)(struct nes_cm_core
*, struct nes_cm_node
*);
368 struct nes_cm_listener
* (*listen
)(struct nes_cm_core
*, struct nes_vnic
*,
369 struct nes_cm_info
*);
370 int (*stop_listener
)(struct nes_cm_core
*, struct nes_cm_listener
*);
371 struct nes_cm_node
* (*connect
)(struct nes_cm_core
*,
372 struct nes_vnic
*, struct ietf_mpa_frame
*,
373 struct nes_cm_info
*);
374 int (*close
)(struct nes_cm_core
*, struct nes_cm_node
*);
375 int (*accept
)(struct nes_cm_core
*, struct ietf_mpa_frame
*,
376 struct nes_cm_node
*);
377 int (*reject
)(struct nes_cm_core
*, struct ietf_mpa_frame
*,
378 struct nes_cm_node
*);
379 int (*recv_pkt
)(struct nes_cm_core
*, struct nes_vnic
*,
381 int (*destroy_cm_core
)(struct nes_cm_core
*);
382 int (*get
)(struct nes_cm_core
*);
383 int (*set
)(struct nes_cm_core
*, u32
, u32
);
387 int send_mpa_request(struct nes_cm_node
*);
388 struct sk_buff
*form_cm_frame(struct sk_buff
*, struct nes_cm_node
*,
389 void *, u32
, void *, u32
, u8
);
390 int schedule_nes_timer(struct nes_cm_node
*, struct sk_buff
*,
391 enum nes_timer_type
, int, int);
392 void nes_cm_timer_tick(unsigned long);
393 int send_syn(struct nes_cm_node
*, u32
);
394 int send_reset(struct nes_cm_node
*);
395 int send_ack(struct nes_cm_node
*);
396 int send_fin(struct nes_cm_node
*, struct sk_buff
*);
397 struct sk_buff
*get_free_pkt(struct nes_cm_node
*);
398 int process_packet(struct nes_cm_node
*, struct sk_buff
*, struct nes_cm_core
*);
400 struct nes_cm_node
* mini_cm_connect(struct nes_cm_core
*,
401 struct nes_vnic
*, struct ietf_mpa_frame
*, struct nes_cm_info
*);
402 int mini_cm_accept(struct nes_cm_core
*, struct ietf_mpa_frame
*, struct nes_cm_node
*);
403 int mini_cm_reject(struct nes_cm_core
*, struct ietf_mpa_frame
*, struct nes_cm_node
*);
404 int mini_cm_close(struct nes_cm_core
*, struct nes_cm_node
*);
405 int mini_cm_recv_pkt(struct nes_cm_core
*, struct nes_vnic
*, struct sk_buff
*);
406 struct nes_cm_core
*mini_cm_alloc_core(struct nes_cm_info
*);
407 int mini_cm_dealloc_core(struct nes_cm_core
*);
408 int mini_cm_get(struct nes_cm_core
*);
409 int mini_cm_set(struct nes_cm_core
*, u32
, u32
);
411 int nes_cm_disconn(struct nes_qp
*);
412 void nes_disconnect_worker(struct work_struct
*);
413 int nes_cm_disconn_true(struct nes_qp
*);
414 int nes_disconnect(struct nes_qp
*, int);
416 int nes_accept(struct iw_cm_id
*, struct iw_cm_conn_param
*);
417 int nes_reject(struct iw_cm_id
*, const void *, u8
);
418 int nes_connect(struct iw_cm_id
*, struct iw_cm_conn_param
*);
419 int nes_create_listen(struct iw_cm_id
*, int);
420 int nes_destroy_listen(struct iw_cm_id
*);
422 int nes_cm_recv(struct sk_buff
*, struct net_device
*);
423 int nes_cm_start(void);
424 int nes_cm_stop(void);
426 /* CM event handler functions */
427 void cm_event_connected(struct nes_cm_event
*);
428 void cm_event_connect_error(struct nes_cm_event
*);
429 void cm_event_reset(struct nes_cm_event
*);
430 void cm_event_mpa_req(struct nes_cm_event
*);
431 int nes_cm_post_event(struct nes_cm_event
*);
433 #endif /* NES_CM_H */