2 * Copyright (C) 2005 - 2012 Emulex
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.
10 * Contact Information:
11 * linux-drivers@emulex.com
15 * Costa Mesa, CA 92626
18 #ifndef BEISCSI_CMDS_H
19 #define BEISCSI_CMDS_H
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.
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 */
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 */
43 u8 embedded_payload[236]; /* used by embedded cmds */
44 struct be_sge sgl[19]; /* used by non-embedded cmds */
48 #define CQE_FLAGS_VALID_MASK (1 << 31)
49 #define CQE_FLAGS_ASYNC_MASK (1 << 30)
50 #define CQE_FLAGS_COMPLETED_MASK (1 << 28)
51 #define CQE_FLAGS_CONSUMED_MASK (1 << 27)
53 /* Completion Status */
54 #define MCC_STATUS_SUCCESS 0x0
56 #define CQE_STATUS_COMPL_MASK 0xFFFF
57 #define CQE_STATUS_COMPL_SHIFT 0 /* bits 0 - 15 */
58 #define CQE_STATUS_EXTD_MASK 0xFFFF
59 #define CQE_STATUS_EXTD_SHIFT 16 /* bits 0 - 15 */
60 #define CQE_STATUS_ADDL_MASK 0xFF00
61 #define CQE_STATUS_MASK 0xFF
62 #define CQE_STATUS_ADDL_SHIFT 0x08
63 #define CQE_STATUS_WRB_MASK 0xFF0000
64 #define CQE_STATUS_WRB_SHIFT 16
65 #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
66 #define BEISCSI_FW_MBX_TIMEOUT 100
68 /* MBOX Command VER */
69 #define MBX_CMD_VER2 0x02
72 u32 status; /* dword 0 */
73 u32 tag0; /* dword 1 */
74 u32 tag1; /* dword 2 */
75 u32 flags; /* dword 3 */
78 /********* Mailbox door bell *************/
80 * Used for driver communication with the FW.
81 * The software must write this register twice to post any command. First,
82 * it writes the register with hi=1 and the upper bits of the physical address
83 * for the MAILBOX structure. Software must poll the ready bit until this
84 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
85 * bits in the address. It must poll the ready bit until the command is
86 * complete. Upon completion, the MAILBOX will contain a valid completion
89 #define MPU_MAILBOX_DB_OFFSET 0x160
90 #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
91 #define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
93 /********** MPU semphore ******************/
94 #define MPU_EP_SEMAPHORE_OFFSET 0xac
95 #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
96 #define EP_SEMAPHORE_POST_ERR_MASK 0x1
97 #define EP_SEMAPHORE_POST_ERR_SHIFT 31
99 /********** MCC door bell ************/
100 #define DB_MCCQ_OFFSET 0x140
101 #define DB_MCCQ_RING_ID_MASK 0x7FF /* bits 0 - 10 */
102 /* Number of entries posted */
103 #define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
105 /* MPU semphore POST stage values */
106 #define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
109 * When the async bit of mcc_compl is set, the last 4 bytes of
110 * mcc_compl is interpreted as follows:
112 #define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
113 #define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
114 #define ASYNC_EVENT_CODE_LINK_STATE 0x1
115 struct be_async_event_trailer {
120 ASYNC_EVENT_LINK_DOWN = 0x0,
121 ASYNC_EVENT_LINK_UP = 0x1
125 * When the event code of an async trailer is link-state, the mcc_compl
126 * must be interpreted as follows
128 struct be_async_event_link_state {
135 struct be_async_event_trailer trailer;
138 struct be_mcc_mailbox {
139 struct be_mcc_wrb wrb;
140 struct be_mcc_compl compl;
143 /* Type of subsystems supported by FW */
144 #define CMD_SUBSYSTEM_COMMON 0x1
145 #define CMD_SUBSYSTEM_ISCSI 0x2
146 #define CMD_SUBSYSTEM_ETH 0x3
147 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
148 #define CMD_COMMON_TCP_UPLOAD 0x1
151 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
152 * These opcodes are unique for each subsystem defined above
154 #define OPCODE_COMMON_CQ_CREATE 12
155 #define OPCODE_COMMON_EQ_CREATE 13
156 #define OPCODE_COMMON_MCC_CREATE 21
157 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
158 #define OPCODE_COMMON_GET_FW_VERSION 35
159 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
160 #define OPCODE_COMMON_FIRMWARE_CONFIG 42
161 #define OPCODE_COMMON_MCC_DESTROY 53
162 #define OPCODE_COMMON_CQ_DESTROY 54
163 #define OPCODE_COMMON_EQ_DESTROY 55
164 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
165 #define OPCODE_COMMON_FUNCTION_RESET 61
168 * LIST of opcodes that are common between Initiator and Target
169 * used by CMD_SUBSYSTEM_ISCSI
170 * These opcodes are unique for each subsystem defined above
172 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
173 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
174 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
175 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
176 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
177 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
178 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
179 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
180 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
181 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
182 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
183 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
184 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
185 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
186 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
187 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
189 struct be_cmd_req_hdr {
190 u8 opcode; /* dword 0 */
191 u8 subsystem; /* dword 0 */
192 u8 port_number; /* dword 0 */
193 u8 domain; /* dword 0 */
194 u32 timeout; /* dword 1 */
195 u32 request_length; /* dword 2 */
196 u8 version; /* dword 3 */
197 u8 rsvd0[3]; /* dword 3 */
200 struct be_cmd_resp_hdr {
201 u32 info; /* dword 0 */
202 u32 status; /* dword 1 */
203 u32 response_length; /* dword 2 */
204 u32 actual_resp_len; /* dword 3 */
212 /**************************
213 * BE Command definitions *
214 **************************/
217 * Pseudo amap definition in which each bit of the actual structure is defined
218 * as a byte - used to calculate offset/shift/mask of each field
220 struct amap_eq_context {
221 u8 cidx[13]; /* dword 0 */
222 u8 rsvd0[3]; /* dword 0 */
223 u8 epidx[13]; /* dword 0 */
224 u8 valid; /* dword 0 */
225 u8 rsvd1; /* dword 0 */
226 u8 size; /* dword 0 */
227 u8 pidx[13]; /* dword 1 */
228 u8 rsvd2[3]; /* dword 1 */
229 u8 pd[10]; /* dword 1 */
230 u8 count[3]; /* dword 1 */
231 u8 solevent; /* dword 1 */
232 u8 stalled; /* dword 1 */
233 u8 armed; /* dword 1 */
234 u8 rsvd3[4]; /* dword 2 */
235 u8 func[8]; /* dword 2 */
236 u8 rsvd4; /* dword 2 */
237 u8 delaymult[10]; /* dword 2 */
238 u8 rsvd5[2]; /* dword 2 */
239 u8 phase[2]; /* dword 2 */
240 u8 nodelay; /* dword 2 */
241 u8 rsvd6[4]; /* dword 2 */
242 u8 rsvd7[32]; /* dword 3 */
245 struct be_cmd_req_eq_create {
246 struct be_cmd_req_hdr hdr; /* dw[4] */
247 u16 num_pages; /* sword */
248 u16 rsvd0; /* sword */
249 u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
250 struct phys_addr pages[8];
253 struct be_cmd_resp_eq_create {
254 struct be_cmd_resp_hdr resp_hdr;
255 u16 eq_id; /* sword */
256 u16 rsvd0; /* sword */
259 struct mgmt_chap_format {
261 u8 intr_chap_name[256];
263 u8 target_chap_name[256];
264 u8 target_secret[16];
265 u16 intr_chap_name_length;
266 u16 intr_secret_length;
267 u16 target_chap_name_length;
268 u16 target_secret_length;
271 struct mgmt_auth_method_format {
274 struct mgmt_chap_format chap;
277 struct mgmt_conn_login_options {
282 u32 max_recv_datasegment_len_ini;
283 u32 max_recv_datasegment_len_tgt;
286 struct mgmt_auth_method_format auth_data;
289 struct ip_addr_format {
290 u16 size_of_structure;
297 struct mgmt_conn_info {
298 u32 connection_handle;
299 u32 connection_status;
302 u16 dest_port_redirected;
304 u32 estimated_throughput;
305 struct ip_addr_format src_ipaddr;
306 struct ip_addr_format dest_ipaddr;
307 struct ip_addr_format dest_ipaddr_redirected;
308 struct mgmt_conn_login_options negotiated_login_options;
311 struct mgmt_session_login_options {
313 u8 error_recovery_level;
315 u32 first_burst_length;
316 u32 max_burst_length;
318 u16 max_outstanding_r2t;
319 u16 default_time2wait;
320 u16 default_time2retain;
323 struct mgmt_session_info {
332 u8 initiator_iscsiname[224];
333 struct mgmt_session_login_options negotiated_login_options;
334 struct mgmt_conn_info conn_list[1];
337 struct be_cmd_get_session_req {
338 struct be_cmd_req_hdr hdr;
342 struct be_cmd_get_session_resp {
343 struct be_cmd_resp_hdr hdr;
344 struct mgmt_session_info session_info;
348 u16 size_of_structure;
352 struct be_cmd_get_boot_target_req {
353 struct be_cmd_req_hdr hdr;
356 struct be_cmd_get_boot_target_resp {
357 struct be_cmd_resp_hdr hdr;
358 u32 boot_session_count;
359 int boot_session_handle;
362 struct be_cmd_reopen_session_req {
363 struct be_cmd_req_hdr hdr;
364 #define BE_REOPEN_ALL_SESSIONS 0x00
365 #define BE_REOPEN_BOOT_SESSIONS 0x01
366 #define BE_REOPEN_A_SESSION 0x02
372 struct be_cmd_reopen_session_resp {
373 struct be_cmd_resp_hdr hdr;
379 struct be_cmd_mac_query_req {
380 struct be_cmd_req_hdr hdr;
386 struct be_cmd_get_mac_resp {
387 struct be_cmd_resp_hdr hdr;
391 struct be_ip_addr_subnet_format {
392 u16 size_of_structure;
394 u8 ipv6_prefix_length;
400 struct be_cmd_get_if_info_req {
401 struct be_cmd_req_hdr hdr;
406 struct be_cmd_get_if_info_resp {
407 struct be_cmd_req_hdr hdr;
412 struct be_ip_addr_subnet_format ip_addr;
415 struct be_ip_addr_record {
418 struct be_ip_addr_subnet_format ip_addr;
422 struct be_ip_addr_record_params {
423 u32 record_entry_count;
424 struct be_ip_addr_record ip_record;
427 struct be_cmd_set_ip_addr_req {
428 struct be_cmd_req_hdr hdr;
429 struct be_ip_addr_record_params ip_params;
433 struct be_cmd_set_dhcp_req {
434 struct be_cmd_req_hdr hdr;
441 struct be_cmd_rel_dhcp_req {
442 struct be_cmd_req_hdr hdr;
447 struct be_cmd_set_def_gateway_req {
448 struct be_cmd_req_hdr hdr;
450 struct ip_addr_format ip_addr;
453 struct be_cmd_get_def_gateway_req {
454 struct be_cmd_req_hdr hdr;
458 struct be_cmd_get_def_gateway_resp {
459 struct be_cmd_req_hdr hdr;
460 struct ip_addr_format ip_addr;
463 #define BEISCSI_VLAN_DISABLE 0xFFFF
464 struct be_cmd_set_vlan_req {
465 struct be_cmd_req_hdr hdr;
469 /******************** Create CQ ***************************/
471 * Pseudo amap definition in which each bit of the actual structure is defined
472 * as a byte - used to calculate offset/shift/mask of each field
474 struct amap_cq_context {
475 u8 cidx[11]; /* dword 0 */
476 u8 rsvd0; /* dword 0 */
477 u8 coalescwm[2]; /* dword 0 */
478 u8 nodelay; /* dword 0 */
479 u8 epidx[11]; /* dword 0 */
480 u8 rsvd1; /* dword 0 */
481 u8 count[2]; /* dword 0 */
482 u8 valid; /* dword 0 */
483 u8 solevent; /* dword 0 */
484 u8 eventable; /* dword 0 */
485 u8 pidx[11]; /* dword 1 */
486 u8 rsvd2; /* dword 1 */
487 u8 pd[10]; /* dword 1 */
488 u8 eqid[8]; /* dword 1 */
489 u8 stalled; /* dword 1 */
490 u8 armed; /* dword 1 */
491 u8 rsvd3[4]; /* dword 2 */
492 u8 func[8]; /* dword 2 */
493 u8 rsvd4[20]; /* dword 2 */
494 u8 rsvd5[32]; /* dword 3 */
497 struct amap_cq_context_v2 {
498 u8 rsvd0[12]; /* dword 0 */
499 u8 coalescwm[2]; /* dword 0 */
500 u8 nodelay; /* dword 0 */
501 u8 rsvd1[12]; /* dword 0 */
502 u8 count[2]; /* dword 0 */
503 u8 valid; /* dword 0 */
504 u8 rsvd2; /* dword 0 */
505 u8 eventable; /* dword 0 */
506 u8 eqid[16]; /* dword 1 */
507 u8 rsvd3[15]; /* dword 1 */
508 u8 armed; /* dword 1 */
509 u8 cqecount[16];/* dword 2 */
510 u8 rsvd4[16]; /* dword 2 */
511 u8 rsvd5[32]; /* dword 3 */
514 struct be_cmd_req_cq_create {
515 struct be_cmd_req_hdr hdr;
519 u8 context[sizeof(struct amap_cq_context) / 8];
520 struct phys_addr pages[4];
523 struct be_cmd_resp_cq_create {
524 struct be_cmd_resp_hdr hdr;
529 /******************** Create MCCQ ***************************/
531 * Pseudo amap definition in which each bit of the actual structure is defined
532 * as a byte - used to calculate offset/shift/mask of each field
534 struct amap_mcc_context {
549 struct be_cmd_req_mcc_create {
550 struct be_cmd_req_hdr hdr;
553 u8 context[sizeof(struct amap_mcc_context) / 8];
554 struct phys_addr pages[8];
557 struct be_cmd_resp_mcc_create {
558 struct be_cmd_resp_hdr hdr;
563 /******************** Q Destroy ***************************/
564 /* Type of Queue to be destroyed */
574 struct be_cmd_req_q_destroy {
575 struct be_cmd_req_hdr hdr;
577 u16 bypass_flush; /* valid only for rx q destroy */
584 struct be_cmd_req_mcast_mac_config {
585 struct be_cmd_req_hdr hdr;
589 struct macaddr mac[32];
592 static inline void *embedded_payload(struct be_mcc_wrb *wrb)
594 return wrb->payload.embedded_payload;
597 static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
599 return &wrb->payload.sgl[0];
602 /******************** Modify EQ Delay *******************/
603 struct be_cmd_req_modify_eq_delay {
604 struct be_cmd_req_hdr hdr;
609 u32 delay_multiplier;
613 /******************** Get MAC ADDR *******************/
617 struct be_cmd_get_nic_conf_req {
618 struct be_cmd_req_hdr hdr;
624 u16 size_of_structure;
625 u8 mac_address[ETH_ALEN];
629 struct be_cmd_get_nic_conf_resp {
630 struct be_cmd_resp_hdr hdr;
636 u16 size_of_structure;
641 #define BEISCSI_ALIAS_LEN 32
643 struct be_cmd_hba_name {
644 struct be_cmd_req_hdr hdr;
647 u8 initiator_name[ISCSI_NAME_LEN];
648 u8 initiator_alias[BEISCSI_ALIAS_LEN];
651 struct be_cmd_ntwk_link_status_req {
652 struct be_cmd_req_hdr hdr;
656 /*** Port Speed Values ***/
657 #define BE2ISCSI_LINK_SPEED_ZERO 0x00
658 #define BE2ISCSI_LINK_SPEED_10MBPS 0x01
659 #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
660 #define BE2ISCSI_LINK_SPEED_1GBPS 0x03
661 #define BE2ISCSI_LINK_SPEED_10GBPS 0x04
662 struct be_cmd_ntwk_link_status_resp {
663 struct be_cmd_resp_hdr hdr;
671 u32 logical_link_speed;
674 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
675 struct be_queue_info *eq, int eq_delay);
677 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
678 struct be_queue_info *cq, struct be_queue_info *eq,
679 bool sol_evts, bool no_delay,
680 int num_cqe_dma_coalesce);
682 int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
684 int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
685 struct be_queue_info *mccq,
686 struct be_queue_info *cq);
688 int be_poll_mcc(struct be_ctrl_info *ctrl);
689 int mgmt_check_supported_fw(struct be_ctrl_info *ctrl,
690 struct beiscsi_hba *phba);
691 unsigned int be_cmd_get_initname(struct beiscsi_hba *phba);
692 unsigned int be_cmd_get_port_speed(struct beiscsi_hba *phba);
694 void free_mcc_tag(struct be_ctrl_info *ctrl, unsigned int tag);
696 int beiscsi_mccq_compl(struct beiscsi_hba *phba,
697 uint32_t tag, struct be_mcc_wrb **wrb, void *cmd_va);
698 /*ISCSI Functuions */
699 int be_cmd_fw_initialize(struct be_ctrl_info *ctrl);
701 struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
702 struct be_mcc_wrb *wrb_from_mccq(struct beiscsi_hba *phba);
703 int be_mcc_notify_wait(struct beiscsi_hba *phba);
704 void be_mcc_notify(struct beiscsi_hba *phba);
705 unsigned int alloc_mcc_tag(struct beiscsi_hba *phba);
706 void beiscsi_async_link_state_process(struct beiscsi_hba *phba,
707 struct be_async_event_link_state *evt);
708 int be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,
709 struct be_mcc_compl *compl);
711 int be_mbox_notify(struct be_ctrl_info *ctrl);
713 int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
714 struct be_queue_info *cq,
715 struct be_queue_info *dq, int length,
718 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
719 struct be_dma_mem *q_mem, u32 page_offset,
722 int beiscsi_cmd_reset_function(struct beiscsi_hba *phba);
724 int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
725 struct be_queue_info *wrbq);
727 bool is_link_state_evt(u32 trailer);
729 /* Configuration Functions */
730 int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
732 struct be_default_pdu_context {
736 struct amap_be_default_pdu_context {
737 u8 dbuf_cindex[13]; /* dword 0 */
738 u8 rsvd0[3]; /* dword 0 */
739 u8 ring_size[4]; /* dword 0 */
740 u8 ring_state[4]; /* dword 0 */
741 u8 rsvd1[8]; /* dword 0 */
742 u8 dbuf_pindex[13]; /* dword 1 */
743 u8 rsvd2; /* dword 1 */
744 u8 pci_func_id[8]; /* dword 1 */
745 u8 rx_pdid[9]; /* dword 1 */
746 u8 rx_pdid_valid; /* dword 1 */
747 u8 default_buffer_size[16]; /* dword 2 */
748 u8 cq_id_recv[10]; /* dword 2 */
749 u8 rx_pdid_not_valid; /* dword 2 */
750 u8 rsvd3[5]; /* dword 2 */
751 u8 rsvd4[32]; /* dword 3 */
754 struct be_defq_create_req {
755 struct be_cmd_req_hdr hdr;
759 struct be_default_pdu_context context;
760 struct phys_addr pages[8];
763 struct be_defq_create_resp {
764 struct be_cmd_req_hdr hdr;
769 struct be_post_sgl_pages_req {
770 struct be_cmd_req_hdr hdr;
774 struct phys_addr pages[26];
778 struct be_wrbq_create_req {
779 struct be_cmd_req_hdr hdr;
783 struct phys_addr pages[8];
786 struct be_wrbq_create_resp {
787 struct be_cmd_resp_hdr resp_hdr;
792 #define SOL_CID_MASK 0x0000FFC0
793 #define SOL_CODE_MASK 0x0000003F
794 #define SOL_WRB_INDEX_MASK 0x00FF0000
795 #define SOL_CMD_WND_MASK 0xFF000000
796 #define SOL_RES_CNT_MASK 0x7FFFFFFF
797 #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
798 #define SOL_HW_STS_MASK 0x000000FF
799 #define SOL_STS_MASK 0x0000FF00
800 #define SOL_RESP_MASK 0x00FF0000
801 #define SOL_FLAGS_MASK 0x7F000000
802 #define SOL_S_MASK 0x80000000
808 struct amap_sol_cqe {
809 u8 hw_sts[8]; /* dword 0 */
810 u8 i_sts[8]; /* dword 0 */
811 u8 i_resp[8]; /* dword 0 */
812 u8 i_flags[7]; /* dword 0 */
814 u8 i_exp_cmd_sn[32]; /* dword 1 */
815 u8 code[6]; /* dword 2 */
816 u8 cid[10]; /* dword 2 */
817 u8 wrb_index[8]; /* dword 2 */
818 u8 i_cmd_wnd[8]; /* dword 2 */
819 u8 i_res_cnt[31]; /* dword 3 */
820 u8 valid; /* dword 3 */
823 #define SOL_ICD_INDEX_MASK 0x0003FFC0
824 struct amap_sol_cqe_ring {
825 u8 hw_sts[8]; /* dword 0 */
826 u8 i_sts[8]; /* dword 0 */
827 u8 i_resp[8]; /* dword 0 */
828 u8 i_flags[7]; /* dword 0 */
830 u8 i_exp_cmd_sn[32]; /* dword 1 */
831 u8 code[6]; /* dword 2 */
832 u8 icd_index[12]; /* dword 2 */
833 u8 rsvd[6]; /* dword 2 */
834 u8 i_cmd_wnd[8]; /* dword 2 */
835 u8 i_res_cnt[31]; /* dword 3 */
836 u8 valid; /* dword 3 */
839 struct amap_sol_cqe_v2 {
840 u8 hw_sts[8]; /* dword 0 */
841 u8 i_sts[8]; /* dword 0 */
842 u8 wrb_index[16]; /* dword 0 */
843 u8 i_exp_cmd_sn[32]; /* dword 1 */
844 u8 code[6]; /* dword 2 */
845 u8 cmd_cmpl; /* dword 2 */
846 u8 rsvd0; /* dword 2 */
847 u8 i_cmd_wnd[8]; /* dword 2 */
848 u8 cid[13]; /* dword 2 */
852 u8 i_res_cnt[31]; /* dword 3 */
853 u8 valid; /* dword 3 */
856 struct common_sol_cqe {
863 u8 res_flag; /* the s feild of structure */
864 u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
865 u8 i_flags; /* for skh or the u and o feilds */
866 u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
869 /*** iSCSI ack/driver message completions ***/
870 struct amap_it_dmsg_cqe {
871 u8 ack_num[32]; /* DWORD 0 */
872 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
873 u8 code[6]; /* DWORD 2 */
874 u8 cid[10]; /* DWORD 2 */
875 u8 wrb_idx[8]; /* DWORD 2 */
876 u8 rsvd0[8]; /* DWORD 2*/
877 u8 rsvd1[31]; /* DWORD 3*/
878 u8 valid; /* DWORD 3 */
881 struct amap_it_dmsg_cqe_v2 {
882 u8 ack_num[32]; /* DWORD 0 */
883 u8 pdu_bytes_rcvd[32]; /* DWORD 1 */
884 u8 code[6]; /* DWORD 2 */
885 u8 rsvd0[10]; /* DWORD 2 */
886 u8 wrb_idx[16]; /* DWORD 2 */
887 u8 rsvd1[16]; /* DWORD 3 */
888 u8 cid[13]; /* DWORD 3 */
889 u8 rsvd2[2]; /* DWORD 3 */
890 u8 valid; /* DWORD 3 */
895 * Post WRB Queue Doorbell Register used by the host Storage
896 * stack to notify the
897 * controller of a posted Work Request Block
899 #define DB_WRB_POST_CID_MASK 0x3FF /* bits 0 - 9 */
900 #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
902 #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
903 #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
905 struct fragnum_bits_for_sgl_cra_in {
906 struct be_cmd_req_hdr hdr;
910 struct iscsi_cleanup_req {
911 struct be_cmd_req_hdr hdr;
921 u32 delay_multiplier;
924 struct be_eq_delay_params_in {
925 struct be_cmd_req_hdr hdr;
927 struct eq_delay delay[8];
930 struct tcp_connect_and_offload_in {
931 struct be_cmd_req_hdr hdr;
932 struct ip_addr_format ip_address;
937 struct phys_addr dataout_template_pa;
944 struct tcp_connect_and_offload_out {
945 struct be_cmd_resp_hdr hdr;
946 u32 connection_handle;
952 struct be_mcc_wrb_context {
954 int *users_final_status;
957 #define DB_DEF_PDU_RING_ID_MASK 0x3FF /* bits 0 - 9 */
958 #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 0 - 9 */
959 #define DB_DEF_PDU_REARM_SHIFT 14
960 #define DB_DEF_PDU_EVENT_SHIFT 15
961 #define DB_DEF_PDU_CQPROC_SHIFT 16
967 struct tcp_upload_params_in {
968 struct be_cmd_req_hdr hdr;
974 struct tcp_upload_params_out {
978 union tcp_upload_params {
979 struct tcp_upload_params_in request;
980 struct tcp_upload_params_out response;
983 struct be_ulp_fw_cfg {
1000 struct be_cmd_req_hdr hdr;
1001 u32 be_config_number;
1005 struct be_ulp_fw_cfg ulp[2];
1009 struct be_cmd_get_all_if_id_req {
1010 struct be_cmd_req_hdr hdr;
1012 u32 if_hndl_list[1];
1015 #define ISCSI_OPCODE_SCSI_DATA_OUT 5
1016 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1017 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1018 #define OPCODE_COMMON_ISCSI_CLEANUP 59
1019 #define OPCODE_COMMON_TCP_UPLOAD 56
1020 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1021 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1022 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1023 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1024 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
1025 #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1026 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1027 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1028 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
1029 #define OPCODE_COMMON_WRITE_FLASH 96
1030 #define OPCODE_COMMON_READ_FLASH 97
1032 /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1033 #define CMD_ISCSI_COMMAND_INVALIDATE 1
1034 #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1035 #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
1037 #define INI_WR_CMD 1 /* Initiator write command */
1038 #define INI_TMF_CMD 2 /* Initiator TMF command */
1039 #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1040 #define INI_RD_CMD 5 /* Initiator requesting to send
1043 #define TGT_CTX_UPDT_CMD 7 /* Target context update */
1044 #define TGT_STS_CMD 8 /* Target R2T and other BHS
1045 * where only the status number
1046 * need to be updated
1048 #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1051 #define TGT_SOS_PDU 10 /* Target:standalone status
1054 #define TGT_DM_CMD 11 /* Indicates that the bhs
1056 * driver should not be touched
1058 /* --- CMD_CHUTE_TYPE --- */
1059 #define CMD_CONNECTION_CHUTE_0 1
1060 #define CMD_CONNECTION_CHUTE_1 2
1061 #define CMD_CONNECTION_CHUTE_2 3
1063 #define EQ_MAJOR_CODE_COMPLETION 0
1065 #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1066 #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1068 /* --- CONNECTION_UPLOAD_PARAMS --- */
1069 /* These parameters are used to define the type of upload desired. */
1070 #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1071 #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1074 #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1077 #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1078 * sequence number by driver */
1080 /* Returns the number of items in the field array. */
1081 #define BE_NUMBER_OF_FIELD(_type_, _field_) \
1082 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1085 * Different types of iSCSI completions to host driver for both initiator
1089 #define SOL_CMD_COMPLETE 1 /* Solicited command completed
1092 #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1093 * invalidated internally due
1094 * to Data Digest error
1096 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1098 * due to a received PDU
1101 #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1102 * internally due ti received
1103 * PDU sequence size >
1106 #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
1107 * internally due to a received
1110 #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1111 * internally due to Hdr Digest
1114 #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1116 * due to a bad opcode in the
1119 #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
1120 * internally due to a received
1121 * ITT/TTT that does not belong
1122 * to this Connection
1124 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
1125 * internally due to received
1126 * ITT/TTT value > Max
1127 * Supported ITTs/TTTs
1129 #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1130 * internally due to an
1133 #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1134 * internally due to timeout on
1135 * tcp segment 12 retransmit
1138 #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1139 * internally due to TCP RST
1140 * sent by the Tx side
1142 #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1143 * internally due to an
1146 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1147 * internally due to bad
1148 * unsolicited PDU Unsolicited
1149 * PDUs are PDUs with
1152 #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1153 * internally due to bad WRB
1156 #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
1157 * internally due to received
1158 * command has residual
1161 #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
1162 * internally due to received
1163 * command has residual under
1166 #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
1167 * internally due to a received
1168 * PDU has an invalid StatusSN
1170 #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
1171 * internally due to a received
1172 * an R2T with some invalid
1175 #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1176 * internally due to received
1177 * PDU has an invalid LUN.
1179 #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1180 * internally due to the
1181 * corresponding ICD not in a
1184 #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1185 * to received PDU has an
1188 #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1189 * to received sequence buffer
1190 * offset is out of order.
1192 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1193 * internally due to a
1194 * received PDU has an invalid
1197 #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1198 * completion notify.
1200 #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1202 * with data PDU index.
1204 #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1205 * completionnotifify.
1207 #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1208 #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
1209 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
1212 #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1215 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1216 * internally due to command
1217 * and data are not on same
1220 #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1221 * invalidated internally due
1224 #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1225 * internally due to incoming
1228 #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1229 * internally due to an
1230 * incoming Unsolicited PDU
1231 * that has immediate data on
1235 int beiscsi_pci_soft_reset(struct beiscsi_hba *phba);
1236 int be_chk_reset_complete(struct beiscsi_hba *phba);
1238 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, int payload_len,
1239 bool embedded, u8 sge_cnt);
1241 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1242 u8 subsystem, u8 opcode, int cmd_len);
1244 #endif /* !BEISCSI_CMDS_H */