Re: [PATCH 3/4] nvme: use blk_rq_payload_bytes

2017-01-18 Thread Sagi Grimberg



@@ -1014,9 +1013,9 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue 
*queue,
}



Christoph, a little above here we still look at blk_rq_bytes(),
shouldn't that look at blk_rq_payload_bytes() too?


The check is ok for now as it's just zero vs non-zero.  It's somewhat
broken for Write Zeroes, though.  I've fixed it in this series
which I need to submit:


http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/write-zeroes-take-2



I see, thanks for the clarification.
--
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 01/17] lpfc: Use new pci_alloc_irq_vectors() interface

2017-01-18 Thread James Smart


On 1/18/2017 8:54 AM, Christoph Hellwig wrote:

On Tue, Jan 17, 2017 at 05:20:44PM -0800, James Smart wrote:

Move to new pci_alloc_irq_vectors() interface for intx/msi/msix

Note: io channel paradigm remains, for now.

Not exactly a well written changelog.  I'd like to know why this is
better than my version here:

http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/lpfc-msix

It also seems to be missing the post_vectors setting for the
Flash Optimized Fabric interrupt, which may lead to an incorrect
vector assignment for all the queues.


well, my intent was to post what we've been testing for a while. Then we 
would look at your mods, the remaining blk-mq mods from Hannes, and 
re-evalute the io channel thing and see where we end up.   This patch 
was just an initial convert to new api change, with the real mods to 
queing and adapter configuration following in the initiator basemods 
patches (a..f). I know your mods did more than the simple api change.


thanks for the post_vectors pickup.

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


Re: [PATCH 04/17] lpfc: NVME Initiator: Base modifications Part C

2017-01-18 Thread James Smart



On 1/18/2017 3:03 AM, Johannes Thumshirn wrote:



+   /* maximum number of xris available for nvme buffers */
+   els_xri_cnt = lpfc_sli4_get_els_iocb_cnt(phba);
+   phba->sli4_hba.nvme_xri_max = phba->sli4_hba.max_cfg_param.max_xri -
+ els_xri_cnt;
+   phba->sli4_hba.nvme_xri_max -= phba->sli4_hba.scsi_xri_max;

nvme_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt;
nvme_xri_max -= phba->sli4_hba.scsi_xri_max;
phba->sli4_hba.nvme_xri_max = nvme_xri_max;

Low hanging anti line-break fruit.


ok - but I didn't think that a style change like this is a mandate.   As 
I'm addressing your other comments, I'll do so.




}
@@ -4273,13 +4489,13 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct 
lpfc_acqe_sli *acqe_sli)
sprintf(message, "Unqualified optics - Replace with "
"Avago optics for Warranty and Technical "

Is Avago still correct, or should it read Broadcom?


It's right - Avago.



@@ -4854,17 +5070,20 @@ static int
  lpfc_enable_pci_dev(struct lpfc_hba *phba)
  {
struct pci_dev *pdev;
+   int bars = 0;
  
  	/* Obtain PCI device reference */

if (!phba->pcidev)
goto out_error;
else
pdev = phba->pcidev;
+   /* Select PCI BARs */
+   bars = pci_select_bars(pdev, IORESOURCE_MEM);
/* Enable PCI device */
if (pci_enable_device_mem(pdev))
goto out_error;
/* Request PCI resource for the device */
-   if (pci_request_mem_regions(pdev, LPFC_DRIVER_NAME))
+   if (pci_request_selected_regions(pdev, bars, LPFC_DRIVER_NAME))
goto out_disable_device;
/* Set up device as PCI master and save state for EEH */
pci_set_master(pdev);
@@ -4881,7 +5100,7 @@ lpfc_enable_pci_dev(struct lpfc_hba *phba)
pci_disable_device(pdev);
  out_error:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
-   "1401 Failed to enable pci device\n");
+   "1401 Failed to enable pci device, bars:x%x\n", bars);
return -ENODEV;
  }

I don't get this change. pci_request_mem_regions does

pci_request_selected_regions(pdev,
pci_select_bars(pdev, IORESOURCE_MEM), name);

if you want to have the bars in the error log please do:
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
"1401 Failed to enable pci device, bars:x%x\n",
pci_select_regions(pdev, IORESOURCE_MEM));


I agree - this is weird.  I'll track why it was ever changed and address it.

Other comments are good. I'll address them.

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


Re: [PATCH 05/17] lpfc: NVME Initiator: Base modifications Part D

2017-01-18 Thread James Smart


On 1/18/2017 5:39 AM, Johannes Thumshirn wrote:
I know this might be annoying by now, but it's really hard to follow 
code that

is so much indented and lpfc really needs some love in the readability case.
Please don't misunderstand me, it has nothing to do with you and lpfc is not
the only driver that could need some refactoring. It's just I've spend a lot
of time looking at lpfc since I've started working in the storage area and
the code style is somewhat inconsistent with the reset of the kernel (as are
other SCSI drivers, I know). If you and Martin/James B. don't mind I'd even
volunteer to help you with cleaning it up a bit.


I agree with the idea but want to hold off a little while longer. first, 
I want the driver to stabilize after adding a second protocol. second, I 
want it to harden a bit.


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


Re: [PATCH 03/17] lpfc: NVME Initiator: Base modifications Part B

2017-01-18 Thread James Smart



On 1/18/2017 2:11 AM, Johannes Thumshirn wrote:

On Tue, Jan 17, 2017 at 05:20:46PM -0800, James Smart wrote:

NVME Initiator: Base modifications

This is part B of parts A..F.

Part B is limited to lpfc_attr.c: lpfc attribute modifications

*

Refer to Part A for a description of base modifications

Signed-off-by: Dick Kennedy 
Signed-off-by: James Smart 
---

[...]


+   len += snprintf(buf + len, PAGE_SIZE - len,
+   "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
+   "NVME LPORT lpfc",

Is it the lack of coffee or should it be
"NVME LPORT lpfc%d WWPN x%llx WWNN x%llx DID x%06x %s\n"

I think you're doing it to not hit the 80 chars limit, but then there are
way more offenders than that one, so...


The line split is certainly due to the 80 limit and have that issue a lot.

As for what the string name should be - I agree with you. something is 
confused.



+int
+lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t *lock)
+{
+   int cnt = 0;
+
+   spin_lock_irq(lock);
+   while (!list_empty(q)) {
+   spin_unlock_irq(lock);
+   msleep(20);
+   if (cnt++ > 250) {  /* 5 secs */
+   lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
+   "0466 %s %s\n",
+   "Outstanding IO when ",
+   "bringing Adapter offline\n");
+   return 0;
+   }
+   spin_lock_irq(lock);
+   }
+   spin_unlock_irq(lock);
+   return 1;
+}
+

Aren't you using lpc_emptyq_wait() in patches prior to that already? This
breaks git bisect. Pleas test-build (ideally + checkpatch and sparse/smatch)
each patch in the series individually.


I called out - in patch2 - that Patches 2 through 7, known as parts 
A..F, area really one big patch. They will not follow the git bisect 
rules.  I could have sent them in one huge patch, but chose to break 
them up. Unfortunately, the mods accumulated over time with lots of 
reworks - creating a base that was too intertwined to put into small 
functional patches without spending oodles of time to carve them up.   I 
hope you can bear with me on this set and review the 7 pieces as one big 
patch.


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


Re: [PATCH 02/17] lpfc: NVME Initiator: Base modifications Part A

2017-01-18 Thread James Smart



On 1/18/2017 1:50 AM, Johannes Thumshirn wrote:


