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 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
73 /* MBOX Command VER */
74 #define MBX_CMD_VER1 0x01
75 #define MBX_CMD_VER2 0x02
78 u32 status
; /* dword 0 */
79 u32 tag0
; /* dword 1 */
80 u32 tag1
; /* dword 2 */
81 u32 flags
; /* dword 3 */
84 /********* Mailbox door bell *************/
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
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 */
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
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 */
111 /* MPU semphore POST stage values */
112 #define POST_STAGE_ARMFW_RDY 0xc000 /* FW is done with POST */
115 * When the async bit of mcc_compl is set, the last 4 bytes of
116 * mcc_compl is interpreted as follows:
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
123 #define ASYNC_TRAILER_EVENT_TYPE_SHIFT 16 /* bits 16 - 23 */
124 #define ASYNC_TRAILER_EVENT_TYPE_MASK 0xF
125 #define ASYNC_EVENT_NEW_ISCSI_TGT_DISC 0x4
126 #define ASYNC_EVENT_NEW_ISCSI_CONN 0x5
127 #define ASYNC_EVENT_NEW_TCP_CONN 0x7
129 struct be_async_event_trailer
{
134 ASYNC_EVENT_LINK_DOWN
= 0x0,
135 ASYNC_EVENT_LINK_UP
= 0x1,
136 ASYNC_EVENT_LOGICAL
= 0x2
140 * When the event code of an async trailer is link-state, the mcc_compl
141 * must be interpreted as follows
143 struct be_async_event_link_state
{
148 #define BEISCSI_PHY_LINK_FAULT_NONE 0x00
149 #define BEISCSI_PHY_LINK_FAULT_LOCAL 0x01
150 #define BEISCSI_PHY_LINK_FAULT_REMOTE 0x02
153 struct be_async_event_trailer trailer
;
156 struct be_mcc_mailbox
{
157 struct be_mcc_wrb wrb
;
158 struct be_mcc_compl
compl;
161 /* Type of subsystems supported by FW */
162 #define CMD_SUBSYSTEM_COMMON 0x1
163 #define CMD_SUBSYSTEM_ISCSI 0x2
164 #define CMD_SUBSYSTEM_ETH 0x3
165 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
166 #define CMD_COMMON_TCP_UPLOAD 0x1
169 * List of common opcodes subsystem CMD_SUBSYSTEM_COMMON
170 * These opcodes are unique for each subsystem defined above
172 #define OPCODE_COMMON_CQ_CREATE 12
173 #define OPCODE_COMMON_EQ_CREATE 13
174 #define OPCODE_COMMON_MCC_CREATE 21
175 #define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS 24
176 #define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS 25
177 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES 32
178 #define OPCODE_COMMON_GET_FW_VERSION 35
179 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
180 #define OPCODE_COMMON_FIRMWARE_CONFIG 42
181 #define OPCODE_COMMON_MCC_DESTROY 53
182 #define OPCODE_COMMON_CQ_DESTROY 54
183 #define OPCODE_COMMON_EQ_DESTROY 55
184 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG 58
185 #define OPCODE_COMMON_FUNCTION_RESET 61
188 * LIST of opcodes that are common between Initiator and Target
189 * used by CMD_SUBSYSTEM_ISCSI
190 * These opcodes are unique for each subsystem defined above
192 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES 2
193 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES 3
194 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG 7
195 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN 14
196 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR 17
197 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR 18
198 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR 21
199 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY 22
200 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
201 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID 24
202 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO 25
203 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
204 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE 64
205 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY 65
206 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE 66
207 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY 67
209 struct be_cmd_req_hdr
{
210 u8 opcode
; /* dword 0 */
211 u8 subsystem
; /* dword 0 */
212 u8 port_number
; /* dword 0 */
213 u8 domain
; /* dword 0 */
214 u32 timeout
; /* dword 1 */
215 u32 request_length
; /* dword 2 */
216 u8 version
; /* dword 3 */
217 u8 rsvd0
[3]; /* dword 3 */
220 struct be_cmd_resp_hdr
{
221 u32 info
; /* dword 0 */
222 u32 status
; /* dword 1 */
223 u32 response_length
; /* dword 2 */
224 u32 actual_resp_len
; /* dword 3 */
236 /**************************
237 * BE Command definitions *
238 **************************/
241 * Pseudo amap definition in which each bit of the actual structure is defined
242 * as a byte - used to calculate offset/shift/mask of each field
244 struct amap_eq_context
{
245 u8 cidx
[13]; /* dword 0 */
246 u8 rsvd0
[3]; /* dword 0 */
247 u8 epidx
[13]; /* dword 0 */
248 u8 valid
; /* dword 0 */
249 u8 rsvd1
; /* dword 0 */
250 u8 size
; /* dword 0 */
251 u8 pidx
[13]; /* dword 1 */
252 u8 rsvd2
[3]; /* dword 1 */
253 u8 pd
[10]; /* dword 1 */
254 u8 count
[3]; /* dword 1 */
255 u8 solevent
; /* dword 1 */
256 u8 stalled
; /* dword 1 */
257 u8 armed
; /* dword 1 */
258 u8 rsvd3
[4]; /* dword 2 */
259 u8 func
[8]; /* dword 2 */
260 u8 rsvd4
; /* dword 2 */
261 u8 delaymult
[10]; /* dword 2 */
262 u8 rsvd5
[2]; /* dword 2 */
263 u8 phase
[2]; /* dword 2 */
264 u8 nodelay
; /* dword 2 */
265 u8 rsvd6
[4]; /* dword 2 */
266 u8 rsvd7
[32]; /* dword 3 */
269 struct be_cmd_req_eq_create
{
270 struct be_cmd_req_hdr hdr
; /* dw[4] */
271 u16 num_pages
; /* sword */
272 u16 rsvd0
; /* sword */
273 u8 context
[sizeof(struct amap_eq_context
) / 8]; /* dw[4] */
274 struct phys_addr pages
[8];
277 struct be_cmd_resp_eq_create
{
278 struct be_cmd_resp_hdr resp_hdr
;
279 u16 eq_id
; /* sword */
280 u16 rsvd0
; /* sword */
286 u32 delay_multiplier
;
289 struct mgmt_chap_format
{
291 u8 intr_chap_name
[256];
293 u8 target_chap_name
[256];
294 u8 target_secret
[16];
295 u16 intr_chap_name_length
;
296 u16 intr_secret_length
;
297 u16 target_chap_name_length
;
298 u16 target_secret_length
;
301 struct mgmt_auth_method_format
{
304 struct mgmt_chap_format chap
;
307 struct be_cmd_req_logout_fw_sess
{
308 struct be_cmd_req_hdr hdr
; /* dw[4] */
309 uint32_t session_handle
;
312 struct be_cmd_resp_logout_fw_sess
{
313 struct be_cmd_resp_hdr hdr
; /* dw[4] */
314 #define BEISCSI_MGMT_SESSION_CLOSE 0x20
315 uint32_t session_status
;
318 struct mgmt_conn_login_options
{
323 u32 max_recv_datasegment_len_ini
;
324 u32 max_recv_datasegment_len_tgt
;
327 struct mgmt_auth_method_format auth_data
;
330 struct ip_addr_format
{
331 u16 size_of_structure
;
338 struct mgmt_conn_info
{
339 u32 connection_handle
;
340 u32 connection_status
;
343 u16 dest_port_redirected
;
345 u32 estimated_throughput
;
346 struct ip_addr_format src_ipaddr
;
347 struct ip_addr_format dest_ipaddr
;
348 struct ip_addr_format dest_ipaddr_redirected
;
349 struct mgmt_conn_login_options negotiated_login_options
;
352 struct mgmt_session_login_options
{
354 u8 error_recovery_level
;
356 u32 first_burst_length
;
357 u32 max_burst_length
;
359 u16 max_outstanding_r2t
;
360 u16 default_time2wait
;
361 u16 default_time2retain
;
364 struct mgmt_session_info
{
373 u8 initiator_iscsiname
[224];
374 struct mgmt_session_login_options negotiated_login_options
;
375 struct mgmt_conn_info conn_list
[1];
378 struct be_cmd_get_session_req
{
379 struct be_cmd_req_hdr hdr
;
383 struct be_cmd_get_session_resp
{
384 struct be_cmd_resp_hdr hdr
;
385 struct mgmt_session_info session_info
;
389 u16 size_of_structure
;
393 struct be_cmd_get_boot_target_req
{
394 struct be_cmd_req_hdr hdr
;
397 struct be_cmd_get_boot_target_resp
{
398 struct be_cmd_resp_hdr hdr
;
399 u32 boot_session_count
;
400 int boot_session_handle
;
403 struct be_cmd_reopen_session_req
{
404 struct be_cmd_req_hdr hdr
;
405 #define BE_REOPEN_ALL_SESSIONS 0x00
406 #define BE_REOPEN_BOOT_SESSIONS 0x01
407 #define BE_REOPEN_A_SESSION 0x02
413 struct be_cmd_reopen_session_resp
{
414 struct be_cmd_resp_hdr hdr
;
420 struct be_cmd_mac_query_req
{
421 struct be_cmd_req_hdr hdr
;
427 struct be_cmd_get_mac_resp
{
428 struct be_cmd_resp_hdr hdr
;
432 struct be_ip_addr_subnet_format
{
433 u16 size_of_structure
;
435 u8 ipv6_prefix_length
;
441 struct be_cmd_get_if_info_req
{
442 struct be_cmd_req_hdr hdr
;
447 struct be_cmd_get_if_info_resp
{
448 struct be_cmd_req_hdr hdr
;
453 struct be_ip_addr_subnet_format ip_addr
;
456 struct be_ip_addr_record
{
459 struct be_ip_addr_subnet_format ip_addr
;
463 struct be_ip_addr_record_params
{
464 u32 record_entry_count
;
465 struct be_ip_addr_record ip_record
;
468 struct be_cmd_set_ip_addr_req
{
469 struct be_cmd_req_hdr hdr
;
470 struct be_ip_addr_record_params ip_params
;
474 struct be_cmd_set_dhcp_req
{
475 struct be_cmd_req_hdr hdr
;
482 struct be_cmd_rel_dhcp_req
{
483 struct be_cmd_req_hdr hdr
;
488 struct be_cmd_set_def_gateway_req
{
489 struct be_cmd_req_hdr hdr
;
491 struct ip_addr_format ip_addr
;
494 struct be_cmd_get_def_gateway_req
{
495 struct be_cmd_req_hdr hdr
;
499 struct be_cmd_get_def_gateway_resp
{
500 struct be_cmd_req_hdr hdr
;
501 struct ip_addr_format ip_addr
;
504 #define BEISCSI_VLAN_DISABLE 0xFFFF
505 struct be_cmd_set_vlan_req
{
506 struct be_cmd_req_hdr hdr
;
510 /******************** Create CQ ***************************/
512 * Pseudo amap definition in which each bit of the actual structure is defined
513 * as a byte - used to calculate offset/shift/mask of each field
515 struct amap_cq_context
{
516 u8 cidx
[11]; /* dword 0 */
517 u8 rsvd0
; /* dword 0 */
518 u8 coalescwm
[2]; /* dword 0 */
519 u8 nodelay
; /* dword 0 */
520 u8 epidx
[11]; /* dword 0 */
521 u8 rsvd1
; /* dword 0 */
522 u8 count
[2]; /* dword 0 */
523 u8 valid
; /* dword 0 */
524 u8 solevent
; /* dword 0 */
525 u8 eventable
; /* dword 0 */
526 u8 pidx
[11]; /* dword 1 */
527 u8 rsvd2
; /* dword 1 */
528 u8 pd
[10]; /* dword 1 */
529 u8 eqid
[8]; /* dword 1 */
530 u8 stalled
; /* dword 1 */
531 u8 armed
; /* dword 1 */
532 u8 rsvd3
[4]; /* dword 2 */
533 u8 func
[8]; /* dword 2 */
534 u8 rsvd4
[20]; /* dword 2 */
535 u8 rsvd5
[32]; /* dword 3 */
538 struct amap_cq_context_v2
{
539 u8 rsvd0
[12]; /* dword 0 */
540 u8 coalescwm
[2]; /* dword 0 */
541 u8 nodelay
; /* dword 0 */
542 u8 rsvd1
[12]; /* dword 0 */
543 u8 count
[2]; /* dword 0 */
544 u8 valid
; /* dword 0 */
545 u8 rsvd2
; /* dword 0 */
546 u8 eventable
; /* dword 0 */
547 u8 eqid
[16]; /* dword 1 */
548 u8 rsvd3
[15]; /* dword 1 */
549 u8 armed
; /* dword 1 */
550 u8 cqecount
[16];/* dword 2 */
551 u8 rsvd4
[16]; /* dword 2 */
552 u8 rsvd5
[32]; /* dword 3 */
555 struct be_cmd_req_cq_create
{
556 struct be_cmd_req_hdr hdr
;
560 u8 context
[sizeof(struct amap_cq_context
) / 8];
561 struct phys_addr pages
[4];
564 struct be_cmd_resp_cq_create
{
565 struct be_cmd_resp_hdr hdr
;
570 /******************** Create MCCQ ***************************/
572 * Pseudo amap definition in which each bit of the actual structure is defined
573 * as a byte - used to calculate offset/shift/mask of each field
575 struct amap_mcc_context
{
590 struct be_cmd_req_mcc_create
{
591 struct be_cmd_req_hdr hdr
;
594 u8 context
[sizeof(struct amap_mcc_context
) / 8];
595 struct phys_addr pages
[8];
598 struct be_cmd_resp_mcc_create
{
599 struct be_cmd_resp_hdr hdr
;
604 /******************** Q Destroy ***************************/
605 /* Type of Queue to be destroyed */
615 struct be_cmd_req_q_destroy
{
616 struct be_cmd_req_hdr hdr
;
618 u16 bypass_flush
; /* valid only for rx q destroy */
625 struct be_cmd_req_mcast_mac_config
{
626 struct be_cmd_req_hdr hdr
;
630 struct macaddr mac
[32];
633 static inline void *embedded_payload(struct be_mcc_wrb
*wrb
)
635 return wrb
->payload
.embedded_payload
;
638 static inline struct be_sge
*nonembedded_sgl(struct be_mcc_wrb
*wrb
)
640 return &wrb
->payload
.sgl
[0];
643 /******************** Modify EQ Delay *******************/
644 struct be_cmd_req_modify_eq_delay
{
645 struct be_cmd_req_hdr hdr
;
650 __le32 delay_multiplier
;
654 /******************** Get MAC ADDR *******************/
658 struct be_cmd_get_nic_conf_req
{
659 struct be_cmd_req_hdr hdr
;
665 u16 size_of_structure
;
666 u8 mac_address
[ETH_ALEN
];
670 struct be_cmd_get_nic_conf_resp
{
671 struct be_cmd_resp_hdr hdr
;
677 u16 size_of_structure
;
682 #define BEISCSI_ALIAS_LEN 32
684 struct be_cmd_hba_name
{
685 struct be_cmd_req_hdr hdr
;
688 u8 initiator_name
[ISCSI_NAME_LEN
];
689 u8 initiator_alias
[BEISCSI_ALIAS_LEN
];
692 struct be_cmd_ntwk_link_status_req
{
693 struct be_cmd_req_hdr hdr
;
697 /*** Port Speed Values ***/
698 #define BE2ISCSI_LINK_SPEED_ZERO 0x00
699 #define BE2ISCSI_LINK_SPEED_10MBPS 0x01
700 #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
701 #define BE2ISCSI_LINK_SPEED_1GBPS 0x03
702 #define BE2ISCSI_LINK_SPEED_10GBPS 0x04
703 struct be_cmd_ntwk_link_status_resp
{
704 struct be_cmd_resp_hdr hdr
;
712 u32 logical_link_speed
;
715 int beiscsi_cmd_eq_create(struct be_ctrl_info
*ctrl
,
716 struct be_queue_info
*eq
, int eq_delay
);
718 int beiscsi_cmd_cq_create(struct be_ctrl_info
*ctrl
,
719 struct be_queue_info
*cq
, struct be_queue_info
*eq
,
720 bool sol_evts
, bool no_delay
,
721 int num_cqe_dma_coalesce
);
723 int beiscsi_cmd_q_destroy(struct be_ctrl_info
*ctrl
, struct be_queue_info
*q
,
725 int beiscsi_cmd_mccq_create(struct beiscsi_hba
*phba
,
726 struct be_queue_info
*mccq
,
727 struct be_queue_info
*cq
);
729 int be_poll_mcc(struct be_ctrl_info
*ctrl
);
730 int mgmt_check_supported_fw(struct be_ctrl_info
*ctrl
,
731 struct beiscsi_hba
*phba
);
732 unsigned int be_cmd_get_initname(struct beiscsi_hba
*phba
);
733 unsigned int be_cmd_get_port_speed(struct beiscsi_hba
*phba
);
735 void free_mcc_tag(struct be_ctrl_info
*ctrl
, unsigned int tag
);
737 int be_cmd_modify_eq_delay(struct beiscsi_hba
*phba
, struct be_set_eqd
*,
739 int beiscsi_mccq_compl(struct beiscsi_hba
*phba
,
740 uint32_t tag
, struct be_mcc_wrb
**wrb
,
741 struct be_dma_mem
*mbx_cmd_mem
);
742 /*ISCSI Functuions */
743 int be_cmd_fw_initialize(struct be_ctrl_info
*ctrl
);
744 int be_cmd_fw_uninit(struct be_ctrl_info
*ctrl
);
746 struct be_mcc_wrb
*wrb_from_mbox(struct be_dma_mem
*mbox_mem
);
747 struct be_mcc_wrb
*wrb_from_mccq(struct beiscsi_hba
*phba
);
748 int be_mcc_notify_wait(struct beiscsi_hba
*phba
);
749 void be_mcc_notify(struct beiscsi_hba
*phba
);
750 unsigned int alloc_mcc_tag(struct beiscsi_hba
*phba
);
751 void beiscsi_async_link_state_process(struct beiscsi_hba
*phba
,
752 struct be_async_event_link_state
*evt
);
753 int be_mcc_compl_process_isr(struct be_ctrl_info
*ctrl
,
754 struct be_mcc_compl
*compl);
756 int be_mbox_notify(struct be_ctrl_info
*ctrl
);
758 int be_cmd_create_default_pdu_queue(struct be_ctrl_info
*ctrl
,
759 struct be_queue_info
*cq
,
760 struct be_queue_info
*dq
, int length
,
761 int entry_size
, uint8_t is_header
,
764 int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info
*ctrl
,
765 struct be_dma_mem
*q_mem
);
767 int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info
*ctrl
);
769 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info
*ctrl
,
770 struct be_dma_mem
*q_mem
, u32 page_offset
,
773 int beiscsi_cmd_reset_function(struct beiscsi_hba
*phba
);
775 int be_cmd_wrbq_create(struct be_ctrl_info
*ctrl
, struct be_dma_mem
*q_mem
,
776 struct be_queue_info
*wrbq
,
777 struct hwi_wrb_context
*pwrb_context
,
780 bool is_link_state_evt(u32 trailer
);
782 /* Configuration Functions */
783 int be_cmd_set_vlan(struct beiscsi_hba
*phba
, uint16_t vlan_tag
);
785 struct be_default_pdu_context
{
789 struct amap_be_default_pdu_context
{
790 u8 dbuf_cindex
[13]; /* dword 0 */
791 u8 rsvd0
[3]; /* dword 0 */
792 u8 ring_size
[4]; /* dword 0 */
793 u8 ring_state
[4]; /* dword 0 */
794 u8 rsvd1
[8]; /* dword 0 */
795 u8 dbuf_pindex
[13]; /* dword 1 */
796 u8 rsvd2
; /* dword 1 */
797 u8 pci_func_id
[8]; /* dword 1 */
798 u8 rx_pdid
[9]; /* dword 1 */
799 u8 rx_pdid_valid
; /* dword 1 */
800 u8 default_buffer_size
[16]; /* dword 2 */
801 u8 cq_id_recv
[10]; /* dword 2 */
802 u8 rx_pdid_not_valid
; /* dword 2 */
803 u8 rsvd3
[5]; /* dword 2 */
804 u8 rsvd4
[32]; /* dword 3 */
807 struct amap_default_pdu_context_ext
{
808 u8 rsvd0
[16]; /* dword 0 */
809 u8 ring_size
[4]; /* dword 0 */
810 u8 rsvd1
[12]; /* dword 0 */
811 u8 rsvd2
[22]; /* dword 1 */
812 u8 rx_pdid
[9]; /* dword 1 */
813 u8 rx_pdid_valid
; /* dword 1 */
814 u8 default_buffer_size
[16]; /* dword 2 */
815 u8 cq_id_recv
[16]; /* dword 2 */
816 u8 rsvd3
[32]; /* dword 3 */
819 struct be_defq_create_req
{
820 struct be_cmd_req_hdr hdr
;
823 #define BEISCSI_DUAL_ULP_AWARE_BIT 0 /* Byte 3 - Bit 0 */
824 #define BEISCSI_BIND_Q_TO_ULP_BIT 1 /* Byte 3 - Bit 1 */
826 struct be_default_pdu_context context
;
827 struct phys_addr pages
[8];
830 struct be_defq_create_resp
{
831 struct be_cmd_req_hdr hdr
;
840 struct be_post_template_pages_req
{
841 struct be_cmd_req_hdr hdr
;
843 #define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
845 struct phys_addr scratch_pa
;
846 struct virt_addr scratch_va
;
847 struct virt_addr pages_va
;
848 struct phys_addr pages
[16];
851 struct be_remove_template_pages_req
{
852 struct be_cmd_req_hdr hdr
;
857 struct be_post_sgl_pages_req
{
858 struct be_cmd_req_hdr hdr
;
862 struct phys_addr pages
[26];
866 struct be_wrbq_create_req
{
867 struct be_cmd_req_hdr hdr
;
871 struct phys_addr pages
[8];
874 struct be_wrbq_create_resp
{
875 struct be_cmd_resp_hdr resp_hdr
;
884 #define SOL_CID_MASK 0x0000FFC0
885 #define SOL_CODE_MASK 0x0000003F
886 #define SOL_WRB_INDEX_MASK 0x00FF0000
887 #define SOL_CMD_WND_MASK 0xFF000000
888 #define SOL_RES_CNT_MASK 0x7FFFFFFF
889 #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
890 #define SOL_HW_STS_MASK 0x000000FF
891 #define SOL_STS_MASK 0x0000FF00
892 #define SOL_RESP_MASK 0x00FF0000
893 #define SOL_FLAGS_MASK 0x7F000000
894 #define SOL_S_MASK 0x80000000
900 struct amap_sol_cqe
{
901 u8 hw_sts
[8]; /* dword 0 */
902 u8 i_sts
[8]; /* dword 0 */
903 u8 i_resp
[8]; /* dword 0 */
904 u8 i_flags
[7]; /* dword 0 */
906 u8 i_exp_cmd_sn
[32]; /* dword 1 */
907 u8 code
[6]; /* dword 2 */
908 u8 cid
[10]; /* dword 2 */
909 u8 wrb_index
[8]; /* dword 2 */
910 u8 i_cmd_wnd
[8]; /* dword 2 */
911 u8 i_res_cnt
[31]; /* dword 3 */
912 u8 valid
; /* dword 3 */
915 #define SOL_ICD_INDEX_MASK 0x0003FFC0
916 struct amap_sol_cqe_ring
{
917 u8 hw_sts
[8]; /* dword 0 */
918 u8 i_sts
[8]; /* dword 0 */
919 u8 i_resp
[8]; /* dword 0 */
920 u8 i_flags
[7]; /* dword 0 */
922 u8 i_exp_cmd_sn
[32]; /* dword 1 */
923 u8 code
[6]; /* dword 2 */
924 u8 icd_index
[12]; /* dword 2 */
925 u8 rsvd
[6]; /* dword 2 */
926 u8 i_cmd_wnd
[8]; /* dword 2 */
927 u8 i_res_cnt
[31]; /* dword 3 */
928 u8 valid
; /* dword 3 */
931 struct amap_sol_cqe_v2
{
932 u8 hw_sts
[8]; /* dword 0 */
933 u8 i_sts
[8]; /* dword 0 */
934 u8 wrb_index
[16]; /* dword 0 */
935 u8 i_exp_cmd_sn
[32]; /* dword 1 */
936 u8 code
[6]; /* dword 2 */
937 u8 cmd_cmpl
; /* dword 2 */
938 u8 rsvd0
; /* dword 2 */
939 u8 i_cmd_wnd
[8]; /* dword 2 */
940 u8 cid
[13]; /* dword 2 */
944 u8 i_res_cnt
[31]; /* dword 3 */
945 u8 valid
; /* dword 3 */
948 struct common_sol_cqe
{
955 u8 res_flag
; /* the s feild of structure */
956 u8 i_resp
; /* for skh if cmd_complete is set then i_sts is response */
957 u8 i_flags
; /* for skh or the u and o feilds */
958 u8 i_sts
; /* for skh if cmd_complete is not-set then i_sts is status */
961 /*** iSCSI ack/driver message completions ***/
962 struct amap_it_dmsg_cqe
{
963 u8 ack_num
[32]; /* DWORD 0 */
964 u8 pdu_bytes_rcvd
[32]; /* DWORD 1 */
965 u8 code
[6]; /* DWORD 2 */
966 u8 cid
[10]; /* DWORD 2 */
967 u8 wrb_idx
[8]; /* DWORD 2 */
968 u8 rsvd0
[8]; /* DWORD 2*/
969 u8 rsvd1
[31]; /* DWORD 3*/
970 u8 valid
; /* DWORD 3 */
973 struct amap_it_dmsg_cqe_v2
{
974 u8 ack_num
[32]; /* DWORD 0 */
975 u8 pdu_bytes_rcvd
[32]; /* DWORD 1 */
976 u8 code
[6]; /* DWORD 2 */
977 u8 rsvd0
[10]; /* DWORD 2 */
978 u8 wrb_idx
[16]; /* DWORD 2 */
979 u8 rsvd1
[16]; /* DWORD 3 */
980 u8 cid
[13]; /* DWORD 3 */
981 u8 rsvd2
[2]; /* DWORD 3 */
982 u8 valid
; /* DWORD 3 */
987 * Post WRB Queue Doorbell Register used by the host Storage
988 * stack to notify the
989 * controller of a posted Work Request Block
991 #define DB_WRB_POST_CID_MASK 0xFFFF /* bits 0 - 16 */
992 #define DB_DEF_PDU_WRB_INDEX_MASK 0xFF /* bits 0 - 9 */
994 #define DB_DEF_PDU_WRB_INDEX_SHIFT 16
995 #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
997 struct fragnum_bits_for_sgl_cra_in
{
998 struct be_cmd_req_hdr hdr
;
1002 struct iscsi_cleanup_req
{
1003 struct be_cmd_req_hdr hdr
;
1013 u32 delay_multiplier
;
1016 struct be_eq_delay_params_in
{
1017 struct be_cmd_req_hdr hdr
;
1019 struct eq_delay delay
[8];
1022 struct tcp_connect_and_offload_in
{
1023 struct be_cmd_req_hdr hdr
;
1024 struct ip_addr_format ip_address
;
1029 struct phys_addr dataout_template_pa
;
1036 struct tcp_connect_and_offload_in_v1
{
1037 struct be_cmd_req_hdr hdr
;
1038 struct ip_addr_format ip_address
;
1043 struct phys_addr dataout_template_pa
;
1049 u16 tcp_window_size
;
1050 u8 tcp_window_scale_count
;
1056 struct tcp_connect_and_offload_out
{
1057 struct be_cmd_resp_hdr hdr
;
1058 u32 connection_handle
;
1064 struct be_mcc_wrb_context
{
1065 struct MCC_WRB
*wrb
;
1066 int *users_final_status
;
1069 #define DB_DEF_PDU_RING_ID_MASK 0x3FFF /* bits 0 - 13 */
1070 #define DB_DEF_PDU_CQPROC_MASK 0x3FFF /* bits 16 - 29 */
1071 #define DB_DEF_PDU_REARM_SHIFT 14
1072 #define DB_DEF_PDU_EVENT_SHIFT 15
1073 #define DB_DEF_PDU_CQPROC_SHIFT 16
1079 struct tcp_upload_params_in
{
1080 struct be_cmd_req_hdr hdr
;
1086 struct tcp_upload_params_out
{
1090 union tcp_upload_params
{
1091 struct tcp_upload_params_in request
;
1092 struct tcp_upload_params_out response
;
1095 struct be_ulp_fw_cfg
{
1096 #define BEISCSI_ULP_ISCSI_INI_MODE 0x10
1112 struct be_ulp_chain_icd
{
1118 struct be_cmd_req_hdr hdr
;
1119 u32 be_config_number
;
1122 #define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1123 #define BEISCSI_FUNC_DUA_MODE 0x800
1125 struct be_ulp_fw_cfg ulp
[2];
1131 struct be_ulp_chain_icd chain_icd
[2];
1134 struct be_cmd_get_all_if_id_req
{
1135 struct be_cmd_req_hdr hdr
;
1137 u32 if_hndl_list
[1];
1140 #define ISCSI_OPCODE_SCSI_DATA_OUT 5
1141 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1142 #define OPCODE_COMMON_MODIFY_EQ_DELAY 41
1143 #define OPCODE_COMMON_ISCSI_CLEANUP 59
1144 #define OPCODE_COMMON_TCP_UPLOAD 56
1145 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1146 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1147 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME 6
1148 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME 7
1149 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION 14
1150 #define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET 24
1151 #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1152 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1153 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1154 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET 52
1155 #define OPCODE_COMMON_WRITE_FLASH 96
1156 #define OPCODE_COMMON_READ_FLASH 97
1158 /* --- CMD_ISCSI_INVALIDATE_CONNECTION_TYPE --- */
1159 #define CMD_ISCSI_COMMAND_INVALIDATE 1
1160 #define CMD_ISCSI_CONNECTION_INVALIDATE 0x8001
1161 #define CMD_ISCSI_CONNECTION_ISSUE_TCP_RST 0x8002
1163 #define INI_WR_CMD 1 /* Initiator write command */
1164 #define INI_TMF_CMD 2 /* Initiator TMF command */
1165 #define INI_NOPOUT_CMD 3 /* Initiator; Send a NOP-OUT */
1166 #define INI_RD_CMD 5 /* Initiator requesting to send
1169 #define TGT_CTX_UPDT_CMD 7 /* Target context update */
1170 #define TGT_STS_CMD 8 /* Target R2T and other BHS
1171 * where only the status number
1172 * need to be updated
1174 #define TGT_DATAIN_CMD 9 /* Target Data-Ins in response
1177 #define TGT_SOS_PDU 10 /* Target:standalone status
1180 #define TGT_DM_CMD 11 /* Indicates that the bhs
1182 * driver should not be touched
1184 /* --- CMD_CHUTE_TYPE --- */
1185 #define CMD_CONNECTION_CHUTE_0 1
1186 #define CMD_CONNECTION_CHUTE_1 2
1187 #define CMD_CONNECTION_CHUTE_2 3
1189 #define EQ_MAJOR_CODE_COMPLETION 0
1191 #define CMD_ISCSI_SESSION_DEL_CFG_FROM_FLASH 0
1192 #define CMD_ISCSI_SESSION_SAVE_CFG_ON_FLASH 1
1194 /* --- CONNECTION_UPLOAD_PARAMS --- */
1195 /* These parameters are used to define the type of upload desired. */
1196 #define CONNECTION_UPLOAD_GRACEFUL 1 /* Graceful upload */
1197 #define CONNECTION_UPLOAD_ABORT_RESET 2 /* Abortive upload with
1200 #define CONNECTION_UPLOAD_ABORT 3 /* Abortive upload without
1203 #define CONNECTION_UPLOAD_ABORT_WITH_SEQ 4 /* Abortive upload with reset,
1204 * sequence number by driver */
1206 /* Returns the number of items in the field array. */
1207 #define BE_NUMBER_OF_FIELD(_type_, _field_) \
1208 (FIELD_SIZEOF(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1211 * Different types of iSCSI completions to host driver for both initiator
1215 #define SOL_CMD_COMPLETE 1 /* Solicited command completed
1218 #define SOL_CMD_KILLED_DATA_DIGEST_ERR 2 /* Solicited command got
1219 * invalidated internally due
1220 * to Data Digest error
1222 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3 /* Connection got invalidated
1224 * due to a received PDU
1227 #define CXN_KILLED_BURST_LEN_MISMATCH 4 /* Connection got invalidated
1228 * internally due ti received
1229 * PDU sequence size >
1232 #define CXN_KILLED_AHS_RCVD 5 /* Connection got invalidated
1233 * internally due to a received
1236 #define CXN_KILLED_HDR_DIGEST_ERR 6 /* Connection got invalidated
1237 * internally due to Hdr Digest
1240 #define CXN_KILLED_UNKNOWN_HDR 7 /* Connection got invalidated
1242 * due to a bad opcode in the
1245 #define CXN_KILLED_STALE_ITT_TTT_RCVD 8 /* Connection got invalidated
1246 * internally due to a received
1247 * ITT/TTT that does not belong
1248 * to this Connection
1250 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9 /* Connection got invalidated
1251 * internally due to received
1252 * ITT/TTT value > Max
1253 * Supported ITTs/TTTs
1255 #define CXN_KILLED_RST_RCVD 10 /* Connection got invalidated
1256 * internally due to an
1259 #define CXN_KILLED_TIMED_OUT 11 /* Connection got invalidated
1260 * internally due to timeout on
1261 * tcp segment 12 retransmit
1264 #define CXN_KILLED_RST_SENT 12 /* Connection got invalidated
1265 * internally due to TCP RST
1266 * sent by the Tx side
1268 #define CXN_KILLED_FIN_RCVD 13 /* Connection got invalidated
1269 * internally due to an
1272 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD 14 /* Connection got invalidated
1273 * internally due to bad
1274 * unsolicited PDU Unsolicited
1275 * PDUs are PDUs with
1278 #define CXN_KILLED_BAD_WRB_INDEX_ERROR 15 /* Connection got invalidated
1279 * internally due to bad WRB
1282 #define CXN_KILLED_OVER_RUN_RESIDUAL 16 /* Command got invalidated
1283 * internally due to received
1284 * command has residual
1287 #define CXN_KILLED_UNDER_RUN_RESIDUAL 17 /* Command got invalidated
1288 * internally due to received
1289 * command has residual under
1292 #define CMD_KILLED_INVALID_STATSN_RCVD 18 /* Command got invalidated
1293 * internally due to a received
1294 * PDU has an invalid StatusSN
1296 #define CMD_KILLED_INVALID_R2T_RCVD 19 /* Command got invalidated
1297 * internally due to a received
1298 * an R2T with some invalid
1301 #define CMD_CXN_KILLED_LUN_INVALID 20 /* Command got invalidated
1302 * internally due to received
1303 * PDU has an invalid LUN.
1305 #define CMD_CXN_KILLED_ICD_INVALID 21 /* Command got invalidated
1306 * internally due to the
1307 * corresponding ICD not in a
1310 #define CMD_CXN_KILLED_ITT_INVALID 22 /* Command got invalidated due
1311 * to received PDU has an
1314 #define CMD_CXN_KILLED_SEQ_OUTOFORDER 23 /* Command got invalidated due
1315 * to received sequence buffer
1316 * offset is out of order.
1318 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24 /* Command got invalidated
1319 * internally due to a
1320 * received PDU has an invalid
1323 #define CXN_INVALIDATE_NOTIFY 25 /* Connection invalidation
1324 * completion notify.
1326 #define CXN_INVALIDATE_INDEX_NOTIFY 26 /* Connection invalidation
1328 * with data PDU index.
1330 #define CMD_INVALIDATED_NOTIFY 27 /* Command invalidation
1331 * completionnotifify.
1333 #define UNSOL_HDR_NOTIFY 28 /* Unsolicited header notify.*/
1334 #define UNSOL_DATA_NOTIFY 29 /* Unsolicited data notify.*/
1335 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY 30 /* Unsolicited data digest
1338 #define DRIVERMSG_NOTIFY 31 /* TCP acknowledge based
1341 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1342 * internally due to command
1343 * and data are not on same
1346 #define SOL_CMD_KILLED_DIF_ERR 33 /* Solicited command got
1347 * invalidated internally due
1350 #define CXN_KILLED_SYN_RCVD 34 /* Connection got invalidated
1351 * internally due to incoming
1354 #define CXN_KILLED_IMM_DATA_RCVD 35 /* Connection got invalidated
1355 * internally due to an
1356 * incoming Unsolicited PDU
1357 * that has immediate data on
1361 int beiscsi_pci_soft_reset(struct beiscsi_hba
*phba
);
1362 int be_chk_reset_complete(struct beiscsi_hba
*phba
);
1364 void be_wrb_hdr_prepare(struct be_mcc_wrb
*wrb
, int payload_len
,
1365 bool embedded
, u8 sge_cnt
);
1367 void be_cmd_hdr_prepare(struct be_cmd_req_hdr
*req_hdr
,
1368 u8 subsystem
, u8 opcode
, int cmd_len
);
1370 void be2iscsi_fail_session(struct iscsi_cls_session
*cls_session
);
1371 #endif /* !BEISCSI_CMDS_H */