2 * Copyright (C) 2005 - 2015 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@avagotech.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 #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 */
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)
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
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 31 - 16 */
65 #define CQE_STATUS_ADDL_MASK 0xFF00
66 #define CQE_STATUS_ADDL_SHIFT 8
67 #define CQE_STATUS_MASK 0xFF
68 #define CQE_STATUS_WRB_MASK 0xFF0000
69 #define CQE_STATUS_WRB_SHIFT 16
71 #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
72 #define BEISCSI_FW_MBX_TIMEOUT 100
74 /* MBOX Command VER */
75 #define MBX_CMD_VER1 0x01
76 #define MBX_CMD_VER2 0x02
79 u32 status
; /* dword 0 */
80 u32 tag0
; /* dword 1 */
81 u32 tag1
; /* dword 2 */
82 u32 flags
; /* dword 3 */
85 /********* Mailbox door bell *************/
87 * Used for driver communication with the FW.
88 * The software must write this register twice to post any command. First,
89 * it writes the register with hi=1 and the upper bits of the physical address
90 * for the MAILBOX structure. Software must poll the ready bit until this
91 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
92 * bits in the address. It must poll the ready bit until the command is
93 * complete. Upon completion, the MAILBOX will contain a valid completion
96 #define MPU_MAILBOX_DB_OFFSET 0x160
97 #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
98 #define MPU_MAILBOX_DB_HI_MASK 0x2 /* bit 1 */
100 /********** MPU semphore ******************/
101 #define MPU_EP_SEMAPHORE_OFFSET 0xac
102 #define EP_SEMAPHORE_POST_STAGE_MASK 0x0000FFFF
103 #define EP_SEMAPHORE_POST_ERR_MASK 0x1
104 #define EP_SEMAPHORE_POST_ERR_SHIFT 31
106 /********** MCC door bell ************/
107 #define DB_MCCQ_OFFSET 0x140
108 #define DB_MCCQ_RING_ID_MASK 0xFFFF /* bits 0 - 15 */
109 /* Number of entries posted */
110 #define DB_MCCQ_NUM_POSTED_SHIFT 16 /* bits 16 - 29 */
112 /* MPU semphore POST stage values */
113 #define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
116 * When the async bit of mcc_compl is set, the last 4 bytes of
117 * mcc_compl is interpreted as follows:
119 #define ASYNC_TRAILER_EVENT_CODE_SHIFT 8 /* bits 8 - 15 */
120 #define ASYNC_TRAILER_EVENT_CODE_MASK 0xFF
121 #define ASYNC_EVENT_CODE_LINK_STATE 0x1
122 #define ASYNC_EVENT_CODE_ISCSI 0x4
123 #define ASYNC_EVENT_CODE_SLI 0x11
125 #define ASYNC_TRAILER_EVENT_TYPE_SHIFT 16 /* bits 16 - 23 */
126 #define ASYNC_TRAILER_EVENT_TYPE_MASK 0xFF
129 #define ASYNC_EVENT_NEW_ISCSI_TGT_DISC 0x4
130 #define ASYNC_EVENT_NEW_ISCSI_CONN 0x5
131 #define ASYNC_EVENT_NEW_TCP_CONN 0x7
134 #define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED 0x9
135 #define ASYNC_SLI_LINK_EFFECT_VALID(le) (le & 0x80)
136 #define ASYNC_SLI_LINK_EFFECT_SEV(le) ((le >> 1) & 0x03)
137 #define ASYNC_SLI_LINK_EFFECT_STATE(le) (le & 0x01)
139 struct be_async_event_trailer
{
144 ASYNC_EVENT_LINK_DOWN
= 0x0,
145 ASYNC_EVENT_LINK_UP
= 0x1,
149 * When the event code of an async trailer is link-state, the mcc_compl
150 * must be interpreted as follows
152 struct be_async_event_link_state
{
156 * ASYNC_EVENT_LINK_DOWN 0x0
157 * ASYNC_EVENT_LINK_UP 0x1
158 * ASYNC_EVENT_LINK_LOGICAL_DOWN 0x2
159 * ASYNC_EVENT_LINK_LOGICAL_UP 0x3
161 #define BE_ASYNC_LINK_UP_MASK 0x01
164 /* BE2ISCSI_LINK_SPEED_ZERO 0x00 - no link */
165 #define BE2ISCSI_LINK_SPEED_10MBPS 0x01
166 #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
167 #define BE2ISCSI_LINK_SPEED_1GBPS 0x03
168 #define BE2ISCSI_LINK_SPEED_10GBPS 0x04
169 #define BE2ISCSI_LINK_SPEED_25GBPS 0x06
170 #define BE2ISCSI_LINK_SPEED_40GBPS 0x07
175 struct be_async_event_trailer trailer
;
179 * When async-trailer is SLI event, mcc_compl is interpreted as
181 struct be_async_event_sli
{
188 struct be_mcc_mailbox
{
189 struct be_mcc_wrb wrb
;
190 struct be_mcc_compl
compl;
193 /* Type of subsystems supported by FW */
194 #define CMD_SUBSYSTEM_COMMON 0x1
195 #define CMD_SUBSYSTEM_ISCSI 0x2
196 #define CMD_SUBSYSTEM_ETH 0x3
197 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
198 #define CMD_COMMON_TCP_UPLOAD 0x1
201 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
202 * These opcodes are unique for each subsystem defined above
204 #define OPCODE_COMMON_CQ_CREATE 12
205 #define OPCODE_COMMON_EQ_CREATE 13
206 #define OPCODE_COMMON_MCC_CREATE 21
207 #define OPCODE_COMMON_MCC_CREATE_EXT 90
208 #define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
209 #define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
210 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
211 #define OPCODE_COMMON_GET_FW_VERSION 35
212 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
213 #define OPCODE_COMMON_FIRMWARE_CONFIG 42
214 #define OPCODE_COMMON_MCC_DESTROY 53
215 #define OPCODE_COMMON_CQ_DESTROY 54
216 #define OPCODE_COMMON_EQ_DESTROY 55
217 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
218 #define OPCODE_COMMON_FUNCTION_RESET 61
219 #define OPCODE_COMMON_GET_PORT_NAME 77
222 * LIST of opcodes that are common between Initiator and Target
223 * used by CMD_SUBSYSTEM_ISCSI
224 * These opcodes are unique for each subsystem defined above
226 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
227 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
228 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
229 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
230 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
231 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
232 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
233 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
234 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
235 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
236 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
237 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
238 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
239 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
240 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
241 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
243 struct be_cmd_req_hdr
{
244 u8 opcode
; /* dword 0 */
245 u8 subsystem
; /* dword 0 */
246 u8 port_number
; /* dword 0 */
247 u8 domain
; /* dword 0 */
248 u32 timeout
; /* dword 1 */
249 u32 request_length
; /* dword 2 */
250 u8 version
; /* dword 3 */
251 u8 rsvd0
[3]; /* dword 3 */
254 struct be_cmd_resp_hdr
{
255 u32 info
; /* dword 0 */
256 u32 status
; /* dword 1 */
257 u32 response_length
; /* dword 2 */
258 u32 actual_resp_len
; /* dword 3 */
270 /**************************
271 * BE Command definitions *
272 **************************/
275 * Pseudo amap definition in which each bit of the actual structure is defined
276 * as a byte - used to calculate offset/shift/mask of each field
278 struct amap_eq_context
{
279 u8 cidx
[13]; /* dword 0 */
280 u8 rsvd0
[3]; /* dword 0 */
281 u8 epidx
[13]; /* dword 0 */
282 u8 valid
; /* dword 0 */
283 u8 rsvd1
; /* dword 0 */
284 u8 size
; /* dword 0 */
285 u8 pidx
[13]; /* dword 1 */
286 u8 rsvd2
[3]; /* dword 1 */
287 u8 pd
[10]; /* dword 1 */
288 u8 count
[3]; /* dword 1 */
289 u8 solevent
; /* dword 1 */
290 u8 stalled
; /* dword 1 */
291 u8 armed
; /* dword 1 */
292 u8 rsvd3
[4]; /* dword 2 */
293 u8 func
[8]; /* dword 2 */
294 u8 rsvd4
; /* dword 2 */
295 u8 delaymult
[10]; /* dword 2 */
296 u8 rsvd5
[2]; /* dword 2 */
297 u8 phase
[2]; /* dword 2 */
298 u8 nodelay
; /* dword 2 */
299 u8 rsvd6
[4]; /* dword 2 */
300 u8 rsvd7
[32]; /* dword 3 */
303 struct be_cmd_req_eq_create
{
304 struct be_cmd_req_hdr hdr
; /* dw[4] */
305 u16 num_pages
; /* sword */
306 u16 rsvd0
; /* sword */
307 u8 context
[sizeof(struct amap_eq_context
) / 8]; /* dw[4] */
308 struct phys_addr pages
[8];
311 struct be_cmd_resp_eq_create
{
312 struct be_cmd_resp_hdr resp_hdr
;
313 u16 eq_id
; /* sword */
314 u16 rsvd0
; /* sword */
320 u32 delay_multiplier
;
323 struct mgmt_chap_format
{
325 u8 intr_chap_name
[256];
327 u8 target_chap_name
[256];
328 u8 target_secret
[16];
329 u16 intr_chap_name_length
;
330 u16 intr_secret_length
;
331 u16 target_chap_name_length
;
332 u16 target_secret_length
;
335 struct mgmt_auth_method_format
{
338 struct mgmt_chap_format chap
;
341 struct be_cmd_req_logout_fw_sess
{
342 struct be_cmd_req_hdr hdr
; /* dw[4] */
343 uint32_t session_handle
;
346 struct be_cmd_resp_logout_fw_sess
{
347 struct be_cmd_resp_hdr hdr
; /* dw[4] */
348 #define BEISCSI_MGMT_SESSION_CLOSE 0x20
349 uint32_t session_status
;
352 struct mgmt_conn_login_options
{
357 u32 max_recv_datasegment_len_ini
;
358 u32 max_recv_datasegment_len_tgt
;
361 struct mgmt_auth_method_format auth_data
;
364 struct ip_addr_format
{
365 u16 size_of_structure
;
372 struct mgmt_conn_info
{
373 u32 connection_handle
;
374 u32 connection_status
;
377 u16 dest_port_redirected
;
379 u32 estimated_throughput
;
380 struct ip_addr_format src_ipaddr
;
381 struct ip_addr_format dest_ipaddr
;
382 struct ip_addr_format dest_ipaddr_redirected
;
383 struct mgmt_conn_login_options negotiated_login_options
;
386 struct mgmt_session_login_options
{
388 u8 error_recovery_level
;
390 u32 first_burst_length
;
391 u32 max_burst_length
;
393 u16 max_outstanding_r2t
;
394 u16 default_time2wait
;
395 u16 default_time2retain
;
398 struct mgmt_session_info
{
407 u8 initiator_iscsiname
[224];
408 struct mgmt_session_login_options negotiated_login_options
;
409 struct mgmt_conn_info conn_list
[1];
412 struct be_cmd_get_session_req
{
413 struct be_cmd_req_hdr hdr
;
417 struct be_cmd_get_session_resp
{
418 struct be_cmd_resp_hdr hdr
;
419 struct mgmt_session_info session_info
;
423 u16 size_of_structure
;
427 struct be_cmd_get_boot_target_req
{
428 struct be_cmd_req_hdr hdr
;
431 struct be_cmd_get_boot_target_resp
{
432 struct be_cmd_resp_hdr hdr
;
433 u32 boot_session_count
;
434 int boot_session_handle
;
437 struct be_cmd_reopen_session_req
{
438 struct be_cmd_req_hdr hdr
;
439 #define BE_REOPEN_ALL_SESSIONS 0x00
440 #define BE_REOPEN_BOOT_SESSIONS 0x01
441 #define BE_REOPEN_A_SESSION 0x02
447 struct be_cmd_reopen_session_resp
{
448 struct be_cmd_resp_hdr hdr
;
454 struct be_cmd_mac_query_req
{
455 struct be_cmd_req_hdr hdr
;
461 struct be_cmd_get_mac_resp
{
462 struct be_cmd_resp_hdr hdr
;
466 struct be_ip_addr_subnet_format
{
467 u16 size_of_structure
;
469 u8 ipv6_prefix_length
;
475 struct be_cmd_get_if_info_req
{
476 struct be_cmd_req_hdr hdr
;
481 struct be_cmd_get_if_info_resp
{
482 struct be_cmd_req_hdr hdr
;
487 struct be_ip_addr_subnet_format ip_addr
;
490 struct be_ip_addr_record
{
493 struct be_ip_addr_subnet_format ip_addr
;
497 struct be_ip_addr_record_params
{
498 u32 record_entry_count
;
499 struct be_ip_addr_record ip_record
;
502 struct be_cmd_set_ip_addr_req
{
503 struct be_cmd_req_hdr hdr
;
504 struct be_ip_addr_record_params ip_params
;
508 struct be_cmd_set_dhcp_req
{
509 struct be_cmd_req_hdr hdr
;
516 struct be_cmd_rel_dhcp_req
{
517 struct be_cmd_req_hdr hdr
;
522 struct be_cmd_set_def_gateway_req
{
523 struct be_cmd_req_hdr hdr
;
525 struct ip_addr_format ip_addr
;
528 struct be_cmd_get_def_gateway_req
{
529 struct be_cmd_req_hdr hdr
;
533 struct be_cmd_get_def_gateway_resp
{
534 struct be_cmd_req_hdr hdr
;
535 struct ip_addr_format ip_addr
;
538 #define BEISCSI_VLAN_DISABLE 0xFFFF
539 struct be_cmd_set_vlan_req
{
540 struct be_cmd_req_hdr hdr
;
544 /******************** Create CQ ***************************/
546 * Pseudo amap definition in which each bit of the actual structure is defined
547 * as a byte - used to calculate offset/shift/mask of each field
549 struct amap_cq_context
{
550 u8 cidx
[11]; /* dword 0 */
551 u8 rsvd0
; /* dword 0 */
552 u8 coalescwm
[2]; /* dword 0 */
553 u8 nodelay
; /* dword 0 */
554 u8 epidx
[11]; /* dword 0 */
555 u8 rsvd1
; /* dword 0 */
556 u8 count
[2]; /* dword 0 */
557 u8 valid
; /* dword 0 */
558 u8 solevent
; /* dword 0 */
559 u8 eventable
; /* dword 0 */
560 u8 pidx
[11]; /* dword 1 */
561 u8 rsvd2
; /* dword 1 */
562 u8 pd
[10]; /* dword 1 */
563 u8 eqid
[8]; /* dword 1 */
564 u8 stalled
; /* dword 1 */
565 u8 armed
; /* dword 1 */
566 u8 rsvd3
[4]; /* dword 2 */
567 u8 func
[8]; /* dword 2 */
568 u8 rsvd4
[20]; /* dword 2 */
569 u8 rsvd5
[32]; /* dword 3 */
572 struct amap_cq_context_v2
{
573 u8 rsvd0
[12]; /* dword 0 */
574 u8 coalescwm
[2]; /* dword 0 */
575 u8 nodelay
; /* dword 0 */
576 u8 rsvd1
[12]; /* dword 0 */
577 u8 count
[2]; /* dword 0 */
578 u8 valid
; /* dword 0 */
579 u8 rsvd2
; /* dword 0 */
580 u8 eventable
; /* dword 0 */
581 u8 eqid
[16]; /* dword 1 */
582 u8 rsvd3
[15]; /* dword 1 */
583 u8 armed
; /* dword 1 */
584 u8 cqecount
[16];/* dword 2 */
585 u8 rsvd4
[16]; /* dword 2 */
586 u8 rsvd5
[32]; /* dword 3 */
589 struct be_cmd_req_cq_create
{
590 struct be_cmd_req_hdr hdr
;
594 u8 context
[sizeof(struct amap_cq_context
) / 8];
595 struct phys_addr pages
[4];
598 struct be_cmd_resp_cq_create
{
599 struct be_cmd_resp_hdr hdr
;
604 /******************** Create MCCQ ***************************/
606 * Pseudo amap definition in which each bit of the actual structure is defined
607 * as a byte - used to calculate offset/shift/mask of each field
609 struct amap_mcc_context
{
624 struct be_cmd_req_mcc_create_ext
{
625 struct be_cmd_req_hdr hdr
;
628 u32 async_evt_bitmap
;
629 u8 context
[sizeof(struct amap_mcc_context
) / 8];
630 struct phys_addr pages
[8];
633 struct be_cmd_resp_mcc_create
{
634 struct be_cmd_resp_hdr hdr
;
639 /******************** Q Destroy ***************************/
640 /* Type of Queue to be destroyed */
650 struct be_cmd_req_q_destroy
{
651 struct be_cmd_req_hdr hdr
;
653 u16 bypass_flush
; /* valid only for rx q destroy */
660 struct be_cmd_req_mcast_mac_config
{
661 struct be_cmd_req_hdr hdr
;
665 struct macaddr mac
[32];
668 static inline void *embedded_payload(struct be_mcc_wrb
*wrb
)
670 return wrb
->payload
.embedded_payload
;
673 static inline struct be_sge
*nonembedded_sgl(struct be_mcc_wrb
*wrb
)
675 return &wrb
->payload
.sgl
[0];
678 /******************** Modify EQ Delay *******************/
679 struct be_cmd_req_modify_eq_delay
{
680 struct be_cmd_req_hdr hdr
;
685 __le32 delay_multiplier
;
689 /******************** Get MAC ADDR *******************/
691 struct be_cmd_get_nic_conf_resp
{
692 struct be_cmd_resp_hdr hdr
;
698 u16 size_of_structure
;
699 u8 mac_address
[ETH_ALEN
];
702 #define BEISCSI_ALIAS_LEN 32
704 struct be_cmd_hba_name
{
705 struct be_cmd_req_hdr hdr
;
708 u8 initiator_name
[ISCSI_NAME_LEN
];
709 u8 initiator_alias
[BEISCSI_ALIAS_LEN
];
712 int beiscsi_cmd_eq_create(struct be_ctrl_info
*ctrl
,
713 struct be_queue_info
*eq
, int eq_delay
);
715 int beiscsi_cmd_cq_create(struct be_ctrl_info
*ctrl
,
716 struct be_queue_info
*cq
, struct be_queue_info
*eq
,
717 bool sol_evts
, bool no_delay
,
718 int num_cqe_dma_coalesce
);
720 int beiscsi_cmd_q_destroy(struct be_ctrl_info
*ctrl
, struct be_queue_info
*q
,
722 int beiscsi_cmd_mccq_create(struct beiscsi_hba
*phba
,
723 struct be_queue_info
*mccq
,
724 struct be_queue_info
*cq
);
726 int be_poll_mcc(struct be_ctrl_info
*ctrl
);
727 int mgmt_check_supported_fw(struct be_ctrl_info
*ctrl
,
728 struct beiscsi_hba
*phba
);
729 unsigned int be_cmd_get_initname(struct beiscsi_hba
*phba
);
731 void free_mcc_wrb(struct be_ctrl_info
*ctrl
, unsigned int tag
);
733 int be_cmd_modify_eq_delay(struct beiscsi_hba
*phba
, struct be_set_eqd
*,
735 int beiscsi_mccq_compl_wait(struct beiscsi_hba
*phba
,
736 uint32_t tag
, struct be_mcc_wrb
**wrb
,
737 struct be_dma_mem
*mbx_cmd_mem
);
738 /*ISCSI Functuions */
739 int be_cmd_fw_initialize(struct be_ctrl_info
*ctrl
);
740 int be_cmd_fw_uninit(struct be_ctrl_info
*ctrl
);
742 struct be_mcc_wrb
*wrb_from_mbox(struct be_dma_mem
*mbox_mem
);
743 int be_mcc_compl_poll(struct beiscsi_hba
*phba
, unsigned int tag
);
744 void be_mcc_notify(struct beiscsi_hba
*phba
, unsigned int tag
);
745 struct be_mcc_wrb
*alloc_mcc_wrb(struct beiscsi_hba
*phba
,
746 unsigned int *ref_tag
);
747 void beiscsi_process_async_event(struct beiscsi_hba
*phba
,
748 struct be_mcc_compl
*compl);
749 int beiscsi_process_mcc_compl(struct be_ctrl_info
*ctrl
,
750 struct be_mcc_compl
*compl);
753 int be_mbox_notify(struct be_ctrl_info
*ctrl
);
755 int be_cmd_create_default_pdu_queue(struct be_ctrl_info
*ctrl
,
756 struct be_queue_info
*cq
,
757 struct be_queue_info
*dq
, int length
,
758 int entry_size
, uint8_t is_header
,
761 int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info
*ctrl
,
762 struct be_dma_mem
*q_mem
);
764 int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info
*ctrl
);
766 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info
*ctrl
,
767 struct be_dma_mem
*q_mem
, u32 page_offset
,
770 int beiscsi_cmd_reset_function(struct beiscsi_hba
*phba
);
772 int be_cmd_wrbq_create(struct be_ctrl_info
*ctrl
, struct be_dma_mem
*q_mem
,
773 struct be_queue_info
*wrbq
,
774 struct hwi_wrb_context
*pwrb_context
,
777 /* Configuration Functions */
778 int be_cmd_set_vlan(struct beiscsi_hba
*phba
, uint16_t vlan_tag
);
780 struct be_default_pdu_context
{
784 struct amap_be_default_pdu_context
{
785 u8 dbuf_cindex
[13]; /* dword 0 */
786 u8 rsvd0
[3]; /* dword 0 */
787 u8 ring_size
[4]; /* dword 0 */
788 u8 ring_state
[4]; /* dword 0 */
789 u8 rsvd1
[8]; /* dword 0 */
790 u8 dbuf_pindex
[13]; /* dword 1 */
791 u8 rsvd2
; /* dword 1 */
792 u8 pci_func_id
[8]; /* dword 1 */
793 u8 rx_pdid
[9]; /* dword 1 */
794 u8 rx_pdid_valid
; /* dword 1 */
795 u8 default_buffer_size
[16]; /* dword 2 */
796 u8 cq_id_recv
[10]; /* dword 2 */
797 u8 rx_pdid_not_valid
; /* dword 2 */
798 u8 rsvd3
[5]; /* dword 2 */
799 u8 rsvd4
[32]; /* dword 3 */
802 struct amap_default_pdu_context_ext
{
803 u8 rsvd0
[16]; /* dword 0 */
804 u8 ring_size
[4]; /* dword 0 */
805 u8 rsvd1
[12]; /* dword 0 */
806 u8 rsvd2
[22]; /* dword 1 */
807 u8 rx_pdid
[9]; /* dword 1 */
808 u8 rx_pdid_valid
; /* dword 1 */
809 u8 default_buffer_size
[16]; /* dword 2 */
810 u8 cq_id_recv
[16]; /* dword 2 */
811 u8 rsvd3
[32]; /* dword 3 */
814 struct be_defq_create_req
{
815 struct be_cmd_req_hdr hdr
;
818 #define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
819 #define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
821 struct be_default_pdu_context context
;
822 struct phys_addr pages
[8];
825 struct be_defq_create_resp
{
826 struct be_cmd_req_hdr hdr
;
835 struct be_post_template_pages_req
{
836 struct be_cmd_req_hdr hdr
;
838 #define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
840 struct phys_addr scratch_pa
;
841 struct virt_addr scratch_va
;
842 struct virt_addr pages_va
;
843 struct phys_addr pages
[16];
846 struct be_remove_template_pages_req
{
847 struct be_cmd_req_hdr hdr
;
852 struct be_post_sgl_pages_req
{
853 struct be_cmd_req_hdr hdr
;
857 struct phys_addr pages
[26];
861 struct be_wrbq_create_req
{
862 struct be_cmd_req_hdr hdr
;
866 struct phys_addr pages
[8];
869 struct be_wrbq_create_resp
{
870 struct be_cmd_resp_hdr resp_hdr
;
879 #define SOL_CID_MASK 0x0000FFC0
880 #define SOL_CODE_MASK 0x0000003F
881 #define SOL_WRB_INDEX_MASK 0x00FF0000
882 #define SOL_CMD_WND_MASK 0xFF000000
883 #define SOL_RES_CNT_MASK 0x7FFFFFFF
884 #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
885 #define SOL_HW_STS_MASK 0x000000FF
886 #define SOL_STS_MASK 0x0000FF00
887 #define SOL_RESP_MASK 0x00FF0000
888 #define SOL_FLAGS_MASK 0x7F000000
889 #define SOL_S_MASK 0x80000000
895 struct amap_sol_cqe
{
896 u8 hw_sts
[8]; /* dword 0 */
897 u8 i_sts
[8]; /* dword 0 */
898 u8 i_resp
[8]; /* dword 0 */
899 u8 i_flags
[7]; /* dword 0 */
901 u8 i_exp_cmd_sn
[32]; /* dword 1 */
902 u8 code
[6]; /* dword 2 */
903 u8 cid
[10]; /* dword 2 */
904 u8 wrb_index
[8]; /* dword 2 */
905 u8 i_cmd_wnd
[8]; /* dword 2 */
906 u8 i_res_cnt
[31]; /* dword 3 */
907 u8 valid
; /* dword 3 */
910 #define SOL_ICD_INDEX_MASK 0x0003FFC0
911 struct amap_sol_cqe_ring
{
912 u8 hw_sts
[8]; /* dword 0 */
913 u8 i_sts
[8]; /* dword 0 */
914 u8 i_resp
[8]; /* dword 0 */
915 u8 i_flags
[7]; /* dword 0 */
917 u8 i_exp_cmd_sn
[32]; /* dword 1 */
918 u8 code
[6]; /* dword 2 */
919 u8 icd_index
[12]; /* dword 2 */
920 u8 rsvd
[6]; /* dword 2 */
921 u8 i_cmd_wnd
[8]; /* dword 2 */
922 u8 i_res_cnt
[31]; /* dword 3 */
923 u8 valid
; /* dword 3 */
926 struct amap_sol_cqe_v2
{
927 u8 hw_sts
[8]; /* dword 0 */
928 u8 i_sts
[8]; /* dword 0 */
929 u8 wrb_index
[16]; /* dword 0 */
930 u8 i_exp_cmd_sn
[32]; /* dword 1 */
931 u8 code
[6]; /* dword 2 */
932 u8 cmd_cmpl
; /* dword 2 */
933 u8 rsvd0
; /* dword 2 */
934 u8 i_cmd_wnd
[8]; /* dword 2 */
935 u8 cid
[13]; /* dword 2 */
939 u8 i_res_cnt
[31]; /* dword 3 */
940 u8 valid
; /* dword 3 */
943 struct common_sol_cqe
{
950 u8 res_flag
; /* the s feild of structure */
951 u8 i_resp
; /* for skh if cmd_complete is set then i_sts is response */
952 u8 i_flags
; /* for skh or the u and o feilds */
953 u8 i_sts
; /* for skh if cmd_complete is not-set then i_sts is status */
956 /*** iSCSI ack/driver message completions ***/
957 struct amap_it_dmsg_cqe
{
958 u8 ack_num
[32]; /* DWORD 0 */
959 u8 pdu_bytes_rcvd
[32]; /* DWORD 1 */
960 u8 code
[6]; /* DWORD 2 */
961 u8 cid
[10]; /* DWORD 2 */
962 u8 wrb_idx
[8]; /* DWORD 2 */
963 u8 rsvd0
[8]; /* DWORD 2*/
964 u8 rsvd1
[31]; /* DWORD 3*/
965 u8 valid
; /* DWORD 3 */
968 struct amap_it_dmsg_cqe_v2
{
969 u8 ack_num
[32]; /* DWORD 0 */
970 u8 pdu_bytes_rcvd
[32]; /* DWORD 1 */
971 u8 code
[6]; /* DWORD 2 */
972 u8 rsvd0
[10]; /* DWORD 2 */
973 u8 wrb_idx
[16]; /* DWORD 2 */
974 u8 rsvd1
[16]; /* DWORD 3 */
975 u8 cid
[13]; /* DWORD 3 */
976 u8 rsvd2
[2]; /* DWORD 3 */
977 u8 valid
; /* DWORD 3 */
982 * Post WRB Queue Doorbell Register used by the host Storage
983 * stack to notify the
984 * controller of a posted Work Request Block
986 #define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
987 #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
989 #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
990 #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
992 struct fragnum_bits_for_sgl_cra_in
{
993 struct be_cmd_req_hdr hdr
;
997 struct iscsi_cleanup_req
{
998 struct be_cmd_req_hdr hdr
;
1008 u32 delay_multiplier
;
1011 struct be_eq_delay_params_in
{
1012 struct be_cmd_req_hdr hdr
;
1014 struct eq_delay delay
[8];
1017 struct tcp_connect_and_offload_in
{
1018 struct be_cmd_req_hdr hdr
;
1019 struct ip_addr_format ip_address
;
1024 struct phys_addr dataout_template_pa
;
1031 struct tcp_connect_and_offload_in_v1
{
1032 struct be_cmd_req_hdr hdr
;
1033 struct ip_addr_format ip_address
;
1038 struct phys_addr dataout_template_pa
;
1044 u16 tcp_window_size
;
1045 u8 tcp_window_scale_count
;
1051 struct tcp_connect_and_offload_out
{
1052 struct be_cmd_resp_hdr hdr
;
1053 u32 connection_handle
;
1059 struct be_mcc_wrb_context
{
1060 struct MCC_WRB
*wrb
;
1061 int *users_final_status
;
1064 #define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1065 #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
1066 #define DB_DEF_PDU_REARM_SHIFT 14
1067 #define DB_DEF_PDU_EVENT_SHIFT 15
1068 #define DB_DEF_PDU_CQPROC_SHIFT 16
1074 struct tcp_upload_params_in
{
1075 struct be_cmd_req_hdr hdr
;
1081 struct tcp_upload_params_out
{
1085 union tcp_upload_params
{
1086 struct tcp_upload_params_in request
;
1087 struct tcp_upload_params_out response
;
1090 struct be_ulp_fw_cfg
{
1091 #define BEISCSI_ULP_ISCSI_INI_MODE 0x10
1107 struct be_ulp_chain_icd
{
1113 struct be_cmd_req_hdr hdr
;
1114 u32 be_config_number
;
1117 #define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1118 #define BEISCSI_FUNC_DUA_MODE 0x800
1120 struct be_ulp_fw_cfg ulp
[2];
1126 struct be_ulp_chain_icd chain_icd
[2];
1129 struct be_cmd_get_all_if_id_req
{
1130 struct be_cmd_req_hdr hdr
;
1132 u32 if_hndl_list
[1];
1135 struct be_cmd_get_port_name
{
1137 struct be_cmd_req_hdr req_hdr
;
1138 struct be_cmd_resp_hdr resp_hdr
;
1150 #define ISCSI_OPCODE_SCSI_DATA_OUT 5
1151 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1152 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1153 #define OPCODE_COMMON_ISCSI_CLEANUP 59
1154 #define OPCODE_COMMON_TCP_UPLOAD 56
1155 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1156 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1157 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1158 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1159 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
1160 #define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
1161 #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1162 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1163 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1164 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
1165 #define OPCODE_COMMON_WRITE_FLASH 96
1166 #define OPCODE_COMMON_READ_FLASH 97
1168 /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1169 #define CMD_ISCSI_COMMAND_INVALIDATE 1
1170 #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1171 #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
1173 #define INI_WR_CMD 1 /* Initiator write command */
1174 #define INI_TMF_CMD 2 /* Initiator TMF command */
1175 #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1176 #define INI_RD_CMD 5 /* Initiator requesting to send
1179 #define TGT_CTX_UPDT_CMD 7 /* Target context update */
1180 #define TGT_STS_CMD 8 /* Target R2T and other BHS
1181 * where only the status number
1182 * need to be updated
1184 #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1187 #define TGT_SOS_PDU 10 /* Target:standalone status
1190 #define TGT_DM_CMD 11 /* Indicates that the bhs
1192 * driver should not be touched
1194 /* --- CMD_CHUTE_TYPE --- */
1195 #define CMD_CONNECTION_CHUTE_0 1
1196 #define CMD_CONNECTION_CHUTE_1 2
1197 #define CMD_CONNECTION_CHUTE_2 3
1199 #define EQ_MAJOR_CODE_COMPLETION 0
1201 #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1202 #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1204 /* --- CONNECTION_UPLOAD_PARAMS --- */
1205 /* These parameters are used to define the type of upload desired. */
1206 #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1207 #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1210 #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1213 #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1214 * sequence number by driver */
1216 /* Returns the number of items in the field array. */
1217 #define BE_NUMBER_OF_FIELD(_type_, _field_) \
1218 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1221 * Different types of iSCSI completions to host driver for both initiator
1225 #define SOL_CMD_COMPLETE 1 /* Solicited command completed
1228 #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1229 * invalidated internally due
1230 * to Data Digest error
1232 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1234 * due to a received PDU
1237 #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1238 * internally due ti received
1239 * PDU sequence size >
1242 #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
1243 * internally due to a received
1246 #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1247 * internally due to Hdr Digest
1250 #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1252 * due to a bad opcode in the
1255 #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
1256 * internally due to a received
1257 * ITT/TTT that does not belong
1258 * to this Connection
1260 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
1261 * internally due to received
1262 * ITT/TTT value > Max
1263 * Supported ITTs/TTTs
1265 #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1266 * internally due to an
1269 #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1270 * internally due to timeout on
1271 * tcp segment 12 retransmit
1274 #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1275 * internally due to TCP RST
1276 * sent by the Tx side
1278 #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1279 * internally due to an
1282 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1283 * internally due to bad
1284 * unsolicited PDU Unsolicited
1285 * PDUs are PDUs with
1288 #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1289 * internally due to bad WRB
1292 #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
1293 * internally due to received
1294 * command has residual
1297 #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
1298 * internally due to received
1299 * command has residual under
1302 #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
1303 * internally due to a received
1304 * PDU has an invalid StatusSN
1306 #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
1307 * internally due to a received
1308 * an R2T with some invalid
1311 #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1312 * internally due to received
1313 * PDU has an invalid LUN.
1315 #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1316 * internally due to the
1317 * corresponding ICD not in a
1320 #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1321 * to received PDU has an
1324 #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1325 * to received sequence buffer
1326 * offset is out of order.
1328 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1329 * internally due to a
1330 * received PDU has an invalid
1333 #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1334 * completion notify.
1336 #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1338 * with data PDU index.
1340 #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1341 * completionnotifify.
1343 #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1344 #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
1345 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
1348 #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1351 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1352 * internally due to command
1353 * and data are not on same
1356 #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1357 * invalidated internally due
1360 #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1361 * internally due to incoming
1364 #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1365 * internally due to an
1366 * incoming Unsolicited PDU
1367 * that has immediate data on
1371 int beiscsi_pci_soft_reset(struct beiscsi_hba
*phba
);
1372 int be_chk_reset_complete(struct beiscsi_hba
*phba
);
1374 void be_wrb_hdr_prepare(struct be_mcc_wrb
*wrb
, int payload_len
,
1375 bool embedded
, u8 sge_cnt
);
1377 void be_cmd_hdr_prepare(struct be_cmd_req_hdr
*req_hdr
,
1378 u8 subsystem
, u8 opcode
, int cmd_len
);
1380 void beiscsi_fail_session(struct iscsi_cls_session
*cls_session
);
1381 #endif /* !BEISCSI_CMDS_H */