linux/drivers/scsi/be2iscsi/be_cmds.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright 2017 Broadcom. All Rights Reserved.
 * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
 *
 * Contact Information:
 * [email protected]
 */

#ifndef BEISCSI_CMDS_H
#define BEISCSI_CMDS_H

/**
 * The driver sends configuration and managements command requests to the
 * firmware in the BE. These requests are communicated to the processor
 * using Work Request Blocks (WRBs) submitted to the MCC-WRB ring or via one
 * WRB inside a MAILBOX.
 * The commands are serviced by the ARM processor in the OneConnect's MPU.
 */
struct be_sge {};

struct be_mcc_wrb {};

#define CQE_FLAGS_VALID_MASK
#define CQE_FLAGS_ASYNC_MASK
#define CQE_FLAGS_COMPLETED_MASK
#define CQE_FLAGS_CONSUMED_MASK

/* Completion Status */
#define MCC_STATUS_SUCCESS
#define MCC_STATUS_FAILED
#define MCC_STATUS_ILLEGAL_REQUEST
#define MCC_STATUS_ILLEGAL_FIELD
#define MCC_STATUS_INSUFFICIENT_BUFFER
#define MCC_STATUS_INVALID_LENGTH

#define CQE_STATUS_COMPL_MASK
#define CQE_STATUS_COMPL_SHIFT
#define CQE_STATUS_EXTD_MASK
#define CQE_STATUS_EXTD_SHIFT
#define CQE_STATUS_ADDL_MASK
#define CQE_STATUS_ADDL_SHIFT
#define CQE_STATUS_MASK
#define CQE_STATUS_WRB_MASK
#define CQE_STATUS_WRB_SHIFT

#define BEISCSI_HOST_MBX_TIMEOUT
#define BEISCSI_FW_MBX_TIMEOUT

/* MBOX Command VER */
#define MBX_CMD_VER1
#define MBX_CMD_VER2

struct be_mcc_compl {};

/********* Mailbox door bell *************/
/**
 * Used for driver communication with the FW.
 * The software must write this register twice to post any command. First,
 * it writes the register with hi=1 and the upper bits of the physical address
 * for the MAILBOX structure. Software must poll the ready bit until this
 * is acknowledged. Then, sotware writes the register with hi=0 with the lower
 * bits in the address. It must poll the ready bit until the command is
 * complete. Upon completion, the MAILBOX will contain a valid completion
 * queue entry.
 */
#define MPU_MAILBOX_DB_OFFSET
#define MPU_MAILBOX_DB_RDY_MASK
#define MPU_MAILBOX_DB_HI_MASK

/********** MPU semphore: used for SH & BE ******************/
#define SLIPORT_SOFTRESET_OFFSET
#define SLIPORT_SEMAPHORE_OFFSET_BEx
#define SLIPORT_SEMAPHORE_OFFSET_SH
#define POST_STAGE_MASK
#define POST_ERROR_BIT
#define POST_ERR_RECOVERY_CODE_MASK

/* Soft Reset register masks */
#define SLIPORT_SOFTRESET_SR_MASK

/* MPU semphore POST stage values */
#define POST_STAGE_AWAITING_HOST_RDY
#define POST_STAGE_HOST_RDY
#define POST_STAGE_BE_RESET
#define POST_STAGE_ARMFW_RDY
#define POST_STAGE_RECOVERABLE_ERR

/********** MCC door bell ************/
#define DB_MCCQ_OFFSET
#define DB_MCCQ_RING_ID_MASK
/* Number of entries posted */
#define DB_MCCQ_NUM_POSTED_SHIFT

/**
 * When the async bit of mcc_compl is set, the last 4 bytes of
 * mcc_compl is interpreted as follows:
 */
#define ASYNC_TRAILER_EVENT_CODE_SHIFT
#define ASYNC_TRAILER_EVENT_CODE_MASK
#define ASYNC_EVENT_CODE_LINK_STATE
#define ASYNC_EVENT_CODE_ISCSI
#define ASYNC_EVENT_CODE_SLI

