added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / drivers / infiniband / hw / nes / nes_cm.h
blobfafa35042ebdcc46d56446acfb40b395aad9c81b
1 /*
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
12 * conditions are met:
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
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
30 * SOFTWARE.
34 #ifndef NES_CM_H
35 #define NES_CM_H
37 #define QUEUE_EVENTS
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
48 enum ietf_mpa_flags {
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];
56 u8 flags;
57 u8 rev;
58 __be16 priv_data_len;
59 u8 priv_data[0];
62 #define ietf_mpa_req_resp_frame ietf_mpa_frame
64 struct nes_v4_quad {
65 u32 rsvd0;
66 __le32 DstIpAdrIndex; /* Only most significant 5 bits are valid */
67 __be32 SrcIpadr;
68 __be16 TcpPorts[2]; /* src is low, dest is high */
71 struct nes_cm_node;
72 enum nes_timer_type {
73 NES_TIMER_TYPE_SEND,
74 NES_TIMER_TYPE_RECV,
75 NES_TIMER_NODE_CLEANUP,
76 NES_TIMER_TYPE_CLOSE,
79 #define NES_PASSIVE_STATE_INDICATED 0
80 #define NES_DO_NOT_SEND_RESET_EVENT 1
81 #define NES_SEND_RESET_EVENT 2
83 #define MAX_NES_IFS 4
85 #define SET_ACK 1
86 #define SET_SYN 2
87 #define SET_FIN 4
88 #define SET_RST 8
90 #define TCP_OPTIONS_PADDING 3
92 struct option_base {
93 u8 optionnum;
94 u8 length;
97 enum option_numbers {
98 OPTION_NUMBER_END,
99 OPTION_NUMBER_NONE,
100 OPTION_NUMBER_MSS,
101 OPTION_NUMBER_WINDOW_SCALE,
102 OPTION_NUMBER_SACK_PERM,
103 OPTION_NUMBER_SACK,
104 OPTION_NUMBER_WRITE0 = 0xbc
107 struct option_mss {
108 u8 optionnum;
109 u8 length;
110 __be16 mss;
113 struct option_windowscale {
114 u8 optionnum;
115 u8 length;
116 u8 shiftcount;
119 union all_known_options {
120 char as_end;
121 struct option_base as_base;
122 struct option_mss as_mss;
123 struct option_windowscale as_windowscale;
126 struct nes_timer_entry {
127 struct list_head list;
128 unsigned long timetosend; /* jiffies */
129 struct sk_buff *skb;
130 u32 type;
131 u32 retrycount;
132 u32 retranscount;
133 u32 context;
134 u32 seq_num;
135 u32 send_retrans;
136 int close_when_complete;
137 struct net_device *netdev;
140 #define NES_DEFAULT_RETRYS 64
141 #define NES_DEFAULT_RETRANS 8
142 #ifdef CONFIG_INFINIBAND_NES_DEBUG
143 #define NES_RETRY_TIMEOUT (1000*HZ/1000)
144 #else
145 #define NES_RETRY_TIMEOUT (3000*HZ/1000)
146 #endif
147 #define NES_SHORT_TIME (10)
148 #define NES_LONG_TIME (2000*HZ/1000)
150 #define NES_CM_HASHTABLE_SIZE 1024
151 #define NES_CM_TCP_TIMER_INTERVAL 3000
152 #define NES_CM_DEFAULT_MTU 1540
153 #define NES_CM_DEFAULT_FRAME_CNT 10
154 #define NES_CM_THREAD_STACK_SIZE 256
155 #define NES_CM_DEFAULT_RCV_WND 64240 // before we know that window scaling is allowed
156 #define NES_CM_DEFAULT_RCV_WND_SCALED 256960 // after we know that window scaling is allowed
157 #define NES_CM_DEFAULT_RCV_WND_SCALE 2
158 #define NES_CM_DEFAULT_FREE_PKTS 0x000A
159 #define NES_CM_FREE_PKT_LO_WATERMARK 2
161 #define NES_CM_DEFAULT_MSS 536
163 #define NES_CM_DEF_SEQ 0x159bf75f
164 #define NES_CM_DEF_LOCAL_ID 0x3b47
166 #define NES_CM_DEF_SEQ2 0x18ed5740
167 #define NES_CM_DEF_LOCAL_ID2 0xb807
168 #define MAX_CM_BUFFER 512
171 typedef u32 nes_addr_t;
173 #define nes_cm_tsa_context nes_qp_context
175 struct nes_qp;
177 /* cm node transition states */
178 enum nes_cm_node_state {
179 NES_CM_STATE_UNKNOWN,
180 NES_CM_STATE_INITED,
181 NES_CM_STATE_LISTENING,
182 NES_CM_STATE_SYN_RCVD,
183 NES_CM_STATE_SYN_SENT,
184 NES_CM_STATE_ONE_SIDE_ESTABLISHED,
185 NES_CM_STATE_ESTABLISHED,
186 NES_CM_STATE_ACCEPTING,
187 NES_CM_STATE_MPAREQ_SENT,
188 NES_CM_STATE_MPAREQ_RCVD,
189 NES_CM_STATE_TSA,
190 NES_CM_STATE_FIN_WAIT1,
191 NES_CM_STATE_FIN_WAIT2,
192 NES_CM_STATE_CLOSE_WAIT,
193 NES_CM_STATE_TIME_WAIT,
194 NES_CM_STATE_LAST_ACK,
195 NES_CM_STATE_CLOSING,
196 NES_CM_STATE_CLOSED
199 enum nes_tcpip_pkt_type {
200 NES_PKT_TYPE_UNKNOWN,
201 NES_PKT_TYPE_SYN,
202 NES_PKT_TYPE_SYNACK,
203 NES_PKT_TYPE_ACK,
204 NES_PKT_TYPE_FIN,
205 NES_PKT_TYPE_RST
209 /* type of nes connection */
210 enum nes_cm_conn_type {
211 NES_CM_IWARP_CONN_TYPE,
214 /* CM context params */
215 struct nes_cm_tcp_context {
216 u8 client;
218 u32 loc_seq_num;
219 u32 loc_ack_num;
220 u32 rem_ack_num;
221 u32 rcv_nxt;
223 u32 loc_id;
224 u32 rem_id;
226 u32 snd_wnd;
227 u32 max_snd_wnd;
229 u32 rcv_wnd;
230 u32 mss;
231 u8 snd_wscale;
232 u8 rcv_wscale;
234 struct nes_cm_tsa_context tsa_cntxt;
235 struct timeval sent_ts;
239 enum nes_cm_listener_state {
240 NES_CM_LISTENER_PASSIVE_STATE=1,
241 NES_CM_LISTENER_ACTIVE_STATE=2,
242 NES_CM_LISTENER_EITHER_STATE=3
245 struct nes_cm_listener {
246 struct list_head list;
247 struct nes_cm_core *cm_core;
248 u8 loc_mac[ETH_ALEN];
249 nes_addr_t loc_addr;
250 u16 loc_port;
251 struct iw_cm_id *cm_id;
252 enum nes_cm_conn_type conn_type;
253 atomic_t ref_count;
254 struct nes_vnic *nesvnic;
255 atomic_t pend_accepts_cnt;
256 int backlog;
257 enum nes_cm_listener_state listener_state;
258 u32 reused_node;
261 /* per connection node and node state information */
262 struct nes_cm_node {
263 nes_addr_t loc_addr, rem_addr;
264 u16 loc_port, rem_port;
266 u8 loc_mac[ETH_ALEN];
267 u8 rem_mac[ETH_ALEN];
269 enum nes_cm_node_state state;
270 struct nes_cm_tcp_context tcp_cntxt;
271 struct nes_cm_core *cm_core;
272 struct sk_buff_head resend_list;
273 atomic_t ref_count;
274 struct net_device *netdev;
276 struct nes_cm_node *loopbackpartner;
278 struct nes_timer_entry *send_entry;
280 spinlock_t retrans_list_lock;
281 struct list_head recv_list;
282 spinlock_t recv_list_lock;
284 int send_write0;
285 union {
286 struct ietf_mpa_frame mpa_frame;
287 u8 mpa_frame_buf[NES_CM_DEFAULT_MTU];
289 u16 mpa_frame_size;
290 struct iw_cm_id *cm_id;
291 struct list_head list;
292 int accelerated;
293 struct nes_cm_listener *listener;
294 enum nes_cm_conn_type conn_type;
295 struct nes_vnic *nesvnic;
296 int apbvt_set;
297 int accept_pend;
298 int freed;
299 struct list_head timer_entry;
300 struct list_head reset_entry;
301 struct nes_qp *nesqp;
302 atomic_t passive_state;
305 /* structure for client or CM to fill when making CM api calls. */
306 /* - only need to set relevant data, based on op. */
307 struct nes_cm_info {
308 union {
309 struct iw_cm_id *cm_id;
310 struct net_device *netdev;
313 u16 loc_port;
314 u16 rem_port;
315 nes_addr_t loc_addr;
316 nes_addr_t rem_addr;
318 enum nes_cm_conn_type conn_type;
319 int backlog;
322 /* CM event codes */
323 enum nes_cm_event_type {
324 NES_CM_EVENT_UNKNOWN,
325 NES_CM_EVENT_ESTABLISHED,
326 NES_CM_EVENT_MPA_REQ,
327 NES_CM_EVENT_MPA_CONNECT,
328 NES_CM_EVENT_MPA_ACCEPT,
329 NES_CM_EVENT_MPA_ESTABLISHED,
330 NES_CM_EVENT_CONNECTED,
331 NES_CM_EVENT_CLOSED,
332 NES_CM_EVENT_RESET,
333 NES_CM_EVENT_DROPPED_PKT,
334 NES_CM_EVENT_CLOSE_IMMED,
335 NES_CM_EVENT_CLOSE_HARD,
336 NES_CM_EVENT_CLOSE_CLEAN,
337 NES_CM_EVENT_ABORTED,
338 NES_CM_EVENT_SEND_FIRST
341 /* event to post to CM event handler */
342 struct nes_cm_event {
343 enum nes_cm_event_type type;
345 struct nes_cm_info cm_info;
346 struct work_struct event_work;
347 struct nes_cm_node *cm_node;
350 struct nes_cm_core {
351 enum nes_cm_node_state state;
353 atomic_t listen_node_cnt;
354 struct nes_cm_node listen_list;
355 spinlock_t listen_list_lock;
357 u32 mtu;
358 u32 free_tx_pkt_max;
359 u32 rx_pkt_posted;
360 atomic_t ht_node_cnt;
361 struct list_head connected_nodes;
362 /* struct list_head hashtable[NES_CM_HASHTABLE_SIZE]; */
363 spinlock_t ht_lock;
365 struct timer_list tcp_timer;
367 struct nes_cm_ops *api;
369 int (*post_event)(struct nes_cm_event *event);
370 atomic_t events_posted;
371 struct workqueue_struct *event_wq;
372 struct workqueue_struct *disconn_wq;
374 atomic_t node_cnt;
375 u64 aborted_connects;
376 u32 options;
378 struct nes_cm_node *current_listen_node;
382 #define NES_CM_SET_PKT_SIZE (1 << 1)
383 #define NES_CM_SET_FREE_PKT_Q_SIZE (1 << 2)
385 /* CM ops/API for client interface */
386 struct nes_cm_ops {
387 int (*accelerated)(struct nes_cm_core *, struct nes_cm_node *);
388 struct nes_cm_listener * (*listen)(struct nes_cm_core *, struct nes_vnic *,
389 struct nes_cm_info *);
390 int (*stop_listener)(struct nes_cm_core *, struct nes_cm_listener *);
391 struct nes_cm_node * (*connect)(struct nes_cm_core *,
392 struct nes_vnic *, u16, void *,
393 struct nes_cm_info *);
394 int (*close)(struct nes_cm_core *, struct nes_cm_node *);
395 int (*accept)(struct nes_cm_core *, struct ietf_mpa_frame *,
396 struct nes_cm_node *);
397 int (*reject)(struct nes_cm_core *, struct ietf_mpa_frame *,
398 struct nes_cm_node *);
399 int (*recv_pkt)(struct nes_cm_core *, struct nes_vnic *,
400 struct sk_buff *);
401 int (*destroy_cm_core)(struct nes_cm_core *);
402 int (*get)(struct nes_cm_core *);
403 int (*set)(struct nes_cm_core *, u32, u32);
406 int schedule_nes_timer(struct nes_cm_node *, struct sk_buff *,
407 enum nes_timer_type, int, int);
409 int nes_cm_disconn(struct nes_qp *);
411 int nes_accept(struct iw_cm_id *, struct iw_cm_conn_param *);
412 int nes_reject(struct iw_cm_id *, const void *, u8);
413 int nes_connect(struct iw_cm_id *, struct iw_cm_conn_param *);
414 int nes_create_listen(struct iw_cm_id *, int);
415 int nes_destroy_listen(struct iw_cm_id *);
417 int nes_cm_recv(struct sk_buff *, struct net_device *);
418 int nes_cm_start(void);
419 int nes_cm_stop(void);
421 #endif /* NES_CM_H */