@@ -4959,11 +4968,11 @@ lpfc_send_taskmgmt(struct lpfc_vport *vport, struct 
scsi_cmnd *cmnd,
int status;
  
  	rdata = lpfc_rport_data_from_scsi_device(cmnd->device);

-   if (!rdata || !rdata->pnode || !NLP_CHK_NODE_ACT(rdata->pnode))
-   return FAILED;

OK, I don't get this hunk. lpfc_rport_data_from_scsi_device() cannot return
NULL anymore?

I at least expected something like:

rdata = lpfc_rport_data_from_scsi_device(cmnd->device);
if (!rdata || !rdata->pnode)
return FAILED;

pnode = rdata->pnode;
if (!NLP_CHK_NODE_ACT(pnode)
return FAILED;


it can and the order of precedence for the if check allows for it. I 
don't see any difference in what you wrote vs what's there, other than 
pnode gets an assignment.



Agree with all your other comments and will address them.

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


Re: [PATCH 06/17] lpfc: NVME Initiator: Base modifications Part E

2017-01-18 Thread James Smart



On 1/17/2017 11:34 PM, Hannes Reinecke wrote:

Is this ever reset?
I don't see it here ...


the lpfc_sli4_hba_setup(), which resets the function and reinits, clears 
the flag.




[ .. ]

@@ -4380,9 +4469,12 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba)
   * configured.
   **/
  int
-lpfc_sli_hbq_count(void)
+lpfc_sli_hbq_count(struct lpfc_hba *phba)
  {
-   return ARRAY_SIZE(lpfc_hbq_defs);
+   int i;
+
+   i = ARRAY_SIZE(lpfc_hbq_defs);
+   return i;
  }
  
  /**

The point of this change being ...?


I don't know - will collapse it.

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


Re: [PATCH 04/17] lpfc: NVME Initiator: Base modifications Part C

2017-01-18 Thread James Smart



On 1/17/2017 11:17 PM, Hannes Reinecke wrote:



@@ -3315,16 +3421,121 @@ lpfc_sli4_xri_sgl_update(struct lpfc_hba *phba)

[ .. ]
Unsafe.
'nvme_xri_cnt' is updated under the lock, but not tested with the lock
held. Please fix.




Yep - will fix.

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


Re: [PATCH 02/17] lpfc: NVME Initiator: Base modifications Part A

2017-01-18 Thread James Smart



On 1/17/2017 11:07 PM, Hannes Reinecke wrote:



- * lpfc_sli4_post_scsi_sgl_list - Post blocks of scsi buffer sgls from a list
+ * lpfc_sli4_post_scsi_sgl_list - Psot blocks of scsi buffer sgls from a list
   * @phba: pointer to lpfc hba data structure.
   * @post_sblist: pointer to the scsi buffer list.
   *

Psot?



Repsot? The reverse of 'Psot'?


lol...



bdea?


Crud - caught a bunch of those but looks like a couple got through. 
Surprised checkpatch let them through. oh well.


anyway - will fix and repost (repsot?) what you mentioned.

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


Re: [PATCH 1/2] qed: Add support for hardware offloaded FCoE.

2017-01-18 Thread Arun Easi
This will be addressed in v2 of the series. The warning pops up when 
CONFIG_DCB is not set. Thanks.

Regards,
-Arun

On Tue, 17 Jan 2017, 6:35am, kbuild test robot wrote:

> Hi Arun,
> 
> [auto build test WARNING on net-next/master]
> [also build test WARNING on v4.10-rc4 next-20170117]
> [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/Dupuis-Chad/Add-QLogic-FastLinQ-FCoE-qedf-driver/20170117-052438
> config: i386-randconfig-c0-01172134 (attached as .config)
> compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=i386 
> 
> All warnings (new ones prefixed by >>):
> 
>In file included from drivers/net/ethernet/qlogic/qed/qed.h:49:0,
> from drivers/net/ethernet/qlogic/qed/qed_cxt.c:44:
> >> include/linux/qed/qed_if.h:428:37: warning: 'struct qed_dcbx_get' declared 
> >> inside parameter list
>  void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
> ^
> >> include/linux/qed/qed_if.h:428:37: warning: its scope is only this 
> >> definition or declaration, which is probably not what you want
> --
>In file included from drivers/net/ethernet/qlogic/qed/qed.h:49:0,
> from drivers/net/ethernet/qlogic/qed/qed_dcbx.c:41:
> >> include/linux/qed/qed_if.h:428:37: warning: 'struct qed_dcbx_get' declared 
> >> inside parameter list
>  void (*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
> ^
> >> include/linux/qed/qed_if.h:428:37: warning: its scope is only this 
> >> definition or declaration, which is probably not what you want
>drivers/net/ethernet/qlogic/qed/qed_dcbx.c: In function 'qed_dcbx_aen':
>drivers/net/ethernet/qlogic/qed/qed_dcbx.c:873:42: error: 'struct 
> qed_dcbx_info' has no member named 'get'
>   op->dcbx_aen(cookie, >p_dcbx_info->get, mib_type);
>  ^
>drivers/net/ethernet/qlogic/qed/qed_dcbx.c: In function 
> 'qed_dcbx_mib_update_event':
>drivers/net/ethernet/qlogic/qed/qed_dcbx.c:902:2: error: implicit 
> declaration of function 'qed_dcbx_get_params' 
> [-Werror=implicit-function-declaration]
>  qed_dcbx_get_params(p_hwfn, p_ptt, _hwfn->p_dcbx_info->get, type);
>  ^
>drivers/net/ethernet/qlogic/qed/qed_dcbx.c:902:57: error: 'struct 
> qed_dcbx_info' has no member named 'get'
>  qed_dcbx_get_params(p_hwfn, p_ptt, _hwfn->p_dcbx_info->get, type);
> ^
>cc1: some warnings being treated as errors
> 
> vim +428 include/linux/qed/qed_if.h
> 
>412u8  name[QED_DRV_VER_STR_SIZE];
>413};
>414
>415#define ILT_PAGE_SIZE_TCFC 0x8000 /* 32KB */
>416
>417struct qed_int_info {
>418struct msix_entry   *msix;
>419u8  msix_cnt;
>420
>421/* This should be updated by the protocol driver */
>422u8  used_cnt;
>423};
>424
>425struct qed_common_cb_ops {
>426void(*link_update)(void *dev,
>427   struct qed_link_output   *link);
>  > 428void(*dcbx_aen)(void *dev, struct qed_dcbx_get 
> *get, u32 mib_type);
>429};
>430
>431struct qed_selftest_ops {
>432/**
>433 * @brief selftest_interrupt - Perform interrupt test
>434 *
>435 * @param cdev
>436 *
> 
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
> 
--
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 v3 06/12] qla2xxx: Use d_id instead of s_id for more clarity.

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

2017-01-18 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|   7 +--
 drivers/scsi/qla2xxx/qla_gbl.h|  14 +++---
 drivers/scsi/qla2xxx/qla_gs.c |  32 ++--
 drivers/scsi/qla2xxx/qla_init.c   | 100 +++---
 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, 201 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..8b1c06d 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)
@@ -3225,6 +3225,7 @@ struct qla_qpair {
struct qla_hw_data *hw;
struct work_struct q_work;
struct list_head qp_list_elem; /* vha->qp_list */
+   struct scsi_qla_host *vha;
 };
 
 /* Place holder for FW buffer parameters */
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 *);

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

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

2017-01-18 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 v3 10/12] qla2xxx: Remove unused reverse_ini_mode.

2017-01-18 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 225d2bf..62cee7b 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -5855,8 +5855,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:
@@ -5871,16 +5869,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;
@@ -5895,9 +5888,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 v3 11/12] qla2xxx: Improve RSCN handling in driver

2017-01-18 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   | 150 
 drivers/scsi/qla2xxx/qla_isr.c|   6 +-
 drivers/scsi/qla2xxx/qla_mbx.c| 144 +++
 drivers/scsi/qla2xxx/qla_os.c |  48 
 drivers/scsi/qla2xxx/qla_target.c | 238 ++
 9 files changed, 533 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];
+
+

[PATCH v3 09/12] qla2xxx: Add Dual mode support in the driver

2017-01-18 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 e628107..2e9142d 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -1568,8 +1568,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;
@@ -3994,7 +3993,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 b5cfab0..225d2bf 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 v3 02/12] qla2xxx: Cleanup TMF code translation from qla_target.

2017-01-18 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 v3 00/12] qla2xxx: Feature updates for target.

2017-01-18 Thread Himanshu Madhani
Hi Bart,

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

Changes from v2 --> v3

o Cleaned up sparse warnings reported by you.

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.

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 |  306 -
 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| 1612 ++--
 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 |  232 ++--
 drivers/scsi/qla2xxx/qla_mr.c  |   48 +-
 drivers/scsi/qla2xxx/qla_os.c  |  330 +++--
 drivers/scsi/qla2xxx/qla_target.c  | 2392 +---
 drivers/scsi/qla2xxx/qla_target.h  |  252 +---
 drivers/scsi/qla2xxx/tcm_qla2xxx.c |  256 ++--
 drivers/scsi/qla2xxx/tcm_qla2xxx.h |4 +-
 18 files changed, 4325 insertions(+), 2551 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 v3 04/12] qla2xxx: Remove SRR code.

2017-01-18 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 v3 03/12] qla2xxx: Make trace flags more readable.

2017-01-18 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 v3 01/12] qla2xxx: Remove direct access of scsi_status field in se_cmd

2017-01-18 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


Re: [PATCH 2/2] scsi: storvsc: Add support for FC lightweight host.

2017-01-18 Thread Dan Carpenter
On Wed, Jan 18, 2017 at 03:28:58PM -0500, Cathy Avery wrote:
> Enable FC lightweight host option so that the luns exposed by
> the driver may be manually scanned.
> 
> Signed-off-by: Cathy Avery 
> ---
>  drivers/scsi/storvsc_drv.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 888e16e..fc1d6ba 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1882,6 +1882,7 @@ static struct hv_driver storvsc_drv = {
>  static struct fc_function_template fc_transport_functions = {
>   .show_host_node_name = 1,
>   .show_host_port_name = 1,
> + .lightweight_transport = 1,
>  };
>  #endif
>  
> @@ -1906,11 +1907,6 @@ static int __init storvsc_drv_init(void)
>   fc_transport_template = fc_attach_transport(_transport_functions);
>   if (!fc_transport_template)
>   return -ENODEV;
> -
> - /*
> -  * Install Hyper-V specific timeout handler.
> -  */
> - fc_transport_template->eh_timed_out = storvsc_eh_timed_out;

I don't undestand how removing this is related.

regards,
dan carpenter
--
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] scsi: storvsc: Add support for FC lightweight host.

2017-01-18 Thread Cathy Avery
Enable FC lightweight host option so that the luns exposed by
the driver may be manually scanned.

