Re: [PATCH] add u64 number parser

2016-07-22 Thread Bart Van Assche

On 07/22/16 17:23, James Smart wrote:

+   buf = kmalloc(len + 1, GFP_KERNEL);
+   if (!buf)
+   return -ENOMEM;
+   memcpy(buf, s->from, len);
+   buf[len] = '\0';


Hello James,

Have you considered to combine the above kmalloc() and memcpy() calls 
into a single kasprintf(GFP_KERNEL, "%.*s", len, s->from) call?


Bart.

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/5] nvme-fabrics: add FC Transport support

2016-07-22 Thread James Smart

This patchset adds FC transport support to nvme fabrics.   Adds both
initiator and target.  The transport utilizes a lower-level api with
FC hbas to actually perform FC link traffic. The drivers are mostly
ignorant of the actual NVME transport implementation, and provide
hooks to send/receive FC-4 LS request/responses or to perform FCP IO
operations.

Patches are cut against the linux-nvme for-4.8/drivers branch

Also dependent on the u64 parser being pulled in.

Note: these patches had been posted to the prior nvme fabrics code but
not merged before being brought over to linux-nvme.


-- james

Signed-off-by: James Smart 


James Smart (5):
  nvme-fabrics: Add FC transport FC-NVME definitions
  nvme-fabrics: Add FC transport LLDD api definitions
  nvme-fabrics: Add host FC transport support
  nvme-fabrics: Add target FC transport support
  nvme-fabrics: Add FC LLDD loopback driver to test FC host and target
transport

 drivers/nvme/host/Kconfig  |   15 +
 drivers/nvme/host/Makefile |3 +
 drivers/nvme/host/fc.c | 2113 
 drivers/nvme/target/Kconfig|   23 +
 drivers/nvme/target/Makefile   |4 +
 drivers/nvme/target/fc.c   | 1881 +++
 drivers/nvme/target/fcloop.c   |  803 +++
 include/linux/nvme-fc-driver.h |  823 
 include/linux/nvme-fc.h|  296 ++
 9 files changed, 5961 insertions(+)
 create mode 100644 drivers/nvme/host/fc.c
 create mode 100644 drivers/nvme/target/fc.c
 create mode 100644 drivers/nvme/target/fcloop.c
 create mode 100644 include/linux/nvme-fc-driver.h
 create mode 100644 include/linux/nvme-fc.h

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] nvme-fabrics: Add nvme host FC transport support to lpfc driver

2016-07-22 Thread James Smart

This patch updates the lpfc driver such that it ties into the NVME FC
transport to add host (initiator) support.
It currently is an unoptimized NVME implementation.

The patch:
-Replaces stubs so that the local FC port is registered with the
 NVME FC transport as a "nvme local port"
-Replaces stubs in the discovery code so that nvme targets are
 registered with the NVME FC transport as a "nvme remote ports"
-Adds the lpfc_nvme.c file which contains all the entrypoints to support
 the NVME FC transport host interfaces. Supports sending of FC-4 LS and
 FCP IO requests to the base driver


Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/Makefile   |3 +-
 drivers/scsi/lpfc/lpfc_crtn.h|3 +
 drivers/scsi/lpfc/lpfc_hbadisc.c |   26 +-
 drivers/scsi/lpfc/lpfc_init.c|   15 +-
 drivers/scsi/lpfc/lpfc_nvme.c| 1447 ++
 5 files changed, 1489 insertions(+), 5 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.c

diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile
index 9606a13..cd7e1fc 100644
--- a/drivers/scsi/lpfc/Makefile
+++ b/drivers/scsi/lpfc/Makefile
@@ -30,4 +30,5 @@ obj-$(CONFIG_SCSI_LPFC) := lpfc.o
 
 lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o \
lpfc_hbadisc.o  lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o   \
-   lpfc_scsi.o lpfc_attr.o lpfc_vport.o lpfc_debugfs.o lpfc_bsg.o
+   lpfc_scsi.o lpfc_attr.o lpfc_vport.o lpfc_debugfs.o lpfc_bsg.o \
+   lpfc_nvme.o
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index bfac2c6..ab2b4eb 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -514,3 +514,6 @@ void lpfc_release_scsi_buf(struct lpfc_hba *, struct 
lpfc_scsi_buf *);
 struct lpfc_scsi_buf *lpfc_get_scsi_buf(struct lpfc_hba *,
struct lpfc_nodelist *);
 
+/* NVME interfaces. */
+int lpfc_create_nvme_lport(struct lpfc_vport *);
+void lpfc_destroy_nvme_lport(struct lpfc_nvme *);
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 2061636..e213cf0f7 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -4060,6 +4060,7 @@ lpfc_register_nvme_port(struct lpfc_vport *vport, struct 
lpfc_nodelist *ndlp)
struct lpfc_nvme *pnvme = vport->pnvme;
struct lpfc_nvme_lport *lport;
struct lpfc_nvme_rport *rport;
+   struct nvme_fc_remote_port *remote_port;
struct nvme_fc_port_info rpinfo;
struct lpfc_nodelist *fndlp;
 
@@ -4152,7 +4153,30 @@ regit:
else
rpinfo.fabric_name = lport->localport->fabric_name;
 
-   /* TODO: bind with nvme layer - register remote nvme port */
+   ret = nvme_fc_register_remoteport(lport->localport, ,
+ _port);
+   if (!ret) {
+   rport = remote_port->private;
+   rport->remoteport = remote_port;
+   rport->lport = lport;
+   rport->ndlp = ndlp;
+   ndlp->nrport = rport;
+   INIT_LIST_HEAD(>list);
+   list_add_tail(>list, >rport_list);
+   lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME | LOG_NODE,
+"6031 Binding new rport to "
+"lport %p using fabricName 0x%llx "
+"Rport WWNN 0x%llx, Rport WWPN 0x%llx "
+"DID x%06x Role x%x\n",
+lport,
+lport->localport->fabric_name,
+rpinfo.node_name, rpinfo.port_name,
+rpinfo.port_id, rpinfo.port_role);
+   } else
+   lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME | LOG_NODE,
+"6031 RemotePort Registration failed "
+"err: %d, DID x%06x\n",
+ret, ndlp->nlp_DID);
} else {
ret = -EINVAL;
lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME,
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 53d3e75..1b786e7 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -5377,8 +5377,10 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
if (bf_get(lpfc_sli_intf_if_type, >sli4_hba.sli_intf) ==
LPFC_SLI_INTF_IF_TYPE_2) {
rc = lpfc_pci_function_reset(phba);
-   if (unlikely(rc))
+   if (unlikely(rc)) {
+   rc = -ENODEV;
goto out_free_mem;
+   }
phba->temp_sensor_support = 1;
  

[PATCH 1/5] nvme-fabrics: Add FC transport FC-NVME definitions

2016-07-22 Thread James Smart

nvme-fabrics: Add FC transport FC-NVME definitions:
- Formats for Cmd, Data, Rsp IUs
- Formats FC-4 LS definitions


Signed-off-by: James Smart 

---
 include/linux/nvme-fc.h | 296 
 1 file changed, 296 insertions(+)
 create mode 100644 include/linux/nvme-fc.h

diff --git a/include/linux/nvme-fc.h b/include/linux/nvme-fc.h
new file mode 100644
index 000..99e9200
--- /dev/null
+++ b/include/linux/nvme-fc.h
@@ -0,0 +1,296 @@
+/*
+ * Copyright (c) 2016 Avago Technologies.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful.
+ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
+ * THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package
+ *
+ */
+
+/*
+ * This file contains definitions relative to FC-NVME r1.05
+ */
+
+#ifndef _NVME_FC_H
+#define _NVME_FC_H 1
+
+#define NVME_FC4_TYPE  0x28
+
+#define NVME_CMD_SCSI_ID   0xFD
+#define NVME_CMD_FC_ID NVME_FC4_TYPE
+
+/* FC-NVME Cmd IU Flags */
+#define FCNVME_CMD_FLAGS_DIRMASK   0x03
+#define FCNVME_CMD_FLAGS_WRITE 0x01
+#define FCNVME_CMD_FLAGS_READ  0x02
+
+struct nvme_fc_cmd_iu {
+   __u8scsi_id;
+   __u8fc_id;
+   __be16  iu_len;
+   __u8rsvd4[3];
+   __u8flags;
+   __be32  rsvd8[2];
+   __be64  connection_id;
+   __be32  csn;
+   __be32  data_len;
+   struct nvme_command sqe;
+};
+
+#define NVME_FC_SIZEOF_ZEROS_RSP   12
+
+struct nvme_fc_ersp_iu {
+   __u8rsvd0[2];
+   __be16  iu_len;
+   __be32  rsn;
+   __be32  rsvd8[2];
+   struct nvme_completion  cqe;
+   /* for now - no additional payload */
+};
+
+
+/* FC-NVME r1.03/16-119v0 NVME Link Services */
+enum {
+   FCNVME_LS_RSVD  = 0,
+   FCNVME_LS_RJT   = 1,
+   FCNVME_LS_ACC   = 2,
+   FCNVME_LS_CREATE_ASSOCIATION= 3,
+   FCNVME_LS_CREATE_CONNECTION = 4,
+   FCNVME_LS_DISCONNECT= 5,
+};
+
+/* FC-NVME r1.03/16-119v0 NVME Link Service Descriptors */
+enum {
+   FCNVME_LSDESC_RSVD  = 0x0,
+   FCNVME_LSDESC_RQST  = 0x1,
+   FCNVME_LSDESC_RJT   = 0x2,
+   FCNVME_LSDESC_CREATE_ASSOC_CMD  = 0x3,
+   FCNVME_LSDESC_CREATE_CONN_CMD   = 0x4,
+   FCNVME_LSDESC_DISCONN_CMD   = 0x5,
+   FCNVME_LSDESC_CONN_ID   = 0x6,
+   FCNVME_LSDESC_ASSOC_ID  = 0x7,
+};
+
+
+/* ** start of Link Service Descriptors ** */
+
+
+/* fills in length of a descriptor. Struture minus descriptor header */
+#define FCNVME_LSDESC_LEN(lsdesc) \
+   cpu_to_be32(sizeof(lsdesc) - (2*(sizeof(u32
+
+struct fcnvme_ls_rqst_w0 {
+   u8  ls_cmd; /* FCNVME_LS_xxx */
+   u8  zeros[3];
+};
+
+/* FCNVME_LSDESC_RQST */
+struct fcnvme_lsdesc_rqst {
+   __be32  desc_tag;   /* FCNVME_LSDESC_xxx */
+   __be32  desc_len;
+   struct fcnvme_ls_rqst_w0w0;
+   __be32  rsvd12;
+};
+
+/* From LS-3 */
+enum {
+   LSRJT_REASON_INVALID_ELS_CODE   = 0x1,
+   LSRJT_REASON_LOGICAL_ERROR  = 0x3,
+   LSRJT_REASON_LOGICAL_BUSY   = 0x5,
+   LSRJT_REASON_PROTOCOL_ERROR = 0x7,
+   LSRJT_REASON_UNABLE_TO_PERFORM_CMD  = 0x9,
+   LSRJT_REASON_CMD_NOT_SUPPORTED  = 0xB,
+   LSRJT_REASON_CMD_ALREADY_IN_PROGRESS= 0xE,
+   LSRJT_REASON_FIP_ERROR  = 0x20,
+   /* Add others later */
+};
+
+enum {
+   LSRJT_EXPL_NO_EXPLANATION   = 0x0,
+   /* Add others later */
+};
+
+
+/* FCNVME_LSDESC_RJT */
+struct fcnvme_lsdesc_rjt {
+   __be32  desc_tag;   /* FCNVME_LSDESC_xxx */
+   __be32  desc_len;
+   u8  rsvd8;
+   u8  reason_code;
+   u8  reason_explanation;
+   u8  vendor;
+   __be32  rsvd12;
+};
+
+
+#define FCNVME_ASSOC_HOSTID_LEN64
+#define FCNVME_ASSOC_HOSTNQN_LEN   256
+#define FCNVME_ASSOC_SUBNQN_LEN256
+
+/* FCNVME_LSDESC_CREATE_ASSOC_CMD */
+struct fcnvme_lsdesc_cr_assoc_cmd {
+   __be32  desc_tag;   /* 

[PATCH 4/5] nvme-fabrics: Add target FC transport support

2016-07-22 Thread James Smart

Add nvme-fabrics target FC transport support

Implements the FC-NVME T11 definition of how nvme fabric capsules are
performed on an FC fabric. Utilizes a lower-layer API to FC host adapters
to send/receive FC-4 LS operations and perform the FCP transactions necessary
to perform and FCP IO request for NVME.

The T11 definitions for FC-4 Link Services are implemented which create
NVMeOF connections.  Implements the hooks with nvmet layer to pass NVME
commands to it for processing and posting of data/response base to the
host via the differernt connections.


Signed-off-by: James Smart 

---
 drivers/nvme/target/Kconfig  |   10 +
 drivers/nvme/target/Makefile |2 +
 drivers/nvme/target/fc.c | 1881 ++
 3 files changed, 1893 insertions(+)
 create mode 100644 drivers/nvme/target/fc.c

diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
index a5c31cb..62819b2 100644
--- a/drivers/nvme/target/Kconfig
+++ b/drivers/nvme/target/Kconfig
@@ -34,3 +34,13 @@ config NVME_TARGET_RDMA
  devices over RDMA.
 
  If unsure, say N.
+
+config NVME_TARGET_FC
+   tristate "NVMe over Fabrics FC target driver"
+   select NVME_TARGET
+   help
+ This enables the NVMe FC target support, which allows exporting NVMe
+ devices over FC.
+
+ If unsure, say N.
+
diff --git a/drivers/nvme/target/Makefile b/drivers/nvme/target/Makefile
index b7a0623..80b128b 100644
--- a/drivers/nvme/target/Makefile
+++ b/drivers/nvme/target/Makefile
@@ -2,8 +2,10 @@
 obj-$(CONFIG_NVME_TARGET)  += nvmet.o
 obj-$(CONFIG_NVME_TARGET_LOOP) += nvme-loop.o
 obj-$(CONFIG_NVME_TARGET_RDMA) += nvmet-rdma.o
+obj-$(CONFIG_NVME_TARGET_FC)   += nvmet-fc.o
 
 nvmet-y+= core.o configfs.o admin-cmd.o io-cmd.o fabrics-cmd.o 
\
discovery.o
 nvme-loop-y+= loop.o
 nvmet-rdma-y   += rdma.o
+nvmet-fc-y += fc.o
diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c
new file mode 100644
index 000..3a5a522
--- /dev/null
+++ b/drivers/nvme/target/fc.c
@@ -0,0 +1,1881 @@
+/*
+ * Copyright (c) 2016 Avago Technologies.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful.
+ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
+ * THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package
+ *
+ */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include 
+#include 
+#include 
+#include 
+
+#include "nvmet.h"
+#include 
+#include 
+
+
+/* *** Data Structures/Defines ** */
+
+
+#define NVMET_LS_CTX_COUNT 4
+
+/* for this implementation, assume small single frame rqst/rsp */
+#define NVME_FC_MAX_LS_BUFFER_SIZE 2048
+
+struct nvmet_fc_tgtport;
+struct nvmet_fc_tgt_assoc;
+
+struct nvmet_fc_ls_iod {
+   struct nvmefc_tgt_ls_req*lsreq;
+
+   struct list_headls_list;/* tgtport->ls_list */
+
+   struct nvmet_fc_tgtport *tgtport;
+   struct nvmet_fc_tgt_assoc   *assoc;
+
+   u8  *rqstbuf;
+   u8  *rspbuf;
+   u16 rqstdatalen;
+   dma_addr_t  rspdma;
+
+   struct scatterlist  sg[2];
+
+   struct work_struct  work;
+} __aligned(sizeof(unsigned long long));
+
+#define NVMET_FC_MAX_KB_PER_XFR256
+
+enum nvmet_fcp_datadir {
+   NVMET_FCP_NODATA,
+   NVMET_FCP_WRITE,
+   NVMET_FCP_READ,
+   NVMET_FCP_ABORTED,
+};
+
+struct nvmet_fc_fcp_iod {
+   struct nvmefc_tgt_fcp_req   *fcpreq;
+
+   struct nvme_fc_cmd_iu   cmdiubuf;
+   struct nvme_fc_ersp_iu  rspiubuf;
+   dma_addr_t  rspdma;
+   struct scatterlist  *data_sg;
+   struct scatterlist  *next_sg;
+   int data_sg_cnt;
+   u32 next_sg_offset;
+   u32 total_length;
+   u32 offset;
+   enum nvmet_fcp_datadir  io_dir;
+   boolaborted;
+
+   struct nvmet_reqreq;
+   struct work_struct  work;
+
+   struct nvmet_fc_tgtport *tgtport;
+   struct nvmet_fc_tgt_queue   *queue;
+
+   

[PATCH 3/3] nvme-fabrics: Add nvme target FC transport support to lpfc driver

2016-07-22 Thread James Smart

This patch updates the lpfc driver such that it ties into the NVME FC
transport to add target (nvme subsystem) support.
It currently is an unoptimized NVME implementation.

The patch:
-Updates the async RX path of the adapter to support reception
 of NVME commands
-Registers the local FC port with the NVME FC transport as a "targetport"
-Adds the lpfc_nvmet.c file which contains all the entrypoints to support
 the NVME FC transport target/subsystem interfaces. Handles the appropriate
 command requests with the adapter for target operation.
-Updates the revision of the driver to 11.2.0.1


Signed-off-by: James Smart 
---
 drivers/scsi/lpfc/Makefile |2 +-
 drivers/scsi/lpfc/lpfc.h   |6 +-
 drivers/scsi/lpfc/lpfc_crtn.h  |8 +
 drivers/scsi/lpfc/lpfc_ct.c|   10 +-
 drivers/scsi/lpfc/lpfc_debugfs.c   |  264 
 drivers/scsi/lpfc/lpfc_els.c   |   14 +-
 drivers/scsi/lpfc/lpfc_hbadisc.c   |9 +
 drivers/scsi/lpfc/lpfc_init.c  |  159 -
 drivers/scsi/lpfc/lpfc_mbox.c  |   10 +
 drivers/scsi/lpfc/lpfc_mem.c   |  110 +++-
 drivers/scsi/lpfc/lpfc_nportdisc.c |4 +-
 drivers/scsi/lpfc/lpfc_nvmet.c | 1269 
 drivers/scsi/lpfc/lpfc_nvmet.h |   72 ++
 drivers/scsi/lpfc/lpfc_sli.c   |  181 -
 drivers/scsi/lpfc/lpfc_sli4.h  |3 +
 drivers/scsi/lpfc/lpfc_version.h   |2 +-
 16 files changed, 2100 insertions(+), 23 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.c
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.h

diff --git a/drivers/scsi/lpfc/Makefile b/drivers/scsi/lpfc/Makefile
index cd7e1fc..30a6a35 100644
--- a/drivers/scsi/lpfc/Makefile
+++ b/drivers/scsi/lpfc/Makefile
@@ -31,4 +31,4 @@ obj-$(CONFIG_SCSI_LPFC) := lpfc.o
 lpfc-objs := lpfc_mem.o lpfc_sli.o lpfc_ct.o lpfc_els.o \
lpfc_hbadisc.o  lpfc_init.o lpfc_mbox.o lpfc_nportdisc.o   \
lpfc_scsi.o lpfc_attr.o lpfc_vport.o lpfc_debugfs.o lpfc_bsg.o \
-   lpfc_nvme.o
+   lpfc_nvme.o lpfc_nvmet.o
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 22dcb39..3f79fc1 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -444,6 +444,7 @@ struct lpfc_vport {
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
struct dentry *debug_disc_trc;
struct dentry *debug_nodelist;
+   struct dentry *debug_nvmestat;
struct dentry *vport_debugfs_root;
struct lpfc_debugfs_trc *disc_trc;
atomic_t disc_trc_cnt;
@@ -481,7 +482,8 @@ struct hbq_s {
 
 /* this matches the position in the lpfc_hbq_defs array */
 #define LPFC_ELS_HBQ   0
-#define LPFC_MAX_HBQS  1
+#define LPFC_NVMET_HBQ 1
+#define LPFC_MAX_HBQS  2
 
 enum hba_temp_state {
HBA_NORMAL_TEMP,
@@ -795,6 +797,7 @@ struct lpfc_hba {
 #define LPFC_ENABLE_NVME 2
 #define LPFC_ENABLE_BOTH 3
uint32_t io_channel;/* max of fcp or nvme io channels */
+   struct nvmet_fc_target_port *targetport;
lpfc_vpd_t vpd; /* vital product data */
 
struct pci_dev *pcidev;
@@ -891,6 +894,7 @@ struct lpfc_hba {
struct pci_pool *lpfc_hrb_pool; /* header receive buffer pool */
struct pci_pool *lpfc_drb_pool; /* data receive buffer pool */
struct pci_pool *lpfc_hbq_pool; /* SLI3 hbq buffer pool */
+   struct pci_pool *txrdy_payload_pool;
struct lpfc_dma_pool lpfc_mbuf_safety_pool;
 
mempool_t *mbox_mem_pool;
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index ab2b4eb..141b23f 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -234,6 +234,8 @@ struct hbq_dmabuf *lpfc_els_hbq_alloc(struct lpfc_hba *);
 void lpfc_els_hbq_free(struct lpfc_hba *, struct hbq_dmabuf *);
 struct hbq_dmabuf *lpfc_sli4_rb_alloc(struct lpfc_hba *);
 void lpfc_sli4_rb_free(struct lpfc_hba *, struct hbq_dmabuf *);
+struct hbq_dmabuf *lpfc_sli4_nvmet_alloc(struct lpfc_hba *);
+void lpfc_sli4_nvmet_free(struct lpfc_hba *, struct hbq_dmabuf *);
 void lpfc_sli4_build_dflt_fcf_record(struct lpfc_hba *, struct fcf_record *,
uint16_t);
 void lpfc_unregister_fcf(struct lpfc_hba *);
@@ -517,3 +519,9 @@ struct lpfc_scsi_buf *lpfc_get_scsi_buf(struct lpfc_hba *,
 /* NVME interfaces. */
 int lpfc_create_nvme_lport(struct lpfc_vport *);
 void lpfc_destroy_nvme_lport(struct lpfc_nvme *);
+int lpfc_nvmet_create_targetport(struct lpfc_hba *);
+void lpfc_nvmet_destroy_targetport(struct lpfc_hba *);
+void lpfc_nvmet_unsol_ls_event(struct lpfc_hba *, struct lpfc_sli_ring *,
+   struct lpfc_iocbq *);
+void lpfc_nvmet_unsol_fcp_event(struct lpfc_hba *, struct lpfc_sli_ring *,
+  struct hbq_dmabuf *);
diff --git a/drivers/scsi/lpfc/lpfc_ct.c b/drivers/scsi/lpfc/lpfc_ct.c
index 3a43cdf..6004d4b 100644
--- a/drivers/scsi/lpfc/lpfc_ct.c
+++ b/drivers/scsi/lpfc/lpfc_ct.c
@@ -1430,10 +1430,16 @@ lpfc_ns_cmd(struct lpfc_vport 

[PATCH 0/3] nvme-fabrics: Add NVME FC Transport support to lpfc

2016-07-22 Thread James Smart

This patchset adds NVME support to the lpfc FC driver.  It reworks
the core driver for both NVME and SCSI protocol support, then adds the
nvme-over-fabrics host and target interfaces which connect to the 
NVME FC transport lower-level api.

Patches are cut against the linux-nvme for-4.8/drivers branch

Dependent on:
-the u64 parser patch just posted
-the lpfc 11.2.0.0 patch set posted to linux-scsi a couple weeks back.
 http://www.spinics.net/lists/linux-scsi/msg97964.html
 http://www.spinics.net/lists/linux-scsi/msg98219.html


Caveats:

-Depends on the lpfc 11.2.0.0 patch set posted to linux-scsi being present
 in the tree:
 http://www.spinics.net/lists/linux-scsi/msg97964.html
 http://www.spinics.net/lists/linux-scsi/msg98219.html

-Depends on the NVME FC Transport patches

-cut against the linux-nvme for-4.8/drivers branch

-Individual patches not tested much individually. All testing has been
 with all 3 patches together - base, host, and target.

-Driver depends on NVME-supporting firmware which is not yet generally
 available. Contact me if there is a need to obtain the firmware.

-- james


James Smart (3):
  nvme_fabrics: Rework lpfc base driver to support the NVME protocol
  nvme-fabrics: Add nvme host FC transport support to lpfc driver
  nvme-fabrics: Add nvme target FC transport support to lpfc driver

 drivers/scsi/lpfc/Makefile |7 +-
 drivers/scsi/lpfc/lpfc.h   |   43 +-
 drivers/scsi/lpfc/lpfc_attr.c  |   69 +-
 drivers/scsi/lpfc/lpfc_crtn.h  |   32 +-
 drivers/scsi/lpfc/lpfc_ct.c|  379 +++---
 drivers/scsi/lpfc/lpfc_debugfs.c   |  636 ++--
 drivers/scsi/lpfc/lpfc_debugfs.h   |  119 ++-
 drivers/scsi/lpfc/lpfc_disc.h  |   17 +-
 drivers/scsi/lpfc/lpfc_els.c   |  212 --
 drivers/scsi/lpfc/lpfc_hbadisc.c   |  352 -
 drivers/scsi/lpfc/lpfc_hw.h|   49 +-
 drivers/scsi/lpfc/lpfc_hw4.h   |  128 +++-
 drivers/scsi/lpfc/lpfc_init.c  |  744 ++
 drivers/scsi/lpfc/lpfc_logmsg.h|1 +
 drivers/scsi/lpfc/lpfc_mbox.c  |   19 +-
 drivers/scsi/lpfc/lpfc_mem.c   |  122 ++-
 drivers/scsi/lpfc/lpfc_nportdisc.c |  150 +++-
 drivers/scsi/lpfc/lpfc_nvme.c  | 1447 
 drivers/scsi/lpfc/lpfc_nvme.h  |   62 ++
 drivers/scsi/lpfc/lpfc_nvmet.c | 1269 +++
 drivers/scsi/lpfc/lpfc_nvmet.h |   72 ++
 drivers/scsi/lpfc/lpfc_scsi.c  |   12 +-
 drivers/scsi/lpfc/lpfc_scsi.h  |   19 +-
 drivers/scsi/lpfc/lpfc_sli.c   |  785 +++
 drivers/scsi/lpfc/lpfc_sli.h   |   30 +-
 drivers/scsi/lpfc/lpfc_sli4.h  |   28 +-
 drivers/scsi/lpfc/lpfc_version.h   |2 +-
 drivers/scsi/lpfc/lpfc_vport.c |1 +
 28 files changed, 6121 insertions(+), 685 deletions(-)
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.c
 create mode 100644 drivers/scsi/lpfc/lpfc_nvme.h
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.c
 create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.h

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/5] nvme-fabrics: Add FC transport LLDD api definitions

2016-07-22 Thread James Smart

nvme-fabrics: Add FC transport LLDD api definitions:

Host:
-LLDD registration with the host transport
-registering host ports (local ports) and target ports seen on
   fabric (remote ports)
-Data structures and call points for FC-4 LS's and FCP IO requests

Target:
-LLDD registration with the target transport
-registering nvme subsystem ports (target ports)
-Data structures and call points for reception of FC-4 LS's and
   FCP IO requests, and callbacks to perform data and rsp transfers
   for the io.


Signed-off-by: James Smart 

---
 include/linux/nvme-fc-driver.h | 823 +
 1 file changed, 823 insertions(+)
 create mode 100644 include/linux/nvme-fc-driver.h

diff --git a/include/linux/nvme-fc-driver.h b/include/linux/nvme-fc-driver.h
new file mode 100644
index 000..78918a7
--- /dev/null
+++ b/include/linux/nvme-fc-driver.h
@@ -0,0 +1,823 @@
+/*
+ * Copyright (c) 2016, Avago Technologies
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef _NVME_FC_DRIVER_H
+#define _NVME_FC_DRIVER_H 1
+
+
+/*
+ * **  LLDD FC-NVME Host API 
+ *
+ *  For FC LLDD's that are the NVME Host role.
+ *
+ * **
+ */
+
+
+
+/* FC Port role bitmask - can merge with FC Port Roles in fc transport */
+#define FC_PORT_ROLE_NVME_INITIATOR0x10
+#define FC_PORT_ROLE_NVME_TARGET   0x11
+#define FC_PORT_ROLE_NVME_DISCOVERY0x12
+
+
+/**
+ * struct nvme_fc_port_info - port-specific ids and FC connection-specific
+ *data element used during NVME Host role
+ *registrations
+ *
+ * Static fields describing the port being registered:
+ * @node_name: FC WWNN for the port
+ * @port_name: FC WWPN for the port
+ * @port_role: What NVME roles are supported (see FC_PORT_ROLE_xxx)
+ *
+ * Initialization values for dynamic port fields:
+ * @fabric_name:  FC Fabric name the port is connected to. If connection is
+ *point-to-point (no switch) use srcport WWPN. If no current
+ *Link Up, set to 0.
+ * @port_id:  FC N_Port_ID currently assigned the port. Upper 8 bits must
+ *be set to 0.
+ */
+struct nvme_fc_port_info {
+   u64 node_name;
+   u64 port_name;
+   u32 port_role;
+   u64 fabric_name;
+   u32 port_id;
+};
+
+
+/**
+ * struct nvmefc_ls_req - Request structure passed from NVME-FC transport
+ *to LLDD in order to perform a NVME FC-4 LS
+ *request and obtain a response.
+ *
+ * Values set by the NVME-FC layer prior to calling the LLDD ls_req
+ * entrypoint.
+ * @rqstaddr: pointer to request buffer
+ * @rqstdma:  PCI DMA address of request buffer
+ * @rqstlen:  Length, in bytes, of request buffer
+ * @rspaddr:  pointer to response buffer
+ * @rspdma:   PCI DMA address of response buffer
+ * @rsplen:   Length, in bytes, of response buffer
+ * @timeout:  Maximum amount of time, in seconds, to wait for the LS response.
+ *If timeout exceeded, LLDD to abort LS exchange and complete
+ *LS request with error status.
+ * @private:  pointer to memory allocated alongside the ls request structure
+ *that is specifically for the LLDD to use while processing the
+ *request. The length of the buffer corresponds to the
+ *lsrqst_priv_sz value specified in the nvme_fc_port_template
+ *supplied by the LLDD.
+ * @done: The callback routine the LLDD is to invoke upon completion of
+ *the LS request. req argument is the pointer to the original LS
+ *request structure. Status argument must be 0 upon success, a
+ *negative errno on failure (example: -ENXIO).
+ */
+struct nvmefc_ls_req {
+   void*rqstaddr;
+   dma_addr_t  rqstdma;
+   u32 rqstlen;
+   void*rspaddr;
+   dma_addr_t  rspdma;
+   u32 rsplen;
+   u32 timeout;
+
+   void*private;
+
+   void (*done)(struct nvmefc_ls_req *req, int status);
+
+} __aligned(sizeof(u64));  /* alignment for other things alloc'd with */
+
+
+enum nvmefc_fcp_datadir {
+   NVMEFC_FCP_NODATA,  /* payload_length and sg_cnt will be zero */
+   NVMEFC_FCP_WRITE,
+   

[PATCH 3/5] nvme-fabrics: Add host FC transport support

2016-07-22 Thread James Smart

Add nvme-fabrics host FC transport support

Implements the FC-NVME T11 definition of how nvme fabric capsules are
performed on an FC fabric. Utilizes a lower-layer API to FC host adapters
to send/receive FC-4 LS operations and FCP operations that comprise NVME
over FC operation.

The T11 definitions for FC-4 Link Services are implemented which create
NVMeOF connections.  Implements the hooks with blk-mq to then submit admin
and io requests to the different connections.


Signed-off-by: James Smart 

---
 drivers/nvme/host/Kconfig  |   15 +
 drivers/nvme/host/Makefile |3 +
 drivers/nvme/host/fc.c | 2113 
 3 files changed, 2131 insertions(+)
 create mode 100644 drivers/nvme/host/fc.c

diff --git a/drivers/nvme/host/Kconfig b/drivers/nvme/host/Kconfig
index db39d53..acacf85 100644
--- a/drivers/nvme/host/Kconfig
+++ b/drivers/nvme/host/Kconfig
@@ -43,3 +43,18 @@ config NVME_RDMA
  from https://github.com/linux-nvme/nvme-cli.
 
  If unsure, say N.
+
+config NVME_FC
+   tristate "NVM Express over Fabrics FC host driver"
+   depends on BLK_DEV_NVME
+   select NVME_FABRICS
+   select SG_POOL
+   help
+ This provides support for the NVMe over Fabrics protocol using
+ the FC transport.  This allows you to use remote block devices
+ exported using the NVMe protocol set.
+
+ To configure a NVMe over Fabrics controller use the nvme-cli tool
+ from https://github.com/linux-nvme/nvme-cli.
+
+ If unsure, say N.
diff --git a/drivers/nvme/host/Makefile b/drivers/nvme/host/Makefile
index 47abcec..f1a7d94 100644
--- a/drivers/nvme/host/Makefile
+++ b/drivers/nvme/host/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_NVME_CORE) += nvme-core.o
 obj-$(CONFIG_BLK_DEV_NVME) += nvme.o
 obj-$(CONFIG_NVME_FABRICS) += nvme-fabrics.o
 obj-$(CONFIG_NVME_RDMA)+= nvme-rdma.o
+obj-$(CONFIG_NVME_FC)  += nvme-fc.o
 
 nvme-core-y:= core.o
 nvme-core-$(CONFIG_BLK_DEV_NVME_SCSI)  += scsi.o
@@ -12,3 +13,5 @@ nvme-y+= pci.o
 nvme-fabrics-y += fabrics.o
 
 nvme-rdma-y+= rdma.o
+
+nvme-fc-y  += fc.o
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
new file mode 100644
index 000..8c242f1
--- /dev/null
+++ b/drivers/nvme/host/fc.c
@@ -0,0 +1,2113 @@
+/*
+ * Copyright (c) 2016 Avago Technologies.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful.
+ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
+ * THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package
+ *
+ */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include 
+#include 
+
+#include "nvme.h"
+#include "fabrics.h"
+#include 
+#include 
+
+
+/* *** Data Structures/Defines ** */
+
+
+/*
+ * We handle AEN commands ourselves and don't even let the
+ * block layer know about them.
+ */
+#define NVME_FC_NR_AEN_COMMANDS1
+#define NVME_FC_AQ_BLKMQ_DEPTH \
+   (NVMF_AQ_DEPTH - NVME_FC_NR_AEN_COMMANDS)
+#define AEN_CMDID_BASE (NVME_FC_AQ_BLKMQ_DEPTH + 1)
+#define IS_AEN_COMMAND(command_id) \
+   ((command_id) >= AEN_CMDID_BASE)
+
+enum nvme_fc_queue_flags {
+   NVME_FC_Q_CONNECTED = (1 << 0),
+};
+
+#define NVMEFC_QUEUE_DELAY 3   /* ms units */
+
+struct nvme_fc_queue {
+   struct nvme_fc_ctrl *ctrl;
+   struct device   *dev;
+   struct blk_mq_hw_ctx*hctx;
+   void*lldd_handle;
+   int queue_size;
+   size_t  cmnd_capsule_len;
+   u32 qnum;
+   u32 rqcnt;
+   u32 seqno;
+   u16 sqhd;
+
+   u64 connection_id;
+   atomic_tcsn;
+
+   unsigned long   flags;
+} __aligned(sizeof(u64));  /* alignment for other things alloc'd with */
+
+struct nvmefc_ls_req_op {
+   struct nvmefc_ls_reqls_req;
+
+   struct nvme_fc_ctrl *ctrl;
+   struct nvme_fc_queue*queue;
+   struct request  *rq;
+
+   int ls_error;
+   struct completion   ls_done;
+   struct list_headlsreq_list; /* 

[PATCH 5/5] nvme-fabrics: Add FC LLDD loopback driver to test FC host and target transport

2016-07-22 Thread James Smart

Add FC LLDD loopback driver to test FC host and target transport within
nvme-fabrics

To aid in the development and testing of the lower-level api of the FC
transport, this loopback driver has been created to act as if it were a
FC hba driver supporting both the host interfaces as well as the target
interfaces with the nvme FC transport.


Signed-off-by: James Smart 

---
 drivers/nvme/target/Kconfig  |  13 +
 drivers/nvme/target/Makefile |   2 +
 drivers/nvme/target/fcloop.c | 803 +++
 3 files changed, 818 insertions(+)
 create mode 100644 drivers/nvme/target/fcloop.c

diff --git a/drivers/nvme/target/Kconfig b/drivers/nvme/target/Kconfig
index 62819b2..a20d41c 100644
--- a/drivers/nvme/target/Kconfig
+++ b/drivers/nvme/target/Kconfig
@@ -44,3 +44,16 @@ config NVME_TARGET_FC
 
  If unsure, say N.
 
+config NVME_TARGET_FCLOOP
+   tristate "NVMe over Fabrics FC Transport Loopback Test driver"
+   depends on BLK_DEV_NVME
+   select NVME_TARGET
+   select NVME_FABRICS
+   select SG_POOL
+   select NVME_FC
+   select NVME_TARGET_FC
+   help
+ This enables the NVMe FC loopback test support, which can be useful
+ to test NVMe-FC transport interfaces.
+
+ If unsure, say N.
diff --git a/drivers/nvme/target/Makefile b/drivers/nvme/target/Makefile
index 80b128b..fecc14f 100644
--- a/drivers/nvme/target/Makefile
+++ b/drivers/nvme/target/Makefile
@@ -3,9 +3,11 @@ obj-$(CONFIG_NVME_TARGET)  += nvmet.o
 obj-$(CONFIG_NVME_TARGET_LOOP) += nvme-loop.o
 obj-$(CONFIG_NVME_TARGET_RDMA) += nvmet-rdma.o
 obj-$(CONFIG_NVME_TARGET_FC)   += nvmet-fc.o
+obj-$(CONFIG_NVME_TARGET_FCLOOP)   += nvme-fcloop.o
 
 nvmet-y+= core.o configfs.o admin-cmd.o io-cmd.o fabrics-cmd.o 
\
discovery.o
 nvme-loop-y+= loop.o
 nvmet-rdma-y   += rdma.o
 nvmet-fc-y += fc.o
+nvme-fcloop-y  += fcloop.o
diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c
new file mode 100644
index 000..277ea61
--- /dev/null
+++ b/drivers/nvme/target/fcloop.c
@@ -0,0 +1,803 @@
+/*
+ * Copyright (c) 2016 Avago Technologies.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful.
+ * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO
+ * THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.
+ * See the GNU General Public License for more details, a copy of which
+ * can be found in the file COPYING included with this package
+ */
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include 
+#include 
+
+#include "../host/nvme.h"
+#include "../target/nvmet.h"
+#include 
+#include 
+
+#define is_end_of_list(pos, head, member) ((>member) == (head))
+
+enum {
+   NVMF_OPT_ERR= 0,
+   NVMF_OPT_WWNN   = 1 << 0,
+   NVMF_OPT_WWPN   = 1 << 1,
+   NVMF_OPT_ROLES  = 1 << 2,
+   NVMF_OPT_FCADDR = 1 << 3,
+   NVMF_OPT_FABRIC = 1 << 5,
+};
+
+struct fcloop_ctrl_options {
+   int mask;
+   u64 wwnn;
+   u64 wwpn;
+   u32 roles;
+   u32 fcaddr;
+   u64 fabric;
+};
+
+static const match_table_t opt_tokens = {
+   { NVMF_OPT_WWNN,"wwnn=%s"   },
+   { NVMF_OPT_WWPN,"wwpn=%s"   },
+   { NVMF_OPT_ROLES,   "roles=%d"  },
+   { NVMF_OPT_FCADDR,  "fcaddr=%x" },
+   { NVMF_OPT_FABRIC,  "fabric=%s" },
+   { NVMF_OPT_ERR, NULL}
+};
+
+static int
+fcloop_parse_options(struct fcloop_ctrl_options *opts,
+   const char *buf)
+{
+   substring_t args[MAX_OPT_ARGS];
+   char *options, *o, *p;
+   int token, ret = 0;
+   u64 token64;
+
+   options = o = kstrdup(buf, GFP_KERNEL);
+   if (!options)
+   return -ENOMEM;
+
+   while ((p = strsep(, ",\n")) != NULL) {
+   if (!*p)
+   continue;
+
+   token = match_token(p, opt_tokens, args);
+   opts->mask |= token;
+   switch (token) {
+   case NVMF_OPT_WWNN:
+   if (match_u64(args, )) {
+   ret = -EINVAL;
+   goto out_free_options;
+   }
+   opts->wwnn = token64;
+   break;
+   case NVMF_OPT_WWPN:
+   if (match_u64(args, )) {
+

[PATCH] nvme-fabrics: patch target code in prep for FC transport support

2016-07-22 Thread James Smart

Patch nvme-fabrics target code in prep for FC transport support:
- Add FC transport type decoding
- Add FC address family decoding

Patch is cut against the linux-nvme for-4.8/drivers branch

Note: this patch had been posted to the prior nvme fabrics repository but
not merged before being brought over to linux-nvme.

Signed-off-by: James Smart 
---
 drivers/nvme/target/configfs.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index af5e2dc..6ffd105 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -37,6 +37,8 @@ static ssize_t nvmet_addr_adrfam_show(struct config_item 
*item,
return sprintf(page, "ipv6\n");
case NVMF_ADDR_FAMILY_IB:
return sprintf(page, "ib\n");
+   case NVMF_ADDR_FAMILY_FC:
+   return sprintf(page, "fc\n");
default:
return sprintf(page, "\n");
}
@@ -59,6 +61,8 @@ static ssize_t nvmet_addr_adrfam_store(struct config_item 
*item,
port->disc_addr.adrfam = NVMF_ADDR_FAMILY_IP6;
} else if (sysfs_streq(page, "ib")) {
port->disc_addr.adrfam = NVMF_ADDR_FAMILY_IB;
+   } else if (sysfs_streq(page, "fc")) {
+   port->disc_addr.adrfam = NVMF_ADDR_FAMILY_FC;
} else {
pr_err("Invalid value '%s' for adrfam\n", page);
return -EINVAL;
@@ -209,6 +213,8 @@ static ssize_t nvmet_addr_trtype_show(struct config_item 
*item,
return sprintf(page, "rdma\n");
case NVMF_TRTYPE_LOOP:
return sprintf(page, "loop\n");
+   case NVMF_TRTYPE_FC:
+   return sprintf(page, "fc\n");
default:
return sprintf(page, "\n");
}
@@ -229,6 +235,12 @@ static void nvmet_port_init_tsas_loop(struct nvmet_port 
*port)
memset(>disc_addr.tsas, 0, NVMF_TSAS_SIZE);
 }
 
+static void nvmet_port_init_tsas_fc(struct nvmet_port *port)
+{
+   port->disc_addr.trtype = NVMF_TRTYPE_FC;
+   memset(>disc_addr.tsas, 0, NVMF_TSAS_SIZE);
+}
+
 static ssize_t nvmet_addr_trtype_store(struct config_item *item,
const char *page, size_t count)
 {
@@ -244,6 +256,8 @@ static ssize_t nvmet_addr_trtype_store(struct config_item 
*item,
nvmet_port_init_tsas_rdma(port);
} else if (sysfs_streq(page, "loop")) {
nvmet_port_init_tsas_loop(port);
+   } else if (sysfs_streq(page, "fc")) {
+   nvmet_port_init_tsas_fc(port);
} else {
pr_err("Invalid value '%s' for trtype\n", page);
return -EINVAL;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nvme-fabrics: Patch host code in prep for FC transport support

2016-07-22 Thread James Smart

Patch nvme-fabrics host code in prep for FC transport support:
- Add the host_traddr field to allow specification of the host-port
  connection info for the transport. Will be used by FC transport.
- Revise nvmf_get_address() string to account for not all options being
  present.
- Revise some of the comments so not so ethernet-network centric

Patch is cut against the linux-nvme for-4.8/drivers branch

Note: this patch had been posted to the prior nvme fabrics repository but
not merged before being brought over to linux-nvme.

Signed-off-by: James Smart 
---
 drivers/nvme/host/fabrics.c | 25 +++--
 drivers/nvme/host/fabrics.h | 11 ---
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index dc99676..1c07b76 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -109,8 +109,19 @@ static void nvmf_host_put(struct nvmf_host *host)
  */
 int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size)
 {
-   return snprintf(buf, size, "traddr=%s,trsvcid=%s\n",
-   ctrl->opts->traddr, ctrl->opts->trsvcid);
+   int len = 0;
+
+   if (ctrl->opts->mask & NVMF_OPT_TRADDR)
+   len += snprintf(buf, size, "traddr=%s", ctrl->opts->traddr);
+   if (ctrl->opts->mask & NVMF_OPT_TRSVCID)
+   len += snprintf(buf + len, size - len, "%strsvcid=%s",
+   (len) ? "," : "", ctrl->opts->trsvcid);
+   if (ctrl->opts->mask & NVMF_OPT_HOST_TRADDR)
+   len += snprintf(buf + len, size - len, "%shost_traddr=%s",
+   (len) ? "," : "", ctrl->opts->host_traddr);
+   len += snprintf(buf + len, size - len, "\n");
+
+   return len;
 }
 EXPORT_SYMBOL_GPL(nvmf_get_address);
 
@@ -510,6 +521,7 @@ static const match_table_t opt_tokens = {
{ NVMF_OPT_RECONNECT_DELAY, "reconnect_delay=%d"},
{ NVMF_OPT_KATO,"keep_alive_tmo=%d" },
{ NVMF_OPT_HOSTNQN, "hostnqn=%s"},
+   { NVMF_OPT_HOST_TRADDR, "host_traddr=%s"},
{ NVMF_OPT_ERR, NULL}
 };
 
@@ -666,6 +678,14 @@ static int nvmf_parse_options(struct nvmf_ctrl_options 
*opts,
}
opts->reconnect_delay = token;
break;
+   case NVMF_OPT_HOST_TRADDR:
+   p = match_strdup(args);
+   if (!p) {
+   ret = -ENOMEM;
+   goto out;
+   }
+   opts->host_traddr = p;
+   break;
default:
pr_warn("unknown parameter or missing value '%s' in 
ctrl creation request\n",
p);
@@ -732,6 +752,7 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts)
kfree(opts->traddr);
kfree(opts->trsvcid);
kfree(opts->subsysnqn);
+   kfree(opts->host_traddr);
kfree(opts);
 }
 EXPORT_SYMBOL_GPL(nvmf_free_options);
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index 89df52c..8f08c3a 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -52,6 +52,7 @@ enum {
NVMF_OPT_KATO   = 1 << 7,
NVMF_OPT_HOSTNQN= 1 << 8,
NVMF_OPT_RECONNECT_DELAY = 1 << 9,
+   NVMF_OPT_HOST_TRADDR= 1 << 10,
 };
 
 /**
@@ -64,9 +65,12 @@ enum {
  * being added.
  * @subsysnqn: Hold the fully qualified NQN subystem name (format defined
  * in the NVMe specification, "NVMe Qualified Names").
- * @traddr:network address that will be used by the host to communicate
- * to the added NVMe controller.
- * @trsvcid:   network port used for host-controller communication.
+ * @traddr:The transport-specific TRADDR field for a port on the
+ *  subsystem which is adding a controller.
+ * @trsvcid:   The transport-specific TRSVCID field for a port on the
+ *  subsystem which is adding a controller.
+ * @host_traddr: A transport-specific field identifying the NVME host port
+ *  to use for the connection to the controller.
  * @queue_size: Number of IO queue elements.
  * @nr_io_queues: Number of controller IO queues that will be established.
  * @reconnect_delay: Time between two consecutive reconnect attempts.
@@ -80,6 +84,7 @@ struct nvmf_ctrl_options {
char*subsysnqn;
char*traddr;
char*trsvcid;
+   char*host_traddr;
size_t  queue_size;
unsigned intnr_io_queues;
unsigned intreconnect_delay;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the 

[PATCH] add u64 number parser

2016-07-22 Thread James Smart

add u64 number parser

Will be used by the nvme-fabrics FC transport in parsing options

Signed-off-by: James Smart 
---
 include/linux/parser.h |  1 +
 lib/parser.c   | 47 +++
 2 files changed, 48 insertions(+)

diff --git a/include/linux/parser.h b/include/linux/parser.h
index 39d5b79..884c1e6 100644
--- a/include/linux/parser.h
+++ b/include/linux/parser.h
@@ -27,6 +27,7 @@ typedef struct {
 
 int match_token(char *, const match_table_t table, substring_t args[]);
 int match_int(substring_t *, int *result);
+int match_u64(substring_t *, u64 *result);
 int match_octal(substring_t *, int *result);
 int match_hex(substring_t *, int *result);
 bool match_wildcard(const char *pattern, const char *str);
diff --git a/lib/parser.c b/lib/parser.c
index b6d1163..3278958 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -152,6 +152,36 @@ static int match_number(substring_t *s, int *result, int 
base)
 }
 
 /**
+ * match_u64int: scan a number in the given base from a substring_t
+ * @s: substring to be scanned
+ * @result: resulting u64 on success
+ * @base: base to use when converting string
+ *
+ * Description: Given a _t and a base, attempts to parse the 
substring
+ * as a number in that base. On success, sets @result to the integer 
represented
+ * by the string and returns 0. Returns -ENOMEM, -EINVAL, or -ERANGE on 
failure.
+ */
+static int match_u64int(substring_t *s, u64 *result, int base)
+{
+   char *buf;
+   int ret;
+   u64 val;
+   size_t len = s->to - s->from;
+
+   buf = kmalloc(len + 1, GFP_KERNEL);
+   if (!buf)
+   return -ENOMEM;
+   memcpy(buf, s->from, len);
+   buf[len] = '\0';
+
+   ret = kstrtoull(buf, base, );
+   if (!ret)
+   *result = val;
+   kfree(buf);
+   return ret;
+}
+
+/**
  * match_int: - scan a decimal representation of an integer from a substring_t
  * @s: substring_t to be scanned
  * @result: resulting integer on success
@@ -167,6 +197,23 @@ int match_int(substring_t *s, int *result)
 EXPORT_SYMBOL(match_int);
 
 /**
+ * match_u64: - scan a decimal representation of a u64 from
+ *  a substring_t
+ * @s: substring_t to be scanned
+ * @result: resulting unsigned long long on success
+ *
+ * Description: Attempts to parse the _t @s as a long decimal
+ * integer. On success, sets @result to the integer represented by the
+ * string and returns 0.
+ * Returns -ENOMEM, -EINVAL, or -ERANGE on failure.
+ */
+int match_u64(substring_t *s, u64 *result)
+{
+   return match_u64int(s, result, 0);
+}
+EXPORT_SYMBOL(match_u64);
+
+/**
  * match_octal: - scan an octal representation of an integer from a substring_t
  * @s: substring_t to be scanned
  * @result: resulting integer on success
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nvme-fabrics: set sqe.command_id in core, not transports

2016-07-22 Thread James Smart

set sqe.command_id in core, not transports

Patch is cut against the linux-nvme for-4.8/drivers branch

Signed-off-by: James Smart 
---
 drivers/nvme/host/core.c | 3 ++-
 drivers/nvme/host/rdma.c | 1 -
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 74b1d38..b391f54 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -290,7 +290,6 @@ static inline void nvme_setup_rw(struct nvme_ns *ns, struct 
request *req,
 
memset(cmnd, 0, sizeof(*cmnd));
cmnd->rw.opcode = (rq_data_dir(req) ? nvme_cmd_write : nvme_cmd_read);
-   cmnd->rw.command_id = req->tag;
cmnd->rw.nsid = cpu_to_le32(ns->ns_id);
cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, blk_rq_pos(req)));
cmnd->rw.length = cpu_to_le16((blk_rq_bytes(req) >> ns->lba_shift) - 1);
@@ -330,6 +329,8 @@ int nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
else
nvme_setup_rw(ns, req, cmd);
 
+   cmd->common.command_id = req->tag;
+
return ret;
 }
 EXPORT_SYMBOL_GPL(nvme_setup_cmd);
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 3e3ce2b..0cd7c3e 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1447,7 +1447,6 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
if (ret)
return ret;
 
-   c->common.command_id = rq->tag;
blk_mq_start_request(rq);
 
map_len = nvme_map_len(rq);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 5/7] iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()

2016-07-22 Thread Markus Mayer
After introducing generic strtolower(), iscsi_initiatorname_tolower() is
no longer needed.

Signed-off-by: Markus Mayer 
Acked-by: Nicholas Bellinger 
---
 drivers/target/iscsi/iscsi_target_nego.c | 17 +
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_nego.c 
b/drivers/target/iscsi/iscsi_target_nego.c
index 89d34bd..fa20638 100644
--- a/drivers/target/iscsi/iscsi_target_nego.c
+++ b/drivers/target/iscsi/iscsi_target_nego.c
@@ -987,21 +987,6 @@ static int iscsi_target_do_login(struct iscsi_conn *conn, 
struct iscsi_login *lo
return 0;
 }
 
-static void iscsi_initiatorname_tolower(
-   char *param_buf)
-{
-   char *c;
-   u32 iqn_size = strlen(param_buf), i;
-
-   for (i = 0; i < iqn_size; i++) {
-   c = _buf[i];
-   if (!isupper(*c))
-   continue;
-
-   *c = tolower(*c);
-   }
-}
-
 /*
  * Processes the first Login Request..
  */
@@ -1075,7 +1060,7 @@ int iscsi_target_locate_portal(
 * RFC-3720 3.2.6.1. section c) that says that iSCSI IQNs
 * are NOT case sensitive.
 */
-   iscsi_initiatorname_tolower(i_buf);
+   strtolower(i_buf);
 
if (!s_buf) {
if (!login->leading_connection)
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/7] lib: string: add functions to case-convert strings

2016-07-22 Thread Markus Mayer
Add a collection of generic functions to convert strings to lowercase
or uppercase.

Changing the case of a string (with or without copying it first) seems
to be a recurring requirement in the kernel that is currently being
solved by several duplicated implementations doing the same thing. This
change aims at reducing this code duplication.

The new functions are
int strlcpytoupper(char *dst, const char *src, size_t len);
int strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

The "str[l]cpyto*" versions of the function take a destination string
and a source string as arguments. The "strlcpyto*" versions additionally
take a length argument like strlcpy() itself. Lastly, the strto*
functions take a single string argument and modify the passed-in string.

strlcpytoupper() and strlcpytolower() return the number of characters
copied or -E2BIG if the destination string was truncated.

Like strlcpy(), and unlike strncpy(), the functions guarantee NULL
termination of the destination string.

Signed-off-by: Markus Mayer 
---
 include/linux/string.h | 40 
 lib/string.c   | 46 ++
 2 files changed, 86 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..257d797 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -116,6 +116,8 @@ extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 void *memchr_inv(const void *s, int c, size_t n);
 char *strreplace(char *s, char old, char new);
+extern int strlcpytoupper(char *dst, const char *src, size_t len);
+extern int strlcpytolower(char *dst, const char *src, size_t len);
 
 extern void kfree_const(const void *x);
 
@@ -169,4 +171,42 @@ static inline const char *kbasename(const char *path)
return tail ? tail + 1 : path;
 }
 
+/**
+ * strcpytoupper - Copy string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ */
+static inline void strcpytoupper(char *dst, const char *src)
+{
+   strlcpytoupper(dst, src, ~(size_t)0);
+}
+
+/**
+ * strcpytolower - Copy string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ */
+static inline void strcpytolower(char *dst, const char *src)
+{
+   strlcpytolower(dst, src, ~(size_t)0);
+}
+
+/**
+ * strtoupper - Convert string to uppercase.
+ * @s: The string to operate on.
+ */
+static inline void strtoupper(char *s)
+{
+   strlcpytoupper(s, s, ~(size_t)0);
+}
+
+/**
+ * strtolower - Convert string to lowercase.
+ * @s: The string to operate on.
+ */
+static inline void strtolower(char *s)
+{
+   strlcpytolower(s, s, ~(size_t)0);
+}
+
 #endif /* _LINUX_STRING_H_ */
diff --git a/lib/string.c b/lib/string.c
index ed83562..d36d5fb2 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -952,3 +952,49 @@ char *strreplace(char *s, char old, char new)
return s;
 }
 EXPORT_SYMBOL(strreplace);
+
+/**
+ * strlcpytoupper - Copy a length-limited string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ * @len: Maximum string length. May be SIZE_MAX to set no limit.
+ *
+ * Returns the number of characters copied or -E2BIG if @dst wasn't big enough.
+ */
+int strlcpytoupper(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return -E2BIG;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = toupper(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+
+   return (i < len) ? i : -E2BIG;
+}
+EXPORT_SYMBOL(strlcpytoupper);
+
+/**
+ * strlcpytolower - Copy a length-limited string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ * @len: Maximum string length. May be SIZE_MAX to set no limit.
+ *
+ * Returns the number of characters copied or -E2BIG if @dst wasn't big enough.
+ */
+int strlcpytolower(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return -E2BIG;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = tolower(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+
+   return (i < len) ? i : -E2BIG;
+}
+EXPORT_SYMBOL(strlcpytolower);
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 0/7] lib: string: add functions to case-convert strings

2016-07-22 Thread Markus Mayer
This series introduces a family of generic string case conversion
functions. This kind of functionality is needed in several places in
the kernel. Right now, everybody seems to be implementing their own
copy of this functionality.

Based on the discussion of the previous version of this series[1] and
the use cases found in the kernel, it does look like having several
flavours of case conversion functions is beneficial. The use cases fall
into three categories:
- copying a string and converting the case while specifying a
  maximum length to mimic strlcpy()
- copying a string and converting the case without specifying a
  length to mimic strcpy()
- converting the case of a string in-place (i.e. modifying the
  string that was passed in)

Consequently, I am proposing these new functions:
int strlcpytoupper(char *dst, const char *src, size_t len);
int strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

Several drivers are being modified to make use of the functions above.
Another driver that also makes use of this functionality will be
submitted upstream shortly, which prompted this whole exercise.

The changes made here have been compile-tested, but not tried out, due
to lack of required hardware.

Changes since v3:
  - strlcpytoupper() and strlcpytolower() return length of destination
or -E2BIG (see [2])
  - we use ~(size_t)0 instead of -1 to copy strings of arbitrary length
in strcpyto*() and strto*()
  - A few ACKs added

Changes since v2:
  - use strlcpy() semantics not strncpy() semantics, i.e. guarantee
NULL termination
  - as a result strncpyto are now called
strlcpyto
  - make functions void
  - use len == -1 (SIZE_MAX) as no-limit indicator rather then len == 0
  - change PATCH 2/7 to match strlcpy() semantics
  - change PATCH 4/7 to match strlcpy() semantics

Changes since v1:
  - expanded strtolower() into a family of functions that cover use
cases when a length argument is or isn't required and that support
copying the string into a new buffer or changing it in-place 
  - changed the function semantics to return a pointer to the
terminating '\0' character of the modified string
  - added strtoupper() functionality mirroring the above
  - dropped the ACPICA patch, since that code is OS independent and
can't rely on a Linux library function (see [3])
  - Added two new patches replacing strtoupper() implementations

[1] https://lkml.org/lkml/2016/6/30/727
[2] https://lkml.org/lkml/2016/7/10/4
[3] https://lkml.org/lkml/2016/7/1/9

Markus Mayer (7):
  lib: string: add functions to case-convert strings
  drm/nouveau/core: make use of new strlcpytolower() function
  ACPI / device_sysfs: make use of new strtolower() function
  staging: speakup: replace spk_strlwr() with strlcpytolower()
  iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()
  drm/nouveau/fifo/gk104: make use of new strcpytoupper() function
  power_supply: make use of new strcpytoupper() function

 drivers/acpi/device_sysfs.c  |  4 +--
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c |  9 +
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c |  5 +--
 drivers/power/power_supply_sysfs.c   | 13 +++
 drivers/staging/speakup/kobjects.c   |  3 +-
 drivers/staging/speakup/main.c   |  3 +-
 drivers/staging/speakup/speakup.h|  1 -
 drivers/staging/speakup/varhandlers.c| 12 ---
 drivers/target/iscsi/iscsi_target_nego.c | 17 +
 include/linux/string.h   | 40 +
 lib/string.c | 46 
 11 files changed, 98 insertions(+), 55 deletions(-)

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] sd: configure ZBC devices

2016-07-22 Thread Ewan D. Milne
On Tue, 2016-07-19 at 15:25 +0200, Hannes Reinecke wrote:
> For ZBC devices I/O must not cross zone boundaries, so setup
> the 'chunk_sectors' block queue setting to the zone size.
> This is only valid for REPORT ZONES SAME type 2 or 3;
> for other types the zone sizes might be different
> for individual zones. So issue a warning if the type is
> found to be different.
> Also the capacity might be different from the announced
> capacity, so adjust it as needed.
> 
> Signed-off-by: Hannes Reinecke 

...

> +static void sd_read_zones(struct scsi_disk *sdkp, unsigned char *buffer)
> +{
> + int retval;
> + unsigned char *desc;
> + u32 rep_len;
> + u8 same;
> + u64 zone_len, lba;
> +
> + if (sdkp->zoned != 1)
> + /* Device managed, no special handling required */
> + return;
> +
> + retval = sd_zbc_report_zones(sdkp, buffer, SD_BUF_SIZE,
> +  0, ZBC_ZONE_REPORTING_OPTION_ALL, false);
> + if (retval < 0)
> + return;
> +
> + rep_len = get_unaligned_be32([0]);
> + if (rep_len < 64) {
> + sd_printk(KERN_WARNING, sdkp,
> +   "REPORT ZONES report invalid length %u\n",
> +   rep_len);
> + return;
> + }
> +
> + if (sdkp->rc_basis == 0) {
> + /* The max_lba field is the capacity of a zoned device */
> + lba = get_unaligned_be64([8]);
> + if (lba + 1 > sdkp->capacity) {
> + sd_printk(KERN_WARNING, sdkp,
> +   "Max LBA %zu (capacity %zu)\n",
> +   (sector_t) lba + 1, sdkp->capacity);
> + sdkp->capacity = lba + 1;
> + }
> + }
> +
> + /*
> +  * Adjust 'chunk_sectors' to the zone length if the device
> +  * supports equal zone sizes.
> +  */
> + same = buffer[4] & 0xf;
> + if (same == 0 || same > 3) {
> + sd_printk(KERN_WARNING, sdkp,
> +   "REPORT ZONES SAME type %d not supported\n", same);
> + return;
> + }
> + /* Read the zone length from the first zone descriptor */
> + desc = [64];
> + zone_len = logical_to_sectors(sdkp->device,
> +   get_unaligned_be64([8]));
> + blk_queue_chunk_sectors(sdkp->disk->queue, zone_len);
> +}
> +

So, blk_queue_chunk_sectors() has:

void blk_queue_chunk_sectors(struct request_queue *q, unsigned int 
chunk_sectors)
{
BUG_ON(!is_power_of_2(chunk_sectors));
q->limits.chunk_sectors = chunk_sectors;
}

and it seems like if some device reports a non-power-of-2 zone_len then we
will BUG_ON().  Probably would be better if we reported an error instead?

-Ewan


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/6] block: update chunk_sectors in blk_stack_limits()

2016-07-22 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Reviewed-by: Martin K. Petersen 

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/6] block: Add 'zoned' sysfs queue attribute

2016-07-22 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> Add a sysfs queue attribute 'zoned' to display the zone layout
Hannes> for zoned devices.

Not quite one value per file :(

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/6] blk-sysfs: Add 'chunk_sectors' to sysfs attributes

2016-07-22 Thread Martin K. Petersen
> "Hannes" == Hannes Reinecke  writes:

Hannes> The queue limits already have a 'chunk_sectors' setting, so we
Hannes> should be presenting it via sysfs.

Reviewed-by: Martin K. Petersen 

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] cxlflash: Regression patch and updating Maintainers list

2016-07-22 Thread Martin K. Petersen
> "Uma" == Uma Krishnan  writes:

Uma> First patch in this set fixes a regression that was casued by the
Uma> Commit 704c4b0ddc03 ("cxlflash: Shutdown notify support for CXL
Uma> Flash cards"), which is currently staged for 4.8 in next/master.
Uma> Second patch updates the Maintainers list for cxlflash driver.

Uma> This series is intended for 4.8 and is bisectable. These patches
Uma> are cut against next/master that contains the original commit.

Applied to 4.8/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] lpfc: fix oops in lpfc_sli4_scmd_to_wqidx_distr() from lpfc_send_taskmgmt()

2016-07-22 Thread Martin K. Petersen
> "Mauricio" == Mauricio Faria de Oliveira  
> writes:

Mauricio> The lpfc_sli4_scmd_to_wqidx_distr() function expects the
Mauricio> scsi_cmnd 'lpfc_cmd->pCmd' not to be null, and point to the
Mauricio> midlayer command.

Applied to 4.8/scsi-queue.

-- 
Martin K. Petersen  Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH resend v3 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-22 Thread tom . ty89
From: Tom Yan 

ata_mselect_*() would initialize a char array for storing a copy of
the current mode page. However, char could be signed char. In that
case, bytes larger than 127 would be converted to negative number.

For example, 0xff from def_control_mpage[] would become -1. This
prevented ata_mselect_control() from working at all, since when it
did the read-only bits check, there would always be a mismatch.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 4a4e6f1..5cfcb4b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3610,7 +3610,7 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
 {
struct ata_taskfile *tf = >tf;
struct ata_device *dev = qc->dev;
-   char mpage[CACHE_MPAGE_LEN];
+   u8 mpage[CACHE_MPAGE_LEN];
u8 wce, mask;
int i;
 
@@ -3668,7 +3668,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
   const u8 *buf, int len, u16 *fp)
 {
struct ata_device *dev = qc->dev;
-   char mpage[CONTROL_MPAGE_LEN];
+   u8 mpage[CONTROL_MPAGE_LEN];
u8 d_sense, mask;
int i;
 
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH resend v2 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-22 Thread Tom Yan
Strange. I merely changed the two "char" to "u8". I wonder how the tab
became spaces. Anyway, sorry about that, resending soon.

On 22 July 2016 at 17:59, Sergei Shtylyov
 wrote:
> Hello.
>
>
> On 7/22/2016 2:29 AM, tom.t...@gmail.com wrote:
>
>> From: Tom Yan 
>>
>> ata_mselect_*() would initialize a char array for storing a copy of
>> the current mode page. However, char could be signed char. In that
>> case, bytes larger than 127 would be converted to negative number.
>>
>> For example, 0xff from def_control_mpage[] would become -1. This
>> prevented ata_mselect_control() from working at all, since when it
>> did the read-only bits check, there would always be a mismatch.
>>
>> Signed-off-by: Tom Yan 
>>
>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>> index 4a4e6f1..a28e2ea94 100644
>> --- a/drivers/ata/libata-scsi.c
>> +++ b/drivers/ata/libata-scsi.c
>> @@ -3610,7 +3610,7 @@ static int ata_mselect_caching(struct ata_queued_cmd
>> *qc,
>>  {
>> struct ata_taskfile *tf = >tf;
>> struct ata_device *dev = qc->dev;
>> -   char mpage[CACHE_MPAGE_LEN];
>> +   u8 mpage[CACHE_MPAGE_LEN];
>> u8 wce, mask;
>> int i;
>>
>> @@ -3668,7 +3668,7 @@ static int ata_mselect_control(struct ata_queued_cmd
>> *qc,
>>const u8 *buf, int len, u16 *fp)
>>  {
>> struct ata_device *dev = qc->dev;
>> -   char mpage[CONTROL_MPAGE_LEN];
>> +u8 mpage[CONTROL_MPAGE_LEN];
>
>
>Indent with tabs please, as above.
>
> [...]
>
> MBR, Sergei
>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] MAINTAINERS: Update cxlflash maintainers

2016-07-22 Thread Matthew R. Ochs
> On Jul 21, 2016, at 3:44 PM, Uma Krishnan  wrote:
> 
> Adding myself as a cxlflash maintainer.
> 
> Signed-off-by: Uma Krishnan 

Acked-by: Matthew R. Ochs 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] cxlflash: Verify problem state area is mapped before notifying shutdown

2016-07-22 Thread Matthew R. Ochs
> On Jul 21, 2016, at 3:44 PM, Uma Krishnan  wrote:
> 
> If an EEH or some other hard error occurs while the
> adapter instance was being initialized, on the subsequent
> shutdown of the device, the system could crash with:
> 
> [c00f1da03b60] c05eccfc pci_device_shutdown+0x6c/0x100
> [c00f1da03ba0] c06d67d4 device_shutdown+0x1b4/0x2c0
> [c00f1da03c40] c00ea30c kernel_restart_prepare+0x5c/0x80
> [c00f1da03c70] c00ea48c kernel_restart+0x2c/0xc0
> [c00f1da03ce0] c00ea970 SyS_reboot+0x1c0/0x2d0
> [c00f1da03e30] c0009204 system_call+0x38/0xb4
> 
> This crash is due to the AFU not being mapped when the shutdown
> notification routine is called and is a regression that was inserted
> recently with Commit 704c4b0ddc03 ("cxlflash: Shutdown notify support
> for CXL Flash cards").
> 
> As a fix, shutdown notification should only occur when the AFU is mapped.
> 
> Fixes: 704c4b0ddc03 ("cxlflash: Shutdown notify support for CXL Flash cards")
> Signed-off-by: Uma Krishnan 

Acked-by: Matthew R. Ochs 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: HDD Unrecovered readerror issue

2016-07-22 Thread James Bottomley
On Fri, 2016-07-22 at 09:51 -0400, Jeff Moyer wrote:
> Dmitry Monakhov  writes:
> 
> > But once I rewrite this block, problem goes away.
> > #xfs_io -c "pwrite -S 0x0 $((80069000/2))k 4k" -d  /dev/sda
> > 
> > Now I can read it w/o any errors and smartctl is happy
> > #smartctl -t short /dev/sda
> > #smartctl -l selftest /dev/sda
> > Num  Test_DescriptionStatus  Remaining
> > LifeTime(hours)  LBA_of_first_error
> > # 1  Short offline   Completed without error   00% 
> >  4683 -
> > 
> > So my disk is not dead right?
> 
> Correct.
> 
> > Why the hell HDD fail read from very beginning
> > Is this because HDD firmware detect internal crcXX sum corruption?
> 
> Yes.
> 
> > How this can happen? Is this because of power failure?
> 
> Could be.  If power was cut in the middle of a write, this can 
> happen. There are other causes, though (bit rot, for example).
> 
> > AFAIK standard guarantees that sector will be updated atomically.
> 
> No, the SCSI and ATA standards most certainly do not guarantee that!
> NVMe is the only standard I know of that requires Atomic Write Unit
> Power Fail to be at lest one sector.

The mechanics of the drive mostly ensure atomic updates on the physical
block level.  You definitely get either the old data, the new data or
an unreadable sector.  The latter is a pretty rare event because
surviving power usually ensures the writes complete, but it's not
guaranteed. 

> > But it happens! Please guide me how to fix such problems in
> > general.
> 
> You fixed it.  Overwriting the sector will clear the error.

Actually only "may clear the error" depending on what happened.  If the
hamming codes on the sector itself just failed (because of a torn write
due to power fail) then a rewrite simply re-fixes the sector in situ. 
 Sometimes the magnetic substrate of the track is worn (so the sector
is permanently damaged) and the re-write forces a reallocation.  If
that's happening to your disk then eventually it will fail
irrecoverably when the reallocation table is full.

You can monitor this with the smart Reallocated_Event_Count.

James

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH -next] ibmvscsis: Use list_move_tail instead of list_del/list_add_tail

2016-07-22 Thread Wei Yongjun
Using list_move_tail() instead of list_del() + list_add_tail().

Signed-off-by: Wei Yongjun 
---
 drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c 
b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
index b29fef9..7e873a7 100644
--- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
+++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
@@ -3697,8 +3697,7 @@ static void ibmvscsis_release_cmd(struct se_cmd *se_cmd)
 
spin_lock_bh(>intr_lock);
/* Remove from active_q */
-   list_del(>list);
-   list_add_tail(>list, >waiting_rsp);
+   list_move_tail(>list, >waiting_rsp);
ibmvscsis_send_messages(vscsi);
spin_unlock_bh(>intr_lock);
 }



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: HDD Unrecovered readerror issue

2016-07-22 Thread Jeff Moyer
Dmitry Monakhov  writes:

> But once I rewrite this block, problem goes away.
> #xfs_io -c "pwrite -S 0x0 $((80069000/2))k 4k" -d  /dev/sda
>
> Now I can read it w/o any errors and smartctl is happy
> #smartctl -t short /dev/sda
> #smartctl -l selftest /dev/sda
> Num  Test_DescriptionStatus  Remaining
> LifeTime(hours)  LBA_of_first_error
> # 1  Short offline   Completed without error   00%  4683 -
>
> So my disk is not dead right?

Correct.

> Why the hell HDD fail read from very beginning
> Is this because HDD firmware detect internal crcXX sum corruption?

Yes.

> How this can happen? Is this because of power failure?

Could be.  If power was cut in the middle of a write, this can happen.
There are other causes, though (bit rot, for example).

> AFAIK standard guarantees that sector will be updated atomically.

No, the SCSI and ATA standards most certainly do not guarantee that!
NVMe is the only standard I know of that requires Atomic Write Unit
Power Fail to be at lest one sector.

> But it happens! Please guide me how to fix such problems in general.

You fixed it.  Overwriting the sector will clear the error.

Cheers,
Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Bug 139951] New: GORILLLLA@ZOH00 1.8 88.633. 55.26+++ ZOHO tech support TOLLFREE number. ZOHO TECH SUPPORT PHONRE NUMBER, ZOHO TELEPHONE NUMBER

2016-07-22 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=139951

Bug ID: 139951
   Summary: GORIA@ZOH00 1.8 88.633. 55.26+++ ZOHO tech support
TOLLFREE number. ZOHO TECH SUPPORT PHONRE NUMBER, ZOHO
TELEPHONE NUMBER
   Product: SCSI Drivers
   Version: 2.5
Kernel Version: ZOHO TECH,TECHNICAL CUSTOMER,SUPPORT
  Hardware: All
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: AHA152X
  Assignee: scsi_drivers-aha1...@kernel-bugs.osdl.org
  Reporter: ramu.sara1000...@gmail.com
Regression: No

Created attachment 225231
  --> https://bugzilla.kernel.org/attachment.cgi?id=225231=edit
ZOHO HELPLINE, ZOHO TECHNICAL SUPPORT NUMBER

CANADA+USA@1-888-633-5526@+@ :  ZOHO Customer Support Phone
number|1*888*633*5526 :  ZOHO Customer Service Phone
Number|+1';88''8';63''3';'55';26:  ZOHO  Support Number

USA/Canaga T0ll-free Di!ll+1';88''8';63''3';'55';26:  ZOHO  Support
Number, :  ZOHO tech support number, :  ZOHO customer support number
:  ZOHO support phone number ++1';88''8';63''3';'55';26:  ZOHO customer
support phone number @1_^-888^-_633^^-5526@ :  ZOHO Tech Support Number
:  ZOHO 
Technical Support number, :  ZOHO support phone number @@@rv
+1';88''8';63''3';'55';26 :  ZOHO Support Phone number :  ZOHO tech
support number ++ 
+1';88''8';63''3';'55';26+ :  ZOHO customer service phone number : 
ZOHO technical support number +1';88''8';63''3';'55';26++ :  ZOHO customer
Care phone number :  ZOHO
GLOBAL tech support number +1';88''8';63''3';'55';26 :  ZOHO helpdesk
support phone number :  ZOHO Customer support phone number
+1';88''8';63''3';'55';26 :  ZOHO 
tech support number , :  ZOHO tech support phone number , :  ZOHO
customer support phone number here $$$##@@ :  ZOHO tech support number 
+1';88''8';63''3';'55';26 :  ZOHO Technical support number @@ :  ZOHO
support phone number +1';88''8';63''3';'55';26 :  ZOHO customer service
phone number :  ZOHO 
customer c.a.r.e number :  ZOHO helpdesk phone number :  ZOHO helpline
phone number (+1';88''8';63''3';'55';26) :  ZOHO contact phone number
+1';88''8';63''3';'55';26 :  ZOHO
World-W!de_Supp0RT@1';88''8';63''3';'55';26 :  ZOHO Phone Number 
Contact :  ZOHO Customer Service+++1';88''8';63''3';'55';26 :  ZOHO
tech support number , :  ZOHO tech support phone number , :  ZOHO
customer support phone number here $$$##@@ :  ZOHO tech support number 
+1';88''8';63''3';'55';26 :  ZOHO Technical support number @@ :  ZOHO
support phone number +1';88''8';63''3';'55';26 :  ZOHO customer service
phone number :  ZOHO 
customer c.a.r.e number :  ZOHO helpdesk phone number :  ZOHO helpline
phone number (+1';88''8';63''3';'55';26) :  ZOHO contact phone number :
 ZOHO help 
number - :  ZOHO helpline number ; :  ZOHO help phone number , : 
ZOHO helpline number , :  ZOHO tech support tollfree number , :  ZOHO 
support Tele phone number , :  ZOHO tech support Tele phone number , : 
ZOHO tech support contact number , :  ZOHO support contact number , : 
ZOHO 
Technical support contact number , :  ZOHO support phone number , : 
ZOHO support phone number . :  ZOHO customer support phone number : 
ZOHO 
customer service number +1';88''8';63''3';'55';26 :  ZOHO call center :
 ZOHO customer service Routeraddress :  ZOHO customer c.a.r.e no : 
ZOHO Technical 
support phone number +1';88''8';63''3';'55';26 :  ZOHO tech support phone
number +1';88''8';63''3';'55';26 :  ZOHO customer service phone number
+1';88''8';63''3';'55';26 :  ZOHO 
Technical support phone number +1';88''8';63''3';'55';26 symantec Technical
support phone number +1';88''8';63''3';'55';26 :  ZOHO Technical support
phone number +1';88''8';63''3';'55';26 :  ZOHO
GLOBAL customer service tele phone number +1';88''8';63''3';'55';26 :  ZOHO
phone number +1';88''8';63''3';'55';26 :  ZOHO customer service phone
number +1';88''8';63''3';'55';26 :  ZOHO
GLOBAL customer service helpdesk :  ZOHO phone number
+1';88''8';63''3';'55';26 :  ZOHO phone number
+1';88''8';63''3';'55';26cancel subscription :  ZOHO Technical support 
phone number +1';88''8';63''3';'55';26 :  ZOHO 855 phone number
+1';88''8';63''3';'55';26 snapdeal tollfree customer c.a.r.e number
+1';88''8';63''3';'55';26 sbi tollfree customer c.a.r.e number 
+1';88''8';63''3';'55';26 :  ZOHO tollfree customer c.a.r.e number
+1';88''8';63''3';'55';26 :  ZOHO tollfree customer c.a.r.e number
+1';88''8';63''3';'55';26 bsnl tollfree customer c.a.r.e number
+1';88''8';63''3';'55';26 mail.:  ZOHO 
tollfree customer c.a.r.e number +1';88''8';63''3';'55';26 :  ZOHO tollfree

Re: [PATCH resend v2 3/5] libata-scsi: use u8 array to store mode page copy

2016-07-22 Thread Sergei Shtylyov

Hello.

On 7/22/2016 2:29 AM, tom.t...@gmail.com wrote:


From: Tom Yan 

ata_mselect_*() would initialize a char array for storing a copy of
the current mode page. However, char could be signed char. In that
case, bytes larger than 127 would be converted to negative number.

For example, 0xff from def_control_mpage[] would become -1. This
prevented ata_mselect_control() from working at all, since when it
did the read-only bits check, there would always be a mismatch.

Signed-off-by: Tom Yan 

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 4a4e6f1..a28e2ea94 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -3610,7 +3610,7 @@ static int ata_mselect_caching(struct ata_queued_cmd *qc,
 {
struct ata_taskfile *tf = >tf;
struct ata_device *dev = qc->dev;
-   char mpage[CACHE_MPAGE_LEN];
+   u8 mpage[CACHE_MPAGE_LEN];
u8 wce, mask;
int i;

@@ -3668,7 +3668,7 @@ static int ata_mselect_control(struct ata_queued_cmd *qc,
   const u8 *buf, int len, u16 *fp)
 {
struct ata_device *dev = qc->dev;
-   char mpage[CONTROL_MPAGE_LEN];
+u8 mpage[CONTROL_MPAGE_LEN];


   Indent with tabs please, as above.

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] lpfc: fix oops in lpfc_sli4_scmd_to_wqidx_distr() from lpfc_send_taskmgmt()

2016-07-22 Thread Johannes Thumshirn
On Tue, Jun 07, 2016 at 08:13:08PM -0300, Mauricio Faria de Oliveira wrote:
> The lpfc_sli4_scmd_to_wqidx_distr() function expects the scsi_cmnd
> 'lpfc_cmd->pCmd' not to be null, and point to the midlayer command.
> 
> That's not true in the .eh_(device|target|bus)_reset_handler path,
> because lpfc_send_taskmgmt() sends commands not from the midlayer,
> so does not set 'lpfc_cmd->pCmd'.
> 
> That is true in the .queuecommand path because lpfc_queuecommand()
> stores the scsi_cmnd from midlayer in lpfc_cmd->pCmd; and lpfc_cmd
> is stored by lpfc_scsi_prep_cmnd() in piocbq->context1 -- which is
> passed to lpfc_sli4_scmd_to_wqidx_distr() as lpfc_cmd parameter.
> 
> This problem can be hit on SCSI EH, and immediately with sg_reset.
> These 2 test-cases demonstrate the problem/fix with next-20160601.
> 
> Test-case 1) sg_reset
> 
> # strace sg_reset --device /dev/sdm
> <...>
> open("/dev/sdm", O_RDWR|O_NONBLOCK) = 3
> ioctl(3, SG_SCSI_RESET, 0x3fffde6d0994 
> +++ killed by SIGSEGV +++
> Segmentation fault
> 
> # dmesg
> Unable to handle kernel paging request for data at address 0x
> Faulting instruction address: 0xd0001c88442c
> Oops: Kernel access of bad area, sig: 11 [#1]
> <...>
> CPU: 104 PID: 16333 Comm: sg_reset Tainted: GW   
> 4.7.0-rc1-next-20160601-4-g95b89dc #6
> <...>
> NIP [d0001c88442c] lpfc_sli4_scmd_to_wqidx_distr+0xc/0xd0 [lpfc]
> LR [d0001c826fe8] lpfc_sli_calc_ring.part.27+0x98/0xd0 [lpfc]
> Call Trace:
> [c03c9ec876f0] [c03c9ec87770] 0xc03c9ec87770 (unreliable)
> [c03c9ec87720] [d0001c82e004] lpfc_sli_issue_iocb+0xd4/0x260 
> [lpfc]
> [c03c9ec87780] [d0001c831a3c] 
> lpfc_sli_issue_iocb_wait+0x15c/0x5b0 [lpfc]
> [c03c9ec87880] [d0001c87f27c] lpfc_send_taskmgmt+0x24c/0x650 
> [lpfc]
> [c03c9ec87950] [d0001c87fd7c] 
> lpfc_device_reset_handler+0x10c/0x200 [lpfc]
> [c03c9ec87a10] [c0610694] scsi_try_bus_device_reset+0x44/0xc0
> [c03c9ec87a40] [c06113e8] scsi_ioctl_reset+0x198/0x2c0
> [c03c9ec87bf0] [c060fe5c] scsi_ioctl+0x13c/0x4b0
> [c03c9ec87c80] [c06629b0] sd_ioctl+0xf0/0x120
> [c03c9ec87cd0] [c046e4f8] blkdev_ioctl+0x248/0xb70
> [c03c9ec87d30] [c02a1f60] block_ioctl+0x70/0x90
> [c03c9ec87d50] [c026d334] do_vfs_ioctl+0xc4/0x890
> [c03c9ec87de0] [c026db60] SyS_ioctl+0x60/0xc0
> [c03c9ec87e30] [c0009120] system_call+0x38/0x108
> Instruction dump:
> <...>
> 
> With fix:
> 
> # strace sg_reset --device /dev/sdm
> <...>
> open("/dev/sdm", O_RDWR|O_NONBLOCK) = 3
> ioctl(3, SG_SCSI_RESET, 0x3fffe103c554) = 0
> close(3)= 0
> exit_group(0)   = ?
> +++ exited with 0 +++
> 
> # dmesg
> [  424.658649] lpfc 0006:01:00.4: 4:(0):0713 SCSI layer issued Device 
> Reset (1, 0) return x2002
> 
> Test-case 2) SCSI EH
> 
> Using this debug patch to wire an SCSI EH trigger, for 
> lpfc_scsi_cmd_iocb_cmpl():
> -   cmd->scsi_done(cmd);
> +   if ((phba->pport ? phba->pport->cfg_log_verbose : 
> phba->cfg_log_verbose) == 0x3210)
> +   printk(KERN_ALERT "lpfc: skip scsi_done()\n");
> +   else
> +   cmd->scsi_done(cmd);
> 
> # echo 0x3210 > /sys/class/scsi_host/host11/lpfc_log_verbose
> 
> # dd if=/dev/sdm of=/dev/null iflag=direct &
> <...>
> 
> After a while:
> 
> # dmesg
> lpfc 0006:01:00.4: 4:(0):3053 lpfc_log_verbose changed from 0 (x0) to 
> 839909376 (x3210)
> lpfc: skip scsi_done()
> <...>
> Unable to handle kernel paging request for data at address 0x
> Faulting instruction address: 0xd000199e448c
> Oops: Kernel access of bad area, sig: 11 [#1]
> <...>
> CPU: 96 PID: 28556 Comm: scsi_eh_11 Tainted: GW   
> 4.7.0-rc1-next-20160601-4-g95b89dc #6
> <...>
> NIP [d000199e448c] lpfc_sli4_scmd_to_wqidx_distr+0xc/0xd0 [lpfc]
> LR [d00019986fe8] lpfc_sli_calc_ring.part.27+0x98/0xd0 [lpfc]
> Call Trace:
> [c00ff0d0b890] [c00ff0d0b900] 0xc00ff0d0b900 (unreliable)
> [c00ff0d0b8c0] [d0001998e004] lpfc_sli_issue_iocb+0xd4/0x260 
> [lpfc]
> [c00ff0d0b920] [d00019991a3c] 
> lpfc_sli_issue_iocb_wait+0x15c/0x5b0 [lpfc]
> [c00ff0d0ba20] [d000199df27c] lpfc_send_taskmgmt+0x24c/0x650 
> [lpfc]
> [c00ff0d0baf0] [d000199dfd7c] 
> lpfc_device_reset_handler+0x10c/0x200 [lpfc]
> [c00ff0d0bbb0] [c0610694] scsi_try_bus_device_reset+0x44/0xc0
> [c00ff0d0bbe0] [c06126cc] scsi_eh_ready_devs+0x49c/0x9c0
> [c00ff0d0bcb0] [c0614160] scsi_error_handler+0x580/0x680
> [c00ff0d0bd80] [c00ae848] kthread+0x108/0x130
>