#define ASYNC_TRAILER_EVENT_TYPE_SHIFT
#define ASYNC_TRAILER_EVENT_TYPE_MASK

/* iSCSI events */
#define ASYNC_EVENT_NEW_ISCSI_TGT_DISC
#define ASYNC_EVENT_NEW_ISCSI_CONN
#define ASYNC_EVENT_NEW_TCP_CONN

/* SLI events */
#define ASYNC_SLI_EVENT_TYPE_MISCONFIGURED
#define ASYNC_SLI_LINK_EFFECT_VALID(le)
#define ASYNC_SLI_LINK_EFFECT_SEV(le)
#define ASYNC_SLI_LINK_EFFECT_STATE(le)

struct be_async_event_trailer {};

enum {};

/**
 * When the event code of an async trailer is link-state, the mcc_compl
 * must be interpreted as follows
 */
struct be_async_event_link_state {} __packed;

/**
 * When async-trailer is SLI event, mcc_compl is interpreted as
 */
struct be_async_event_sli {} __packed;

struct be_mcc_mailbox {};

/* Type of subsystems supported by FW */
#define CMD_SUBSYSTEM_COMMON
#define CMD_SUBSYSTEM_ISCSI
#define CMD_SUBSYSTEM_ETH
#define CMD_SUBSYSTEM_ISCSI_INI
#define CMD_COMMON_TCP_UPLOAD

/**
 * List of common opcodes subsystem  CMD_SUBSYSTEM_COMMON
 * These opcodes are unique for each subsystem defined above
 */
#define OPCODE_COMMON_CQ_CREATE
#define OPCODE_COMMON_EQ_CREATE
#define OPCODE_COMMON_MCC_CREATE
#define OPCODE_COMMON_MCC_CREATE_EXT
#define OPCODE_COMMON_ADD_TEMPLATE_HEADER_BUFFERS
#define OPCODE_COMMON_REMOVE_TEMPLATE_HEADER_BUFFERS
#define OPCODE_COMMON_GET_CNTL_ATTRIBUTES
#define OPCODE_COMMON_GET_FW_VERSION
#define OPCODE_COMMON_MODIFY_EQ_DELAY
#define OPCODE_COMMON_FIRMWARE_CONFIG
#define OPCODE_COMMON_MCC_DESTROY
#define OPCODE_COMMON_CQ_DESTROY
#define OPCODE_COMMON_EQ_DESTROY
#define OPCODE_COMMON_QUERY_FIRMWARE_CONFIG
#define OPCODE_COMMON_FUNCTION_RESET
#define OPCODE_COMMON_GET_PORT_NAME
#define OPCODE_COMMON_SET_HOST_DATA
#define OPCODE_COMMON_SET_FEATURES

/**
 * LIST of opcodes that are common between Initiator and Target
 * used by CMD_SUBSYSTEM_ISCSI
 * These opcodes are unique for each subsystem defined above
 */
#define OPCODE_COMMON_ISCSI_CFG_POST_SGL_PAGES
#define OPCODE_COMMON_ISCSI_CFG_REMOVE_SGL_PAGES
#define OPCODE_COMMON_ISCSI_NTWK_GET_NIC_CONFIG
#define OPCODE_COMMON_ISCSI_NTWK_SET_VLAN
#define OPCODE_COMMON_ISCSI_NTWK_CONFIG_STATELESS_IP_ADDR
#define OPCODE_COMMON_ISCSI_NTWK_REL_STATELESS_IP_ADDR
#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_IP_ADDR
#define OPCODE_COMMON_ISCSI_NTWK_GET_DEFAULT_GATEWAY
#define OPCODE_COMMON_ISCSI_NTWK_MODIFY_DEFAULT_GATEWAY
#define OPCODE_COMMON_ISCSI_NTWK_GET_ALL_IF_ID
#define OPCODE_COMMON_ISCSI_NTWK_GET_IF_INFO
#define OPCODE_COMMON_ISCSI_SET_FRAGNUM_BITS_FOR_SGL_CRA
#define OPCODE_COMMON_ISCSI_DEFQ_CREATE
#define OPCODE_COMMON_ISCSI_DEFQ_DESTROY
#define OPCODE_COMMON_ISCSI_WRBQ_CREATE
#define OPCODE_COMMON_ISCSI_WRBQ_DESTROY

struct be_cmd_req_hdr {};

struct be_cmd_resp_hdr {};

struct phys_addr {};

struct virt_addr {};
/**************************
 * BE Command definitions *
 **************************/

/**
 * Pseudo amap definition in which each bit of the actual structure is defined
 * as a byte - used to calculate offset/shift/mask of each field
 */
struct amap_eq_context {} __packed;

struct be_cmd_req_eq_create {} __packed;

struct be_cmd_resp_eq_create {} __packed;

struct be_set_eqd {} __packed;

struct mgmt_chap_format {} __packed;

struct mgmt_auth_method_format {} __packed;

struct be_cmd_req_logout_fw_sess {} __packed;

struct be_cmd_resp_logout_fw_sess {} __packed;

struct mgmt_conn_login_options {} __packed;

struct ip_addr_format {} __packed;

struct mgmt_conn_info {} __packed;

struct mgmt_session_login_options {} __packed;

struct mgmt_session_info {} __packed;

struct be_cmd_get_session_req {} __packed;

struct be_cmd_get_session_resp {} __packed;

struct mac_addr {} __packed;

struct be_cmd_get_boot_target_req {} __packed;

struct be_cmd_get_boot_target_resp {};

struct be_cmd_reopen_session_req {} __packed;

struct be_cmd_reopen_session_resp {} __packed;


struct be_cmd_mac_query_req {} __packed;

struct be_cmd_get_mac_resp {};

struct be_ip_addr_subnet_format {} __packed;

struct be_cmd_get_if_info_req {} __packed;

struct be_cmd_get_if_info_resp {} __packed;

struct be_ip_addr_record {} __packed;

struct be_ip_addr_record_params {} __packed;

struct be_cmd_set_ip_addr_req {} __packed;


struct be_cmd_set_dhcp_req {} __packed;

struct be_cmd_rel_dhcp_req {} __packed;

struct be_cmd_set_def_gateway_req {} __packed;

struct be_cmd_get_def_gateway_req {} __packed;

struct be_cmd_get_def_gateway_resp {} __packed;

#define BEISCSI_VLAN_DISABLE
struct be_cmd_set_vlan_req {} __packed;
/******************** Create CQ ***************************/
/**
 * Pseudo amap definition in which each bit of the actual structure is defined
 * as a byte - used to calculate offset/shift/mask of each field
 */
struct amap_cq_context {} __packed;

struct amap_cq_context_v2 {};

struct be_cmd_req_cq_create {} __packed;

struct be_cmd_resp_cq_create {} __packed;

/******************** Create MCCQ ***************************/
/**
 * Pseudo amap definition in which each bit of the actual structure is defined
 * as a byte - used to calculate offset/shift/mask of each field
 */
struct amap_mcc_context {} __packed;

struct be_cmd_req_mcc_create_ext {} __packed;

struct be_cmd_resp_mcc_create {} __packed;

/******************** Q Destroy  ***************************/
/* Type of Queue to be destroyed */
enum {};

struct be_cmd_req_q_destroy {} __packed;

struct macaddr {};

struct be_cmd_req_mcast_mac_config {} __packed;

static inline void *embedded_payload(struct be_mcc_wrb *wrb)
{}

static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
{}

/******************** Modify EQ Delay *******************/
struct be_cmd_req_modify_eq_delay {} __packed;

/******************** Get MAC ADDR *******************/

struct be_cmd_get_nic_conf_resp {} __packed;

/******************** Get HBA NAME *******************/

struct be_cmd_hba_name {} __packed;

/******************** COMMON SET HOST DATA *******************/
#define BE_CMD_SET_HOST_PARAM_ID
#define BE_CMD_MAX_DRV_VERSION
struct be_sethost_req {};

struct be_sethost_resp {};

struct be_cmd_set_host_data {} __packed;

/******************** COMMON SET Features *******************/
#define BE_CMD_SET_FEATURE_UER
#define BE_CMD_UER_SUPP_BIT
struct be_uer_req {};

struct be_uer_resp {};

struct be_cmd_set_features {} __packed;

int beiscsi_cmd_function_reset(struct beiscsi_hba *phba);

int beiscsi_cmd_special_wrb(struct be_ctrl_info *ctrl, u32 load);

int beiscsi_check_fw_rdy(struct beiscsi_hba *phba);

int beiscsi_init_sliport(struct beiscsi_hba *phba);

int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short ulp_num);

int beiscsi_detect_ue(struct beiscsi_hba *phba);

int beiscsi_detect_tpe(struct beiscsi_hba *phba);

int beiscsi_cmd_eq_create(struct be_ctrl_info *ctrl,
			  struct be_queue_info *eq, int eq_delay);

int beiscsi_cmd_cq_create(struct be_ctrl_info *ctrl,
			  struct be_queue_info *cq, struct be_queue_info *eq,
			  bool sol_evts, bool no_delay,
			  int num_cqe_dma_coalesce);

int beiscsi_cmd_q_destroy(struct be_ctrl_info *ctrl, struct be_queue_info *q,
			  int type);
int beiscsi_cmd_mccq_create(struct beiscsi_hba *phba,
			struct be_queue_info *mccq,
			struct be_queue_info *cq);

void free_mcc_wrb(struct be_ctrl_info *ctrl, unsigned int tag);

int beiscsi_modify_eq_delay(struct beiscsi_hba *phba, struct be_set_eqd *,
			    int num);
int beiscsi_mccq_compl_wait(struct beiscsi_hba *phba,
			    unsigned int tag,
			    struct be_mcc_wrb **wrb,
			    struct be_dma_mem *mbx_cmd_mem);
int __beiscsi_mcc_compl_status(struct beiscsi_hba *phba,
			       unsigned int tag,
			       struct be_mcc_wrb **wrb,
			       struct be_dma_mem *mbx_cmd_mem);
struct be_mcc_wrb *wrb_from_mbox(struct be_dma_mem *mbox_mem);
void be_mcc_notify(struct beiscsi_hba *phba, unsigned int tag);
struct be_mcc_wrb *alloc_mcc_wrb(struct beiscsi_hba *phba,
				 unsigned int *ref_tag);
void beiscsi_process_async_event(struct beiscsi_hba *phba,
				struct be_mcc_compl *compl);
int beiscsi_process_mcc_compl(struct be_ctrl_info *ctrl,
			      struct be_mcc_compl *compl);

int be_cmd_create_default_pdu_queue(struct be_ctrl_info *ctrl,
				    struct be_queue_info *cq,
				    struct be_queue_info *dq, int length,
				    int entry_size, uint8_t is_header,
				    uint8_t ulp_num);

int be_cmd_iscsi_post_template_hdr(struct be_ctrl_info *ctrl,
				    struct be_dma_mem *q_mem);

int be_cmd_iscsi_remove_template_hdr(struct be_ctrl_info *ctrl);

int be_cmd_iscsi_post_sgl_pages(struct be_ctrl_info *ctrl,
				struct be_dma_mem *q_mem, u32 page_offset,
				u32 num_pages);

int be_cmd_wrbq_create(struct be_ctrl_info *ctrl, struct be_dma_mem *q_mem,
		       struct be_queue_info *wrbq,
		       struct hwi_wrb_context *pwrb_context,
		       uint8_t ulp_num);

/* Configuration Functions */
int be_cmd_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);

int beiscsi_check_supported_fw(struct be_ctrl_info *ctrl,
			       struct beiscsi_hba *phba);

int beiscsi_get_fw_config(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);

int beiscsi_get_port_name(struct be_ctrl_info *ctrl, struct beiscsi_hba *phba);

int beiscsi_set_uer_feature(struct beiscsi_hba *phba);
int beiscsi_set_host_data(struct beiscsi_hba *phba);

struct be_default_pdu_context {} __packed;

struct amap_be_default_pdu_context {} __packed;

struct amap_default_pdu_context_ext {} __packed;

struct be_defq_create_req {} __packed;

struct be_defq_create_resp {} __packed;

struct be_post_template_pages_req {} __packed;

struct be_remove_template_pages_req {} __packed;

struct be_post_sgl_pages_req {} __packed;

struct be_wrbq_create_req {} __packed;

struct be_wrbq_create_resp {} __packed;

#define SOL_CID_MASK
#define SOL_CODE_MASK
#define SOL_WRB_INDEX_MASK
#define SOL_CMD_WND_MASK
#define SOL_RES_CNT_MASK
#define SOL_EXP_CMD_SN_MASK
#define SOL_HW_STS_MASK
#define SOL_STS_MASK
#define SOL_RESP_MASK
#define SOL_FLAGS_MASK
#define SOL_S_MASK

struct sol_cqe {};

struct amap_sol_cqe {} __packed;

#define SOL_ICD_INDEX_MASK
struct amap_sol_cqe_ring {} __packed;

struct amap_sol_cqe_v2 {} __packed;

struct common_sol_cqe {};

/*** iSCSI ack/driver message completions ***/
struct amap_it_dmsg_cqe {} __packed;

struct amap_it_dmsg_cqe_v2 {} __packed;


/**
 * Post WRB Queue Doorbell Register used by the host Storage
 * stack to notify the
 * controller of a posted Work Request Block
 */
#define DB_WRB_POST_CID_MASK
#define DB_DEF_PDU_WRB_INDEX_MASK

#define DB_DEF_PDU_WRB_INDEX_SHIFT
#define DB_DEF_PDU_NUM_POSTED_SHIFT

struct fragnum_bits_for_sgl_cra_in {} __packed;

struct iscsi_cleanup_req {} __packed;

struct iscsi_cleanup_req_v1 {} __packed;

struct eq_delay {} __packed;

struct be_eq_delay_params_in {} __packed;

struct tcp_connect_and_offload_in {} __packed;

struct tcp_connect_and_offload_in_v1 {} __packed;

struct tcp_connect_and_offload_out {} __packed;

#define DB_DEF_PDU_RING_ID_MASK
#define DB_DEF_PDU_CQPROC_MASK
#define DB_DEF_PDU_REARM_SHIFT
#define DB_DEF_PDU_EVENT_SHIFT
#define DB_DEF_PDU_CQPROC_SHIFT

struct be_invalidate_connection_params_in {} __packed;

struct be_invalidate_connection_params_out {} __packed;

be_invalidate_connection_params __packed;

struct be_tcp_upload_params_in {} __packed;

struct be_tcp_upload_params_out {} __packed;

be_tcp_upload_params __packed;

struct be_ulp_fw_cfg {};

struct be_ulp_chain_icd {};

struct be_fw_cfg {} __packed;

struct be_cmd_get_all_if_id_req {} __packed;

struct be_cmd_get_port_name {} __packed;

