Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2017 Broadcom. All Rights Reserved.
0004  * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
0005  *
0006  * Contact Information:
0007  * linux-drivers@broadcom.com
0008  */
0009 
0010 #ifndef BEISCSI_CMDS_H
0011 #define BEISCSI_CMDS_H
0012 
0013 /**
0014  * The driver sends configuration and managements command requests to the
0015  * firmware in the BE. These requests are communicated to the processor
0016  * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
0017  * WRB inside a MAILBOX.
0018  * The commands are serviced by the ARM processor in the OneConnect's MPU.
0019  */
0020 struct be_sge {
0021     __le32 pa_lo;
0022     __le32 pa_hi;
0023     __le32 len;
0024 };
0025 
0026 struct be_mcc_wrb {
0027     u32 emb_sgecnt_special; /* dword 0 */
0028     /* bits 0 - embedded    */
0029     /* bits 1 - 2 reserved  */
0030     /* bits 3 - 7 sge count */
0031     /* bits 8 - 23 reserved */
0032     /* bits 24 - 31 special */
0033 #define MCC_WRB_EMBEDDED_MASK 1
0034 #define MCC_WRB_SGE_CNT_SHIFT 3
0035 #define MCC_WRB_SGE_CNT_MASK 0x1F
0036     u32 payload_length; /* dword 1 */
0037     u32 tag0;       /* dword 2 */
0038     u32 tag1;       /* dword 3 */
0039     u32 rsvd;       /* dword 4 */
0040     union {
0041 #define EMBED_MBX_MAX_PAYLOAD_SIZE  220
0042         u8 embedded_payload[236];   /* used by embedded cmds */
0043         struct be_sge sgl[19];  /* used by non-embedded cmds */
0044     } payload;
0045 };
0046 
0047 #define CQE_FLAGS_VALID_MASK (1 << 31)
0048 #define CQE_FLAGS_ASYNC_MASK (1 << 30)
0049 #define CQE_FLAGS_COMPLETED_MASK    (1 << 28)
0050 #define CQE_FLAGS_CONSUMED_MASK     (1 << 27)
0051 
0052 /* Completion Status */
0053 #define MCC_STATUS_SUCCESS 0x0
0054 #define MCC_STATUS_FAILED 0x1
0055 #define MCC_STATUS_ILLEGAL_REQUEST 0x2
0056 #define MCC_STATUS_ILLEGAL_FIELD 0x3
0057 #define MCC_STATUS_INSUFFICIENT_BUFFER 0x4
0058 #define MCC_STATUS_INVALID_LENGTH 0x74
0059 
0060 #define CQE_STATUS_COMPL_MASK   0xFFFF
0061 #define CQE_STATUS_COMPL_SHIFT  0       /* bits 0 - 15 */
0062 #define CQE_STATUS_EXTD_MASK    0xFFFF
0063 #define CQE_STATUS_EXTD_SHIFT   16      /* bits 31 - 16 */
0064 #define CQE_STATUS_ADDL_MASK    0xFF00
0065 #define CQE_STATUS_ADDL_SHIFT   8
0066 #define CQE_STATUS_MASK     0xFF
0067 #define CQE_STATUS_WRB_MASK 0xFF0000
0068 #define CQE_STATUS_WRB_SHIFT    16
0069 
0070 #define BEISCSI_HOST_MBX_TIMEOUT (110 * 1000)
0071 #define BEISCSI_FW_MBX_TIMEOUT  100
0072 
0073 /* MBOX Command VER */
0074 #define MBX_CMD_VER1    0x01
0075 #define MBX_CMD_VER2    0x02
0076 
0077 struct be_mcc_compl {
0078     u32 status;     /* dword 0 */
0079     u32 tag0;       /* dword 1 */
0080     u32 tag1;       /* dword 2 */
0081     u32 flags;      /* dword 3 */
0082 };
0083 
0084 /********* Mailbox door bell *************/
0085 /**
0086  * Used for driver communication with the FW.
0087  * The software must write this register twice to post any command. First,
0088  * it writes the register with hi=1 and the upper bits of the physical address
0089  * for the MAILBOX structure. Software must poll the ready bit until this
0090  * is acknowledged. Then, sotware writes the register with hi=0 with the lower
0091  * bits in the address. It must poll the ready bit until the command is
0092  * complete. Upon completion, the MAILBOX will contain a valid completion
0093  * queue entry.
0094  */
0095 #define MPU_MAILBOX_DB_OFFSET   0x160
0096 #define MPU_MAILBOX_DB_RDY_MASK 0x1 /* bit 0 */
0097 #define MPU_MAILBOX_DB_HI_MASK  0x2 /* bit 1 */
0098 
0099 /********** MPU semphore: used for SH & BE ******************/
0100 #define SLIPORT_SOFTRESET_OFFSET        0x5c    /* CSR BAR offset */
0101 #define SLIPORT_SEMAPHORE_OFFSET_BEx        0xac    /* CSR BAR offset */
0102 #define SLIPORT_SEMAPHORE_OFFSET_SH     0x94    /* PCI-CFG offset */
0103 #define POST_STAGE_MASK             0x0000FFFF
0104 #define POST_ERROR_BIT              0x80000000
0105 #define POST_ERR_RECOVERY_CODE_MASK     0xF000
0106 
0107 /* Soft Reset register masks */
0108 #define SLIPORT_SOFTRESET_SR_MASK       0x00000080  /* SR bit */
0109 
0110 /* MPU semphore POST stage values */
0111 #define POST_STAGE_AWAITING_HOST_RDY    0x1 /* FW awaiting goahead from host */
0112 #define POST_STAGE_HOST_RDY     0x2 /* Host has given go-ahed to FW */
0113 #define POST_STAGE_BE_RESET     0x3 /* Host wants to reset chip */
0114 #define POST_STAGE_ARMFW_RDY        0xC000 /* FW is done with POST */
0115 #define POST_STAGE_RECOVERABLE_ERR  0xE000 /* Recoverable err detected */
0116 
0117 /********** MCC door bell ************/
0118 #define DB_MCCQ_OFFSET 0x140
0119 #define DB_MCCQ_RING_ID_MASK 0xFFFF     /* bits 0 - 15 */
0120 /* Number of entries posted */
0121 #define DB_MCCQ_NUM_POSTED_SHIFT 16     /* bits 16 - 29 */
0122 
0123 /**
0124  * When the async bit of mcc_compl is set, the last 4 bytes of
0125  * mcc_compl is interpreted as follows:
0126  */
0127 #define ASYNC_TRAILER_EVENT_CODE_SHIFT  8   /* bits 8 - 15 */
0128 #define ASYNC_TRAILER_EVENT_CODE_MASK   0xFF
0129 #define ASYNC_EVENT_CODE_LINK_STATE 0x1
0130 #define ASYNC_EVENT_CODE_ISCSI      0x4
0131 #define ASYNC_EVENT_CODE_SLI        0x11
0132 
0133 #define ASYNC_TRAILER_EVENT_TYPE_SHIFT  16  /* bits 16 - 23 */
0134 #define ASYNC_TRAILER_EVENT_TYPE_MASK   0xFF
0135 
0136 /* iSCSI events */
0137 #define ASYNC_EVENT_NEW_ISCSI_TGT_DISC  0x4
0138 #define ASYNC_EVENT_NEW_ISCSI_CONN  0x5
0139 #define ASYNC_EVENT_NEW_TCP_CONN    0x7
0140 
0141 /* SLI events */
0142 #define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED  0x9
0143 #define ASYNC_SLI_LINK_EFFECT_VALID(le)     (le & 0x80)
0144 #define ASYNC_SLI_LINK_EFFECT_SEV(le)       ((le >> 1)  & 0x03)
0145 #define ASYNC_SLI_LINK_EFFECT_STATE(le)     (le & 0x01)
0146 
0147 struct be_async_event_trailer {
0148     u32 code;
0149 };
0150 
0151 enum {
0152     ASYNC_EVENT_LINK_DOWN = 0x0,
0153     ASYNC_EVENT_LINK_UP = 0x1,
0154 };
0155 
0156 /**
0157  * When the event code of an async trailer is link-state, the mcc_compl
0158  * must be interpreted as follows
0159  */
0160 struct be_async_event_link_state {
0161     u8 physical_port;
0162     u8 port_link_status;
0163 /**
0164  * ASYNC_EVENT_LINK_DOWN        0x0
0165  * ASYNC_EVENT_LINK_UP          0x1
0166  * ASYNC_EVENT_LINK_LOGICAL_DOWN    0x2
0167  * ASYNC_EVENT_LINK_LOGICAL_UP      0x3
0168  */
0169 #define BE_ASYNC_LINK_UP_MASK       0x01
0170     u8 port_duplex;
0171     u8 port_speed;
0172 /* BE2ISCSI_LINK_SPEED_ZERO 0x00 - no link */
0173 #define BE2ISCSI_LINK_SPEED_10MBPS  0x01
0174 #define BE2ISCSI_LINK_SPEED_100MBPS 0x02
0175 #define BE2ISCSI_LINK_SPEED_1GBPS   0x03
0176 #define BE2ISCSI_LINK_SPEED_10GBPS  0x04
0177 #define BE2ISCSI_LINK_SPEED_25GBPS  0x06
0178 #define BE2ISCSI_LINK_SPEED_40GBPS  0x07
0179     u8 port_fault;
0180     u8 event_reason;
0181     u16 qos_link_speed;
0182     u32 event_tag;
0183     struct be_async_event_trailer trailer;
0184 } __packed;
0185 
0186 /**
0187  * When async-trailer is SLI event, mcc_compl is interpreted as
0188  */
0189 struct be_async_event_sli {
0190     u32 event_data1;
0191     u32 event_data2;
0192     u32 reserved;
0193     u32 trailer;
0194 } __packed;
0195 
0196 struct be_mcc_mailbox {
0197     struct be_mcc_wrb wrb;
0198     struct be_mcc_compl compl;
0199 };
0200 
0201 /* Type of subsystems supported by FW */
0202 #define CMD_SUBSYSTEM_COMMON    0x1
0203 #define CMD_SUBSYSTEM_ISCSI     0x2
0204 #define CMD_SUBSYSTEM_ETH       0x3
0205 #define CMD_SUBSYSTEM_ISCSI_INI 0x6
0206 #define CMD_COMMON_TCP_UPLOAD   0x1
0207 
0208 /**
0209  * List of common opcodes subsystem  CMD_SUBSYSTEM_COMMON
0210  * These opcodes are unique for each subsystem defined above
0211  */
0212 #define OPCODE_COMMON_CQ_CREATE             12
0213 #define OPCODE_COMMON_EQ_CREATE             13
0214 #define OPCODE_COMMON_MCC_CREATE            21
0215 #define OPCODE_COMMON_MCC_CREATE_EXT            90
0216 #define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS   24
0217 #define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS    25
0218 #define OPCODE_COMMON_GET_CNTL_ATTRIBUTES       32
0219 #define OPCODE_COMMON_GET_FW_VERSION            35
0220 #define OPCODE_COMMON_MODIFY_EQ_DELAY           41
0221 #define OPCODE_COMMON_FIRMWARE_CONFIG           42
0222 #define OPCODE_COMMON_MCC_DESTROY           53
0223 #define OPCODE_COMMON_CQ_DESTROY            54
0224 #define OPCODE_COMMON_EQ_DESTROY            55
0225 #define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG     58
0226 #define OPCODE_COMMON_FUNCTION_RESET            61
0227 #define OPCODE_COMMON_GET_PORT_NAME         77
0228 #define OPCODE_COMMON_SET_HOST_DATA         93
0229 #define OPCODE_COMMON_SET_FEATURES          191
0230 
0231 /**
0232  * LIST of opcodes that are common between Initiator and Target
0233  * used by CMD_SUBSYSTEM_ISCSI
0234  * These opcodes are unique for each subsystem defined above
0235  */
0236 #define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES      2
0237 #define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES        3
0238 #define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG     7
0239 #define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN       14
0240 #define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR   17
0241 #define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR  18
0242 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR     21
0243 #define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY    22
0244 #define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY 23
0245 #define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID      24
0246 #define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO        25
0247 #define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA 61
0248 #define OPCODE_COMMON_ISCSI_DEFQ_CREATE                 64
0249 #define OPCODE_COMMON_ISCSI_DEFQ_DESTROY        65
0250 #define OPCODE_COMMON_ISCSI_WRBQ_CREATE         66
0251 #define OPCODE_COMMON_ISCSI_WRBQ_DESTROY        67
0252 
0253 struct be_cmd_req_hdr {
0254     u8 opcode;      /* dword 0 */
0255     u8 subsystem;       /* dword 0 */
0256     u8 port_number;     /* dword 0 */
0257     u8 domain;      /* dword 0 */
0258     u32 timeout;        /* dword 1 */
0259     u32 request_length; /* dword 2 */
0260     u8 version;     /* dword 3 */
0261     u8 rsvd0[3];        /* dword 3 */
0262 };
0263 
0264 struct be_cmd_resp_hdr {
0265     u32 info;       /* dword 0 */
0266     u32 status;     /* dword 1 */
0267     u32 response_length;    /* dword 2 */
0268     u32 actual_resp_len;    /* dword 3 */
0269 };
0270 
0271 struct phys_addr {
0272     u32 lo;
0273     u32 hi;
0274 };
0275 
0276 struct virt_addr {
0277     u32 lo;
0278     u32 hi;
0279 };
0280 /**************************
0281  * BE Command definitions *
0282  **************************/
0283 
0284 /**
0285  * Pseudo amap definition in which each bit of the actual structure is defined
0286  * as a byte - used to calculate offset/shift/mask of each field
0287  */
0288 struct amap_eq_context {
0289     u8 cidx[13];        /* dword 0 */
0290     u8 rsvd0[3];        /* dword 0 */
0291     u8 epidx[13];       /* dword 0 */
0292     u8 valid;       /* dword 0 */
0293     u8 rsvd1;       /* dword 0 */
0294     u8 size;        /* dword 0 */
0295     u8 pidx[13];        /* dword 1 */
0296     u8 rsvd2[3];        /* dword 1 */
0297     u8 pd[10];      /* dword 1 */
0298     u8 count[3];        /* dword 1 */
0299     u8 solevent;        /* dword 1 */
0300     u8 stalled;     /* dword 1 */
0301     u8 armed;       /* dword 1 */
0302     u8 rsvd3[4];        /* dword 2 */
0303     u8 func[8];     /* dword 2 */
0304     u8 rsvd4;       /* dword 2 */
0305     u8 delaymult[10];   /* dword 2 */
0306     u8 rsvd5[2];        /* dword 2 */
0307     u8 phase[2];        /* dword 2 */
0308     u8 nodelay;     /* dword 2 */
0309     u8 rsvd6[4];        /* dword 2 */
0310     u8 rsvd7[32];       /* dword 3 */
0311 } __packed;
0312 
0313 struct be_cmd_req_eq_create {
0314     struct be_cmd_req_hdr hdr;  /* dw[4] */
0315     u16 num_pages;      /* sword */
0316     u16 rsvd0;      /* sword */
0317     u8 context[sizeof(struct amap_eq_context) / 8]; /* dw[4] */
0318     struct phys_addr pages[8];
0319 } __packed;
0320 
0321 struct be_cmd_resp_eq_create {
0322     struct be_cmd_resp_hdr resp_hdr;
0323     u16 eq_id;      /* sword */
0324     u16 rsvd0;      /* sword */
0325 } __packed;
0326 
0327 struct be_set_eqd {
0328     u32 eq_id;
0329     u32 phase;
0330     u32 delay_multiplier;
0331 } __packed;
0332 
0333 struct mgmt_chap_format {
0334     u32 flags;
0335     u8  intr_chap_name[256];
0336     u8  intr_secret[16];
0337     u8  target_chap_name[256];
0338     u8  target_secret[16];
0339     u16 intr_chap_name_length;
0340     u16 intr_secret_length;
0341     u16 target_chap_name_length;
0342     u16 target_secret_length;
0343 } __packed;
0344 
0345 struct mgmt_auth_method_format {
0346     u8  auth_method_type;
0347     u8  padding[3];
0348     struct  mgmt_chap_format chap;
0349 } __packed;
0350 
0351 struct be_cmd_req_logout_fw_sess {
0352     struct be_cmd_req_hdr hdr;  /* dw[4] */
0353     uint32_t session_handle;
0354 } __packed;
0355 
0356 struct be_cmd_resp_logout_fw_sess {
0357     struct be_cmd_resp_hdr hdr; /* dw[4] */
0358     uint32_t session_status;
0359 #define BE_SESS_STATUS_CLOSE        0x20
0360 } __packed;
0361 
0362 struct mgmt_conn_login_options {
0363     u8 flags;
0364     u8 header_digest;
0365     u8 data_digest;
0366     u8 rsvd0;
0367     u32 max_recv_datasegment_len_ini;
0368     u32 max_recv_datasegment_len_tgt;
0369     u32 tcp_mss;
0370     u32 tcp_window_size;
0371     struct  mgmt_auth_method_format auth_data;
0372 } __packed;
0373 
0374 struct ip_addr_format {
0375     u16 size_of_structure;
0376     u8 reserved;
0377     u8 ip_type;
0378 #define BEISCSI_IP_TYPE_V4      0x1
0379 #define BEISCSI_IP_TYPE_STATIC_V4   0x3
0380 #define BEISCSI_IP_TYPE_DHCP_V4     0x5
0381 /* type v4 values < type v6 values */
0382 #define BEISCSI_IP_TYPE_V6      0x10
0383 #define BEISCSI_IP_TYPE_ROUTABLE_V6 0x30
0384 #define BEISCSI_IP_TYPE_LINK_LOCAL_V6   0x50
0385 #define BEISCSI_IP_TYPE_AUTO_V6     0x90
0386     u8 addr[16];
0387     u32 rsvd0;
0388 } __packed;
0389 
0390 struct mgmt_conn_info {
0391     u32 connection_handle;
0392     u32 connection_status;
0393     u16 src_port;
0394     u16 dest_port;
0395     u16 dest_port_redirected;
0396     u16 cid;
0397     u32 estimated_throughput;
0398     struct  ip_addr_format  src_ipaddr;
0399     struct  ip_addr_format  dest_ipaddr;
0400     struct  ip_addr_format  dest_ipaddr_redirected;
0401     struct  mgmt_conn_login_options negotiated_login_options;
0402 } __packed;
0403 
0404 struct mgmt_session_login_options {
0405     u8  flags;
0406     u8  error_recovery_level;
0407     u16 rsvd0;
0408     u32 first_burst_length;
0409     u32 max_burst_length;
0410     u16 max_connections;
0411     u16 max_outstanding_r2t;
0412     u16 default_time2wait;
0413     u16 default_time2retain;
0414 } __packed;
0415 
0416 struct mgmt_session_info {
0417     u32 session_handle;
0418     u32 status;
0419     u8  isid[6];
0420     u16 tsih;
0421     u32 session_flags;
0422     u16 conn_count;
0423     u16 pad;
0424     u8  target_name[224];
0425     u8  initiator_iscsiname[224];
0426     struct  mgmt_session_login_options negotiated_login_options;
0427     struct  mgmt_conn_info  conn_list[1];
0428 } __packed;
0429 
0430 struct be_cmd_get_session_req {
0431     struct be_cmd_req_hdr hdr;
0432     u32 session_handle;
0433 } __packed;
0434 
0435 struct be_cmd_get_session_resp {
0436     struct be_cmd_resp_hdr hdr;
0437     struct mgmt_session_info session_info;
0438 } __packed;
0439 
0440 struct mac_addr {
0441     u16 size_of_structure;
0442     u8 addr[ETH_ALEN];
0443 } __packed;
0444 
0445 struct be_cmd_get_boot_target_req {
0446     struct be_cmd_req_hdr hdr;
0447 } __packed;
0448 
0449 struct be_cmd_get_boot_target_resp {
0450     struct be_cmd_resp_hdr hdr;
0451     u32 boot_session_count;
0452     u32 boot_session_handle;
0453 /**
0454  * FW returns 0xffffffff if it couldn't establish connection with
0455  * configured boot target.
0456  */
0457 #define BE_BOOT_INVALID_SHANDLE 0xffffffff
0458 };
0459 
0460 struct be_cmd_reopen_session_req {
0461     struct be_cmd_req_hdr hdr;
0462 #define BE_REOPEN_ALL_SESSIONS  0x00
0463 #define BE_REOPEN_BOOT_SESSIONS 0x01
0464 #define BE_REOPEN_A_SESSION     0x02
0465     u16 reopen_type;
0466     u16 rsvd;
0467     u32 session_handle;
0468 } __packed;
0469 
0470 struct be_cmd_reopen_session_resp {
0471     struct be_cmd_resp_hdr hdr;
0472     u32 rsvd;
0473     u32 session_handle;
0474 } __packed;
0475 
0476 
0477 struct be_cmd_mac_query_req {
0478     struct be_cmd_req_hdr hdr;
0479     u8 type;
0480     u8 permanent;
0481     u16 if_id;
0482 } __packed;
0483 
0484 struct be_cmd_get_mac_resp {
0485     struct be_cmd_resp_hdr hdr;
0486     struct mac_addr mac;
0487 };
0488 
0489 struct be_ip_addr_subnet_format {
0490     u16 size_of_structure;
0491     u8 ip_type;
0492     u8 ipv6_prefix_length;
0493     u8 addr[16];
0494     u8 subnet_mask[16];
0495     u32 rsvd0;
0496 } __packed;
0497 
0498 struct be_cmd_get_if_info_req {
0499     struct be_cmd_req_hdr hdr;
0500     u32 interface_hndl;
0501     u32 ip_type;
0502 } __packed;
0503 
0504 struct be_cmd_get_if_info_resp {
0505     struct be_cmd_req_hdr hdr;
0506     u32 interface_hndl;
0507     u32 vlan_priority;
0508     u32 ip_addr_count;
0509     u32 dhcp_state;
0510     struct be_ip_addr_subnet_format ip_addr;
0511 } __packed;
0512 
0513 struct be_ip_addr_record {
0514     u32 action;
0515     u32 interface_hndl;
0516     struct be_ip_addr_subnet_format ip_addr;
0517     u32 status;
0518 } __packed;
0519 
0520 struct be_ip_addr_record_params {
0521     u32 record_entry_count;
0522     struct be_ip_addr_record ip_record;
0523 } __packed;
0524 
0525 struct be_cmd_set_ip_addr_req {
0526     struct be_cmd_req_hdr hdr;
0527     struct be_ip_addr_record_params ip_params;
0528 } __packed;
0529 
0530 
0531 struct be_cmd_set_dhcp_req {
0532     struct be_cmd_req_hdr hdr;
0533     u32 interface_hndl;
0534     u32 ip_type;
0535     u32 flags;
0536     u32 retry_count;
0537 } __packed;
0538 
0539 struct be_cmd_rel_dhcp_req {
0540     struct be_cmd_req_hdr hdr;
0541     u32 interface_hndl;
0542     u32 ip_type;
0543 } __packed;
0544 
0545 struct be_cmd_set_def_gateway_req {
0546     struct be_cmd_req_hdr hdr;
0547     u32 action;
0548     struct ip_addr_format ip_addr;
0549 } __packed;
0550 
0551 struct be_cmd_get_def_gateway_req {
0552     struct be_cmd_req_hdr hdr;
0553     u32 ip_type;
0554 } __packed;
0555 
0556 struct be_cmd_get_def_gateway_resp {
0557     struct be_cmd_req_hdr hdr;
0558     struct ip_addr_format ip_addr;
0559 } __packed;
0560 
0561 #define BEISCSI_VLAN_DISABLE    0xFFFF
0562 struct be_cmd_set_vlan_req {
0563     struct be_cmd_req_hdr hdr;
0564     u32 interface_hndl;
0565     u32 vlan_priority;
0566 } __packed;
0567 /******************** Create CQ ***************************/
0568 /**
0569  * Pseudo amap definition in which each bit of the actual structure is defined
0570  * as a byte - used to calculate offset/shift/mask of each field
0571  */
0572 struct amap_cq_context {
0573     u8 cidx[11];        /* dword 0 */
0574     u8 rsvd0;       /* dword 0 */
0575     u8 coalescwm[2];    /* dword 0 */
0576     u8 nodelay;     /* dword 0 */
0577     u8 epidx[11];       /* dword 0 */
0578     u8 rsvd1;       /* dword 0 */
0579     u8 count[2];        /* dword 0 */
0580     u8 valid;       /* dword 0 */
0581     u8 solevent;        /* dword 0 */
0582     u8 eventable;       /* dword 0 */
0583     u8 pidx[11];        /* dword 1 */
0584     u8 rsvd2;       /* dword 1 */
0585     u8 pd[10];      /* dword 1 */
0586     u8 eqid[8];     /* dword 1 */
0587     u8 stalled;     /* dword 1 */
0588     u8 armed;       /* dword 1 */
0589     u8 rsvd3[4];        /* dword 2 */
0590     u8 func[8];     /* dword 2 */
0591     u8 rsvd4[20];       /* dword 2 */
0592     u8 rsvd5[32];       /* dword 3 */
0593 } __packed;
0594 
0595 struct amap_cq_context_v2 {
0596     u8 rsvd0[12];   /* dword 0 */
0597     u8 coalescwm[2];    /* dword 0 */
0598     u8 nodelay;     /* dword 0 */
0599     u8 rsvd1[12];   /* dword 0 */
0600     u8 count[2];    /* dword 0 */
0601     u8 valid;       /* dword 0 */
0602     u8 rsvd2;       /* dword 0 */
0603     u8 eventable;   /* dword 0 */
0604     u8 eqid[16];    /* dword 1 */
0605     u8 rsvd3[15];   /* dword 1 */
0606     u8 armed;       /* dword 1 */
0607     u8 cqecount[16];/* dword 2 */
0608     u8 rsvd4[16];   /* dword 2 */
0609     u8 rsvd5[32];   /* dword 3 */
0610 };
0611 
0612 struct be_cmd_req_cq_create {
0613     struct be_cmd_req_hdr hdr;
0614     u16 num_pages;
0615     u8 page_size;
0616     u8 rsvd0;
0617     u8 context[sizeof(struct amap_cq_context) / 8];
0618     struct phys_addr pages[4];
0619 } __packed;
0620 
0621 struct be_cmd_resp_cq_create {
0622     struct be_cmd_resp_hdr hdr;
0623     u16 cq_id;
0624     u16 rsvd0;
0625 } __packed;
0626 
0627 /******************** Create MCCQ ***************************/
0628 /**
0629  * Pseudo amap definition in which each bit of the actual structure is defined
0630  * as a byte - used to calculate offset/shift/mask of each field
0631  */
0632 struct amap_mcc_context {
0633     u8 con_index[14];
0634     u8 rsvd0[2];
0635     u8 ring_size[4];
0636     u8 fetch_wrb;
0637     u8 fetch_r2t;
0638     u8 cq_id[10];
0639     u8 prod_index[14];
0640     u8 fid[8];
0641     u8 pdid[9];
0642     u8 valid;
0643     u8 rsvd1[32];
0644     u8 rsvd2[32];
0645 } __packed;
0646 
0647 struct be_cmd_req_mcc_create_ext {
0648     struct be_cmd_req_hdr hdr;
0649     u16 num_pages;
0650     u16 rsvd0;
0651     u32 async_evt_bitmap;
0652     u8 context[sizeof(struct amap_mcc_context) / 8];
0653     struct phys_addr pages[8];
0654 } __packed;
0655 
0656 struct be_cmd_resp_mcc_create {
0657     struct be_cmd_resp_hdr hdr;
0658     u16 id;
0659     u16 rsvd0;
0660 } __packed;
0661 
0662 /******************** Q Destroy  ***************************/
0663 /* Type of Queue to be destroyed */
0664 enum {
0665     QTYPE_EQ = 1,
0666     QTYPE_CQ,
0667     QTYPE_MCCQ,
0668     QTYPE_WRBQ,
0669     QTYPE_DPDUQ,
0670     QTYPE_SGL
0671 };
0672 
0673 struct be_cmd_req_q_destroy {
0674     struct be_cmd_req_hdr hdr;
0675     u16 id;
0676     u16 bypass_flush;   /* valid only for rx q destroy */
0677 } __packed;
0678 
0679 struct macaddr {
0680     u8 byte[ETH_ALEN];
0681 };
0682 
0683 struct be_cmd_req_mcast_mac_config {
0684     struct be_cmd_req_hdr hdr;
0685     u16 num_mac;
0686     u8 promiscuous;
0687     u8 interface_id;
0688     struct macaddr mac[32];
0689 } __packed;
0690 
0691 static inline void *embedded_payload(struct be_mcc_wrb *wrb)
0692 {
0693     return wrb->payload.embedded_payload;
0694 }
0695 
0696 static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
0697 {
0698     return &wrb->payload.sgl[0];
0699 }
0700 
0701 /******************** Modify EQ Delay *******************/
0702 struct be_cmd_req_modify_eq_delay {
0703     struct be_cmd_req_hdr hdr;
0704     __le32 num_eq;
0705     struct {
0706         __le32 eq_id;
0707         __le32 phase;
0708         __le32 delay_multiplier;
0709     } delay[MAX_CPUS];
0710 } __packed;
0711 
0712 /******************** Get MAC ADDR *******************/
0713 
0714 struct be_cmd_get_nic_conf_resp {
0715     struct be_cmd_resp_hdr hdr;
0716     u32 nic_port_count;
0717     u32 speed;
0718     u32 max_speed;
0719     u32 link_state;
0720     u32 max_frame_size;
0721     u16 size_of_structure;
0722     u8 mac_address[ETH_ALEN];
0723 } __packed;
0724 
0725 /******************** Get HBA NAME *******************/
0726 
0727 struct be_cmd_hba_name {
0728     struct be_cmd_req_hdr hdr;
0729     u16 flags;
0730     u16 rsvd0;
0731     u8 initiator_name[ISCSI_NAME_LEN];
0732 #define BE_INI_ALIAS_LEN 32
0733     u8 initiator_alias[BE_INI_ALIAS_LEN];
0734 } __packed;
0735 
0736 /******************** COMMON SET HOST DATA *******************/
0737 #define BE_CMD_SET_HOST_PARAM_ID    0x2
0738 #define BE_CMD_MAX_DRV_VERSION      0x30
0739 struct be_sethost_req {
0740     u32 param_id;
0741     u32 param_len;
0742     u32 param_data[32];
0743 };
0744 
0745 struct be_sethost_resp {
0746     u32 rsvd0;
0747 };
0748 
0749 struct be_cmd_set_host_data {
0750     union {
0751         struct be_cmd_req_hdr req_hdr;
0752         struct be_cmd_resp_hdr resp_hdr;
0753     } h;
0754     union {
0755         struct be_sethost_req req;
0756         struct be_sethost_resp resp;
0757     } param;
0758 } __packed;
0759 
0760 /******************** COMMON SET Features *******************/
0761 #define BE_CMD_SET_FEATURE_UER  0x10
0762 #define BE_CMD_UER_SUPP_BIT 0x1
0763 struct be_uer_req {
0764     u32 uer;
0765     u32 rsvd;
0766 };
0767 
0768 struct be_uer_resp {
0769     u32 uer;
0770     u16 ue2rp;
0771     u16 ue2sr;
0772 };
0773 
0774 struct be_cmd_set_features {
0775     union {
0776         struct be_cmd_req_hdr req_hdr;
0777         struct be_cmd_resp_hdr resp_hdr;
0778     } h;
0779     u32 feature;
0780     u32 param_len;
0781     union {
0782         struct be_uer_req req;
0783         struct be_uer_resp resp;
0784         u32 rsvd[2];
0785     } param;
0786 } __packed;
0787 
0788 int beiscsi_cmd_function_reset(struct beiscsi_hba *phba);
0789 
0790 int beiscsi_cmd_special_wrb(struct be_ctrl_info *ctrl, u32 load);
0791 
0792 int beiscsi_check_fw_rdy(struct beiscsi_hba *phba);
0793 
0794 int beiscsi_init_sliport(struct beiscsi_hba *phba);
0795 
0796 int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num);
0797 
0798 int beiscsi_detect_ue(struct beiscsi_hba *phba);
0799 
0800 int beiscsi_detect_tpe(struct beiscsi_hba *phba);
0801 
0802 int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
0803               struct be_queue_info *eq, int eq_delay);
0804 
0805 int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
0806               struct be_queue_info *cq, struct be_queue_info *eq,
0807               bool sol_evts, bool no_delay,
0808               int num_cqe_dma_coalesce);
0809 
0810 int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
0811               int type);
0812 int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
0813             struct be_queue_info *mccq,
0814             struct be_queue_info *cq);
0815 
0816 void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);
0817 
0818 int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
0819                 int num);
0820 int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
0821                 unsigned int tag,
0822                 struct be_mcc_wrb **wrb,
0823                 struct be_dma_mem *mbx_cmd_mem);
0824 int __beiscsi_mcc_compl_status(struct beiscsi_hba *phba,
0825                    unsigned int tag,
0826                    struct be_mcc_wrb **wrb,
0827                    struct be_dma_mem *mbx_cmd_mem);
0828 struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
0829 void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
0830 struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
0831                  unsigned int *ref_tag);
0832 void beiscsi_process_async_event(struct beiscsi_hba *phba,
0833                 struct be_mcc_compl *compl);
0834 int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
0835                   struct be_mcc_compl *compl);
0836 
0837 int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
0838                     struct be_queue_info *cq,
0839                     struct be_queue_info *dq, int length,
0840                     int entry_size, uint8_t is_header,
0841                     uint8_t ulp_num);
0842 
0843 int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
0844                     struct be_dma_mem *q_mem);
0845 
0846 int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);
0847 
0848 int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
0849                 struct be_dma_mem *q_mem, u32 page_offset,
0850                 u32 num_pages);
0851 
0852 int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
0853                struct be_queue_info *wrbq,
0854                struct hwi_wrb_context *pwrb_context,
0855                uint8_t ulp_num);
0856 
0857 /* Configuration Functions */
0858 int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
0859 
0860 int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
0861                    struct beiscsi_hba *phba);
0862 
0863 int beiscsi_get_fw_config(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
0864 
0865 int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);
0866 
0867 int beiscsi_set_uer_feature(struct beiscsi_hba *phba);
0868 int beiscsi_set_host_data(struct beiscsi_hba *phba);
0869 
0870 struct be_default_pdu_context {
0871     u32 dw[4];
0872 } __packed;
0873 
0874 struct amap_be_default_pdu_context {
0875     u8 dbuf_cindex[13]; /* dword 0 */
0876     u8 rsvd0[3];        /* dword 0 */
0877     u8 ring_size[4];    /* dword 0 */
0878     u8 ring_state[4];   /* dword 0 */
0879     u8 rsvd1[8];        /* dword 0 */
0880     u8 dbuf_pindex[13]; /* dword 1 */
0881     u8 rsvd2;       /* dword 1 */
0882     u8 pci_func_id[8];  /* dword 1 */
0883     u8 rx_pdid[9];      /* dword 1 */
0884     u8 rx_pdid_valid;   /* dword 1 */
0885     u8 default_buffer_size[16]; /* dword 2 */
0886     u8 cq_id_recv[10];  /* dword 2 */
0887     u8 rx_pdid_not_valid;   /* dword 2 */
0888     u8 rsvd3[5];        /* dword 2 */
0889     u8 rsvd4[32];       /* dword 3 */
0890 } __packed;
0891 
0892 struct amap_default_pdu_context_ext {
0893     u8 rsvd0[16];   /* dword 0 */
0894     u8 ring_size[4];    /* dword 0 */
0895     u8 rsvd1[12];   /* dword 0 */
0896     u8 rsvd2[22];   /* dword 1 */
0897     u8 rx_pdid[9];  /* dword 1 */
0898     u8 rx_pdid_valid;   /* dword 1 */
0899     u8 default_buffer_size[16]; /* dword 2 */
0900     u8 cq_id_recv[16];  /* dword 2 */
0901     u8 rsvd3[32];   /* dword 3 */
0902 } __packed;
0903 
0904 struct be_defq_create_req {
0905     struct be_cmd_req_hdr hdr;
0906     u16 num_pages;
0907     u8 ulp_num;
0908 #define BEISCSI_DUAL_ULP_AWARE_BIT  0   /* Byte 3 - Bit 0 */
0909 #define BEISCSI_BIND_Q_TO_ULP_BIT   1   /* Byte 3 - Bit 1 */
0910     u8 dua_feature;
0911     struct be_default_pdu_context context;
0912     struct phys_addr pages[8];
0913 } __packed;
0914 
0915 struct be_defq_create_resp {
0916     struct be_cmd_req_hdr hdr;
0917     u16 id;
0918     u8 rsvd0;
0919     u8 ulp_num;
0920     u32 doorbell_offset;
0921     u16 register_set;
0922     u16 doorbell_format;
0923 } __packed;
0924 
0925 struct be_post_template_pages_req {
0926     struct be_cmd_req_hdr hdr;
0927     u16 num_pages;
0928 #define BEISCSI_TEMPLATE_HDR_TYPE_ISCSI 0x1
0929     u16 type;
0930     struct phys_addr scratch_pa;
0931     struct virt_addr scratch_va;
0932     struct virt_addr pages_va;
0933     struct phys_addr pages[16];
0934 } __packed;
0935 
0936 struct be_remove_template_pages_req {
0937     struct be_cmd_req_hdr hdr;
0938     u16 type;
0939     u16 rsvd0;
0940 } __packed;
0941 
0942 struct be_post_sgl_pages_req {
0943     struct be_cmd_req_hdr hdr;
0944     u16 num_pages;
0945     u16 page_offset;
0946     u32 rsvd0;
0947     struct phys_addr pages[26];
0948     u32 rsvd1;
0949 } __packed;
0950 
0951 struct be_wrbq_create_req {
0952     struct be_cmd_req_hdr hdr;
0953     u16 num_pages;
0954     u8 ulp_num;
0955     u8 dua_feature;
0956     struct phys_addr pages[8];
0957 } __packed;
0958 
0959 struct be_wrbq_create_resp {
0960     struct be_cmd_resp_hdr resp_hdr;
0961     u16 cid;
0962     u8 rsvd0;
0963     u8 ulp_num;
0964     u32 doorbell_offset;
0965     u16 register_set;
0966     u16 doorbell_format;
0967 } __packed;
0968 
0969 #define SOL_CID_MASK        0x0000FFC0
0970 #define SOL_CODE_MASK       0x0000003F
0971 #define SOL_WRB_INDEX_MASK  0x00FF0000
0972 #define SOL_CMD_WND_MASK    0xFF000000
0973 #define SOL_RES_CNT_MASK    0x7FFFFFFF
0974 #define SOL_EXP_CMD_SN_MASK 0xFFFFFFFF
0975 #define SOL_HW_STS_MASK     0x000000FF
0976 #define SOL_STS_MASK        0x0000FF00
0977 #define SOL_RESP_MASK       0x00FF0000
0978 #define SOL_FLAGS_MASK      0x7F000000
0979 #define SOL_S_MASK      0x80000000
0980 
0981 struct sol_cqe {
0982     u32 dw[4];
0983 };
0984 
0985 struct amap_sol_cqe {
0986     u8 hw_sts[8];       /* dword 0 */
0987     u8 i_sts[8];        /* dword 0 */
0988     u8 i_resp[8];       /* dword 0 */
0989     u8 i_flags[7];      /* dword 0 */
0990     u8 s;           /* dword 0 */
0991     u8 i_exp_cmd_sn[32];    /* dword 1 */
0992     u8 code[6];     /* dword 2 */
0993     u8 cid[10];     /* dword 2 */
0994     u8 wrb_index[8];    /* dword 2 */
0995     u8 i_cmd_wnd[8];    /* dword 2 */
0996     u8 i_res_cnt[31];   /* dword 3 */
0997     u8 valid;       /* dword 3 */
0998 } __packed;
0999 
1000 #define SOL_ICD_INDEX_MASK  0x0003FFC0
1001 struct amap_sol_cqe_ring {
1002     u8 hw_sts[8];       /* dword 0 */
1003     u8 i_sts[8];        /* dword 0 */
1004     u8 i_resp[8];       /* dword 0 */
1005     u8 i_flags[7];      /* dword 0 */
1006     u8 s;           /* dword 0 */
1007     u8 i_exp_cmd_sn[32];    /* dword 1 */
1008     u8 code[6];     /* dword 2 */
1009     u8 icd_index[12];   /* dword 2 */
1010     u8 rsvd[6];     /* dword 2 */
1011     u8 i_cmd_wnd[8];    /* dword 2 */
1012     u8 i_res_cnt[31];   /* dword 3 */
1013     u8 valid;       /* dword 3 */
1014 } __packed;
1015 
1016 struct amap_sol_cqe_v2 {
1017     u8 hw_sts[8];   /* dword 0 */
1018     u8 i_sts[8];    /* dword 0 */
1019     u8 wrb_index[16];   /* dword 0 */
1020     u8 i_exp_cmd_sn[32];    /* dword 1 */
1021     u8 code[6]; /* dword 2 */
1022     u8 cmd_cmpl;    /* dword 2 */
1023     u8 rsvd0;   /* dword 2 */
1024     u8 i_cmd_wnd[8];    /* dword 2 */
1025     u8 cid[13]; /* dword 2 */
1026     u8 u;   /* dword 2 */
1027     u8 o;   /* dword 2 */
1028     u8 s;   /* dword 2 */
1029     u8 i_res_cnt[31];   /* dword 3 */
1030     u8 valid;   /* dword 3 */
1031 } __packed;
1032 
1033 struct common_sol_cqe {
1034     u32 exp_cmdsn;
1035     u32 res_cnt;
1036     u16 wrb_index;
1037     u16 cid;
1038     u8 hw_sts;
1039     u8 cmd_wnd;
1040     u8 res_flag; /* the s feild of structure */
1041     u8 i_resp; /* for skh if cmd_complete is set then i_sts is response */
1042     u8 i_flags; /* for skh or the u and o feilds */
1043     u8 i_sts; /* for skh if cmd_complete is not-set then i_sts is status */
1044 };
1045 
1046 /*** iSCSI ack/driver message completions ***/
1047 struct amap_it_dmsg_cqe {
1048     u8 ack_num[32]; /* DWORD 0 */
1049     u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
1050     u8 code[6]; /* DWORD 2 */
1051     u8 cid[10]; /* DWORD 2 */
1052     u8 wrb_idx[8];  /* DWORD 2 */
1053     u8 rsvd0[8];    /* DWORD 2*/
1054     u8 rsvd1[31];   /* DWORD 3*/
1055     u8 valid;   /* DWORD 3 */
1056 } __packed;
1057 
1058 struct amap_it_dmsg_cqe_v2 {
1059     u8 ack_num[32]; /* DWORD 0 */
1060     u8 pdu_bytes_rcvd[32];  /* DWORD 1 */
1061     u8 code[6]; /* DWORD 2 */
1062     u8 rsvd0[10];   /* DWORD 2 */
1063     u8 wrb_idx[16]; /* DWORD 2 */
1064     u8 rsvd1[16];   /* DWORD 3 */
1065     u8 cid[13]; /* DWORD 3 */
1066     u8 rsvd2[2];    /* DWORD 3 */
1067     u8 valid;   /* DWORD 3 */
1068 } __packed;
1069 
1070 
1071 /**
1072  * Post WRB Queue Doorbell Register used by the host Storage
1073  * stack to notify the
1074  * controller of a posted Work Request Block
1075  */
1076 #define DB_WRB_POST_CID_MASK        0xFFFF  /* bits 0 - 16 */
1077 #define DB_DEF_PDU_WRB_INDEX_MASK   0xFF    /* bits 0 - 9 */
1078 
1079 #define DB_DEF_PDU_WRB_INDEX_SHIFT  16
1080 #define DB_DEF_PDU_NUM_POSTED_SHIFT 24
1081 
1082 struct fragnum_bits_for_sgl_cra_in {
1083     struct be_cmd_req_hdr hdr;
1084     u32 num_bits;
1085 } __packed;
1086 
1087 struct iscsi_cleanup_req {
1088     struct be_cmd_req_hdr hdr;
1089     u16 chute;
1090     u8 hdr_ring_id;
1091     u8 data_ring_id;
1092 } __packed;
1093 
1094 struct iscsi_cleanup_req_v1 {
1095     struct be_cmd_req_hdr hdr;
1096     u16 chute;
1097     u16 rsvd1;
1098     u16 hdr_ring_id;
1099     u16 rsvd2;
1100     u16 data_ring_id;
1101     u16 rsvd3;
1102 } __packed;
1103 
1104 struct eq_delay {
1105     u32 eq_id;
1106     u32 phase;
1107     u32 delay_multiplier;
1108 } __packed;
1109 
1110 struct be_eq_delay_params_in {
1111     struct be_cmd_req_hdr hdr;
1112     u32 num_eq;
1113     struct eq_delay delay[8];
1114 } __packed;
1115 
1116 struct tcp_connect_and_offload_in {
1117     struct be_cmd_req_hdr hdr;
1118     struct ip_addr_format ip_address;
1119     u16 tcp_port;
1120     u16 cid;
1121     u16 cq_id;
1122     u16 defq_id;
1123     struct phys_addr dataout_template_pa;
1124     u16 hdr_ring_id;
1125     u16 data_ring_id;
1126     u8 do_offload;
1127     u8 rsvd0[3];
1128 } __packed;
1129 
1130 struct tcp_connect_and_offload_in_v1 {
1131     struct be_cmd_req_hdr hdr;
1132     struct ip_addr_format ip_address;
1133     u16 tcp_port;
1134     u16 cid;
1135     u16 cq_id;
1136     u16 defq_id;
1137     struct phys_addr dataout_template_pa;
1138     u16 hdr_ring_id;
1139     u16 data_ring_id;
1140     u8 do_offload;
1141     u8 ifd_state;
1142     u8 rsvd0[2];
1143     u16 tcp_window_size;
1144     u8 tcp_window_scale_count;
1145     u8 rsvd1;
1146     u32 tcp_mss:24;
1147     u8 rsvd2;
1148 } __packed;
1149 
1150 struct tcp_connect_and_offload_out {
1151     struct be_cmd_resp_hdr hdr;
1152     u32 connection_handle;
1153     u16 cid;
1154     u16 rsvd0;
1155 
1156 } __packed;
1157 
1158 #define DB_DEF_PDU_RING_ID_MASK 0x3FFF  /* bits 0 - 13 */
1159 #define DB_DEF_PDU_CQPROC_MASK      0x3FFF  /* bits 16 - 29 */
1160 #define DB_DEF_PDU_REARM_SHIFT      14
1161 #define DB_DEF_PDU_EVENT_SHIFT      15
1162 #define DB_DEF_PDU_CQPROC_SHIFT     16
1163 
1164 struct be_invalidate_connection_params_in {
1165     struct be_cmd_req_hdr hdr;
1166     u32 session_handle;
1167     u16 cid;
1168     u16 unused;
1169 #define BE_CLEANUP_TYPE_INVALIDATE  0x8001
1170 #define BE_CLEANUP_TYPE_ISSUE_TCP_RST   0x8002
1171     u16 cleanup_type;
1172     u16 save_cfg;
1173 } __packed;
1174 
1175 struct be_invalidate_connection_params_out {
1176     u32 session_handle;
1177     u16 cid;
1178     u16 unused;
1179 } __packed;
1180 
1181 union be_invalidate_connection_params {
1182     struct be_invalidate_connection_params_in req;
1183     struct be_invalidate_connection_params_out resp;
1184 } __packed;
1185 
1186 struct be_tcp_upload_params_in {
1187     struct be_cmd_req_hdr hdr;
1188     u16 id;
1189 #define BE_UPLOAD_TYPE_GRACEFUL     1
1190 /* abortive upload with reset */
1191 #define BE_UPLOAD_TYPE_ABORT_RESET  2
1192 /* abortive upload without reset */
1193 #define BE_UPLOAD_TYPE_ABORT        3
1194 /* abortive upload with reset, sequence number by driver */
1195 #define BE_UPLOAD_TYPE_ABORT_WITH_SEQ   4
1196     u16 upload_type;
1197     u32 reset_seq;
1198 } __packed;
1199 
1200 struct be_tcp_upload_params_out {
1201     u32 dw[32];
1202 } __packed;
1203 
1204 union be_tcp_upload_params {
1205     struct be_tcp_upload_params_in request;
1206     struct be_tcp_upload_params_out response;
1207 } __packed;
1208 
1209 struct be_ulp_fw_cfg {
1210 #define BEISCSI_ULP_ISCSI_INI_MODE  0x10
1211     u32 ulp_mode;
1212     u32 etx_base;
1213     u32 etx_count;
1214     u32 sq_base;
1215     u32 sq_count;
1216     u32 rq_base;
1217     u32 rq_count;
1218     u32 dq_base;
1219     u32 dq_count;
1220     u32 lro_base;
1221     u32 lro_count;
1222     u32 icd_base;
1223     u32 icd_count;
1224 };
1225 
1226 struct be_ulp_chain_icd {
1227     u32 chain_base;
1228     u32 chain_count;
1229 };
1230 
1231 struct be_fw_cfg {
1232     struct be_cmd_req_hdr hdr;
1233     u32 be_config_number;
1234     u32 asic_revision;
1235     u32 phys_port;
1236 #define BEISCSI_FUNC_ISCSI_INI_MODE 0x10
1237 #define BEISCSI_FUNC_DUA_MODE   0x800
1238     u32 function_mode;
1239     struct be_ulp_fw_cfg ulp[2];
1240     u32 function_caps;
1241     u32 cqid_base;
1242     u32 cqid_count;
1243     u32 eqid_base;
1244     u32 eqid_count;
1245     struct be_ulp_chain_icd chain_icd[2];
1246 } __packed;
1247 
1248 struct be_cmd_get_all_if_id_req {
1249     struct be_cmd_req_hdr hdr;
1250     u32 if_count;
1251     u32 if_hndl_list[1];
1252 } __packed;
1253 
1254 struct be_cmd_get_port_name {
1255     union {
1256         struct be_cmd_req_hdr req_hdr;
1257         struct be_cmd_resp_hdr resp_hdr;
1258     } h;
1259     union {
1260         struct {
1261             u32 reserved;
1262         } req;
1263         struct {
1264             u32 port_names;
1265         } resp;
1266     } p;
1267 } __packed;
1268 
1269 #define ISCSI_OPCODE_SCSI_DATA_OUT      5
1270 #define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY 5
1271 #define OPCODE_COMMON_MODIFY_EQ_DELAY       41
1272 #define OPCODE_COMMON_ISCSI_CLEANUP     59
1273 #define OPCODE_COMMON_TCP_UPLOAD        56
1274 #define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD 70
1275 #define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS 1
1276 #define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME   6
1277 #define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME   7
1278 #define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION  14
1279 #define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET   24
1280 #define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS 36
1281 #define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION 41
1282 #define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION 42
1283 #define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET   52
1284 #define OPCODE_COMMON_WRITE_FLASH       96
1285 #define OPCODE_COMMON_READ_FLASH        97
1286 
1287 #define CMD_ISCSI_COMMAND_INVALIDATE        1
1288 
1289 #define INI_WR_CMD          1   /* Initiator write command */
1290 #define INI_TMF_CMD         2   /* Initiator TMF command */
1291 #define INI_NOPOUT_CMD          3   /* Initiator; Send a NOP-OUT */
1292 #define INI_RD_CMD          5   /* Initiator requesting to send
1293                          * a read command
1294                          */
1295 #define TGT_CTX_UPDT_CMD        7   /* Target context update */
1296 #define TGT_DM_CMD          11  /* Indicates that the bhs
1297                          * prepared by driver should not
1298                          * be touched.
1299                          */
1300 
1301 /* Returns the number of items in the field array. */
1302 #define BE_NUMBER_OF_FIELD(_type_, _field_) \
1303     (sizeof_field(_type_, _field_)/sizeof((((_type_ *)0)->_field_[0])))\
1304 
1305 /**
1306  * Different types of iSCSI completions to host driver for both initiator
1307  * and taget mode
1308  * of operation.
1309  */
1310 #define SOL_CMD_COMPLETE        1   /* Solicited command completed
1311                          * normally
1312                          */
1313 #define SOL_CMD_KILLED_DATA_DIGEST_ERR  2   /* Solicited command got
1314                          * invalidated internally due
1315                          * to Data Digest error
1316                          */
1317 #define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL 3   /* Connection got invalidated
1318                          * internally
1319                          * due to a received PDU
1320                          * size > DSL
1321                          */
1322 #define CXN_KILLED_BURST_LEN_MISMATCH   4   /* Connection got invalidated
1323                          * internally due ti received
1324                          * PDU sequence size >
1325                          * FBL/MBL.
1326                          */
1327 #define CXN_KILLED_AHS_RCVD     5   /* Connection got invalidated
1328                          * internally due to a received
1329                          * PDU Hdr that has
1330                          * AHS */
1331 #define CXN_KILLED_HDR_DIGEST_ERR   6   /* Connection got invalidated
1332                          * internally due to Hdr Digest
1333                          * error
1334                          */
1335 #define CXN_KILLED_UNKNOWN_HDR      7   /* Connection got invalidated
1336                          *  internally
1337                          * due to a bad opcode in the
1338                          * pdu hdr
1339                          */
1340 #define CXN_KILLED_STALE_ITT_TTT_RCVD   8   /* Connection got invalidated
1341                          * internally due to a received
1342                          * ITT/TTT that does not belong
1343                          * to this Connection
1344                          */
1345 #define CXN_KILLED_INVALID_ITT_TTT_RCVD 9   /* Connection got invalidated
1346                          * internally due to received
1347                          * ITT/TTT value > Max
1348                          * Supported ITTs/TTTs
1349                          */
1350 #define CXN_KILLED_RST_RCVD     10  /* Connection got invalidated
1351                          * internally due to an
1352                          * incoming TCP RST
1353                          */
1354 #define CXN_KILLED_TIMED_OUT        11  /* Connection got invalidated
1355                          * internally due to timeout on
1356                          * tcp segment 12 retransmit
1357                          * attempts failed
1358                          */
1359 #define CXN_KILLED_RST_SENT     12  /* Connection got invalidated
1360                          * internally due to TCP RST
1361                          * sent by the Tx side
1362                          */
1363 #define CXN_KILLED_FIN_RCVD     13  /* Connection got invalidated
1364                          * internally due to an
1365                          * incoming TCP FIN.
1366                          */
1367 #define CXN_KILLED_BAD_UNSOL_PDU_RCVD   14  /* Connection got invalidated
1368                          * internally due to bad
1369                          * unsolicited PDU Unsolicited
1370                          * PDUs are PDUs with
1371                          * ITT=0xffffffff
1372                          */
1373 #define CXN_KILLED_BAD_WRB_INDEX_ERROR  15  /* Connection got invalidated
1374                          * internally due to bad WRB
1375                          * index.
1376                          */
1377 #define CXN_KILLED_OVER_RUN_RESIDUAL    16  /* Command got invalidated
1378                          * internally due to received
1379                          * command has residual
1380                          * over run bytes.
1381                          */
1382 #define CXN_KILLED_UNDER_RUN_RESIDUAL   17  /* Command got invalidated
1383                          * internally due to received
1384                          * command has residual under
1385                          * run bytes.
1386                          */
1387 #define CMD_KILLED_INVALID_STATSN_RCVD  18  /* Command got invalidated
1388                          * internally due to a received
1389                          * PDU has an invalid StatusSN
1390                          */
1391 #define CMD_KILLED_INVALID_R2T_RCVD 19  /* Command got invalidated
1392                          * internally due to a received
1393                          * an R2T with some invalid
1394                          * fields in it
1395                          */
1396 #define CMD_CXN_KILLED_LUN_INVALID  20  /* Command got invalidated
1397                          * internally due to received
1398                          * PDU has an invalid LUN.
1399                          */
1400 #define CMD_CXN_KILLED_ICD_INVALID  21  /* Command got invalidated
1401                          * internally due to the
1402                          * corresponding ICD not in a
1403                          * valid state
1404                          */
1405 #define CMD_CXN_KILLED_ITT_INVALID  22  /* Command got invalidated due
1406                          *  to received PDU has an
1407                          *  invalid ITT.
1408                          */
1409 #define CMD_CXN_KILLED_SEQ_OUTOFORDER   23  /* Command got invalidated due
1410                          * to received sequence buffer
1411                          * offset is out of order.
1412                          */
1413 #define CMD_CXN_KILLED_INVALID_DATASN_RCVD 24   /* Command got invalidated
1414                          * internally due to a
1415                          * received PDU has an invalid
1416                          * DataSN
1417                          */
1418 #define CXN_INVALIDATE_NOTIFY       25  /* Connection invalidation
1419                          * completion notify.
1420                          */
1421 #define CXN_INVALIDATE_INDEX_NOTIFY 26  /* Connection invalidation
1422                          * completion
1423                          * with data PDU index.
1424                          */
1425 #define CMD_INVALIDATED_NOTIFY      27  /* Command invalidation
1426                          * completionnotifify.
1427                          */
1428 #define UNSOL_HDR_NOTIFY        28  /* Unsolicited header notify.*/
1429 #define UNSOL_DATA_NOTIFY       29  /* Unsolicited data notify.*/
1430 #define UNSOL_DATA_DIGEST_ERROR_NOTIFY  30  /* Unsolicited data digest
1431                          * error notify.
1432                          */
1433 #define DRIVERMSG_NOTIFY        31  /* TCP acknowledge based
1434                          * notification.
1435                          */
1436 #define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN 32 /* Connection got invalidated
1437                           * internally due to command
1438                           * and data are not on same
1439                           * connection.
1440                           */
1441 #define SOL_CMD_KILLED_DIF_ERR      33  /* Solicited command got
1442                          *  invalidated internally due
1443                          *  to DIF error
1444                          */
1445 #define CXN_KILLED_SYN_RCVD     34  /* Connection got invalidated
1446                          * internally due to incoming
1447                          * TCP SYN
1448                          */
1449 #define CXN_KILLED_IMM_DATA_RCVD    35  /* Connection got invalidated
1450                          * internally due to an
1451                          * incoming Unsolicited PDU
1452                          * that has immediate data on
1453                          * the cxn
1454                          */
1455 
1456 void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, u32 payload_len,
1457             bool embedded, u8 sge_cnt);
1458 
1459 void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
1460             u8 subsystem, u8 opcode, u32 cmd_len);
1461 #endif /* !BEISCSI_CMDS_H */