Signed-off-by: Cathy Avery 
---
 drivers/scsi/storvsc_drv.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 888e16e..fc1d6ba 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1882,6 +1882,7 @@ static struct hv_driver storvsc_drv = {
 static struct fc_function_template fc_transport_functions = {
.show_host_node_name = 1,
.show_host_port_name = 1,
+   .lightweight_transport = 1,
 };
 #endif
 
@@ -1906,11 +1907,6 @@ static int __init storvsc_drv_init(void)
fc_transport_template = fc_attach_transport(_transport_functions);
if (!fc_transport_template)
return -ENODEV;
-
-   /*
-* Install Hyper-V specific timeout handler.
-*/
-   fc_transport_template->eh_timed_out = storvsc_eh_timed_out;
 #endif
 
ret = vmbus_driver_register(_drv);
-- 
2.5.0

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


[PATCH 1/2] scsi: scsi_transport_fc: Provide a lightweight option for Virtual FC Hosts.

2017-01-18 Thread Cathy Avery
The patch provides a means to offer a lightweight option to the
current FC transport class. The new option is selected by a
driver when it indicates it wants the lightweight
transport via fc_function_template.

Signed-off-by: Cathy Avery 
---
 drivers/scsi/scsi_transport_fc.c | 125 +--
 include/scsi/scsi_transport_fc.h |   1 +
 2 files changed, 122 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 03577bd..4adc669 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -50,6 +50,15 @@ static int fc_bsg_hostadd(struct Scsi_Host *, struct 
fc_host_attrs *);
 static int fc_bsg_rportadd(struct Scsi_Host *, struct fc_rport *);
 static void fc_bsg_remove(struct request_queue *);
 static void fc_bsg_goose_queue(struct fc_rport *);
+static int fc_host_lw_setup(struct Scsi_Host *, struct fc_host_attrs *);
+static int fc_host_hw_setup(struct Scsi_Host *, struct fc_host_attrs *);
+static int fc_host_hw_remove(struct fc_host_attrs *);
+static struct scsi_transport_template *
+   fc_attach_lw_transport(struct fc_function_template *);
+static struct scsi_transport_template *
+   fc_attach_hw_transport(struct fc_function_template *);
+static void fc_remove_lw_host(struct Scsi_Host *);
+static void fc_remove_hw_host(struct Scsi_Host *, struct fc_host_attrs *);
 
 /*
  * Module Parameters
@@ -352,6 +361,10 @@ struct fc_internal {
 
 #define to_fc_internal(tmpl)   container_of(tmpl, struct fc_internal, t)
 
+
+static void fc_release_lw_transport(struct fc_internal *);
+static void fc_release_hw_transport(struct fc_internal *);
+
 static int fc_target_setup(struct transport_container *tc, struct device *dev,
   struct device *cdev)
 {
@@ -387,7 +400,26 @@ static int fc_host_setup(struct transport_container *tc, 
struct device *dev,
 {
struct Scsi_Host *shost = dev_to_shost(dev);
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
+   struct fc_internal *i = to_fc_internal(shost->transportt);
+
+   if (i->f->lightweight_transport)
+   return fc_host_lw_setup(shost, fc_host);
+
+   return fc_host_hw_setup(shost, fc_host);
+}
+
+static int fc_host_lw_setup(struct Scsi_Host *shost,
+   struct fc_host_attrs *fc_host)
+{
+   fc_host->node_name = -1;
+   fc_host->port_name = -1;
+
+   return 0;
+}
 
+static int fc_host_hw_setup(struct Scsi_Host *shost,
+   struct fc_host_attrs *fc_host)
+{
/*
 * Set default values easily detected by the midlayer as
 * failure cases.  The scsi lldd is responsible for initializing
@@ -468,7 +500,16 @@ static int fc_host_remove(struct transport_container *tc, 
struct device *dev,
 {
struct Scsi_Host *shost = dev_to_shost(dev);
struct fc_host_attrs *fc_host = shost_to_fc_host(shost);
+   struct fc_internal *i = to_fc_internal(shost->transportt);
+
+   if (i->f->lightweight_transport)
+   return 0;
 
+   return fc_host_hw_remove(fc_host);
+}
+
+static int fc_host_hw_remove(struct fc_host_attrs *fc_host)
+{
fc_bsg_remove(fc_host->rqst_q);
return 0;
 }
@@ -2175,6 +2216,49 @@ static int fc_it_nexus_response(struct Scsi_Host *shost, 
u64 nexus, int result)
 struct scsi_transport_template *
 fc_attach_transport(struct fc_function_template *ft)
 {
+   if (ft->lightweight_transport)
+   return fc_attach_lw_transport(ft);
+
+   return fc_attach_hw_transport(ft);
+}
+EXPORT_SYMBOL(fc_attach_transport);
+
+
+struct scsi_transport_template *
+fc_attach_lw_transport(struct fc_function_template *ft)
+{
+   int count;
+   struct fc_internal *i;
+
+   i = kzalloc(sizeof(struct fc_internal),
+   GFP_KERNEL);
+
+   if (unlikely(!i))
+   return NULL;
+
+   i->t.host_attrs.ac.attrs = >host_attrs[0];
+   i->t.host_attrs.ac.class = _host_class.class;
+   i->t.host_attrs.ac.match = fc_host_match;
+   i->t.host_size = sizeof(struct fc_host_attrs);
+   transport_container_register(>t.host_attrs);
+
+   i->f = ft;
+
+   count = 0;
+   SETUP_HOST_ATTRIBUTE_RD(node_name);
+   SETUP_HOST_ATTRIBUTE_RD(port_name);
+
+   BUG_ON(count > FC_HOST_NUM_ATTRS);
+
+   i->host_attrs[count] = NULL;
+
+   return >t;
+}
+
+
+struct scsi_transport_template *
+fc_attach_hw_transport(struct fc_function_template *ft)
+{
int count;
struct fc_internal *i = kzalloc(sizeof(struct fc_internal),
GFP_KERNEL);
@@ -2318,12 +2402,27 @@ fc_attach_transport(struct fc_function_template *ft)
 
return >t;
 }
-EXPORT_SYMBOL(fc_attach_transport);
 
 void fc_release_transport(struct scsi_transport_template *t)
 {
struct fc_internal *i = to_fc_internal(t);
 
+   if (i->f->lightweight_transport)
+   

[PATCH 0/2] scsi: Create a lightweight FC Transport option for Virtual FC Hosts.

2017-01-18 Thread Cathy Avery
Currently virtual FC hosts or lightweight hosts are not able to be
manually scanned  via sysfs due to the fact that they do not
contain the complete characteristic set associated with a normal FC host
( missing rports, vports, etc ) and are not consistent with the current FC
transport model.

Patch 1: The patch provides a lightweight option to the current FC 
transport class. The new option is selected by a driver when it 
indicates it wants the lightweight transport in fc_function_template.

Patch 2: storvsc elects using the new lightweight FC host option.

Cathy Avery (2):
  scsi: scsi_transport_fc: Provide a lightweight option for Virtual FC
Hosts.
  scsi: storvsc: Add support for FC lightweight host.

 drivers/scsi/scsi_transport_fc.c | 125 +--
 drivers/scsi/storvsc_drv.c   |   6 +-
 include/scsi/scsi_transport_fc.h |   1 +
 3 files changed, 123 insertions(+), 9 deletions(-)

-- 
2.5.0

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


Re: [PATCH v2] ata: xgene: Enable NCQ support for APM X-Gene SATA controller hardware v1.1

2017-01-18 Thread Tejun Heo
Hello,

On Tue, Jan 17, 2017 at 08:25:21PM +0530, Rameshwar Sahu wrote:
> Hi Tejun,
> 
> On Fri, Nov 18, 2016 at 3:15 PM, Rameshwar Prasad Sahu  wrote:
> > This patch enables NCQ support for APM X-Gene SATA controller hardware v1.1
> > that was broken with hardware v1.0. Second thing, here we should not assume
> > XGENE_AHCI_V2 always in case of having valid _CID in ACPI table. I need to
> > remove this assumption because V1_1 also has a valid _CID for backward
> > compatibly with v1.
> >
> > v2 changes:
> > 1. Changed patch description
> >
> > Signed-off-by: Rameshwar Prasad Sahu 

Hmm... I don't have the patch in my queue.  Can you please resend it?

Thanks.

-- 
tejun
--
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 01/17] lpfc: Use new pci_alloc_irq_vectors() interface

2017-01-18 Thread Christoph Hellwig
On Tue, Jan 17, 2017 at 05:20:44PM -0800, James Smart wrote:
> 
> Move to new pci_alloc_irq_vectors() interface for intx/msi/msix
> 
> Note: io channel paradigm remains, for now.

Not exactly a well written changelog.  I'd like to know why this is
better than my version here:

http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/lpfc-msix

It also seems to be missing the post_vectors setting for the
Flash Optimized Fabric interrupt, which may lead to an incorrect
vector assignment for all the queues.
--
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: [Open-FCoE] [PATCH 2/2] qedf: Add QLogic FastLinQ offload FCoE driver framework.

2017-01-18 Thread Hannes Reinecke
On 01/16/2017 08:53 PM, Dupuis, Chad wrote:
> From: "Dupuis, Chad" 
> 
> The QLogic FastLinQ Driver for FCoE (qedf) is the FCoE specific module for 
> 41000
> Series Converged Network Adapters by QLogic. This patch consists of following
> changes:
> 
> - MAINTAINERS Makefile and Kconfig changes for qedf
> - PCI driver registration
> - libfc/fcoe host level initialization
> - SCSI host template initialization and callbacks
> - Debugfs and log level infrastructure
> - Link handling
> - Firmware interface structures
> - QED core module initialization
> - Light L2 interface callbacks
> - I/O request initialization
> - Firmware I/O completion handling
> - Firmware ELS request/response handling
> - FIP request/response handled by the driver itself
> 
> Signed-off-by: Nilesh Javali 
> Signed-off-by: Manish Rangankar 
> Signed-off-by: Saurav Kashyap 
> Signed-off-by: Arun Easi 
> Signed-off-by: Chad Dupuis 

[ .. ]

> +/* Main thread to process skb's from light-L2 interface */
> +static int qedf_ll2_recv_thread(void *arg)
> +{
> + struct qedf_ctx *qedf = (struct qedf_ctx *)arg;
> + struct qedf_skb_work *work, *work_tmp;
> + unsigned long flags;
> +
> + set_user_nice(current, -20);
> + set_current_state(TASK_INTERRUPTIBLE);
> +
> + while (!kthread_should_stop()) {
> + schedule();
> + if (!list_empty(>ll2_skb_list)) {
> + list_for_each_entry_safe(work, work_tmp,
> + >ll2_skb_list, list) {
> + spin_lock_irqsave(>ll2_lock, flags);
> + list_del(>list);
> + spin_unlock_irqrestore(>ll2_lock, flags);
> + qedf_ll2_process_skb(qedf, work->skb);
> + kfree(work);
> + }
> + }
> + __set_current_state(TASK_INTERRUPTIBLE);
> + }
> +
> + __set_current_state(TASK_RUNNING);
> + return 0;
> +}
> +
Please: don't.

The RT folks are trying to get rid of kthreads altogether as it's a
nightmare to get it to work with cpu hotplugging.
Please convert to workqueues.

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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: [Open-FCoE] [PATCH 1/2] qed: Add support for hardware offloaded FCoE.

2017-01-18 Thread Hannes Reinecke
On 01/16/2017 08:53 PM, 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 
> ---

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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


[PATCH 6/7] scsi: hisi_sas: fix probe ordering problem

2017-01-18 Thread John Garry
From: Xiang Chen 

There is a potential probe issue in how we trigger the hw initialisation.
Although we use 1s timer to delay hw initialisation, there is still a
potential that sas_register_ha() is not be finished before we start
the PHY init from hw->hw_init().
To avoid this issue, initialise the hw after sas_register_ha() in the
same probe context.
Note: it is not necessary to use 1s timer now (modified v2 hw only).

Signed-off-by: Xiang Chen 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 8 
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 8 ++--
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index b2782ce..8601cec 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1552,10 +1552,6 @@ int hisi_sas_probe(struct platform_device *pdev,
 
hisi_sas_init_add(hisi_hba);
 
-   rc = hisi_hba->hw->hw_init(hisi_hba);
-   if (rc)
-   goto err_out_ha;
-
rc = scsi_add_host(shost, >dev);
if (rc)
goto err_out_ha;
@@ -1564,6 +1560,10 @@ int hisi_sas_probe(struct platform_device *pdev,
if (rc)
goto err_out_register_ha;
 
+   rc = hisi_hba->hw->hw_init(hisi_hba);
+   if (rc)
+   goto err_out_register_ha;
+
scsi_scan_host(shost);
 
return 0;
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 7519772..62655c7 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1090,9 +1090,8 @@ static void phy_hard_reset_v2_hw(struct hisi_hba 
*hisi_hba, int phy_no)
start_phy_v2_hw(hisi_hba, phy_no);
 }
 
-static void start_phys_v2_hw(unsigned long data)
+static void start_phys_v2_hw(struct hisi_hba *hisi_hba)
 {
-   struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
int i;
 
for (i = 0; i < hisi_hba->n_phy; i++)
@@ -1101,10 +1100,7 @@ static void start_phys_v2_hw(unsigned long data)
 
 static void phys_init_v2_hw(struct hisi_hba *hisi_hba)
 {
-   struct timer_list *timer = _hba->timer;
-
-   setup_timer(timer, start_phys_v2_hw, (unsigned long)hisi_hba);
-   mod_timer(timer, jiffies + HZ);
+   start_phys_v2_hw(hisi_hba);
 }
 
 static void sl_notify_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
-- 
1.9.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 7/7] scsi: hisi_sas: decrease running_req in hisi_sas_slot_task_free()

2017-01-18 Thread John Garry
From: Xiang Chen 

There is an issue that hisi_sas_dev.running_req is not
decremented properly for internal abort and TMF.

To resolve, only decrease running_req in hisi_sas_slot_task_free()

Signed-off-by: Xiang Chen 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_main.c  | 8 
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 --
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 8601cec..53637a9 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -71,6 +71,8 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 
struct sas_task *task,
 struct hisi_sas_slot *slot)
 {
struct device *dev = _hba->pdev->dev;
+   struct domain_device *device = task->dev;
+   struct hisi_sas_device *sas_dev = device->lldd_dev;
 
if (!slot->task)
return;
@@ -97,6 +99,8 @@ void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, 
struct sas_task *task,
slot->task = NULL;
slot->port = NULL;
hisi_sas_slot_index_free(hisi_hba, slot->idx);
+   if (sas_dev)
+   atomic64_dec(_dev->running_req);
/* slot memory is fully zeroed when it is reused */
 }
 EXPORT_SYMBOL_GPL(hisi_sas_slot_task_free);
@@ -141,8 +145,6 @@ static void hisi_sas_slot_abort(struct work_struct *work)
struct hisi_hba *hisi_hba = dev_to_hisi_hba(task->dev);
struct scsi_cmnd *cmnd = task->uldd_task;
struct hisi_sas_tmf_task tmf_task;
-   struct domain_device *device = task->dev;
-   struct hisi_sas_device *sas_dev = device->lldd_dev;
struct scsi_lun lun;
struct device *dev = _hba->pdev->dev;
int tag = abort_slot->idx;
@@ -165,8 +167,6 @@ static void hisi_sas_slot_abort(struct work_struct *work)
spin_unlock_irqrestore(_hba->lock, flags);
if (task->task_done)
task->task_done(task);
-   if (sas_dev)
-   atomic64_dec(_dev->running_req);
 }
 
 static int hisi_sas_task_prep(struct sas_task *task, struct hisi_hba *hisi_hba,
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 62655c7..de240d2 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -1827,8 +1827,6 @@ static void slot_err_v2_hw(struct hisi_hba *hisi_hba,
}
 
 out:
-   if (sas_dev)
-   atomic64_dec(_dev->running_req);
 
hisi_sas_slot_task_free(hisi_hba, task, slot);
sts = ts->stat;
-- 
1.9.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 0/7] hisi_sas: SATA IO workaround and other misc patches