#define ISCSI_OPCODE_SCSI_DATA_OUT
#define OPCODE_COMMON_NTWK_LINK_STATUS_QUERY
#define OPCODE_COMMON_MODIFY_EQ_DELAY
#define OPCODE_COMMON_ISCSI_CLEANUP
#define OPCODE_COMMON_TCP_UPLOAD
#define OPCODE_COMMON_ISCSI_TCP_CONNECT_AND_OFFLOAD
#define OPCODE_COMMON_ISCSI_ERROR_RECOVERY_INVALIDATE_COMMANDS
#define OPCODE_ISCSI_INI_CFG_GET_HBA_NAME
#define OPCODE_ISCSI_INI_CFG_SET_HBA_NAME
#define OPCODE_ISCSI_INI_SESSION_GET_A_SESSION
#define OPCODE_ISCSI_INI_SESSION_LOGOUT_TARGET
#define OPCODE_ISCSI_INI_DRIVER_REOPEN_ALL_SESSIONS
#define OPCODE_ISCSI_INI_DRIVER_OFFLOAD_SESSION
#define OPCODE_ISCSI_INI_DRIVER_INVALIDATE_CONNECTION
#define OPCODE_ISCSI_INI_BOOT_GET_BOOT_TARGET
#define OPCODE_COMMON_WRITE_FLASH
#define OPCODE_COMMON_READ_FLASH

#define CMD_ISCSI_COMMAND_INVALIDATE

#define INI_WR_CMD
#define INI_TMF_CMD
#define INI_NOPOUT_CMD
#define INI_RD_CMD
#define TGT_CTX_UPDT_CMD
#define TGT_DM_CMD

/* Returns the number of items in the field array. */
#define BE_NUMBER_OF_FIELD(_type_, _field_)\

/**
 * Different types of iSCSI completions to host driver for both initiator
 * and taget mode
 * of operation.
 */
#define SOL_CMD_COMPLETE
#define SOL_CMD_KILLED_DATA_DIGEST_ERR
#define CXN_KILLED_PDU_SIZE_EXCEEDS_DSL
#define CXN_KILLED_BURST_LEN_MISMATCH
#define CXN_KILLED_AHS_RCVD
#define CXN_KILLED_HDR_DIGEST_ERR
#define CXN_KILLED_UNKNOWN_HDR
#define CXN_KILLED_STALE_ITT_TTT_RCVD
#define CXN_KILLED_INVALID_ITT_TTT_RCVD
#define CXN_KILLED_RST_RCVD
#define CXN_KILLED_TIMED_OUT
#define CXN_KILLED_RST_SENT
#define CXN_KILLED_FIN_RCVD
#define CXN_KILLED_BAD_UNSOL_PDU_RCVD
#define CXN_KILLED_BAD_WRB_INDEX_ERROR
#define CXN_KILLED_OVER_RUN_RESIDUAL
#define CXN_KILLED_UNDER_RUN_RESIDUAL
#define CMD_KILLED_INVALID_STATSN_RCVD
#define CMD_KILLED_INVALID_R2T_RCVD
#define CMD_CXN_KILLED_LUN_INVALID
#define CMD_CXN_KILLED_ICD_INVALID
#define CMD_CXN_KILLED_ITT_INVALID
#define CMD_CXN_KILLED_SEQ_OUTOFORDER
#define CMD_CXN_KILLED_INVALID_DATASN_RCVD
#define CXN_INVALIDATE_NOTIFY
#define CXN_INVALIDATE_INDEX_NOTIFY
#define CMD_INVALIDATED_NOTIFY
#define UNSOL_HDR_NOTIFY
#define UNSOL_DATA_NOTIFY
#define UNSOL_DATA_DIGEST_ERROR_NOTIFY
#define DRIVERMSG_NOTIFY
#define CXN_KILLED_CMND_DATA_NOT_ON_SAME_CONN
#define SOL_CMD_KILLED_DIF_ERR
#define CXN_KILLED_SYN_RCVD
#define CXN_KILLED_IMM_DATA_RCVD

void be_wrb_hdr_prepare(struct be_mcc_wrb *wrb, u32 payload_len,
			bool embedded, u8 sge_cnt);

void be_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
			u8 subsystem, u8 opcode, u32 cmd_len);
#endif /* !BEISCSI_CMDS_H */