xref: /linux/drivers/scsi/bnx2i/57xx_iscsi_hsi.h (revision 0d456bad36d42d16022be045c8a53ddbb59ee478)
1 /* 57xx_iscsi_hsi.h: Broadcom NetXtreme II iSCSI HSI.
2  *
3  * Copyright (c) 2006 - 2012 Broadcom Corporation
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation.
8  *
9  * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
10  * Maintained by: Eddie Wai (eddie.wai@broadcom.com)
11  */
12 #ifndef __57XX_ISCSI_HSI_LINUX_LE__
13 #define __57XX_ISCSI_HSI_LINUX_LE__
14 
15 /*
16  * iSCSI Async CQE
17  */
18 struct bnx2i_async_msg {
19 #if defined(__BIG_ENDIAN)
20 	u8 op_code;
21 	u8 reserved1;
22 	u16 reserved0;
23 #elif defined(__LITTLE_ENDIAN)
24 	u16 reserved0;
25 	u8 reserved1;
26 	u8 op_code;
27 #endif
28 	u32 reserved2;
29 	u32 exp_cmd_sn;
30 	u32 max_cmd_sn;
31 	u32 reserved3[2];
32 #if defined(__BIG_ENDIAN)
33 	u16 reserved5;
34 	u8 err_code;
35 	u8 reserved4;
36 #elif defined(__LITTLE_ENDIAN)
37 	u8 reserved4;
38 	u8 err_code;
39 	u16 reserved5;
40 #endif
41 	u32 reserved6;
42 	u32 lun[2];
43 #if defined(__BIG_ENDIAN)
44 	u8 async_event;
45 	u8 async_vcode;
46 	u16 param1;
47 #elif defined(__LITTLE_ENDIAN)
48 	u16 param1;
49 	u8 async_vcode;
50 	u8 async_event;
51 #endif
52 #if defined(__BIG_ENDIAN)
53 	u16 param2;
54 	u16 param3;
55 #elif defined(__LITTLE_ENDIAN)
56 	u16 param3;
57 	u16 param2;
58 #endif
59 	u32 reserved7[3];
60 	u32 cq_req_sn;
61 };
62 
63 
64 /*
65  * iSCSI Buffer Descriptor (BD)
66  */
67 struct iscsi_bd {
68 	u32 buffer_addr_hi;
69 	u32 buffer_addr_lo;
70 #if defined(__BIG_ENDIAN)
71 	u16 reserved0;
72 	u16 buffer_length;
73 #elif defined(__LITTLE_ENDIAN)
74 	u16 buffer_length;
75 	u16 reserved0;
76 #endif
77 #if defined(__BIG_ENDIAN)
78 	u16 reserved3;
79 	u16 flags;
80 #define ISCSI_BD_RESERVED1 (0x3F<<0)
81 #define ISCSI_BD_RESERVED1_SHIFT 0
82 #define ISCSI_BD_LAST_IN_BD_CHAIN (0x1<<6)
83 #define ISCSI_BD_LAST_IN_BD_CHAIN_SHIFT 6
84 #define ISCSI_BD_FIRST_IN_BD_CHAIN (0x1<<7)
85 #define ISCSI_BD_FIRST_IN_BD_CHAIN_SHIFT 7
86 #define ISCSI_BD_RESERVED2 (0xFF<<8)
87 #define ISCSI_BD_RESERVED2_SHIFT 8
88 #elif defined(__LITTLE_ENDIAN)
89 	u16 flags;
90 #define ISCSI_BD_RESERVED1 (0x3F<<0)
91 #define ISCSI_BD_RESERVED1_SHIFT 0
92 #define ISCSI_BD_LAST_IN_BD_CHAIN (0x1<<6)
93 #define ISCSI_BD_LAST_IN_BD_CHAIN_SHIFT 6
94 #define ISCSI_BD_FIRST_IN_BD_CHAIN (0x1<<7)
95 #define ISCSI_BD_FIRST_IN_BD_CHAIN_SHIFT 7
96 #define ISCSI_BD_RESERVED2 (0xFF<<8)
97 #define ISCSI_BD_RESERVED2_SHIFT 8
98 	u16 reserved3;
99 #endif
100 };
101 
102 
103 /*
104  * iSCSI Cleanup SQ WQE
105  */
106 struct bnx2i_cleanup_request {
107 #if defined(__BIG_ENDIAN)
108 	u8 op_code;
109 	u8 reserved1;
110 	u16 reserved0;
111 #elif defined(__LITTLE_ENDIAN)
112 	u16 reserved0;
113 	u8 reserved1;
114 	u8 op_code;
115 #endif
116 	u32 reserved2[3];
117 #if defined(__BIG_ENDIAN)
118 	u16 reserved3;
119 	u16 itt;
120 #define ISCSI_CLEANUP_REQUEST_INDEX (0x3FFF<<0)
121 #define ISCSI_CLEANUP_REQUEST_INDEX_SHIFT 0
122 #define ISCSI_CLEANUP_REQUEST_TYPE (0x3<<14)
123 #define ISCSI_CLEANUP_REQUEST_TYPE_SHIFT 14
124 #elif defined(__LITTLE_ENDIAN)
125 	u16 itt;
126 #define ISCSI_CLEANUP_REQUEST_INDEX (0x3FFF<<0)
127 #define ISCSI_CLEANUP_REQUEST_INDEX_SHIFT 0
128 #define ISCSI_CLEANUP_REQUEST_TYPE (0x3<<14)
129 #define ISCSI_CLEANUP_REQUEST_TYPE_SHIFT 14
130 	u16 reserved3;
131 #endif
132 	u32 reserved4[10];
133 #if defined(__BIG_ENDIAN)
134 	u8 cq_index;
135 	u8 reserved6;
136 	u16 reserved5;
137 #elif defined(__LITTLE_ENDIAN)
138 	u16 reserved5;
139 	u8 reserved6;
140 	u8 cq_index;
141 #endif
142 };
143 
144 
145 /*
146  * iSCSI Cleanup CQE
147  */
148 struct bnx2i_cleanup_response {
149 #if defined(__BIG_ENDIAN)
150 	u8 op_code;
151 	u8 status;
152 	u16 reserved0;
153 #elif defined(__LITTLE_ENDIAN)
154 	u16 reserved0;
155 	u8 status;
156 	u8 op_code;
157 #endif
158 	u32 reserved1[3];
159 	u32 reserved2[2];
160 #if defined(__BIG_ENDIAN)
161 	u16 reserved4;
162 	u8 err_code;
163 	u8 reserved3;
164 #elif defined(__LITTLE_ENDIAN)
165 	u8 reserved3;
166 	u8 err_code;
167 	u16 reserved4;
168 #endif
169 	u32 reserved5[7];
170 #if defined(__BIG_ENDIAN)
171 	u16 reserved6;
172 	u16 itt;
173 #define ISCSI_CLEANUP_RESPONSE_INDEX (0x3FFF<<0)
174 #define ISCSI_CLEANUP_RESPONSE_INDEX_SHIFT 0
175 #define ISCSI_CLEANUP_RESPONSE_TYPE (0x3<<14)
176 #define ISCSI_CLEANUP_RESPONSE_TYPE_SHIFT 14
177 #elif defined(__LITTLE_ENDIAN)
178 	u16 itt;
179 #define ISCSI_CLEANUP_RESPONSE_INDEX (0x3FFF<<0)
180 #define ISCSI_CLEANUP_RESPONSE_INDEX_SHIFT 0
181 #define ISCSI_CLEANUP_RESPONSE_TYPE (0x3<<14)
182 #define ISCSI_CLEANUP_RESPONSE_TYPE_SHIFT 14
183 	u16 reserved6;
184 #endif
185 	u32 cq_req_sn;
186 };
187 
188 
189 /*
190  * SCSI read/write SQ WQE
191  */
192 struct bnx2i_cmd_request {
193 #if defined(__BIG_ENDIAN)
194 	u8 op_code;
195 	u8 op_attr;
196 #define ISCSI_CMD_REQUEST_TASK_ATTR (0x7<<0)
197 #define ISCSI_CMD_REQUEST_TASK_ATTR_SHIFT 0
198 #define ISCSI_CMD_REQUEST_RESERVED1 (0x3<<3)
199 #define ISCSI_CMD_REQUEST_RESERVED1_SHIFT 3
200 #define ISCSI_CMD_REQUEST_WRITE (0x1<<5)
201 #define ISCSI_CMD_REQUEST_WRITE_SHIFT 5
202 #define ISCSI_CMD_REQUEST_READ (0x1<<6)
203 #define ISCSI_CMD_REQUEST_READ_SHIFT 6
204 #define ISCSI_CMD_REQUEST_FINAL (0x1<<7)
205 #define ISCSI_CMD_REQUEST_FINAL_SHIFT 7
206 	u16 reserved0;
207 #elif defined(__LITTLE_ENDIAN)
208 	u16 reserved0;
209 	u8 op_attr;
210 #define ISCSI_CMD_REQUEST_TASK_ATTR (0x7<<0)
211 #define ISCSI_CMD_REQUEST_TASK_ATTR_SHIFT 0
212 #define ISCSI_CMD_REQUEST_RESERVED1 (0x3<<3)
213 #define ISCSI_CMD_REQUEST_RESERVED1_SHIFT 3
214 #define ISCSI_CMD_REQUEST_WRITE (0x1<<5)
215 #define ISCSI_CMD_REQUEST_WRITE_SHIFT 5
216 #define ISCSI_CMD_REQUEST_READ (0x1<<6)
217 #define ISCSI_CMD_REQUEST_READ_SHIFT 6
218 #define ISCSI_CMD_REQUEST_FINAL (0x1<<7)
219 #define ISCSI_CMD_REQUEST_FINAL_SHIFT 7
220 	u8 op_code;
221 #endif
222 #if defined(__BIG_ENDIAN)
223 	u16 ud_buffer_offset;
224 	u16 sd_buffer_offset;
225 #elif defined(__LITTLE_ENDIAN)
226 	u16 sd_buffer_offset;
227 	u16 ud_buffer_offset;
228 #endif
229 	u32 lun[2];
230 #if defined(__BIG_ENDIAN)
231 	u16 reserved2;
232 	u16 itt;
233 #define ISCSI_CMD_REQUEST_INDEX (0x3FFF<<0)
234 #define ISCSI_CMD_REQUEST_INDEX_SHIFT 0
235 #define ISCSI_CMD_REQUEST_TYPE (0x3<<14)
236 #define ISCSI_CMD_REQUEST_TYPE_SHIFT 14
237 #elif defined(__LITTLE_ENDIAN)
238 	u16 itt;
239 #define ISCSI_CMD_REQUEST_INDEX (0x3FFF<<0)
240 #define ISCSI_CMD_REQUEST_INDEX_SHIFT 0
241 #define ISCSI_CMD_REQUEST_TYPE (0x3<<14)
242 #define ISCSI_CMD_REQUEST_TYPE_SHIFT 14
243 	u16 reserved2;
244 #endif
245 	u32 total_data_transfer_length;
246 	u32 cmd_sn;
247 	u32 reserved3;
248 	u32 cdb[4];
249 	u32 zero_fill;
250 	u32 bd_list_addr_lo;
251 	u32 bd_list_addr_hi;
252 #if defined(__BIG_ENDIAN)
253 	u8 cq_index;
254 	u8 sd_start_bd_index;
255 	u8 ud_start_bd_index;
256 	u8 num_bds;
257 #elif defined(__LITTLE_ENDIAN)
258 	u8 num_bds;
259 	u8 ud_start_bd_index;
260 	u8 sd_start_bd_index;
261 	u8 cq_index;
262 #endif
263 };
264 
265 
266 /*
267  * task statistics for write response
268  */
269 struct bnx2i_write_resp_task_stat {
270 #if defined(__BIG_ENDIAN)
271 	u16 num_r2ts;
272 	u16 num_data_outs;
273 #elif defined(__LITTLE_ENDIAN)
274 	u16 num_data_outs;
275 	u16 num_r2ts;
276 #endif
277 };
278 
279 /*
280  * task statistics for read response
281  */
282 struct bnx2i_read_resp_task_stat {
283 #if defined(__BIG_ENDIAN)
284 	u16 reserved;
285 	u16 num_data_ins;
286 #elif defined(__LITTLE_ENDIAN)
287 	u16 num_data_ins;
288 	u16 reserved;
289 #endif
290 };
291 
292 /*
293  * task statistics for iSCSI cmd response
294  */
295 union bnx2i_cmd_resp_task_stat {
296 	struct bnx2i_write_resp_task_stat write_stat;
297 	struct bnx2i_read_resp_task_stat read_stat;
298 };
299 
300 /*
301  * SCSI Command CQE
302  */
303 struct bnx2i_cmd_response {
304 #if defined(__BIG_ENDIAN)
305 	u8 op_code;
306 	u8 response_flags;
307 #define ISCSI_CMD_RESPONSE_RESERVED0 (0x1<<0)
308 #define ISCSI_CMD_RESPONSE_RESERVED0_SHIFT 0
309 #define ISCSI_CMD_RESPONSE_RESIDUAL_UNDERFLOW (0x1<<1)
310 #define ISCSI_CMD_RESPONSE_RESIDUAL_UNDERFLOW_SHIFT 1
311 #define ISCSI_CMD_RESPONSE_RESIDUAL_OVERFLOW (0x1<<2)
312 #define ISCSI_CMD_RESPONSE_RESIDUAL_OVERFLOW_SHIFT 2
313 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_UNDERFLOW (0x1<<3)
314 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_UNDERFLOW_SHIFT 3
315 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_OVERFLOW (0x1<<4)
316 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_OVERFLOW_SHIFT 4
317 #define ISCSI_CMD_RESPONSE_RESERVED1 (0x7<<5)
318 #define ISCSI_CMD_RESPONSE_RESERVED1_SHIFT 5
319 	u8 response;
320 	u8 status;
321 #elif defined(__LITTLE_ENDIAN)
322 	u8 status;
323 	u8 response;
324 	u8 response_flags;
325 #define ISCSI_CMD_RESPONSE_RESERVED0 (0x1<<0)
326 #define ISCSI_CMD_RESPONSE_RESERVED0_SHIFT 0
327 #define ISCSI_CMD_RESPONSE_RESIDUAL_UNDERFLOW (0x1<<1)
328 #define ISCSI_CMD_RESPONSE_RESIDUAL_UNDERFLOW_SHIFT 1
329 #define ISCSI_CMD_RESPONSE_RESIDUAL_OVERFLOW (0x1<<2)
330 #define ISCSI_CMD_RESPONSE_RESIDUAL_OVERFLOW_SHIFT 2
331 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_UNDERFLOW (0x1<<3)
332 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_UNDERFLOW_SHIFT 3
333 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_OVERFLOW (0x1<<4)
334 #define ISCSI_CMD_RESPONSE_BR_RESIDUAL_OVERFLOW_SHIFT 4
335 #define ISCSI_CMD_RESPONSE_RESERVED1 (0x7<<5)
336 #define ISCSI_CMD_RESPONSE_RESERVED1_SHIFT 5
337 	u8 op_code;
338 #endif
339 	u32 data_length;
340 	u32 exp_cmd_sn;
341 	u32 max_cmd_sn;
342 	u32 reserved2;
343 	u32 residual_count;
344 #if defined(__BIG_ENDIAN)
345 	u16 reserved4;
346 	u8 err_code;
347 	u8 reserved3;
348 #elif defined(__LITTLE_ENDIAN)
349 	u8 reserved3;
350 	u8 err_code;
351 	u16 reserved4;
352 #endif
353 	u32 reserved5[5];
354 	union bnx2i_cmd_resp_task_stat task_stat;
355 	u32 reserved6;
356 #if defined(__BIG_ENDIAN)
357 	u16 reserved7;
358 	u16 itt;
359 #define ISCSI_CMD_RESPONSE_INDEX (0x3FFF<<0)
360 #define ISCSI_CMD_RESPONSE_INDEX_SHIFT 0
361 #define ISCSI_CMD_RESPONSE_TYPE (0x3<<14)
362 #define ISCSI_CMD_RESPONSE_TYPE_SHIFT 14
363 #elif defined(__LITTLE_ENDIAN)
364 	u16 itt;
365 #define ISCSI_CMD_RESPONSE_INDEX (0x3FFF<<0)
366 #define ISCSI_CMD_RESPONSE_INDEX_SHIFT 0
367 #define ISCSI_CMD_RESPONSE_TYPE (0x3<<14)
368 #define ISCSI_CMD_RESPONSE_TYPE_SHIFT 14
369 	u16 reserved7;
370 #endif
371 	u32 cq_req_sn;
372 };
373 
374 
375 
376 /*
377  * firmware middle-path request SQ WQE
378  */
379 struct bnx2i_fw_mp_request {
380 #if defined(__BIG_ENDIAN)
381 	u8 op_code;
382 	u8 op_attr;
383 	u16 hdr_opaque1;
384 #elif defined(__LITTLE_ENDIAN)
385 	u16 hdr_opaque1;
386 	u8 op_attr;
387 	u8 op_code;
388 #endif
389 	u32 data_length;
390 	u32 hdr_opaque2[2];
391 #if defined(__BIG_ENDIAN)
392 	u16 reserved0;
393 	u16 itt;
394 #define ISCSI_FW_MP_REQUEST_INDEX (0x3FFF<<0)
395 #define ISCSI_FW_MP_REQUEST_INDEX_SHIFT 0
396 #define ISCSI_FW_MP_REQUEST_TYPE (0x3<<14)
397 #define ISCSI_FW_MP_REQUEST_TYPE_SHIFT 14
398 #elif defined(__LITTLE_ENDIAN)
399 	u16 itt;
400 #define ISCSI_FW_MP_REQUEST_INDEX (0x3FFF<<0)
401 #define ISCSI_FW_MP_REQUEST_INDEX_SHIFT 0
402 #define ISCSI_FW_MP_REQUEST_TYPE (0x3<<14)
403 #define ISCSI_FW_MP_REQUEST_TYPE_SHIFT 14
404 	u16 reserved0;
405 #endif
406 	u32 hdr_opaque3[4];
407 	u32 resp_bd_list_addr_lo;
408 	u32 resp_bd_list_addr_hi;
409 	u32 resp_buffer;
410 #define ISCSI_FW_MP_REQUEST_RESP_BUFFER_LENGTH (0xFFFFFF<<0)
411 #define ISCSI_FW_MP_REQUEST_RESP_BUFFER_LENGTH_SHIFT 0
412 #define ISCSI_FW_MP_REQUEST_NUM_RESP_BDS (0xFF<<24)
413 #define ISCSI_FW_MP_REQUEST_NUM_RESP_BDS_SHIFT 24
414 #if defined(__BIG_ENDIAN)
415 	u16 reserved4;
416 	u8 reserved3;
417 	u8 flags;
418 #define ISCSI_FW_MP_REQUEST_RESERVED1 (0x1<<0)
419 #define ISCSI_FW_MP_REQUEST_RESERVED1_SHIFT 0
420 #define ISCSI_FW_MP_REQUEST_LOCAL_COMPLETION (0x1<<1)
421 #define ISCSI_FW_MP_REQUEST_LOCAL_COMPLETION_SHIFT 1
422 #define ISCSI_FW_MP_REQUEST_UPDATE_EXP_STAT_SN (0x1<<2)
423 #define ISCSI_FW_MP_REQUEST_UPDATE_EXP_STAT_SN_SHIFT 2
424 #define ISCSI_FW_MP_REQUEST_RESERVED2 (0x1F<<3)
425 #define ISCSI_FW_MP_REQUEST_RESERVED2_SHIFT 3
426 #elif defined(__LITTLE_ENDIAN)
427 	u8 flags;
428 #define ISCSI_FW_MP_REQUEST_RESERVED1 (0x1<<0)
429 #define ISCSI_FW_MP_REQUEST_RESERVED1_SHIFT 0
430 #define ISCSI_FW_MP_REQUEST_LOCAL_COMPLETION (0x1<<1)
431 #define ISCSI_FW_MP_REQUEST_LOCAL_COMPLETION_SHIFT 1
432 #define ISCSI_FW_MP_REQUEST_UPDATE_EXP_STAT_SN (0x1<<2)
433 #define ISCSI_FW_MP_REQUEST_UPDATE_EXP_STAT_SN_SHIFT 2
434 #define ISCSI_FW_MP_REQUEST_RESERVED2 (0x1F<<3)
435 #define ISCSI_FW_MP_REQUEST_RESERVED2_SHIFT 3
436 	u8 reserved3;
437 	u16 reserved4;
438 #endif
439 	u32 bd_list_addr_lo;
440 	u32 bd_list_addr_hi;
441 #if defined(__BIG_ENDIAN)
442 	u8 cq_index;
443 	u8 reserved6;
444 	u8 reserved5;
445 	u8 num_bds;
446 #elif defined(__LITTLE_ENDIAN)
447 	u8 num_bds;
448 	u8 reserved5;
449 	u8 reserved6;
450 	u8 cq_index;
451 #endif
452 };
453 
454 
455 /*
456  * firmware response - CQE: used only by firmware
457  */
458 struct bnx2i_fw_response {
459 	u32 hdr_dword1[2];
460 	u32 hdr_exp_cmd_sn;
461 	u32 hdr_max_cmd_sn;
462 	u32 hdr_ttt;
463 	u32 hdr_res_cnt;
464 	u32 cqe_flags;
465 #define ISCSI_FW_RESPONSE_RESERVED2 (0xFF<<0)
466 #define ISCSI_FW_RESPONSE_RESERVED2_SHIFT 0
467 #define ISCSI_FW_RESPONSE_ERR_CODE (0xFF<<8)
468 #define ISCSI_FW_RESPONSE_ERR_CODE_SHIFT 8
469 #define ISCSI_FW_RESPONSE_RESERVED3 (0xFFFF<<16)
470 #define ISCSI_FW_RESPONSE_RESERVED3_SHIFT 16
471 	u32 stat_sn;
472 	u32 hdr_dword2[2];
473 	u32 hdr_dword3[2];
474 	u32 task_stat;
475 	u32 reserved0;
476 	u32 hdr_itt;
477 	u32 cq_req_sn;
478 };
479 
480 
481 /*
482  * iSCSI KCQ CQE parameters
483  */
484 union iscsi_kcqe_params {
485 	u32 reserved0[4];
486 };
487 
488 /*
489  * iSCSI KCQ CQE
490  */
491 struct iscsi_kcqe {
492 	u32 iscsi_conn_id;
493 	u32 completion_status;
494 	u32 iscsi_conn_context_id;
495 	union iscsi_kcqe_params params;
496 #if defined(__BIG_ENDIAN)
497 	u8 flags;
498 #define ISCSI_KCQE_RESERVED0 (0xF<<0)
499 #define ISCSI_KCQE_RESERVED0_SHIFT 0
500 #define ISCSI_KCQE_LAYER_CODE (0x7<<4)
501 #define ISCSI_KCQE_LAYER_CODE_SHIFT 4
502 #define ISCSI_KCQE_RESERVED1 (0x1<<7)
503 #define ISCSI_KCQE_RESERVED1_SHIFT 7
504 	u8 op_code;
505 	u16 qe_self_seq;
506 #elif defined(__LITTLE_ENDIAN)
507 	u16 qe_self_seq;
508 	u8 op_code;
509 	u8 flags;
510 #define ISCSI_KCQE_RESERVED0 (0xF<<0)
511 #define ISCSI_KCQE_RESERVED0_SHIFT 0
512 #define ISCSI_KCQE_LAYER_CODE (0x7<<4)
513 #define ISCSI_KCQE_LAYER_CODE_SHIFT 4
514 #define ISCSI_KCQE_RESERVED1 (0x1<<7)
515 #define ISCSI_KCQE_RESERVED1_SHIFT 7
516 #endif
517 };
518 
519 
520 
521 /*
522  * iSCSI KWQE header
523  */
524 struct iscsi_kwqe_header {
525 #if defined(__BIG_ENDIAN)
526 	u8 flags;
527 #define ISCSI_KWQE_HEADER_RESERVED0 (0xF<<0)
528 #define ISCSI_KWQE_HEADER_RESERVED0_SHIFT 0
529 #define ISCSI_KWQE_HEADER_LAYER_CODE (0x7<<4)
530 #define ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT 4
531 #define ISCSI_KWQE_HEADER_RESERVED1 (0x1<<7)
532 #define ISCSI_KWQE_HEADER_RESERVED1_SHIFT 7
533 	u8 op_code;
534 #elif defined(__LITTLE_ENDIAN)
535 	u8 op_code;
536 	u8 flags;
537 #define ISCSI_KWQE_HEADER_RESERVED0 (0xF<<0)
538 #define ISCSI_KWQE_HEADER_RESERVED0_SHIFT 0
539 #define ISCSI_KWQE_HEADER_LAYER_CODE (0x7<<4)
540 #define ISCSI_KWQE_HEADER_LAYER_CODE_SHIFT 4
541 #define ISCSI_KWQE_HEADER_RESERVED1 (0x1<<7)
542 #define ISCSI_KWQE_HEADER_RESERVED1_SHIFT 7
543 #endif
544 };
545 
546 /*
547  * iSCSI firmware init request 1
548  */
549 struct iscsi_kwqe_init1 {
550 #if defined(__BIG_ENDIAN)
551 	struct iscsi_kwqe_header hdr;
552 	u8 reserved0;
553 	u8 num_cqs;
554 #elif defined(__LITTLE_ENDIAN)
555 	u8 num_cqs;
556 	u8 reserved0;
557 	struct iscsi_kwqe_header hdr;
558 #endif
559 	u32 dummy_buffer_addr_lo;
560 	u32 dummy_buffer_addr_hi;
561 #if defined(__BIG_ENDIAN)
562 	u16 num_ccells_per_conn;
563 	u16 num_tasks_per_conn;
564 #elif defined(__LITTLE_ENDIAN)
565 	u16 num_tasks_per_conn;
566 	u16 num_ccells_per_conn;
567 #endif
568 #if defined(__BIG_ENDIAN)
569 	u16 sq_wqes_per_page;
570 	u16 sq_num_wqes;
571 #elif defined(__LITTLE_ENDIAN)
572 	u16 sq_num_wqes;
573 	u16 sq_wqes_per_page;
574 #endif
575 #if defined(__BIG_ENDIAN)
576 	u8 cq_log_wqes_per_page;
577 	u8 flags;
578 #define ISCSI_KWQE_INIT1_PAGE_SIZE (0xF<<0)
579 #define ISCSI_KWQE_INIT1_PAGE_SIZE_SHIFT 0
580 #define ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE (0x1<<4)
581 #define ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE_SHIFT 4
582 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE (0x1<<5)
583 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE_SHIFT 5
584 #define ISCSI_KWQE_INIT1_RESERVED1 (0x3<<6)
585 #define ISCSI_KWQE_INIT1_RESERVED1_SHIFT 6
586 	u16 cq_num_wqes;
587 #elif defined(__LITTLE_ENDIAN)
588 	u16 cq_num_wqes;
589 	u8 flags;
590 #define ISCSI_KWQE_INIT1_PAGE_SIZE (0xF<<0)
591 #define ISCSI_KWQE_INIT1_PAGE_SIZE_SHIFT 0
592 #define ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE (0x1<<4)
593 #define ISCSI_KWQE_INIT1_DELAYED_ACK_ENABLE_SHIFT 4
594 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE (0x1<<5)
595 #define ISCSI_KWQE_INIT1_KEEP_ALIVE_ENABLE_SHIFT 5
596 #define ISCSI_KWQE_INIT1_RESERVED1 (0x3<<6)
597 #define ISCSI_KWQE_INIT1_RESERVED1_SHIFT 6
598 	u8 cq_log_wqes_per_page;
599 #endif
600 #if defined(__BIG_ENDIAN)
601 	u16 cq_num_pages;
602 	u16 sq_num_pages;
603 #elif defined(__LITTLE_ENDIAN)
604 	u16 sq_num_pages;
605 	u16 cq_num_pages;
606 #endif
607 #if defined(__BIG_ENDIAN)
608 	u16 rq_buffer_size;
609 	u16 rq_num_wqes;
610 #elif defined(__LITTLE_ENDIAN)
611 	u16 rq_num_wqes;
612 	u16 rq_buffer_size;
613 #endif
614 };
615 
616 /*
617  * iSCSI firmware init request 2
618  */
619 struct iscsi_kwqe_init2 {
620 #if defined(__BIG_ENDIAN)
621 	struct iscsi_kwqe_header hdr;
622 	u16 max_cq_sqn;
623 #elif defined(__LITTLE_ENDIAN)
624 	u16 max_cq_sqn;
625 	struct iscsi_kwqe_header hdr;
626 #endif
627 	u32 error_bit_map[2];
628 	u32 reserved1[5];
629 };
630 
631 /*
632  * Initial iSCSI connection offload request 1
633  */
634 struct iscsi_kwqe_conn_offload1 {
635 #if defined(__BIG_ENDIAN)
636 	struct iscsi_kwqe_header hdr;
637 	u16 iscsi_conn_id;
638 #elif defined(__LITTLE_ENDIAN)
639 	u16 iscsi_conn_id;
640 	struct iscsi_kwqe_header hdr;
641 #endif
642 	u32 sq_page_table_addr_lo;
643 	u32 sq_page_table_addr_hi;
644 	u32 cq_page_table_addr_lo;
645 	u32 cq_page_table_addr_hi;
646 	u32 reserved0[3];
647 };
648 
649 /*
650  * iSCSI Page Table Entry (PTE)
651  */
652 struct iscsi_pte {
653 	u32 hi;
654 	u32 lo;
655 };
656 
657 /*
658  * Initial iSCSI connection offload request 2
659  */
660 struct iscsi_kwqe_conn_offload2 {
661 #if defined(__BIG_ENDIAN)
662 	struct iscsi_kwqe_header hdr;
663 	u16 reserved0;
664 #elif defined(__LITTLE_ENDIAN)
665 	u16 reserved0;
666 	struct iscsi_kwqe_header hdr;
667 #endif
668 	u32 rq_page_table_addr_lo;
669 	u32 rq_page_table_addr_hi;
670 	struct iscsi_pte sq_first_pte;
671 	struct iscsi_pte cq_first_pte;
672 	u32 num_additional_wqes;
673 };
674 
675 
676 /*
677  * Initial iSCSI connection offload request 3
678  */
679 struct iscsi_kwqe_conn_offload3 {
680 #if defined(__BIG_ENDIAN)
681 	struct iscsi_kwqe_header hdr;
682 	u16 reserved0;
683 #elif defined(__LITTLE_ENDIAN)
684 	u16 reserved0;
685 	struct iscsi_kwqe_header hdr;
686 #endif
687 	u32 reserved1;
688 	struct iscsi_pte qp_first_pte[3];
689 };
690 
691 
692 /*
693  * iSCSI connection update request
694  */
695 struct iscsi_kwqe_conn_update {
696 #if defined(__BIG_ENDIAN)
697 	struct iscsi_kwqe_header hdr;
698 	u16 reserved0;
699 #elif defined(__LITTLE_ENDIAN)
700 	u16 reserved0;
701 	struct iscsi_kwqe_header hdr;
702 #endif
703 #if defined(__BIG_ENDIAN)
704 	u8 session_error_recovery_level;
705 	u8 max_outstanding_r2ts;
706 	u8 reserved2;
707 	u8 conn_flags;
708 #define ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST (0x1<<0)
709 #define ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST_SHIFT 0
710 #define ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST (0x1<<1)
711 #define ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST_SHIFT 1
712 #define ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T (0x1<<2)
713 #define ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T_SHIFT 2
714 #define ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA (0x1<<3)
715 #define ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA_SHIFT 3
716 #define ISCSI_KWQE_CONN_UPDATE_OOO_SUPPORT_MODE (0x3<<4)
717 #define ISCSI_KWQE_CONN_UPDATE_OOO_SUPPORT_MODE_SHIFT 4
718 #define ISCSI_KWQE_CONN_UPDATE_RESERVED1 (0x3<<6)
719 #define ISCSI_KWQE_CONN_UPDATE_RESERVED1_SHIFT 6
720 #elif defined(__LITTLE_ENDIAN)
721 	u8 conn_flags;
722 #define ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST (0x1<<0)
723 #define ISCSI_KWQE_CONN_UPDATE_HEADER_DIGEST_SHIFT 0
724 #define ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST (0x1<<1)
725 #define ISCSI_KWQE_CONN_UPDATE_DATA_DIGEST_SHIFT 1
726 #define ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T (0x1<<2)
727 #define ISCSI_KWQE_CONN_UPDATE_INITIAL_R2T_SHIFT 2
728 #define ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA (0x1<<3)
729 #define ISCSI_KWQE_CONN_UPDATE_IMMEDIATE_DATA_SHIFT 3
730 #define ISCSI_KWQE_CONN_UPDATE_OOO_SUPPORT_MODE (0x3<<4)
731 #define ISCSI_KWQE_CONN_UPDATE_OOO_SUPPORT_MODE_SHIFT 4
732 #define ISCSI_KWQE_CONN_UPDATE_RESERVED1 (0x3<<6)
733 #define ISCSI_KWQE_CONN_UPDATE_RESERVED1_SHIFT 6
734 	u8 reserved2;
735 	u8 max_outstanding_r2ts;
736 	u8 session_error_recovery_level;
737 #endif
738 	u32 context_id;
739 	u32 max_send_pdu_length;
740 	u32 max_recv_pdu_length;
741 	u32 first_burst_length;
742 	u32 max_burst_length;
743 	u32 exp_stat_sn;
744 };
745 
746 /*
747  * iSCSI destroy connection request
748  */
749 struct iscsi_kwqe_conn_destroy {
750 #if defined(__BIG_ENDIAN)
751 	struct iscsi_kwqe_header hdr;
752 	u16 reserved0;
753 #elif defined(__LITTLE_ENDIAN)
754 	u16 reserved0;
755 	struct iscsi_kwqe_header hdr;
756 #endif
757 	u32 context_id;
758 	u32 reserved1[6];
759 };
760 
761 /*
762  * iSCSI KWQ WQE
763  */
764 union iscsi_kwqe {
765 	struct iscsi_kwqe_init1 init1;
766 	struct iscsi_kwqe_init2 init2;
767 	struct iscsi_kwqe_conn_offload1 conn_offload1;
768 	struct iscsi_kwqe_conn_offload2 conn_offload2;
769 	struct iscsi_kwqe_conn_update conn_update;
770 	struct iscsi_kwqe_conn_destroy conn_destroy;
771 };
772 
773 /*
774  * iSCSI Login SQ WQE
775  */
776 struct bnx2i_login_request {
777 #if defined(__BIG_ENDIAN)
778 	u8 op_code;
779 	u8 op_attr;
780 #define ISCSI_LOGIN_REQUEST_NEXT_STAGE (0x3<<0)
781 #define ISCSI_LOGIN_REQUEST_NEXT_STAGE_SHIFT 0
782 #define ISCSI_LOGIN_REQUEST_CURRENT_STAGE (0x3<<2)
783 #define ISCSI_LOGIN_REQUEST_CURRENT_STAGE_SHIFT 2
784 #define ISCSI_LOGIN_REQUEST_RESERVED0 (0x3<<4)
785 #define ISCSI_LOGIN_REQUEST_RESERVED0_SHIFT 4
786 #define ISCSI_LOGIN_REQUEST_CONT (0x1<<6)
787 #define ISCSI_LOGIN_REQUEST_CONT_SHIFT 6
788 #define ISCSI_LOGIN_REQUEST_TRANSIT (0x1<<7)
789 #define ISCSI_LOGIN_REQUEST_TRANSIT_SHIFT 7
790 	u8 version_max;
791 	u8 version_min;
792 #elif defined(__LITTLE_ENDIAN)
793 	u8 version_min;
794 	u8 version_max;
795 	u8 op_attr;
796 #define ISCSI_LOGIN_REQUEST_NEXT_STAGE (0x3<<0)
797 #define ISCSI_LOGIN_REQUEST_NEXT_STAGE_SHIFT 0
798 #define ISCSI_LOGIN_REQUEST_CURRENT_STAGE (0x3<<2)
799 #define ISCSI_LOGIN_REQUEST_CURRENT_STAGE_SHIFT 2
800 #define ISCSI_LOGIN_REQUEST_RESERVED0 (0x3<<4)
801 #define ISCSI_LOGIN_REQUEST_RESERVED0_SHIFT 4
802 #define ISCSI_LOGIN_REQUEST_CONT (0x1<<6)
803 #define ISCSI_LOGIN_REQUEST_CONT_SHIFT 6
804 #define ISCSI_LOGIN_REQUEST_TRANSIT (0x1<<7)
805 #define ISCSI_LOGIN_REQUEST_TRANSIT_SHIFT 7
806 	u8 op_code;
807 #endif
808 	u32 data_length;
809 	u32 isid_lo;
810 #if defined(__BIG_ENDIAN)
811 	u16 isid_hi;
812 	u16 tsih;
813 #elif defined(__LITTLE_ENDIAN)
814 	u16 tsih;
815 	u16 isid_hi;
816 #endif
817 #if defined(__BIG_ENDIAN)
818 	u16 reserved2;
819 	u16 itt;
820 #define ISCSI_LOGIN_REQUEST_INDEX (0x3FFF<<0)
821 #define ISCSI_LOGIN_REQUEST_INDEX_SHIFT 0
822 #define ISCSI_LOGIN_REQUEST_TYPE (0x3<<14)
823 #define ISCSI_LOGIN_REQUEST_TYPE_SHIFT 14
824 #elif defined(__LITTLE_ENDIAN)
825 	u16 itt;
826 #define ISCSI_LOGIN_REQUEST_INDEX (0x3FFF<<0)
827 #define ISCSI_LOGIN_REQUEST_INDEX_SHIFT 0
828 #define ISCSI_LOGIN_REQUEST_TYPE (0x3<<14)
829 #define ISCSI_LOGIN_REQUEST_TYPE_SHIFT 14
830 	u16 reserved2;
831 #endif
832 #if defined(__BIG_ENDIAN)
833 	u16 cid;
834 	u16 reserved3;
835 #elif defined(__LITTLE_ENDIAN)
836 	u16 reserved3;
837 	u16 cid;
838 #endif
839 	u32 cmd_sn;
840 	u32 exp_stat_sn;
841 	u32 reserved4;
842 	u32 resp_bd_list_addr_lo;
843 	u32 resp_bd_list_addr_hi;
844 	u32 resp_buffer;
845 #define ISCSI_LOGIN_REQUEST_RESP_BUFFER_LENGTH (0xFFFFFF<<0)
846 #define ISCSI_LOGIN_REQUEST_RESP_BUFFER_LENGTH_SHIFT 0
847 #define ISCSI_LOGIN_REQUEST_NUM_RESP_BDS (0xFF<<24)
848 #define ISCSI_LOGIN_REQUEST_NUM_RESP_BDS_SHIFT 24
849 #if defined(__BIG_ENDIAN)
850 	u16 reserved8;
851 	u8 reserved7;
852 	u8 flags;
853 #define ISCSI_LOGIN_REQUEST_RESERVED5 (0x3<<0)
854 #define ISCSI_LOGIN_REQUEST_RESERVED5_SHIFT 0
855 #define ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN (0x1<<2)
856 #define ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN_SHIFT 2
857 #define ISCSI_LOGIN_REQUEST_RESERVED6 (0x1F<<3)
858 #define ISCSI_LOGIN_REQUEST_RESERVED6_SHIFT 3
859 #elif defined(__LITTLE_ENDIAN)
860 	u8 flags;
861 #define ISCSI_LOGIN_REQUEST_RESERVED5 (0x3<<0)
862 #define ISCSI_LOGIN_REQUEST_RESERVED5_SHIFT 0
863 #define ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN (0x1<<2)
864 #define ISCSI_LOGIN_REQUEST_UPDATE_EXP_STAT_SN_SHIFT 2
865 #define ISCSI_LOGIN_REQUEST_RESERVED6 (0x1F<<3)
866 #define ISCSI_LOGIN_REQUEST_RESERVED6_SHIFT 3
867 	u8 reserved7;
868 	u16 reserved8;
869 #endif
870 	u32 bd_list_addr_lo;
871 	u32 bd_list_addr_hi;
872 #if defined(__BIG_ENDIAN)
873 	u8 cq_index;
874 	u8 reserved10;
875 	u8 reserved9;
876 	u8 num_bds;
877 #elif defined(__LITTLE_ENDIAN)
878 	u8 num_bds;
879 	u8 reserved9;
880 	u8 reserved10;
881 	u8 cq_index;
882 #endif
883 };
884 
885 
886 /*
887  * iSCSI Login CQE
888  */
889 struct bnx2i_login_response {
890 #if defined(__BIG_ENDIAN)
891 	u8 op_code;
892 	u8 response_flags;
893 #define ISCSI_LOGIN_RESPONSE_NEXT_STAGE (0x3<<0)
894 #define ISCSI_LOGIN_RESPONSE_NEXT_STAGE_SHIFT 0
895 #define ISCSI_LOGIN_RESPONSE_CURRENT_STAGE (0x3<<2)
896 #define ISCSI_LOGIN_RESPONSE_CURRENT_STAGE_SHIFT 2
897 #define ISCSI_LOGIN_RESPONSE_RESERVED0 (0x3<<4)
898 #define ISCSI_LOGIN_RESPONSE_RESERVED0_SHIFT 4
899 #define ISCSI_LOGIN_RESPONSE_CONT (0x1<<6)
900 #define ISCSI_LOGIN_RESPONSE_CONT_SHIFT 6
901 #define ISCSI_LOGIN_RESPONSE_TRANSIT (0x1<<7)
902 #define ISCSI_LOGIN_RESPONSE_TRANSIT_SHIFT 7
903 	u8 version_max;
904 	u8 version_active;
905 #elif defined(__LITTLE_ENDIAN)
906 	u8 version_active;
907 	u8 version_max;
908 	u8 response_flags;
909 #define ISCSI_LOGIN_RESPONSE_NEXT_STAGE (0x3<<0)
910 #define ISCSI_LOGIN_RESPONSE_NEXT_STAGE_SHIFT 0
911 #define ISCSI_LOGIN_RESPONSE_CURRENT_STAGE (0x3<<2)
912 #define ISCSI_LOGIN_RESPONSE_CURRENT_STAGE_SHIFT 2
913 #define ISCSI_LOGIN_RESPONSE_RESERVED0 (0x3<<4)
914 #define ISCSI_LOGIN_RESPONSE_RESERVED0_SHIFT 4
915 #define ISCSI_LOGIN_RESPONSE_CONT (0x1<<6)
916 #define ISCSI_LOGIN_RESPONSE_CONT_SHIFT 6
917 #define ISCSI_LOGIN_RESPONSE_TRANSIT (0x1<<7)
918 #define ISCSI_LOGIN_RESPONSE_TRANSIT_SHIFT 7
919 	u8 op_code;
920 #endif
921 	u32 data_length;
922 	u32 exp_cmd_sn;
923 	u32 max_cmd_sn;
924 	u32 reserved1[2];
925 #if defined(__BIG_ENDIAN)
926 	u16 reserved3;
927 	u8 err_code;
928 	u8 reserved2;
929 #elif defined(__LITTLE_ENDIAN)
930 	u8 reserved2;
931 	u8 err_code;
932 	u16 reserved3;
933 #endif
934 	u32 stat_sn;
935 	u32 isid_lo;
936 #if defined(__BIG_ENDIAN)
937 	u16 isid_hi;
938 	u16 tsih;
939 #elif defined(__LITTLE_ENDIAN)
940 	u16 tsih;
941 	u16 isid_hi;
942 #endif
943 #if defined(__BIG_ENDIAN)
944 	u8 status_class;
945 	u8 status_detail;
946 	u16 reserved4;
947 #elif defined(__LITTLE_ENDIAN)
948 	u16 reserved4;
949 	u8 status_detail;
950 	u8 status_class;
951 #endif
952 	u32 reserved5[3];
953 #if defined(__BIG_ENDIAN)
954 	u16 reserved6;
955 	u16 itt;
956 #define ISCSI_LOGIN_RESPONSE_INDEX (0x3FFF<<0)
957 #define ISCSI_LOGIN_RESPONSE_INDEX_SHIFT 0
958 #define ISCSI_LOGIN_RESPONSE_TYPE (0x3<<14)
959 #define ISCSI_LOGIN_RESPONSE_TYPE_SHIFT 14
960 #elif defined(__LITTLE_ENDIAN)
961 	u16 itt;
962 #define ISCSI_LOGIN_RESPONSE_INDEX (0x3FFF<<0)
963 #define ISCSI_LOGIN_RESPONSE_INDEX_SHIFT 0
964 #define ISCSI_LOGIN_RESPONSE_TYPE (0x3<<14)
965 #define ISCSI_LOGIN_RESPONSE_TYPE_SHIFT 14
966 	u16 reserved6;
967 #endif
968 	u32 cq_req_sn;
969 };
970 
971 
972 /*
973  * iSCSI Logout SQ WQE
974  */
975 struct bnx2i_logout_request {
976 #if defined(__BIG_ENDIAN)
977 	u8 op_code;
978 	u8 op_attr;
979 #define ISCSI_LOGOUT_REQUEST_REASON (0x7F<<0)
980 #define ISCSI_LOGOUT_REQUEST_REASON_SHIFT 0
981 #define ISCSI_LOGOUT_REQUEST_ALWAYS_ONE (0x1<<7)
982 #define ISCSI_LOGOUT_REQUEST_ALWAYS_ONE_SHIFT 7
983 	u16 reserved0;
984 #elif defined(__LITTLE_ENDIAN)
985 	u16 reserved0;
986 	u8 op_attr;
987 #define ISCSI_LOGOUT_REQUEST_REASON (0x7F<<0)
988 #define ISCSI_LOGOUT_REQUEST_REASON_SHIFT 0
989 #define ISCSI_LOGOUT_REQUEST_ALWAYS_ONE (0x1<<7)
990 #define ISCSI_LOGOUT_REQUEST_ALWAYS_ONE_SHIFT 7
991 	u8 op_code;
992 #endif
993 	u32 data_length;
994 	u32 reserved1[2];
995 #if defined(__BIG_ENDIAN)
996 	u16 reserved2;
997 	u16 itt;
998 #define ISCSI_LOGOUT_REQUEST_INDEX (0x3FFF<<0)
999 #define ISCSI_LOGOUT_REQUEST_INDEX_SHIFT 0
1000 #define ISCSI_LOGOUT_REQUEST_TYPE (0x3<<14)
1001 #define ISCSI_LOGOUT_REQUEST_TYPE_SHIFT 14
1002 #elif defined(__LITTLE_ENDIAN)
1003 	u16 itt;
1004 #define ISCSI_LOGOUT_REQUEST_INDEX (0x3FFF<<0)
1005 #define ISCSI_LOGOUT_REQUEST_INDEX_SHIFT 0
1006 #define ISCSI_LOGOUT_REQUEST_TYPE (0x3<<14)
1007 #define ISCSI_LOGOUT_REQUEST_TYPE_SHIFT 14
1008 	u16 reserved2;
1009 #endif
1010 #if defined(__BIG_ENDIAN)
1011 	u16 cid;
1012 	u16 reserved3;
1013 #elif defined(__LITTLE_ENDIAN)
1014 	u16 reserved3;
1015 	u16 cid;
1016 #endif
1017 	u32 cmd_sn;
1018 	u32 reserved4[5];
1019 	u32 zero_fill;
1020 	u32 bd_list_addr_lo;
1021 	u32 bd_list_addr_hi;
1022 #if defined(__BIG_ENDIAN)
1023 	u8 cq_index;
1024 	u8 reserved6;
1025 	u8 reserved5;
1026 	u8 num_bds;
1027 #elif defined(__LITTLE_ENDIAN)
1028 	u8 num_bds;
1029 	u8 reserved5;
1030 	u8 reserved6;
1031 	u8 cq_index;
1032 #endif
1033 };
1034 
1035 
1036 /*
1037  * iSCSI Logout CQE
1038  */
1039 struct bnx2i_logout_response {
1040 #if defined(__BIG_ENDIAN)
1041 	u8 op_code;
1042 	u8 reserved1;
1043 	u8 response;
1044 	u8 reserved0;
1045 #elif defined(__LITTLE_ENDIAN)
1046 	u8 reserved0;
1047 	u8 response;
1048 	u8 reserved1;
1049 	u8 op_code;
1050 #endif
1051 	u32 reserved2;
1052 	u32 exp_cmd_sn;
1053 	u32 max_cmd_sn;
1054 	u32 reserved3[2];
1055 #if defined(__BIG_ENDIAN)
1056 	u16 reserved5;
1057 	u8 err_code;
1058 	u8 reserved4;
1059 #elif defined(__LITTLE_ENDIAN)
1060 	u8 reserved4;
1061 	u8 err_code;
1062 	u16 reserved5;
1063 #endif
1064 	u32 reserved6[3];
1065 #if defined(__BIG_ENDIAN)
1066 	u16 time_to_wait;
1067 	u16 time_to_retain;
1068 #elif defined(__LITTLE_ENDIAN)
1069 	u16 time_to_retain;
1070 	u16 time_to_wait;
1071 #endif
1072 	u32 reserved7[3];
1073 #if defined(__BIG_ENDIAN)
1074 	u16 reserved8;
1075 	u16 itt;
1076 #define ISCSI_LOGOUT_RESPONSE_INDEX (0x3FFF<<0)
1077 #define ISCSI_LOGOUT_RESPONSE_INDEX_SHIFT 0
1078 #define ISCSI_LOGOUT_RESPONSE_TYPE (0x3<<14)
1079 #define ISCSI_LOGOUT_RESPONSE_TYPE_SHIFT 14
1080 #elif defined(__LITTLE_ENDIAN)
1081 	u16 itt;
1082 #define ISCSI_LOGOUT_RESPONSE_INDEX (0x3FFF<<0)
1083 #define ISCSI_LOGOUT_RESPONSE_INDEX_SHIFT 0
1084 #define ISCSI_LOGOUT_RESPONSE_TYPE (0x3<<14)
1085 #define ISCSI_LOGOUT_RESPONSE_TYPE_SHIFT 14
1086 	u16 reserved8;
1087 #endif
1088 	u32 cq_req_sn;
1089 };
1090 
1091 
1092 /*
1093  * iSCSI Nop-In CQE
1094  */
1095 struct bnx2i_nop_in_msg {
1096 #if defined(__BIG_ENDIAN)
1097 	u8 op_code;
1098 	u8 reserved1;
1099 	u16 reserved0;
1100 #elif defined(__LITTLE_ENDIAN)
1101 	u16 reserved0;
1102 	u8 reserved1;
1103 	u8 op_code;
1104 #endif
1105 	u32 data_length;
1106 	u32 exp_cmd_sn;
1107 	u32 max_cmd_sn;
1108 	u32 ttt;
1109 	u32 reserved2;
1110 #if defined(__BIG_ENDIAN)
1111 	u16 reserved4;
1112 	u8 err_code;
1113 	u8 reserved3;
1114 #elif defined(__LITTLE_ENDIAN)
1115 	u8 reserved3;
1116 	u8 err_code;
1117 	u16 reserved4;
1118 #endif
1119 	u32 reserved5;
1120 	u32 lun[2];
1121 	u32 reserved6[4];
1122 #if defined(__BIG_ENDIAN)
1123 	u16 reserved7;
1124 	u16 itt;
1125 #define ISCSI_NOP_IN_MSG_INDEX (0x3FFF<<0)
1126 #define ISCSI_NOP_IN_MSG_INDEX_SHIFT 0
1127 #define ISCSI_NOP_IN_MSG_TYPE (0x3<<14)
1128 #define ISCSI_NOP_IN_MSG_TYPE_SHIFT 14
1129 #elif defined(__LITTLE_ENDIAN)
1130 	u16 itt;
1131 #define ISCSI_NOP_IN_MSG_INDEX (0x3FFF<<0)
1132 #define ISCSI_NOP_IN_MSG_INDEX_SHIFT 0
1133 #define ISCSI_NOP_IN_MSG_TYPE (0x3<<14)
1134 #define ISCSI_NOP_IN_MSG_TYPE_SHIFT 14
1135 	u16 reserved7;
1136 #endif
1137 	u32 cq_req_sn;
1138 };
1139 
1140 
1141 /*
1142  * iSCSI NOP-OUT SQ WQE
1143  */
1144 struct bnx2i_nop_out_request {
1145 #if defined(__BIG_ENDIAN)
1146 	u8 op_code;
1147 	u8 op_attr;
1148 #define ISCSI_NOP_OUT_REQUEST_RESERVED1 (0x7F<<0)
1149 #define ISCSI_NOP_OUT_REQUEST_RESERVED1_SHIFT 0
1150 #define ISCSI_NOP_OUT_REQUEST_ALWAYS_ONE (0x1<<7)
1151 #define ISCSI_NOP_OUT_REQUEST_ALWAYS_ONE_SHIFT 7
1152 	u16 reserved0;
1153 #elif defined(__LITTLE_ENDIAN)
1154 	u16 reserved0;
1155 	u8 op_attr;
1156 #define ISCSI_NOP_OUT_REQUEST_RESERVED1 (0x7F<<0)
1157 #define ISCSI_NOP_OUT_REQUEST_RESERVED1_SHIFT 0
1158 #define ISCSI_NOP_OUT_REQUEST_ALWAYS_ONE (0x1<<7)
1159 #define ISCSI_NOP_OUT_REQUEST_ALWAYS_ONE_SHIFT 7
1160 	u8 op_code;
1161 #endif
1162 	u32 data_length;
1163 	u32 lun[2];
1164 #if defined(__BIG_ENDIAN)
1165 	u16 reserved2;
1166 	u16 itt;
1167 #define ISCSI_NOP_OUT_REQUEST_INDEX (0x3FFF<<0)
1168 #define ISCSI_NOP_OUT_REQUEST_INDEX_SHIFT 0
1169 #define ISCSI_NOP_OUT_REQUEST_TYPE (0x3<<14)
1170 #define ISCSI_NOP_OUT_REQUEST_TYPE_SHIFT 14
1171 #elif defined(__LITTLE_ENDIAN)
1172 	u16 itt;
1173 #define ISCSI_NOP_OUT_REQUEST_INDEX (0x3FFF<<0)
1174 #define ISCSI_NOP_OUT_REQUEST_INDEX_SHIFT 0
1175 #define ISCSI_NOP_OUT_REQUEST_TYPE (0x3<<14)
1176 #define ISCSI_NOP_OUT_REQUEST_TYPE_SHIFT 14
1177 	u16 reserved2;
1178 #endif
1179 	u32 ttt;
1180 	u32 cmd_sn;
1181 	u32 reserved3[2];
1182 	u32 resp_bd_list_addr_lo;
1183 	u32 resp_bd_list_addr_hi;
1184 	u32 resp_buffer;
1185 #define ISCSI_NOP_OUT_REQUEST_RESP_BUFFER_LENGTH (0xFFFFFF<<0)
1186 #define ISCSI_NOP_OUT_REQUEST_RESP_BUFFER_LENGTH_SHIFT 0
1187 #define ISCSI_NOP_OUT_REQUEST_NUM_RESP_BDS (0xFF<<24)
1188 #define ISCSI_NOP_OUT_REQUEST_NUM_RESP_BDS_SHIFT 24
1189 #if defined(__BIG_ENDIAN)
1190 	u16 reserved7;
1191 	u8 reserved6;
1192 	u8 flags;
1193 #define ISCSI_NOP_OUT_REQUEST_RESERVED4 (0x1<<0)
1194 #define ISCSI_NOP_OUT_REQUEST_RESERVED4_SHIFT 0
1195 #define ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION (0x1<<1)
1196 #define ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION_SHIFT 1
1197 #define ISCSI_NOP_OUT_REQUEST_ZERO_FILL (0x3F<<2)
1198 #define ISCSI_NOP_OUT_REQUEST_ZERO_FILL_SHIFT 2
1199 #elif defined(__LITTLE_ENDIAN)
1200 	u8 flags;
1201 #define ISCSI_NOP_OUT_REQUEST_RESERVED4 (0x1<<0)
1202 #define ISCSI_NOP_OUT_REQUEST_RESERVED4_SHIFT 0
1203 #define ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION (0x1<<1)
1204 #define ISCSI_NOP_OUT_REQUEST_LOCAL_COMPLETION_SHIFT 1
1205 #define ISCSI_NOP_OUT_REQUEST_ZERO_FILL (0x3F<<2)
1206 #define ISCSI_NOP_OUT_REQUEST_ZERO_FILL_SHIFT 2
1207 	u8 reserved6;
1208 	u16 reserved7;
1209 #endif
1210 	u32 bd_list_addr_lo;
1211 	u32 bd_list_addr_hi;
1212 #if defined(__BIG_ENDIAN)
1213 	u8 cq_index;
1214 	u8 reserved9;
1215 	u8 reserved8;
1216 	u8 num_bds;
1217 #elif defined(__LITTLE_ENDIAN)
1218 	u8 num_bds;
1219 	u8 reserved8;
1220 	u8 reserved9;
1221 	u8 cq_index;
1222 #endif
1223 };
1224 
1225 /*
1226  * iSCSI Reject CQE
1227  */
1228 struct bnx2i_reject_msg {
1229 #if defined(__BIG_ENDIAN)
1230 	u8 op_code;
1231 	u8 reserved1;
1232 	u8 reason;
1233 	u8 reserved0;
1234 #elif defined(__LITTLE_ENDIAN)
1235 	u8 reserved0;
1236 	u8 reason;
1237 	u8 reserved1;
1238 	u8 op_code;
1239 #endif
1240 	u32 data_length;
1241 	u32 exp_cmd_sn;
1242 	u32 max_cmd_sn;
1243 	u32 reserved2[2];
1244 #if defined(__BIG_ENDIAN)
1245 	u16 reserved4;
1246 	u8 err_code;
1247 	u8 reserved3;
1248 #elif defined(__LITTLE_ENDIAN)
1249 	u8 reserved3;
1250 	u8 err_code;
1251 	u16 reserved4;
1252 #endif
1253 	u32 reserved5[8];
1254 	u32 cq_req_sn;
1255 };
1256 
1257 /*
1258  * bnx2i iSCSI TMF SQ WQE
1259  */
1260 struct bnx2i_tmf_request {
1261 #if defined(__BIG_ENDIAN)
1262 	u8 op_code;
1263 	u8 op_attr;
1264 #define ISCSI_TMF_REQUEST_FUNCTION (0x7F<<0)
1265 #define ISCSI_TMF_REQUEST_FUNCTION_SHIFT 0
1266 #define ISCSI_TMF_REQUEST_ALWAYS_ONE (0x1<<7)
1267 #define ISCSI_TMF_REQUEST_ALWAYS_ONE_SHIFT 7
1268 	u16 reserved0;
1269 #elif defined(__LITTLE_ENDIAN)
1270 	u16 reserved0;
1271 	u8 op_attr;
1272 #define ISCSI_TMF_REQUEST_FUNCTION (0x7F<<0)
1273 #define ISCSI_TMF_REQUEST_FUNCTION_SHIFT 0
1274 #define ISCSI_TMF_REQUEST_ALWAYS_ONE (0x1<<7)
1275 #define ISCSI_TMF_REQUEST_ALWAYS_ONE_SHIFT 7
1276 	u8 op_code;
1277 #endif
1278 	u32 data_length;
1279 	u32 lun[2];
1280 #if defined(__BIG_ENDIAN)
1281 	u16 reserved1;
1282 	u16 itt;
1283 #define ISCSI_TMF_REQUEST_INDEX (0x3FFF<<0)
1284 #define ISCSI_TMF_REQUEST_INDEX_SHIFT 0
1285 #define ISCSI_TMF_REQUEST_TYPE (0x3<<14)
1286 #define ISCSI_TMF_REQUEST_TYPE_SHIFT 14
1287 #elif defined(__LITTLE_ENDIAN)
1288 	u16 itt;
1289 #define ISCSI_TMF_REQUEST_INDEX (0x3FFF<<0)
1290 #define ISCSI_TMF_REQUEST_INDEX_SHIFT 0
1291 #define ISCSI_TMF_REQUEST_TYPE (0x3<<14)
1292 #define ISCSI_TMF_REQUEST_TYPE_SHIFT 14
1293 	u16 reserved1;
1294 #endif
1295 	u32 ref_itt;
1296 	u32 cmd_sn;
1297 	u32 reserved2;
1298 	u32 ref_cmd_sn;
1299 	u32 reserved3[3];
1300 	u32 zero_fill;
1301 	u32 bd_list_addr_lo;
1302 	u32 bd_list_addr_hi;
1303 #if defined(__BIG_ENDIAN)
1304 	u8 cq_index;
1305 	u8 reserved5;
1306 	u8 reserved4;
1307 	u8 num_bds;
1308 #elif defined(__LITTLE_ENDIAN)
1309 	u8 num_bds;
1310 	u8 reserved4;
1311 	u8 reserved5;
1312 	u8 cq_index;
1313 #endif
1314 };
1315 
1316 /*
1317  * iSCSI Text SQ WQE
1318  */
1319 struct bnx2i_text_request {
1320 #if defined(__BIG_ENDIAN)
1321 	u8 op_code;
1322 	u8 op_attr;
1323 #define ISCSI_TEXT_REQUEST_RESERVED1 (0x3F<<0)
1324 #define ISCSI_TEXT_REQUEST_RESERVED1_SHIFT 0
1325 #define ISCSI_TEXT_REQUEST_CONT (0x1<<6)
1326 #define ISCSI_TEXT_REQUEST_CONT_SHIFT 6
1327 #define ISCSI_TEXT_REQUEST_FINAL (0x1<<7)
1328 #define ISCSI_TEXT_REQUEST_FINAL_SHIFT 7
1329 	u16 reserved0;
1330 #elif defined(__LITTLE_ENDIAN)
1331 	u16 reserved0;
1332 	u8 op_attr;
1333 #define ISCSI_TEXT_REQUEST_RESERVED1 (0x3F<<0)
1334 #define ISCSI_TEXT_REQUEST_RESERVED1_SHIFT 0
1335 #define ISCSI_TEXT_REQUEST_CONT (0x1<<6)
1336 #define ISCSI_TEXT_REQUEST_CONT_SHIFT 6
1337 #define ISCSI_TEXT_REQUEST_FINAL (0x1<<7)
1338 #define ISCSI_TEXT_REQUEST_FINAL_SHIFT 7
1339 	u8 op_code;
1340 #endif
1341 	u32 data_length;
1342 	u32 lun[2];
1343 #if defined(__BIG_ENDIAN)
1344 	u16 reserved3;
1345 	u16 itt;
1346 #define ISCSI_TEXT_REQUEST_INDEX (0x3FFF<<0)
1347 #define ISCSI_TEXT_REQUEST_INDEX_SHIFT 0
1348 #define ISCSI_TEXT_REQUEST_TYPE (0x3<<14)
1349 #define ISCSI_TEXT_REQUEST_TYPE_SHIFT 14
1350 #elif defined(__LITTLE_ENDIAN)
1351 	u16 itt;
1352 #define ISCSI_TEXT_REQUEST_INDEX (0x3FFF<<0)
1353 #define ISCSI_TEXT_REQUEST_INDEX_SHIFT 0
1354 #define ISCSI_TEXT_REQUEST_TYPE (0x3<<14)
1355 #define ISCSI_TEXT_REQUEST_TYPE_SHIFT 14
1356 	u16 reserved3;
1357 #endif
1358 	u32 ttt;
1359 	u32 cmd_sn;
1360 	u32 reserved4[2];
1361 	u32 resp_bd_list_addr_lo;
1362 	u32 resp_bd_list_addr_hi;
1363 	u32 resp_buffer;
1364 #define ISCSI_TEXT_REQUEST_RESP_BUFFER_LENGTH (0xFFFFFF<<0)
1365 #define ISCSI_TEXT_REQUEST_RESP_BUFFER_LENGTH_SHIFT 0
1366 #define ISCSI_TEXT_REQUEST_NUM_RESP_BDS (0xFF<<24)
1367 #define ISCSI_TEXT_REQUEST_NUM_RESP_BDS_SHIFT 24
1368 	u32 zero_fill;
1369 	u32 bd_list_addr_lo;
1370 	u32 bd_list_addr_hi;
1371 #if defined(__BIG_ENDIAN)
1372 	u8 cq_index;
1373 	u8 reserved7;
1374 	u8 reserved6;
1375 	u8 num_bds;
1376 #elif defined(__LITTLE_ENDIAN)
1377 	u8 num_bds;
1378 	u8 reserved6;
1379 	u8 reserved7;
1380 	u8 cq_index;
1381 #endif
1382 };
1383 
1384 /*
1385  * iSCSI SQ WQE
1386  */
1387 union iscsi_request {
1388 	struct bnx2i_cmd_request cmd;
1389 	struct bnx2i_tmf_request tmf;
1390 	struct bnx2i_nop_out_request nop_out;
1391 	struct bnx2i_login_request login_req;
1392 	struct bnx2i_text_request text;
1393 	struct bnx2i_logout_request logout_req;
1394 	struct bnx2i_cleanup_request cleanup;
1395 };
1396 
1397 
1398 /*
1399  * iSCSI TMF CQE
1400  */
1401 struct bnx2i_tmf_response {
1402 #if defined(__BIG_ENDIAN)
1403 	u8 op_code;
1404 	u8 reserved1;
1405 	u8 response;
1406 	u8 reserved0;
1407 #elif defined(__LITTLE_ENDIAN)
1408 	u8 reserved0;
1409 	u8 response;
1410 	u8 reserved1;
1411 	u8 op_code;
1412 #endif
1413 	u32 reserved2;
1414 	u32 exp_cmd_sn;
1415 	u32 max_cmd_sn;
1416 	u32 reserved3[2];
1417 #if defined(__BIG_ENDIAN)
1418 	u16 reserved5;
1419 	u8 err_code;
1420 	u8 reserved4;
1421 #elif defined(__LITTLE_ENDIAN)
1422 	u8 reserved4;
1423 	u8 err_code;
1424 	u16 reserved5;
1425 #endif
1426 	u32 reserved6[7];
1427 #if defined(__BIG_ENDIAN)
1428 	u16 reserved7;
1429 	u16 itt;
1430 #define ISCSI_TMF_RESPONSE_INDEX (0x3FFF<<0)
1431 #define ISCSI_TMF_RESPONSE_INDEX_SHIFT 0
1432 #define ISCSI_TMF_RESPONSE_TYPE (0x3<<14)
1433 #define ISCSI_TMF_RESPONSE_TYPE_SHIFT 14
1434 #elif defined(__LITTLE_ENDIAN)
1435 	u16 itt;
1436 #define ISCSI_TMF_RESPONSE_INDEX (0x3FFF<<0)
1437 #define ISCSI_TMF_RESPONSE_INDEX_SHIFT 0
1438 #define ISCSI_TMF_RESPONSE_TYPE (0x3<<14)
1439 #define ISCSI_TMF_RESPONSE_TYPE_SHIFT 14
1440 	u16 reserved7;
1441 #endif
1442 	u32 cq_req_sn;
1443 };
1444 
1445 /*
1446  * iSCSI Text CQE
1447  */
1448 struct bnx2i_text_response {
1449 #if defined(__BIG_ENDIAN)
1450 	u8 op_code;
1451 	u8 response_flags;
1452 #define ISCSI_TEXT_RESPONSE_RESERVED1 (0x3F<<0)
1453 #define ISCSI_TEXT_RESPONSE_RESERVED1_SHIFT 0
1454 #define ISCSI_TEXT_RESPONSE_CONT (0x1<<6)
1455 #define ISCSI_TEXT_RESPONSE_CONT_SHIFT 6
1456 #define ISCSI_TEXT_RESPONSE_FINAL (0x1<<7)
1457 #define ISCSI_TEXT_RESPONSE_FINAL_SHIFT 7
1458 	u16 reserved0;
1459 #elif defined(__LITTLE_ENDIAN)
1460 	u16 reserved0;
1461 	u8 response_flags;
1462 #define ISCSI_TEXT_RESPONSE_RESERVED1 (0x3F<<0)
1463 #define ISCSI_TEXT_RESPONSE_RESERVED1_SHIFT 0
1464 #define ISCSI_TEXT_RESPONSE_CONT (0x1<<6)
1465 #define ISCSI_TEXT_RESPONSE_CONT_SHIFT 6
1466 #define ISCSI_TEXT_RESPONSE_FINAL (0x1<<7)
1467 #define ISCSI_TEXT_RESPONSE_FINAL_SHIFT 7
1468 	u8 op_code;
1469 #endif
1470 	u32 data_length;
1471 	u32 exp_cmd_sn;
1472 	u32 max_cmd_sn;
1473 	u32 ttt;
1474 	u32 reserved2;
1475 #if defined(__BIG_ENDIAN)
1476 	u16 reserved4;
1477 	u8 err_code;
1478 	u8 reserved3;
1479 #elif defined(__LITTLE_ENDIAN)
1480 	u8 reserved3;
1481 	u8 err_code;
1482 	u16 reserved4;
1483 #endif
1484 	u32 reserved5;
1485 	u32 lun[2];
1486 	u32 reserved6[4];
1487 #if defined(__BIG_ENDIAN)
1488 	u16 reserved7;
1489 	u16 itt;
1490 #define ISCSI_TEXT_RESPONSE_INDEX (0x3FFF<<0)
1491 #define ISCSI_TEXT_RESPONSE_INDEX_SHIFT 0
1492 #define ISCSI_TEXT_RESPONSE_TYPE (0x3<<14)
1493 #define ISCSI_TEXT_RESPONSE_TYPE_SHIFT 14
1494 #elif defined(__LITTLE_ENDIAN)
1495 	u16 itt;
1496 #define ISCSI_TEXT_RESPONSE_INDEX (0x3FFF<<0)
1497 #define ISCSI_TEXT_RESPONSE_INDEX_SHIFT 0
1498 #define ISCSI_TEXT_RESPONSE_TYPE (0x3<<14)
1499 #define ISCSI_TEXT_RESPONSE_TYPE_SHIFT 14
1500 	u16 reserved7;
1501 #endif
1502 	u32 cq_req_sn;
1503 };
1504 
1505 /*
1506  * iSCSI CQE
1507  */
1508 union iscsi_response {
1509 	struct bnx2i_cmd_response cmd;
1510 	struct bnx2i_tmf_response tmf;
1511 	struct bnx2i_login_response login_resp;
1512 	struct bnx2i_text_response text;
1513 	struct bnx2i_logout_response logout_resp;
1514 	struct bnx2i_cleanup_response cleanup;
1515 	struct bnx2i_reject_msg reject;
1516 	struct bnx2i_async_msg async;
1517 	struct bnx2i_nop_in_msg nop_in;
1518 };
1519 
1520 #endif /* __57XX_ISCSI_HSI_LINUX_LE__ */
1521