2017-01-18 Thread John Garry
This patchset introduces some misc fixes and improvements.

Most signifigantly this patchset includes a workaround
for a SATA IO issue on v2 hw (hip06/7).

John Garry (2):
  scsi: hisi_sas: downgrade refclk message
  scsi: hisi_sas: downgrade internal abort exit print

Xiang Chen (5):
  scsi: hisi_sas: workaround v2 hw SATA IO timeout issue
  scsi: hisi_sas: modify some values of ITCT table
  scsi: hisi_sas: modify hard reset for directed-attached disk
  scsi: hisi_sas: fix probe ordering problem
  scsi: hisi_sas: decrease running_req in hisi_sas_slot_task_free()

 drivers/scsi/hisi_sas/hisi_sas_main.c  |  20 +++
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 106 +
 2 files changed, 103 insertions(+), 23 deletions(-)

-- 
1.9.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 5/7] scsi: hisi_sas: downgrade internal abort exit print

2017-01-18 Thread John Garry
Downgrade the exit print in hisi_sas_internal_task_abort()
to dbg level, as info is not required.

Signed-off-by: John Garry 
Reviewed-by: Xiang Chen 
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index eee7ae2..b2782ce 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1121,7 +1121,7 @@ static int hisi_sas_query_task(struct sas_task *task)
}
 
 exit:
