Re: [PATCH v3] ibmvscsis: Initial commit of IBM VSCSI Tgt Driver
Hi Bryant, On Fri, 2016-05-27 at 09:32 -0500, Bryant G. Ly wrote > diff --git a/drivers/scsi/ibmvscsi/ibmvscsi_tgt.c > b/drivers/scsi/ibmvscsi/ibmvscsi_tgt.c > new file mode 100644 > index 000..292d129 > --- /dev/null > +++ b/drivers/scsi/ibmvscsi/ibmvscsi_tgt.c > + > +static struct se_portal_group *ibmvscsis_make_nexus(struct ibmvscsis_tport > + *tport, > + const char *name) > +{ > + struct se_node_acl *acl; > + > + if (tport->se_sess) { > + pr_debug("tport->se_sess already exists\n"); > + return &tport->se_tpg; > + } > + > + /* > + * Initialize the struct se_session pointer and setup tagpool > + * for struct ibmvscsis_cmd descriptors > + */ > + tport->se_sess = transport_init_session(TARGET_PROT_NORMAL); > + if (IS_ERR(tport->se_sess)) > + goto transport_init_fail; > + > + /* > + * Since we are running in 'demo mode' this call will generate a > + * struct se_node_acl for the ibmvscsis struct se_portal_group with > + * the SCSI Initiator port name of the passed configfs group 'name'. > + */ > + > + acl = core_tpg_check_initiator_node_acl(&tport->se_tpg, > + (unsigned char *)name); > + if (!acl) { > + pr_debug("core_tpg_check_initiator_node_acl() failed for %s\n", > + name); > + goto acl_failed; > + } > + tport->se_sess->se_node_acl = acl; > + > + /* > + * Now register the TCM ibmvscsis virtual I_T Nexus as active. > + */ > + transport_register_session(&tport->se_tpg, > +tport->se_sess->se_node_acl, > +tport->se_sess, tport); > + > + tport->se_sess->se_tpg = &tport->se_tpg; > + FYI, starting in v4.6 these three calls are handled directly by a new target_alloc_session() helper. No objection to leaving this as-is for now to make it easier to run atop unmodified v4.4 target code, but note you'll want to be converting this post merge. > +static int ibmvscsis_shutdown_session(struct se_session *se_sess) > +{ > + return 0; > +} > + > +static void ibmvscsis_close_session(struct se_session *se_sess) > +{ > +} > + > These two target_core_fabric_ops callers have been made optional for v4.7+ > diff --git a/drivers/scsi/ibmvscsi/ibmvscsi_tgt.h > b/drivers/scsi/ibmvscsi/ibmvscsi_tgt.h > new file mode 100644 > index 000..23e9449 > --- /dev/null > +++ b/drivers/scsi/ibmvscsi/ibmvscsi_tgt.h > + > +struct client_info { > +#define SRP_VERSION "16.a" > + char srp_version[8]; > + /* root node property ibm,partition-name */ > + char partition_name[PARTITION_NAMELEN]; > + /* root node property ibm,partition-no */ > + u32 partition_number; > + /* initially 1 */ > + u32 mad_version; > + u32 os_type; > +}; > + > +struct ibmvscsis_cmd { > + /* Used for libsrp processing callbacks */ > + struct scsi_cmnd sc; AFAICT, struct scsi_cmnd is only being used for passing io memory descriptors and struct iu_entry via sc->SCp.ptr between ibmvscsi_tgt + libsrp. Now with the other legacy libsrp.c Scsi_Host related bits removed, it should be easy to convert the rest in order to drop the last vestiges of SCSI host LLD structures from ibmvscsi_tgt code. > + /* Used for TCM Core operations */ > + struct se_cmd se_cmd; > + /* Sense buffer that will be mapped into outgoing status */ > + unsigned char sense_buf[TRANSPORT_SENSE_BUFFER]; > + u32 lun; > +}; > + > diff --git a/drivers/scsi/ibmvscsi/libsrp.h b/drivers/scsi/ibmvscsi/libsrp.h > new file mode 100644 > index 000..bf9e30b > --- /dev/null > +++ b/drivers/scsi/ibmvscsi/libsrp.h > @@ -0,0 +1,91 @@ > +#ifndef __LIBSRP_H__ > +#define __LIBSRP_H__ > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +enum srp_task_attributes { > + SRP_SIMPLE_TASK = 0, > + SRP_HEAD_TASK = 1, > + SRP_ORDERED_TASK = 2, > + SRP_ACA_TASK = 4 > +}; > + > +enum iue_flags { > + V_DIOVER, > + V_WRITE, > + V_LINKED, > + V_FLYING, > +}; > + > +enum { > + SRP_TASK_MANAGEMENT_FUNCTION_COMPLETE = 0, > + SRP_REQUEST_FIELDS_INVALID = 2, > + SRP_TASK_MANAGEMENT_FUNCTION_NOT_SUPPORTED = 4, > + SRP_TASK_MANAGEMENT_FUNCTION_FAILED = 5 > +}; > + > +struct srp_buf { > + dma_addr_t dma; > + void *buf; > +}; > + > +struct srp_queue { > + void *pool; > + void *items; > + struct kfifo queue; > + spinlock_t lock; > +}; > + > +struct srp_target { > + struct Scsi_Host *shost; Unused. > + struct se_device *tgt; > + struct device *dev; > + > + spinlock_t lock; > + struct list_head cmd_queue; > + > + size_t srp_iu_size; > + struct srp_queue iu_queue; > + size_t rx_ring_size; > + struc
[PATCH v3] ibmvscsis: Initial commit of IBM VSCSI Tgt Driver
Version 1: This initial commit contains WIP of the IBM VSCSI Target Fabric Module. It currently supports read/writes, and I have tested the ability to create a file backstore with the driver, install RHEL, and then boot up the partition via filio backstore through the driver. This driver is a pick up of the old IBM VIO scsi Target Driver that was started by Nick and Fujita 2-4 years ago. http://comments.gmane.org/gmane.linux.scsi/90119 and http://marc.info/?t=12973408564&r=1&w=2 The driver provides a virtual SCSI device on IBM Power Servers. When reviving the old libsrp, I stripped out all that utilized scsi to submit commands to the target. Hence there is no more scsi_tgt_if_*, and scsi_transport_* files and fully utilizes LIO instead. This driver does however use the SRP protocol for communication between guests/and or hosts, but its all synchronous data transfers due to the utilization of H_COPY_RDMA, a VIO mechanism which means that others like ib_srp, ib_srpt which are asynchronous can't use this driver. This was also the reason for moving libsrp out of the drivers/scsi/. and into the ibmvscsi folder. Signed-off-by: Steven Royer Signed-off-by: Tyrel Datwyler Signed-off-by: Bryant G. Ly --- MAINTAINERS | 10 + drivers/scsi/Kconfig | 27 +- drivers/scsi/Makefile|2 +- drivers/scsi/ibmvscsi/Makefile |4 + drivers/scsi/ibmvscsi/ibmvscsi_tgt.c | 1932 ++ drivers/scsi/ibmvscsi/ibmvscsi_tgt.h | 169 +++ drivers/scsi/ibmvscsi/libsrp.c | 386 +++ drivers/scsi/ibmvscsi/libsrp.h | 91 ++ drivers/scsi/libsrp.c| 447 include/scsi/libsrp.h| 78 -- 10 files changed, 2610 insertions(+), 536 deletions(-) create mode 100644 drivers/scsi/ibmvscsi/ibmvscsi_tgt.c create mode 100644 drivers/scsi/ibmvscsi/ibmvscsi_tgt.h create mode 100644 drivers/scsi/ibmvscsi/libsrp.c create mode 100644 drivers/scsi/ibmvscsi/libsrp.h delete mode 100644 drivers/scsi/libsrp.c delete mode 100644 include/scsi/libsrp.h diff --git a/MAINTAINERS b/MAINTAINERS index 9c567a4..0f412d4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -5451,6 +5451,16 @@ S: Supported F: drivers/scsi/ibmvscsi/ibmvscsi* F: drivers/scsi/ibmvscsi/viosrp.h +IBM Power Virtual SCSI Device Target Driver +M: Bryant G. Ly +L: linux-scsi@vger.kernel.org +L: target-de...@vger.kernel.org +S: Supported +F: drivers/scsi/ibmvscsi/ibmvscsis.c +F: drivers/scsi/ibmvscsi/ibmvscsis.h +F: drivers/scsi/ibmvscsi/libsrp.c +F: drivers/scsi/ibmvscsi/libsrp.h + IBM Power Virtual FC Device Drivers M: Tyrel Datwyler L: linux-scsi@vger.kernel.org diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index c5883a5..0f8a1de 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -848,6 +848,23 @@ config SCSI_IBMVSCSI To compile this driver as a module, choose M here: the module will be called ibmvscsi. +config SCSI_IBMVSCSIS + tristate "IBM Virtual SCSI Server support" + depends on PPC_PSERIES && TARGET_CORE && SCSI && PCI + help + This is the IBM POWER Virtual SCSI Target Server + This driver uses the SRP protocol for communication betwen servers + guest and/or the host that run on the same server. + More information on VSCSI protocol can be found at www.power.org + + The userspace configuration needed to initialize the driver can be + be found here: + + https://github.com/powervm/ibmvscsis/wiki/Configuration + + To compile this driver as a module, choose M here: the + module will be called ibmvstgt. + config SCSI_IBMVFC tristate "IBM Virtual FC support" depends on PPC_PSERIES && SCSI @@ -1729,16 +1746,6 @@ config SCSI_PM8001 This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip based host adapters. -config SCSI_SRP - tristate "SCSI RDMA Protocol helper library" - depends on SCSI && PCI - select SCSI_TGT - help - If you wish to use SRP target drivers, say Y. - - To compile this driver as a module, choose M here: the - module will be called libsrp. - config SCSI_BFA_FC tristate "Brocade BFA Fibre Channel Support" depends on PCI && SCSI diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index 0335d28..ea2030c 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -127,8 +127,8 @@ obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o obj-$(CONFIG_SCSI_SNI_53C710) += 53c700.o sni_53c710.o obj-$(CONFIG_SCSI_NSP32) += nsp32.o obj-$(CONFIG_SCSI_IPR) += ipr.o -obj-$(CONFIG_SCSI_SRP) += libsrp.o obj-$(CONFIG_SCSI_IBMVSCSI)+= ibmvscsi/ +obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ obj-$(CONFIG_SCSI_IBMVFC) += ibmvscsi/ obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o obj-$(CONFIG_SCSI