ibmvscsis: Initial commit of IBM VSCSI Tgt Driver
Subsystems (3)
PATCH 1/1 ibmvscsis: Initial commit of IBM VSCSI Tgt Driver
From: bgly <[email protected]>
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 and install RHEL VIA NIM and then boot up the partition via filio backstore through the driver.
--- MAINTAINERS | 10 + drivers/scsi/Kconfig | 24 + drivers/scsi/Makefile | 2 + drivers/scsi/ibmvscsi/Makefile | 1 + drivers/scsi/ibmvscsi/ibmvscsis.c | 2033 +++++++++++++++++++++++++++++++++++++ drivers/scsi/ibmvscsi/ibmvscsis.h | 160 +++ drivers/scsi/libsrp.c | 387 +++++++ include/scsi/libsrp.h | 95 ++ 8 files changed, 2712 insertions(+) create mode 100644 drivers/scsi/ibmvscsi/ibmvscsis.c create mode 100644 drivers/scsi/ibmvscsi/ibmvscsis.h create mode 100644 drivers/scsi/libsrp.c create mode 100644 include/scsi/libsrp.h
MAINTAINERS +10 -0
@@ -5381,6 +5381,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 <[email protected]> +L: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/ibmvscsi/ibmvscsis.c +F: drivers/scsi/ibmvscsi/ibmvscsis.h +F: drivers/scsi/libsrp.h +F: drivers/scsi/libsrp.c + IBM Power Virtual FC Device Drivers M: Tyrel Datwyler <[email protected]> L: [email protected]
drivers/scsi/Kconfig +24 -0
@@ -847,6 +847,20 @@ 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 && SCSI_SRP && TARGET_CORE + help + This is the IBM POWER Virtual SCSI Target Server + + The userspace component needed to initialize the driver and + documentation can be found: + + https://github.com/powervm/ibmvscsis + + 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
@@ -1728,6 +1742,16 @@ 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 + help + This scsi srp module is a library for ibmvscsi target driver. + 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
drivers/scsi/Makefile +2 -0
@@ -127,7 +127,9 @@ 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_STEX) += stex.o
drivers/scsi/ibmvscsi/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi.o +obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsis.o obj-$(CONFIG_SCSI_IBMVFC) += ibmvfc.o
drivers/scsi/ibmvscsi/ibmvscsis.c new file +2033 -0
2,033 lines not on this page · raw message
drivers/scsi/ibmvscsi/ibmvscsis.h new file +160 -0
160 lines not on this page · raw message
drivers/scsi/libsrp.c new file +387 -0
387 lines not on this page · raw message
include/scsi/libsrp.h new file +95 -0
95 lines not on this page · raw message
--
This is a first push up for grok and is WIP code. The driver does function, but there are alot of features left that need to be handled and will be addressed in a series of upcoming patches. We currently have a version of the driver that is closer to being complete, but is pending lawyers approval, since it was written by referencing our internal VIOS Virtual SCSI driver.
2.5.4 (Apple Git-61)
Quoted 7 lines · Bryant G. Ly
From: bgly <[email protected]>
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 and install RHEL VIA NIM and then boot up the partition via filio backstore through the driver.
Only trivial notes:
Maybe try checkpatch with the --strict option and see if any of the additional messages are important to you.
MAINTAINERS
Quoted 1 line
MAINTAINERS +0
-0
[]
MAINTAINERS S: Supported · line 5392
Quoted 13 lines
MAINTAINERS +0
-0@@ -5381,6 +5381,16 @@ S: SupportedF:
drivers/scsi/ibmvscsi/ibmvscsi*
F:drivers/scsi/ibmvscsi/viosrp.hMAINTAINERS +9
-0+IBM Power Virtual SCSI Device Target Driver +M: Bryant G. Ly <[email protected]> +L: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/ibmvscsi/ibmvscsis.c +F: drivers/scsi/ibmvscsi/ibmvscsis.h +F: drivers/scsi/libsrp.h +F: drivers/scsi/libsrp.c
Please use a tab character consistently after the :
drivers/scsi/Kconfig
Quoted 1 line
drivers/scsi/Kconfig +0
-0
[]
drivers/scsi/Kconfig config SCSI_IBMVSCSI · line 857
Quoted 12 lines
drivers/scsi/Kconfig +0
-0@@ -847,6 +847,20 @@ config SCSI_IBMVSCSITo compile this driver as a module, choose M here: the module will be called ibmvscsi.
drivers/scsi/Kconfig +8
-0+config SCSI_IBMVSCSIS + tristate "IBM Virtual SCSI Server support" + depends on PPC_PSERIES && SCSI_SRP && TARGET_CORE + help + This is the IBM POWER Virtual SCSI Target Server + + The userspace component needed to initialize the driver and + documentation can be found:
here too.
drivers/scsi/Kconfig config SCSI_IBMVSCSI · line 863
Quoted 6 lines
drivers/scsi/Kconfig +6
-0+ + https://github.com/powervm/ibmvscsis + + To compile this driver as a module, choose M here: the + module will be called ibmvstgt. +
[]
drivers/scsi/Makefile
Quoted 1 line
drivers/scsi/Makefile +0
-0
[]
Quoted 7 lines
drivers/scsi/Makefile +0
-0@@ -127,7 +127,9 @@ obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.oobj-$(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/
and here
drivers/scsi/ibmvscsi/ibmvscsis.c
Quoted 1 line
drivers/scsi/ibmvscsi/ibmvscsis.c +0
-0
[]
drivers/scsi/ibmvscsi/ibmvscsis.c line 73
Quoted 2 lines
drivers/scsi/ibmvscsi/ibmvscsis.c +2
-0+static int ibmvscsis_probe (struct vio_dev *vdev, + const struct vio_device_id *id);
[...]
It might be nice to rearrange the code to avoid these forward function declarations.
drivers/scsi/ibmvscsi/ibmvscsis.c line 255
Quoted 3 lines
drivers/scsi/ibmvscsi/ibmvscsis.c +3
-0+static ssize_t ibmvscsis_tpg_enable_store (struct config_item *item, +const char *page,size_t count) +{
[]
drivers/scsi/ibmvscsi/ibmvscsis.c line 266
Quoted 5 lines
Quoted 1 line
drivers/scsi/ibmvscsi/ibmvscsis.c new file +1
-0+ ret =kstrtoul (page,0 , &tmp);drivers/scsi/ibmvscsi/ibmvscsis.c +4
-0+if (ret <0 ) { +pr_err ("Unable to extract ibmvscsis_tpg_store_enable\n" ); +return -EINVAL ; + }
It might be nicer to add:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
before any #include to output all the logging messages with a standardized prefix. Then all the other logging with an embedded prefix can have the embedded prefix removed too.
drivers/scsi/ibmvscsi/ibmvscsis.c line 277
Quoted 11 lines
drivers/scsi/ibmvscsi/ibmvscsis.c +11
-0+ +if ((tmp !=0 ) && (tmp !=1 )) { +pr_err ("Illegal value for ibmvscsis_tpg_store_enable: %lu\n" , + tmp); +return -EINVAL ; + } + +if (tmp ==1 ) + tport->enabled = true; +else + tport->enabled = false;
tport->enabled = tmp;
Quoted 1 line · Bryant G. Ly
From: bgly <[email protected]>
Really? Please go get a proper review from the other internal IBM developers to fix this, and the other obvious problems with your patch, before you send it publically and force us to tell you these things...
thanks,
greg k-h
Quoted 4 lines · Bryant G. Ly
drivers/scsi/Kconfig +4
-0+config SCSI_IBMVSCSIS + tristate "IBM Virtual SCSI Server support" + depends on PPC_PSERIES && SCSI_SRP && TARGET_CORE + help
drivers/scsi/Kconfig config SCSI_IBMVSCSI · line 863
Quoted 10 lines
drivers/scsi/Kconfig +10
-0+ This is the IBM POWER Virtual SCSI Target Server + + The userspace component needed to initialize the driver and + documentation can be found: + + https://github.com/powervm/ibmvscsis + + To compile this driver as a module, choose M here: the + module will be called ibmvstgt. +
This driver has confused Linux users before. Most people know SRP as a SCSI transport layer that is used for communication between servers. This driver however uses the SRP protocol for communication between guests and/or the host that run on the same server. Please add this information to the above help text, together with a reference to the VIO protocol documentation in the POWER architecture manual.
Quoted 1 line
+#include <
generated/utsrelease.h>
Every Linux user can query the kernel version by running the uname command. Is it really useful to print the kernel version (UTS_RELEASE) when this driver is loaded?
Quoted 1 line
+#include "
ibmvscsi.h"
The above include directive indirectly includes a whole bunch of SCSI initiator driver header files. We do not want that initiator header files are included in the source code of a target driver. If it is necessary to share definitions of symbolic constants between the initiator and the target driver please move these into a new header file.
drivers/scsi/ibmvscsi/ibmvscsis.c line 181
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +9
-0+static inline long h_send_crq (struct ibmvscsis_adapter *adapter, +u64 word1,u64 word2) +{ +long rc; +struct vio_dev *vdev = adapter->dma_dev; + +pr_debug ("ibmvscsis: ibmvscsis_send_crq(0x%x, 0x%016llx, 0x%016llx)\n" , + vdev->unit_address, word1, word2); +
As Joe Perches already asked, please define pr_fmt() instead of including the kernel module name in every pr_debug() statement.
drivers/scsi/ibmvscsi/ibmvscsis.c line 199
Quoted 2 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +2
-0+static char system_id[64 ] ="" ; +static char partition_name[97 ] ="UNKNOWN" ;
Where do these magic constants come from and what is their meaning? Please consider to introduce symbolic names for these constants.
drivers/scsi/ibmvscsi/ibmvscsis.c line 251
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +9
-0+static ssize_t ibmvscsis_tpg_enable_show (struct config_item *item, +char *page) +{ +struct se_portal_group *se_tpg =to_tpg (item); +struct ibmvscsis_tport *tport =container_of (se_tpg, + struct ibmvscsis_tport, se_tpg); + +return snprintf (page,PAGE_SIZE ,"%d\n" , (tport->enabled) ?1 :0 ); +}
Have you considered to use MODULE_VERSION() instead of introducing a sysfs attribute to export the module version? An advantage of MODULE_VERSION() is that it allows to query the module version without having to load a kernel module.
Quoted 10 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +10
-0+static void ibmvscsis_modify_std_inquiry (struct se_cmd *se_cmd) +{ +struct se_device *dev = se_cmd->se_dev; +unsigned char *buf =NULL ; +u32 cmd_len = se_cmd->data_length; + +if (cmd_len <=INQ_DATA_OFFSET ) +return ; + + buf =transport_kmap_data_sg (se_cmd);
drivers/scsi/ibmvscsi/ibmvscsis.c line 556
Quoted 10 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +10
-0+if (buf) { +memcpy (&buf[8 ],"IBM " ,8 ); +if (dev->transport->get_device_type (dev) ==TYPE_ROM ) +memcpy (&buf[16 ],"VOPTA " ,16 ); +else +memcpy (&buf[16 ],"3303 NVDISK" ,16 ); +memcpy (&buf[32 ],"0001" ,4 ); +transport_kunmap_data_sg (se_cmd); + } +}
Shouldn't a sense code be returned to the initiator if this function fails?
drivers/scsi/ibmvscsi/ibmvscsis.c line 1707
Quoted 10 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +10
-0+default : +pr_err ("ibmvscsis: unknown task mgmt func %d\n" , + srp_tsk->tsk_mgmt_func); + cmd->se_cmd.se_tmr_req->response = +TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED ; + rc =-1 ; +break ; + } + +if (!rc) {
Please consider changing the above "break" into "goto fail" such that the if (!rc) can be left out and such that the indentation of the code below if (!rc) can be reduced.
drivers/scsi/ibmvscsi/ibmvscsis.c line 1838
Quoted 11 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +11
-0+static int ibmvscsis_queuecommand (struct ibmvscsis_adapter *adapter, +struct iu_entry *iue) +{ +struct srp_cmd *cmd = iue->sbuf->buf; +struct scsi_cmnd *sc; +struct ibmvscsis_cmnd *vsc; +int ret; + +pr_debug ("ibmvscsis: ibmvscsis_queuecommand\n" ); + + vsc =kzalloc (sizeof (*vsc),GFP_KERNEL );
Allocating memory in the command processing path in a SCSI driver usually causes suboptimal performance. Other LIO target drivers preallocate such buffers before I/O starts.
Quoted 41 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +41
-0+static uint64_t ibmvscsis_unpack_lun (const uint8_t *lun,int len) +{ +uint64_t res =NO_SUCH_LUN ; +int addressing_method; + +if (unlikely (len <2 )) { +pr_err ("Illegal LUN length %d, expected 2 bytes or more\n" , + len); + goto out; + } + +switch (len) { +case 8 : +if ((*((__be64 *)lun) &cpu_to_be64 (0x0000FFFFFFFFFFFFLL )) !=0 ) + goto out_err; +break ; +case 4 : +if (*((__be16 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 6 : +if (*((__be32 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 2 : +break ; +default : + goto out_err; + } + + addressing_method = (*lun) >>6 ;/* highest two bits of byte 0 */ +switch (addressing_method) { +case SCSI_LUN_ADDR_METHOD_PERIPHERAL : +case SCSI_LUN_ADDR_METHOD_FLAT : +case SCSI_LUN_ADDR_METHOD_LUN : + res = *(lun +1 ) | (((*lun) &0x3f ) <<8 ); +break ; + +case SCSI_LUN_ADDR_METHOD_EXTENDED_LUN : +default : + pr_err("Unimplemented LUN addressing method %u\n",
drivers/scsi/ibmvscsi/ibmvscsis.c line 1900
Quoted 10 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +10
-0+ addressing_method); +break ; + } + +out: +return res; +out_err: +pr_err ("Support for multi-level LUNs has not yet been implemented\n" ); + goto out; +}
In the above function there is nothing that is specific to the VIO mechanism. Please consider to merge this function with scsilun_to_int(), e.g. by introducing a new function that accepts a SCSI LUN and the addressing method as arguments and by making scsilun_to_int() call that function with SCSI_LUN_ADDR_METHOD_PERIPHERAL as one of its arguments.
Quoted 8 lines
drivers/scsi/ibmvscsi/ibmvscsis.h new file +8
-0+struct inquiry_data { +u8 qual_type; +u8 rmb_reserve; +u8 version; +u8 aerc_naca_hisup_format; +u8 addl_len; +u8 sccs_reserved; +u8 bque_encserv_vs_multip_mchngr_reserved;
drivers/scsi/ibmvscsi/ibmvscsis.h line 132
Quoted 10 lines
drivers/scsi/ibmvscsi/ibmvscsis.h new file +10
-0+u8 reladr_reserved_linked_cmdqueue_vs; +char vendor[8 ]; +char product[16 ]; +char revision[4 ]; +char vendor_specific[20 ]; +char reserved1[2 ]; +char version_descriptor[16 ]; +char reserved2[22 ]; +char unique[158 ]; +};
Is this the inquiry data response format from SPC? If so, this is a structure definition that is useful for the SCSI initiator core and also for other LIO target drivers. There might be a more appropriate header file for this definition.
drivers/scsi/ibmvscsi/ibmvscsis.h line 146
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.h new file +6
-0+enum scsi_lun_addr_method { +SCSI_LUN_ADDR_METHOD_PERIPHERAL =0 , +SCSI_LUN_ADDR_METHOD_FLAT =1 , +SCSI_LUN_ADDR_METHOD_LUN =2 , +SCSI_LUN_ADDR_METHOD_EXTENDED_LUN =3 , +};
Same comment here.
drivers/scsi/libsrp.c line 2
Quoted 8 lines
drivers/scsi/libsrp.c new file +2
-0@@ -0,0 +1,387 @@ +/******************************************************************************* +* SCSI RDMA Protocol lib functions
My understanding of the VIO mechanism is that the invocation of H_COPY_RDMA is synchronous. This means that this operation only finishes after the data has been transferred. If I interpret the code in libsrp.c and libsrp.h correctly then this code can only be used by SRP drivers use synchronous data transfers and not by SRP drivers that use asynchronous data transfers. This means that this code is not useful for any of the SRP drivers that are already upstream (ib_srp and ib_srpt). Hence my proposal to move the libsrp.c and libsrp.h source files from drivers/scsi and include/scsi to the same directory as the ibmvscsis driver.
Thanks,
Bart.
Quoted 4 lines · Bart Van Assche
Quoted 4 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +4
-0+static inline long h_send_crq (struct ibmvscsis_adapter *adapter, +u64 word1,u64 word2) +{ +long rc;
Quoted 8 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 181
Quoted 5 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +5
-0+struct vio_dev *vdev = adapter->dma_dev; + +pr_debug ("ibmvscsis: ibmvscsis_send_crq(0x%x, 0x%016llx, 0x%016llx)\n" , + vdev->unit_address, word1, word2); +As Joe Perches already asked, please define
pr_fmt()instead of including the kernel module name in everypr_debug()statement.
Even better, as this is a driver, it should be using dev_*() calls instead of pr_*() calls to properly identify the device and driver that is making the message. No driver should be using pr_*() except in _very_ limited usages.
thanks,
greg k-h
Quoted 14 lines · Greg KH
Quoted 4 lines · Bart Van Assche
Quoted 4 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +4
-0+static inline long h_send_crq (struct ibmvscsis_adapter *adapter, +u64 word1,u64 word2) +{ +long rc;Quoted 8 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 181
Quoted 5 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +5
-0+struct vio_dev *vdev = adapter->dma_dev; + +pr_debug ("ibmvscsis: ibmvscsis_send_crq(0x%x, 0x%016llx, 0x%016llx)\n" , + vdev->unit_address, word1, word2); +As Joe Perches already asked, please define
pr_fmt()instead of including the kernel module name in everypr_debug()statement.
Quoted 4 lines
Even better, as this is a driver, it should be using dev_*() calls instead of pr_*() calls to properly identify the device and driver that is making the message. No driver should be using pr_*() except in _very_ limited usages.
Hi Greg,
The reason I recommended pr_debug() is because ibmvscsis is a LIO target driver and I don't think a struct device is associated with a LIO target driver. See e.g. target_register_template() in drivers/target/target_core_configfs.c.
Bart.
Quoted 20 lines · Bart Van Assche
Quoted 14 lines · Greg KH
Quoted 4 lines · Bart Van Assche
Quoted 4 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +4
-0+static inline long h_send_crq (struct ibmvscsis_adapter *adapter, +u64 word1,u64 word2) +{ +long rc;Quoted 8 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 181
Quoted 5 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +5
-0+struct vio_dev *vdev = adapter->dma_dev; + +pr_debug ("ibmvscsis: ibmvscsis_send_crq(0x%x, 0x%016llx, 0x%016llx)\n" , + vdev->unit_address, word1, word2); +As Joe Perches already asked, please define
pr_fmt()instead of including the kernel module name in everypr_debug()statement.Quoted 4 lines
Even better, as this is a driver, it should be using dev_*() calls instead of pr_*() calls to properly identify the device and driver that is making the message. No driver should be using pr_*() except in _very_ limited usages.
Quoted 6 lines
Hi Greg,
The reason I recommended
pr_debug()is because ibmvscsis is a LIO target driver and I don't think a struct device is associated with a LIO target driver. See e.g.target_register_template()indrivers/target/target_core_configfs.c.
That seems messed up, there should be a struct device somewhere to use...
Quoting Bart Van Assche <[email protected]>:
Quoted 9 lines · Bryant G. Ly
Quoted 8 lines
drivers/scsi/Kconfig +8
-0+config SCSI_IBMVSCSIS + tristate "IBM Virtual SCSI Server support" + depends on PPC_PSERIES && SCSI_SRP && TARGET_CORE + help + This is the IBM POWER Virtual SCSI Target Server + + The userspace component needed to initialize the driver and + documentation can be found:
Quoted 9 lines
drivers/scsi/Kconfig config SCSI_IBMVSCSI · line 863
Quoted 6 lines
drivers/scsi/Kconfig +6
-0+ + https://github.com/powervm/ibmvscsis + + To compile this driver as a module, choose M here: the + module will be called ibmvstgt. +This driver has confused Linux users before. Most people know SRP as a SCSI transport layer that is used for communication between servers. This driver however uses the SRP protocol for communication between guests and/or the host that run on the same server. Please add this information to the above help text, together with a reference to the VIO protocol documentation in the POWER architecture manual.
Done
Quoted 4 lines
Quoted 1 line
+#include <
generated/utsrelease.h>Every Linux user can query the kernel version by running the uname command. Is it really useful to print the kernel version (
UTS_RELEASE) when this driver is loaded?
Done
Quoted 4 lines
Quoted 1 line
+#include "
ibmvscsi.h"The above include directive indirectly includes a whole bunch of SCSI initiator driver header files. We do not want that initiator header files are included in the source code of a target driver. If it is necessary to share definitions of symbolic constants between the initiator and the target driver please move these into a new header file.
Done
Quoted 12 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 181
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +9
-0+static inline long h_send_crq (struct ibmvscsis_adapter *adapter, +u64 word1,u64 word2) +{ +long rc; +struct vio_dev *vdev = adapter->dma_dev; + +pr_debug ("ibmvscsis: ibmvscsis_send_crq(0x%x, 0x%016llx, 0x%016llx)\n" , + vdev->unit_address, word1, word2); +As Joe Perches already asked, please define
pr_fmt()instead of including the kernel module name in everypr_debug()statement.
Done
Quoted 5 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 199
Quoted 2 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +2
-0+static char system_id[64 ] ="" ; +static char partition_name[97 ] ="UNKNOWN" ;Where do these magic constants come from and what is their meaning? Please consider to introduce symbolic names for these constants.
Done
Quoted 12 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 251
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +9
-0+static ssize_t ibmvscsis_tpg_enable_show (struct config_item *item, +char *page) +{ +struct se_portal_group *se_tpg =to_tpg (item); +struct ibmvscsis_tport *tport =container_of (se_tpg, + struct ibmvscsis_tport, se_tpg); + +return snprintf (page,PAGE_SIZE ,"%d\n" , (tport->enabled) ?1 :0 ); +}Have you considered to use
MODULE_VERSION()instead of introducing a sysfs attribute to export the module version? An advantage ofMODULE_VERSION()is that it allows to query the module version without having to load a kernel module.
Done
Quoted 14 lines
Quoted 14 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +14
-0+static void ibmvscsis_modify_std_inquiry (struct se_cmd *se_cmd) +{ +struct se_device *dev = se_cmd->se_dev; +unsigned char *buf =NULL ; +u32 cmd_len = se_cmd->data_length; + +if (cmd_len <=INQ_DATA_OFFSET ) +return ; + + buf =transport_kmap_data_sg (se_cmd); +if (buf) { +memcpy (&buf[8 ],"IBM " ,8 ); +if (dev->transport->get_device_type (dev) ==TYPE_ROM ) +memcpy (&buf[16 ],"VOPTA " ,16 );
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 556
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +6
-0+else +memcpy (&buf[16 ],"3303 NVDISK" ,16 ); +memcpy (&buf[32 ],"0001" ,4 ); +transport_kunmap_data_sg (se_cmd); + } +}Shouldn't a sense code be returned to the initiator if this function fails?
This function never fails? Also this is a temporary function that will go away soon. It's to address AIX not recognizing target emulation of inquiry, but we have already discussed internally to add these ODM entries into AIX.
Quoted 4 lines
Quoted 4 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +4
-0+default : +pr_err ("ibmvscsis: unknown task mgmt func %d\n" , + srp_tsk->tsk_mgmt_func); + cmd->se_cmd.se_tmr_req->response =
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 1707
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +6
-0+TMR_TASK_MGMT_FUNCTION_NOT_SUPPORTED ; + rc =-1 ; +break ; + } + +if (!rc) {Please consider changing the above "break" into "goto fail" such that the if (!rc) can be left out and such that the indentation of the code below if (!rc) can be reduced.
Done
Quoted 5 lines
Quoted 5 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +5
-0+static int ibmvscsis_queuecommand (struct ibmvscsis_adapter *adapter, +struct iu_entry *iue) +{ +struct srp_cmd *cmd = iue->sbuf->buf; +struct scsi_cmnd *sc;
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 1838
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +6
-0+struct ibmvscsis_cmnd *vsc; +int ret; + +pr_debug ("ibmvscsis: ibmvscsis_queuecommand\n" ); + + vsc =kzalloc (sizeof (*vsc),GFP_KERNEL );Allocating memory in the command processing path in a SCSI driver usually causes suboptimal performance. Other LIO target drivers preallocate such buffers before I/O starts.
We have a version of this driver that uses preallocation of the buffers. It's not currently being pushed up for review because it was written by referencing the internal VIOS VSCSI driver. Once our lawyers have approved the open-sourcing of the internal driver we will push up patches to address this issue and add a lot more features.
Quoted 45 lines
Quoted 45 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +45
-0+static uint64_t ibmvscsis_unpack_lun (const uint8_t *lun,int len) +{ +uint64_t res =NO_SUCH_LUN ; +int addressing_method; + +if (unlikely (len <2 )) { +pr_err ("Illegal LUN length %d, expected 2 bytes or more\n" , + len); + goto out; + } + +switch (len) { +case 8 : +if ((*((__be64 *)lun) &cpu_to_be64 (0x0000FFFFFFFFFFFFLL )) !=0 ) + goto out_err; +break ; +case 4 : +if (*((__be16 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 6 : +if (*((__be32 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 2 : +break ; +default : + goto out_err; + } + + addressing_method = (*lun) >>6 ;/* highest two bits of byte 0 */ +switch (addressing_method) { +case SCSI_LUN_ADDR_METHOD_PERIPHERAL : +case SCSI_LUN_ADDR_METHOD_FLAT : +case SCSI_LUN_ADDR_METHOD_LUN : + res = *(lun +1 ) | (((*lun) &0x3f ) <<8 ); +break ; + +case SCSI_LUN_ADDR_METHOD_EXTENDED_LUN : +default : +pr_err ("Unimplemented LUN addressing method %u\n" , + addressing_method); +break ; + } +
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.c line 1900
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +6
-0+out: +return res; +out_err: +pr_err ("Support for multi-level LUNs has not yet been implemented\n" ); + goto out; +}In the above function there is nothing that is specific to the VIO mechanism. Please consider to merge this function with
scsilun_to_int(), e.g. by introducing a new function that accepts a SCSI LUN and the addressing method as arguments and by makingscsilun_to_int()call that function withSCSI_LUN_ADDR_METHOD_PERIPHERALas one of its arguments.
We are going to keep this here atm, until we can make sure canonical can pick up these changes, since we have a deliverable for a 3rd party vendor who is going to fully utilize this driver. Once they can pick it up in 4.4 kernel I will make the change you recommended / move the scsi_lun_addr_method addressed below. I will also address the changes that ib_srpt needs to utilize this new function too.
Quoted 12 lines
Quoted 12 lines
drivers/scsi/ibmvscsi/ibmvscsis.h new file +12
-0+struct inquiry_data { +u8 qual_type; +u8 rmb_reserve; +u8 version; +u8 aerc_naca_hisup_format; +u8 addl_len; +u8 sccs_reserved; +u8 bque_encserv_vs_multip_mchngr_reserved; +u8 reladr_reserved_linked_cmdqueue_vs; +char vendor[8 ]; +char product[16 ]; +char revision[4 ];
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.h line 132
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.h new file +6
-0+char vendor_specific[20 ]; +char reserved1[2 ]; +char version_descriptor[16 ]; +char reserved2[22 ]; +char unique[158 ]; +};Is this the inquiry data response format from SPC? If so, this is a structure definition that is useful for the SCSI initiator core and also for other LIO target drivers. There might be a more appropriate header file for this definition.
It is from the SPC, but it was already defined. So I removed this and my driver wasn't using it atm anyways.
Quoted 9 lines
drivers/scsi/ibmvscsi/ibmvscsis.h line 146
Quoted 6 lines
drivers/scsi/ibmvscsi/ibmvscsis.h new file +6
-0+enum scsi_lun_addr_method { +SCSI_LUN_ADDR_METHOD_PERIPHERAL =0 , +SCSI_LUN_ADDR_METHOD_FLAT =1 , +SCSI_LUN_ADDR_METHOD_LUN =2 , +SCSI_LUN_ADDR_METHOD_EXTENDED_LUN =3 , +};Same comment here.
Comment from above.
Quoted 11 lines
drivers/scsi/libsrp.c line 2
Quoted 8 lines
drivers/scsi/libsrp.c new file +2
-0@@ -0,0 +1,387 @@ +/******************************************************************************* +* SCSI RDMA Protocol lib functions My understanding of the VIO mechanism is that the invocation of
H_COPY_RDMAis synchronous. This means that this operation only finishes after the data has been transferred. If I interpret the code inlibsrp.candlibsrp.hcorrectly then this code can only be used by SRP drivers use synchronous data transfers and not by SRP drivers that use asynchronous data transfers. This means that this code is not useful for any of the SRP drivers that are already upstream (ib_srpandib_srpt). Hence my proposal to move thelibsrp.candlibsrp.hsource files fromdrivers/scsiandinclude/scsito the same directory as the ibmvscsis driver.
Done
Thanks for the reviews thus far, I apologize for some of the styling problems that Joe had pointed out. I didn't run --strict against the patch and had missed a lot of stuff. It's also my first time working with the Linux community, so I apologize.
-Bryant
IBM VSCSI Target Driver Initial Patch Sets
In reply to Bryant G. LyThis patch series addresses comments by Joe with runing checkpatch with a --strict. It cleans up all the misc styling and removes all the forward declarations.
The patch also addresses all of Bart's comments besides the preallocation of buffers before IO starts and the merging of unpack_lun with scsiluntoint. Those will come in later patch sets.
[PATCH 2/3] ibmvscsis: Addressing Bart's comments
[PATCH 3/3] ibmvscsis: clean up functions
PATCH 2/3 ibmvscsis: Addressing Bart's comments
From: bryantly <[email protected]>
This patch contains cleaning up the code for styling and also addresses Bart's comments.
--- MAINTAINERS | 4 +- drivers/scsi/Kconfig | 36 +-- drivers/scsi/Makefile | 4 +- drivers/scsi/ibmvscsi/Makefile | 3 +- drivers/scsi/ibmvscsi/ibmvscsis.c | 450 ++++++++++++++++++-------------------- drivers/scsi/ibmvscsi/ibmvscsis.h | 40 ++-- drivers/scsi/ibmvscsi/libsrp.c | 386 ++++++++++++++++++++++++++++++++ drivers/scsi/ibmvscsi/libsrp.h | 91 ++++++++ drivers/scsi/libsrp.c | 387 -------------------------------- include/scsi/libsrp.h | 95 -------- 10 files changed, 737 insertions(+), 759 deletions(-) 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
MAINTAINERS +2 -2
@@ -5387,9 +5387,9 @@ L: [email protected] L: [email protected] S: Supported F: drivers/scsi/ibmvscsi/ibmvscsis.c -F: drivers/scsi/ibmvscsi/ibmvscsis.h +F: drivers/scsi/ibmvscsi/ibmvscsis.h F: drivers/scsi/libsrp.h -F: drivers/scsi/libsrp.c +F: drivers/scsi/libsrp.c IBM Power Virtual FC Device Drivers M: Tyrel Datwyler <[email protected]>
drivers/scsi/Kconfig +21 -15
@@ -848,18 +848,21 @@ config SCSI_IBMVSCSI module will be called ibmvscsi. config SCSI_IBMVSCSIS - tristate "IBM Virtual SCSI Server support" - depends on PPC_PSERIES && SCSI_SRP && TARGET_CORE - help - This is the IBM POWER Virtual SCSI Target Server + tristate "IBM Virtual SCSI Server support" + depends on PPC_PSERIES && SCSI_SRP && TARGET_CORE + 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 component needed to initialize the driver and - documentation can be found: + The userspace component needed to initialize the driver and + documentation can be found: - https://github.com/powervm/ibmvscsis + https://github.com/powervm/ibmvscsis - To compile this driver as a module, choose M here: the - module will be called ibmvstgt. + To compile this driver as a module, choose M here: the + module will be called ibmvstgt. config SCSI_IBMVFC tristate "IBM Virtual FC support"
@@ -1743,14 +1746,17 @@ config SCSI_PM8001 based host adapters. config SCSI_SRP - tristate "SCSI RDMA Protocol helper library" - depends on SCSI && PCI - help - This scsi srp module is a library for ibmvscsi target driver. + tristate "SCSI RDMA Protocol helper library" + depends on SCSI && PCI + help + This SCSI SRP module is a library for ibmvscsi target driver. + This module can only be used by SRP drivers that utilize synchronous + data transfers and not by SRP drivers that use asynchronous. + 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. + 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"
drivers/scsi/Makefile +2 -2
@@ -127,9 +127,9 @@ 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_SRP) += ibmvscsi/ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/ -obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ +obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ obj-$(CONFIG_SCSI_IBMVFC) += ibmvscsi/ obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o obj-$(CONFIG_SCSI_STEX) += stex.o
drivers/scsi/ibmvscsi/Makefile +2 -1
@@ -1,3 +1,4 @@ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi.o -obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsis.o +obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsis.o obj-$(CONFIG_SCSI_IBMVFC) += ibmvfc.o +obj-$(CONFIG_SCSI_SRP) += libsrp.o
drivers/scsi/ibmvscsi/ibmvscsis.c +218 -232
1,171 lines not on this page · raw message
drivers/scsi/ibmvscsi/ibmvscsis.h +15 -25
@@ -25,27 +25,36 @@#ifndef __H_IBMVSCSIS#define __H_IBMVSCSIS +#define SYS_ID_NAME_LEN 64 +#define PARTITION_NAMELEN 97#define IBMVSCSIS_NAMELEN 32#define SCSOLNT_RESP_SHIFT 1#define UCSOLNT_RESP_SHIFT 2 -#define SCSOLNT (1 << SCSOLNT_RESP_SHIFT) -#define UCSOLNT (1 << UCSOLNT_RESP_SHIFT) +#define SCSOLNT BIT(SCSOLNT_RESP_SHIFT) +#define UCSOLNT BIT(UCSOLNT_RESP_SHIFT)#define INQ_DATA_OFFSET 8#define NO_SUCH_LUN ((u64)-1LL) +struct crq_queue { +struct viosrp_crq *msgs; +int size, cur; +dma_addr_t msg_token; +spinlock_t lock; +}; +struct client_info {#define SRP_VERSION "16.a"char srp_version[8 ];/* root node property ibm,partition-name */ -char partition_name[96 ]; +char partition_name[PARTITION_NAMELEN ];/* root node property ibm,partition-no */ -uint32_t partition_number; +u32 partition_number;/* initially 1 */ -uint32_t mad_version; -uint32_t os_type; +u32 mad_version; +u32 os_type; }; struct ibmvscsis_cmnd {
@@ -112,25 +121,6 @@ struct ibmvscsis_nacl {struct se_node_acl se_node_acl; }; -struct inquiry_data { -u8 qual_type; -u8 rmb_reserve; -u8 version; -u8 aerc_naca_hisup_format; -u8 addl_len; -u8 sccs_reserved; -u8 bque_encserv_vs_multip_mchngr_reserved; -u8 reladr_reserved_linked_cmdqueue_vs; -char vendor[8 ]; -char product[16 ]; -char revision[4 ]; -char vendor_specific[20 ]; -char reserved1[2 ]; -char version_descriptor[16 ]; -char reserved2[22 ]; -char unique[158 ]; -}; -enum srp_trans_event {UNUSED_FORMAT =0 ,PARTNER_FAILED =1 ,
drivers/scsi/ibmvscsi/libsrp.c new file +386 -0
386 lines not on this page · raw message
drivers/scsi/ibmvscsi/libsrp.h new file +91 -0
91 lines not on this page · raw message
drivers/scsi/libsrp.c deleted +0 -387
387 lines not on this page · raw message
include/scsi/libsrp.h deleted +0 -95
95 lines not on this page · raw message
Signature · 1 line
2.5.4 (Apple Git-61)
PATCH 3/3 ibmvscsis: clean up functions
In reply to Bryant G. LyFrom: bryantly <[email protected]>
This patch removes forward declarations and re-organizes the functions within the driver. This patch also fixes MAINTAINERS for ibmvscsis.
--- MAINTAINERS | 4 +- drivers/scsi/ibmvscsi/ibmvscsis.c | 2709 ++++++++++++++++++------------------- 2 files changed, 1315 insertions(+), 1398 deletions(-)
MAINTAINERS +2 -2
@@ -5388,8 +5388,8 @@ L: [email protected] S: Supported F: drivers/scsi/ibmvscsi/ibmvscsis.c F: drivers/scsi/ibmvscsi/ibmvscsis.h -F: drivers/scsi/libsrp.h -F: drivers/scsi/libsrp.c +F: drivers/scsi/ibmvscsi/libsrp.c +F: drivers/scsi/ibmvscsi/libsrp.h IBM Power Virtual FC Device Drivers M: Tyrel Datwyler <[email protected]>
drivers/scsi/ibmvscsi/ibmvscsis.c +1313 -1396
2,990 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.5.4 (Apple Git-61)
Part of the diff is not shown here. View the raw message.
Re: [PATCH 3/3] ibmvscsis: clean up functions
Quoted 1 line · Bryant G. Ly
From: bryantly <[email protected]>
Please use your whole name here and for your sign-off like:
From: Bryant G. Ly <[email protected]>
Quoted 3 lines
This patch removes forward declarations and re-organizes the functions within the driver. This patch also fixes
MAINTAINERSfor ibmvscsis.
trivial note:
drivers/scsi/ibmvscsi/ibmvscsis.c
Quoted 1 line
drivers/scsi/ibmvscsi/ibmvscsis.c +0
-0
[]
Quoted 4 lines
static inline long
h_copy_rdma(s64 length, u64 sliobn, u64 slioba, u64 dliobn, u64 dlioba)
{
Functions like this would be less indented and less line wrapped for 80 columns if they were written:
if (!se_cmd->residual_count) return; [unindented one level...]
etc...
Quoted 64 lines · Bryant G Ly
Quoting Bart Van Assche <[email protected]>:
Quoted 53 lines · Bryant G. Ly
Quoted 52 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +14
-0+static uint64_t ibmvscsis_unpack_lun (const uint8_t *lun,int len) +{ +uint64_t res =NO_SUCH_LUN ; +int addressing_method; + +if (unlikely (len <2 )) { +pr_err ("Illegal LUN length %d, expected 2 bytes or more\n" , + len); + goto out; + } + +switch (len) { +case 8 : + if ((*((__be64 *)lun) & cpu_to_be64(0x0000FFFFFFFFFFFFLL))!= 0)
drivers/scsi/ibmvscsi/ibmvscsis.c new file +35
-0+ goto out_err; +break ; +case 4 : +if (*((__be16 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 6 : +if (*((__be32 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 2 : +break ; +default : + goto out_err; + } + + addressing_method = (*lun) >>6 ;/* highest two bits of byte 0 */ +switch (addressing_method) { +case SCSI_LUN_ADDR_METHOD_PERIPHERAL : +case SCSI_LUN_ADDR_METHOD_FLAT : +case SCSI_LUN_ADDR_METHOD_LUN : + res = *(lun +1 ) | (((*lun) &0x3f ) <<8 ); +break ; + +case SCSI_LUN_ADDR_METHOD_EXTENDED_LUN : +default : +pr_err ("Unimplemented LUN addressing method %u\n" , + addressing_method); +break ; + } + +out: +return res; +out_err: + pr_err("Support for multi-level LUNs has not yet beenimplemented\n");
+ goto out;Quoted 9 lines
Quoted 1 line
+}
In the above function there is nothing that is specific to the VIO mechanism. Please consider to merge this function with
scsilun_to_int(), e.g. by introducing a new function that accepts a SCSI LUN and the addressing method as arguments and by makingscsilun_to_int()call that function withSCSI_LUN_ADDR_METHOD_PERIPHERALas one of its arguments.
Quoted 9 lines
We are going to keep this here atm, until we can make sure canonical can pick up
these changes, since we have a deliverable for a 3rd party vendor who is going to
fully utilize this driver. Once they can pick it up in 4.4 kernel I will make the
change you recommended / move thescsi_lun_addr_methodaddressed below. I will also
address the changes thatib_srptneeds to utilize this new function too.
A much better approach would be to move this function into the SCSI core and to add a copy of that function to the backported driver that will be provided to Canonical.
Thanks,
Bart.
Quoted 75 lines · Bart Van Assche
Quoted 64 lines · Bryant G Ly
Quoting Bart Van Assche <[email protected]>:
Quoted 53 lines · Bryant G. Ly
Quoted 52 lines
drivers/scsi/ibmvscsi/ibmvscsis.c new file +14
-0+static uint64_t ibmvscsis_unpack_lun (const uint8_t *lun,int len) +{ +uint64_t res =NO_SUCH_LUN ; +int addressing_method; + +if (unlikely (len <2 )) { +pr_err ("Illegal LUN length %d, expected 2 bytes or more\n" , + len); + goto out; + } + +switch (len) { +case 8 : + if ((*((__be64 *)lun) & cpu_to_be64(0x0000FFFFFFFFFFFFLL))!= 0)
drivers/scsi/ibmvscsi/ibmvscsis.c new file +35
-0+ goto out_err; +break ; +case 4 : +if (*((__be16 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 6 : +if (*((__be32 *)&lun[2 ]) !=0 ) + goto out_err; +break ; +case 2 : +break ; +default : + goto out_err; + } + + addressing_method = (*lun) >>6 ;/* highest two bits of byte 0 */ +switch (addressing_method) { +case SCSI_LUN_ADDR_METHOD_PERIPHERAL : +case SCSI_LUN_ADDR_METHOD_FLAT : +case SCSI_LUN_ADDR_METHOD_LUN : + res = *(lun +1 ) | (((*lun) &0x3f ) <<8 ); +break ; + +case SCSI_LUN_ADDR_METHOD_EXTENDED_LUN : +default : +pr_err ("Unimplemented LUN addressing method %u\n" , + addressing_method); +break ; + } + +out: +return res; +out_err: + pr_err("Support for multi-level LUNs has not yet beenimplemented\n");
+ goto out;Quoted 9 lines
Quoted 1 line
+}
In the above function there is nothing that is specific to the VIO mechanism. Please consider to merge this function with
scsilun_to_int(), e.g. by introducing a new function that accepts a SCSI LUN and the addressing method as arguments and by makingscsilun_to_int()call that function withSCSI_LUN_ADDR_METHOD_PERIPHERALas one of its arguments.Quoted 9 lines
We are going to keep this here atm, until we can make sure canonical can pick up
these changes, since we have a deliverable for a 3rd party vendor who is going to
fully utilize this driver. Once they can pick it up in 4.4 kernel I will make the
change you recommended / move thescsi_lun_addr_methodaddressed below. I will also
address the changes thatib_srptneeds to utilize this new function too.
Quoted 3 lines
A much better approach would be to move this function into the SCSI core and to add a copy of that function to the backported driver that will be provided to Canonical.
AFAICT, the problem with this improvement is that it's not stable material, which means that Canonical would have to carry this separately beyond linux-4.4.y, in order to support ibmvscsi-tgt.
As-is, it looks like we'll have two target-core fixes to support ibmvscsi-tgt, both of which are considered stable material at this point and will eventually make it to linux-4.4.y.
That said Bryant, I still don't have an objection for the initial commit to use it's own internal ibmvscsis_unpack_lun(), but it would be nice in the patch series containing the initial ibmvscsi-tgt commit to include an incremental patch to make this common code, as Bart has highlighted.
Quoted 3 lines · Nicholas A. Bellinger
AFAICT, the problem with this improvement is that it's not stable material, which means that Canonical would have to carry this separately beyond linux-4.4.y, in order to support ibmvscsi-tgt.
So who cares? If they have a business interest in backporting the driver they'll need to figure out a way. None of that should matter in any way whatsover for mainline.