-   dev_info(dev, "internal task abort: task to dev %016llx task=%p "
+   dev_dbg(dev, "internal task abort: task to dev %016llx task=%p "
"resp: 0x%x sts 0x%x\n",
SAS_ADDR(device->sas_addr),
task,
-- 
1.9.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 2/7] scsi: hisi_sas: modify some values of ITCT table

2017-01-18 Thread John Garry
From: Xiang Chen 

Set SMP connection timeout and continue AWT timer;
Clear ITCT table when dev gone.

Signed-off-by: Xiang Chen 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 6c787eb..452e329 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -334,6 +334,8 @@
 #define ITCT_HDR_MCR_MSK   (0xf << ITCT_HDR_MCR_OFF)
 #define ITCT_HDR_VLN_OFF   9
 #define ITCT_HDR_VLN_MSK   (0xf << ITCT_HDR_VLN_OFF)
+#define ITCT_HDR_SMP_TIMEOUT_OFF   16
+#define ITCT_HDR_AWT_CONTINUE_OFF  25
 #define ITCT_HDR_PORT_ID_OFF   28
 #define ITCT_HDR_PORT_ID_MSK   (0xf << ITCT_HDR_PORT_ID_OFF)
 /* qw2 */
@@ -696,6 +698,8 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
qw0 |= ((1 << ITCT_HDR_VALID_OFF) |
(device->linkrate << ITCT_HDR_MCR_OFF) |
(1 << ITCT_HDR_VLN_OFF) |
+   (0xfa << ITCT_HDR_SMP_TIMEOUT_OFF) |
+   (1 << ITCT_HDR_AWT_CONTINUE_OFF) |
(port->id << ITCT_HDR_PORT_ID_OFF));
itct->qw0 = cpu_to_le64(qw0);
 
@@ -705,7 +709,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
 
/* qw2 */
if (!dev_is_sata(device))
-   itct->qw2 = cpu_to_le64((500ULL << ITCT_HDR_INLT_OFF) |
+   itct->qw2 = cpu_to_le64((5000ULL << ITCT_HDR_INLT_OFF) |
(0x1ULL << ITCT_HDR_BITLT_OFF) |
(0x32ULL << ITCT_HDR_MCTLT_OFF) |
(0x1ULL << ITCT_HDR_RTOLT_OFF));
@@ -714,7 +718,7 @@ static void setup_itct_v2_hw(struct hisi_hba *hisi_hba,
 static void free_device_v2_hw(struct hisi_hba *hisi_hba,
  struct hisi_sas_device *sas_dev)
 {
-   u64 qw0, dev_id = sas_dev->device_id;
+   u64 dev_id = sas_dev->device_id;
struct device *dev = _hba->pdev->dev;
struct hisi_sas_itct *itct = _hba->itct[dev_id];
u32 reg_val = hisi_sas_read32(hisi_hba, ENT_INT_SRC3);
@@ -738,8 +742,7 @@ static void free_device_v2_hw(struct hisi_hba *hisi_hba,
dev_dbg(dev, "got clear ITCT done interrupt\n");
 
/* invalid the itct state*/
-   qw0 = cpu_to_le64(itct->qw0);
-   qw0 &= ~(1 << ITCT_HDR_VALID_OFF);
+   memset(itct, 0, sizeof(struct hisi_sas_itct));
hisi_sas_write32(hisi_hba, ENT_INT_SRC3,
 ENT_INT_SRC3_ITC_INT_MSK);
 
-- 
1.9.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 1/7] scsi: hisi_sas: workaround v2 hw SATA IO timeout issue

2017-01-18 Thread John Garry
From: Xiang Chen 

The v2 SAS controller needs more time to detect channel idle
and send setup link request than SATA disk does, so it is
difficult for SAS controller to setup an STP link. Therefore it
may cause some IO timeouts.

We need to periodically configure the SAS controller so it
doesn't receive STP setup requests from SATA disks for a while,
so IO can be sent during this period.

Signed-off-by: Xiang Chen 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 75 +-
 1 file changed, 74 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 69b0f06..6c787eb 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -215,6 +215,7 @@
 #define RX_IDAF_DWORD5 (PORT_BASE + 0xd8)
 #define RX_IDAF_DWORD6 (PORT_BASE + 0xdc)
 #define RXOP_CHECK_CFG_H   (PORT_BASE + 0xfc)
+#define CON_CONTROL(PORT_BASE + 0x118)
 #define DONE_RECEIVED_TIME (PORT_BASE + 0x11c)
 #define CHL_INT0   (PORT_BASE + 0x1b4)
 #define CHL_INT0_HOTPLUG_TOUT_OFF  0
@@ -526,6 +527,8 @@ enum {
 #define SATA_PROTOCOL_FPDMA0x8
 #define SATA_PROTOCOL_ATAPI0x10
 
+static void hisi_sas_link_timeout_disable_link(unsigned long data);
+
 static u32 hisi_sas_read32(struct hisi_hba *hisi_hba, u32 off)
 {
void __iomem *regs = hisi_hba->regs + off;
@@ -978,6 +981,50 @@ static void init_reg_v2_hw(struct hisi_hba *hisi_hba)
 upper_32_bits(hisi_hba->initial_fis_dma));
 }
 
+static void hisi_sas_link_timeout_enable_link(unsigned long data)
+{
+   struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
+   int i, reg_val;
+
+   for (i = 0; i < hisi_hba->n_phy; i++) {
+   reg_val = hisi_sas_phy_read32(hisi_hba, i, CON_CONTROL);
+   if (!(reg_val & BIT(0))) {
+   hisi_sas_phy_write32(hisi_hba, i,
+   CON_CONTROL, 0x7);
+   break;
+   }
+   }
+
+   hisi_hba->timer.function = hisi_sas_link_timeout_disable_link;
+   mod_timer(_hba->timer, jiffies + msecs_to_jiffies(900));
+}
+
+static void hisi_sas_link_timeout_disable_link(unsigned long data)
+{
+   struct hisi_hba *hisi_hba = (struct hisi_hba *)data;
+   int i, reg_val;
+
+   reg_val = hisi_sas_read32(hisi_hba, PHY_STATE);
+   for (i = 0; i < hisi_hba->n_phy && reg_val; i++) {
+   if (reg_val & BIT(i)) {
+   hisi_sas_phy_write32(hisi_hba, i,
+   CON_CONTROL, 0x6);
+   break;
+   }
+   }
+
+   hisi_hba->timer.function = hisi_sas_link_timeout_enable_link;
+   mod_timer(_hba->timer, jiffies + msecs_to_jiffies(100));
+}
+
+static void set_link_timer_quirk(struct hisi_hba *hisi_hba)
+{
+   hisi_hba->timer.data = (unsigned long)hisi_hba;
+   hisi_hba->timer.function = hisi_sas_link_timeout_disable_link;
+   hisi_hba->timer.expires = jiffies + msecs_to_jiffies(1000);
+   add_timer(_hba->timer);
+}
+
 static int hw_init_v2_hw(struct hisi_hba *hisi_hba)
 {
struct device *dev = _hba->pdev->dev;
@@ -2020,9 +2067,12 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba 
*hisi_hba)
if (phy->identify.device_type == SAS_END_DEVICE)
phy->identify.target_port_protocols =
SAS_PROTOCOL_SSP;
-   else if (phy->identify.device_type != SAS_PHY_UNUSED)
+   else if (phy->identify.device_type != SAS_PHY_UNUSED) {
phy->identify.target_port_protocols =
SAS_PROTOCOL_SMP;
+   if (!timer_pending(_hba->timer))
+   set_link_timer_quirk(hisi_hba);
+   }
queue_work(hisi_hba->wq, >phyup_ws);
 
 end:
@@ -2033,10 +2083,23 @@ static int phy_up_v2_hw(int phy_no, struct hisi_hba 
*hisi_hba)
return res;
 }
 
+static bool check_any_wideports_v2_hw(struct hisi_hba *hisi_hba)
+{
+   u32 port_state;
+
+   port_state = hisi_sas_read32(hisi_hba, PORT_STATE);
+   if (port_state & 0x1ff)
+   return true;
+
+   return false;
+}
+
 static int phy_down_v2_hw(int phy_no, struct hisi_hba *hisi_hba)
 {
int res = 0;
u32 phy_state, sl_ctrl, txid_auto;
+   struct hisi_sas_phy *phy = _hba->phy[phy_no];
+   struct hisi_sas_port *port = phy->port;
 
hisi_sas_phy_write32(hisi_hba, phy_no, PHYCTRL_NOT_RDY_MSK, 1);
 
@@ -2046,6 +2109,10 @@ static int phy_down_v2_hw(int phy_no, struct hisi_hba 
*hisi_hba)
sl_ctrl = hisi_sas_phy_read32(hisi_hba, phy_no, SL_CONTROL);
hisi_sas_phy_write32(hisi_hba, phy_no, SL_CONTROL,
 sl_ctrl & ~SL_CONTROL_CTA_MSK);
+  

[PATCH 4/7] scsi: hisi_sas: modify hard reset for directed-attached disk

2017-01-18 Thread John Garry
From: Xiang Chen 

Correctly set registers in v2 for root PHY hardreset for directly
attached disk.

Signed-off-by: Xiang Chen 
Signed-off-by: John Garry 
---
 drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c 
b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
index 452e329..7519772 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c
@@ -207,6 +207,8 @@
 #define TXID_AUTO  (PORT_BASE + 0xb8)
 #define TXID_AUTO_CT3_OFF  1
 #define TXID_AUTO_CT3_MSK  (0x1 << TXID_AUTO_CT3_OFF)
+#define TX_HARDRST_OFF  2
+#define TX_HARDRST_MSK  (0x1 << TX_HARDRST_OFF)
 #define RX_IDAF_DWORD0 (PORT_BASE + 0xc4)
 #define RX_IDAF_DWORD1 (PORT_BASE + 0xc8)
 #define RX_IDAF_DWORD2 (PORT_BASE + 0xcc)
@@ -1075,7 +1077,15 @@ static void stop_phy_v2_hw(struct hisi_hba *hisi_hba, 
int phy_no)
 
 static void phy_hard_reset_v2_hw(struct hisi_hba *hisi_hba, int phy_no)
 {
+   struct hisi_sas_phy *phy = _hba->phy[phy_no];
+   u32 txid_auto;
+
stop_phy_v2_hw(hisi_hba, phy_no);
+   if (phy->identify.device_type == SAS_END_DEVICE) {
+   txid_auto = hisi_sas_phy_read32(hisi_hba, phy_no, TXID_AUTO);
+   hisi_sas_phy_write32(hisi_hba, phy_no, TXID_AUTO,
+   txid_auto | TX_HARDRST_MSK);
+   }
msleep(100);
start_phy_v2_hw(hisi_hba, phy_no);
 }
-- 
1.9.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 3/7] scsi: hisi_sas: downgrade refclk message

2017-01-18 Thread John Garry
The message to inform that the controller has no refclk
is currently at warning level, which is unnecessary, so
downgrade to debug.

Signed-off-by: John Garry 
Reviewed-by: Xiang Chen 
---
 drivers/scsi/hisi_sas/hisi_sas_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c 
b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 22dba01..eee7ae2 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -1453,7 +1453,7 @@ static struct Scsi_Host *hisi_sas_shost_alloc(struct 
platform_device *pdev,
 
refclk = devm_clk_get(>dev, NULL);
if (IS_ERR(refclk))
-   dev_info(dev, "no ref clk property\n");
+   dev_dbg(dev, "no ref clk property\n");
else
hisi_hba->refclk_frequency_mhz = clk_get_rate(refclk) / 100;
 
-- 
1.9.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


Re: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 04:16 PM, Johannes Thumshirn wrote:
> On Wed, Jan 18, 2017 at 05:14:36PM +0200, Sagi Grimberg wrote:
>>
>>> Hannes just spotted this:
>>> static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
>>> const struct blk_mq_queue_data *bd)
>>> {
>>> [...]
>>>__nvme_submit_cmd(nvmeq, );
>>>nvme_process_cq(nvmeq);
>>>spin_unlock_irq(>q_lock);
>>>return BLK_MQ_RQ_QUEUE_OK;
>>> out_cleanup_iod:
>>>nvme_free_iod(dev, req);
>>> out_free_cmd:
>>>nvme_cleanup_cmd(req);
>>>return ret;
>>> }
>>>
>>> So we're draining the CQ on submit. This of cause makes polling for
>>> completions in the IRQ handler rather pointless as we already did in the
>>> submission path.
>>
>> I think you missed:
>> http://git.infradead.org/nvme.git/commit/49c91e3e09dc3c9dd1718df85112a8cce3ab7007
> 
> I indeed did, thanks.
> 
But it doesn't help.

We're still having to wait for the first interrupt, and if we're really
fast that's the only completion we have to process.

Try this:


diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index b4b32e6..e2dd9e2 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -623,6 +623,8 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
}
__nvme_submit_cmd(nvmeq, );
spin_unlock(>sq_lock);
+   disable_irq_nosync(nvmeq_irq(irq));
+   irq_poll_sched(>iop);
return BLK_MQ_RQ_QUEUE_OK;
 out_cleanup_iod:
nvme_free_iod(dev, req);

That should avoid the first interrupt, and with a bit of lock reduce the
number of interrupts _drastically_.

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Andrey Kuzmin
On Wed, Jan 18, 2017 at 5:40 PM, Sagi Grimberg  wrote:
>
>> Your report provided this stats with one-completion dominance for the
>> single-threaded case. Does it also hold if you run multiple fio
>> threads per core?
>
>
> It's useless to run more threads on that core, it's already fully
> utilized. That single threads is already posting a fair amount of
> submissions, so I don't see how adding more fio jobs can help in any
> way.

With a single thread, your completion processing/submission is
completely serialized. From my experience, it takes fio couple of
microsec to process completion and submit next request, and that'
(much) larger than your interrupt processing time.

Regards,
Andrey
--
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Johannes Thumshirn
On Wed, Jan 18, 2017 at 05:14:36PM +0200, Sagi Grimberg wrote:
> 
> >Hannes just spotted this:
> >static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
> > const struct blk_mq_queue_data *bd)
> >{
> >[...]
> >__nvme_submit_cmd(nvmeq, );
> >nvme_process_cq(nvmeq);
> >spin_unlock_irq(>q_lock);
> >return BLK_MQ_RQ_QUEUE_OK;
> >out_cleanup_iod:
> >nvme_free_iod(dev, req);
> >out_free_cmd:
> >nvme_cleanup_cmd(req);
> >return ret;
> >}
> >
> >So we're draining the CQ on submit. This of cause makes polling for
> >completions in the IRQ handler rather pointless as we already did in the
> >submission path.
> 
> I think you missed:
> http://git.infradead.org/nvme.git/commit/49c91e3e09dc3c9dd1718df85112a8cce3ab7007

I indeed did, thanks.

-- 
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Sagi Grimberg



Hannes just spotted this:
static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 const struct blk_mq_queue_data *bd)
{
[...]
__nvme_submit_cmd(nvmeq, );
nvme_process_cq(nvmeq);
spin_unlock_irq(>q_lock);
return BLK_MQ_RQ_QUEUE_OK;
out_cleanup_iod:
nvme_free_iod(dev, req);
out_free_cmd:
nvme_cleanup_cmd(req);
return ret;
}

So we're draining the CQ on submit. This of cause makes polling for
completions in the IRQ handler rather pointless as we already did in the
submission path.


