tcm_qla2xxx: Add initial HW and NPIV configfs handlers
Subsystems (2)
PATCH 1/1 tcm_qla2xxx: Add initial HW and NPIV configfs handlers
From: Nicholas Bellinger <[email protected]>
Hi Giridhar, Andrew and Co,
Attached is a functional control plane prototype that I have come up thus far for lio-core-2.6.git/tcm_qla2xxx using ISP2532-based 8Gb adapters in a PTP setup, with the tcm_qla2xxx side using host PCIe device passthrough for
individual ports into .37-rc1 KVM/QEMU guest. I am interested to get some
feedback on the configfs enabled NPIV pieces especially (currently compile tested only in PTP mode), but I think the non NPIV case is straight-forward enough for the moment.
So, please have a look at the following and add your comments accordingly.
Thanks!
--nab
------------------------------------------------------------------------------
This patch adds the base tcm_qla2xxx HW configfs handler (non NPIV) in tcm_qla2xxx_make_lport() that will walk the PCI device list looking for a driver with MODE_TARGET supported and not already enabled, looking for a matching struct scsi_qla_host->port_name for the passed configfs FC WWPN.
This patch also adds initial (compile tested) support for NPIV capable driver by registering a second tcm_qla2xxx_npiv_ops during tcm_qla2xxx_register_configfs() at module_init() time, and saves a global pointer to tcm_qla2xxx_npiv_fabric_configfs. This means the seperate NPIV enabled code can be run from the same tcm_qla2xxx LKM at /sys/kernel/config/target/qla2xxx_npiv/$WWPN+$WWNN using the same format as the existing NPIV sysfs triggers at /sys/class/fc_host/$HOST/[create,delete]_vport.
This patch also adds special NPIV configfs handlers in tcm_qla2xxx_npiv_make_lport() and tcm_qla2xxx_npiv_drop_lport() to call fc_vport_create() and fc_vport_terminate() respectively to setup/release the NPIV port with libfc code. Also included is a NPIV version of tcm_qla2xxx_npiv_make_tpg() that references the NPIV global pointer directly.
For the non NPIV case the current control plane code looks like the following in action for a matching vha->port_name containing a FC WWPN of 21:00:00:24:ff:31:4c:48
lenny64guest0:/usr/src/lio-core-2.6.git# insmod drivers/target/tcm_qla2xxx/tcm_qla2xxx.ko lenny64guest0:/usr/src/lio-core-2.6.git# mkdir -p /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:31:4c:48/tpgt_1/lun/lun_0 lenny64guest0:/usr/src/lio-core-2.6.git# cd /sys/kernel/config/target/qla2xxx/21:00:00:24:ff:31:4c:48/tpgt_1/lun/lun_0 lenny64guest0:/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:31:4c:48/tpgt_1/lun/lun_0# ln -s /sys/kernel/config/target/core/fileio_0/sync_fileio qla2xxx_port
lenny64guest0:/sys/kernel/config/target/qla2xxx/21:00:00:24:ff:31:4c:48/tpgt_1/lun/lun_0# tree /sys/kernel/config/target/qla2xxx/ /sys/kernel/config/target/qla2xxx/ |-- 21:00:00:24:ff:31:4c:48 | `-- tpgt_1 | |-- acls | |-- attrib | |-- lun | | `-- lun_0 | | |-- alua_tg_pt_gp | | |-- alua_tg_pt_offline | | |-- alua_tg_pt_status | | |-- alua_tg_pt_write_md | | `-- qla2xxx_port -> ../../../../../../target/core/fileio_0/sync_fileio | |-- np | `-- param |-- discovery_auth `-- version
and from the kernel log:
[15078.953293] TCM QLOGIC QLA2XXX fabric module v0.1 on Linux/x86_64 on 2.6.37-rc1+ [15078.953361] Setup generic discovery [15078.953361] Setup generic wwn [15078.953361] Setup generic tpg [15078.953361] Setup generic tpg_base [15078.953361] Setup generic tpg_port [15078.957499] Setup generic tpg_lun [15078.958080] Setup generic tpg_np [15078.958640] Setup generic tpg_np_base [15078.959273] Setup generic tpg_attrib [15078.959891] Setup generic tpg_param [15078.960494] Setup generic tpg_nacl [15078.961085] Setup generic tpg_nacl_base [15078.961481] Setup generic tpg_nacl_attrib [15078.961481] Setup generic tpg_nacl_auth [15078.961481] Setup generic tpg_nacl_param [15078.961481] Setup generic tpg_mappedlun [15078.961481] <<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>>>>>>>>>>>>>>> [15078.965721] Initialized struct target_fabric_configfs: ffff88007494c890 for qla2xxx [15078.967043] <<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>>>>>> [15078.968185] TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_fabric_configfs [15078.969311] Setup generic discovery [15078.969696] Setup generic wwn [15078.969696] Setup generic tpg [15078.969696] Setup generic tpg_base [15078.969696] Setup generic tpg_port [15078.969696] Setup generic tpg_lun [15078.969696] Setup generic tpg_np [15078.969696] Setup generic tpg_np_base [15078.973959] Setup generic tpg_attrib [15078.974579] Setup generic tpg_param [15078.975155] Setup generic tpg_nacl [15078.975718] Setup generic tpg_nacl_base [15078.976352] Setup generic tpg_nacl_attrib [15078.977010] Setup generic tpg_nacl_auth [15078.977793] Setup generic tpg_nacl_param [15078.977939] Setup generic tpg_mappedlun [15078.977939] <<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>>>>>>>>>>>>>>> [15078.977939] Initialized struct target_fabric_configfs: ffff88007494a850 for qla2xxx_npiv [15078.981638] <<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>>>>>> [15078.982750] TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_npiv_fabric_configfs [15085.683873] Target_Core_ConfigFS: REGISTER -> group: ffffffffa05b2b00 name: qla2xxx [15085.685184] Target_Core_ConfigFS: REGISTER -> Located fabric: qla2xxx [15085.686270] Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> ffff88007494cb98 [15085.686343] Target_Core_ConfigFS: REGISTER -> Allocated Fabric: qla2xxx [15085.686343] Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric for qla2xxx [15085.686343] qla2xxx HW vha->node_name: 20 00 00 24 ff 31 4c 48 [15085.690922] qla2xxx HW vha->port_name: 21 00 00 24 ff 31 4c 48 [15085.692079] qla2xxx passed configfs WWPN: 21 00 00 24 ff 31 4c 48 [15085.693276] qla2xxx: Found matching HW WWPN: 21:00:00:24:ff:31:4c:48 for lport [15085.694349] TARGET_CORE[qla2xxx]: Allocated Normal struct se_portal_group for endpoint: 21:00:00:24:ff:31:4c:48, Portal Tag: 1 [15203.490029] fileio/qla2xxx: Adding to default ALUA Target Port Group: alua/default_tg_pt_gp [15203.491497] qla2xxx_TPG[1]_LUN[0] - Activated qla2xxx Logical Unit from CORE HBA: 2
--- drivers/target/tcm_qla2xxx/Kbuild | 2 +- drivers/target/tcm_qla2xxx/tcm_qla2xxx_base.h | 18 + drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c | 397 ++++++++++++++++++++- drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c | 94 +++++- drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.h | 22 +- 5 files changed, 517 insertions(+), 16 deletions(-)
drivers/target/tcm_qla2xxx/Kbuild +1 -1
@@ -1,4 +1,4 @@ -EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_qla2xxx +EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ -I$(srctree)/drivers/scsi/qla2xxx/ -I$(srctree)/include/scsi/ -I$(srctree)/drivers/target/tcm_qla2xxx/ tcm_qla2xxx-objs := tcm_qla2xxx_fabric.o \ tcm_qla2xxx_configfs.o \
drivers/target/tcm_qla2xxx/tcm_qla2xxx_base.h +18 -0
@@ -3,6 +3,12 @@#define TCM_QLA2XXX_VERSION "v0.1"/* length of ASCII WWPNs including pad */ #define TCM_QLA2XXX_NAMELEN 32 +/* lenth of ASCII NPIV 'WWPN+WWNN' including pad */ +#define TCM_QLA2XXX_NPIV_NAMELEN 66 + +struct tcm_qla2xxx_cmd { +struct se_cmd se_cmd; +};struct tcm_qla2xxx_nacl {/* Binary World Wide unique Port Name for FC Initiator Nport */
@@ -27,8 +33,20 @@ struct tcm_qla2xxx_lport {u8 lport_proto_id;/* Binary World Wide unique Port Name for FC Target Lport */ u64 lport_wwpn; +/* Binary World Wide unique Port Name for FC NPIV Target Lport */ +u64 lport_npiv_wwpn; +/* Binary World Wide unique Node Name for FC NPIV Target Lport */ +u64 lport_npiv_wwnn;/* ASCII formatted WWPN for FC Target Lport */ char lport_name[TCM_QLA2XXX_NAMELEN ]; +/* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */ +char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN ]; +/* Pointer to struct scsi_qla_host from qla2xxx LLD */ +struct scsi_qla_host *qla_vha; +/* Pointer to struct scsi_qla_host for NPIV VP from qla2xxx LLD */ +struct scsi_qla_host *qla_npiv_vp; +/* Pointer to struct fc_vport for NPIV vport from libfc */ +struct fc_vport *npiv_vport;/* Returned by tcm_qla2xxx_make_lport() */ struct se_wwn lport_wwn; };
drivers/target/tcm_qla2xxx/tcm_qla2xxx_configfs.c +393 -4
462 lines not on this page · raw message
drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.c +92 -2
112 lines not on this page · raw message
drivers/target/tcm_qla2xxx/tcm_qla2xxx_fabric.h +13 -9
@@ -3,15 +3,19 @@ extern int tcm_qla2xxx_check_false(struct se_portal_group *);extern ssize_t tcm_qla2xxx_parse_wwn (const char *,u64 *,int );extern ssize_t tcm_qla2xxx_format_wwn (char *,size_t ,u64 );extern char *tcm_qla2xxx_get_fabric_name (void ); -extern u8 tcm_qla2xxx_get_fabric_proto_ident (se_portal_group_t *); -extern char *tcm_qla2xxx_get_fabric_wwn (se_portal_group_t *); -extern u16 tcm_qla2xxx_get_tag (se_portal_group_t *); -extern u32 tcm_qla2xxx_get_default_depth (se_portal_group_t *); -extern u32 tcm_qla2xxx_get_pr_transport_id (se_portal_group_t *,se_node_acl_t *, -t10_pr_registration_t *,int *,unsigned char *); -extern u32 tcm_qla2xxx_get_pr_transport_id_len (se_portal_group_t *,se_node_acl_t *, -t10_pr_registration_t *,int *); -extern char *tcm_qla2xxx_parse_pr_out_transport_id (se_portal_group_t *,const char *, +extern int tcm_qla2xxx_npiv_parse_wwn (const char *name,size_t ,u64 *,u64 *); +extern ssize_t tcm_qla2xxx_npiv_format_wwn (char *,size_t ,u64 ,u64 ); +extern char *tcm_qla2xxx_npiv_get_fabric_name (void ); +extern u8 tcm_qla2xxx_get_fabric_proto_ident (struct se_portal_group *); +extern char *tcm_qla2xxx_get_fabric_wwn (struct se_portal_group *); +extern char *tcm_qla2xxx_npiv_get_fabric_wwn (struct se_portal_group *); +extern u16 tcm_qla2xxx_get_tag (struct se_portal_group *); +extern u32 tcm_qla2xxx_get_default_depth (struct se_portal_group *); +extern u32 tcm_qla2xxx_get_pr_transport_id (struct se_portal_group *,struct se_node_acl *, +struct t10_pr_registration *,int *,unsigned char *); +extern u32 tcm_qla2xxx_get_pr_transport_id_len (struct se_portal_group *,struct se_node_acl *, +struct t10_pr_registration *,int *); +extern char *tcm_qla2xxx_parse_pr_out_transport_id (struct se_portal_group *,const char *,u32 *,char **);extern struct se_node_acl *tcm_qla2xxx_alloc_fabric_acl (struct se_portal_group *);extern void tcm_qla2xxx_release_fabric_acl (struct se_portal_group *,struct se_node_acl *);
Signature · 1 line
1.5.6.5