]>
Commit | Line | Data |
---|---|---|
b038ced7 SW |
1 | /* |
2 | * Copyright (c) 2006 Chelsio, Inc. All rights reserved. | |
b038ced7 SW |
3 | * |
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: | |
9 | * | |
10 | * Redistribution and use in source and binary forms, with or | |
11 | * without modification, are permitted provided that the following | |
12 | * conditions are met: | |
13 | * | |
14 | * - Redistributions of source code must retain the above | |
15 | * copyright notice, this list of conditions and the following | |
16 | * disclaimer. | |
17 | * | |
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. | |
22 | * | |
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. | |
31 | */ | |
32 | #ifndef _IWCH_CM_H_ | |
33 | #define _IWCH_CM_H_ | |
34 | ||
35 | #include <linux/inet.h> | |
36 | #include <linux/wait.h> | |
37 | #include <linux/spinlock.h> | |
38 | #include <linux/kref.h> | |
39 | ||
40 | #include <rdma/ib_verbs.h> | |
41 | #include <rdma/iw_cm.h> | |
42 | ||
43 | #include "cxgb3_offload.h" | |
44 | #include "iwch_provider.h" | |
45 | ||
46 | #define MPA_KEY_REQ "MPA ID Req Frame" | |
47 | #define MPA_KEY_REP "MPA ID Rep Frame" | |
48 | ||
49 | #define MPA_MAX_PRIVATE_DATA 256 | |
50 | #define MPA_REV 0 /* XXX - amso1100 uses rev 0 ! */ | |
51 | #define MPA_REJECT 0x20 | |
52 | #define MPA_CRC 0x40 | |
53 | #define MPA_MARKERS 0x80 | |
54 | #define MPA_FLAGS_MASK 0xE0 | |
55 | ||
56 | #define put_ep(ep) { \ | |
33718363 | 57 | PDBG("put_ep (via %s:%u) ep %p refcnt %d\n", __func__, __LINE__, \ |
b038ced7 SW |
58 | ep, atomic_read(&((ep)->kref.refcount))); \ |
59 | kref_put(&((ep)->kref), __free_ep); \ | |
60 | } | |
61 | ||
62 | #define get_ep(ep) { \ | |
33718363 | 63 | PDBG("get_ep (via %s:%u) ep %p, refcnt %d\n", __func__, __LINE__, \ |
b038ced7 SW |
64 | ep, atomic_read(&((ep)->kref.refcount))); \ |
65 | kref_get(&((ep)->kref)); \ | |
66 | } | |
67 | ||
68 | struct mpa_message { | |
69 | u8 key[16]; | |
70 | u8 flags; | |
71 | u8 revision; | |
72 | __be16 private_data_size; | |
73 | u8 private_data[0]; | |
74 | }; | |
75 | ||
76 | struct terminate_message { | |
77 | u8 layer_etype; | |
78 | u8 ecode; | |
79 | __be16 hdrct_rsvd; | |
80 | u8 len_hdrs[0]; | |
81 | }; | |
82 | ||
83 | #define TERM_MAX_LENGTH (sizeof(struct terminate_message) + 2 + 18 + 28) | |
84 | ||
85 | enum iwch_layers_types { | |
86 | LAYER_RDMAP = 0x00, | |
87 | LAYER_DDP = 0x10, | |
88 | LAYER_MPA = 0x20, | |
89 | RDMAP_LOCAL_CATA = 0x00, | |
90 | RDMAP_REMOTE_PROT = 0x01, | |
91 | RDMAP_REMOTE_OP = 0x02, | |
92 | DDP_LOCAL_CATA = 0x00, | |
93 | DDP_TAGGED_ERR = 0x01, | |
94 | DDP_UNTAGGED_ERR = 0x02, | |
95 | DDP_LLP = 0x03 | |
96 | }; | |
97 | ||
98 | enum iwch_rdma_ecodes { | |
99 | RDMAP_INV_STAG = 0x00, | |
100 | RDMAP_BASE_BOUNDS = 0x01, | |
101 | RDMAP_ACC_VIOL = 0x02, | |
102 | RDMAP_STAG_NOT_ASSOC = 0x03, | |
103 | RDMAP_TO_WRAP = 0x04, | |
104 | RDMAP_INV_VERS = 0x05, | |
105 | RDMAP_INV_OPCODE = 0x06, | |
106 | RDMAP_STREAM_CATA = 0x07, | |
107 | RDMAP_GLOBAL_CATA = 0x08, | |
108 | RDMAP_CANT_INV_STAG = 0x09, | |
109 | RDMAP_UNSPECIFIED = 0xff | |
110 | }; | |
111 | ||
112 | enum iwch_ddp_ecodes { | |
113 | DDPT_INV_STAG = 0x00, | |
114 | DDPT_BASE_BOUNDS = 0x01, | |
115 | DDPT_STAG_NOT_ASSOC = 0x02, | |
116 | DDPT_TO_WRAP = 0x03, | |
117 | DDPT_INV_VERS = 0x04, | |
118 | DDPU_INV_QN = 0x01, | |
119 | DDPU_INV_MSN_NOBUF = 0x02, | |
120 | DDPU_INV_MSN_RANGE = 0x03, | |
121 | DDPU_INV_MO = 0x04, | |
122 | DDPU_MSG_TOOBIG = 0x05, | |
123 | DDPU_INV_VERS = 0x06 | |
124 | }; | |
125 | ||
126 | enum iwch_mpa_ecodes { | |
127 | MPA_CRC_ERR = 0x02, | |
128 | MPA_MARKER_ERR = 0x03 | |
129 | }; | |
130 | ||
131 | enum iwch_ep_state { | |
132 | IDLE = 0, | |
133 | LISTEN, | |
134 | CONNECTING, | |
135 | MPA_REQ_WAIT, | |
136 | MPA_REQ_SENT, | |
137 | MPA_REQ_RCVD, | |
138 | MPA_REP_SENT, | |
139 | FPDU_MODE, | |
140 | ABORTING, | |
141 | CLOSING, | |
142 | MORIBUND, | |
143 | DEAD, | |
144 | }; | |
145 | ||
aff9e39d SW |
146 | enum iwch_ep_flags { |
147 | PEER_ABORT_IN_PROGRESS = (1 << 0), | |
148 | ABORT_REQ_IN_PROGRESS = (1 << 1), | |
149 | }; | |
150 | ||
b038ced7 SW |
151 | struct iwch_ep_common { |
152 | struct iw_cm_id *cm_id; | |
153 | struct iwch_qp *qp; | |
154 | struct t3cdev *tdev; | |
155 | enum iwch_ep_state state; | |
156 | struct kref kref; | |
157 | spinlock_t lock; | |
158 | struct sockaddr_in local_addr; | |
159 | struct sockaddr_in remote_addr; | |
160 | wait_queue_head_t waitq; | |
161 | int rpl_done; | |
162 | int rpl_err; | |
163 | }; | |
164 | ||
165 | struct iwch_listen_ep { | |
166 | struct iwch_ep_common com; | |
167 | unsigned int stid; | |
168 | int backlog; | |
169 | }; | |
170 | ||
171 | struct iwch_ep { | |
172 | struct iwch_ep_common com; | |
173 | struct iwch_ep *parent_ep; | |
174 | struct timer_list timer; | |
175 | unsigned int atid; | |
176 | u32 hwtid; | |
177 | u32 snd_seq; | |
de3d3530 | 178 | u32 rcv_seq; |
b038ced7 SW |
179 | struct l2t_entry *l2t; |
180 | struct dst_entry *dst; | |
181 | struct sk_buff *mpa_skb; | |
182 | struct iwch_mpa_attributes mpa_attr; | |
183 | unsigned int mpa_pkt_len; | |
184 | u8 mpa_pkt[sizeof(struct mpa_message) + MPA_MAX_PRIVATE_DATA]; | |
185 | u8 tos; | |
186 | u16 emss; | |
187 | u16 plen; | |
188 | u32 ird; | |
189 | u32 ord; | |
aff9e39d | 190 | u32 flags; |
b038ced7 SW |
191 | }; |
192 | ||
193 | static inline struct iwch_ep *to_ep(struct iw_cm_id *cm_id) | |
194 | { | |
195 | return cm_id->provider_data; | |
196 | } | |
197 | ||
198 | static inline struct iwch_listen_ep *to_listen_ep(struct iw_cm_id *cm_id) | |
199 | { | |
200 | return cm_id->provider_data; | |
201 | } | |
202 | ||
203 | static inline int compute_wscale(int win) | |
204 | { | |
205 | int wscale = 0; | |
206 | ||
207 | while (wscale < 14 && (65535<<wscale) < win) | |
208 | wscale++; | |
209 | return wscale; | |
210 | } | |
211 | ||
212 | /* CM prototypes */ | |
213 | ||
214 | int iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); | |
215 | int iwch_create_listen(struct iw_cm_id *cm_id, int backlog); | |
216 | int iwch_destroy_listen(struct iw_cm_id *cm_id); | |
217 | int iwch_reject_cr(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len); | |
218 | int iwch_accept_cr(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param); | |
219 | int iwch_ep_disconnect(struct iwch_ep *ep, int abrupt, gfp_t gfp); | |
220 | int iwch_quiesce_tid(struct iwch_ep *ep); | |
221 | int iwch_resume_tid(struct iwch_ep *ep); | |
222 | void __free_ep(struct kref *kref); | |
223 | void iwch_rearp(struct iwch_ep *ep); | |
224 | int iwch_ep_redirect(void *ctx, struct dst_entry *old, struct dst_entry *new, struct l2t_entry *l2t); | |
225 | ||
226 | int __init iwch_cm_init(void); | |
227 | void __exit iwch_cm_term(void); | |
228 | ||
229 | #endif /* _IWCH_CM_H_ */ |