I think you missed:
http://git.infradead.org/nvme.git/commit/49c91e3e09dc3c9dd1718df85112a8cce3ab7007
--
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Johannes Thumshirn
On Wed, Jan 18, 2017 at 04:27:24PM +0200, Sagi Grimberg wrote:
> 
> >So what you say is you saw a consomed == 1 [1] most of the time?
> >
> >[1] from 
> >http://git.infradead.org/nvme.git/commitdiff/eed5a9d925c59e43980047059fde29e3aa0b7836
> 
> Exactly. By processing 1 completion per interrupt it makes perfect sense
> why this performs poorly, it's not worth paying the soft-irq schedule
> for only a single completion.
> 
> What I'm curious is how consistent is this with different devices (wish
> I had some...)

Hannes just spotted this:
static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
 const struct blk_mq_queue_data *bd)
{
[...]
__nvme_submit_cmd(nvmeq, );
nvme_process_cq(nvmeq);
spin_unlock_irq(>q_lock);
return BLK_MQ_RQ_QUEUE_OK;
out_cleanup_iod:
nvme_free_iod(dev, req);
out_free_cmd:
nvme_cleanup_cmd(req);
return ret;
}

So we're draining the CQ on submit. This of cause makes polling for
completions in the IRQ handler rather pointless as we already did in the
submission path. 

-- 
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Sagi Grimberg



Your report provided this stats with one-completion dominance for the
single-threaded case. Does it also hold if you run multiple fio
threads per core?


It's useless to run more threads on that core, it's already fully
utilized. That single threads is already posting a fair amount of
submissions, so I don't see how adding more fio jobs can help in any
way.
--
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Andrey Kuzmin
On Wed, Jan 18, 2017 at 5:27 PM, Sagi Grimberg  wrote:
>
>> So what you say is you saw a consomed == 1 [1] most of the time?
>>
>> [1] from
>> http://git.infradead.org/nvme.git/commitdiff/eed5a9d925c59e43980047059fde29e3aa0b7836
>
>
> Exactly. By processing 1 completion per interrupt it makes perfect sense
> why this performs poorly, it's not worth paying the soft-irq schedule
> for only a single completion.

Your report provided this stats with one-completion dominance for the
single-threaded case. Does it also hold if you run multiple fio
threads per core?

Regards,
Andrey

>
> What I'm curious is how consistent is this with different devices (wish
> I had some...)
>
>
> ___
> Linux-nvme mailing list
> linux-n...@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-nvme
--
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Sagi Grimberg



So what you say is you saw a consomed == 1 [1] most of the time?

[1] from 
http://git.infradead.org/nvme.git/commitdiff/eed5a9d925c59e43980047059fde29e3aa0b7836


Exactly. By processing 1 completion per interrupt it makes perfect sense
why this performs poorly, it's not worth paying the soft-irq schedule
for only a single completion.

What I'm curious is how consistent is this with different devices (wish
I had some...)
--
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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Hannes Reinecke
On 01/17/2017 05:50 PM, Sagi Grimberg wrote:
> 
>> So it looks like we are super not efficient because most of the
>> times we catch 1
>> completion per interrupt and the whole point is that we need to find
>> more! This fio
>> is single threaded with QD=32 so I'd expect that we be somewhere in
>> 8-31 almost all
>> the time... I also tried QD=1024, histogram is still the same.
>>
>>
>> It looks like it takes you longer to submit an I/O than to service an
>> interrupt,
> 
> Well, with irq-poll we do practically nothing in the interrupt handler,
> only schedule irq-poll. Note that the latency measures are only from
> the point the interrupt arrives and the point we actually service it
> by polling for completions.
> 
>> so increasing queue depth in the singe-threaded case doesn't
>> make much difference. You might want to try multiple threads per core
>> with QD, say, 32
> 
> This is how I ran, QD=32.

The one thing which I found _really_ curious is this:

  IO depths: 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=0.1%,
>=64=100.0%
 submit: 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%,
>=64=0.0%
 complete  : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%,
>=64=0.1%
 issued: total=r=7673377/w=0/d=0, short=r=0/w=0/d=0,
drop=r=0/w=0/d=0
 latency   : target=0, window=0, percentile=100.00%, depth=256

