linux/drivers/scsi/qla2xxx/qla_target.h

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *  Copyright (C) 2004 - 2010 Vladislav Bolkhovitin <[email protected]>
 *  Copyright (C) 2004 - 2005 Leonid Stoljar
 *  Copyright (C) 2006 Nathaniel Clark <[email protected]>
 *  Copyright (C) 2007 - 2010 ID7 Ltd.
 *
 *  Forward port and refactoring to modern qla2xxx and target/configfs
 *
 *  Copyright (C) 2010-2011 Nicholas A. Bellinger <[email protected]>
 *
 *  Additional file for the target driver support.
 */
/*
 * This is the global def file that is useful for including from the
 * target portion.
 */

#ifndef __QLA_TARGET_H
#define __QLA_TARGET_H

#include "qla_def.h"
#include "qla_dsd.h"

/*
 * Must be changed on any change in any initiator visible interfaces or
 * data in the target add-on
 */
#define QLA2XXX_TARGET_MAGIC

/*
 * Must be changed on any change in any target visible interfaces or
 * data in the initiator
 */
#define QLA2XXX_INITIATOR_MAGIC

#define QLA2XXX_INI_MODE_STR_EXCLUSIVE
#define QLA2XXX_INI_MODE_STR_DISABLED
#define QLA2XXX_INI_MODE_STR_ENABLED
#define QLA2XXX_INI_MODE_STR_DUAL

#define QLA2XXX_INI_MODE_EXCLUSIVE
#define QLA2XXX_INI_MODE_DISABLED
#define QLA2XXX_INI_MODE_ENABLED
#define QLA2XXX_INI_MODE_DUAL

#define QLA2XXX_COMMAND_COUNT_INIT
#define QLA2XXX_IMMED_NOTIFY_COUNT_INIT

/*
 * Used to mark which completion handles (for RIO Status's) are for CTIO's
 * vs. regular (non-target) info. This is checked for in
 * qla2x00_process_response_queue() to see if a handle coming back in a
 * multi-complete should come to the tgt driver or be handled there by qla2xxx
 */
#define CTIO_COMPLETION_HANDLE_MARK
#if (CTIO_COMPLETION_HANDLE_MARK <= DEFAULT_OUTSTANDING_COMMANDS)
#error "CTIO_COMPLETION_HANDLE_MARK not larger than "
	"DEFAULT_OUTSTANDING_COMMANDS"
#endif
#define HANDLE_IS_CTIO_COMP(h)

/* Used to mark CTIO as intermediate */
#define CTIO_INTERMEDIATE_HANDLE_MARK
#define QLA_TGT_NULL_HANDLE

#define QLA_TGT_HANDLE_MASK
#define QLA_QPID_HANDLE_MASK
#define QLA_CMD_HANDLE_MASK
#define QLA_TGT_SKIP_HANDLE

#define QLA_QPID_HANDLE_SHIFT
#define GET_QID(_h)


#ifndef OF_SS_MODE_0
/*
 * ISP target entries - Flags bit definitions.
 */
#define OF_SS_MODE_0
#define OF_SS_MODE_1
#define OF_SS_MODE_2
#define OF_SS_MODE_3

#define OF_EXPL_CONF
#define OF_DATA_IN
					/*  (data from target to initiator) */
#define OF_DATA_OUT
					/*  (data from initiator to target) */
#define OF_NO_DATA
#define OF_INC_RC
#define OF_FAST_POST
#define OF_CONF_REQ
#define OF_TERM_EXCH
#define OF_SSTS
#endif

#ifndef QLA_TGT_DATASEGS_PER_CMD32
#define QLA_TGT_DATASEGS_PER_CMD32
#define QLA_TGT_DATASEGS_PER_CONT32
#define QLA_TGT_MAX_SG32(ql)

#define QLA_TGT_DATASEGS_PER_CMD64
#define QLA_TGT_DATASEGS_PER_CONT64
#define QLA_TGT_MAX_SG64(ql)
#endif

#ifndef QLA_TGT_DATASEGS_PER_CMD_24XX
#define QLA_TGT_DATASEGS_PER_CMD_24XX
#define QLA_TGT_DATASEGS_PER_CONT_24XX
#define QLA_TGT_MAX_SG_24XX(ql)
#endif

#define GET_TARGET_ID(ha, iocb)

