Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/comstar/port/fcoet/fcoet.h
+++ new/usr/src/uts/common/io/comstar/port/fcoet/fcoet.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24 #ifndef _FCOET_H
25 25 #define _FCOET_H
26 26
27 27 #include <sys/stmf_defines.h>
28 28
29 29 #ifdef __cplusplus
30 30 extern "C" {
31 31 #endif
32 32
33 33 #ifdef _KERNEL
34 34
35 35 #define FCOET_VERSION "v20091123-1.02"
36 36 #define FCOET_NAME "COMSTAR FCoET "
37 37 #define FCOET_MOD_NAME FCOET_NAME FCOET_VERSION
38 38
39 39 #define FCOET_TASKQ_NAME_LEN 32
40 40
41 41 /*
42 42 * FCOET logging
43 43 */
44 44 extern int fcoet_use_ext_log;
45 45
46 46 /*
47 47 * Caution: 1) LOG will be available in debug/non-debug mode
48 48 * 2) Anything which can potentially flood the log should be under
49 49 * extended logging, and use FCOET_EXT_LOG.
50 50 * 3) Don't use FCOET_EXT_LOG in performance-critical code path, such
51 51 * as normal SCSI I/O code path. It could hurt system performance.
52 52 * 4) Use kmdb to change focet_use_ext_log in the fly to adjust
53 53 * tracing
54 54 */
55 55 #define FCOET_EXT_LOG(log_ident, ...) \
56 56 { \
57 57 if (fcoet_use_ext_log) { \
58 58 fcoe_trace(log_ident, __VA_ARGS__); \
59 59 } \
60 60 }
61 61
62 62 #define FCOET_LOG(log_ident, ...) \
63 63 fcoe_trace(log_ident, __VA_ARGS__)
64 64
65 65 /*
66 66 * define common-used constants
67 67 */
68 68 #define FCOET_MAX_LOGINS 2048
69 69 #define FCOET_MAX_XCHGES 2048
70 70 #define FCOET_SOL_HASH_SIZE 128
71 71 #define FCOET_UNSOL_HASH_SIZE 2048
72 72
73 73 typedef enum fcoet_sol_flogi_state {
74 74 SFS_WAIT_LINKUP = 0,
75 75 SFS_FLOGI_INIT,
76 76 SFS_FLOGI_CHECK_TIMEOUT,
77 77 SFS_ABTS_INIT,
78 78 SFS_CLEAR_FLOGI,
79 79 SFS_FLOGI_ACC,
80 80 SFS_FLOGI_DONE
81 81 } fcoet_sol_flogi_state_t;
82 82
83 83 /*
84 84 * define data structures
85 85 */
86 86 struct fcoet_exchange;
87 87 typedef struct fcoet_soft_state {
88 88 /*
89 89 * basic information
90 90 */
91 91 dev_info_t *ss_dip;
92 92 int ss_instance;
93 93 uint32_t ss_flags;
94 94 fct_local_port_t *ss_port;
95 95 fcoe_port_t *ss_eport;
96 96 char ss_alias[32];
97 97 uint32_t ss_fcp_data_payload_size;
98 98
99 99 /*
100 100 * support degregister remote port
101 101 */
102 102 uint32_t ss_rportid_in_dereg;
103 103 uint32_t ss_rport_dereg_state;
104 104
105 105 /*
106 106 * oxid/rxid
107 107 */
108 108 mod_hash_t *ss_sol_oxid_hash;
109 109 mod_hash_t *ss_unsol_rxid_hash;
110 110 uint16_t ss_next_sol_oxid;
111 111 uint16_t ss_next_unsol_rxid;
112 112 int ss_sol_oxid_hash_empty;
113 113 int ss_unsol_rxid_hash_empty;
114 114
115 115 /*
116 116 * watch thread related stuff
117 117 */
118 118 ddi_taskq_t *ss_watchdog_taskq;
119 119 kcondvar_t ss_watch_cv;
120 120 kmutex_t ss_watch_mutex;
121 121 uint64_t ss_watch_count;
122 122 list_t ss_abort_xchg_list;
123 123
124 124 /*
125 125 * topology discovery
126 126 */
127 127 struct fcoet_exchange *ss_sol_flogi;
128 128 fcoet_sol_flogi_state_t ss_sol_flogi_state;
129 129 fct_link_info_t ss_link_info;
130 130
131 131 /*
132 132 * ioctl related stuff
133 133 */
134 134 uint32_t ss_ioctl_flags;
135 135 kmutex_t ss_ioctl_mutex;
136 136
137 137 /*
138 138 * special stuff
139 139 */
140 140 uint32_t ss_change_state_flags;
141 141 uint8_t ss_state:7,
142 142 ss_state_not_acked:1;
143 143 } fcoet_soft_state_t;
144 144
145 145 #define SS_FLAG_UNSOL_FLOGI_DONE 0x0001
146 146 #define SS_FLAG_REPORT_TO_FCT 0x0002
147 147 #define SS_FLAG_PORT_DISABLED 0x0004
148 148 #define SS_FLAG_STOP_WATCH 0x0008
149 149 #define SS_FLAG_TERMINATE_WATCHDOG 0x0010
150 150 #define SS_FLAG_WATCHDOG_RUNNING 0x0020
151 151 #define SS_FLAG_DOG_WAITING 0x0040
152 152 #define SS_FLAG_DELAY_PLOGI 0x0080
153 153
154 154 /*
155 155 * Sequence and frame are transient objects, so their definition is simple.
156 156 */
157 157
158 158 /*
159 159 * Sequence.
160 160 * we will not use sequence in current implementation
161 161 */
162 162 typedef struct fcoet_sequence {
163 163 list_t seq_frame_list;
164 164 struct fcoet_exchange *seq_exchange;
165 165 } fcoet_sequence_t;
166 166
167 167 /*
168 168 * Frame
169 169 */
170 170 typedef struct fcoet_frame {
171 171 list_node_t tfm_seq_node;
172 172 fcoe_frame_t *tfm_fcoe_frame;
173 173
174 174 struct fcoet_exchange *tfm_xch;
175 175 struct fcoet_sequence *tfm_seq;
176 176 uint8_t tfm_rctl;
177 177 uint8_t tfm_buf_idx;
178 178 } fcoet_frame_t;
179 179
180 180 /*
181 181 * FCOET_MAX_DBUF_LEN should better be consistent with sbd_scsi.c. Since
182 182 * sbd_scsi.c use 128k as the max dbuf size, we'd better define this between
183 183 * 32k - 128k.
184 184 */
185 185 #define FCOET_MAX_DBUF_LEN 0x20000 /* 128 * 1024 */
186 186 /*
187 187 * exchange - cmd alias
188 188 */
189 189 typedef struct fcoet_exchange {
190 190 /*
191 191 * it is only used for ss_abort_xchg_list
192 192 */
193 193 list_node_t xch_abort_node;
194 194
195 195 /*
196 196 * We don't believe oxid/rxid in fct_cmd_t
197 197 */
198 198 uint16_t xch_oxid;
199 199 uint16_t xch_rxid;
200 200
201 201 uint32_t xch_flags;
202 202 fcoet_soft_state_t *xch_ss;
203 203 fct_cmd_t *xch_cmd;
204 204
205 205 fcoet_sequence_t *xch_current_seq;
206 206 clock_t xch_start_time;
207 207
208 208 stmf_data_buf_t **xch_dbufs;
209 209 uint8_t xch_dbuf_num;
210 210 uint8_t xch_sequence_no;
211 211 uint8_t xch_ref;
212 212
213 213 int xch_left_data_size;
214 214 } fcoet_exchange_t;
215 215 /*
↓ open down ↓ |
215 lines elided |
↑ open up ↑ |
216 216 * Add the reference to avoid such situation:
217 217 * 1, Frame received, then abort happen (maybe because local port offline, or
218 218 * remote port abort the cmd), cmd is aborted and then freed right after we
219 219 * get the exchange from hash table in fcoet_rx_frame.
220 220 * 2, Frame sent out, then queued in fcoe for release. then abort happen, cmd
221 221 * is aborted and then freed before fcoe_watchdog() call up to release the
222 222 * frame.
223 223 * These two situation should seldom happen. But just invoke this seems won't
224 224 * downgrade the performance too much, so we keep it.
225 225 */
226 -#define FCOET_BUSY_XCHG(xch) atomic_add_8(&(xch)->xch_ref, 1)
227 -#define FCOET_RELE_XCHG(xch) atomic_add_8(&(xch)->xch_ref, -1)
226 +#define FCOET_BUSY_XCHG(xch) atomic_inc_8(&(xch)->xch_ref)
227 +#define FCOET_RELE_XCHG(xch) atomic_dec_8(&(xch)->xch_ref)
228 228
229 229 #define XCH_FLAG_NONFCP_REQ_SENT 0x0001
230 230 #define XCH_FLAG_NONFCP_RESP_SENT 0x0002
231 231 #define XCH_FLAG_FCP_CMD_RCVD 0x0004
232 232 #define XCH_FLAG_INI_ASKED_ABORT 0x0008
233 233 #define XCH_FLAG_FCT_CALLED_ABORT 0x0010
234 234 #define XCH_FLAG_IN_HASH_TABLE 0x0020
235 235
236 236 /*
237 237 * IOCTL supporting stuff
238 238 */
239 239 #define FCOET_IOCTL_FLAG_MASK 0xFF
240 240 #define FCOET_IOCTL_FLAG_IDLE 0x00
241 241 #define FCOET_IOCTL_FLAG_OPEN 0x01
242 242 #define FCOET_IOCTL_FLAG_EXCL 0x02
243 243
244 244 /*
245 245 * define common-used conversion and calculation macros
246 246 */
247 247 #define FRM2SS(x_frm) \
248 248 ((fcoet_soft_state_t *)(x_frm)->frm_eport->eport_client_private)
249 249 #define FRM2TFM(x_frm) ((fcoet_frame_t *)(x_frm)->frm_client_private)
250 250
251 251 #define PORT2SS(x_port) ((fcoet_soft_state_t *)(x_port)->port_fca_private)
252 252 #define EPORT2SS(x_port) ((fcoet_soft_state_t *)(x_port)->eport_client_private)
253 253
254 254 #define XCH2ELS(x_xch) ((fct_els_t *)x_xch->xch_cmd->cmd_specific)
255 255 #define XCH2CT(x_xch) ((fct_ct_t *)x_xch->xch_cmd->cmd_specific)
256 256 #define XCH2TASK(x_xch) ((scsi_task_t *)x_xch->xch_cmd->cmd_specific)
257 257
258 258 #define CMD2ELS(x_cmd) ((fct_els_t *)x_cmd->cmd_specific)
259 259 #define CMD2CT(x_cmd) ((fct_sol_ct_t *)x_cmd->cmd_specific)
260 260 #define CMD2TASK(x_cmd) ((scsi_task_t *)x_cmd->cmd_specific)
261 261 #define CMD2XCH(x_cmd) ((fcoet_exchange_t *)x_cmd->cmd_fca_private)
262 262 #define CMD2SS(x_cmd) \
263 263 ((fcoet_soft_state_t *)(x_cmd)->cmd_port->port_fca_private)
264 264
265 265 void fcoet_init_tfm(fcoe_frame_t *frm, fcoet_exchange_t *xch);
266 266 fct_status_t fcoet_send_status(fct_cmd_t *cmd);
267 267 void fcoet_modhash_find_cb(mod_hash_key_t, mod_hash_val_t);
268 268
269 269 /*
270 270 * DBUF stuff
271 271 */
272 272 #define FCOET_DB_SEG_NUM(x_db) (x_db->db_port_private)
273 273 #define FCOET_DB_NETB(x_db) \
274 274 (((uintptr_t)FCOET_DB_SEG_NUM(x_db)) * \
275 275 sizeof (struct stmf_sglist_ent) + (uintptr_t)(x_db)->db_sglist)
276 276
277 277 #define FCOET_SET_SEG_NUM(x_db, x_num) \
278 278 { \
279 279 FCOET_DB_SEG_NUM(x_db) = (void *)(unsigned long)x_num; \
280 280 }
281 281
282 282 #define FCOET_GET_SEG_NUM(x_db) ((int)(unsigned long)FCOET_DB_SEG_NUM(x_db))
283 283
284 284
285 285 #define FCOET_SET_NETB(x_db, x_idx, x_netb) \
286 286 { \
287 287 ((void **)FCOET_DB_NETB(x_db))[x_idx] = x_netb; \
288 288 }
289 289
290 290 #define FCOET_GET_NETB(x_db, x_idx) \
291 291 (((void **)FCOET_DB_NETB(x_db))[x_idx])
292 292
293 293 #define PRT_FRM_HDR(x_p, x_f) \
294 294 { \
295 295 FCOET_LOG(x_p, "rctl/%x, type/%x, fctl/%x, oxid/%x", \
296 296 FCOE_B2V_1((x_f)->frm_hdr->hdr_r_ctl), \
297 297 FCOE_B2V_1((x_f)->frm_hdr->hdr_type), \
298 298 FCOE_B2V_3((x_f)->frm_hdr->hdr_f_ctl), \
299 299 FCOE_B2V_4((x_f)->frm_hdr->hdr_oxid)); \
300 300 }
301 301
302 302 #endif /* _KERNEL */
303 303
304 304 #ifdef __cplusplus
305 305 }
306 306 #endif
307 307
308 308 #endif /* _FCOET_H */
↓ open down ↓ |
71 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX