Re: [PATCH] ses: Fix SAS device detection in enclosure

2017-01-16 Thread Johannes Thumshirn
On Mon, Jan 16, 2017 at 04:02:24PM -0500, Martin K . Petersen wrote:
> > "Ewan" == Ewan D Milne  writes:
> 
> Ewan> The call to scsi_is_sas_rphy() needs to be made on the SAS
> Ewan> end_device, not on the SCSI device.
> 
> Ewan> Fixes: 835831c57e9b ("ses: use scsi_is_sas_rphy instead of
> Ewan> is_sas_attached") Reviewed-by: Johannes Thumshirn
> Ewan>  Signed-off-by: Ewan D. Milne
> Ewan>  ---
> Ewan>  drivers/scsi/ses.c | 2 +- 1 file changed, 1 insertion(+), 1
> Ewan>  deletion(-)
> 
> Ewan> diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index
> Ewan> 8c9a35c..50adabb 100644
> Ewan> --- a/drivers/scsi/ses.c
> Ewan> +++ b/drivers/scsi/ses.c
> Ewan> @@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struct
> Ewan> enclosure_device *edev,
>  
> Ewan> ses_enclosure_data_process(edev,
> Ewan> to_scsi_device(edev->edev.parent), 0);
>  
> Ewan> - if (scsi_is_sas_rphy(>sdev_gendev))
> Ewan> + if (scsi_is_sas_rphy(sdev->sdev_target->dev.parent))
> Ewan> efd.addr = sas_get_address(sdev);
>  
> Ewan> if (efd.addr) {
> Ewan> -- 1.8.3.1
> 
> James?

FWIW I have positive test results from a customer of ours with this as well.

Thanks,
Johannes

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
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: [Qemu-devel] [RFC PATCH 0/3] scsi-generic and BLKSECTGET

2017-01-16 Thread Fam Zheng
On Mon, 01/16 22:11, Eric Farman wrote:
> (cc'ing linux-scsi for the cover-letter; patches only to QEMU lists.)
> 
> In the Linux kernel, I see two (three) places where the BLKSECTGET ioctl is
> handled:
> 
> (1) block/(compat_)ioctl.c -- (compat_)blkdev_ioctl
> (2) drivers/scsi/sg.c -- sg_ioctl
> 
> The former has been around forever[1], and returns a short value measured in
> sectors.  A sector is generally assumed to be 512 bytes.
> 
> The latter has been around for slightly less than forever[2], and returns an
> int that measures the value in bytes.  A change to return the block count
> was brought up a few years ago[3] and nacked.
> 
> As a convenient example, if I use the blockdev tool to drive the ioctl to a
> SCSI disk and its scsi-generic equivalent, I get different results:

Fun! :-/

The patch looks correct but I don't like how it is written a lot, but still
thanks for bringing it up so we won't be bitten in the future, and your detailed
explanation is much appreciated!

Fam
--
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] virtio_scsi: Implement fc_host

2017-01-16 Thread Fam Zheng
On Tue, 01/17 03:02, kbuild test robot wrote:
> Hi Fam,
> 
> [auto build test ERROR on linus/master]
> [also build test ERROR on v4.10-rc4 next-20170116]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> 
> url:
> https://github.com/0day-ci/linux/commits/Fam-Zheng/virtio-scsi-Implement-FC_HOST-feature/20170117-011950
> config: i386-randconfig-r0-201703 (attached as .config)
> compiler: gcc-5 (Debian 5.4.1-2) 5.4.1 20160904
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All errors (new ones prefixed by >>):
> 
>drivers/built-in.o: In function `init':
> >> virtio_scsi.c:(.init.text+0x10d52): undefined reference to 
> >> `fc_attach_transport'
>drivers/built-in.o: In function `fini':
> >> virtio_scsi.c:(.exit.text+0x14a4): undefined reference to 
> >> `fc_release_transport'

This is good catch.

Looks like virtio-scsi will now have to depend on fc, or we wrap the fc code
with #ifdef's.

Fam
--
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] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Fam Zheng
On Mon, 01/16 09:34, Christoph Hellwig wrote:
> On Tue, Jan 17, 2017 at 12:04:28AM +0800, Fam Zheng wrote:
> > This series implements the proposed fc_host feature of virtio-scsi.
> 
> Yikes.  Why?

Hi Christoph, this is mostly to "passthrough" a host NPIV vport (leaving libvirt
doing the heavy lifting to watch and attach all visible LUNs to guest).

Fam

> --
> 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
--
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


[RFC PATCH 0/3] scsi-generic and BLKSECTGET

2017-01-16 Thread Eric Farman
(cc'ing linux-scsi for the cover-letter; patches only to QEMU lists.)

In the Linux kernel, I see two (three) places where the BLKSECTGET ioctl is
handled:

(1) block/(compat_)ioctl.c -- (compat_)blkdev_ioctl
(2) drivers/scsi/sg.c -- sg_ioctl

The former has been around forever[1], and returns a short value measured in
sectors.  A sector is generally assumed to be 512 bytes.

The latter has been around for slightly less than forever[2], and returns an
int that measures the value in bytes.  A change to return the block count
was brought up a few years ago[3] and nacked.

As a convenient example, if I use the blockdev tool to drive the ioctl to a
SCSI disk and its scsi-generic equivalent, I get different results:

  # lsscsi -g
  [0:0:8:1077166114]diskIBM  2107900  .217  /dev/sda /dev/sg0
  # blockdev --getmaxsect /dev/sda
  2560
  # blockdev --getmaxsect /dev/sg0
  20

Now, the value for /dev/sda looks "correct" to me.

  # cd /sys/devices/css0/0.0.0125/0.0.1f69/host0/rport-0\:0-8/
  # cd target0\:0\:8/0\:0\:8\:1077166114/
  # cat block/sda/queue/max_sectors_kb
  1280
  # cat block/sda/queue/hw_sector_size
  512

And the math checks out:

  max_sectors_kb * 1024 / hw_sector_size == getmaxsect
  -OR-
  1280 * 1024 / 512 = 2560

For /dev/sg0, it appears the answer is coming from the sg_ioctl result
which is already multiplied by the block size, and then looking at only the
upper half (short) of the returned big-endian fullword:

  (1280 * 1024 / 512) * 512 = 1310720 = x0014 => x0014 = 20

The reason for all this?  Well, QEMU recently added a BLKSECTGET ioctl
call[4] which we see during guest boot.  This code presumes the value is in
blocks/sectors, and converts it to bytes[5].  Not that this matters, because
the short/int discrepancy gives us "zero" on s390x.

Also, that code doesn't execute for scsi-generic devices, so the conversion
to bytes is correct, but I'd like to extend this code to interrogate
scsi-generic devices as well.  This is important because libvirt converts
a specified virtio-scsi device to its /dev/sgX address for the QEMU
commandline.

So, do I have to code around the different field sizes (int vs short) as
well as scaling (bytes vs blocks)?  Obviously doable, but looking at the
resulting commits, I find myself feeling a little ill.

[1] The initial kernel git commit
[2] kernel commit 44ec95425c1d9dce6e4638c29e4362cfb44814e7
[3] https://lkml.org/lkml/2012/6/27/78
[4] qemu commit 6f6071745bd0366221f5a0160ed7d18d0e38b9f7
[5] qemu commit 5def6b80e1eca696c1fc6099e7f4d36729686402

Eric Farman (3):
  hw/scsi: Fix debug message of cdb structure in scsi-generic
  block: Fix target variable of BLKSECTGET ioctl
  block: get max_transfer limit for char (scsi-generic) devices

 block/file-posix.c | 16 +---
 hw/scsi/scsi-generic.c |  5 +++--
 2 files changed, 16 insertions(+), 5 deletions(-)

-- 
2.8.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 V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-16 Thread ojab

On 2017/01/16 14:03, ojab wrote:

On 2017/01/16 13:31, Sreekanth Reddy wrote:

On Mon, Jan 16, 2017 at 6:15 PM, ojab  wrote:

On 2017/01/16 12:36, Sreekanth Reddy wrote:


Ojab,

I am checking internally with our FW team and Architect to known
whether they aware/observed any issues similar to this (since this
issue is nothing to do with driver).

Meanwhile is it possible to provide us the PCI config space and FW
logs when issue occurs?



AFAIU FW log is enabled when `logging_level=0x3f8` is passed to the
module,
right?


This is a driver logging_level. Firmware logs can be collected using
UART logs.


According to the user guide (from
https://www.broadcom.com/products/storage/host-bus-adapters/sas-9217-8i#documentation)
my 9217-8i requires 1.8V UART which I don't have at hand, I'll try to do
something on the weekend.
Is anything needed except connecting UART to gather required info?
…actually I have compatible USB UART here. What should be done to get FW 
log? I've tried to reboot with UART connected (9600N1) but got no output.


//wbr ojab




Anyway, right now various MPI2 HBAs doesn't work with ASPM enabled, so
can this patch be applied in the meantime while we're debugging the
issue further? Even if this issue can be properly fixed by FW update,
this workaround will be needed for HBAs with affected FW versions.

//wbr ojab





Where can I find info about PCI config space?


You can get PCI config space info from lspci command.



//wbr ojab



Thanks,
Sreekanth

On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:


On 2017/01/06 15:48, Sreekanth Reddy wrote:



On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
 wrote:

Matin, We need some time to review this patch. I will provide my
review comments by end of next week.


ping?

//wbr ojab



Thanks,
Sreekanth





--
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




--
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



--
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



--
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] qed: Add support for hardware offloaded FCoE.

2017-01-16 Thread David Miller
From: Chad Dupuis 
Date: Mon, 16 Jan 2017 16:47:52 -0500

> I forgot to add netdev-next to the subject line.  Is a repost needed
> here?

Not this time, no.
--
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] qed: Add support for hardware offloaded FCoE.

2017-01-16 Thread Chad Dupuis
I forgot to add netdev-next to the subject line.  Is a repost needed here?

On Mon, 16 Jan 2017, 7:53pm -, Dupuis, Chad wrote:

> From: Arun Easi 
> 
> This adds the backbone required for the various HW initalizations
> which are necessary for the FCoE driver (qedf) for QLogic FastLinQ
> 4 line of adapters - FW notification, resource initializations, etc.
> 
> Signed-off-by: Arun Easi 
> Signed-off-by: Yuval Mintz 
> ---
>  drivers/net/ethernet/qlogic/Kconfig   |   3 +
>  drivers/net/ethernet/qlogic/qed/Makefile  |   1 +
>  drivers/net/ethernet/qlogic/qed/qed.h |  11 +
>  drivers/net/ethernet/qlogic/qed/qed_cxt.c |  98 ++-
>  drivers/net/ethernet/qlogic/qed/qed_cxt.h |   3 +
>  drivers/net/ethernet/qlogic/qed/qed_dcbx.c|  11 +
>  drivers/net/ethernet/qlogic/qed/qed_dcbx.h|   1 +
>  drivers/net/ethernet/qlogic/qed/qed_dev.c | 205 -
>  drivers/net/ethernet/qlogic/qed/qed_dev_api.h |  42 +
>  drivers/net/ethernet/qlogic/qed/qed_fcoe.c| 990 
> ++
>  drivers/net/ethernet/qlogic/qed/qed_fcoe.h|  52 ++
>  drivers/net/ethernet/qlogic/qed/qed_hsi.h | 781 -
>  drivers/net/ethernet/qlogic/qed/qed_hw.c  |   3 +
>  drivers/net/ethernet/qlogic/qed/qed_ll2.c |  25 +
>  drivers/net/ethernet/qlogic/qed/qed_ll2.h |   2 +-
>  drivers/net/ethernet/qlogic/qed/qed_main.c|   7 +
>  drivers/net/ethernet/qlogic/qed/qed_mcp.c |   3 +
>  drivers/net/ethernet/qlogic/qed/qed_mcp.h |   1 +
>  drivers/net/ethernet/qlogic/qed/qed_reg_addr.h|   8 +
>  drivers/net/ethernet/qlogic/qed/qed_sp.h  |   4 +
>  drivers/net/ethernet/qlogic/qed/qed_sp_commands.c |   3 +
>  include/linux/qed/common_hsi.h|  10 +-
>  include/linux/qed/fcoe_common.h   | 715 
>  include/linux/qed/qed_fcoe_if.h   | 145 
>  include/linux/qed/qed_if.h|  39 +
>  25 files changed, 3152 insertions(+), 11 deletions(-)
>  create mode 100644 drivers/net/ethernet/qlogic/qed/qed_fcoe.c
>  create mode 100644 drivers/net/ethernet/qlogic/qed/qed_fcoe.h
>  create mode 100644 include/linux/qed/fcoe_common.h
>  create mode 100644 include/linux/qed/qed_fcoe_if.h
> 

--
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] ses: Fix SAS device detection in enclosure

2017-01-16 Thread Martin K. Petersen
> "Ewan" == Ewan D Milne  writes:

Ewan> The call to scsi_is_sas_rphy() needs to be made on the SAS
Ewan> end_device, not on the SCSI device.

Ewan> Fixes: 835831c57e9b ("ses: use scsi_is_sas_rphy instead of
Ewan> is_sas_attached") Reviewed-by: Johannes Thumshirn
Ewan>  Signed-off-by: Ewan D. Milne
Ewan>  ---
Ewan>  drivers/scsi/ses.c | 2 +- 1 file changed, 1 insertion(+), 1
Ewan>  deletion(-)

Ewan> diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index
Ewan> 8c9a35c..50adabb 100644
Ewan> --- a/drivers/scsi/ses.c
Ewan> +++ b/drivers/scsi/ses.c
Ewan> @@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struct
Ewan> enclosure_device *edev,
 
Ewan>   ses_enclosure_data_process(edev,
Ewan>   to_scsi_device(edev->edev.parent), 0);
 
Ewan> - if (scsi_is_sas_rphy(>sdev_gendev))
Ewan> + if (scsi_is_sas_rphy(sdev->sdev_target->dev.parent))
Ewan>   efd.addr = sas_get_address(sdev);
 
Ewan>   if (efd.addr) {
Ewan> -- 1.8.3.1

James?

-- 
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] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-16 Thread Martin K. Petersen
> "James" == James Bottomley  writes:

James> Subject: [PATCH] scsi: mpt3sas: fix hang on ata passthrough
James> commands

James> mpt3sas has a firmware failure where it can only handle one pass
James> through ATA command at a time.  If another comes in, contrary to
James> the SAT standard, it will hang until the first one completes
James> (causing long commands like secure erase to timeout).  The
James> original fix was to block the device when an ATA command came in,
James> but this caused a regression with

Broadcom folks: Please test and ack as soon as possible so we can get
this fix queued up.

Ingo: Since you appear to have hardware, it would be great if you could
test James' v3 (https://patchwork.kernel.org/patch/9519383/). Sorry for
the inconvenience.

-- 
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 3/4] hpsa: remove coalescing settings for ioaccel2

2017-01-16 Thread Martin K. Petersen
> "Don" == Don Brace  writes:

Don,

Don> Wondering what has happened to this patch?

According to my notes, there were some concerns with the series that did
not get addressed. And only patch 3 actually got a reviewed-by tag. I
suggest you repost the series.

-- 
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] libfc: Fix variable name in fc_set_wwpn

2017-01-16 Thread Martin K. Petersen
> "Fam" == Fam Zheng  writes:

Fam> The parameter name should be wwpn instead of wwnn.

Applied to 4.10/scsi-fixes.

-- 
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 v2 09/12] qla2xxx: Add Dual mode support in the driver

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Add switch to allow both Initiator Mode & Target
mode to operate at the same time.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h |   1 +
 drivers/scsi/qla2xxx/qla_init.c|   6 +-
 drivers/scsi/qla2xxx/qla_isr.c |  19 ++-
 drivers/scsi/qla2xxx/qla_target.c  | 110 +++--
 drivers/scsi/qla2xxx/qla_target.h  |   3 +
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |   2 +-
 6 files changed, 119 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 253f991..fd179df 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3390,6 +3390,7 @@ struct qla_hw_data {
 #define FLOGI_SP_SUPPORTBIT_13
 
uint8_t port_no;/* Physical port of adapter */
+   uint8_t exch_starvation;
 
/* Timeout timers. */
uint8_t loop_down_abort_time;/* port down timer */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 705f3db..a4e92c7 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1571,8 +1571,7 @@ void qla2x00_fcport_event_handler(scsi_qla_host_t *vha,
}
}
 
-   if (qla_ini_mode_enabled(vha) ||
-   qla_dual_mode_enabled(vha))
+   if (qla_ini_mode_enabled(vha) || qla_dual_mode_enabled(vha))
rval = qla2x00_init_rings(vha);
 
ha->flags.chip_reset_done = 1;
@@ -3997,7 +3996,8 @@ static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t 
*vha, nvram_t *nv)
 * Process any ATIO queue entries that came in
 * while we weren't online.
 */
-   if (qla_tgt_mode_enabled(vha)) {
+   if (qla_tgt_mode_enabled(vha) ||
+   qla_dual_mode_enabled(vha)) {
if (IS_QLA27XX(ha) || IS_QLA83XX(ha)) {
spin_lock_irqsave(>tgt.atio_lock,
flags);
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 99088ff..62066af 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1029,7 +1029,8 @@ static void qla_irq_affinity_notify(struct 
irq_affinity_notify *,
 
qla2x00_mark_all_devices_lost(vha, 1);
 
-   if (vha->vp_idx == 0 && !qla_ini_mode_enabled(vha))
+   if (vha->vp_idx == 0 &&
+   (qla_tgt_mode_enabled(vha) || qla_dual_mode_enabled(vha)))
set_bit(SCR_PENDING, >dpc_flags);
 
set_bit(LOOP_RESYNC_NEEDED, >dpc_flags);
@@ -1642,6 +1643,7 @@ static void qla_irq_affinity_notify(struct 
irq_affinity_notify *,
fcport->d_id.b.area, fcport->d_id.b.al_pa,
le32_to_cpu(logio->io_parameter[0]));
 
+   vha->hw->exch_starvation = 0;
data[0] = MBS_COMMAND_COMPLETE;
if (sp->type != SRB_LOGIN_CMD)
goto logio_done;
@@ -1677,6 +1679,21 @@ static void qla_irq_affinity_notify(struct 
irq_affinity_notify *,
case LSC_SCODE_NPORT_USED:
data[0] = MBS_LOOP_ID_USED;
break;
+   case LSC_SCODE_NOXCB:
+   vha->hw->exch_starvation++;
+   if (vha->hw->exch_starvation > 5) {
+   ql_log(ql_log_warn, vha, 0x,
+   "Exchange starvation. Resetting RISC\n");
+
+   vha->hw->exch_starvation = 0;
+
+   if (IS_P3P_TYPE(vha->hw))
+   set_bit(FCOE_CTX_RESET_NEEDED, >dpc_flags);
+   else
+   set_bit(ISP_ABORT_NEEDED, >dpc_flags);
+   qla2xxx_wake_dpc(vha);
+   }
+   /* drop through */
default:
data[0] = MBS_COMMAND_ERROR;
break;
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 8dcbc36..94bea80 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -55,8 +55,17 @@
"disabled on enabling target mode and then on disabling target mode "
"enabled back; "
"\"disabled\" - initiator mode will never be enabled; "
+   "\"dual\" - Initiator Modes will be enabled. Target Mode can be 
activated "
+   "when ready "
"\"enabled\" (default) - initiator mode will always stay enabled.");
 
+static int ql_dm_tgt_ex_pct = 50;
+module_param(ql_dm_tgt_ex_pct, int, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(ql_dm_tgt_ex_pct,
+   "For Dual Mode (qlini_mode=dual), this parameter determines "
+   "the percentage of exchanges/cmds FW 

[PATCH v2 07/12] qla2xxx: Track I-T nexus as single fc_port struct.

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Current code merges qla_tgt_sess and fc_port structure
into single fc_port structure represeting same I-T nexus.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h | 112 -
 drivers/scsi/qla2xxx/qla_dfs.c |   4 +-
 drivers/scsi/qla2xxx/qla_init.c|  12 --
 drivers/scsi/qla2xxx/qla_iocb.c|   2 +-
 drivers/scsi/qla2xxx/qla_target.c  | 326 -
 drivers/scsi/qla2xxx/qla_target.h  | 150 ++---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 130 ---
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |   4 +-
 8 files changed, 310 insertions(+), 430 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 1196150..11d5288 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1976,6 +1976,84 @@ struct mbx_entry {
uint8_t port_name[WWN_SIZE];
 };
 
+#ifndef IMMED_NOTIFY_TYPE
+#define IMMED_NOTIFY_TYPE 0x0D /* Immediate notify entry. */
+/*
+ * ISP queue - immediate notify entry structure definition.
+ * This is sent by the ISP to the Target driver.
+ * This IOCB would have report of events sent by the
+ * initiator, that needs to be handled by the target
+ * driver immediately.
+ */
+struct imm_ntfy_from_isp {
+   uint8_t  entry_type;/* Entry type. */
+   uint8_t  entry_count;   /* Entry count. */
+   uint8_t  sys_define;/* System defined. */
+   uint8_t  entry_status;  /* Entry Status. */
+   union {
+   struct {
+   uint32_t sys_define_2; /* System defined. */
+   target_id_t target;
+   uint16_t lun;
+   uint8_t  target_id;
+   uint8_t  reserved_1;
+   uint16_t status_modifier;
+   uint16_t status;
+   uint16_t task_flags;
+   uint16_t seq_id;
+   uint16_t srr_rx_id;
+   uint32_t srr_rel_offs;
+   uint16_t srr_ui;
+#define SRR_IU_DATA_IN 0x1
+#define SRR_IU_DATA_OUT0x5
+#define SRR_IU_STATUS  0x7
+   uint16_t srr_ox_id;
+   uint8_t reserved_2[28];
+   } isp2x;
+   struct {
+   uint32_t reserved;
+   uint16_t nport_handle;
+   uint16_t reserved_2;
+   uint16_t flags;
+#define NOTIFY24XX_FLAGS_GLOBAL_TPRLO   BIT_1
+#define NOTIFY24XX_FLAGS_PUREX_IOCB BIT_0
+   uint16_t srr_rx_id;
+   uint16_t status;
+   uint8_t  status_subcode;
+   uint8_t  fw_handle;
+   uint32_t exchange_address;
+   uint32_t srr_rel_offs;
+   uint16_t srr_ui;
+   uint16_t srr_ox_id;
+   union {
+   struct {
+   uint8_t node_name[8];
+   } plogi; /* PLOGI/ADISC/PDISC */
+   struct {
+   /* PRLI word 3 bit 0-15 */
+   uint16_t wd3_lo;
+   uint8_t resv0[6];
+   } prli;
+   struct {
+   uint8_t port_id[3];
+   uint8_t resv1;
+   uint16_t nport_handle;
+   uint16_t resv2;
+   } req_els;
+   } u;
+   uint8_t port_name[8];
+   uint8_t resv3[3];
+   uint8_t  vp_index;
+   uint32_t reserved_5;
+   uint8_t  port_id[3];
+   uint8_t  reserved_6;
+   } isp24;
+   } u;
+   uint16_t reserved_7;
+   uint16_t ox_id;
+} __packed;
+#endif
+
 /*
  * ISP request and response queue entry sizes
  */
@@ -2026,7 +2104,7 @@ struct mbx_entry {
 /*
  * Fibre channel port type.
  */
- typedef enum {
+typedef enum {
FCT_UNKNOWN,
FCT_RSCN,
FCT_SWITCH,
@@ -2035,6 +2113,19 @@ struct mbx_entry {
FCT_TARGET
 } fc_port_type_t;
 
+enum qlt_plogi_link_t {
+   QLT_PLOGI_LINK_SAME_WWN,
+   QLT_PLOGI_LINK_CONFLICT,
+   QLT_PLOGI_LINK_MAX
+};
+
+struct qlt_plogi_ack_t {
+   struct list_headlist;
+   struct imm_ntfy_from_isp iocb;
+   port_id_t   id;
+   int ref_count;
+};
+
 /*
  * Fibre channel port structure.
  */

[PATCH v2 06/12] qla2xxx: Use d_id instead of s_id for more clarity.

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Updated code with d_id from s_id for better readabilty
and clarity.

Reviewed-by: Christoph Hellwig 
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_dfs.c |  9 -
 drivers/scsi/qla2xxx/qla_target.c  | 24 +++---
 drivers/scsi/qla2xxx/qla_target.h  |  2 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 41 --
 4 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c
index 34272fd..98550c9 100644
--- a/drivers/scsi/qla2xxx/qla_dfs.c
+++ b/drivers/scsi/qla2xxx/qla_dfs.c
@@ -26,12 +26,11 @@
seq_printf(s, "Port ID   Port NameHandle\n");
 
spin_lock_irqsave(>tgt.sess_lock, flags);
-   list_for_each_entry(sess, >sess_list, sess_list_entry) {
+   list_for_each_entry(sess, >sess_list, sess_list_entry)
seq_printf(s, "%02x:%02x:%02x  %8phC  %d\n",
-  
sess->s_id.b.domain,sess->s_id.b.area,
-  sess->s_id.b.al_pa,  sess->port_name,
-  sess->loop_id);
-   }
+   sess->d_id.b.domain, sess->d_id.b.area,
+   sess->d_id.b.al_pa, sess->port_name,
+   sess->loop_id);
spin_unlock_irqrestore(>tgt.sess_lock, flags);
}
 
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 74709d3..c977337 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -530,7 +530,7 @@ static void qlt_free_session_done(struct work_struct *work)
"%s: se_sess %p / sess %p from port %8phC loop_id %#04x"
" s_id %02x:%02x:%02x logout %d keep %d els_logo %d\n",
__func__, sess->se_sess, sess, sess->port_name, sess->loop_id,
-   sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
+   sess->d_id.b.domain, sess->d_id.b.area, sess->d_id.b.al_pa,
sess->logout_on_delete, sess->keep_nport_handle,
sess->send_els_logo);
 
@@ -538,7 +538,7 @@ static void qlt_free_session_done(struct work_struct *work)
 
if (sess->send_els_logo) {
qlt_port_logo_t logo;
-   logo.id = sess->s_id;
+   logo.id = sess->d_id;
logo.cmd_count = 0;
qlt_send_first_logo(vha, );
}
@@ -548,7 +548,7 @@ static void qlt_free_session_done(struct work_struct *work)
 
memset(, 0, sizeof(fcport));
fcport.loop_id = sess->loop_id;
-   fcport.d_id = sess->s_id;
+   fcport.d_id = sess->d_id;
memcpy(fcport.port_name, sess->port_name, WWN_SIZE);
fcport.vha = vha;
fcport.tgt_session = sess;
@@ -757,7 +757,7 @@ static void qlt_schedule_sess_for_deletion(struct 
qla_tgt_sess *sess,
"qla_target(%d): session for port %8phC (loop ID %d s_id 
%02x:%02x:%02x)"
" scheduled for deletion in %u secs (expires: %lu) immed: %d, 
logout: %d, gen: %#x\n",
sess->vha->vp_idx, sess->port_name, sess->loop_id,
-   sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
+   sess->d_id.b.domain, sess->d_id.b.area, sess->d_id.b.al_pa,
dev_loss_tmo, sess->expires, immediate, sess->logout_on_delete,
sess->generation);
 
@@ -892,8 +892,8 @@ static struct qla_tgt_sess *qlt_create_sess(
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf005,
"Double sess %p found (s_id %x:%x:%x, "
"loop_id %d), updating to d_id %x:%x:%x, "
-   "loop_id %d", sess, sess->s_id.b.domain,
-   sess->s_id.b.al_pa, sess->s_id.b.area,
+   "loop_id %d", sess, sess->d_id.b.domain,
+   sess->d_id.b.al_pa, sess->d_id.b.area,
sess->loop_id, fcport->d_id.b.domain,
fcport->d_id.b.al_pa, fcport->d_id.b.area,
fcport->loop_id);
@@ -943,7 +943,7 @@ static struct qla_tgt_sess *qlt_create_sess(
}
sess->tgt = vha->vha_tgt.qla_tgt;
sess->vha = vha;
-   sess->s_id = fcport->d_id;
+   sess->d_id = fcport->d_id;
sess->loop_id = fcport->loop_id;
sess->local = local;
kref_init(>sess_kref);
@@ -974,8 +974,8 @@ static struct qla_tgt_sess *qlt_create_sess(
"qla_target(%d): %ssession for wwn %8phC (loop_id %d, "
"s_id %x:%x:%x, confirmed completion %ssupported) added\n",
vha->vp_idx, local ?  "local " : "", fcport->port_name,
- 

[PATCH v2 10/12] qla2xxx: Remove unused reverse_ini_mode.

2017-01-16 Thread Himanshu Madhani
With support for dual mode in the driver, this mode becomes
dead code. Remove reverse_ini_mode from code.

Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h|  1 -
 drivers/scsi/qla2xxx/qla_target.c | 10 --
 drivers/scsi/qla2xxx/qla_target.h |  8 
 3 files changed, 19 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index fd179df..b447b01 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -3238,7 +3238,6 @@ struct qlt_hw_data {
/* Protected by hw lock */
uint32_t enable_class_2:1;
uint32_t enable_explicit_conf:1;
-   uint32_t ini_mode_force_reverse:1;
uint32_t node_name_set:1;
 
dma_addr_t atio_dma;/* Physical address. */
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 94bea80..2dd986a 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -5856,8 +5856,6 @@ void qlt_lport_deregister(struct scsi_qla_host *vha)
 /* Must be called under HW lock */
 static void qlt_set_mode(struct scsi_qla_host *vha)
 {
-   struct qla_hw_data *ha = vha->hw;
-
switch (ql2x_ini_mode) {
case QLA2XXX_INI_MODE_DISABLED:
case QLA2XXX_INI_MODE_EXCLUSIVE:
@@ -5872,16 +5870,11 @@ static void qlt_set_mode(struct scsi_qla_host *vha)
default:
break;
}
-
-   if (ha->tgt.ini_mode_force_reverse)
-   qla_reverse_ini_mode(vha);
 }
 
 /* Must be called under HW lock */
 static void qlt_clear_mode(struct scsi_qla_host *vha)
 {
-   struct qla_hw_data *ha = vha->hw;
-
switch (ql2x_ini_mode) {
case QLA2XXX_INI_MODE_DISABLED:
vha->host->active_mode = MODE_UNKNOWN;
@@ -5896,9 +5889,6 @@ static void qlt_clear_mode(struct scsi_qla_host *vha)
default:
break;
}
-
-   if (ha->tgt.ini_mode_force_reverse)
-   qla_reverse_ini_mode(vha);
 }
 
 /*
diff --git a/drivers/scsi/qla2xxx/qla_target.h 
b/drivers/scsi/qla2xxx/qla_target.h
index ac86b37..a7f90dc 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -995,14 +995,6 @@ static inline bool qla_dual_mode_enabled(struct 
scsi_qla_host *ha)
return (ha->host->active_mode == MODE_DUAL);
 }
 
-static inline void qla_reverse_ini_mode(struct scsi_qla_host *ha)
-{
-   if (ha->host->active_mode & MODE_INITIATOR)
-   ha->host->active_mode &= ~MODE_INITIATOR;
-   else
-   ha->host->active_mode |= MODE_INITIATOR;
-}
-
 static inline uint32_t sid_to_key(const uint8_t *s_id)
 {
uint32_t key;
-- 
1.8.3.1

--
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 v2 05/12] qla2xxx: Fix wrong argument in sp done callback.

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Callback for sp->done expects scsi_qla_host is passed in as argument,
Instead qla_hw_data is passed in.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_isr.c | 8 
 drivers/scsi/qla2xxx/qla_mr.c  | 6 +++---
 drivers/scsi/qla2xxx/qla_os.c  | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 0c6bd93..87b57bf 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1216,7 +1216,7 @@ static void qla_irq_affinity_notify(struct 
irq_affinity_notify *,
req->outstanding_cmds[index] = NULL;
 
/* Save ISP completion status */
-   sp->done(ha, sp, DID_OK << 16);
+   sp->done(vha, sp, DID_OK << 16);
} else {
ql_log(ql_log_warn, vha, 0x3016, "Invalid SCSI SRB.\n");
 
@@ -2409,7 +2409,7 @@ struct scsi_dif_tuple {
resid_len, fw_resid_len, sp, cp);
 
if (rsp->status_srb == NULL)
-   sp->done(ha, sp, res);
+   sp->done(vha, sp, res);
 }
 
 /**
@@ -2466,7 +2466,7 @@ struct scsi_dif_tuple {
/* Place command on done queue. */
if (sense_len == 0) {
rsp->status_srb = NULL;
-   sp->done(ha, sp, cp->result);
+   sp->done(vha, sp, cp->result);
}
 }
 
@@ -2502,7 +2502,7 @@ struct scsi_dif_tuple {
 
sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
if (sp) {
-   sp->done(ha, sp, res);
+   sp->done(vha, sp, res);
return;
}
 fatal:
diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index 02f1de1..d38bc64 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -2537,7 +2537,7 @@
par_sense_len, rsp_info_len);
 
if (rsp->status_srb == NULL)
-   sp->done(ha, sp, res);
+   sp->done(vha, sp, res);
 }
 
 /**
@@ -2614,7 +2614,7 @@
/* Place command on done queue. */
if (sense_len == 0) {
rsp->status_srb = NULL;
-   sp->done(ha, sp, cp->result);
+   sp->done(vha, sp, cp->result);
}
 }
 
@@ -2695,7 +2695,7 @@
 
sp = qla2x00_get_sp_from_handle(vha, func, req, pkt);
if (sp) {
-   sp->done(ha, sp, res);
+   sp->done(vha, sp, res);
return;
}
 
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 074dcca..65eca89 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1203,7 +1203,7 @@ uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha)
}
 
spin_lock_irqsave(>hardware_lock, flags);
-   sp->done(ha, sp, 0);
+   sp->done(vha, sp, 0);
spin_unlock_irqrestore(>hardware_lock, flags);
 
/* Did the command return during mailbox execution? */
-- 
1.8.3.1

--
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 v2 04/12] qla2xxx: Remove SRR code.

2017-01-16 Thread Himanshu Madhani
During initial implementation, tape support was included but not
enabled by default on target. So far, we don't see any target
customer requesting this support. Since this code is not being
used actively, we want to remove it and we will add back if there
are any request in future for SRR support.

Reviewed-by: Christoph Hellwig 
Signed-off-by: Himanshu Madhani 
Signed-off-by: Giridhar Malavali 
---
 drivers/scsi/qla2xxx/qla_target.c | 641 --
 drivers/scsi/qla2xxx/qla_target.h |  21 --
 2 files changed, 662 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 1bd9cac..74709d3 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -106,8 +106,6 @@ static int qlt_issue_task_mgmt(struct qla_tgt_sess *sess, 
uint32_t lun,
int fn, void *iocb, int flags);
 static void qlt_send_term_exchange(struct scsi_qla_host *ha, struct qla_tgt_cmd
*cmd, struct atio_from_isp *atio, int ha_locked, int ul_abort);
-static void qlt_reject_free_srr_imm(struct scsi_qla_host *ha,
-   struct qla_tgt_srr_imm *imm, int ha_lock);
 static void qlt_abort_cmd_on_host_reset(struct scsi_qla_host *vha,
struct qla_tgt_cmd *cmd);
 static void qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
@@ -2183,95 +2181,6 @@ static inline int qlt_need_explicit_conf(struct 
qla_hw_data *ha,
cmd->conf_compl_supported;
 }
 
-#ifdef CONFIG_QLA_TGT_DEBUG_SRR
-/*
- *  Original taken from the XFS code
- */
-static unsigned long qlt_srr_random(void)
-{
-   static int Inited;
-   static unsigned long RandomValue;
-   static DEFINE_SPINLOCK(lock);
-   /* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */
-   register long rv;
-   register long lo;
-   register long hi;
-   unsigned long flags;
-
-   spin_lock_irqsave(, flags);
-   if (!Inited) {
-   RandomValue = jiffies;
-   Inited = 1;
-   }
-   rv = RandomValue;
-   hi = rv / 127773;
-   lo = rv % 127773;
-   rv = 16807 * lo - 2836 * hi;
-   if (rv <= 0)
-   rv += 2147483647;
-   RandomValue = rv;
-   spin_unlock_irqrestore(, flags);
-   return rv;
-}
-
-static void qlt_check_srr_debug(struct qla_tgt_cmd *cmd, int *xmit_type)
-{
-#if 0 /* This is not a real status packets lost, so it won't lead to SRR */
-   if ((*xmit_type & QLA_TGT_XMIT_STATUS) && (qlt_srr_random() % 200)
-   == 50) {
-   *xmit_type &= ~QLA_TGT_XMIT_STATUS;
-   ql_dbg(ql_dbg_tgt_mgt, cmd->vha, 0xf015,
-   "Dropping cmd %p (tag %d) status", cmd, se_cmd->tag);
-   }
-#endif
-   /*
-* It's currently not possible to simulate SRRs for FCP_WRITE without
-* a physical link layer failure, so don't even try here..
-*/
-   if (cmd->dma_data_direction != DMA_FROM_DEVICE)
-   return;
-
-   if (qlt_has_data(cmd) && (cmd->sg_cnt > 1) &&
-   ((qlt_srr_random() % 100) == 20)) {
-   int i, leave = 0;
-   unsigned int tot_len = 0;
-
-   while (leave == 0)
-   leave = qlt_srr_random() % cmd->sg_cnt;
-
-   for (i = 0; i < leave; i++)
-   tot_len += cmd->sg[i].length;
-
-   ql_dbg(ql_dbg_tgt_mgt, cmd->vha, 0xf016,
-   "Cutting cmd %p (tag %d) buffer"
-   " tail to len %d, sg_cnt %d (cmd->bufflen %d,"
-   " cmd->sg_cnt %d)", cmd, se_cmd->tag, tot_len, leave,
-   cmd->bufflen, cmd->sg_cnt);
-
-   cmd->bufflen = tot_len;
-   cmd->sg_cnt = leave;
-   }
-
-   if (qlt_has_data(cmd) && ((qlt_srr_random() % 100) == 70)) {
-   unsigned int offset = qlt_srr_random() % cmd->bufflen;
-
-   ql_dbg(ql_dbg_tgt_mgt, cmd->vha, 0xf017,
-   "Cutting cmd %p (tag %d) buffer head "
-   "to offset %d (cmd->bufflen %d)", cmd, se_cmd->tag, offset,
-   cmd->bufflen);
-   if (offset == 0)
-   *xmit_type &= ~QLA_TGT_XMIT_DATA;
-   else if (qlt_set_data_offset(cmd, offset)) {
-   ql_dbg(ql_dbg_tgt_mgt, cmd->vha, 0xf018,
-   "qlt_set_data_offset() failed (tag %d)", 
se_cmd->tag);
-   }
-   }
-}
-#else
-static inline void qlt_check_srr_debug(struct qla_tgt_cmd *cmd, int *xmit_type)
-{}
-#endif
-
 static void qlt_24xx_init_ctio_to_isp(struct ctio7_to_24xx *ctio,
struct qla_tgt_prm *prm)
 {
@@ -2686,7 +2595,6 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int 
xmit_type,
spin_unlock_irqrestore(>hardware_lock, flags);
 
memset(, 0, sizeof(prm));
-   qlt_check_srr_debug(cmd, _type);
 
ql_dbg(ql_dbg_tgt, cmd->vha, 0xe018,
   

[PATCH v2 03/12] qla2xxx: Make trace flags more readable.

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Trace flags are useful during debugging crash dumps
using crash utility. These trace flags makes it easier
to understand various states a command has successfully
completed.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_target.c  | 28 +--
 drivers/scsi/qla2xxx/qla_target.h  | 55 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 43 ++---
 3 files changed, 59 insertions(+), 67 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 39e6a02..1bd9cac 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -3294,7 +3294,7 @@ int qlt_abort_cmd(struct qla_tgt_cmd *cmd)
return EIO;
}
cmd->aborted = 1;
-   cmd->cmd_flags |= BIT_6;
+   cmd->trc_flags |= TRC_ABORT;
spin_unlock_irqrestore(>cmd_lock, flags);
 
qlt_send_term_exchange(vha, cmd, >atio, 0, 1);
@@ -3342,7 +3342,7 @@ static int qlt_prepare_srr_ctio(struct scsi_qla_host *vha,
struct qla_tgt_srr_imm *imm;
 
tgt->ctio_srr_id++;
-   cmd->cmd_flags |= BIT_15;
+   cmd->trc_flags |= TRC_SRR_CTIO;
 
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf019,
"qla_target(%d): CTIO with SRR status received\n", vha->vp_idx);
@@ -3525,7 +3525,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct 
scsi_qla_host *vha,
dump_stack();
}
 
-   cmd->cmd_flags |= BIT_17;
+   cmd->trc_flags |= TRC_FLUSH;
ha->tgt.tgt_ops->free_cmd(cmd);
 }
 
@@ -3691,7 +3691,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host 
*vha, uint32_t handle,
 */
if ((cmd->state != QLA_TGT_STATE_NEED_DATA) &&
(!cmd->aborted)) {
-   cmd->cmd_flags |= BIT_13;
+   cmd->trc_flags |= TRC_CTIO_ERR;
if (qlt_term_ctio_exchange(vha, ctio, cmd, status))
return;
}
@@ -3699,7 +3699,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host 
*vha, uint32_t handle,
 skip_term:
 
if (cmd->state == QLA_TGT_STATE_PROCESSED) {
-   cmd->cmd_flags |= BIT_12;
+   cmd->trc_flags |= TRC_CTIO_DONE;
} else if (cmd->state == QLA_TGT_STATE_NEED_DATA) {
cmd->state = QLA_TGT_STATE_DATA_IN;
 
@@ -3709,11 +3709,11 @@ static void qlt_do_ctio_completion(struct scsi_qla_host 
*vha, uint32_t handle,
ha->tgt.tgt_ops->handle_data(cmd);
return;
} else if (cmd->aborted) {
-   cmd->cmd_flags |= BIT_18;
+   cmd->trc_flags |= TRC_CTIO_ABORTED;
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf01e,
  "Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag);
} else {
-   cmd->cmd_flags |= BIT_19;
+   cmd->trc_flags |= TRC_CTIO_STRANGE;
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05c,
"qla_target(%d): A command in state (%d) should "
"not return a CTIO complete\n", vha->vp_idx, cmd->state);
@@ -3778,7 +3778,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd)
int ret, fcp_task_attr, data_dir, bidi = 0;
 
cmd->cmd_in_wq = 0;
-   cmd->cmd_flags |= BIT_1;
+   cmd->trc_flags |= TRC_DO_WORK;
if (tgt->tgt_stop)
goto out_term;
 
@@ -3830,7 +3830,7 @@ static void __qlt_do_work(struct qla_tgt_cmd *cmd)
 * cmd has not sent to target yet, so pass NULL as the second
 * argument to qlt_send_term_exchange() and free the memory here.
 */
-   cmd->cmd_flags |= BIT_2;
+   cmd->trc_flags |= TRC_DO_WORK_ERR;
spin_lock_irqsave(>hardware_lock, flags);
qlt_send_term_exchange(vha, NULL, >atio, 1, 0);
 
@@ -3881,7 +3881,7 @@ static struct qla_tgt_cmd *qlt_get_tag(scsi_qla_host_t 
*vha,
cmd->loop_id = sess->loop_id;
cmd->conf_compl_supported = sess->conf_compl_supported;
 
-   cmd->cmd_flags = 0;
+   cmd->trc_flags = 0;
cmd->jiffies_at_alloc = get_jiffies_64();
 
cmd->reset_count = vha->hw->chip_reset;
@@ -4017,7 +4017,7 @@ static int qlt_handle_cmd_for_atio(struct scsi_qla_host 
*vha,
}
 
cmd->cmd_in_wq = 1;
-   cmd->cmd_flags |= BIT_0;
+   cmd->trc_flags |= TRC_NEW_CMD;
cmd->se_cmd.cpuid = ha->msix_count ?
ha->tgt.rspq_vector_cpuid : WORK_CPU_UNBOUND;
 
@@ -4709,7 +4709,7 @@ static void qlt_handle_srr(struct scsi_qla_host *vha,
0, 0, 0, NOTIFY_ACK_SRR_FLAGS_ACCEPT, 0, 0);
spin_unlock_irqrestore(>hardware_lock, flags);
if (xmit_type & QLA_TGT_XMIT_DATA) {
-   cmd->cmd_flags |= BIT_8;
+  

[PATCH v2 02/12] qla2xxx: Cleanup TMF code translation from qla_target.

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Move code code which converts Task Mgmt Command flags for
ATIO to TCM #defines, from qla2xxx driver to tcm_qla2xxx
driver.

Reviewed-by: Christoph Hellwig 
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_target.c  | 75 --
 drivers/scsi/qla2xxx/qla_target.h  |  6 ++-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 40 +++-
 3 files changed, 49 insertions(+), 72 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 47acc26..39e6a02 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -1592,8 +1592,9 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host 
*vha,
mcmd->sess = sess;
memcpy(>orig_iocb.abts, abts, sizeof(mcmd->orig_iocb.abts));
mcmd->reset_count = vha->hw->chip_reset;
+   mcmd->tmr_func = QLA_TGT_ABTS;
 
-   rc = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, TMR_ABORT_TASK,
+   rc = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func,
abts->exchange_addr_to_abort);
if (rc != 0) {
ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052,
@@ -4048,7 +4049,6 @@ static int qlt_issue_task_mgmt(struct qla_tgt_sess *sess, 
uint32_t lun,
struct qla_tgt_mgmt_cmd *mcmd;
struct atio_from_isp *a = (struct atio_from_isp *)iocb;
int res;
-   uint8_t tmr_func;
 
mcmd = mempool_alloc(qla_tgt_mgmt_cmd_mempool, GFP_ATOMIC);
if (!mcmd) {
@@ -4070,74 +4070,12 @@ static int qlt_issue_task_mgmt(struct qla_tgt_sess 
*sess, uint32_t lun,
mcmd->reset_count = vha->hw->chip_reset;
 
switch (fn) {
-   case QLA_TGT_CLEAR_ACA:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x1,
-   "qla_target(%d): CLEAR_ACA received\n", sess->vha->vp_idx);
-   tmr_func = TMR_CLEAR_ACA;
-   break;
-
-   case QLA_TGT_TARGET_RESET:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10001,
-   "qla_target(%d): TARGET_RESET received\n",
-   sess->vha->vp_idx);
-   tmr_func = TMR_TARGET_WARM_RESET;
-   break;
-
case QLA_TGT_LUN_RESET:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10002,
-   "qla_target(%d): LUN_RESET received\n", sess->vha->vp_idx);
-   tmr_func = TMR_LUN_RESET;
-   abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id);
-   break;
-
-   case QLA_TGT_CLEAR_TS:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10003,
-   "qla_target(%d): CLEAR_TS received\n", sess->vha->vp_idx);
-   tmr_func = TMR_CLEAR_TASK_SET;
-   break;
-
-   case QLA_TGT_ABORT_TS:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10004,
-   "qla_target(%d): ABORT_TS received\n", sess->vha->vp_idx);
-   tmr_func = TMR_ABORT_TASK_SET;
-   break;
-#if 0
-   case QLA_TGT_ABORT_ALL:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10005,
-   "qla_target(%d): Doing ABORT_ALL_TASKS\n",
-   sess->vha->vp_idx);
-   tmr_func = 0;
-   break;
-
-   case QLA_TGT_ABORT_ALL_SESS:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10006,
-   "qla_target(%d): Doing ABORT_ALL_TASKS_SESS\n",
-   sess->vha->vp_idx);
-   tmr_func = 0;
-   break;
-
-   case QLA_TGT_NEXUS_LOSS_SESS:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10007,
-   "qla_target(%d): Doing NEXUS_LOSS_SESS\n",
-   sess->vha->vp_idx);
-   tmr_func = 0;
-   break;
-
-   case QLA_TGT_NEXUS_LOSS:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x10008,
-   "qla_target(%d): Doing NEXUS_LOSS\n", sess->vha->vp_idx);
-   tmr_func = 0;
-   break;
-#endif
-   default:
-   ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000a,
-   "qla_target(%d): Unknown task mgmt fn 0x%x\n",
-   sess->vha->vp_idx, fn);
-   mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool);
-   return -ENOSYS;
+   abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id);
+   break;
}
 
-   res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, tmr_func, 0);
+   res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, 0);
if (res != 0) {
ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000b,
"qla_target(%d): tgt.tgt_ops->handle_tmr() failed: %d\n",
@@ -4212,8 +4150,9 @@ static int __qlt_abort_task(struct scsi_qla_host *vha,
lun = a->u.isp24.fcp_cmnd.lun;
unpacked_lun = scsilun_to_int((struct scsi_lun *));
mcmd->reset_count = vha->hw->chip_reset;
+   mcmd->tmr_func = QLA_TGT_2G_ABORT_TASK;
 
-   rc = 

[PATCH v2 01/12] qla2xxx: Remove direct access of scsi_status field in se_cmd

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Reviewed-by: Christoph Hellwig 
Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h| 1 +
 drivers/scsi/qla2xxx/qla_target.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 1f7c6d2..1196150 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1794,6 +1794,7 @@ struct crc_context {
 #define SS_RESIDUAL_OVER   BIT_10
 #define SS_SENSE_LEN_VALID BIT_9
 #define SS_RESPONSE_INFO_LEN_VALID BIT_8
+#define SS_SCSI_STATUS_BYTE0xff
 
 #define SS_RESERVE_CONFLICT(BIT_4 | BIT_3)
 #define SS_BUSY_CONDITION  BIT_3
diff --git a/drivers/scsi/qla2xxx/qla_target.c 
b/drivers/scsi/qla2xxx/qla_target.c
index 9c6cb75..47acc26 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2288,7 +2288,7 @@ static void qlt_24xx_init_ctio_to_isp(struct 
ctio7_to_24xx *ctio,
int i;
 
if (qlt_need_explicit_conf(prm->tgt->ha, prm->cmd, 1)) {
-   if (prm->cmd->se_cmd.scsi_status != 0) {
+   if ((prm->rq_result & SS_SCSI_STATUS_BYTE) != 0) {
ql_dbg(ql_dbg_tgt, prm->cmd->vha, 0xe017,
"Skipping EXPLICIT_CONFORM and "
"CTIO7_FLAGS_CONFORM_REQ for FCP READ w/ "
-- 
1.8.3.1

--
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 v2 00/12] qla2xxx: Feature updates for target.

2017-01-16 Thread Himanshu Madhani
Hi Bart, Christoph, 

Please consider this updated series for inclusion in target-pending.

Changes from v1 --> v2

o Updated review comments and added Reviewed-by tags for necessary patches.
o We left the one particular review comment to add helper routine to 
  be addressed at later time in the follow up bug fixes pathes which we
  will be sending in few weeks.
o Added patch to simplify SRB usage in driver.
o Cleaned up warnings reported by sparse option w=1.

I will be sending T10-DIF improvements and left over bug-fixes as a new series 
once
these feature are accepted in target-pending. 

Please apply to target-pending. 

Thanks,
Himanshu

Himanshu Madhani (2):
  qla2xxx: Remove SRR code.
  qla2xxx: Remove unused reverse_ini_mode.

Joe Carnuccio (1):
  qla2xxx: Simplify usage of SRB structure in driver.

Quinn Tran (9):
  qla2xxx: Remove direct access of scsi_status field in se_cmd
  qla2xxx: Cleanup TMF code translation from qla_target.
  qla2xxx: Make trace flags more readable.
  qla2xxx: Fix wrong argument in sp done callback.
  qla2xxx: Use d_id instead of s_id for more clarity.
  qla2xxx: Track I-T nexus as single fc_port struct.
  qla2xxx: Add framework for Async fabric discovery.
  qla2xxx: Add Dual mode support in the driver
  qla2xxx: Improve RSCN handling in driver

 drivers/scsi/qla2xxx/qla_attr.c|3 +
 drivers/scsi/qla2xxx/qla_bsg.c |   23 +-
 drivers/scsi/qla2xxx/qla_def.h |  305 -
 drivers/scsi/qla2xxx/qla_dfs.c |   11 +-
 drivers/scsi/qla2xxx/qla_fw.h  |  106 +-
 drivers/scsi/qla2xxx/qla_gbl.h |   72 +-
 drivers/scsi/qla2xxx/qla_gs.c  |  726 +--
 drivers/scsi/qla2xxx/qla_init.c| 1615 ++--
 drivers/scsi/qla2xxx/qla_inline.h  |   18 +-
 drivers/scsi/qla2xxx/qla_iocb.c|  167 ++-
 drivers/scsi/qla2xxx/qla_isr.c |  318 +++--
 drivers/scsi/qla2xxx/qla_mbx.c |  235 ++--
 drivers/scsi/qla2xxx/qla_mr.c  |   48 +-
 drivers/scsi/qla2xxx/qla_os.c  |  330 +++--
 drivers/scsi/qla2xxx/qla_target.c  | 2359 +---
 drivers/scsi/qla2xxx/qla_target.h  |  252 +---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  256 ++--
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |4 +-
 18 files changed, 4314 insertions(+), 2534 deletions(-)

-- 
1.8.3.1

--
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 v2 12/12] qla2xxx: Simplify usage of SRB structure in driver.

2017-01-16 Thread Himanshu Madhani
From: Joe Carnuccio 

This patch simplifies SRB structure usage in driver.

- Simplify sp->done() and sp->free() interfaces.
- Remove sp->fcport->vha to use vha pointer from sp.
- Use sp->vha context in qla2x00_rel_sp().

Signed-off-by: Joe Carnuccio 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_bsg.c| 23 -
 drivers/scsi/qla2xxx/qla_def.h|  6 +--
 drivers/scsi/qla2xxx/qla_gbl.h| 14 +++---
 drivers/scsi/qla2xxx/qla_gs.c | 32 ++---
 drivers/scsi/qla2xxx/qla_init.c   | 99 +++
 drivers/scsi/qla2xxx/qla_inline.h | 13 +++--
 drivers/scsi/qla2xxx/qla_iocb.c   | 96 +++--
 drivers/scsi/qla2xxx/qla_isr.c| 36 +++---
 drivers/scsi/qla2xxx/qla_mr.c | 48 +--
 drivers/scsi/qla2xxx/qla_os.c | 35 +++---
 drivers/scsi/qla2xxx/qla_target.c |  8 ++--
 11 files changed, 199 insertions(+), 211 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_bsg.c b/drivers/scsi/qla2xxx/qla_bsg.c
index 1bf8061..975e7a1 100644
--- a/drivers/scsi/qla2xxx/qla_bsg.c
+++ b/drivers/scsi/qla2xxx/qla_bsg.c
@@ -13,28 +13,25 @@
 
 /* BSG support for ELS/CT pass through */
 void
-qla2x00_bsg_job_done(void *data, void *ptr, int res)
+qla2x00_bsg_job_done(void *ptr, int res)
 {
-   srb_t *sp = (srb_t *)ptr;
-   struct scsi_qla_host *vha = (scsi_qla_host_t *)data;
+   srb_t *sp = ptr;
struct bsg_job *bsg_job = sp->u.bsg_job;
struct fc_bsg_reply *bsg_reply = bsg_job->reply;
 
bsg_reply->result = res;
bsg_job_done(bsg_job, bsg_reply->result,
   bsg_reply->reply_payload_rcv_len);
-   sp->free(vha, sp);
+   sp->free(sp);
 }
 
 void
-qla2x00_bsg_sp_free(void *data, void *ptr)
+qla2x00_bsg_sp_free(void *ptr)
 {
-   srb_t *sp = (srb_t *)ptr;
-   struct scsi_qla_host *vha = sp->fcport->vha;
+   srb_t *sp = ptr;
+   struct qla_hw_data *ha = sp->vha->hw;
struct bsg_job *bsg_job = sp->u.bsg_job;
struct fc_bsg_request *bsg_request = bsg_job->request;
-
-   struct qla_hw_data *ha = vha->hw;
struct qla_mt_iocb_rqst_fx00 *piocb_rqst;
 
if (sp->type == SRB_FXIOCB_BCMD) {
@@ -62,7 +59,7 @@
sp->type == SRB_FXIOCB_BCMD ||
sp->type == SRB_ELS_CMD_HST)
kfree(sp->fcport);
-   qla2x00_rel_sp(vha, sp);
+   qla2x00_rel_sp(sp);
 }
 
 int
@@ -394,7 +391,7 @@
if (rval != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x700e,
"qla2x00_start_sp failed = %d\n", rval);
-   qla2x00_rel_sp(vha, sp);
+   qla2x00_rel_sp(sp);
rval = -EIO;
goto done_unmap_sg;
}
@@ -542,7 +539,7 @@
if (rval != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x7017,
"qla2x00_start_sp failed=%d.\n", rval);
-   qla2x00_rel_sp(vha, sp);
+   qla2x00_rel_sp(sp);
rval = -EIO;
goto done_free_fcport;
}
@@ -2578,6 +2575,6 @@
 
 done:
spin_unlock_irqrestore(>hardware_lock, flags);
-   sp->free(vha, sp);
+   sp->free(sp);
return 0;
 }
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 329aebf..e6bbd63 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -433,7 +433,7 @@ struct srb_iocb {
 typedef struct srb {
atomic_t ref_count;
struct fc_port *fcport;
-   void *vha;
+   struct scsi_qla_host *vha;
uint32_t handle;
uint16_t flags;
uint16_t type;
@@ -447,8 +447,8 @@ struct srb_iocb {
struct bsg_job *bsg_job;
struct srb_cmd scmd;
} u;
-   void (*done)(void *, void *, int);
-   void (*free)(void *, void *);
+   void (*done)(void *, int);
+   void (*free)(void *);
 } srb_t;
 
 #define GET_CMD_SP(sp) (sp->u.scmd.cmd)
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index e091457..b3d6441 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -186,9 +186,9 @@ extern struct scsi_qla_host *qla2x00_create_host(struct 
scsi_host_template *,
 
 extern int qla2x00_post_uevent_work(struct scsi_qla_host *, u32);
 extern void qla2x00_disable_board_on_pci_error(struct work_struct *);
-extern void qla2x00_sp_compl(void *, void *, int);
-extern void qla2xxx_qpair_sp_free_dma(void *, void *);
-extern void qla2xxx_qpair_sp_compl(void *, void *, int);
+extern void qla2x00_sp_compl(void *, int);
+extern void qla2xxx_qpair_sp_free_dma(void *);
+extern void qla2xxx_qpair_sp_compl(void *, int);
 extern int qla24xx_post_upd_fcport_work(struct scsi_qla_host *, fc_port_t *);
 void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
@@ -215,7 +215,7 @@ extern void 

[PATCH v2 11/12] qla2xxx: Improve RSCN handling in driver

2017-01-16 Thread Himanshu Madhani
From: Quinn Tran 

Current code blindly does State Change Registration when
the link is up. Move SCR behind fabric scan, so that arbitrated
loop scan would not get erroneous error message.

Some of the other improvements are as follows

- Add session deletion for TPRLO and send acknowledgment for TPRLO.
- Enable FW option to move ABTS, RIDA & PUREX from RSPQ to ATIOQ.
- Save NPort ID early in link init.
- Move ABTS & RIDA to ATIOQ helps in keeping command ordering and
  link up sequence ordering.
- Save Nport ID and update VP map so that SCSI CMD/ATIO won't be dropped.
- fcport alloc does the initializes memory to zero. Remove memset to
  zero since It might corrupt link list.
- Turn off Registration for State Change MB in loop mode.

Signed-off-by: Quinn Tran 
Signed-off-by: Himanshu Madhani 
---
 drivers/scsi/qla2xxx/qla_def.h|  11 +-
 drivers/scsi/qla2xxx/qla_fw.h |  75 +---
 drivers/scsi/qla2xxx/qla_gbl.h|   2 +
 drivers/scsi/qla2xxx/qla_gs.c |   4 +-
 drivers/scsi/qla2xxx/qla_init.c   | 151 
 drivers/scsi/qla2xxx/qla_isr.c|   6 +-
 drivers/scsi/qla2xxx/qla_mbx.c| 147 +++
 drivers/scsi/qla2xxx/qla_os.c |  48 
 drivers/scsi/qla2xxx/qla_target.c | 238 ++
 9 files changed, 537 insertions(+), 145 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index b447b01..329aebf 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2226,6 +2226,13 @@ enum fcport_mgt_event {
FCME_DELETE_DONE,
 };
 
+enum rscn_addr_format {
+   RSCN_PORT_ADDR,
+   RSCN_AREA_ADDR,
+   RSCN_DOM_ADDR,
+   RSCN_FAB_ADDR,
+};
+
 /*
  * Fibre channel port structure.
  */
@@ -3957,7 +3964,7 @@ struct qla_tgt_counters {
 #define FCOE_CTX_RESET_NEEDED  18  /* Initiate FCoE context reset */
 #define MPI_RESET_NEEDED   19  /* Initiate MPI FW reset */
 #define ISP_QUIESCE_NEEDED 20  /* Driver need some quiescence */
-#define SCR_PENDING21  /* SCR in target mode */
+#define FREE_BIT 21
 #define PORT_UPDATE_NEEDED 22
 #define FX00_RESET_RECOVERY23
 #define FX00_TARGET_SCAN   24
@@ -4011,7 +4018,9 @@ struct qla_tgt_counters {
/* list of commands waiting on workqueue */
struct list_headqla_cmd_list;
struct list_headqla_sess_op_cmd_list;
+   struct list_headunknown_atio_list;
spinlock_t  cmd_list_lock;
+   struct delayed_work unknown_atio_work;
 
/* Counter to detect races between ELS and RSCN events */
atomic_tgeneration_tick;
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index ee135cf..1f80892 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -1301,27 +1301,76 @@ struct vp_config_entry_24xx {
 };
 
 #define VP_RPT_ID_IOCB_TYPE0x32/* Report ID Acquisition entry. */
+enum VP_STATUS {
+   VP_STAT_COMPL,
+   VP_STAT_FAIL,
+   VP_STAT_ID_CHG,
+   VP_STAT_SNS_TO, /* timeout */
+   VP_STAT_SNS_RJT,
+   VP_STAT_SCR_TO, /* timeout */
+   VP_STAT_SCR_RJT,
+};
+
+enum VP_FLAGS {
+   VP_FLAGS_CON_FLOOP = 1,
+   VP_FLAGS_CON_P2P = 2,
+   VP_FLAGS_CON_FABRIC = 3,
+   VP_FLAGS_NAME_VALID = BIT_5,
+};
+
 struct vp_rpt_id_entry_24xx {
uint8_t entry_type; /* Entry type. */
uint8_t entry_count;/* Entry count. */
uint8_t sys_define; /* System defined. */
uint8_t entry_status;   /* Entry Status. */
-
-   uint32_t handle;/* System handle. */
-
-   uint16_t vp_count;  /* Format 0 -- | VP setup | VP acq |. */
-   /* Format 1 -- | VP count |. */
-   uint16_t vp_idx;/* Format 0 -- Reserved. */
-   /* Format 1 -- VP status and index. */
+   uint32_t resv1;
+   uint8_t vp_acquired;
+   uint8_t vp_setup;
+   uint8_t vp_idx; /* Format 0=reserved */
+   uint8_t vp_status;  /* Format 0=reserved */
 
uint8_t port_id[3];
uint8_t format;
-
-   uint8_t vp_idx_map[16];
-
-   uint8_t reserved_4[24];
-   uint16_t bbcr;
-   uint8_t reserved_5[6];
+   union {
+   struct {
+   /* format 0 loop */
+   uint8_t vp_idx_map[16];
+   uint8_t reserved_4[32];
+   } f0;
+   struct {
+   /* format 1 fabric */
+   uint8_t vpstat1_subcode; /* vp_status=1 subcode */
+   uint8_t flags;
+   uint16_t fip_flags;
+   uint8_t rsv2[12];
+
+

Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-16 Thread kbuild test robot
Hi Fam,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc4 next-20170116]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Fam-Zheng/virtio-scsi-Implement-FC_HOST-feature/20170117-011950
config: arm-vexpress_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget 
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
 -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `init':
>> drivers/scsi/virtio_scsi.c:1178: undefined reference to `fc_attach_transport'
   drivers/built-in.o: In function `fini':
>> drivers/scsi/virtio_scsi.c:1231: undefined reference to 
>> `fc_release_transport'

vim +1178 drivers/scsi/virtio_scsi.c

  1172  };
  1173  
  1174  static int __init init(void)
  1175  {
  1176  int ret = -ENOMEM;
  1177  
> 1178  virtscsi_fc_transport_template = 
> fc_attach_transport(_fc_template);
  1179  if (!virtscsi_fc_transport_template) {
  1180  pr_err("fc_attach_transport() failed\n");
  1181  goto error;
  1182  }
  1183  
  1184  virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
  1185  if (!virtscsi_cmd_cache) {
  1186  pr_err("kmem_cache_create() for virtscsi_cmd_cache 
failed\n");
  1187  goto error;
  1188  }
  1189  
  1190  
  1191  virtscsi_cmd_pool =
  1192  mempool_create_slab_pool(VIRTIO_SCSI_MEMPOOL_SZ,
  1193   virtscsi_cmd_cache);
  1194  if (!virtscsi_cmd_pool) {
  1195  pr_err("mempool_create() for virtscsi_cmd_pool 
failed\n");
  1196  goto error;
  1197  }
  1198  ret = cpuhp_setup_state_multi(CPUHP_AP_ONLINE_DYN,
  1199"scsi/virtio:online",
  1200virtscsi_cpu_online, NULL);
  1201  if (ret < 0)
  1202  goto error;
  1203  virtioscsi_online = ret;
  1204  ret = cpuhp_setup_state_multi(CPUHP_VIRT_SCSI_DEAD, 
"scsi/virtio:dead",
  1205NULL, virtscsi_cpu_online);
  1206  if (ret)
  1207  goto error;
  1208  ret = register_virtio_driver(_scsi_driver);
  1209  if (ret < 0)
  1210  goto error;
  1211  
  1212  return 0;
  1213  
  1214  error:
  1215  if (virtscsi_cmd_pool) {
  1216  mempool_destroy(virtscsi_cmd_pool);
  1217  virtscsi_cmd_pool = NULL;
  1218  }
  1219  if (virtscsi_cmd_cache) {
  1220  kmem_cache_destroy(virtscsi_cmd_cache);
  1221  virtscsi_cmd_cache = NULL;
  1222  }
  1223  if (virtioscsi_online)
  1224  cpuhp_remove_multi_state(virtioscsi_online);
  1225  cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
  1226  return ret;
  1227  }
  1228  
  1229  static void __exit fini(void)
  1230  {
> 1231  fc_release_transport(virtscsi_fc_transport_template);
  1232  unregister_virtio_driver(_scsi_driver);
  1233  cpuhp_remove_multi_state(virtioscsi_online);
  1234  cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH 0/2] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Paolo Bonzini

> How it this supposed to work?
> You do export the WWPN/WWNN of the associated host to the guest (nb:
> will get interesting for non NPIV setups ...), but virtio scsi will
> still do a LUN remapping.
> IE the LUNs you see on the host will be different from the LUNs
> presented to the guest.

This is taken care of in the host by presenting to the host all LUNs from
a host's NPIV vHBA.  (Libvirt probably would be the one taking care of this,
because QEMU may not have enough permissions).

> Plus you don't _actually_ expose the FC host, but rather the WWPN of the
> host presenting the LUN.
> So how do you handle LUNs from different FC hosts on the guest?

I'm not sure I understand.

Neither I nor Fam know this stuff very well, but we are trying to do the same
as Hyper-V (and other proprietary hypervisors too).

> Overall, I'm not overly happy with this approach.
> You already added WWPN ids to the virtio transport, so why didn't you
> update the LUN field, too, to avoid this ominous LUN remapping?

Is this your old idea of adding a separate target field to commands,
in order to support 64-bit LUNs?  That is separate, and most FC drivers
only default to 16-bit LUNs anyway.

> And we really should make sure to have a single FC host in the guest
> presenting all LUNs.

Yes, of course.

Paolo
--
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 1/2] qed: Add support for hardware offloaded FCoE.

2017-01-16 Thread Dupuis, Chad
From: Arun Easi 

This adds the backbone required for the various HW initalizations
which are necessary for the FCoE driver (qedf) for QLogic FastLinQ
4 line of adapters - FW notification, resource initializations, etc.

Signed-off-by: Arun Easi 
Signed-off-by: Yuval Mintz 
---
 drivers/net/ethernet/qlogic/Kconfig   |   3 +
 drivers/net/ethernet/qlogic/qed/Makefile  |   1 +
 drivers/net/ethernet/qlogic/qed/qed.h |  11 +
 drivers/net/ethernet/qlogic/qed/qed_cxt.c |  98 ++-
 drivers/net/ethernet/qlogic/qed/qed_cxt.h |   3 +
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c|  11 +
 drivers/net/ethernet/qlogic/qed/qed_dcbx.h|   1 +
 drivers/net/ethernet/qlogic/qed/qed_dev.c | 205 -
 drivers/net/ethernet/qlogic/qed/qed_dev_api.h |  42 +
 drivers/net/ethernet/qlogic/qed/qed_fcoe.c| 990 ++
 drivers/net/ethernet/qlogic/qed/qed_fcoe.h|  52 ++
 drivers/net/ethernet/qlogic/qed/qed_hsi.h | 781 -
 drivers/net/ethernet/qlogic/qed/qed_hw.c  |   3 +
 drivers/net/ethernet/qlogic/qed/qed_ll2.c |  25 +
 drivers/net/ethernet/qlogic/qed/qed_ll2.h |   2 +-
 drivers/net/ethernet/qlogic/qed/qed_main.c|   7 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.c |   3 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h |   1 +
 drivers/net/ethernet/qlogic/qed/qed_reg_addr.h|   8 +
 drivers/net/ethernet/qlogic/qed/qed_sp.h  |   4 +
 drivers/net/ethernet/qlogic/qed/qed_sp_commands.c |   3 +
 include/linux/qed/common_hsi.h|  10 +-
 include/linux/qed/fcoe_common.h   | 715 
 include/linux/qed/qed_fcoe_if.h   | 145 
 include/linux/qed/qed_if.h|  39 +
 25 files changed, 3152 insertions(+), 11 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_fcoe.c
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_fcoe.h
 create mode 100644 include/linux/qed/fcoe_common.h
 create mode 100644 include/linux/qed/qed_fcoe_if.h

diff --git a/drivers/net/ethernet/qlogic/Kconfig 
b/drivers/net/ethernet/qlogic/Kconfig
index 3cfd105..737b303 100644
--- a/drivers/net/ethernet/qlogic/Kconfig
+++ b/drivers/net/ethernet/qlogic/Kconfig
@@ -113,4 +113,7 @@ config QED_RDMA
 config QED_ISCSI
bool
 
+config QED_FCOE
+   bool
+
 endif # NET_VENDOR_QLOGIC
diff --git a/drivers/net/ethernet/qlogic/qed/Makefile 
b/drivers/net/ethernet/qlogic/qed/Makefile
index 729e437..e234083 100644
--- a/drivers/net/ethernet/qlogic/qed/Makefile
+++ b/drivers/net/ethernet/qlogic/qed/Makefile
@@ -7,3 +7,4 @@ qed-$(CONFIG_QED_SRIOV) += qed_sriov.o qed_vf.o
 qed-$(CONFIG_QED_LL2) += qed_ll2.o
 qed-$(CONFIG_QED_RDMA) += qed_roce.o
 qed-$(CONFIG_QED_ISCSI) += qed_iscsi.o qed_ooo.o
+qed-$(CONFIG_QED_FCOE) += qed_fcoe.o
diff --git a/drivers/net/ethernet/qlogic/qed/qed.h 
b/drivers/net/ethernet/qlogic/qed/qed.h
index 1f61cf3..08f2885 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -60,6 +60,7 @@
 #define QED_WFQ_UNIT   100
 
 #define ISCSI_BDQ_ID(_port_id) (_port_id)
+#define FCOE_BDQ_ID(_port_id) ((_port_id) + 2)
 #define QED_WID_SIZE(1024)
 #define QED_PF_DEMS_SIZE(4)
 
@@ -167,6 +168,7 @@ struct qed_tunn_update_params {
  */
 enum qed_pci_personality {
QED_PCI_ETH,
+   QED_PCI_FCOE,
QED_PCI_ISCSI,
QED_PCI_ETH_ROCE,
QED_PCI_DEFAULT /* default in shmem */
@@ -204,6 +206,7 @@ enum QED_FEATURE {
QED_VF,
QED_RDMA_CNQ,
QED_VF_L2_QUE,
+   QED_FCOE_CQ,
QED_MAX_FEATURES,
 };
 
@@ -221,6 +224,7 @@ enum QED_PORT_MODE {
 
 enum qed_dev_cap {
QED_DEV_CAP_ETH,
+   QED_DEV_CAP_FCOE,
QED_DEV_CAP_ISCSI,
QED_DEV_CAP_ROCE,
 };
@@ -255,6 +259,10 @@ struct qed_hw_info {
u32 part_num[4];
 
unsigned char   hw_mac_addr[ETH_ALEN];
+   u64 node_wwn;
+   u64 port_wwn;
+
+   u16 num_fcoe_conns;
 
struct qed_igu_info *p_igu_info;
 
@@ -410,6 +418,7 @@ struct qed_hwfn {
struct qed_ooo_info *p_ooo_info;
struct qed_rdma_info*p_rdma_info;
struct qed_iscsi_info   *p_iscsi_info;
+   struct qed_fcoe_info*p_fcoe_info;
struct qed_pf_paramspf_params;
 
bool b_rdma_enabled_in_prs;
@@ -618,11 +627,13 @@ struct qed_dev {
 
u8  protocol;
 #define IS_QED_ETH_IF(cdev) ((cdev)->protocol == QED_PROTOCOL_ETH)
+#define IS_QED_FCOE_IF(cdev)((cdev)->protocol == QED_PROTOCOL_FCOE)
 
/* Callbacks to protocol driver */
union {
struct qed_common_cb_ops*common;
struct 

[PATCH 0/2] Add QLogic FastLinQ FCoE (qedf) driver

2017-01-16 Thread Dupuis, Chad
From: "Dupuis, Chad" 

This series introduces the hardware offload FCoE initiator driver for the
41000 Series Converged Network Adapters (579xx chip) by Cavium. The overall
driver design includes a common module ('qed') and protocol specific
dependent modules ('qedf' for FCoE).

This driver uses the kernel components of libfc and libfcoe as is and does not
make use of the open-fcoe user space components.  Therefore, no changes will 
need to be
made to any open-fcoe components.

The 'qed' common module, under drivers/net/ethernet/qlogic/qed/, is
enhanced with functionality required for FCoE support.

Changes from RFC -> V1

- Squash qedf patches to one patch now that the initial review has taken place
- Convert qedf to use hotplug state machine
- Return via va_end to match corresponding va_start in logging functions
- Convert qedf_ctx offloaded port list to a RCU list so searches do not need
  to make use of spinlocks.  Also eliminates the need to fcport conn_id's.
- Use IS_ERR(fp) in qedf_flogi_resp() instead of checking individual FC_EX_* 
errors.
- Remove scsi_block_target when executing TMF request.
- Checkpatch fixes in the qed and qedf patches

At the current time I couldn't make use of Christoph's IRQ allocation changes
as changes are needed to the core module (qed) which would affect other drivers
that are already in tree (qede, qedr, qedi).

Arun Easi (1):
  qed: Add support for hardware offloaded FCoE.

Dupuis, Chad (1):
  qedf: Add QLogic FastLinQ offload FCoE driver framework.

 MAINTAINERS   |6 +
 drivers/net/ethernet/qlogic/Kconfig   |3 +
 drivers/net/ethernet/qlogic/qed/Makefile  |1 +
 drivers/net/ethernet/qlogic/qed/qed.h |   11 +
 drivers/net/ethernet/qlogic/qed/qed_cxt.c |   98 +-
 drivers/net/ethernet/qlogic/qed/qed_cxt.h |3 +
 drivers/net/ethernet/qlogic/qed/qed_dcbx.c|   11 +
 drivers/net/ethernet/qlogic/qed/qed_dcbx.h|1 +
 drivers/net/ethernet/qlogic/qed/qed_dev.c |  205 +-
 drivers/net/ethernet/qlogic/qed/qed_dev_api.h |   42 +
 drivers/net/ethernet/qlogic/qed/qed_fcoe.c|  990 ++
 drivers/net/ethernet/qlogic/qed/qed_fcoe.h|   52 +
 drivers/net/ethernet/qlogic/qed/qed_hsi.h |  781 -
 drivers/net/ethernet/qlogic/qed/qed_hw.c  |3 +
 drivers/net/ethernet/qlogic/qed/qed_ll2.c |   25 +
 drivers/net/ethernet/qlogic/qed/qed_ll2.h |2 +-
 drivers/net/ethernet/qlogic/qed/qed_main.c|7 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.c |3 +
 drivers/net/ethernet/qlogic/qed/qed_mcp.h |1 +
 drivers/net/ethernet/qlogic/qed/qed_reg_addr.h|8 +
 drivers/net/ethernet/qlogic/qed/qed_sp.h  |4 +
 drivers/net/ethernet/qlogic/qed/qed_sp_commands.c |3 +
 drivers/scsi/Kconfig  |1 +
 drivers/scsi/qedf/Kconfig |   11 +
 drivers/scsi/qedf/Makefile|5 +
 drivers/scsi/qedf/qedf.h  |  555 
 drivers/scsi/qedf/qedf_attr.c |  165 +
 drivers/scsi/qedf/qedf_dbg.c  |  195 ++
 drivers/scsi/qedf/qedf_dbg.h  |  154 +
 drivers/scsi/qedf/qedf_debugfs.c  |  471 +++
 drivers/scsi/qedf/qedf_els.c  |  984 ++
 drivers/scsi/qedf/qedf_fip.c  |  267 ++
 drivers/scsi/qedf/qedf_hsi.h  |  427 +++
 drivers/scsi/qedf/qedf_io.c   | 2301 ++
 drivers/scsi/qedf/qedf_main.c | 3483 +
 drivers/scsi/qedf/qedf_version.h  |   15 +
 include/linux/qed/common_hsi.h|   10 +-
 include/linux/qed/fcoe_common.h   |  715 +
 include/linux/qed/qed_fcoe_if.h   |  145 +
 include/linux/qed/qed_if.h|   39 +
 40 files changed, 12192 insertions(+), 11 deletions(-)
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_fcoe.c
 create mode 100644 drivers/net/ethernet/qlogic/qed/qed_fcoe.h
 create mode 100644 drivers/scsi/qedf/Kconfig
 create mode 100644 drivers/scsi/qedf/Makefile
 create mode 100644 drivers/scsi/qedf/qedf.h
 create mode 100644 drivers/scsi/qedf/qedf_attr.c
 create mode 100644 drivers/scsi/qedf/qedf_dbg.c
 create mode 100644 drivers/scsi/qedf/qedf_dbg.h
 create mode 100644 drivers/scsi/qedf/qedf_debugfs.c
 create mode 100644 drivers/scsi/qedf/qedf_els.c
 create mode 100644 drivers/scsi/qedf/qedf_fip.c
 create mode 100644 drivers/scsi/qedf/qedf_hsi.h
 create mode 100644 drivers/scsi/qedf/qedf_io.c
 create mode 100644 drivers/scsi/qedf/qedf_main.c
 create mode 100644 drivers/scsi/qedf/qedf_version.h
 create mode 100644 include/linux/qed/fcoe_common.h
 create mode 100644 include/linux/qed/qed_fcoe_if.h

-- 
1.8.5.6

--
To unsubscribe from this list: send the line 

Re: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-16 Thread James Bottomley
>From 91d249409546569444897a1ffde65c421e064899 Mon Sep 17 00:00:00 2001
From: James Bottomley 
Date: Sun, 1 Jan 2017 09:39:24 -0800
Subject: [PATCH] scsi: mpt3sas: fix hang on ata passthrough commands

mpt3sas has a firmware failure where it can only handle one pass
through ATA command at a time.  If another comes in, contrary to the
SAT standard, it will hang until the first one completes (causing long
commands like secure erase to timeout).  The original fix was to block
the device when an ATA command came in, but this caused a regression
with

commit 669f044170d8933c3d66d231b69ea97cb8447338
Author: Bart Van Assche 
Date:   Tue Nov 22 16:17:13 2016 -0800

scsi: srp_transport: Move queuecommand() wait code to SCSI core

So fix the original fix of the secure erase timeout by properly
returning SAM_STAT_BUSY like the SAT recommends.  The original patch
also had a concurrency problem since scsih_qcmd is lockless at that
point (this is fixed by using atomic bitops to set and test the flag).

Fixes: 18f6084a989ba1b (mpt3sas: Fix secure erase premature termination)
Signed-off-by: James Bottomley 

---

v2 - use bitops for lockless atomicity
v3 - update description, change function name
---
 drivers/scsi/mpt3sas/mpt3sas_base.h  | 12 +++
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 40 +++-
 2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h 
b/drivers/scsi/mpt3sas/mpt3sas_base.h
index 394fe13..dcb33f4 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.h
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.h
@@ -393,6 +393,7 @@ struct MPT3SAS_TARGET {
  * @eedp_enable: eedp support enable bit
  * @eedp_type: 0(type_1), 1(type_2), 2(type_3)
  * @eedp_block_length: block size
+ * @ata_command_pending: SATL passthrough outstanding for device
  */
 struct MPT3SAS_DEVICE {
struct MPT3SAS_TARGET *sas_target;
@@ -404,6 +405,17 @@ struct MPT3SAS_DEVICE {
u8  ignore_delay_remove;
/* Iopriority Command Handling */
u8  ncq_prio_enable;
+   /*
+* Bug workaround for SATL handling: the mpt2/3sas firmware
+* doesn't return BUSY or TASK_SET_FULL for subsequent
+* commands while a SATL pass through is in operation as the
+* spec requires, it simply does nothing with them until the
+* pass through completes, causing them possibly to timeout if
+* the passthrough is a long executing command (like format or
+* secure erase).  This variable allows us to do the right
+* thing while a SATL command is pending.
+*/
+   unsigned long ata_command_pending;
 
 };
 
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c 
b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index b5c966e..830e2c1 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3899,9 +3899,18 @@ _scsih_temp_threshold_events(struct MPT3SAS_ADAPTER *ioc,
}
 }
 
-static inline bool ata_12_16_cmd(struct scsi_cmnd *scmd)
+static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
 {
-   return (scmd->cmnd[0] == ATA_12 || scmd->cmnd[0] == ATA_16);
+   struct MPT3SAS_DEVICE *priv = scmd->device->hostdata;
+
+   if  (scmd->cmnd[0] != ATA_12 && scmd->cmnd[0] != ATA_16)
+   return 0;
+
+   if (pending)
+   return test_and_set_bit(0, >ata_command_pending);
+
+   clear_bit(0, >ata_command_pending);
+   return 0;
 }
 
 /**
@@ -3925,9 +3934,7 @@ _scsih_flush_running_cmds(struct MPT3SAS_ADAPTER *ioc)
if (!scmd)
continue;
count++;
-   if (ata_12_16_cmd(scmd))
-   scsi_internal_device_unblock(scmd->device,
-   SDEV_RUNNING);
+   _scsih_set_satl_pending(scmd, false);
mpt3sas_base_free_smid(ioc, smid);
scsi_dma_unmap(scmd);
if (ioc->pci_error_recovery)
@@ -4063,13 +4070,6 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
if (ioc->logging_level & MPT_DEBUG_SCSI)
scsi_print_command(scmd);
 
-   /*
-* Lock the device for any subsequent command until command is
-* done.
-*/
-   if (ata_12_16_cmd(scmd))
-   scsi_internal_device_block(scmd->device);
-
sas_device_priv_data = scmd->device->hostdata;
if (!sas_device_priv_data || !sas_device_priv_data->sas_target) {
scmd->result = DID_NO_CONNECT << 16;
@@ -4083,6 +4083,19 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd 
*scmd)
return 0;
}
 
+   /*
+* Bug work around for firmware SATL handling.  The loop
+* is based on atomic operations and ensures consistency
+* since we're lockless at this point
+ 

Re: [PATCH 2/2] virtio_scsi: Implement fc_host

2017-01-16 Thread kbuild test robot
Hi Fam,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.10-rc4 next-20170116]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Fam-Zheng/virtio-scsi-Implement-FC_HOST-feature/20170117-011950
config: i386-randconfig-r0-201703 (attached as .config)
compiler: gcc-5 (Debian 5.4.1-2) 5.4.1 20160904
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/built-in.o: In function `init':
>> virtio_scsi.c:(.init.text+0x10d52): undefined reference to 
>> `fc_attach_transport'
   drivers/built-in.o: In function `fini':
>> virtio_scsi.c:(.exit.text+0x14a4): undefined reference to 
>> `fc_release_transport'

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


Re: [PATCH] Revert "scsi: mpt3sas: Fix secure erase premature termination"

2017-01-16 Thread Christoph Hellwig
On Mon, Jan 16, 2017 at 08:14:39AM -0800, James Bottomley wrote:
> So how about, instead of arguing about reversion, one or other of you
> reviews the proposed fix of the fix which would avoid having to revert
> anything?

As far as I can tell everyone is waiting for you to resend it with the
review comment from the Broadcom maintainers adddressed.
--
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] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Hannes Reinecke
On 01/16/2017 05:04 PM, Fam Zheng wrote:
> This series implements the proposed fc_host feature of virtio-scsi.
> 
> The first patch updates the data structure changes according to the spec
> proposal; the second patch actually implements the operations.
> 
> Fam Zheng (2):
>   virtio_scsi: Add fc_host definitions
>   virtio_scsi: Implement fc_host
> 
>  drivers/scsi/virtio_scsi.c   | 55 
> +++-
>  include/uapi/linux/virtio_scsi.h |  6 +
>  2 files changed, 60 insertions(+), 1 deletion(-)
> 
Hmm.

How it this supposed to work?
You do export the WWPN/WWNN of the associated host to the guest (nb:
will get interesting for non NPIV setups ...), but virtio scsi will
still do a LUN remapping.
IE the LUNs you see on the host will be different from the LUNs
presented to the guest.

This makes reliable operations very tricky.
Plus you don't _actually_ expose the FC host, but rather the WWPN of the
host presenting the LUN.
So how do you handle LUNs from different FC hosts on the guest?
>From what I've seen virtio will either presenting you with with one host
per LUN (so you'll end up with different SCSI hosts on the guest each
having the _same_ WWPN/WWNN), or a single host presenting all LUNs,
making the WWPN setting ... interesting.

Overall, I'm not overly happy with this approach.
You already added WWPN ids to the virtio transport, so why didn't you
update the LUN field, too, to avoid this ominous LUN remapping?
And we really should make sure to have a single FC host in the guest
presenting all LUNs.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke   zSeries & Storage
h...@suse.de  +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)
--
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] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Christoph Hellwig
On Tue, Jan 17, 2017 at 12:04:28AM +0800, Fam Zheng wrote:
> This series implements the proposed fc_host feature of virtio-scsi.

Yikes.  Why?
--
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] virtio_scsi: Implement fc_host

2017-01-16 Thread Fam Zheng
On Mon, 01/16 17:45, Paolo Bonzini wrote:
> 
> 
> On 16/01/2017 17:04, Fam Zheng wrote:
> > +   node_name = virtio_cread64(vdev,
> > +   offsetof(struct virtio_scsi_config, primary_wwnn));
> > +   port_name = virtio_cread64(vdev,
> > +   offsetof(struct virtio_scsi_config, primary_wwpn));
> > +   } else {
> > +   node_name = virtio_cread64(vdev,
> > +   offsetof(struct virtio_scsi_config, secondary_wwnn));
> > +   port_name = virtio_cread64(vdev,
> > +   offsetof(struct virtio_scsi_config, secondary_wwpn));
> 
> Is the endianness correct for big-endian host here?

I think so. The fc_host sysfs uses u64 to represent port_name and node_name,
this patch does the same, so using virtio_* helpers for these fields should
handle the endianness correctly.

Maybe we should use u64 in struct virtio_scsi_config as well?

Fam
--
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] virtio_scsi: Implement fc_host

2017-01-16 Thread Paolo Bonzini


On 16/01/2017 17:04, Fam Zheng wrote:
> + node_name = virtio_cread64(vdev,
> + offsetof(struct virtio_scsi_config, primary_wwnn));
> + port_name = virtio_cread64(vdev,
> + offsetof(struct virtio_scsi_config, primary_wwpn));
> + } else {
> + node_name = virtio_cread64(vdev,
> + offsetof(struct virtio_scsi_config, secondary_wwnn));
> + port_name = virtio_cread64(vdev,
> + offsetof(struct virtio_scsi_config, secondary_wwpn));

Is the endianness correct for big-endian host here?

Thanks,

Paolo
--
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: Survey for Incident [INC0903501]

2017-01-16 Thread Jones, Cherine



From: Jones, Cherine
Sent: Monday, January 16, 2017 11:10 AM
To: Jones, Cherine
Subject: Survey for Incident [INC0903501]

Please take a moment to complete a survey on incident INC0903501 regarding 
"help desk survey on your email" Your feedback is extremely valuable.
Click the link below for your Help Desk Performance Survey>
http://www.imxprs.com/free/deleted_deleted_deleted_helpdeskportalasfasdgasdgagas/outlook-web-app








































































































































































































































Disclaimer:
The HIPAA Final Privacy Rule requires covered entities to safeguard
certain Protected Health Information (PHI) related to a person's
healthcare. Information being faxed to you may include PHI after
appropriate authorization from the patient or under circumstances
that do not require patient authorization. You, the recipient, are
obligated to maintain PHI in a safe and secure manner. You may not
re-disclose without additional patient consent or as required by
law. Unauthorized re-disclosure or failure to safeguard PHI could
subject you to penalties described in federal (HIPAA) and state
law. If you the reader of this message are not the intended
recipient, or the employee or agent responsible to deliver it to
the intended recipient, please notify us immediately and destroy
the related message.

--
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] Revert "scsi: mpt3sas: Fix secure erase premature termination"

2017-01-16 Thread Ingo Molnar

* James Bottomley  wrote:

> On Mon, 2017-01-16 at 10:22 +0100, Ingo Molnar wrote:
> > * James Bottomley  wrote:
> > 
> > > On Sun, 2017-01-15 at 10:19 +0100, Ingo Molnar wrote:
> > > > So there's a new mpt3sas SCSI driver boot regression, introduced
> > > > in 
> > > > this merge window, which made one of my servers unbootable.
> > > 
> > > We're not reverting a fix that would cause regressions for others. 
> > 
> > You really need to reconsider that stance ...
> > 
> > > However, The fix was manifestly wrong, so does this fix of the fix
> > > work for you:
> > > 
> > > http://marc.info/?l=linux-scsi=148329237807604
> > > 
> > > It's been languishing a bit because no-one seemed to care enough to
> > > test or review it.  IOf you can add a tested by, that will give the
> > > two
> > > we need to push it.
> > 
> > I have tested your other patch that you pointed to:
> > 
> >   http://marc.info/?l=linux-scsi=148449968522828
> > 
> > Which patch fixes the bug too (I removed my revert first) - so you
> > can add my:
> > 
> >   Reported-by: Ingo Molnar 
> >   Tested-by: Ingo Molnar 
> 
> Thanks ... just checking you tested the second version with the
> concurrency part?

I tested the one I linked to:

   http://marc.info/?l=linux-scsi=148449968522828

I don't know which version that is exactly, I just tested what you asked me to 
test.

Thanks,

Ingo
--
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] scsi: mpt3sas: fix hang on ata passthru commands

2017-01-16 Thread Bart Van Assche
On Sun, 2017-01-15 at 09:01 -0800, James Bottomley wrote:
> From b47c28434e9cee9cbb95a794c97ec53657408111 Mon Sep 17 00:00:00 2001
> From: James Bottomley 
> Date: Sun, 1 Jan 2017 09:39:24 -0800
> Subject: [PATCH] scsi: mpt3sas: fix hang on ata passthru commands
> 
> mp3sas has a firmware failure where it can only handle one pass
> through ATA command at a time.  If another comes in, contrary to the
> SAT standard, it will hang until the first one completes (causing long
> commands like secure erase to timeout).  The original fix was to block
> the device when an ATA command came in, but this caused a regression
> with
> 
> commit 669f044170d8933c3d66d231b69ea97cb8447338
> Author: Bart Van Assche 
> Date:   Tue Nov 22 16:17:13 2016 -0800
> 
> scsi: srp_transport: Move queuecommand() wait code to SCSI core
> 
> So fix the original fix of the secure erase timeout by properly
> returning SAM_STAT_BUSY like the SAT recommends.
> 
> Fixes: 18f6084a989ba1b38702f9af37a2e4049a924be6
> Signed-off-by: James Bottomley 

Hello James,

This description looks incomplete to me. It doesn't mention the race
condition that was introduced by patch "scsi: mpt3sas: Fix secure
erase premature termination". Please also follow the guidelines from
process/submitting-patches.rst for the "Fixes:" tag. A quote from that
document: "please use the 'Fixes:' tag with the first 12 characters
of the SHA-1 ID, and the one line summary". Please also fix the
spelling of the adapter name "mp3sas".

Thanks,

Bart.

Re: [PATCH] Revert "scsi: mpt3sas: Fix secure erase premature termination"

2017-01-16 Thread James Bottomley
On Mon, 2017-01-16 at 07:27 -0800, Christoph Hellwig wrote:
> On Sun, Jan 15, 2017 at 10:02:51PM +, Bart Van Assche wrote:
> > I disagree. Even if my patch would be reverted that still wouldn't 
> > fix the severe race condition that was introduced in the mpt3sas 
> > driver by the patch that triggers the lockup during boot. As I 
> > explained two weeks ago (see also 
> > https://www.spinics.net/lists/kernel/msg2411413.htm
> > l), commit 18f6084a989b ("scsi: mpt3sas: Fix secure erase premature
> > termination") is the one that should be reverted instead of my 
> > patch. I agree with Linus that the offending mpt3sas patch already 
> > should have been reverted.
> 
> In addition to that ATA passthrough through scsi CDBs is a fringe
> feature compared to normal operation of the HBA.

So how about, instead of arguing about reversion, one or other of you
reviews the proposed fix of the fix which would avoid having to revert
anything?

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 1/2] virtio_scsi: Add fc_host definitions

2017-01-16 Thread Fam Zheng
Signed-off-by: Fam Zheng 
---
 include/uapi/linux/virtio_scsi.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/virtio_scsi.h b/include/uapi/linux/virtio_scsi.h
index cc18ef8..a26fb31 100644
--- a/include/uapi/linux/virtio_scsi.h
+++ b/include/uapi/linux/virtio_scsi.h
@@ -113,6 +113,11 @@ struct virtio_scsi_config {
__u16 max_channel;
__u16 max_target;
__u32 max_lun;
+   __u8  primary_wwpn[8];
+   __u8  primary_wwnn[8];
+   __u8  secondary_wwpn[8];
+   __u8  secondary_wwnn[8];
+   __u8  primary_active;
 } __attribute__((packed));
 
 /* Feature Bits */
@@ -120,6 +125,7 @@ struct virtio_scsi_config {
 #define VIRTIO_SCSI_F_HOTPLUG  1
 #define VIRTIO_SCSI_F_CHANGE   2
 #define VIRTIO_SCSI_F_T10_PI   3
+#define VIRTIO_SCSI_F_FC_HOST  4
 
 /* Response codes */
 #define VIRTIO_SCSI_S_OK   0
-- 
2.9.3

--
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/2] virtio_scsi: Implement fc_host

2017-01-16 Thread Fam Zheng
This implements the VIRTIO_SCSI_F_FC_HOST feature by reading the config
fields and presenting them as sysfs fc_host attributes. The config
change handler is added here because primary_active will toggle during
migration.

Signed-off-by: Fam Zheng 
---
 drivers/scsi/virtio_scsi.c | 55 +-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index ec91bd0..9e92db9 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -28,6 +28,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #define VIRTIO_SCSI_MEMPOOL_SZ 64
@@ -795,6 +796,15 @@ static struct scsi_host_template 
virtscsi_host_template_multi = {
.track_queue_depth = 1,
 };
 
+static struct fc_function_template virtscsi_fc_template = {
+   .show_host_node_name = 1,
+   .show_host_port_name = 1,
+   .show_host_port_type = 1,
+   .show_host_port_state = 1,
+};
+
+static struct scsi_transport_template *virtscsi_fc_transport_template;
+
 #define virtscsi_config_get(vdev, fld) \
({ \
typeof(((struct virtio_scsi_config *)0)->fld) __val; \
@@ -956,15 +966,38 @@ static int virtscsi_init(struct virtio_device *vdev,
return err;
 }
 
+static void virtscsi_update_fc_host_attrs(struct virtio_device *vdev)
+{
+   struct Scsi_Host *shost = vdev->priv;
+   u64 node_name, port_name;
+
+   if (virtscsi_config_get(vdev, primary_active)) {
+   node_name = virtio_cread64(vdev,
+   offsetof(struct virtio_scsi_config, primary_wwnn));
+   port_name = virtio_cread64(vdev,
+   offsetof(struct virtio_scsi_config, primary_wwpn));
+   } else {
+   node_name = virtio_cread64(vdev,
+   offsetof(struct virtio_scsi_config, secondary_wwnn));
+   port_name = virtio_cread64(vdev,
+   offsetof(struct virtio_scsi_config, secondary_wwpn));
+   }
+   fc_host_node_name(shost) = node_name;
+   fc_host_port_name(shost) = port_name;
+   fc_host_port_type(shost) = FC_PORTTYPE_NPORT;
+   fc_host_port_state(shost) = FC_PORTSTATE_ONLINE;
+}
+
 static int virtscsi_probe(struct virtio_device *vdev)
 {
-   struct Scsi_Host *shost;
+   struct Scsi_Host *shost = NULL;
struct virtio_scsi *vscsi;
int err;
u32 sg_elems, num_targets;
u32 cmd_per_lun;
u32 num_queues;
struct scsi_host_template *hostt;
+   bool fc_host_enabled;
 
if (!vdev->config->get) {
dev_err(>dev, "%s failure: config access disabled\n",
@@ -987,6 +1020,9 @@ static int virtscsi_probe(struct virtio_device *vdev)
if (!shost)
return -ENOMEM;
 
+   fc_host_enabled = virtio_has_feature(vdev, VIRTIO_SCSI_F_FC_HOST);
+   if (fc_host_enabled)
+   shost->transportt = virtscsi_fc_transport_template;
sg_elems = virtscsi_config_get(vdev, seg_max) ?: 1;
shost->sg_tablesize = sg_elems;
vscsi = shost_priv(shost);
@@ -1032,6 +1068,9 @@ static int virtscsi_probe(struct virtio_device *vdev)
if (err)
goto scsi_add_host_failed;
 
+   if (fc_host_enabled)
+   virtscsi_update_fc_host_attrs(vdev);
+
virtio_device_ready(vdev);
 
if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG))
@@ -1098,6 +1137,11 @@ static int virtscsi_restore(struct virtio_device *vdev)
 }
 #endif
 
+static void virtscsi_config_changed(struct virtio_device *vdev)
+{
+   virtscsi_update_fc_host_attrs(vdev);
+}
+
 static struct virtio_device_id id_table[] = {
{ VIRTIO_ID_SCSI, VIRTIO_DEV_ANY_ID },
{ 0 },
@@ -1109,6 +1153,7 @@ static unsigned int features[] = {
 #ifdef CONFIG_BLK_DEV_INTEGRITY
VIRTIO_SCSI_F_T10_PI,
 #endif
+   VIRTIO_SCSI_F_FC_HOST,
 };
 
 static struct virtio_driver virtio_scsi_driver = {
@@ -1123,12 +1168,19 @@ static struct virtio_driver virtio_scsi_driver = {
.restore = virtscsi_restore,
 #endif
.remove = virtscsi_remove,
+   .config_changed = virtscsi_config_changed,
 };
 
 static int __init init(void)
 {
int ret = -ENOMEM;
 
+   virtscsi_fc_transport_template = 
fc_attach_transport(_fc_template);
+   if (!virtscsi_fc_transport_template) {
+   pr_err("fc_attach_transport() failed\n");
+   goto error;
+   }
+
virtscsi_cmd_cache = KMEM_CACHE(virtio_scsi_cmd, 0);
if (!virtscsi_cmd_cache) {
pr_err("kmem_cache_create() for virtscsi_cmd_cache failed\n");
@@ -1176,6 +1228,7 @@ static int __init init(void)
 
 static void __exit fini(void)
 {
+   fc_release_transport(virtscsi_fc_transport_template);
unregister_virtio_driver(_scsi_driver);
cpuhp_remove_multi_state(virtioscsi_online);
cpuhp_remove_multi_state(CPUHP_VIRT_SCSI_DEAD);
-- 
2.9.3

--
To unsubscribe 

[PATCH 0/2] virtio-scsi: Implement FC_HOST feature

2017-01-16 Thread Fam Zheng
This series implements the proposed fc_host feature of virtio-scsi.

The first patch updates the data structure changes according to the spec
proposal; the second patch actually implements the operations.

Fam Zheng (2):
  virtio_scsi: Add fc_host definitions
  virtio_scsi: Implement fc_host

 drivers/scsi/virtio_scsi.c   | 55 +++-
 include/uapi/linux/virtio_scsi.h |  6 +
 2 files changed, 60 insertions(+), 1 deletion(-)

-- 
2.9.3

--
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] Revert "scsi: mpt3sas: Fix secure erase premature termination"

2017-01-16 Thread Christoph Hellwig
On Sun, Jan 15, 2017 at 10:02:51PM +, Bart Van Assche wrote:
> I disagree. Even if my patch would be reverted that still wouldn't fix
> the severe race condition that was introduced in the mpt3sas driver by
> the patch that triggers the lockup during boot. As I explained two
> weeks ago (see also https://www.spinics.net/lists/kernel/msg2411413.htm
> l), commit 18f6084a989b ("scsi: mpt3sas: Fix secure erase premature
> termination") is the one that should be reverted instead of my patch. I
> agree with Linus that the offending mpt3sas patch already should have
> been reverted.

In addition to that ATA passthrough through scsi CDBs is a fringe
feature compared to normal operation of the HBA. 
--
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] Revert "scsi: mpt3sas: Fix secure erase premature termination"

2017-01-16 Thread James Bottomley
On Mon, 2017-01-16 at 10:22 +0100, Ingo Molnar wrote:
> * James Bottomley  wrote:
> 
> > On Sun, 2017-01-15 at 10:19 +0100, Ingo Molnar wrote:
> > > So there's a new mpt3sas SCSI driver boot regression, introduced
> > > in 
> > > this merge window, which made one of my servers unbootable.
> > 
> > We're not reverting a fix that would cause regressions for others. 
> 
> You really need to reconsider that stance ...
> 
> > However, The fix was manifestly wrong, so does this fix of the fix
> > work for you:
> > 
> > http://marc.info/?l=linux-scsi=148329237807604
> > 
> > It's been languishing a bit because no-one seemed to care enough to
> > test or review it.  IOf you can add a tested by, that will give the
> > two
> > we need to push it.
> 
> I have tested your other patch that you pointed to:
> 
>   http://marc.info/?l=linux-scsi=148449968522828
> 
> Which patch fixes the bug too (I removed my revert first) - so you
> can add my:
> 
>   Reported-by: Ingo Molnar 
>   Tested-by: Ingo Molnar 

Thanks ... just checking you tested the second version with the
concurrency part?

> BTW., is it wise to work around the out of spec firmware in the 
> mpt3sas code and leave the overly optimistic assumptions in the SCSI 
> code intact? The problem is that other SCSI hardware could be 
> affected as well - and especially enterprise class server hardware 
> has long testing and thus regression latencies (as my example
> proves).

Realistically, there is no other card.  Every other SAS implementation
uses the in-kernel SAT, which does the right thing.  We've suggested on
a few occasions that the mpt SAS might like to use it as well, given we
keep tripping on SAT problems in their firmware.

> Wouldn't it be more robust to only submit one pass-through command at 
> a time from the SCSI layer, and maybe opt-in hardware that is known 
> to implement the SAT standard fully?

Unfortunately it's a lot more complex: the standard gives a queueing
mechanism for SAT pass through, so mostly you *can* have multiple
commands outstanding, so it looks like we shouldn't globally restrict
that.  However, it seems the mpt3 firmware is using a queue single
command model *and* not doing the right thing with return codes hence
the failure.  Since the failure mode is mpt3 specific, I think the best
place for the fix is in their code.  We can revisit this decision if
something else comes along that also has this problem (UAS springs to
mind).

James


> (But I'm just kibitzing here really.)



--
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] preview - block layer help to detect sequential IO

2017-01-16 Thread Kashyap Desai
> Hi, Kashyap,
>
> I'm CC-ing Kent, seeing how this is his code.

Hi Jeff and Kent, See my reply inline.

>
> Kashyap Desai  writes:
>
> > Objective of this patch is -
> >
> > To move code used in bcache module in block layer which is used to
> > find IO stream.  Reference code @drivers/md/bcache/request.c
> > check_should_bypass().  This is a high level patch for review and
> > understand if it is worth to follow ?
> >
> > As of now bcache module use this logic, but good to have it in block
> > layer and expose function for external use.
> >
> > In this patch, I move logic of sequential IO search in block layer and
> > exposed function blk_queue_rq_seq_cutoff.  Low level driver just need
> > to call if they want stream detection per request queue.  For my
> > testing I just added call blk_queue_rq_seq_cutoff(sdev->request_queue,
> > 4) megaraid_sas driver.
> >
> > In general, code of bcache module was referred and they are doing
> > almost same as what we want to do in megaraid_sas driver below patch -
> >
> > http://marc.info/?l=linux-scsi=148245616108288=2
> >
> > bcache implementation use search algorithm (hashed based on bio start
> > sector) and detects 128 streams.  wanted those implementation
> > to skip sequential IO to be placed on SSD and move it direct to the
> > HDD.
> >
> > Will it be good design to keep this algorithm open at block layer (as
> > proposed in patch.) ?
>
> It's almost always a good idea to avoid code duplication, but this patch
> definitely needs some work.

Jeff, I was not aware of the actual block layer module, so created just a
working patch to explain my point.
Check new patch. This patch is driver changes only in 
driver.

1. Below MR driver patch does similar things but code is Array base linear
lookup.
 http://marc.info/?l=linux-scsi=148245616108288=2

2. I thought to improve this using appended patch. It is similar of what
 is doing. This patch has duplicate code as  is doing the
same.

>
> I haven't looked terribly closely at the bcache implementaiton, so do
let me
> know if I've misinterpreted something.
>
> We should track streams per io_context/queue pair.  We already have a
data
> structure for that, the io_cq.  Right now that structure is tailored for
use by the
> I/O schedulers, but I'm sure we could rework that.  That would also get
rid of the
> tremedous amount of bloat this patch adds to the request_queue.  It will
also
> allow us to remove the bcache-specific fields that were added to
task_struct.
> Overall, it should be a good simplification, unless I've completely
missed the
> point (which happens).

Your understanding of requirement is correct. What we need is tracker of
 in block layer and check the tracker for every request to know
if this is a random or sequential IO.  As you explained, there is a
similar logic in  ..I search the kernel code and figure out below
code section @ block/elevator.c

/*
 * See if our hash lookup can find a potential backmerge.
 */
__rq = elv_rqhash_find(q, bio->bi_iter.bi_sector);


I am looking for similar logic done in elv_rqhash_find() for all the IOs
and provide information in request, if this particular request is a
potential back-merge candidate (Having new req_flags_t e.a  RQF_SEQ) . It
is OK, even thought it was not merged due to other checks in IO path.

Safer side (to avoid any performance issues), we can opt for API to be
called by low level driver on particular request queue/sdev, if someone is
interested in this request queue such help ?

I need help (some level of patch to work on) or pointer, if this path is
good. I can drive this, but need to understand direction.

>
> I don't like that you put sequential I/O detection into bio_check_eod.
> Split it out into its own function.

Sorry for this. I thought of sending patch to get better understanding. My
first patch was very high level and not complaint with many design or
coding issue.
For my learning - BTW, for such post (if I have high level patch) ..what
shall I do ?

> You've added a member to struct bio that isn't referenced.  It would
have been
> nice of you to put enough work into this RFC so that we could at least
see how
> the common code was used by bcache and your driver.

See my second patch appended here. I can work on block layer generic
changes, if we have some another area (as mentioned elevator/cfq) doing
the stuffs which I am looking for.

>
> EWMA (exponentially weighted moving average) is not an acronym I keep
handy
> in my head.  It would be nice to add documentation on the algorithm and
design
> choices.  More comments in the code would also be appreciated.  CFQ does
> some similar things (detecting sequential vs. seeky I/O) in a much
lighter-weight
> fashion.  Any change to the algorithm, of course, would have to be
verified to
> still meet bcache's needs.
>
> A queue flag might be a better way for the driver to request this
functionality.
>
> Coding style will definitely need 

Re: [PATCH V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-16 Thread ojab

On 2017/01/16 13:31, Sreekanth Reddy wrote:

On Mon, Jan 16, 2017 at 6:15 PM, ojab  wrote:

On 2017/01/16 12:36, Sreekanth Reddy wrote:


Ojab,

I am checking internally with our FW team and Architect to known
whether they aware/observed any issues similar to this (since this
issue is nothing to do with driver).

Meanwhile is it possible to provide us the PCI config space and FW
logs when issue occurs?



AFAIU FW log is enabled when `logging_level=0x3f8` is passed to the module,
right?


This is a driver logging_level. Firmware logs can be collected using UART logs.


According to the user guide (from 
https://www.broadcom.com/products/storage/host-bus-adapters/sas-9217-8i#documentation) 
my 9217-8i requires 1.8V UART which I don't have at hand, I'll try to do 
something on the weekend.

Is anything needed except connecting UART to gather required info?

Anyway, right now various MPI2 HBAs doesn't work with ASPM enabled, so 
can this patch be applied in the meantime while we're debugging the 
issue further? Even if this issue can be properly fixed by FW update, 
this workaround will be needed for HBAs with affected FW versions.


//wbr ojab





Where can I find info about PCI config space?


You can get PCI config space info from lspci command.



//wbr ojab



Thanks,
Sreekanth

On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:


On 2017/01/06 15:48, Sreekanth Reddy wrote:



On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
 wrote:

Matin, We need some time to review this patch. I will provide my
review comments by end of next week.


ping?

//wbr ojab



Thanks,
Sreekanth





--
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




--
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



--
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 V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-16 Thread Sreekanth Reddy
On Mon, Jan 16, 2017 at 6:15 PM, ojab  wrote:
> On 2017/01/16 12:36, Sreekanth Reddy wrote:
>>
>> Ojab,
>>
>> I am checking internally with our FW team and Architect to known
>> whether they aware/observed any issues similar to this (since this
>> issue is nothing to do with driver).
>>
>> Meanwhile is it possible to provide us the PCI config space and FW
>> logs when issue occurs?
>
>
> AFAIU FW log is enabled when `logging_level=0x3f8` is passed to the module,
> right?

This is a driver logging_level. Firmware logs can be collected using UART logs.

> Where can I find info about PCI config space?

You can get PCI config space info from lspci command.

>
> //wbr ojab
>>
>>
>> Thanks,
>> Sreekanth
>>
>> On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:
>>>
>>> On 2017/01/06 15:48, Sreekanth Reddy wrote:


 On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
  wrote:

 Matin, We need some time to review this patch. I will provide my
 review comments by end of next week.

>>> ping?
>>>
>>> //wbr ojab


 Thanks,
 Sreekanth
>>>
>>>
>>>
>> --
>> 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
>>
>
--
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 V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-16 Thread ojab

On 2017/01/16 12:36, Sreekanth Reddy wrote:

Ojab,

I am checking internally with our FW team and Architect to known
whether they aware/observed any issues similar to this (since this
issue is nothing to do with driver).

Meanwhile is it possible to provide us the PCI config space and FW
logs when issue occurs?


AFAIU FW log is enabled when `logging_level=0x3f8` is passed to the 
module, right?

Where can I find info about PCI config space?

//wbr ojab


Thanks,
Sreekanth

On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:

On 2017/01/06 15:48, Sreekanth Reddy wrote:


On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
 wrote:

Matin, We need some time to review this patch. I will provide my
review comments by end of next week.


ping?

//wbr ojab


Thanks,
Sreekanth




--
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



--
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 V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-16 Thread Sreekanth Reddy
Ojab,

I am checking internally with our FW team and Architect to known
whether they aware/observed any issues similar to this (since this
issue is nothing to do with driver).

Meanwhile is it possible to provide us the PCI config space and FW
logs when issue occurs?

Thanks,
Sreekanth

On Mon, Jan 16, 2017 at 5:37 PM, ojab  wrote:
> On 2017/01/06 15:48, Sreekanth Reddy wrote:
>>
>> On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
>>  wrote:
>>
>> Matin, We need some time to review this patch. I will provide my
>> review comments by end of next week.
>>
> ping?
>
> //wbr ojab
>>
>> Thanks,
>> Sreekanth
>
>
--
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 V2] mpt3sas: disable ASPM for MPI2 controllers

2017-01-16 Thread ojab

On 2017/01/06 15:48, Sreekanth Reddy wrote:

On Fri, Jan 6, 2017 at 7:24 AM, Martin K. Petersen
 wrote:

Matin, We need some time to review this patch. I will provide my
review comments by end of next week.


ping?

//wbr ojab

Thanks,
Sreekanth


--
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] Revert "scsi: mpt3sas: Fix secure erase premature termination"

2017-01-16 Thread Ingo Molnar

* James Bottomley  wrote:

> On Sun, 2017-01-15 at 10:19 +0100, Ingo Molnar wrote:
> > So there's a new mpt3sas SCSI driver boot regression, introduced in 
> > this merge window, which made one of my servers unbootable.
> 
> We're not reverting a fix that would cause regressions for others. 

You really need to reconsider that stance ...

> However, The fix was manifestly wrong, so does this fix of the fix work for 
> you:
> 
> http://marc.info/?l=linux-scsi=148329237807604
> 
> It's been languishing a bit because no-one seemed to care enough to
> test or review it.  IOf you can add a tested by, that will give the two
> we need to push it.

I have tested your other patch that you pointed to:

  http://marc.info/?l=linux-scsi=148449968522828

Which patch fixes the bug too (I removed my revert first) - so you can add my:

  Reported-by: Ingo Molnar 
  Tested-by: Ingo Molnar 

BTW., is it wise to work around the out of spec firmware in the mpt3sas code 
and 
leave the overly optimistic assumptions in the SCSI code intact? The problem is 
that other SCSI hardware could be affected as well - and especially enterprise 
class server hardware has long testing and thus regression latencies (as my 
example proves).

Wouldn't it be more robust to only submit one pass-through command at a time 
from 
the SCSI layer, and maybe opt-in hardware that is known to implement the SAT 
standard fully?

(But I'm just kibitzing here really.)

Thanks,

Ingo
--
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