#include <linux/module.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/blkdev.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/list.h>
#include <linux/workqueue.h>
#include <asm/unaligned.h>
#include <scsi/scsi.h>
#include <scsi/scsi_host.h>
#include <scsi/scsi_tcq.h>
#include "qla_def.h"
#include "qla_target.h"
static int ql2xtgt_tape_enable;
module_param(ql2xtgt_tape_enable, int, S_IRUGO|S_IWUSR);
MODULE_PARM_DESC(…) …;
static char *qlini_mode = …;
module_param(qlini_mode, charp, S_IRUGO);
MODULE_PARM_DESC(…) …;
int ql2xuctrlirq = …;
module_param(ql2xuctrlirq, int, 0644);
MODULE_PARM_DESC(…) …;
int ql2x_ini_mode = …;
static int qla_sam_status = …;
static int tc_sam_status = …;
enum fcp_resp_rsp_codes { … };
#define FCP_PTA_SIMPLE …
#define FCP_PTA_HEADQ …
#define FCP_PTA_ORDERED …
#define FCP_PTA_ACA …
#define FCP_PTA_MASK …
#define FCP_PRI_SHIFT …
#define FCP_PRI_RESVD_MASK …
static void qlt_24xx_atio_pkt(struct scsi_qla_host *ha,
struct atio_from_isp *pkt, uint8_t);
static void qlt_response_pkt(struct scsi_qla_host *ha, struct rsp_que *rsp,
response_t *pkt);
static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
int fn, void *iocb, int flags);
static void qlt_send_term_exchange(struct qla_qpair *, struct qla_tgt_cmd
*cmd, struct atio_from_isp *atio, int ha_locked, int ul_abort);
static void qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
struct atio_from_isp *atio, uint16_t status, int qfull);
static void qlt_disable_vha(struct scsi_qla_host *vha);
static void qlt_clear_tgt_db(struct qla_tgt *tgt);
static void qlt_send_notify_ack(struct qla_qpair *qpair,
struct imm_ntfy_from_isp *ntfy,
uint32_t add_flags, uint16_t resp_code, int resp_code_valid,
uint16_t srr_flags, uint16_t srr_reject_code, uint8_t srr_explan);
static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *imm, int ha_locked);
static struct fc_port *qlt_create_sess(struct scsi_qla_host *vha,
fc_port_t *fcport, bool local);
void qlt_unreg_sess(struct fc_port *sess);
static void qlt_24xx_handle_abts(struct scsi_qla_host *,
struct abts_recv_from_24xx *);
static void qlt_send_busy(struct qla_qpair *, struct atio_from_isp *,
uint16_t);
static int qlt_check_reserve_free_req(struct qla_qpair *qpair, uint32_t);
static inline uint32_t qlt_make_handle(struct qla_qpair *);
static struct kmem_cache *qla_tgt_mgmt_cmd_cachep;
struct kmem_cache *qla_tgt_plogi_cachep;
static mempool_t *qla_tgt_mgmt_cmd_mempool;
static struct workqueue_struct *qla_tgt_wq;
static DEFINE_MUTEX(qla_tgt_mutex);
static LIST_HEAD(qla_tgt_glist);
static const char *prot_op_str(u32 prot_op)
{ … }
void qlt_do_generation_tick(struct scsi_qla_host *vha, int *dest)
{ … }
static inline int qlt_issue_marker(struct scsi_qla_host *vha, int vha_locked)
{ … }
struct scsi_qla_host *qla_find_host_by_d_id(struct scsi_qla_host *vha,
be_id_t d_id)
{ … }
static inline void qlt_incr_num_pend_cmds(struct scsi_qla_host *vha)
{ … }
static inline void qlt_decr_num_pend_cmds(struct scsi_qla_host *vha)
{ … }
static void qlt_queue_unknown_atio(scsi_qla_host_t *vha,
struct atio_from_isp *atio, uint8_t ha_locked)
{ … }
static void qlt_try_to_dequeue_unknown_atios(struct scsi_qla_host *vha,
uint8_t ha_locked)
{ … }
void qlt_unknown_atio_work_fn(struct work_struct *work)
{ … }
static bool qlt_24xx_atio_pkt_all_vps(struct scsi_qla_host *vha,
struct atio_from_isp *atio, uint8_t ha_locked)
{ … }
void qlt_response_pkt_all_vps(struct scsi_qla_host *vha,
struct rsp_que *rsp, response_t *pkt)
{ … }
static int qla24xx_post_nack_work(struct scsi_qla_host *vha, fc_port_t *fcport,
struct imm_ntfy_from_isp *ntfy, int type)
{ … }
static void qla2x00_async_nack_sp_done(srb_t *sp, int res)
{ … }
int qla24xx_async_notify_ack(scsi_qla_host_t *vha, fc_port_t *fcport,
struct imm_ntfy_from_isp *ntfy, int type)
{ … }
void qla24xx_do_nack_work(struct scsi_qla_host *vha, struct qla_work_evt *e)
{ … }
void qla24xx_delete_sess_fn(struct work_struct *work)
{ … }
void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport)
{ … }
static struct qlt_plogi_ack_t *
qlt_plogi_ack_find_add(struct scsi_qla_host *vha, port_id_t *id,
struct imm_ntfy_from_isp *iocb)
{ … }
void qlt_plogi_ack_unref(struct scsi_qla_host *vha,
struct qlt_plogi_ack_t *pla)
{ … }
void
qlt_plogi_ack_link(struct scsi_qla_host *vha, struct qlt_plogi_ack_t *pla,
struct fc_port *sess, enum qlt_plogi_link_t link)
{ … }
qlt_port_logo_t;
static void
qlt_send_first_logo(struct scsi_qla_host *vha, qlt_port_logo_t *logo)
{ … }
void qlt_free_session_done(struct work_struct *work)
{ … }
void qlt_unreg_sess(struct fc_port *sess)
{ … }
EXPORT_SYMBOL(…);
static int qlt_reset(struct scsi_qla_host *vha, void *iocb, int mcmd)
{ … }
static void qla24xx_chk_fcp_state(struct fc_port *sess)
{ … }
void qlt_schedule_sess_for_deletion(struct fc_port *sess)
{ … }
static void qlt_clear_tgt_db(struct qla_tgt *tgt)
{ … }
static int qla24xx_get_loop_id(struct scsi_qla_host *vha, be_id_t s_id,
uint16_t *loop_id)
{ … }
static struct fc_port *qlt_create_sess(
struct scsi_qla_host *vha,
fc_port_t *fcport,
bool local)
{ … }
void
qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport, int max_gen)
{ … }
static inline int test_tgt_sess_count(struct qla_tgt *tgt)
{ … }
int qlt_stop_phase1(struct qla_tgt *tgt)
{ … }
EXPORT_SYMBOL(…);
void qlt_stop_phase2(struct qla_tgt *tgt)
{ … }
EXPORT_SYMBOL(…);
static void qlt_release(struct qla_tgt *tgt)
{ … }
static int qlt_sched_sess_work(struct qla_tgt *tgt, int type,
const void *param, unsigned int param_size)
{ … }
static void qlt_send_notify_ack(struct qla_qpair *qpair,
struct imm_ntfy_from_isp *ntfy,
uint32_t add_flags, uint16_t resp_code, int resp_code_valid,
uint16_t srr_flags, uint16_t srr_reject_code, uint8_t srr_explan)
{ … }
static int qlt_build_abts_resp_iocb(struct qla_tgt_mgmt_cmd *mcmd)
{ … }
static void qlt_24xx_send_abts_resp(struct qla_qpair *qpair,
struct abts_recv_from_24xx *abts, uint32_t status,
bool ids_reversed)
{ … }
static void qlt_24xx_retry_term_exchange(struct scsi_qla_host *vha,
struct qla_qpair *qpair, response_t *pkt, struct qla_tgt_mgmt_cmd *mcmd)
{ … }
static void abort_cmds_for_lun(struct scsi_qla_host *vha, u64 lun, be_id_t s_id)
{ … }
static struct qla_qpair_hint *qlt_find_qphint(struct scsi_qla_host *vha,
uint64_t unpacked_lun)
{ … }
static void qlt_do_tmr_work(struct work_struct *work)
{ … }
static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha,
struct abts_recv_from_24xx *abts, struct fc_port *sess)
{ … }
static void qlt_24xx_handle_abts(struct scsi_qla_host *vha,
struct abts_recv_from_24xx *abts)
{ … }
static void qlt_24xx_send_task_mgmt_ctio(struct qla_qpair *qpair,
struct qla_tgt_mgmt_cmd *mcmd, uint32_t resp_code)
{ … }
void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *mcmd)
{ … }
EXPORT_SYMBOL(…);
void qlt_send_resp_ctio(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd,
uint8_t scsi_status, uint8_t sense_key, uint8_t asc, uint8_t ascq)
{ … }
void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd)
{ … }
EXPORT_SYMBOL(…);
static int qlt_pci_map_calc_cnt(struct qla_tgt_prm *prm)
{ … }
static void qlt_unmap_sg(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd)
{ … }
static int qlt_check_reserve_free_req(struct qla_qpair *qpair,
uint32_t req_cnt)
{ … }
static inline void *qlt_get_req_pkt(struct req_que *req)
{ … }
static inline uint32_t qlt_make_handle(struct qla_qpair *qpair)
{ … }
static int qlt_24xx_build_ctio_pkt(struct qla_qpair *qpair,
struct qla_tgt_prm *prm)
{ … }
static void qlt_load_cont_data_segments(struct qla_tgt_prm *prm)
{ … }
static void qlt_load_data_segments(struct qla_tgt_prm *prm)
{ … }
static inline int qlt_has_data(struct qla_tgt_cmd *cmd)
{ … }
static void qlt_print_dif_err(struct qla_tgt_prm *prm)
{ … }
static int qlt_pre_xmit_response(struct qla_tgt_cmd *cmd,
struct qla_tgt_prm *prm, int xmit_type, uint8_t scsi_status,
uint32_t *full_req_cnt)
{ … }
static inline int qlt_need_explicit_conf(struct qla_tgt_cmd *cmd,
int sending_sense)
{ … }
static void qlt_24xx_init_ctio_to_isp(struct ctio7_to_24xx *ctio,
struct qla_tgt_prm *prm)
{ … }
static inline int
qlt_hba_err_chk_enabled(struct se_cmd *se_cmd)
{ … }
static inline int
qla_tgt_ref_mask_check(struct se_cmd *se_cmd)
{ … }
static void
qla_tgt_set_dif_tags(struct qla_tgt_cmd *cmd, struct crc_context *ctx,
uint16_t *pfw_prot_opts)
{ … }
static inline int
qlt_build_ctio_crc2_pkt(struct qla_qpair *qpair, struct qla_tgt_prm *prm)
{ … }
int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type,
uint8_t scsi_status)
{ … }
EXPORT_SYMBOL(…);
int qlt_rdy_to_xfer(struct qla_tgt_cmd *cmd)
{ … }
EXPORT_SYMBOL(…);
static void
qlt_handle_dif_error(struct qla_qpair *qpair, struct qla_tgt_cmd *cmd,
struct ctio_crc_from_fw *sts)
{ … }
static int __qlt_send_term_imm_notif(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *ntfy)
{ … }
static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *imm, int ha_locked)
{ … }
static int __qlt_send_term_exchange(struct qla_qpair *qpair,
struct qla_tgt_cmd *cmd,
struct atio_from_isp *atio)
{ … }
static void qlt_send_term_exchange(struct qla_qpair *qpair,
struct qla_tgt_cmd *cmd, struct atio_from_isp *atio, int ha_locked,
int ul_abort)
{ … }
static void qlt_init_term_exchange(struct scsi_qla_host *vha)
{ … }
static void qlt_chk_exch_leak_thresh_hold(struct scsi_qla_host *vha)
{ … }
int qlt_abort_cmd(struct qla_tgt_cmd *cmd)
{ … }
EXPORT_SYMBOL(…);
void qlt_free_cmd(struct qla_tgt_cmd *cmd)
{ … }
EXPORT_SYMBOL(…);
static int qlt_term_ctio_exchange(struct qla_qpair *qpair, void *ctio,
struct qla_tgt_cmd *cmd, uint32_t status)
{ … }
static void *qlt_ctio_to_cmd(struct scsi_qla_host *vha,
struct rsp_que *rsp, uint32_t handle, void *ctio)
{ … }
static void qlt_do_ctio_completion(struct scsi_qla_host *vha,
struct rsp_que *rsp, uint32_t handle, uint32_t status, void *ctio)
{ … }
static inline int qlt_get_fcp_task_attr(struct scsi_qla_host *vha,
uint8_t task_codes)
{ … }
static void __qlt_do_work(struct qla_tgt_cmd *cmd)
{ … }
static void qlt_do_work(struct work_struct *work)
{ … }
void qlt_clr_qp_table(struct scsi_qla_host *vha)
{ … }
static void qlt_assign_qpair(struct scsi_qla_host *vha,
struct qla_tgt_cmd *cmd)
{ … }
static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t *vha,
struct fc_port *sess,
struct atio_from_isp *atio)
{ … }
static int qlt_handle_cmd_for_atio(struct scsi_qla_host *vha,
struct atio_from_isp *atio)
{ … }
static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun,
int fn, void *iocb, int flags)
{ … }
static int qlt_handle_task_mgmt(struct scsi_qla_host *vha, void *iocb)
{ … }
static int __qlt_abort_task(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *iocb, struct fc_port *sess)
{ … }
static int qlt_abort_task(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *iocb)
{ … }
void qlt_logo_completion_handler(fc_port_t *fcport, int rc)
{ … }
struct fc_port *
qlt_find_sess_invalidate_other(scsi_qla_host_t *vha, uint64_t wwn,
port_id_t port_id, uint16_t loop_id, struct fc_port **conflict_sess)
{ … }
static int abort_cmds_for_s_id(struct scsi_qla_host *vha, port_id_t *s_id)
{ … }
static int qlt_handle_login(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *iocb)
{ … }
static int qlt_24xx_handle_els(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *iocb)
{ … }
static void qlt_handle_imm_notify(struct scsi_qla_host *vha,
struct imm_ntfy_from_isp *iocb)
{ … }
static int __qlt_send_busy(struct qla_qpair *qpair,
struct atio_from_isp *atio, uint16_t status)
{ … }
static void
qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
struct atio_from_isp *atio, uint16_t status, int qfull)
{ … }
int
qlt_free_qfull_cmds(struct qla_qpair *qpair)
{ … }
static void
qlt_send_busy(struct qla_qpair *qpair, struct atio_from_isp *atio,
uint16_t status)
{ … }
static int
qlt_chk_qfull_thresh_hold(struct scsi_qla_host *vha, struct qla_qpair *qpair,
struct atio_from_isp *atio, uint8_t ha_locked)
{ … }
static void qlt_24xx_atio_pkt(struct scsi_qla_host *vha,
struct atio_from_isp *atio, uint8_t ha_locked)
{ … }
static int qlt_chk_unresolv_exchg(struct scsi_qla_host *vha,
struct qla_qpair *qpair, struct abts_resp_from_24xx_fw *entry)
{ … }
static void qlt_handle_abts_completion(struct scsi_qla_host *vha,
struct rsp_que *rsp, response_t *pkt)
{ … }
static void qlt_response_pkt(struct scsi_qla_host *vha,
struct rsp_que *rsp, response_t *pkt)
{ … }
void qlt_async_event(uint16_t code, struct scsi_qla_host *vha,
uint16_t *mailbox)
{ … }
static fc_port_t *qlt_get_port_database(struct scsi_qla_host *vha,
uint16_t loop_id)
{ … }
static struct fc_port *qlt_make_local_sess(struct scsi_qla_host *vha,
be_id_t s_id)
{ … }
static void qlt_abort_work(struct qla_tgt *tgt,
struct qla_tgt_sess_work_param *prm)
{ … }
static void qlt_sess_work_fn(struct work_struct *work)
{ … }
int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)
{ … }
int qlt_remove_target(struct qla_hw_data *ha, struct scsi_qla_host *vha)
{ … }
void qla_remove_hostmap(struct qla_hw_data *ha)
{ … }
static void qlt_lport_dump(struct scsi_qla_host *vha, u64 wwpn,
unsigned char *b)
{ … }
int qlt_lport_register(void *target_lport_ptr, u64 phys_wwpn,
u64 npiv_wwpn, u64 npiv_wwnn,
int (*callback)(struct scsi_qla_host *, void *, u64, u64))
{ … }
EXPORT_SYMBOL(…);
void qlt_lport_deregister(struct scsi_qla_host *vha)
{ … }
EXPORT_SYMBOL(…);
void qlt_set_mode(struct scsi_qla_host *vha)
{ … }
static void qlt_clear_mode(struct scsi_qla_host *vha)
{ … }
void
qlt_enable_vha(struct scsi_qla_host *vha)
{ … }
EXPORT_SYMBOL(…);
static void qlt_disable_vha(struct scsi_qla_host *vha)
{ … }
void
qlt_vport_create(struct scsi_qla_host *vha, struct qla_hw_data *ha)
{ … }
u8
qlt_rff_id(struct scsi_qla_host *vha)
{ … }
void
qlt_init_atio_q_entries(struct scsi_qla_host *vha)
{ … }
void
qlt_24xx_process_atio_queue(struct scsi_qla_host *vha, uint8_t ha_locked)
{ … }
void
qlt_24xx_config_rings(struct scsi_qla_host *vha)
{ … }
void
qlt_24xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_24xx *nv)
{ … }
void
qlt_24xx_config_nvram_stage2(struct scsi_qla_host *vha,
struct init_cb_24xx *icb)
{ … }
void
qlt_81xx_config_nvram_stage1(struct scsi_qla_host *vha, struct nvram_81xx *nv)
{ … }
void
qlt_81xx_config_nvram_stage2(struct scsi_qla_host *vha,
struct init_cb_81xx *icb)
{ … }
void
qlt_83xx_iospace_config(struct qla_hw_data *ha)
{ … }
void
qlt_modify_vp_config(struct scsi_qla_host *vha,
struct vp_config_entry_24xx *vpmod)
{ … }
void
qlt_probe_one_stage1(struct scsi_qla_host *base_vha, struct qla_hw_data *ha)
{ … }
irqreturn_t
qla83xx_msix_atio_q(int irq, void *dev_id)
{ … }
static void
qlt_handle_abts_recv_work(struct work_struct *work)
{ … }
void
qlt_handle_abts_recv(struct scsi_qla_host *vha, struct rsp_que *rsp,
response_t *pkt)
{ … }
int
qlt_mem_alloc(struct qla_hw_data *ha)
{ … }
void
qlt_mem_free(struct qla_hw_data *ha)
{ … }
static int __init qlt_parse_ini_mode(void)
{ … }
int __init qlt_init(void)
{ … }
void qlt_exit(void)
{ … }