qla22xxx: target mode LLD changes + tcm_qla2xxx fabric module
Subsystems (2)
v5 cover qla22xxx: target mode LLD changes + tcm_qla2xxx fabric module
From: Nicholas Bellinger <[email protected]>
Greetings all,
The following is the fifth RFC series for adding qla2xxx LLD target mode support into mainline with 8.03.07.13-k @ v3.3-rc6 code. This along with accompanying tcm_qla2xxx.ko fabric module using target-core v4.1 infrastructure allows Qlogic
Quoted 1 line
= 24xx series PCI-Express adapters to function in hardware Fibre Channel
target mode operation.
Along with a number of bugfixes from different folks, the biggest changes during RFC-v5 is the removal of pre 24xx series (PCI-X) HW support from qla_target + qla2xxx LLD changes (1K less LOC than RFC-v4), and enabling of ABORT_TASK usabe in tcm_qla2xxx with the current set of v3.4 target-pending/for-next patches in the queue for v3.4-rc1. This series is available directly here:
git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git qla_tgt-rfc-v5
As before, this series has been broken up into reviewable sections and should considered a 'for-3.4' -> 'for-3.5' item following the TODO items below.
The changes since RFC-v4 in mid December include:
*) Fix cmd_kref leak on target shutdown in qla_tgt_do_work() (roland) *) Drop pre 24xx series support for target-mode (hch + nab)
*) Fix tcm_qla2xxx_do_rsp check condition cmd_kref leak (nab)
*) Hookup ABORT_TASK into qla_target/tcm_qla2xxx code (nab)
*) Convert to target_submit_tmr() usage in tcm_qla2xxx (andy + nab) *) Fix sign of FCP_RESID field for status with RESID_OVER (roland) *) Fix NULL pointer dereference for qla_tgt_do_work() w/ new session (joern) *) Set disable_target_scan=1 when initiator-mode is disabled (nab) *) Set correct nport_handle in __qla_tgt_send_term_exchange() (roland) *) Seperate out per qla_tgt session management from qla_hw_data->hardware_lock
to use se_session->sess_kref (nab)
*) Convert qla_target.c to use qla2x00_start_iocbs() (nab)
Unfortuately little much progress has been made since RFC-v4 to address the TODO item wrt to mixed target/initiator mode operation on a HW per port (struct qla_hw_data) context basis between target-core and scsi-core subsystems.
Note to testers that patch #1 by default sets the following qla2xxx module parameter at the head of qla_target.c to enforce qla2xxx LLD module wide target-mode and disable initiator mode:
static char *qlini_mode = QLA2XXX_INI_MODE_STR_DISABLED; module_param(qlini_mode, charp, S_IRUGO); MODULE_PARM_DESC(qlini_mode,
"Determines when initiator mode will be enabled. Possible values: " "\"exclusive\" - initiator mode will be enabled on load, " "disabled on enabling target mode and then on disabling target mode " "enabled back; "
"\"disabled\" (default) - initiator mode will never be enabled; " "\"enabled\" - initiator mode will always stay enabled.");
For an initial mainline merge, we still expect to use initiator-mode by default (QLA2XXX_INI_MODE_STR_EXCLUSIVE) and disable target mode by default. The qla2xxx module parameter should be used to enable target mode for qla2xxx until scsi-core + target-core interaction can be addressed.
(PING for feedback from hch, jejb, andrew, other folks on scsi-core + target-core
interaction here..?)
So along with resolving this issue wrt mixed T/I mode between subsystems, other remaining items include:
*) Fix HW session level and ConfigFS ACL level shutdown race in target core (nab) *) Move write-pending abort checks into process-context in target core (nab) *) Finish up NPIV support for /sys/kernel/config/target/qla2xxx_npiv/ and determine
remaining NPIV I/O path items. (nab + madhu)
*) FC jammer testing to verify bugfix for SRRs with non zero relative offsets before
re-enabling them. (qlogic linux team)
*) Multi-queue support with qla_hw_data->mqenable=1 (arun + qlogic team) *) Global event handling for active sessions in qla_tgt_reset() (nab) *) Support for target mode on 16 Gb/sec hw (qlogic team)
Thanks again to everyone who has been testing lio-core code in their respective setups, and to the Qlogic + Pure teams for their feedback and patches.
--nab
Nicholas Bellinger (3):
qla2xxx: Add LLD target-mode infrastructure for >= 24xx series
qla2xxx: Enable >= 24xx target-mode support in SCSI LLD
tcm_qla2xxx: Add >= 24xx series fabric module for target-core
drivers/scsi/qla2xxx/Kconfig | 8 + drivers/scsi/qla2xxx/Makefile | 3 +- drivers/scsi/qla2xxx/qla_attr.c | 5 +- drivers/scsi/qla2xxx/qla_dbg.c | 5 + drivers/scsi/qla2xxx/qla_dbg.h | 5 + drivers/scsi/qla2xxx/qla_def.h | 69 +- drivers/scsi/qla2xxx/qla_gbl.h | 7 + drivers/scsi/qla2xxx/qla_gs.c | 4 +- drivers/scsi/qla2xxx/qla_init.c | 92 +- drivers/scsi/qla2xxx/qla_iocb.c | 102 +- drivers/scsi/qla2xxx/qla_isr.c | 87 +- drivers/scsi/qla2xxx/qla_mbx.c | 116 +- drivers/scsi/qla2xxx/qla_mid.c | 17 +- drivers/scsi/qla2xxx/qla_os.c | 133 +- drivers/scsi/qla2xxx/qla_target.c | 4730 ++++++++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_target.h | 984 ++++++++ drivers/scsi/qla2xxx/tcm_qla2xxx.c | 1961 +++++++++++++++ drivers/scsi/qla2xxx/tcm_qla2xxx.h | 149 ++ 18 files changed, 8431 insertions(+), 46 deletions(-) create mode 100644 drivers/scsi/qla2xxx/qla_target.c create mode 100644 drivers/scsi/qla2xxx/qla_target.h create mode 100644 drivers/scsi/qla2xxx/tcm_qla2xxx.c create mode 100644 drivers/scsi/qla2xxx/tcm_qla2xxx.h
Signature · 1 line
1.7.2.5
RFC v5 1/3 qla2xxx: Add LLD target-mode infrastructure for >= 24xx series
From: Nicholas Bellinger <[email protected]>
This patch adds the internal qla_target.[c,h] support pieces for qla2xxx LLD target mode for 24xx series HW. This code was originally based on external qla2x00t module based on 8.02.01-k4, and has been refactored to push the bulk of code into mainline qla2xxx.ko LLD -> qla_target.c.
The implementation uses internal workqueues for I/O context submission into tcm_qla2xxx code, and includes the following API for external interaction to allow qla2xxx LDD to function without direct target-core dependencies:
struct qla_tgt_func_tmpl {
int (*handle_cmd)(struct scsi_qla_host *, struct qla_tgt_cmd *,
unsigned char *, uint32_t, int, int, int);
int (*handle_data)(struct qla_tgt_cmd *);
int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, uint32_t, uint8_t, uint32_t);
void (*free_cmd)(struct qla_tgt_cmd *);
void (*free_session)(struct qla_tgt_sess *);
int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *,
void *, uint8_t *, uint16_t);
struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *,
const uint16_t);
struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *,
const uint8_t *);
void (*clear_nacl_from_fcport_map)(struct qla_tgt_sess *);
void (*put_sess)(struct qla_tgt_sess *);
};--- drivers/scsi/qla2xxx/Makefile | 2 +- drivers/scsi/qla2xxx/qla_target.c | 4730 +++++++++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/qla_target.h | 984 ++++++++ 3 files changed, 5715 insertions(+), 1 deletions(-) create mode 100644 drivers/scsi/qla2xxx/qla_target.c create mode 100644 drivers/scsi/qla2xxx/qla_target.h
drivers/scsi/qla2xxx/Makefile +1 -1
@@ -1,5 +1,5 @@ qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ qla_dbg.o qla_sup.o qla_attr.o qla_mid.o qla_dfs.o qla_bsg.o \ - qla_nx.o + qla_nx.o qla_target.o obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o
drivers/scsi/qla2xxx/qla_target.c new file +4730 -0
2,994 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_target.h new file +984 -0
984 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.2.5
Part of the diff is not shown here. View the raw message.
RFC v5 2/3 qla2xxx: Enable >= 24xx target-mode support in SCSI LLD
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch enables target mode support within the existing qla2xxx LLD using qla_target.c logic. This includes the following changes:
*) Addition of target mode specific members to existing data structures in qla_def.h and struct qla_hw_data->tgt_ops using qla_target.h:struct qla_tgt_func_tmpl
*) Addition of struct qla_tgt_func_tmpl and direct calls into qla_target.c logic w/ qla_tgt_* prefixed functions.
*) Addition of qla_iocb.c:qla2x00_req_pkt() for ring processing, and qla2x00_issue_marker() for handling request/response queue processing for target mode operation
*) Addition of various qla_tgt_mode_enabled() logic checks in qla24xx_nvram_config(), qla2x00_initialize_adapter(), qla2x00_rff_id(), qla2x00_abort_isp(), qla24xx_modify_vp_config(), and qla2x00_vp_abort_isp().
More specific checks for qla_hw_data->qla2x_tmpl include:
*) control plane:
qla_init.c:qla2x00_rport_del() -> qla_tgt_fc_port_deleted() qla_init.c:qla2x00_reg_remote_port() -> qla_tgt_fc_port_added() qla_init.c:qla2x00_device_resync() -> qla2x00_mark_device_lost()
*) I/O path:
qla_isr.c:qla2x00_async_event() -> qla_tgt_async_event() qla_isr.c:qla2x00_process_response_queue() -> qla_tgt_response_pkt_all_vps() qla_isr.c:qla24xx_process_response_queue() -> qla_tgt_response_pkt_all_vps()
*) interrupt handlers:
qla_isr.c:qla24xx_intr_handler() -> qla_tgt_24xx_process_atio_queue() +
qla24xx_process_response_queue()qla24xx_msix_default(): qla_tgt_24xx_process_atio_queue() +
qla24xx_process_response_queue()
--- drivers/scsi/qla2xxx/qla_attr.c | 5 +- drivers/scsi/qla2xxx/qla_dbg.c | 5 ++ drivers/scsi/qla2xxx/qla_dbg.h | 5 ++ drivers/scsi/qla2xxx/qla_def.h | 69 ++++++++++++++++++-- drivers/scsi/qla2xxx/qla_gbl.h | 7 ++ drivers/scsi/qla2xxx/qla_gs.c | 4 +- drivers/scsi/qla2xxx/qla_init.c | 92 ++++++++++++++++++++++++--- drivers/scsi/qla2xxx/qla_iocb.c | 102 +++++++++++++++++++++++++++++- drivers/scsi/qla2xxx/qla_isr.c | 87 +++++++++++++++++++++++++- drivers/scsi/qla2xxx/qla_mbx.c | 116 ++++++++++++++++++++++++++++++++-- drivers/scsi/qla2xxx/qla_mid.c | 17 +++++- drivers/scsi/qla2xxx/qla_os.c | 133 ++++++++++++++++++++++++++++++++++----- 12 files changed, 597 insertions(+), 45 deletions(-)
drivers/scsi/qla2xxx/qla_attr.c +4 -1
@@ -5,6 +5,7 @@* See LICENSE.qla2xxx for copyright and licensing details. */ #include "qla_def.h" +#include "qla_target.h" #include <linux/kthread.h> #include <linux/vmalloc.h>
@@ -1869,6 +1870,7 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)fc_host_supported_speeds (vha->host) =fc_host_supported_speeds (base_vha->host); +qla_tgt_vport_create (vha, ha);qla24xx_vport_disable (fc_vport, disable);if (ha->flags.cpu_affinity_enabled) {
@@ -2082,7 +2084,8 @@ qla2x00_init_host_attr(scsi_qla_host_t *vha)fc_host_dev_loss_tmo (vha->host) = ha->port_down_retry_count;fc_host_node_name (vha->host) =wwn_to_u64 (vha->node_name);fc_host_port_name (vha->host) =wwn_to_u64 (vha->port_name); -fc_host_supported_classes (vha->host) =FC_COS_CLASS3 ; +fc_host_supported_classes (vha->host) = ha->enable_class_2 ? + (FC_COS_CLASS2 |FC_COS_CLASS3 ) :FC_COS_CLASS3 ;fc_host_max_npiv_vports (vha->host) = ha->max_npiv_vports;fc_host_npiv_vports_inuse (vha->host) = ha->cur_vport_count;
drivers/scsi/qla2xxx/qla_dbg.c +5 -0
@@ -28,6 +28,11 @@* | ISP82XX Specific | 0xb052 | | * | MultiQ | 0xc00b | | * | Misc | 0xd00b | | +* | Target Mode | 0xe037 | | +* | Target Mode Management | 0xe14e | | +* | Target Mode SCSI Packets | 0xe20b | | +* | Target Mode Scatterlists | 0xe30c | | +* | Target Mode Task Management | 0xe409 | | * ---------------------------------------------------------------------- */
drivers/scsi/qla2xxx/qla_dbg.h +5 -0
@@ -276,3 +276,8 @@ ql_log_pci(uint32_t, struct pci_dev *pdev, int32_t, const char *fmt, ...);#define ql_dbg_misc 0x00010000/* For dumping everything that is not * not covered by upper categories */ +#define ql_dbg_tgt 0x00008000/* Target mode */ +#define ql_dbg_tgt_mgt 0x00004000/* Target mode management */ +#define ql_dbg_tgt_pkt 0x00002000/* Target mode SCSI packets */ +#define ql_dbg_tgt_sgl 0x00001000/* Target mode scatterlists */ +#define ql_dbg_tgt_tmr 0x00000800/* Target mode task management */
drivers/scsi/qla2xxx/qla_def.h +63 -6
118 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_gbl.h +7 -0
@@ -178,6 +178,7 @@ extern int qla2x00_vp_abort_isp(scsi_qla_host_t *);/* * Global Function Prototypes in qla_iocb.c source file. */ +extern uint16_t qla2x00_calc_iocbs_32 (uint16_t );extern uint16_t qla2x00_calc_iocbs_64 (uint16_t );extern void qla2x00_build_scsi_iocbs_32 (srb_t *,cmd_entry_t *,uint16_t );
@@ -191,6 +192,8 @@ extern uint16_t qla24xx_calc_iocbs(scsi_qla_host_t *, uint16_t);extern void qla24xx_build_scsi_iocbs (srb_t *,struct cmd_type_7 *,uint16_t );extern int qla24xx_dif_start_scsi (srb_t *); +extern void *qla2x00_alloc_iocbs (scsi_qla_host_t *,srb_t *); +extern int qla2x00_issue_marker (scsi_qla_host_t *,int );/* * Global Function Prototypes in qla_mbx.c source file.
@@ -243,6 +246,9 @@ extern int qla2x00_init_firmware(scsi_qla_host_t *, uint16_t);extern int +qla2x00_get_node_name_list (scsi_qla_host_t *,void **,int *); + +extern int qla2x00_get_port_database (scsi_qla_host_t *,fc_port_t *,uint8_t ); extern int
@@ -541,6 +547,7 @@ extern int qla82xx_restart_isp(scsi_qla_host_t *);/* IOCB related functions */ extern int qla82xx_start_scsi (srb_t *); +extern void qla2x00_start_iocbs (struct scsi_qla_host *,struct req_que *);/* Interrupt related */ extern irqreturn_t qla82xx_intr_handler (int ,void *);
drivers/scsi/qla2xxx/qla_gs.c +3 -1
@@ -5,6 +5,7 @@* See LICENSE.qla2xxx for copyright and licensing details. */ #include "qla_def.h" +#include "qla_target.h" static int qla2x00_sns_ga_nxt (scsi_qla_host_t *,fc_port_t *);static int qla2x00_sns_gid_pt (scsi_qla_host_t *,sw_info_t *);
@@ -545,7 +546,8 @@ qla2x00_rff_id(scsi_qla_host_t *vha) ct_req->req.rff_id.port_id[1 ] = vha->d_id.b.area; ct_req->req.rff_id.port_id[2 ] = vha->d_id.b.al_pa; - ct_req->req.rff_id.fc4_feature =BIT_1 ; +qla_tgt_rff_id (vha, ct_req); + ct_req->req.rff_id.fc4_type =0x08 ;/* SCSI - FCP */ /* Execute MS IOCB */
drivers/scsi/qla2xxx/qla_init.c +83 -9
212 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_iocb.c +101 -1
126 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_isr.c +85 -2
191 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_mbx.c +110 -6
164 lines not on this page · raw message
drivers/scsi/qla2xxx/qla_mid.c +15 -2
@@ -6,6 +6,7 @@*/ #include "qla_def.h" #include "qla_gbl.h" +#include "qla_target.h" #include <linux/moduleparam.h> #include <linux/vmalloc.h>
@@ -49,6 +50,7 @@ qla24xx_allocate_vp_id(scsi_qla_host_t *vha)spin_lock_irqsave (&ha->vport_slock, flags);list_add_tail (&vha->list, &ha->vp_list); + ha->tgt_vp_map[vp_id].vha = vha;spin_unlock_irqrestore (&ha->vport_slock, flags);mutex_unlock (&ha->vport_lock);
@@ -79,6 +81,7 @@ qla24xx_deallocate_vp_id(scsi_qla_host_t *vha)spin_lock_irqsave (&ha->vport_slock, flags); }list_del (&vha->list); + ha->tgt_vp_map[vha->vp_idx].vha =NULL ;spin_unlock_irqrestore (&ha->vport_slock, flags); vp_id = vha->vp_idx;
@@ -144,12 +147,16 @@ qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)int qla24xx_disable_vp (scsi_qla_host_t *vha) { +struct qla_hw_data *ha = vha->hw;int ret; ret =qla24xx_control_vp (vha,VCE_COMMAND_DISABLE_VPS_LOGO_ALL );atomic_set (&vha->loop_state,LOOP_DOWN );atomic_set (&vha->loop_down_timer,LOOP_DOWN_TIME ); +/* Remove port id from vp target map */ + ha->tgt_vp_map[vha->d_id.b.al_pa].idx =0 ; +qla2x00_mark_vp_devices_dead (vha);atomic_set (&vha->vp_state,VP_FAILED ); vha->flags.management_server_logged_in =0 ;
@@ -267,6 +274,8 @@ qla2x00_alert_all_vps(struct rsp_que *rsp, uint16_t *mb)int qla2x00_vp_abort_isp (scsi_qla_host_t *vha) { +int ret; +/* * Physical port will do most of the abort and recovery work. We can * just treat it as a loop down
@@ -288,8 +297,12 @@ qla2x00_vp_abort_isp(scsi_qla_host_t *vha)qla24xx_control_vp (vha,VCE_COMMAND_DISABLE_VPS_LOGO_ALL );ql_dbg (ql_dbg_taskm, vha,0x801d , -"Scheduling enable of Vport %d.\n" , vha->vp_idx); -return qla24xx_enable_vp (vha); +"Scheduling enable of Vport %d.\n" , vha->vp_idx); + ret =qla24xx_enable_vp (vha); +if (ret) +return ret; + +return 0 ; } static int
drivers/scsi/qla2xxx/qla_os.c +116 -17
293 lines not on this page · raw message
Signature · 1 line
1.7.2.5
RFC v5 3/3 tcm_qla2xxx: Add >= 24xx series fabric module for target-core
In reply to Nicholas A. BellingerFrom: Nicholas Bellinger <[email protected]>
This patch adds support for tcm_qla2xxx fabric module for target-core using the new qla_target.c LLD logic. This includes support for explict NodeACLs via configfs using tcm_qla2xxx_setup_nacl_from_rport() from libfc struct fc_host->rports, and demo-mode support for virtual LUN=0 access.
This patch also adds support for using tcm_qla2xxx_lport->lport_fcport_map and ->lport_loopid_map to track struct se_node_acl pointers for individual 24-bit Port ID and 16-bit Loop ID values for qla_target_template ->find_sess_by_s_id() and ->find_sess_by_loop_id() used in a number of locations into the primary I/O dispatch logic in qla_target.c LLD code.
The main piece for FC Nexus setup is in tcm_qla2xxx_check_initiator_node_acl(), which calls tcm_qla2xxx_set_sess_by_[s_id,loop_id]() to setup our lport->lport_fcport_map and lport_loopid_map pointers respectively, and register the new nexus with TCM via __transport_register_session().
--- drivers/scsi/qla2xxx/Kconfig | 8 + drivers/scsi/qla2xxx/Makefile | 1 + drivers/scsi/qla2xxx/tcm_qla2xxx.c | 1961 ++++++++++++++++++++++++++++++++++++ drivers/scsi/qla2xxx/tcm_qla2xxx.h | 149 +++ 4 files changed, 2119 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/qla2xxx/tcm_qla2xxx.c create mode 100644 drivers/scsi/qla2xxx/tcm_qla2xxx.h
drivers/scsi/qla2xxx/Kconfig +8 -0
@@ -25,3 +25,11 @@ config SCSI_QLA_FC Firmware images can be retrieved from: ftp://ftp.qlogic.com/outgoing/linux/firmware/ + +config TCM_QLA2XXX + tristate "TCM_QLA2XXX fabric module for Qlogic 2xxx series target mode HBAs" + depends on SCSI_QLA_FC && TARGET_CORE + select LIBFC + default n + ---help--- + Say Y here to enable the TCM_QLA2XXX fabric module for Qlogic 2xxx series target mode HBAs
drivers/scsi/qla2xxx/Makefile +1 -0
@@ -3,3 +3,4 @@ qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ qla_nx.o qla_target.o obj-$(CONFIG_SCSI_QLA_FC) += qla2xxx.o +obj-$(CONFIG_TCM_QLA2XXX) += tcm_qla2xxx.o
drivers/scsi/qla2xxx/tcm_qla2xxx.c new file +1961 -0
1,961 lines not on this page · raw message
drivers/scsi/qla2xxx/tcm_qla2xxx.h new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
1.7.2.5