(note the lines starting with 'submit' and 'complete').
They are _always_ 4, irrespective of the hardware and/or tests which I
run. Jens, what are these numbers supposed to mean?
Is this intended?
ATM the information content from those two lines is essentially 0,
seeing that the never change irrespective of the tests I'm doing.
(And which fio version I'm using ...)

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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: [LSF/MM TOPIC][LSF/MM ATTEND] NAPI polling for block drivers

2017-01-18 Thread Johannes Thumshirn
On Tue, Jan 17, 2017 at 06:38:43PM +0200, Sagi Grimberg wrote:
> 
> >Just for the record, all tests you've run are with the upper irq_poll_budget 
> >of
> >256 [1]?
> 
> Yes, but that's the point, I never ever reach this budget because
> I'm only processing 1-2 completions per interrupt.
> 
> >We (Hannes and me) recently stumbed accross this when trying to poll for more
> >than 256 queue entries in the drivers we've been testing.

s/stumbed/stumbled/

> 
> What do you mean by stumbed? irq-poll should be agnostic to the fact
> that drivers can poll more than their given budget?

So what you say is you saw a consomed == 1 [1] most of the time?

[1] from 
http://git.infradead.org/nvme.git/commitdiff/eed5a9d925c59e43980047059fde29e3aa0b7836

-- 
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: [PATCH 05/17] lpfc: NVME Initiator: Base modifications Part D

2017-01-18 Thread Johannes Thumshirn
On Tue, Jan 17, 2017 at 05:20:48PM -0800, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part D of parts A..F.
> 
> Part D is the 2nd half of the mods to lpfc_init.c. This is the location
> of most of changes for the following:
> - sli3 ring vs sli4 wq splits
> - buffer pools are allocated/freed
> - sgl pools allocated/freed
> - adapter resources split up
> - queue config decided and enacted
> - receive buffer management
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_init.c | 1088 
> +++--
>  1 file changed, 616 insertions(+), 472 deletions(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index ca54beb..ea12eca 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -7876,14 +7876,14 @@ lpfc_sli4_queue_create(struct lpfc_hba *phba)
>  void
>  lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
>  {
> - int idx;
> + int idx, numwq;
>  
>   if (phba->cfg_fof)
>   lpfc_fof_queue_destroy(phba);
>  
>   if (phba->sli4_hba.hba_eq != NULL) {
>   /* Release HBA event queue */
> - for (idx = 0; idx < phba->cfg_fcp_io_channel; idx++) {
> + for (idx = 0; idx < phba->io_channel; idx++) {
>   if (phba->sli4_hba.hba_eq[idx] != NULL) {
>   lpfc_sli4_queue_free(
>   phba->sli4_hba.hba_eq[idx]);
> @@ -7907,9 +7907,22 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
>   phba->sli4_hba.fcp_cq = NULL;
>   }
>  
> + if (phba->sli4_hba.nvme_cq != NULL) {
> + /* Release NVME completion queue */
> + for (idx = 0; idx < phba->cfg_nvme_io_channel; idx++) {
> + if (phba->sli4_hba.nvme_cq[idx] != NULL) {
> + lpfc_sli4_queue_free(
> + phba->sli4_hba.nvme_cq[idx]);
> + phba->sli4_hba.nvme_cq[idx] = NULL;
> + }
> + }
> + kfree(phba->sli4_hba.nvme_cq);
> + phba->sli4_hba.nvme_cq = NULL;
> + }
> +


static inline void lpfc_sli4_release_nvme_cqs(struct lpfc_hba *phba)
{
int i;

for (i = 0; i  < phba->cfg_nvme_io_channel; i++) {
if (phba->sli4_hba.nvme_cq[idx] != NULL) {
lpfc_sli4_queue_free(phba->sli4_hba.nvme_cq[idx]);
phba->sli4_hba.nvme_cq[idx] = NULL;
}
kfree(phba->sli4_hba.nvme_cq);
phba->sli4_hba.nvme_cq = NULL;
}
}

And then:

if (phba->sli4_hba.nvme_cq)
lpfc_sli4_release_nvme_cqs(phba);

I know this might be annoying by now, but it's really hard to follow code that
is so much indented and lpfc really needs some love in the readability case.
Please don't misunderstand me, it has nothing to do with you and lpfc is not
the only driver that could need some refactoring. It's just I've spend a lot
of time looking at lpfc since I've started working in the storage area and
the code style is somewhat inconsistent with the reset of the kernel (as are
other SCSI drivers, I know). If you and Martin/James B. don't mind I'd even
volunteer to help you with cleaning it up a bit.

[...]

> @@ -7920,12 +7933,32 @@ lpfc_sli4_queue_destroy(struct lpfc_hba *phba)
>   phba->sli4_hba.fcp_wq = NULL;
>   }
>  
> + if (phba->sli4_hba.nvme_wq != NULL) {
> + /* Release NVME work queue */
> + numwq = phba->cfg_nvme_max_hw_queue;
> + for (idx = 0; idx < numwq; idx++) {
> + if (phba->sli4_hba.nvme_wq[idx] != NULL) {
> + lpfc_sli4_queue_free(
> + phba->sli4_hba.nvme_wq[idx]);
> + phba->sli4_hba.nvme_wq[idx] = NULL;
> + }
> + }
> + kfree(phba->sli4_hba.nvme_wq);
> + phba->sli4_hba.nvme_wq = NULL;
> + }
> +

Same goes for the WQs here.

[...]

> + nvme_cqidx = 0;
> + nvme_wqidx = 0;
> + if (phba->cfg_nvme_io_channel) {
> + /* Set up fast-path NVME Response Complete Queue */
> + if (!phba->sli4_hba.nvme_cq) {

Hint, if you write a comment what the specific code block is doing, you might
actually write a function. Here sth. like 'lpfc_nvme_setup_fast_path_cq()'
comes to my mind. Especially if you have to use more than 3 levels of
indentation and the block is more then 75-100 LoC. It is most likely getting
inlined by the compiler anyways.

[...]

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 

Re: [PATCH 04/17] lpfc: NVME Initiator: Base modifications Part C

2017-01-18 Thread Johannes Thumshirn
On Tue, Jan 17, 2017 at 05:20:47PM -0800, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part C of parts A..F.
> 
> Part C is the 1st half of the mods to lpfc_init.c. This is the location
> of most of changes for the following:
> - sli3 ring vs sli4 wq splits
> - buffer pools are allocated/freed
> - sgl pools allocated/freed
> - adapter resources split up
> - queue config decided and enacted
> - receive buffer management
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---

[...]

> @@ -925,32 +926,43 @@ static void
>  lpfc_hba_clean_txcmplq(struct lpfc_hba *phba)
>  {
>   struct lpfc_sli *psli = >sli;
> + struct lpfc_queue *qp = NULL;
>   struct lpfc_sli_ring *pring;
>   LIST_HEAD(completions);
>   int i;
>  
> - for (i = 0; i < psli->num_rings; i++) {
> - pring = >ring[i];
> - if (phba->sli_rev >= LPFC_SLI_REV4)
> - spin_lock_irq(>ring_lock);
> - else
> + if (phba->sli_rev != LPFC_SLI_REV4) {
> + for (i = 0; i < psli->num_rings; i++) {
> + pring = >sli3_ring[i];
>   spin_lock_irq(>hbalock);
> - /* At this point in time the HBA is either reset or DOA. Either
> -  * way, nothing should be on txcmplq as it will NEVER complete.
> -  */
> - list_splice_init(>txcmplq, );
> - pring->txcmplq_cnt = 0;
> -
> - if (phba->sli_rev >= LPFC_SLI_REV4)
> - spin_unlock_irq(>ring_lock);
> - else
> + /* At this point in time the HBA is either reset or DOA
> +  * Nothing should be on txcmplq as it will
> +  * NEVER complete.
> +  */
> + list_splice_init(>txcmplq, );
> + pring->txcmplq_cnt = 0;
>   spin_unlock_irq(>hbalock);
>  
> + lpfc_sli_abort_iocb_ring(phba, pring);
> + }

>   /* Cancel all the IOCBs from the completions list */
> - lpfc_sli_cancel_iocbs(phba, , IOSTAT_LOCAL_REJECT,
> -   IOERR_SLI_ABORTED);
> + lpfc_sli_cancel_iocbs(phba, ,
> +   IOSTAT_LOCAL_REJECT, IOERR_SLI_ABORTED);
> + return;
> + }

And another great opportunity to factor a block into a helper function.

[...]

>  /**
> + * lpfc_sli4_nvme_sgl_update - update xri-sgl sizing and mapping
> + * @phba: pointer to lpfc hba data structure.
> + *
> + * This routine first calculates the sizes of the current els and allocated
> + * scsi sgl lists, and then goes through all sgls to updates the physical
> + * XRIs assigned due to port function reset. During port initialization, the
> + * current els and allocated scsi sgl lists are 0s.
> + *
> + * Return codes
> + *   0 - successful (for now, it always returns 0)
> + **/
> +int
> +lpfc_sli4_nvme_sgl_update(struct lpfc_hba *phba)
> +{
> + struct lpfc_nvme_buf *lpfc_ncmd = NULL, *lpfc_ncmd_next = NULL;
> + uint16_t i, lxri, els_xri_cnt;
> + uint16_t nvme_xri_cnt;
> + LIST_HEAD(nvme_sgl_list);
> + int rc;
> +
> + phba->total_nvme_bufs = 0;
> +
> + if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME))
> + return 0;
> + /*
> +  * update on pci function's allocated nvme xri-sgl list
> +  */
> +
> + /* maximum number of xris available for nvme buffers */
> + els_xri_cnt = lpfc_sli4_get_els_iocb_cnt(phba);
> + phba->sli4_hba.nvme_xri_max = phba->sli4_hba.max_cfg_param.max_xri -
> +   els_xri_cnt;
> + phba->sli4_hba.nvme_xri_max -= phba->sli4_hba.scsi_xri_max;

nvme_xri_max = phba->sli4_hba.max_cfg_param.max_xri - els_xri_cnt;
nvme_xri_max -= phba->sli4_hba.scsi_xri_max;
phba->sli4_hba.nvme_xri_max = nvme_xri_max; 

Low hanging anti line-break fruit.

[...]

> @@ -4240,9 +4456,9 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct 
> lpfc_acqe_sli *acqe_sli)
>   break;
>   default:
>   lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
> - "3296 "
> - "LPFC_SLI_EVENT_TYPE_MISCONFIGURED "
> - "event: Invalid link %d",
> + "3296 LPFC_SLI_EVENT_TYPE_"
> + "MISCONFIGURED  event: "
> + "Invalid link %d\n",
>   phba->sli4_hba.lnk_info.lnk_no);
>   return;
>   }
> @@ -4273,13 +4489,13 @@ lpfc_sli4_async_sli_evt(struct lpfc_hba *phba, struct 
> lpfc_acqe_sli *acqe_sli)
>   

Re: [PATCH 03/17] lpfc: NVME Initiator: Base modifications Part B

2017-01-18 Thread Johannes Thumshirn
On Tue, Jan 17, 2017 at 05:20:46PM -0800, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part B of parts A..F.
> 
> Part B is limited to lpfc_attr.c: lpfc attribute modifications
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---

[...]

> + len += snprintf(buf + len, PAGE_SIZE - len,
> + "%s%d WWPN x%llx WWNN x%llx DID x%06x %s\n",
> + "NVME LPORT lpfc",

Is it the lack of coffee or should it be 
"NVME LPORT lpfc%d WWPN x%llx WWNN x%llx DID x%06x %s\n"

I think you're doing it to not hit the 80 chars limit, but then there are
way more offenders than that one, so...


> + phba->brd_no,
> + wwn_to_u64(vport->fc_portname.u.wwn),
> + wwn_to_u64(vport->fc_nodename.u.wwn),
> + localport->port_id, statep);

[...]

> +int
> +lpfc_emptyq_wait(struct lpfc_hba *phba, struct list_head *q, spinlock_t 
> *lock)
> +{
> + int cnt = 0;
> +
> + spin_lock_irq(lock);
> + while (!list_empty(q)) {
> + spin_unlock_irq(lock);
> + msleep(20);
> + if (cnt++ > 250) {  /* 5 secs */
> + lpfc_printf_log(phba, KERN_WARNING, LOG_INIT,
> + "0466 %s %s\n",
> + "Outstanding IO when ",
> + "bringing Adapter offline\n");
> + return 0;
> + }
> + spin_lock_irq(lock);
> + }
> + spin_unlock_irq(lock);
> + return 1;
> +}
> +

Aren't you using lpc_emptyq_wait() in patches prior to that already? This
breaks git bisect. Pleas test-build (ideally + checkpatch and sparse/smatch)
each patch in the series individually.

[...]

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


Geschäftsvorschlag

2017-01-18 Thread tester
Lieber Freund.

Erlauben Sie mir, auf diese Weise auf Sie zuzugehen. Ich bin Dr. Arnold 
Kristofferson, ein US-Auftragnehmer, der mit Nichtkämpfer US Marine in 
Ba'qubah, Irak arbeitet. Ich habe die Summe von 10,6 Millionen Dollar, die ich 
aus einem Rohöl-Deal gemacht habe, und ich möchte, dass Sie mir helfen, es zu 
erhalten. Da ich hier auf offizieller Kapazität arbeite, kann ich diesen Fonds 
nicht bei mir behalten und dies ist mein einziger Grund für die Kontaktaufnahme 
mit Ihnen. Wenn Sie interessiert sind und Sie diesen Fonds in Ihrer Kapazität 
erhalten können, melden Sie sich bitte bei mir, damit ich Ihnen weitere Details 
geben kann, wie Sie dieses Geld für mich erhalten können. Bitte erreichen Sie 
mich per E-Mail: arnoldkristoferson...@gmail.com
Mit freundlichen Grüßen.

--
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 07/17] lpfc: NVME Initiator: Base modifications Part F

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part F of parts A..F.
> 
> Part F is limited to lpfc_debugfs.[ch]. It contains the modifications in
> the existing debugfs snippets to work with the base modifications.
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_debugfs.c | 535 
> +--
>  drivers/scsi/lpfc/lpfc_debugfs.h |  69 ++---
>  2 files changed, 324 insertions(+), 280 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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 02/17] lpfc: NVME Initiator: Base modifications Part A

2017-01-18 Thread Johannes Thumshirn
Hi James,

On Tue, Jan 17, 2017 at 05:20:45PM -0800, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part A of parts A..F.
> 
> Part A is the bulk of the file list changed by the modifications as
> most mods are small-ish. Changes may be for any aspect below.
> 
> *
> 
> This set of patches (6 parts) adds base modifications for NVME initiator
> support to the lpfc driver.
> 
> The base modifications consist of:
> - Formal split of SLI3 rings from SLI-4 WQs (sometimes referred to as
>   rings as well) as implementation now widely varies between the two.
> - Addition of configuration modes:
>SCSI initiator only; NVME initiator only; NVME target only; and
>SCSI and NVME initiator.
>The configuration mode drives overall adapter configuration,
>offloads enabled, and resource splits.
>NVME support is only available on SLI-4 devices and newer fw.
> - Implements the following based on configuration mode:
>   - Exchange resources are split by protocol; Obviously, if only
>  1 mode, then no split occurs. Default is 50/50. module attribute
>  allows tuning.
>   - Each protocol has it's own set of queues, but share interrupt
> vectors.
>  SCSI:
>SLI3 devices have few queues and the original style of queue
>  allocation remains.
>SLI4 devices piggy back on an "io-channel" concept that
>  eventually needs to merge with scsi-mq/blk-mq support (it is
>underway).  For now, the paradigm continues as it existed
>prior. io channel allocates N msix and N WQs (N=4 default)
>and either round robins or uses cpu # modulo N for scheduling.
>A bunch of module parameters allow the configuration to be
>tuned.
>  NVME (initiator):
>Allocates an msix per cpu (or whatever pci_alloc_irq_vectors
>  gets)
>Allocates a WQ per cpu, and maps the WQs to msix on a WQ #
>  modulo msix vector count basis.
>Module parameters exist to cap/control the config if desired.
>   - Each protocol has its own buffer and dma pools.
> 
> Unfortunately, it was very difficult to break out the above into
> functional patches. A such, they are presented as a 6-patch set to
> keep email size reasonable. All patches in the set must be applied to
> create a functional unit.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---

[...]

> @@ -2704,7 +2710,7 @@ static int lpfcdiag_loop_get_xri(struct lpfc_hba *phba, 
> uint16_t rpi,
>   * @phba: Pointer to HBA context object
>   *
>   * This function allocates BSG_MBOX_SIZE (4KB) page size dma buffer and.
> - * returns the pointer to the buffer.
> + * retruns the pointer to the buffer.

This hunk introduces a spelling error.

>   **/
>  static struct lpfc_dmabuf *
>  lpfc_bsg_dma_page_alloc(struct lpfc_hba *phba)
> @@ -2876,7 +2882,7 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba 
> *phba, uint16_t rxxri,
>size_t len)
>  {
>   struct lpfc_sli *psli = >sli;
> - struct lpfc_sli_ring *pring = >ring[LPFC_ELS_RING];
> + struct lpfc_sli_ring *pring;
>   struct lpfc_iocbq *cmdiocbq;
>   IOCB_t *cmd = NULL;
>   struct list_head head, *curr, *next;
> @@ -2890,6 +2896,11 @@ static int lpfcdiag_loop_post_rxbufs(struct lpfc_hba 
> *phba, uint16_t rxxri,
>   int iocb_stat;
>   int i = 0;
>  
> + if (phba->sli_rev == LPFC_SLI_REV4)
> + pring = phba->sli4_hba.els_wq->pring;
> + else
> + pring = >sli3_ring[LPFC_ELS_RING];
> +
>   cmdiocbq = lpfc_sli_get_iocbq(phba);
>   rxbmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
>   if (rxbmp != NULL) {
> @@ -5258,7 +5269,7 @@ static int
>  lpfc_forced_link_speed(struct bsg_job *job)
>  {
>   struct Scsi_Host *shost = fc_bsg_to_shost(job);
> - struct lpfc_vport *vport = shost_priv(shost);
> + struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;

Please don't. A) it's unnecessary to cast a void* and b) shost_priv() just
returns shost->hostdata (casted to void*). So all's fine.

[...]

> diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h
> index 361f5b3..1d07a5f 100644
> --- a/drivers/scsi/lpfc/lpfc_disc.h
> +++ b/drivers/scsi/lpfc/lpfc_disc.h
> @@ -133,6 +133,7 @@ struct lpfc_node_rrq {
>  /* Defines for nlp_flag (uint32) */
>  #define NLP_IGNR_REG_CMPL  0x0001 /* Rcvd rscn before we cmpl reg login 
> */
>  #define NLP_REG_LOGIN_SEND 0x0002   /* sent reglogin to adapter */
> +#define NLP_SUPPRESS_RSP   0x0010/* Remote NPort supports 
> suppress rsp */
>  #define NLP_PLOGI_SND  0x0020/* sent PLOGI request for this 
> entry */
>  #define NLP_PRLI_SND   0x0040/* sent PRLI request for this 
> entry */
>  #define NLP_ADISC_SND  0x0080/* sent ADISC request for this 
> entry */
> diff --git a/drivers/scsi/lpfc/lpfc_els.c 

Re: [PATCH 06/17] lpfc: NVME Initiator: Base modifications Part E

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Initiator: Base modifications
> 
> This is part E of parts A..F.
> 
> Part E is limited to lpfc_sli.c. This is the location of most of changes
> for the following:
> - sli3 ring vs sli4 wq splits
> - io abort interfaces
> - actual queuing routines and use of dma and sgl pools
> - service routines to create/delete queues
> 
> *
> 
> Refer to Part A for a description of base modifications
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_sli.c | 1508 
> ++
>  1 file changed, 1093 insertions(+), 415 deletions(-)
> 
[ .. ]
> @@ -3696,6 +3740,51 @@ lpfc_sli_flush_fcp_rings(struct lpfc_hba *phba)
>  }
>  
>  /**
> + * lpfc_sli_flush_nvme_rings - flush all wqes in the nvme rings
> + * @phba: Pointer to HBA context object.
> + *
> + * This function flushes all wqes in the nvme rings and frees all resources
> + * in the txcmplq. This function does not issue abort wqes for the IO
> + * commands in txcmplq, they will just be returned with
> + * IOERR_SLI_DOWN. This function is invoked with EEH when device's PCI
> + * slot has been permanently disabled.
> + **/
> +void
> +lpfc_sli_flush_nvme_rings(struct lpfc_hba *phba)
> +{
> + LIST_HEAD(txcmplq);
> + struct lpfc_sli_ring  *pring;
> + uint32_t i;
> +
> + if (phba->sli_rev < LPFC_SLI_REV4)
> + return;
> +
> + /* Hint to other driver operations that a flush is in progress. */
> + spin_lock_irq(>hbalock);
> + phba->hba_flag |= HBA_NVME_IOQ_FLUSH;
> + spin_unlock_irq(>hbalock);
> +
Is this ever reset?
I don't see it here ...

[ .. ]
> @@ -4380,9 +4469,12 @@ lpfc_sli_chipset_init(struct lpfc_hba *phba)
>   * configured.
>   **/
>  int
> -lpfc_sli_hbq_count(void)
> +lpfc_sli_hbq_count(struct lpfc_hba *phba)
>  {
> - return ARRAY_SIZE(lpfc_hbq_defs);
> + int i;
> +
> + i = ARRAY_SIZE(lpfc_hbq_defs);
> + return i;
>  }
>  
>  /**
The point of this change being ...?

Other than that:

Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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 3/4] nvme: use blk_rq_payload_bytes

2017-01-18 Thread Christoph Hellwig
On Tue, Jan 17, 2017 at 10:06:51PM +0200, Sagi Grimberg wrote:
>
>> @@ -1014,9 +1013,9 @@ static int nvme_rdma_map_data(struct nvme_rdma_queue 
>> *queue,
>>  }
>>
>
> Christoph, a little above here we still look at blk_rq_bytes(),
> shouldn't that look at blk_rq_payload_bytes() too?

The check is ok for now as it's just zero vs non-zero.  It's somewhat
broken for Write Zeroes, though.  I've fixed it in this series
which I need to submit:


http://git.infradead.org/users/hch/block.git/shortlog/refs/heads/write-zeroes-take-2
--
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 17/17] lpfc: Update lpfc version to 11.2.0.7

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:21 AM, James Smart wrote:
> 
> Update lpfc version to 11.2.0.7
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_version.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/lpfc/lpfc_version.h 
> b/drivers/scsi/lpfc/lpfc_version.h
> index 4e46ce4..9dfdab1 100644
> --- a/drivers/scsi/lpfc/lpfc_version.h
> +++ b/drivers/scsi/lpfc/lpfc_version.h
> @@ -18,7 +18,7 @@
>   * included with this package. *
>   ***/
>  
> -#define LPFC_DRIVER_VERSION "11.2.0.4"
> +#define LPFC_DRIVER_VERSION "11.2.0.7"
>  #define LPFC_DRIVER_NAME "lpfc"
>  #define LPFCMGMT_NAME"lpfcmgmt"
>  
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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 15/17] lpfc: NVME Target: Add debugfs support

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Target: Add debugfs support
> 
> Adds debugfs snippets to cover the new NVME target functionality
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_debugfs.c | 387 
> ++-
>  drivers/scsi/lpfc/lpfc_nvmet.c   | 279 +++-
>  drivers/scsi/lpfc/lpfc_nvmet.h   |  13 ++
>  3 files changed, 674 insertions(+), 5 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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 14/17] lpfc: NVME Target: bind to nvmet_fc api

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Target: Tie in to NVME Fabrics nvmet_fc LLDD target api
> 
> Adds the routines to:
> - register and deregister the FC port as a nvmet-fc targetport
> - binding of nvme queues to adapter WQs
> - receipt and passing of NVME LS's to transport, sending transport response
> - receipt of NVME FCP CMD IUs, processing FCP target io data transmission
>   commands; transmission of FCP io response.
> - Abort operations for tgt io exchanges.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/Makefile   |2 +-
>  drivers/scsi/lpfc/lpfc_crtn.h|8 +
>  drivers/scsi/lpfc/lpfc_ct.c  |2 +-
>  drivers/scsi/lpfc/lpfc_els.c |5 +-
>  drivers/scsi/lpfc/lpfc_hbadisc.c |   10 +-
>  drivers/scsi/lpfc/lpfc_init.c|2 +-
>  drivers/scsi/lpfc/lpfc_nvmet.c   | 1365 
> ++
>  drivers/scsi/lpfc/lpfc_sli.c |8 +-
>  8 files changed, 1390 insertions(+), 12 deletions(-)
>  create mode 100644 drivers/scsi/lpfc/lpfc_nvmet.c
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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 13/17] lpfc: NVME Target: Merge into FC discovery

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Target: Merge into FC discovery
> 
> Adds NVME PRLI handling and Nameserver registrations for NVME
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc_ct.c|  8 +++-
>  drivers/scsi/lpfc/lpfc_els.c   | 34 ++
>  drivers/scsi/lpfc/lpfc_hbadisc.c   | 27 +++
>  drivers/scsi/lpfc/lpfc_nportdisc.c | 35 ---
>  4 files changed, 92 insertions(+), 12 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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 12/17] lpfc: NVME Target: Receive buffer updates

2017-01-18 Thread Hannes Reinecke
On 01/18/2017 02:20 AM, James Smart wrote:
> 
> NVME Target: Receive buffer updates
> 
> Allocates buffer pools and configures adapter interfaces to handle
> receive buffer (asynchronous FCP CMD ius, first burst data)
> from the adapter. Splits by protocol, etc.
> 
> Signed-off-by: Dick Kennedy 
> Signed-off-by: James Smart 
> ---
>  drivers/scsi/lpfc/lpfc.h  |   3 +
>  drivers/scsi/lpfc/lpfc_attr.c |  86 +-
>  drivers/scsi/lpfc/lpfc_crtn.h |   1 +
>  drivers/scsi/lpfc/lpfc_hw4.h  | 274 +++
>  drivers/scsi/lpfc/lpfc_init.c | 264 +-
>  drivers/scsi/lpfc/lpfc_mbox.c |  87 ++
>  drivers/scsi/lpfc/lpfc_sli.c  | 608 
> +-
>  drivers/scsi/lpfc/lpfc_sli4.h |  11 +
>  8 files changed, 1313 insertions(+), 21 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (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