#ifndef NOTIFY_ACK_TYPE
#define NOTIFY_ACK_TYPE
/*
 * ISP queue -	notify acknowledge entry structure definition.
 *		This is sent to the ISP from the target driver.
 */
struct nack_to_isp {} __packed;
#define NOTIFY_ACK_FLAGS_FCSP
#define NOTIFY_ACK_FLAGS_TERMINATE
#define NOTIFY_ACK_SRR_FLAGS_ACCEPT
#define NOTIFY_ACK_SRR_FLAGS_REJECT

#define NOTIFY_ACK_SRR_REJECT_REASON_UNABLE_TO_PERFORM

#define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL
#define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_UNABLE_TO_SUPPLY_DATA

#define NOTIFY_ACK_SUCCESS
#endif

#ifndef ACCEPT_TGT_IO_TYPE
#define ACCEPT_TGT_IO_TYPE
#endif

#ifndef CONTINUE_TGT_IO_TYPE
#define CONTINUE_TGT_IO_TYPE
/*
 * ISP queue -	Continue Target I/O (CTIO) entry for status mode 0 structure.
 *		This structure is sent to the ISP 2xxx from target driver.
 */
struct ctio_to_2xxx {} __packed;
#define ATIO_PATH_INVALID
#define ATIO_CANT_PROV_CAP
#define ATIO_CDB_VALID

#define ATIO_EXEC_READ
#define ATIO_EXEC_WRITE
#endif

#ifndef CTIO_A64_TYPE
#define CTIO_A64_TYPE
#define CTIO_SUCCESS
#define CTIO_ABORTED
#define CTIO_INVALID_RX_ID
#define CTIO_TIMEOUT
#define CTIO_DIF_ERROR
#define CTIO_LIP_RESET
#define CTIO_TARGET_RESET
#define CTIO_PORT_UNAVAILABLE
#define CTIO_PORT_LOGGED_OUT
#define CTIO_PORT_CONF_CHANGED
#define CTIO_SRR_RECEIVED
#define CTIO_FAST_AUTH_ERR
#define CTIO_FAST_INCOMP_PAD_LEN
#define CTIO_FAST_INVALID_REQ
#define CTIO_FAST_SPI_ERR
#endif

#ifndef CTIO_RET_TYPE
#define CTIO_RET_TYPE
#define ATIO_TYPE7
#endif

struct fcp_hdr {};

struct fcp_hdr_le {};

#define F_CTL_EXCH_CONTEXT_RESP
#define F_CTL_SEQ_CONTEXT_RESIP
#define F_CTL_LAST_SEQ
#define F_CTL_END_SEQ
#define F_CTL_SEQ_INITIATIVE

#define R_CTL_BASIC_LINK_SERV
#define R_CTL_B_ACC
#define R_CTL_B_RJT

struct atio7_fcp_cmnd {} __packed;

/*
 * ISP queue -	Accept Target I/O (ATIO) type entry IOCB structure.
 *		This is sent from the ISP to the target driver.
 */
struct atio_from_isp {} __packed;

static inline int fcpcmd_is_corrupted(struct atio *atio)
{}

/* adjust corrupted atio so we won't trip over the same entry again. */
static inline void adjust_corrupted_atio(struct atio_from_isp *atio)
{}

static inline int get_datalen_for_atio(struct atio_from_isp *atio)
{}

#define CTIO_TYPE7

/*
 * ISP queue -	Continue Target I/O (ATIO) type 7 entry (for 24xx) structure.
 *		This structure is sent to the ISP 24xx from the target driver.
 */

struct ctio7_to_24xx {} __packed;

/*
 * ISP queue - CTIO type 7 from ISP 24xx to target driver
 * returned entry structure.
 */
struct ctio7_from_24xx {} __packed;

/* CTIO7 flags values */
#define CTIO7_FLAGS_SEND_STATUS
#define CTIO7_FLAGS_TERMINATE
#define CTIO7_FLAGS_CONFORM_REQ
#define CTIO7_FLAGS_DONT_RET_CTIO
#define CTIO7_FLAGS_STATUS_MODE_0
#define CTIO7_FLAGS_STATUS_MODE_1
#define CTIO7_FLAGS_STATUS_MODE_2
#define CTIO7_FLAGS_EXPLICIT_CONFORM
#define CTIO7_FLAGS_CONFIRM_SATISF
#define CTIO7_FLAGS_DSD_PTR
#define CTIO7_FLAGS_DATA_IN
#define CTIO7_FLAGS_DATA_OUT

