be2iscsi: Fix to process 25G link speed info from FW
[cascardo/linux.git] / drivers / scsi / be2iscsi / be_cmds.h
1 /**
2  * Copyright (C) 2005 - 2015 Emulex
3  * All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation.  The full GNU General
8  * Public License is included in this distribution in the file called COPYING.
9  *
10  * Contact Information:
11  * linux-drivers@avagotech.com
12  *
13  * Emulex
14  * 3333 Susan Street
15  * Costa Mesa, CA 92626
16  */
17
18 #ifndef BEISCSI_CMDS_H
19 #define BEISCSI_CMDS_H
20
21 /**
22  * The driver sends configuration and managements command requests to the
23  * firmware in the BE. These requests are communicated to the processor
24  * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
25  * WRB inside a MAILBOX.
26  * The commands are serviced by the ARM processor in the OneConnect's MPU.
27  */
28 struct be_sge {
29         __le32 pa_lo;
30         __le32 pa_hi;
31         __le32 len;
32 };
33
34 #define MCC_WRB_SGE_CNT_SHIFT 3 /* bits 3 - 7 of dword 0 */
35 #define MCC_WRB_SGE_CNT_MASK 0x1F       /* bits 3 - 7 of dword 0 */
36 struct be_mcc_wrb {
37         u32 embedded;           /* dword 0 */
38         u32 payload_length;     /* dword 1 */
39         u32 tag0;               /* dword 2 */
40         u32 tag1;               /* dword 3 */
41         u32 rsvd;               /* dword 4 */
42         union {
43 #define EMBED_MBX_MAX_PAYLOAD_SIZE  220
44                 u8 embedded_payload[236];       /* used by embedded cmds */
45                 struct be_sge sgl[19];  /* used by non-embedded cmds */
46         } payload;
47 };
48
49 #define CQE_FLAGS_VALID_MASK (1 << 31)
50 #define CQE_FLAGS_ASYNC_MASK (1 << 30)
51 #define CQE_FLAGS_COMPLETED_MASK        (1 << 28)
52 #define CQE_FLAGS_CONSUMED_MASK         (1 << 27)
53
54 /* Completion Status */
55 #define MCC_STATUS_SUCCESS 0x0
56 #define MCC_STATUS_FAILED 0x1
57 #define MCC_STATUS_ILLEGAL_REQUEST 0x2
58 #define MCC_STATUS_ILLEGAL_FIELD 0x3
59 #define MCC_STATUS_INSUFFICIENT_BUFFER 0x4
60
61 #define CQE_STATUS_COMPL_MASK 0xFFFF
62 #define CQE_STATUS_COMPL_SHIFT 0        /* bits 0 - 15 */
63 #define CQE_STATUS_EXTD_MASK 0xFFFF
64 #define CQE_STATUS_EXTD_SHIFT 16                /* bits 0 - 15 */
65 #define CQE_STATUS_ADDL_MASK    0xFF00
66 #define CQE_STATUS_MASK 0xFF
67 #define CQE_STATUS_ADDL_SHIFT   0x08
68 #define CQE_STATUS_WRB_MASK     0xFF0000
69 #define CQE_STATUS_WRB_SHIFT    16
70 #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
71 #define BEISCSI_FW_MBX_TIMEOUT  100
72
73 /* MBOX Command VER */
74 #define MBX_CMD_VER1    0x01
75 #define MBX_CMD_VER2    0x02
76
77 struct be_mcc_compl {
78         u32 status;             /* dword 0 */
79         u32 tag0;               /* dword 1 */
80         u32 tag1;               /* dword 2 */
81         u32 flags;              /* dword 3 */
82 };
83
84 /********* Mailbox door bell *************/
85 /**
86  * Used for driver communication with the FW.
87  * The software must write this register twice to post any command. First,
88  * it writes the register with hi=1 and the upper bits of the physical address
89  * for the MAILBOX structure. Software must poll the ready bit until this
90  * is acknowledged. Then, sotware writes the register with hi=0 with the lower
91  * bits in the address. It must poll the ready bit until the command is
92  * complete. Upon completion, the MAILBOX will contain a valid completion
93  * queue entry.
94  */
95 #define MPU_MAILBOX_DB_OFFSET   0x160
96 #define MPU_MAILBOX_DB_RDY_MASK 0x1     /* bit 0 */
97 #define MPU_MAILBOX_DB_HI_MASK  0x2     /* bit 1 */
98
99 /********** MPU semphore ******************/
100 #define MPU_EP_SEMAPHORE_OFFSET 0xac
101 #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
102 #define EP_SEMAPHORE_POST_ERR_MASK 0x1
103 #define EP_SEMAPHORE_POST_ERR_SHIFT 31
104
105 /********** MCC door bell ************/
106 #define DB_MCCQ_OFFSET 0x140
107 #define DB_MCCQ_RING_ID_MASK 0xFFFF             /* bits 0 - 15 */
108 /* Number of entries posted */
109 #define DB_MCCQ_NUM_POSTED_SHIFT 16             /* bits 16 - 29 */
110
111 /* MPU semphore POST stage values */
112 #define POST_STAGE_ARMFW_RDY            0xc000  /* FW is done with POST */
113
114 /**
115  * When the async bit of mcc_compl is set, the last 4 bytes of
116  * mcc_compl is interpreted as follows:
117  */
118 #define ASYNC_TRAILER_EVENT_CODE_SHIFT  8       /* bits 8 - 15 */
119 #define ASYNC_TRAILER_EVENT_CODE_MASK   0xFF
120 #define ASYNC_EVENT_CODE_LINK_STATE     0x1
121 #define ASYNC_EVENT_CODE_ISCSI          0x4
122 #define ASYNC_EVENT_CODE_SLI            0x11
123
124 #define ASYNC_TRAILER_EVENT_TYPE_SHIFT  16      /* bits 16 - 23 */
125 #define ASYNC_TRAILER_EVENT_TYPE_MASK   0xFF
126
127 /* iSCSI events */
128 #define ASYNC_EVENT_NEW_ISCSI_TGT_DISC  0x4
129 #define ASYNC_EVENT_NEW_ISCSI_CONN      0x5
130 #define ASYNC_EVENT_NEW_TCP_CONN        0x7
131
132 /* SLI events */
133 #define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED      0x9
134 #define ASYNC_SLI_LINK_EFFECT_VALID(le)         (le & 0x80)
135 #define ASYNC_SLI_LINK_EFFECT_SEV(le)           ((le >> 1)  & 0x03)
136 #define ASYNC_SLI_LINK_EFFECT_STATE(le)         (le & 0x01)
137
138 struct be_async_event_trailer {
139         u32 code;
140 };
141
142 enum {
143         ASYNC_EVENT_LINK_DOWN = 0x0,
144         ASYNC_EVENT_LINK_UP = 0x1,
145         ASYNC_EVENT_LOGICAL = 0x2
146 };
147
148 /**
149  * When the event code of an async trailer is link-state, the mcc_compl
150  * must be interpreted as follows
151  */
152 struct be_async_event_link_state {
153         u8 physical_port;
154         u8 port_link_status;
155         u8 port_duplex;
156 /* BE2ISCSI_LINK_SPEED_ZERO     0x00 - no link */
157 #define BE2ISCSI_LINK_SPEED_10MBPS      0x01
158 #define BE2ISCSI_LINK_SPEED_100MBPS     0x02
159 #define BE2ISCSI_LINK_SPEED_1GBPS       0x03
160 #define BE2ISCSI_LINK_SPEED_10GBPS      0x04
161 #define BE2ISCSI_LINK_SPEED_25GBPS      0x06
162 #define BE2ISCSI_LINK_SPEED_40GBPS      0x07
163         u8 port_speed;
164 #define BEISCSI_PHY_LINK_FAULT_NONE     0x00
165 #define BEISCSI_PHY_LINK_FAULT_LOCAL    0x01
166 #define BEISCSI_PHY_LINK_FAULT_REMOTE   0x02
167         u8 port_fault;
168         u8 event_reason;
169         u16 qos_link_speed;
170         u32 event_tag;
171         struct be_async_event_trailer trailer;
172 } __packed;
173
174 /**
175  * When async-trailer is SLI event, mcc_compl is interpreted as
176  */
177 struct be_async_event_sli {
178         u32 event_data1;
179         u32 event_data2;
180         u32 reserved;
181         u32 trailer;
182 } __packed;
183
184 struct be_mcc_mailbox {
185         struct be_mcc_wrb wrb;
186         struct be_mcc_compl compl;
187 };
188
189 /* Type of subsystems supported by FW */
190 #define CMD_SUBSYSTEM_COMMON    0x1
191 #define CMD_SUBSYSTEM_ISCSI     0x2
192 #define CMD_SUBSYSTEM_ETH       0x3
193 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
194 #define CMD_COMMON_TCP_UPLOAD   0x1
195
196 /**
197  * List of common opcodes subsystem  CMD_SUBSYSTEM_COMMON
198  * These opcodes are unique for each subsystem defined above
199  */
200 #define OPCODE_COMMON_CQ_CREATE                         12
201 #define OPCODE_COMMON_EQ_CREATE                         13
202 #define OPCODE_COMMON_MCC_CREATE                        21
203 #define OPCODE_COMMON_MCC_CREATE_EXT                    90
204 #define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS       24
205 #define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS    25
206 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES               32
207 #define OPCODE_COMMON_GET_FW_VERSION                    35
208 #define OPCODE_COMMON_MODIFY_EQ_DELAY                   41
209 #define OPCODE_COMMON_FIRMWARE_CONFIG                   42
210 #define OPCODE_COMMON_MCC_DESTROY                       53
211 #define OPCODE_COMMON_CQ_DESTROY                        54
212 #define OPCODE_COMMON_EQ_DESTROY                        55
213 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG             58
214 #define OPCODE_COMMON_FUNCTION_RESET                    61
215 #define OPCODE_COMMON_GET_PORT_NAME                     77
216
217 /**
218  * LIST of opcodes that are common between Initiator and Target
219  * used by CMD_SUBSYSTEM_ISCSI
220  * These opcodes are unique for each subsystem defined above
221  */
222 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES          2
223 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES        3
224 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG         7
225 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN               14
226 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR       17
227 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR  18
228 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR         21
229 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY    22
230 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
231 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID          24
232 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO            25
233 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
234 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE                 64
235 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY                65
236 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE                 66
237 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY                67
238
239 struct be_cmd_req_hdr {
240         u8 opcode;              /* dword 0 */
241         u8 subsystem;           /* dword 0 */
242         u8 port_number;         /* dword 0 */
243         u8 domain;              /* dword 0 */
244         u32 timeout;            /* dword 1 */
245         u32 request_length;     /* dword 2 */
246         u8 version;             /* dword 3 */
247         u8 rsvd0[3];            /* dword 3 */
248 };
249
250 struct be_cmd_resp_hdr {
251         u32 info;               /* dword 0 */
252         u32 status;             /* dword 1 */
253         u32 response_length;    /* dword 2 */
254         u32 actual_resp_len;    /* dword 3 */
255 };
256
257 struct phys_addr {
258         u32 lo;
259         u32 hi;
260 };
261
262 struct virt_addr {
263         u32 lo;
264         u32 hi;
265 };
266 /**************************
267  * BE Command definitions *
268  **************************/
269
270 /**
271  * Pseudo amap definition in which each bit of the actual structure is defined
272  * as a byte - used to calculate offset/shift/mask of each field
273  */
274 struct amap_eq_context {
275         u8 cidx[13];            /* dword 0 */
276         u8 rsvd0[3];            /* dword 0 */
277         u8 epidx[13];           /* dword 0 */
278         u8 valid;               /* dword 0 */
279         u8 rsvd1;               /* dword 0 */
280         u8 size;                /* dword 0 */
281         u8 pidx[13];            /* dword 1 */
282         u8 rsvd2[3];            /* dword 1 */
283         u8 pd[10];              /* dword 1 */
284         u8 count[3];            /* dword 1 */
285         u8 solevent;            /* dword 1 */
286         u8 stalled;             /* dword 1 */
287         u8 armed;               /* dword 1 */
288         u8 rsvd3[4];            /* dword 2 */
289         u8 func[8];             /* dword 2 */
290         u8 rsvd4;               /* dword 2 */
291         u8 delaymult[10];       /* dword 2 */
292         u8 rsvd5[2];            /* dword 2 */
293         u8 phase[2];            /* dword 2 */
294         u8 nodelay;             /* dword 2 */
295         u8 rsvd6[4];            /* dword 2 */
296         u8 rsvd7[32];           /* dword 3 */
297 } __packed;
298
299 struct be_cmd_req_eq_create {
300         struct be_cmd_req_hdr hdr;      /* dw[4] */
301         u16 num_pages;          /* sword */
302         u16 rsvd0;              /* sword */
303         u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
304         struct phys_addr pages[8];
305 } __packed;
306
307 struct be_cmd_resp_eq_create {
308         struct be_cmd_resp_hdr resp_hdr;
309         u16 eq_id;              /* sword */
310         u16 rsvd0;              /* sword */
311 } __packed;
312
313 struct be_set_eqd {
314         u32 eq_id;
315         u32 phase;
316         u32 delay_multiplier;
317 } __packed;
318
319 struct mgmt_chap_format {
320         u32 flags;
321         u8  intr_chap_name[256];
322         u8  intr_secret[16];
323         u8  target_chap_name[256];
324         u8  target_secret[16];
325         u16 intr_chap_name_length;
326         u16 intr_secret_length;
327         u16 target_chap_name_length;
328         u16 target_secret_length;
329 } __packed;
330
331 struct mgmt_auth_method_format {
332         u8      auth_method_type;
333         u8      padding[3];
334         struct  mgmt_chap_format chap;
335 } __packed;
336
337 struct be_cmd_req_logout_fw_sess {
338         struct be_cmd_req_hdr hdr;      /* dw[4] */
339         uint32_t session_handle;
340 } __packed;
341
342 struct be_cmd_resp_logout_fw_sess {
343         struct be_cmd_resp_hdr hdr;     /* dw[4] */
344 #define BEISCSI_MGMT_SESSION_CLOSE 0x20
345         uint32_t session_status;
346 } __packed;
347
348 struct mgmt_conn_login_options {
349         u8 flags;
350         u8 header_digest;
351         u8 data_digest;
352         u8 rsvd0;
353         u32 max_recv_datasegment_len_ini;
354         u32 max_recv_datasegment_len_tgt;
355         u32 tcp_mss;
356         u32 tcp_window_size;
357         struct  mgmt_auth_method_format auth_data;
358 } __packed;
359
360 struct ip_addr_format {
361         u16 size_of_structure;
362         u8 reserved;
363         u8 ip_type;
364         u8 addr[16];
365         u32 rsvd0;
366 } __packed;
367
368 struct mgmt_conn_info {
369         u32     connection_handle;
370         u32     connection_status;
371         u16     src_port;
372         u16     dest_port;
373         u16     dest_port_redirected;
374         u16     cid;
375         u32     estimated_throughput;
376         struct  ip_addr_format  src_ipaddr;
377         struct  ip_addr_format  dest_ipaddr;
378         struct  ip_addr_format  dest_ipaddr_redirected;
379         struct  mgmt_conn_login_options negotiated_login_options;
380 } __packed;
381
382 struct mgmt_session_login_options {
383         u8      flags;
384         u8      error_recovery_level;
385         u16     rsvd0;
386         u32     first_burst_length;
387         u32     max_burst_length;
388         u16     max_connections;
389         u16     max_outstanding_r2t;
390         u16     default_time2wait;
391         u16     default_time2retain;
392 } __packed;
393
394 struct mgmt_session_info {
395         u32     session_handle;
396         u32     status;
397         u8      isid[6];
398         u16     tsih;
399         u32     session_flags;
400         u16     conn_count;
401         u16     pad;
402         u8      target_name[224];
403         u8      initiator_iscsiname[224];
404         struct  mgmt_session_login_options negotiated_login_options;
405         struct  mgmt_conn_info  conn_list[1];
406 } __packed;
407
408 struct be_cmd_get_session_req {
409         struct be_cmd_req_hdr hdr;
410         u32 session_handle;
411 } __packed;
412
413 struct be_cmd_get_session_resp {
414         struct be_cmd_resp_hdr hdr;
415         struct mgmt_session_info session_info;
416 } __packed;
417
418 struct mac_addr {
419         u16 size_of_structure;
420         u8 addr[ETH_ALEN];
421 } __packed;
422
423 struct be_cmd_get_boot_target_req {
424         struct be_cmd_req_hdr hdr;
425 } __packed;
426
427 struct be_cmd_get_boot_target_resp {
428         struct be_cmd_resp_hdr hdr;
429         u32  boot_session_count;
430         int  boot_session_handle;
431 };
432
433 struct be_cmd_reopen_session_req {
434         struct be_cmd_req_hdr hdr;
435 #define BE_REOPEN_ALL_SESSIONS  0x00
436 #define BE_REOPEN_BOOT_SESSIONS 0x01
437 #define BE_REOPEN_A_SESSION     0x02
438         u16 reopen_type;
439         u16 rsvd;
440         u32 session_handle;
441 } __packed;
442
443 struct be_cmd_reopen_session_resp {
444         struct be_cmd_resp_hdr hdr;
445         u32 rsvd;
446         u32 session_handle;
447 } __packed;
448
449
450 struct be_cmd_mac_query_req {
451         struct be_cmd_req_hdr hdr;
452         u8 type;
453         u8 permanent;
454         u16 if_id;
455 } __packed;
456
457 struct be_cmd_get_mac_resp {
458         struct be_cmd_resp_hdr hdr;
459         struct mac_addr mac;
460 };
461
462 struct be_ip_addr_subnet_format {
463         u16 size_of_structure;
464         u8 ip_type;
465         u8 ipv6_prefix_length;
466         u8 addr[16];
467         u8 subnet_mask[16];
468         u32 rsvd0;
469 } __packed;
470
471 struct be_cmd_get_if_info_req {
472         struct be_cmd_req_hdr hdr;
473         u32 interface_hndl;
474         u32 ip_type;
475 } __packed;
476
477 struct be_cmd_get_if_info_resp {
478         struct be_cmd_req_hdr hdr;
479         u32 interface_hndl;
480         u32 vlan_priority;
481         u32 ip_addr_count;
482         u32 dhcp_state;
483         struct be_ip_addr_subnet_format ip_addr;
484 } __packed;
485
486 struct be_ip_addr_record {
487         u32 action;
488         u32 interface_hndl;
489         struct be_ip_addr_subnet_format ip_addr;
490         u32 status;
491 } __packed;
492
493 struct be_ip_addr_record_params {
494         u32 record_entry_count;
495         struct be_ip_addr_record ip_record;
496 } __packed;
497
498 struct be_cmd_set_ip_addr_req {
499         struct be_cmd_req_hdr hdr;
500         struct be_ip_addr_record_params ip_params;
501 } __packed;
502
503
504 struct be_cmd_set_dhcp_req {
505         struct be_cmd_req_hdr hdr;
506         u32 interface_hndl;
507         u32 ip_type;
508         u32 flags;
509         u32 retry_count;
510 } __packed;
511
512 struct be_cmd_rel_dhcp_req {
513         struct be_cmd_req_hdr hdr;
514         u32 interface_hndl;
515         u32 ip_type;
516 } __packed;
517
518 struct be_cmd_set_def_gateway_req {
519         struct be_cmd_req_hdr hdr;
520         u32 action;
521         struct ip_addr_format ip_addr;
522 } __packed;
523
524 struct be_cmd_get_def_gateway_req {
525         struct be_cmd_req_hdr hdr;
526         u32 ip_type;
527 } __packed;
528
529 struct be_cmd_get_def_gateway_resp {
530         struct be_cmd_req_hdr hdr;
531         struct ip_addr_format ip_addr;
532 } __packed;
533
534 #define BEISCSI_VLAN_DISABLE    0xFFFF
535 struct be_cmd_set_vlan_req {
536         struct be_cmd_req_hdr hdr;
537         u32 interface_hndl;
538         u32 vlan_priority;
539 } __packed;
540 /******************** Create CQ ***************************/
541 /**
542  * Pseudo amap definition in which each bit of the actual structure is defined
543  * as a byte - used to calculate offset/shift/mask of each field
544  */
545 struct amap_cq_context {
546         u8 cidx[11];            /* dword 0 */
547         u8 rsvd0;               /* dword 0 */
548         u8 coalescwm[2];        /* dword 0 */
549         u8 nodelay;             /* dword 0 */
550         u8 epidx[11];           /* dword 0 */
551         u8 rsvd1;               /* dword 0 */
552         u8 count[2];            /* dword 0 */
553         u8 valid;               /* dword 0 */
554         u8 solevent;            /* dword 0 */
555         u8 eventable;           /* dword 0 */
556         u8 pidx[11];            /* dword 1 */
557         u8 rsvd2;               /* dword 1 */
558         u8 pd[10];              /* dword 1 */
559         u8 eqid[8];             /* dword 1 */
560         u8 stalled;             /* dword 1 */
561         u8 armed;               /* dword 1 */
562         u8 rsvd3[4];            /* dword 2 */
563         u8 func[8];             /* dword 2 */
564         u8 rsvd4[20];           /* dword 2 */
565         u8 rsvd5[32];           /* dword 3 */
566 } __packed;
567
568 struct amap_cq_context_v2 {
569         u8 rsvd0[12];   /* dword 0 */
570         u8 coalescwm[2];    /* dword 0 */
571         u8 nodelay;     /* dword 0 */
572         u8 rsvd1[12];   /* dword 0 */
573         u8 count[2];    /* dword 0 */
574         u8 valid;       /* dword 0 */
575         u8 rsvd2;       /* dword 0 */
576         u8 eventable;   /* dword 0 */
577         u8 eqid[16];    /* dword 1 */
578         u8 rsvd3[15];   /* dword 1 */
579         u8 armed;       /* dword 1 */
580         u8 cqecount[16];/* dword 2 */
581         u8 rsvd4[16];   /* dword 2 */
582         u8 rsvd5[32];   /* dword 3 */
583 };
584
585 struct be_cmd_req_cq_create {
586         struct be_cmd_req_hdr hdr;
587         u16 num_pages;
588         u8 page_size;
589         u8 rsvd0;
590         u8 context[sizeof(struct amap_cq_context) / 8];
591         struct phys_addr pages[4];
592 } __packed;
593
594 struct be_cmd_resp_cq_create {
595         struct be_cmd_resp_hdr hdr;
596         u16 cq_id;
597         u16 rsvd0;
598 } __packed;
599
600 /******************** Create MCCQ ***************************/
601 /**
602  * Pseudo amap definition in which each bit of the actual structure is defined
603  * as a byte - used to calculate offset/shift/mask of each field
604  */
605 struct amap_mcc_context {
606         u8 con_index[14];
607         u8 rsvd0[2];
608         u8 ring_size[4];
609         u8 fetch_wrb;
610         u8 fetch_r2t;
611         u8 cq_id[10];
612         u8 prod_index[14];
613         u8 fid[8];
614         u8 pdid[9];
615         u8 valid;
616         u8 rsvd1[32];
617         u8 rsvd2[32];
618 } __packed;
619
620 struct be_cmd_req_mcc_create_ext {
621         struct be_cmd_req_hdr hdr;
622         u16 num_pages;
623         u16 rsvd0;
624         u32 async_evt_bitmap;
625         u8 context[sizeof(struct amap_mcc_context) / 8];
626         struct phys_addr pages[8];
627 } __packed;
628
629 struct be_cmd_resp_mcc_create {
630         struct be_cmd_resp_hdr hdr;
631         u16 id;
632         u16 rsvd0;
633 } __packed;
634
635 /******************** Q Destroy  ***************************/
636 /* Type of Queue to be destroyed */
637 enum {
638         QTYPE_EQ = 1,
639         QTYPE_CQ,
640         QTYPE_MCCQ,
641         QTYPE_WRBQ,
642         QTYPE_DPDUQ,
643         QTYPE_SGL
644 };
645
646 struct be_cmd_req_q_destroy {
647         struct be_cmd_req_hdr hdr;
648         u16 id;
649         u16 bypass_flush;       /* valid only for rx q destroy */
650 } __packed;
651
652 struct macaddr {
653         u8 byte[ETH_ALEN];
654 };
655
656 struct be_cmd_req_mcast_mac_config {
657         struct be_cmd_req_hdr hdr;
658         u16 num_mac;
659         u8 promiscuous;
660         u8 interface_id;
661         struct macaddr mac[32];
662 } __packed;
663
664 static inline void *embedded_payload(struct be_mcc_wrb *wrb)
665 {
666         return wrb->payload.embedded_payload;
667 }
668
669 static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
670 {
671         return &wrb->payload.sgl[0];
672 }
673
674 /******************** Modify EQ Delay *******************/
675 struct be_cmd_req_modify_eq_delay {
676         struct be_cmd_req_hdr hdr;
677         __le32 num_eq;
678         struct {
679                 __le32 eq_id;
680                 __le32 phase;
681                 __le32 delay_multiplier;
682         } delay[MAX_CPUS];
683 } __packed;
684
685 /******************** Get MAC ADDR *******************/
686
687 #define ETH_ALEN        6
688
689 struct be_cmd_get_nic_conf_req {
690         struct be_cmd_req_hdr hdr;
691         u32 nic_port_count;
692         u32 speed;
693         u32 max_speed;
694         u32 link_state;
695         u32 max_frame_size;
696         u16 size_of_structure;
697         u8 mac_address[ETH_ALEN];
698         u32 rsvd[23];
699 };
700
701 struct be_cmd_get_nic_conf_resp {
702         struct be_cmd_resp_hdr hdr;
703         u32 nic_port_count;
704         u32 speed;
705         u32 max_speed;
706         u32 link_state;
707         u32 max_frame_size;
708         u16 size_of_structure;
709         u8 mac_address[6];
710         u32 rsvd[23];
711 };
712
713 #define BEISCSI_ALIAS_LEN 32
714
715 struct be_cmd_hba_name {
716         struct be_cmd_req_hdr hdr;
717         u16 flags;
718         u16 rsvd0;
719         u8 initiator_name[ISCSI_NAME_LEN];
720         u8 initiator_alias[BEISCSI_ALIAS_LEN];
721 } __packed;
722
723 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
724                           struct be_queue_info *eq, int eq_delay);
725
726 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
727                           struct be_queue_info *cq, struct be_queue_info *eq,
728                           bool sol_evts, bool no_delay,
729                           int num_cqe_dma_coalesce);
730
731 int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
732                           int type);
733 int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
734                         struct be_queue_info *mccq,
735                         struct be_queue_info *cq);
736
737 int be_poll_mcc(struct be_ctrl_info *ctrl);
738 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
739                                       struct beiscsi_hba *phba);
740 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
741
742 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
743
744 int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
745                             int num);
746 int beiscsi_mccq_compl(struct beiscsi_hba *phba,
747                         uint32_t tag, struct be_mcc_wrb **wrb,
748                         struct be_dma_mem *mbx_cmd_mem);
749 /*ISCSI Functuions */
750 int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
751 int be_cmd_fw_uninit(struct be_ctrl_info *ctrl);
752
753 struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
754 struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
755 int be_mcc_notify_wait(struct beiscsi_hba *phba, unsigned int tag);
756 void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
757 unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
758 void beiscsi_process_async_event(struct beiscsi_hba *phba,
759                                 struct be_mcc_compl *compl);
760 int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
761                                     struct be_mcc_compl *compl);
762
763 int be_mbox_notify(struct be_ctrl_info *ctrl);
764
765 int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
766                                     struct be_queue_info *cq,
767                                     struct be_queue_info *dq, int length,
768                                     int entry_size, uint8_t is_header,
769                                     uint8_t ulp_num);
770
771 int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
772                                     struct be_dma_mem *q_mem);
773
774 int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
775
776 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
777                                 struct be_dma_mem *q_mem, u32 page_offset,
778                                 u32 num_pages);
779
780 int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
781
782 int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
783                        struct be_queue_info *wrbq,
784                        struct hwi_wrb_context *pwrb_context,
785                        uint8_t ulp_num);
786
787 /* Configuration Functions */
788 int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
789
790 struct be_default_pdu_context {
791         u32 dw[4];
792 } __packed;
793
794 struct amap_be_default_pdu_context {
795         u8 dbuf_cindex[13];     /* dword 0 */
796         u8 rsvd0[3];            /* dword 0 */
797         u8 ring_size[4];        /* dword 0 */
798         u8 ring_state[4];       /* dword 0 */
799         u8 rsvd1[8];            /* dword 0 */
800         u8 dbuf_pindex[13];     /* dword 1 */
801         u8 rsvd2;               /* dword 1 */
802         u8 pci_func_id[8];      /* dword 1 */
803         u8 rx_pdid[9];          /* dword 1 */
804         u8 rx_pdid_valid;       /* dword 1 */
805         u8 default_buffer_size[16];     /* dword 2 */
806         u8 cq_id_recv[10];      /* dword 2 */
807         u8 rx_pdid_not_valid;   /* dword 2 */
808         u8 rsvd3[5];            /* dword 2 */
809         u8 rsvd4[32];           /* dword 3 */
810 } __packed;
811
812 struct amap_default_pdu_context_ext {
813         u8 rsvd0[16];   /* dword 0 */
814         u8 ring_size[4];    /* dword 0 */
815         u8 rsvd1[12];   /* dword 0 */
816         u8 rsvd2[22];   /* dword 1 */
817         u8 rx_pdid[9];  /* dword 1 */
818         u8 rx_pdid_valid;   /* dword 1 */
819         u8 default_buffer_size[16]; /* dword 2 */
820         u8 cq_id_recv[16];  /* dword 2 */
821         u8 rsvd3[32];   /* dword 3 */
822 } __packed;
823
824 struct be_defq_create_req {
825         struct be_cmd_req_hdr hdr;
826         u16 num_pages;
827         u8 ulp_num;
828 #define BEISCSI_DUAL_ULP_AWARE_BIT      0       /* Byte 3 - Bit 0 */
829 #define BEISCSI_BIND_Q_TO_ULP_BIT       1       /* Byte 3 - Bit 1 */
830         u8 dua_feature;
831         struct be_default_pdu_context context;
832         struct phys_addr pages[8];
833 } __packed;
834
835 struct be_defq_create_resp {
836         struct be_cmd_req_hdr hdr;
837         u16 id;
838         u8 rsvd0;
839         u8 ulp_num;
840         u32 doorbell_offset;
841         u16 register_set;
842         u16 doorbell_format;
843 } __packed;
844
845 struct be_post_template_pages_req {
846         struct be_cmd_req_hdr hdr;
847         u16 num_pages;
848 #define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
849         u16 type;
850         struct phys_addr scratch_pa;
851         struct virt_addr scratch_va;
852         struct virt_addr pages_va;
853         struct phys_addr pages[16];
854 } __packed;
855
856 struct be_remove_template_pages_req {
857         struct be_cmd_req_hdr hdr;
858         u16 type;
859         u16 rsvd0;
860 } __packed;
861
862 struct be_post_sgl_pages_req {
863         struct be_cmd_req_hdr hdr;
864         u16 num_pages;
865         u16 page_offset;
866         u32 rsvd0;
867         struct phys_addr pages[26];
868         u32 rsvd1;
869 } __packed;
870
871 struct be_wrbq_create_req {
872         struct be_cmd_req_hdr hdr;
873         u16 num_pages;
874         u8 ulp_num;
875         u8 dua_feature;
876         struct phys_addr pages[8];
877 } __packed;
878
879 struct be_wrbq_create_resp {
880         struct be_cmd_resp_hdr resp_hdr;
881         u16 cid;
882         u8 rsvd0;
883         u8 ulp_num;
884         u32 doorbell_offset;
885         u16 register_set;
886         u16 doorbell_format;
887 } __packed;
888
889 #define SOL_CID_MASK            0x0000FFC0
890 #define SOL_CODE_MASK           0x0000003F
891 #define SOL_WRB_INDEX_MASK      0x00FF0000
892 #define SOL_CMD_WND_MASK        0xFF000000
893 #define SOL_RES_CNT_MASK        0x7FFFFFFF
894 #define SOL_EXP_CMD_SN_MASK     0xFFFFFFFF
895 #define SOL_HW_STS_MASK         0x000000FF
896 #define SOL_STS_MASK            0x0000FF00
897 #define SOL_RESP_MASK           0x00FF0000
898 #define SOL_FLAGS_MASK          0x7F000000
899 #define SOL_S_MASK              0x80000000
900
901 struct sol_cqe {
902         u32 dw[4];
903 };
904
905 struct amap_sol_cqe {
906         u8 hw_sts[8];           /* dword 0 */
907         u8 i_sts[8];            /* dword 0 */
908         u8 i_resp[8];           /* dword 0 */
909         u8 i_flags[7];          /* dword 0 */
910         u8 s;                   /* dword 0 */
911         u8 i_exp_cmd_sn[32];    /* dword 1 */
912         u8 code[6];             /* dword 2 */
913         u8 cid[10];             /* dword 2 */
914         u8 wrb_index[8];        /* dword 2 */
915         u8 i_cmd_wnd[8];        /* dword 2 */
916         u8 i_res_cnt[31];       /* dword 3 */
917         u8 valid;               /* dword 3 */
918 } __packed;
919
920 #define SOL_ICD_INDEX_MASK      0x0003FFC0
921 struct amap_sol_cqe_ring {
922         u8 hw_sts[8];           /* dword 0 */
923         u8 i_sts[8];            /* dword 0 */
924         u8 i_resp[8];           /* dword 0 */
925         u8 i_flags[7];          /* dword 0 */
926         u8 s;                   /* dword 0 */
927         u8 i_exp_cmd_sn[32];    /* dword 1 */
928         u8 code[6];             /* dword 2 */
929         u8 icd_index[12];       /* dword 2 */
930         u8 rsvd[6];             /* dword 2 */
931         u8 i_cmd_wnd[8];        /* dword 2 */
932         u8 i_res_cnt[31];       /* dword 3 */
933         u8 valid;               /* dword 3 */
934 } __packed;
935
936 struct amap_sol_cqe_v2 {
937         u8 hw_sts[8];   /* dword 0 */
938         u8 i_sts[8];    /* dword 0 */
939         u8 wrb_index[16];   /* dword 0 */
940         u8 i_exp_cmd_sn[32];    /* dword 1 */
941         u8 code[6]; /* dword 2 */
942         u8 cmd_cmpl;    /* dword 2 */
943         u8 rsvd0;   /* dword 2 */
944         u8 i_cmd_wnd[8];    /* dword 2 */
945         u8 cid[13]; /* dword 2 */
946         u8 u;   /* dword 2 */
947         u8 o;   /* dword 2 */
948         u8 s;   /* dword 2 */
949         u8 i_res_cnt[31];   /* dword 3 */
950         u8 valid;   /* dword 3 */
951 } __packed;
952
953 struct common_sol_cqe {
954         u32 exp_cmdsn;
955         u32 res_cnt;
956         u16 wrb_index;
957         u16 cid;
958         u8 hw_sts;
959         u8 cmd_wnd;
960         u8 res_flag; /* the s feild of structure */
961         u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
962         u8 i_flags; /* for skh or the u and o feilds */
963         u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
964 };
965
966 /*** iSCSI ack/driver message completions ***/
967 struct amap_it_dmsg_cqe {
968         u8 ack_num[32]; /* DWORD 0 */
969         u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
970         u8 code[6]; /* DWORD 2 */
971         u8 cid[10]; /* DWORD 2 */
972         u8 wrb_idx[8];  /* DWORD 2 */
973         u8 rsvd0[8];    /* DWORD 2*/
974         u8 rsvd1[31];   /* DWORD 3*/
975         u8 valid;   /* DWORD 3 */
976 } __packed;
977
978 struct amap_it_dmsg_cqe_v2 {
979         u8 ack_num[32]; /* DWORD 0 */
980         u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
981         u8 code[6]; /* DWORD 2 */
982         u8 rsvd0[10];   /* DWORD 2 */
983         u8 wrb_idx[16]; /* DWORD 2 */
984         u8 rsvd1[16];   /* DWORD 3 */
985         u8 cid[13]; /* DWORD 3 */
986         u8 rsvd2[2];    /* DWORD 3 */
987         u8 valid;   /* DWORD 3 */
988 } __packed;
989
990
991 /**
992  * Post WRB Queue Doorbell Register used by the host Storage
993  * stack to notify the
994  * controller of a posted Work Request Block
995  */
996 #define DB_WRB_POST_CID_MASK            0xFFFF  /* bits 0 - 16 */
997 #define DB_DEF_PDU_WRB_INDEX_MASK       0xFF    /* bits 0 - 9 */
998
999 #define DB_DEF_PDU_WRB_INDEX_SHIFT      16
1000 #define DB_DEF_PDU_NUM_POSTED_SHIFT     24
1001
1002 struct fragnum_bits_for_sgl_cra_in {
1003         struct be_cmd_req_hdr hdr;
1004         u32 num_bits;
1005 } __packed;
1006
1007 struct iscsi_cleanup_req {
1008         struct be_cmd_req_hdr hdr;
1009         u16 chute;
1010         u8 hdr_ring_id;
1011         u8 data_ring_id;
1012
1013 } __packed;
1014
1015 struct eq_delay {
1016         u32 eq_id;
1017         u32 phase;
1018         u32 delay_multiplier;
1019 } __packed;
1020
1021 struct be_eq_delay_params_in {
1022         struct be_cmd_req_hdr hdr;
1023         u32 num_eq;
1024         struct eq_delay delay[8];
1025 } __packed;
1026
1027 struct tcp_connect_and_offload_in {
1028         struct be_cmd_req_hdr hdr;
1029         struct ip_addr_format ip_address;
1030         u16 tcp_port;
1031         u16 cid;
1032         u16 cq_id;
1033         u16 defq_id;
1034         struct phys_addr dataout_template_pa;
1035         u16 hdr_ring_id;
1036         u16 data_ring_id;
1037         u8 do_offload;
1038         u8 rsvd0[3];
1039 } __packed;
1040
1041 struct tcp_connect_and_offload_in_v1 {
1042         struct be_cmd_req_hdr hdr;
1043         struct ip_addr_format ip_address;
1044         u16 tcp_port;
1045         u16 cid;
1046         u16 cq_id;
1047         u16 defq_id;
1048         struct phys_addr dataout_template_pa;
1049         u16 hdr_ring_id;
1050         u16 data_ring_id;
1051         u8 do_offload;
1052         u8 ifd_state;
1053         u8 rsvd0[2];
1054         u16 tcp_window_size;
1055         u8 tcp_window_scale_count;
1056         u8 rsvd1;
1057         u32 tcp_mss:24;
1058         u8 rsvd2;
1059 } __packed;
1060
1061 struct tcp_connect_and_offload_out {
1062         struct be_cmd_resp_hdr hdr;
1063         u32 connection_handle;
1064         u16 cid;
1065         u16 rsvd0;
1066
1067 } __packed;
1068
1069 struct be_mcc_wrb_context {
1070         struct MCC_WRB *wrb;
1071         int *users_final_status;
1072 } __packed;
1073
1074 #define DB_DEF_PDU_RING_ID_MASK 0x3FFF  /* bits 0 - 13 */
1075 #define DB_DEF_PDU_CQPROC_MASK          0x3FFF  /* bits 16 - 29 */
1076 #define DB_DEF_PDU_REARM_SHIFT          14
1077 #define DB_DEF_PDU_EVENT_SHIFT          15
1078 #define DB_DEF_PDU_CQPROC_SHIFT         16
1079
1080 struct dmsg_cqe {
1081         u32 dw[4];
1082 } __packed;
1083
1084 struct tcp_upload_params_in {
1085         struct be_cmd_req_hdr hdr;
1086         u16 id;
1087         u16 upload_type;
1088         u32 reset_seq;
1089 } __packed;
1090
1091 struct tcp_upload_params_out {
1092         u32 dw[32];
1093 } __packed;
1094
1095 union tcp_upload_params {
1096         struct tcp_upload_params_in request;
1097         struct tcp_upload_params_out response;
1098 } __packed;
1099
1100 struct be_ulp_fw_cfg {
1101 #define BEISCSI_ULP_ISCSI_INI_MODE      0x10
1102         u32 ulp_mode;
1103         u32 etx_base;
1104         u32 etx_count;
1105         u32 sq_base;
1106         u32 sq_count;
1107         u32 rq_base;
1108         u32 rq_count;
1109         u32 dq_base;
1110         u32 dq_count;
1111         u32 lro_base;
1112         u32 lro_count;
1113         u32 icd_base;
1114         u32 icd_count;
1115 };
1116
1117 struct be_ulp_chain_icd {
1118         u32 chain_base;
1119         u32 chain_count;
1120 };
1121
1122 struct be_fw_cfg {
1123         struct be_cmd_req_hdr hdr;
1124         u32 be_config_number;
1125         u32 asic_revision;
1126         u32 phys_port;
1127 #define BEISCSI_FUNC_ISCSI_INI_MODE     0x10
1128 #define BEISCSI_FUNC_DUA_MODE   0x800
1129         u32 function_mode;
1130         struct be_ulp_fw_cfg ulp[2];
1131         u32 function_caps;
1132         u32 cqid_base;
1133         u32 cqid_count;
1134         u32 eqid_base;
1135         u32 eqid_count;
1136         struct be_ulp_chain_icd chain_icd[2];
1137 } __packed;
1138
1139 struct be_cmd_get_all_if_id_req {
1140         struct be_cmd_req_hdr hdr;
1141         u32 if_count;
1142         u32 if_hndl_list[1];
1143 } __packed;
1144
1145 struct be_cmd_get_port_name {
1146         union {
1147                 struct be_cmd_req_hdr req_hdr;
1148                 struct be_cmd_resp_hdr resp_hdr;
1149         } h;
1150         union {
1151                 struct {
1152                         u32 reserved;
1153                 } req;
1154                 struct {
1155                         u32 port_names;
1156                 } resp;
1157         } p;
1158 } __packed;
1159
1160 #define ISCSI_OPCODE_SCSI_DATA_OUT              5
1161 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1162 #define OPCODE_COMMON_MODIFY_EQ_DELAY           41
1163 #define OPCODE_COMMON_ISCSI_CLEANUP             59
1164 #define OPCODE_COMMON_TCP_UPLOAD                56
1165 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1166 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1167 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME       6
1168 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME       7
1169 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION  14
1170 #define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET   24
1171 #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1172 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1173 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1174 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET   52
1175 #define OPCODE_COMMON_WRITE_FLASH               96
1176 #define OPCODE_COMMON_READ_FLASH                97
1177
1178 /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1179 #define CMD_ISCSI_COMMAND_INVALIDATE            1
1180 #define CMD_ISCSI_CONNECTION_INVALIDATE         0x8001
1181 #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST      0x8002
1182
1183 #define INI_WR_CMD                      1       /* Initiator write command */
1184 #define INI_TMF_CMD                     2       /* Initiator TMF command */
1185 #define INI_NOPOUT_CMD                  3       /* Initiator; Send a NOP-OUT */
1186 #define INI_RD_CMD                      5       /* Initiator requesting to send
1187                                                  * a read command
1188                                                  */
1189 #define TGT_CTX_UPDT_CMD                7       /* Target context update */
1190 #define TGT_STS_CMD                     8       /* Target R2T and other BHS
1191                                                  * where only the status number
1192                                                  * need to be updated
1193                                                  */
1194 #define TGT_DATAIN_CMD                  9       /* Target Data-Ins in response
1195                                                  * to read command
1196                                                  */
1197 #define TGT_SOS_PDU                     10      /* Target:standalone status
1198                                                  * response
1199                                                  */
1200 #define TGT_DM_CMD                      11      /* Indicates that the bhs
1201                                                  *  preparedby
1202                                                  * driver should not be touched
1203                                                  */
1204 /* --- CMD_CHUTE_TYPE --- */
1205 #define CMD_CONNECTION_CHUTE_0          1
1206 #define CMD_CONNECTION_CHUTE_1          2
1207 #define CMD_CONNECTION_CHUTE_2          3
1208
1209 #define EQ_MAJOR_CODE_COMPLETION        0
1210
1211 #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1212 #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1213
1214 /* --- CONNECTION_UPLOAD_PARAMS --- */
1215 /* These parameters are used to define the type of upload desired.  */
1216 #define CONNECTION_UPLOAD_GRACEFUL      1       /* Graceful upload  */
1217 #define CONNECTION_UPLOAD_ABORT_RESET   2       /* Abortive upload with
1218                                                  * reset
1219                                                  */
1220 #define CONNECTION_UPLOAD_ABORT         3       /* Abortive upload without
1221                                                  * reset
1222                                                  */
1223 #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4      /* Abortive upload with reset,
1224                                                  * sequence number by driver  */
1225
1226 /* Returns the number of items in the field array. */
1227 #define BE_NUMBER_OF_FIELD(_type_, _field_)     \
1228         (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1229
1230 /**
1231  * Different types of iSCSI completions to host driver for both initiator
1232  * and taget mode
1233  * of operation.
1234  */
1235 #define SOL_CMD_COMPLETE                1       /* Solicited command completed
1236                                                  * normally
1237                                                  */
1238 #define SOL_CMD_KILLED_DATA_DIGEST_ERR  2       /* Solicited command got
1239                                                  * invalidated internally due
1240                                                  * to Data Digest error
1241                                                  */
1242 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3       /* Connection got invalidated
1243                                                  * internally
1244                                                  * due to a received PDU
1245                                                  * size > DSL
1246                                                  */
1247 #define CXN_KILLED_BURST_LEN_MISMATCH   4       /* Connection got invalidated
1248                                                  * internally due ti received
1249                                                  * PDU sequence size >
1250                                                  * FBL/MBL.
1251                                                  */
1252 #define CXN_KILLED_AHS_RCVD             5       /* Connection got invalidated
1253                                                  * internally due to a received
1254                                                  * PDU Hdr that has
1255                                                  * AHS */
1256 #define CXN_KILLED_HDR_DIGEST_ERR       6       /* Connection got invalidated
1257                                                  * internally due to Hdr Digest
1258                                                  * error
1259                                                  */
1260 #define CXN_KILLED_UNKNOWN_HDR          7       /* Connection got invalidated
1261                                                  *  internally
1262                                                  * due to a bad opcode in the
1263                                                  * pdu hdr
1264                                                  */
1265 #define CXN_KILLED_STALE_ITT_TTT_RCVD   8       /* Connection got invalidated
1266                                                  * internally due to a received
1267                                                  * ITT/TTT that does not belong
1268                                                  * to this Connection
1269                                                  */
1270 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9       /* Connection got invalidated
1271                                                  * internally due to received
1272                                                  * ITT/TTT value > Max
1273                                                  * Supported ITTs/TTTs
1274                                                  */
1275 #define CXN_KILLED_RST_RCVD             10      /* Connection got invalidated
1276                                                  * internally due to an
1277                                                  * incoming TCP RST
1278                                                  */
1279 #define CXN_KILLED_TIMED_OUT            11      /* Connection got invalidated
1280                                                  * internally due to timeout on
1281                                                  * tcp segment 12 retransmit
1282                                                  * attempts failed
1283                                                  */
1284 #define CXN_KILLED_RST_SENT             12      /* Connection got invalidated
1285                                                  * internally due to TCP RST
1286                                                  * sent by the Tx side
1287                                                  */
1288 #define CXN_KILLED_FIN_RCVD             13      /* Connection got invalidated
1289                                                  * internally due to an
1290                                                  * incoming TCP FIN.
1291                                                  */
1292 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD   14      /* Connection got invalidated
1293                                                  * internally due to bad
1294                                                  * unsolicited PDU Unsolicited
1295                                                  * PDUs are PDUs with
1296                                                  * ITT=0xffffffff
1297                                                  */
1298 #define CXN_KILLED_BAD_WRB_INDEX_ERROR  15      /* Connection got invalidated
1299                                                  * internally due to bad WRB
1300                                                  * index.
1301                                                  */
1302 #define CXN_KILLED_OVER_RUN_RESIDUAL    16      /* Command got invalidated
1303                                                  * internally due to received
1304                                                  * command has residual
1305                                                  * over run bytes.
1306                                                  */
1307 #define CXN_KILLED_UNDER_RUN_RESIDUAL   17      /* Command got invalidated
1308                                                  * internally due to received
1309                                                  * command has residual under
1310                                                  * run bytes.
1311                                                  */
1312 #define CMD_KILLED_INVALID_STATSN_RCVD  18      /* Command got invalidated
1313                                                  * internally due to a received
1314                                                  * PDU has an invalid StatusSN
1315                                                  */
1316 #define CMD_KILLED_INVALID_R2T_RCVD     19      /* Command got invalidated
1317                                                  * internally due to a received
1318                                                  * an R2T with some invalid
1319                                                  * fields in it
1320                                                  */
1321 #define CMD_CXN_KILLED_LUN_INVALID      20      /* Command got invalidated
1322                                                  * internally due to received
1323                                                  * PDU has an invalid LUN.
1324                                                  */
1325 #define CMD_CXN_KILLED_ICD_INVALID      21      /* Command got invalidated
1326                                                  * internally due to the
1327                                                  * corresponding ICD not in a
1328                                                  * valid state
1329                                                  */
1330 #define CMD_CXN_KILLED_ITT_INVALID      22      /* Command got invalidated due
1331                                                  *  to received PDU has an
1332                                                  *  invalid ITT.
1333                                                  */
1334 #define CMD_CXN_KILLED_SEQ_OUTOFORDER   23      /* Command got invalidated due
1335                                                  * to received sequence buffer
1336                                                  * offset is out of order.
1337                                                  */
1338 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24   /* Command got invalidated
1339                                                  * internally due to a
1340                                                  * received PDU has an invalid
1341                                                  * DataSN
1342                                                  */
1343 #define CXN_INVALIDATE_NOTIFY           25      /* Connection invalidation
1344                                                  * completion notify.
1345                                                  */
1346 #define CXN_INVALIDATE_INDEX_NOTIFY     26      /* Connection invalidation
1347                                                  * completion
1348                                                  * with data PDU index.
1349                                                  */
1350 #define CMD_INVALIDATED_NOTIFY          27      /* Command invalidation
1351                                                  * completionnotifify.
1352                                                  */
1353 #define UNSOL_HDR_NOTIFY                28      /* Unsolicited header notify.*/
1354 #define UNSOL_DATA_NOTIFY               29      /* Unsolicited data notify.*/
1355 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY  30      /* Unsolicited data digest
1356                                                  * error notify.
1357                                                  */
1358 #define DRIVERMSG_NOTIFY                31      /* TCP acknowledge based
1359                                                  * notification.
1360                                                  */
1361 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1362                                                   * internally due to command
1363                                                   * and data are not on same
1364                                                   * connection.
1365                                                   */
1366 #define SOL_CMD_KILLED_DIF_ERR          33      /* Solicited command got
1367                                                  *  invalidated internally due
1368                                                  *  to DIF error
1369                                                  */
1370 #define CXN_KILLED_SYN_RCVD             34      /* Connection got invalidated
1371                                                  * internally due to incoming
1372                                                  * TCP SYN
1373                                                  */
1374 #define CXN_KILLED_IMM_DATA_RCVD        35      /* Connection got invalidated
1375                                                  * internally due to an
1376                                                  * incoming Unsolicited PDU
1377                                                  * that has immediate data on
1378                                                  * the cxn
1379                                                  */
1380
1381 int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1382 int be_chk_reset_complete(struct beiscsi_hba *phba);
1383
1384 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1385                         bool embedded, u8 sge_cnt);
1386
1387 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1388                         u8 subsystem, u8 opcode, int cmd_len);
1389
1390 void beiscsi_fail_session(struct iscsi_cls_session *cls_session);
1391 #endif /* !BEISCSI_CMDS_H */