#define ELS_PLOGI
#define ELS_FLOGI
#define ELS_LOGO
#define ELS_PRLI
#define ELS_PRLO
#define ELS_TPRLO
#define ELS_PDISC
#define ELS_ADISC

/*
 *CTIO Type CRC_2 IOCB
 */
struct ctio_crc2_to_fw {};

/* CTIO Type CRC_x Status IOCB */
struct ctio_crc_from_fw {} __packed;

/*
 * ISP queue - ABTS received/response entries structure definition for 24xx.
 */
#define ABTS_RECV_24XX
#define ABTS_RESP_24XX

/*
 * ISP queue -	ABTS received IOCB entry structure definition for 24xx.
 *		The ABTS BLS received from the wire is sent to the
 *		target driver by the ISP 24xx.
 *		The IOCB is placed on the response queue.
 */
struct abts_recv_from_24xx {} __packed;

#define ABTS_PARAM_ABORT_SEQ

struct ba_acc_le {} __packed;

struct ba_rjt_le {} __packed;

/*
 * ISP queue -	ABTS Response IOCB entry structure definition for 24xx.
 *		The ABTS response to the ABTS received is sent by the
 *		target driver to the ISP 24xx.
 *		The IOCB is placed on the request queue.
 */
struct abts_resp_to_24xx {} __packed;

/*
 * ISP queue -	ABTS Response IOCB from ISP24xx Firmware entry structure.
 *		The ABTS response with completion status to the ABTS response
 *		(sent by the target driver to the ISP 24xx) is sent by the
 *		ISP24xx firmware to the target driver.
 *		The IOCB is placed on the response queue.
 */
struct abts_resp_from_24xx_fw {} __packed;

/********************************************************************\
 * Type Definitions used by initiator & target halves
\********************************************************************/

struct qla_tgt_mgmt_cmd;
struct fc_port;
struct qla_tgt_cmd;

/*
 * This structure provides a template of function calls that the
 * target driver (from within qla_target.c) can issue to the
 * target module (tcm_qla2xxx).
 */
struct qla_tgt_func_tmpl {};

int qla2x00_wait_for_hba_online(struct scsi_qla_host *);

#include <target/target_core_base.h>

#define QLA_TGT_TIMEOUT

#define QLA_TGT_MAX_HW_PENDING_TIME

/* Immediate notify status constants */
#define IMM_NTFY_LIP_RESET
#define IMM_NTFY_LIP_LINK_REINIT
#define IMM_NTFY_IOCB_OVERFLOW
#define IMM_NTFY_ABORT_TASK
#define IMM_NTFY_PORT_LOGOUT
#define IMM_NTFY_PORT_CONFIG
#define IMM_NTFY_GLBL_TPRLO
#define IMM_NTFY_GLBL_LOGO
#define IMM_NTFY_RESOURCE
#define IMM_NTFY_MSG_RX
#define IMM_NTFY_SRR
#define IMM_NTFY_ELS

/* Immediate notify task flags */
#define IMM_NTFY_TASK_MGMT_SHIFT

#define QLA_TGT_CLEAR_ACA
#define QLA_TGT_TARGET_RESET
#define QLA_TGT_LUN_RESET
#define QLA_TGT_CLEAR_TS
#define QLA_TGT_ABORT_TS
#define QLA_TGT_ABORT_ALL_SESS
#define QLA_TGT_ABORT_ALL
#define QLA_TGT_NEXUS_LOSS_SESS
#define QLA_TGT_NEXUS_LOSS
#define QLA_TGT_ABTS
#define QLA_TGT_2G_ABORT_TASK

/* Notify Acknowledge flags */
#define NOTIFY_ACK_RES_COUNT
#define NOTIFY_ACK_CLEAR_LIP_RESET
#define NOTIFY_ACK_TM_RESP_CODE_VALID

/* Command's states */
#define QLA_TGT_STATE_NEW
#define QLA_TGT_STATE_NEED_DATA
#define QLA_TGT_STATE_DATA_IN
#define QLA_TGT_STATE_PROCESSED

/* ATIO task_codes field */
#define ATIO_SIMPLE_QUEUE
#define ATIO_HEAD_OF_QUEUE
#define ATIO_ORDERED_QUEUE
#define ATIO_ACA_QUEUE
#define ATIO_UNTAGGED

/* TM failed response codes, see FCP (9.4.11 FCP_RSP_INFO) */
#define FC_TM_SUCCESS
#define FC_TM_BAD_FCP_DATA
#define FC_TM_BAD_CMD
#define FC_TM_FCP_DATA_MISMATCH
#define FC_TM_REJECT
#define FC_TM_FAILED

#define QLA_TGT_SENSE_VALID(sense)

struct qla_port_24xx_data {};

struct qla_qpair_hint {};

struct qla_tgt {};

struct qla_tgt_sess_op {};

enum trace_flags {};

struct qla_tgt_cmd {};

struct qla_tgt_sess_work_param {};

struct qla_tgt_mgmt_cmd {};

struct qla_tgt_prm {};

/* Check for Switch reserved address */
#define IS_SW_RESV_ADDR(_s_id)

#define QLA_TGT_XMIT_DATA
#define QLA_TGT_XMIT_STATUS
#define QLA_TGT_XMIT_ALL


extern struct qla_tgt_data qla_target;

/*
 * Function prototypes for qla_target.c logic used by qla2xxx LLD code.
 */
extern int qlt_add_target(struct qla_hw_data *, struct scsi_qla_host *);
extern int qlt_remove_target(struct qla_hw_data *, struct scsi_qla_host *);
extern int qlt_lport_register(void *, u64, u64, u64,
			int (*callback)(struct scsi_qla_host *, void *, u64, u64));
extern void qlt_lport_deregister(struct scsi_qla_host *);
extern void qlt_unreg_sess(struct fc_port *);
extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *);
extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int);
extern int __init qlt_init(void);
extern void qlt_exit(void);
extern void qlt_free_session_done(struct work_struct *);
/*
 * This macro is used during early initializations when host->active_mode
 * is not set. Right now, ha value is ignored.
 */
#define QLA_TGT_MODE_ENABLED()

extern int ql2x_ini_mode;

static inline bool qla_tgt_mode_enabled(struct scsi_qla_host *ha)
{}

static inline bool qla_ini_mode_enabled(struct scsi_qla_host *ha)
{}

static inline bool qla_dual_mode_enabled(struct scsi_qla_host *ha)
{}

static inline uint32_t sid_to_key(const be_id_t s_id)
{}

/*
 * Exported symbols from qla_target.c LLD logic used by qla2xxx code..
 */
extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, struct rsp_que *,
	response_t *);
extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *);
extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t);
extern int qlt_abort_cmd(struct qla_tgt_cmd *);
extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);
extern void qlt_async_event(uint16_t, struct scsi_qla_host *, uint16_t *);
extern void qlt_enable_vha(struct scsi_qla_host *);
extern void qlt_vport_create(struct scsi_qla_host *, struct qla_hw_data *);
extern u8 qlt_rff_id(struct scsi_qla_host *);
extern void qlt_init_atio_q_entries(struct scsi_qla_host *);
extern void qlt_24xx_process_atio_queue(struct scsi_qla_host *, uint8_t);
extern void qlt_24xx_config_rings(struct scsi_qla_host *);
extern void qlt_24xx_config_nvram_stage1(struct scsi_qla_host *,
	struct nvram_24xx *);
extern void qlt_24xx_config_nvram_stage2(struct scsi_qla_host *,
	struct init_cb_24xx *);
extern void qlt_81xx_config_nvram_stage2(struct scsi_qla_host *,
	struct init_cb_81xx *);
extern void qlt_81xx_config_nvram_stage1(struct scsi_qla_host *,
	struct nvram_81xx *);
extern void qlt_modify_vp_config(struct scsi_qla_host *,
	struct vp_config_entry_24xx *);
extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *);
extern int qlt_mem_alloc(struct qla_hw_data *);
extern void qlt_mem_free(struct qla_hw_data *);
extern int qlt_stop_phase1(struct qla_tgt *);
extern void qlt_stop_phase2(struct qla_tgt *);
extern irqreturn_t qla83xx_msix_atio_q(int, void *);
extern void qlt_83xx_iospace_config(struct qla_hw_data *);
extern int qlt_free_qfull_cmds(struct qla_qpair *);
extern void qlt_logo_completion_handler(fc_port_t *, int);
extern void qlt_do_generation_tick(struct scsi_qla_host *, int *);

void qlt_send_resp_ctio(struct qla_qpair *, struct qla_tgt_cmd *, uint8_t,
    uint8_t, uint8_t, uint8_t);

#endif /* __QLA_TARGET_H */