[PATCH] qedf: Send the driver state to MFW.

2018-07-05 Thread Chad Dupuis
From: Saurav Kashyap 

Need to notify firmware when driver is loaded and unloaded.

Signed-off-by: Saurav Kashyap 
Signed-off-by: Chad Dupuis 
---
 drivers/scsi/qedf/qedf_main.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 90394cef0f41..0a5dd5595dd3 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3295,6 +3295,11 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
init_completion(>flogi_compl);
 
+   status = qed_ops->common->update_drv_state(qedf->cdev, true);
+   if (status)
+   QEDF_ERR(&(qedf->dbg_ctx),
+   "Failed to send drv state to MFW.\n");
+
memset(_params, 0, sizeof(struct qed_link_params));
link_params.link_up = true;
status = qed_ops->common->set_link(qedf->cdev, _params);
@@ -3343,6 +3348,7 @@ static int qedf_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
 static void __qedf_remove(struct pci_dev *pdev, int mode)
 {
struct qedf_ctx *qedf;
+   int rc;
 
if (!pdev) {
QEDF_ERR(NULL, "pdev is NULL.\n");
@@ -3437,6 +3443,12 @@ static void __qedf_remove(struct pci_dev *pdev, int mode)
qed_ops->common->set_power_state(qedf->cdev, PCI_D0);
pci_set_drvdata(pdev, NULL);
}
+
+   rc = qed_ops->common->update_drv_state(qedf->cdev, false);
+   if (rc)
+   QEDF_ERR(&(qedf->dbg_ctx),
+   "Failed to send drv state to MFW.\n");
+
qed_ops->common->slowpath_stop(qedf->cdev);
qed_ops->common->remove(qedf->cdev);
 
-- 
2.12.3



Re: [RFC PATCH] qedf: qedf_dcbx_no_wait can be static

2018-04-27 Thread Chad Dupuis

On Thu, 26 Apr 2018, 9:47pm, kbuild test robot wrote:

> 
> Fixes: d9867ecbae88 ("qedf: Add dcbx_not_wait module parameter so we won't 
> wait for DCBX convergence to start discovery.")
> Signed-off-by: Fengguang Wu <fengguang...@intel.com>
> ---
>  qedf_main.c |2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index 8df151e..b96c928 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -89,7 +89,7 @@ module_param_named(retry_delay, qedf_retry_delay, bool, 
> S_IRUGO | S_IWUSR);
>  MODULE_PARM_DESC(retry_delay, " Enable/disable handling of FCP_RSP IU retry "
>   "delay handling (default off).");
>  
> -bool qedf_dcbx_no_wait;
> +static bool qedf_dcbx_no_wait;
>  module_param_named(dcbx_no_wait, qedf_dcbx_no_wait, bool, S_IRUGO | S_IWUSR);
>  MODULE_PARM_DESC(dcbx_no_wait, " Do not wait for DCBX convergence to start "
>   "sending FIP VLAN requests on link up (Default: off).");
> 

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


[PATCH 20/21] qedf: Update copyright for 2018.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 2 +-
 drivers/scsi/qedf/drv_fcoe_fw_funcs.h | 2 +-
 drivers/scsi/qedf/drv_scsi_fw_funcs.c | 2 +-
 drivers/scsi/qedf/drv_scsi_fw_funcs.h | 2 +-
 drivers/scsi/qedf/qedf.h  | 2 +-
 drivers/scsi/qedf/qedf_attr.c | 2 +-
 drivers/scsi/qedf/qedf_dbg.c  | 2 +-
 drivers/scsi/qedf/qedf_dbg.h  | 2 +-
 drivers/scsi/qedf/qedf_debugfs.c  | 2 +-
 drivers/scsi/qedf/qedf_els.c  | 2 +-
 drivers/scsi/qedf/qedf_fip.c  | 2 +-
 drivers/scsi/qedf/qedf_hsi.h  | 2 +-
 drivers/scsi/qedf/qedf_io.c   | 2 +-
 drivers/scsi/qedf/qedf_main.c | 2 +-
 drivers/scsi/qedf/qedf_version.h  | 2 +-
 15 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/qedf/drv_fcoe_fw_funcs.c 
b/drivers/scsi/qedf/drv_fcoe_fw_funcs.c
index a980ef756a67..5bd10b534c99 100644
--- a/drivers/scsi/qedf/drv_fcoe_fw_funcs.c
+++ b/drivers/scsi/qedf/drv_fcoe_fw_funcs.c
@@ -1,5 +1,5 @@
 /* QLogic FCoE Offload Driver
- * Copyright (c) 2016-2017 Cavium Inc.
+ * Copyright (c) 2016-2018 Cavium Inc.
  *
  * This software is available under the terms of the GNU General Public License
  * (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/drv_fcoe_fw_funcs.h 
b/drivers/scsi/qedf/drv_fcoe_fw_funcs.h
index b5c236efd465..42fde55ac735 100644
--- a/drivers/scsi/qedf/drv_fcoe_fw_funcs.h
+++ b/drivers/scsi/qedf/drv_fcoe_fw_funcs.h
@@ -1,5 +1,5 @@
 /* QLogic FCoE Offload Driver
- * Copyright (c) 2016-2017 Cavium Inc.
+ * Copyright (c) 2016-2018 Cavium Inc.
  *
  * This software is available under the terms of the GNU General Public License
  * (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/drv_scsi_fw_funcs.c 
b/drivers/scsi/qedf/drv_scsi_fw_funcs.c
index 5d5095e3d96d..29a55257224f 100644
--- a/drivers/scsi/qedf/drv_scsi_fw_funcs.c
+++ b/drivers/scsi/qedf/drv_scsi_fw_funcs.c
@@ -1,5 +1,5 @@
 /* QLogic FCoE Offload Driver
- * Copyright (c) 2016-2017 Cavium Inc.
+ * Copyright (c) 2016-2018 Cavium Inc.
  *
  * This software is available under the terms of the GNU General Public License
  * (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/drv_scsi_fw_funcs.h 
b/drivers/scsi/qedf/drv_scsi_fw_funcs.h
index 8fbe6e4d0b4f..bf102204fe56 100644
--- a/drivers/scsi/qedf/drv_scsi_fw_funcs.h
+++ b/drivers/scsi/qedf/drv_scsi_fw_funcs.h
@@ -1,5 +1,5 @@
 /* QLogic FCoE Offload Driver
- * Copyright (c) 2016-2017 Cavium Inc.
+ * Copyright (c) 2016-2018 Cavium Inc.
  *
  * This software is available under the terms of the GNU General Public License
  * (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 44770f849632..2372a40326f8 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -1,6 +1,6 @@
 /*
  *  QLogic FCoE Offload Driver
- *  Copyright (c) 2016-2017 Cavium Inc.
+ *  Copyright (c) 2016-2018 Cavium Inc.
  *
  *  This software is available under the terms of the GNU General Public 
License
  *  (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/qedf_attr.c b/drivers/scsi/qedf/qedf_attr.c
index fa6727685627..0487b7237104 100644
--- a/drivers/scsi/qedf/qedf_attr.c
+++ b/drivers/scsi/qedf/qedf_attr.c
@@ -1,6 +1,6 @@
 /*
  *  QLogic FCoE Offload Driver
- *  Copyright (c) 2016-2017 Cavium Inc.
+ *  Copyright (c) 2016-2018 Cavium Inc.
  *
  *  This software is available under the terms of the GNU General Public 
License
  *  (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/qedf_dbg.c b/drivers/scsi/qedf/qedf_dbg.c
index e02c7a497de9..f2397ee9ba69 100644
--- a/drivers/scsi/qedf/qedf_dbg.c
+++ b/drivers/scsi/qedf/qedf_dbg.c
@@ -1,6 +1,6 @@
 /*
  *  QLogic FCoE Offload Driver
- *  Copyright (c) 2016 Cavium Inc.
+ *  Copyright (c) 2016-2018 Cavium Inc.
  *
  *  This software is available under the terms of the GNU General Public 
License
  *  (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/qedf_dbg.h b/drivers/scsi/qedf/qedf_dbg.h
index 77c27e888969..dd0109653aa3 100644
--- a/drivers/scsi/qedf/qedf_dbg.h
+++ b/drivers/scsi/qedf/qedf_dbg.h
@@ -1,6 +1,6 @@
 /*
  *  QLogic FCoE Offload Driver
- *  Copyright (c) 2016-2017 Cavium Inc.
+ *  Copyright (c) 2016-2018 Cavium Inc.
  *
  *  This software is available under the terms of the GNU General Public 
License
  *  (GPL) Version 2, available from the file COPYING in the main directory of
diff --git a/drivers/scsi/qedf/qedf_debugfs.c b/drivers/scsi/qedf/qedf_debugfs.c
index c539a7ae3a7e..99783402df5c 100644
--- a/drivers/scsi/qedf/qedf_debugfs.c
+++ b/drivers/scsi/qedf/qedf_debugfs.c
@@ -1,6 +1,6 @@
 /*
  *  QLogic FCoE O

[PATCH 18/21] qedf: Set the UNLOADING flag when removing a vport.

2018-04-25 Thread Chad Dupuis
Similar to what we do when we remove a PCI function, set the
QEDF_UNLOADING flag to prevent any requests from being queued while
a vport is being deleted.  This prevents any requests from getting
stuck in limbo when the vport is unloaded or deleted.

Fixes the crash:

PID: 106676  TASK: 9a436aa9  CPU: 12  COMMAND: "multipathd"
 #0 [9a43567d3550] machine_kexec+522 at aca60b2a
 #1 [9a43567d35b0] __crash_kexec+114 at acb13512
 #2 [9a43567d3680] crash_kexec+48 at acb13600
 #3 [9a43567d3698] oops_end+168 at ad117768
 #4 [9a43567d36c0] no_context+645 at ad106f52
 #5 [9a43567d3710] __bad_area_nosemaphore+116 at ad106fe9
 #6 [9a43567d3760] bad_area+70 at ad107379
 #7 [9a43567d3788] __do_page_fault+1247 at ad11a8cf
 #8 [9a43567d37f0] do_page_fault+53 at ad11a915
 #9 [9a43567d3820] page_fault+40 at ad116768
[exception RIP: qedf_init_task+61]
RIP: c0e13c2d  RSP: 9a43567d38d0  RFLAGS: 00010046
RAX:   RBX: be920472c738  RCX: 9a434fa0e3e8
RDX: 9a434f695280  RSI: be920472c738  RDI: 9a43aa359c80
RBP: 9a43567d3950   R8: 0c15   R9: 9a3fb09b9880
R10: 9a434fa0e3e8  R11: 9a43567d35ce  R12: 
R13: 9a434f695280  R14: 9a43aa359c80  R15: 9a3fb9e005c0
ORIG_RAX:   CS: 0010  SS: 0018

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 31fc64b23566..59bcb7916441 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -1677,6 +1677,15 @@ static int qedf_vport_destroy(struct fc_vport *vport)
struct Scsi_Host *shost = vport_to_shost(vport);
struct fc_lport *n_port = shost_priv(shost);
struct fc_lport *vn_port = vport->dd_data;
+   struct qedf_ctx *qedf = lport_priv(vn_port);
+
+   if (!qedf) {
+   QEDF_ERR(NULL, "qedf is NULL.\n");
+   goto out;
+   }
+
+   /* Set unloading bit on vport qedf_ctx to prevent more I/O */
+   set_bit(QEDF_UNLOADING, >flags);
 
mutex_lock(_port->lp_mutex);
list_del(_port->list);
@@ -1703,6 +1712,7 @@ static int qedf_vport_destroy(struct fc_vport *vport)
if (vn_port->host)
scsi_host_put(vn_port->host);
 
+out:
return 0;
 }
 
-- 
2.12.3



[PATCH 21/21] qedf: Update version number to 8.33.16.20.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_version.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_version.h b/drivers/scsi/qedf/qedf_version.h
index 4a19e6f6d843..9455faacd5de 100644
--- a/drivers/scsi/qedf/qedf_version.h
+++ b/drivers/scsi/qedf/qedf_version.h
@@ -7,9 +7,9 @@
  *  this source tree.
  */
 
-#define QEDF_VERSION   "8.33.0.20"
+#define QEDF_VERSION   "8.33.16.20"
 #define QEDF_DRIVER_MAJOR_VER  8
 #define QEDF_DRIVER_MINOR_VER  33
-#define QEDF_DRIVER_REV_VER0
+#define QEDF_DRIVER_REV_VER16
 #define QEDF_DRIVER_ENG_VER20
 
-- 
2.12.3



[PATCH 17/21] qedf: Add additional checks when restarting an rport due to ABTS timeout.

2018-04-25 Thread Chad Dupuis
There are a couple of kernel cases when we restart a remote port due to
ABTS timeout that we need to handle:

1. Flush any outstanding ABTS requests when flushing I/Os so that we do not
   hold up the eh_abort handler indefinitely causing process hangs.
2. Check if we are currently uploading a connection before issuing an ABTS.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_io.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 589414f06376..f669df03f37d 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1457,6 +1457,31 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, 
int lun)
goto free_cmd;
}
 
+   if (io_req->cmd_type == QEDF_ABTS) {
+   rc = kref_get_unless_zero(_req->refcount);
+   if (!rc) {
+   QEDF_ERR(&(qedf->dbg_ctx),
+   "Could not get kref for abort io_req=0x%p 
xid=0x%x.\n",
+   io_req, io_req->xid);
+   continue;
+   }
+   QEDF_INFO(>dbg_ctx, QEDF_LOG_IO,
+   "Flushing abort xid=0x%x.\n", io_req->xid);
+
+   clear_bit(QEDF_CMD_IN_ABORT, _req->flags);
+
+   if (io_req->sc_cmd) {
+   if (io_req->return_scsi_cmd_on_abts)
+   qedf_scsi_done(qedf, io_req, DID_ERROR);
+   }
+
+   /* Notify eh_abort handler that ABTS is complete */
+   complete(_req->abts_done);
+   kref_put(_req->refcount, qedf_release_cmd);
+
+   goto free_cmd;
+   }
+
if (!io_req->sc_cmd)
continue;
if (lun > 0) {
@@ -1534,6 +1559,11 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool 
return_scsi_cmd_on_abts)
goto abts_err;
}
 
+   if (test_bit(QEDF_RPORT_UPLOADING_CONNECTION, >flags)) {
+   QEDF_ERR(>dbg_ctx, "fcport is uploading.\n");
+   rc = 1;
+   goto out;
+   }
 
kref_get(_req->refcount);
 
@@ -1573,6 +1603,7 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool 
return_scsi_cmd_on_abts)
 * task at the firmware.
 */
qedf_initiate_cleanup(io_req, return_scsi_cmd_on_abts);
+out:
return rc;
 }
 
-- 
2.12.3



[PATCH 19/21] qedf: Add more defensive checks for concurrent error conditions.

2018-04-25 Thread Chad Dupuis
During an uplink toggle test all error handling is done via timeout and
firmware error conditions which can occur concurrentl:

- SCSI layer timeouts
- Error detect CQEs
- Firmware detected underruns
- ABTS timeouts

All these concurrent events require more defensive checks in the driver
including:

- Check both internally and externally generated aborts to make sure the
  xid is not already been aborted in another context or in cleanup.
- Check back pointers in qedf_cmd_timeout to verify the context of the
  io_req, fcport and qedf_ctx
- Check rport state in host reset handler to not reset the whole host
  if the rport is already uploaded or in the process of relogin
- Check to state for an fcport before initiating a middle path ELS
  request

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_els.c  | 13 +++--
 drivers/scsi/qedf/qedf_io.c   | 33 +++--
 drivers/scsi/qedf/qedf_main.c | 26 --
 3 files changed, 58 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index 816f693ef4a8..3053270aa473 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -14,8 +14,8 @@ static int qedf_initiate_els(struct qedf_rport *fcport, 
unsigned int op,
void (*cb_func)(struct qedf_els_cb_arg *cb_arg),
struct qedf_els_cb_arg *cb_arg, uint32_t timer_msec)
 {
-   struct qedf_ctx *qedf = fcport->qedf;
-   struct fc_lport *lport = qedf->lport;
+   struct qedf_ctx *qedf;
+   struct fc_lport *lport;
struct qedf_ioreq *els_req;
struct qedf_mp_req *mp_req;
struct fc_frame_header *fc_hdr;
@@ -29,6 +29,15 @@ static int qedf_initiate_els(struct qedf_rport *fcport, 
unsigned int op,
unsigned long flags;
u16 sqe_idx;
 
+   if (!fcport) {
+   QEDF_ERR(NULL, "fcport is NULL");
+   rc = -EINVAL;
+   goto els_err;
+   }
+
+   qedf = fcport->qedf;
+   lport = qedf->lport;
+
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_ELS, "Sending ELS\n");
 
rc = fc_remote_port_chkready(fcport->rport);
diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index f669df03f37d..07925f8e65bf 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -23,12 +23,31 @@ static void qedf_cmd_timeout(struct work_struct *work)
 
struct qedf_ioreq *io_req =
container_of(work, struct qedf_ioreq, timeout_work.work);
-   struct qedf_ctx *qedf = io_req->fcport->qedf;
-   struct qedf_rport *fcport = io_req->fcport;
+   struct qedf_ctx *qedf;
+   struct qedf_rport *fcport;
u8 op = 0;
 
+   if (io_req == NULL) {
+   QEDF_INFO(NULL, QEDF_LOG_IO, "io_req is NULL.\n");
+   return;
+   }
+
+   fcport = io_req->fcport;
+   if (io_req->fcport == NULL) {
+   QEDF_INFO(NULL, QEDF_LOG_IO,  "fcport is NULL.\n");
+   return;
+   }
+
+   qedf = fcport->qedf;
+
switch (io_req->cmd_type) {
case QEDF_ABTS:
+   if (qedf == NULL) {
+   QEDF_INFO(NULL, QEDF_LOG_IO, "qedf is NULL for 
xid=0x%x.\n",
+   io_req->xid);
+   return;
+   }
+
QEDF_ERR((>dbg_ctx), "ABTS timeout, xid=0x%x.\n",
io_req->xid);
/* Cleanup timed out ABTS */
@@ -1565,6 +1584,16 @@ int qedf_initiate_abts(struct qedf_ioreq *io_req, bool 
return_scsi_cmd_on_abts)
goto out;
}
 
+   if (!test_bit(QEDF_CMD_OUTSTANDING, _req->flags) ||
+   test_bit(QEDF_CMD_IN_CLEANUP, _req->flags) ||
+   test_bit(QEDF_CMD_IN_ABORT, _req->flags)) {
+   QEDF_ERR(&(qedf->dbg_ctx), "io_req xid=0x%x already in "
+ "cleanup or abort processing or already "
+ "completed.\n", io_req->xid);
+   rc = 1;
+   goto out;
+   }
+
kref_get(_req->refcount);
 
xid = io_req->xid;
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 59bcb7916441..9a2774e56e75 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -643,16 +643,6 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
goto out;
}
 
-   if (!test_bit(QEDF_CMD_OUTSTANDING, _req->flags) ||
-   test_bit(QEDF_CMD_IN_CLEANUP, _req->flags) ||
-   test_bit(QEDF_CMD_IN_ABORT, _req->flags)) {
-   QEDF_ERR(&(qedf->dbg_ctx), "io_req xid=0x%x already in "
- "cleanup or abort processing or already "
- "completed

[PATCH 14/21] qedf: Improve firmware debug dump handling.

2018-04-25 Thread Chad Dupuis
Get all firmware debug data instead of just a grc dump.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf.h  |  2 ++
 drivers/scsi/qedf/qedf_dbg.c  |  2 +-
 drivers/scsi/qedf/qedf_main.c | 13 -
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 1dffe21873d0..44770f849632 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -367,6 +367,7 @@ struct qedf_ctx {
 #define QEDF_IO_WORK_MIN   64
mempool_t *io_mempool;
struct workqueue_struct *dpc_wq;
+   struct delayed_work grcdump_work;
 
u32 slow_sge_ios;
u32 fast_sge_ios;
@@ -499,6 +500,7 @@ extern void qedf_process_seq_cleanup_compl(struct qedf_ctx 
*qedf,
struct fcoe_cqe *cqe, struct qedf_ioreq *io_req);
 extern int qedf_send_flogi(struct qedf_ctx *qedf);
 extern void qedf_fp_io_handler(struct work_struct *work);
+extern void qedf_wq_grcdump(struct work_struct *work);
 
 #define FCOE_WORD_TO_BYTE  4
 #define QEDF_MAX_TASK_NUM  0x
diff --git a/drivers/scsi/qedf/qedf_dbg.c b/drivers/scsi/qedf/qedf_dbg.c
index bd1cef25a900..e02c7a497de9 100644
--- a/drivers/scsi/qedf/qedf_dbg.c
+++ b/drivers/scsi/qedf/qedf_dbg.c
@@ -147,7 +147,7 @@ qedf_get_grc_dump(struct qed_dev *cdev, const struct 
qed_common_ops *common,
if (!*buf)
return -EINVAL;
 
-   return common->dbg_grc(cdev, *buf, grcsize);
+   return common->dbg_all_data(cdev, *buf);
 }
 
 void
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index be29c8d155c2..3e9befcbd5ba 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3008,6 +3008,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
qedf->link_update_wq = create_workqueue(host_buf);
INIT_DELAYED_WORK(>link_update, qedf_handle_link_update);
INIT_DELAYED_WORK(>link_recovery, qedf_link_recovery);
+   INIT_DELAYED_WORK(>grcdump_work, qedf_wq_grcdump);
qedf->fipvlan_retries = qedf_fipvlan_retries;
/* Set a default prio in case DCBX doesn't converge */
qedf->prio = QEDF_DEFAULT_PRIO;
@@ -3240,7 +3241,8 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 * unload process.
 */
if (mode != QEDF_MODE_RECOVERY) {
-   qedf->grcdump_size = qed_ops->common->dbg_grc_size(qedf->cdev);
+   qedf->grcdump_size =
+   qed_ops->common->dbg_all_data_size(qedf->cdev);
if (qedf->grcdump_size) {
rc = qedf_alloc_grc_dump_buf(>grcdump,
qedf->grcdump_size);
@@ -3424,6 +3426,15 @@ static void qedf_remove(struct pci_dev *pdev)
__qedf_remove(pdev, QEDF_MODE_NORMAL);
 }
 
+void qedf_wq_grcdump(struct work_struct *work)
+{
+   struct qedf_ctx *qedf =
+   container_of(work, struct qedf_ctx, grcdump_work.work);
+
+   QEDF_ERR(&(qedf->dbg_ctx), "Collecting GRC dump.\n");
+   qedf_capture_grc_dump(qedf);
+}
+
 /*
  * Module Init/Remove
  */
-- 
2.12.3



[PATCH 10/21] qedf: Return request as DID_NO_CONNECT if MSI-X is not enabled.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_io.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 94d6455c9ddc..78cbd126c7e5 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -931,6 +931,15 @@ qedf_queuecommand(struct Scsi_Host *host, struct scsi_cmnd 
*sc_cmd)
return 0;
}
 
+   if (!qedf->pdev->msix_enabled) {
+   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
+   "Completing sc_cmd=%p DID_NO_CONNECT as MSI-X is not 
enabled.\n",
+   sc_cmd);
+   sc_cmd->result = DID_NO_CONNECT << 16;
+   sc_cmd->scsi_done(sc_cmd);
+   return 0;
+   }
+
rval = fc_remote_port_chkready(rport);
if (rval) {
sc_cmd->result = rval;
-- 
2.12.3



[PATCH 16/21] qedf: If qed fails to enable MSI-X fail PCI probe.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 0150f2e4e75c..31fc64b23566 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2134,7 +2134,8 @@ static int qedf_setup_int(struct qedf_ctx *qedf)
QEDF_SIMD_HANDLER_NUM, qedf_simd_int_handler);
qedf->int_info.used_cnt = 1;
 
-   return 0;
+   QEDF_ERR(>dbg_ctx, "Only MSI-X supported. Failing probe.\n");
+   return -EINVAL;
 }
 
 /* Main function for libfc frame reception */
-- 
2.12.3



[PATCH 15/21] qedf: Honor default_prio module parameter even if DCBX does not converge.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 3e9befcbd5ba..0150f2e4e75c 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3011,7 +3011,14 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
INIT_DELAYED_WORK(>grcdump_work, qedf_wq_grcdump);
qedf->fipvlan_retries = qedf_fipvlan_retries;
/* Set a default prio in case DCBX doesn't converge */
-   qedf->prio = QEDF_DEFAULT_PRIO;
+   if (qedf_default_prio > -1) {
+   /*
+* This is the case where we pass a modparam in so we want to
+* honor it even if dcbx doesn't converge.
+*/
+   qedf->prio = qedf_default_prio;
+   } else
+   qedf->prio = QEDF_DEFAULT_PRIO;
 
/*
 * Common probe. Takes care of basic hardware init and pci_*
-- 
2.12.3



[PATCH 03/21] qedf: Add missing skb frees in error path.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_fip.c  | 1 +
 drivers/scsi/qedf/qedf_main.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c
index 773558fc0697..aef199c12fb4 100644
--- a/drivers/scsi/qedf/qedf_fip.c
+++ b/drivers/scsi/qedf/qedf_fip.c
@@ -181,6 +181,7 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff 
*skb)
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
"Dropping CVL since FCF has not been selected "
"yet.");
+   kfree_skb(skb);
return;
}
 
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index e14b402f25d5..8dcacc5b5f60 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2190,6 +2190,7 @@ static void qedf_recv_frame(struct qedf_ctx *qedf,
if (ntoh24(_mac[3]) != ntoh24(fh->fh_d_id)) {
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2,
"FC frame d_id mismatch with MAC %pM.\n", dest_mac);
+   kfree_skb(skb);
return;
}
 
-- 
2.12.3



[PATCH 06/21] qedf: Sanity check FCoE/FIP priority value to make sure it's between 0 and 7.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 8dcacc5b5f60..1a58f4a9cdf9 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3405,6 +3405,13 @@ static int __init qedf_init(void)
if (qedf_debug == QEDF_LOG_DEFAULT)
qedf_debug = QEDF_DEFAULT_LOG_MASK;
 
+   /* Check that default prio for FIP/FCoE traffic is between 0..7 */
+   if (qedf_default_prio > 7) {
+   qedf_default_prio = QEDF_DEFAULT_PRIO;
+   QEDF_ERR(NULL, "FCoE/FIP priority out of range, resetting to 
%d.\n",
+   QEDF_DEFAULT_PRIO);
+   }
+
/* Print driver banner */
QEDF_INFO(NULL, QEDF_LOG_INFO, "%s v%s.\n", QEDF_DESCR,
   QEDF_VERSION);
-- 
2.12.3



[PATCH 00/21] qedf: Update driver to 8.33.16.20.

2018-04-25 Thread Chad Dupuis
Hi Martin,

Please add these patches to your tree for the next kernel merge window at your 
convenience.

Thanks,
Chad

Chad Dupuis (20):
  qedf: Synchronize rport restarts when multiple ELS commands time out.
  qedf: Increase the number of default FIP VLAN request retries to 60.
  qedf: Add missing skb frees in error path.
  qedf: Fix VLAN display when printing sent FIP frames.
  qedf: Add check for offload before flushing I/Os for target.
  qedf: Sanity check FCoE/FIP priority value to make sure it's between 0
and 7.
  qedf: Add dcbx_not_wait module parameter so we won't wait for DCBX
convergence to start discovery.
  qedf: Honor priority from DCBX FCoE App tag.
  qedf: Release RRQ reference correctly when RRQ command times out.
  qedf: Return request as DID_NO_CONNECT if MSI-X is not enabled.
  qedf: Check if link is alraedy up when receiving a link up event from
qed.
  qedf: Add task id to kref_get_unless_zero() debug messages when
flushing requests.
  qedf: Improve firmware debug dump handling.
  qedf: Honor default_prio module parameter even if DCBX does not
converge.
  qedf: If qed fails to enable MSI-X fail PCI probe.
  qedf: Add additional checks when restarting an rport due to ABTS
timeout.
  qedf: Set the UNLOADING flag when removing a vport.
  qedf: Add more defensive checks for concurrent error conditions.
  qedf: Update copyright for 2018.
  qedf: Update version number to 8.33.16.20.

Saurav Kashyap (1):
  qedf: Remove setting DCBX pending during soft context reset.

 drivers/scsi/qedf/drv_fcoe_fw_funcs.c |   2 +-
 drivers/scsi/qedf/drv_fcoe_fw_funcs.h |   2 +-
 drivers/scsi/qedf/drv_scsi_fw_funcs.c |   2 +-
 drivers/scsi/qedf/drv_scsi_fw_funcs.h |   2 +-
 drivers/scsi/qedf/qedf.h  |   6 +-
 drivers/scsi/qedf/qedf_attr.c |   2 +-
 drivers/scsi/qedf/qedf_dbg.c  |   4 +-
 drivers/scsi/qedf/qedf_dbg.h  |   2 +-
 drivers/scsi/qedf/qedf_debugfs.c  |   2 +-
 drivers/scsi/qedf/qedf_els.c  |  35 -
 drivers/scsi/qedf/qedf_fip.c  |   5 +-
 drivers/scsi/qedf/qedf_hsi.h  |   2 +-
 drivers/scsi/qedf/qedf_io.c   |  87 +--
 drivers/scsi/qedf/qedf_main.c | 130 +++---
 drivers/scsi/qedf/qedf_version.h  |   6 +-
 15 files changed, 238 insertions(+), 51 deletions(-)

-- 
2.12.3



[PATCH 13/21] qedf: Remove setting DCBX pending during soft context reset.

2018-04-25 Thread Chad Dupuis
From: Saurav Kashyap <saurav.kash...@cavium.com>

PROBLEM DESCRIPTION:

According to the logs STAG was changing and it was triggering soft reset.
In soft reset we used to virtual link down and up and also we were
disabling DCBx flag. Since this was virtual link flap, DCBx never used to
converge again.

SOLUTION:

Code change is to remove disabling DCBx flag from soft reset.

Signed-off-by: Saurav Kashyap <saurav.kash...@cavium.com>
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 866989ccd66e..be29c8d155c2 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -734,7 +734,6 @@ static void qedf_ctx_soft_reset(struct fc_lport *lport)
 
/* For host reset, essentially do a soft link up/down */
atomic_set(>link_state, QEDF_LINK_DOWN);
-   atomic_set(>dcbx, QEDF_DCBX_PENDING);
queue_delayed_work(qedf->link_update_wq, >link_update,
0);
qedf_wait_for_upload(qedf);
-- 
2.12.3



[PATCH 02/21] qedf: Increase the number of default FIP VLAN request retries to 60.

2018-04-25 Thread Chad Dupuis
Some configurations need more than 30 seconds to respond to a FIP VLAN
request so increase the default to 60 seconds.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 284ccb566b19..e14b402f25d5 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -44,10 +44,10 @@ module_param_named(debug, qedf_debug, uint, S_IRUGO);
 MODULE_PARM_DESC(debug, " Debug mask. Pass '1' to enable default debugging"
" mask");
 
-static uint qedf_fipvlan_retries = 30;
+static uint qedf_fipvlan_retries = 60;
 module_param_named(fipvlan_retries, qedf_fipvlan_retries, int, S_IRUGO);
 MODULE_PARM_DESC(fipvlan_retries, " Number of FIP VLAN requests to attempt "
-   "before giving up (default 30)");
+   "before giving up (default 60)");
 
 static uint qedf_fallback_vlan = QEDF_FALLBACK_VLAN;
 module_param_named(fallback_vlan, qedf_fallback_vlan, int, S_IRUGO);
-- 
2.12.3



[PATCH 04/21] qedf: Fix VLAN display when printing sent FIP frames.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_fip.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c
index aef199c12fb4..c6b984efa5e8 100644
--- a/drivers/scsi/qedf/qedf_fip.c
+++ b/drivers/scsi/qedf/qedf_fip.c
@@ -134,7 +134,7 @@ void qedf_fip_send(struct fcoe_ctlr *fip, struct sk_buff 
*skb)
 
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, "FIP frame send: "
"dest=%pM op=%x sub=%x vlan=%04x.", eth_hdr->h_dest, op, sub,
-   ntohs(vlan_tci));
+   vlan_tci);
if (qedf_dump_frames)
print_hex_dump(KERN_WARNING, "fip ", DUMP_PREFIX_OFFSET, 16, 1,
skb->data, skb->len, false);
-- 
2.12.3



[PATCH 05/21] qedf: Add check for offload before flushing I/Os for target.

2018-04-25 Thread Chad Dupuis
We need to check that a fcport is offloaded before we try to flush any
requests.  No doing so could lead to undefined results and most likely a
crash.

Fixes the oops:

[  343.971886] [:42:00.3]:[qedf_execute_tmf:2070]:8: wait for tm_cmpl 
timeout!
[  343.971933] BUG: unable to handle kernel paging request at 24a8
[  343.971949] IP: [] qedf_flush_active_ios+0x46/0x260 [qedf]
[  343.971952] PGD 42c569067 PUD 4160fe067 PMD 0
[  343.971954] Oops:  [#1] SMP
[  343.972008] Modules linked in: qedf(OEX) qed(OEX) bnx2i cnic fuse af_packet 
iscsi_ibft msr xfs intel_rapl sb_edac edac_core x86_pkg_temp_thermal bnx2x 
geneve intel_powerclamp vxlan coretemp ipmi_ssif ipmi_devintf kvm_intel kvm 
libiscsi joydev irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel tg3 
ip6_udp_tunnel udp_tunnel mdio libcrc32c iTCO_wdt scsi_transport_iscsi uio drbg 
iTCO_vendor_support iscsi_boot_sysfs dcdbas(X) ipmi_si ansi_cprng aesni_intel 
aes_x86_64 lrw gf128mul glue_helper ablk_helper ptp pps_core pcspkr libphy 
lpc_ich mfd_core cryptd fjes wmi ipmi_msghandler button crc8 libfcoe libfc 
scsi_transport_fc mei_me mei shpchp processor acpi_pad btrfs xor hid_generic 
usbhid raid6_pq sd_mod sr_mod cdrom mgag200 crc32c_intel i2c_algo_bit 
drm_kms_helper syscopyarea sysfillrect sysimgblt
[  343.972020]  fb_sys_fops ttm ahci ehci_pci libahci ehci_hcd drm libata 
usbcore megaraid_sas usb_common sg dm_multipath dm_mod scsi_dh_rdac scsi_dh_emc 
scsi_dh_alua scsi_mod autofs4 [last unloaded: qedf]
[  343.972022] Supported: Yes, External
[  343.972026] CPU: 30 PID: 12777 Comm: sg_reset Tainted: GW  OEX 
4.4.73-5-default #1
[  343.972027] Hardware name: Dell Inc. PowerEdge R720/0X3D66, BIOS 2.1.3 
11/20/2013
[  343.972029] task: 88018dfc0e80 ti: 88042bd7c000 task.ti: 
88042bd7c000
[  343.972036] RIP: 0010:[]  [] 
qedf_flush_active_ios+0x46/0x260 [qedf]
[  343.972038] RSP: 0018:88042bd7fbe0  EFLAGS: 00010286
[  343.972039] RAX:  RBX: 88042ce37800 RCX: 0400
[  343.972040] RDX: 060e RSI: a06be830 RDI: 8807e5072cc0
[  343.972041] RBP: 1000 R08: a06bff4d R09: 88018dd84580
[  343.972042] R10: 018b R11: 0002 R12: 2003
[  343.972043] R13:  R14:  R15: 8807e5072cc0
[  343.972046] FS:  7fc1c8809700() GS:88042fbc() 
knlGS:
[  343.972048] CS:  0010 DS:  ES:  CR0: 80050033
[  343.972049] CR2: 24a8 CR3: 0004236ec000 CR4: 001406e0
[  343.972050] Stack:
[  343.972053]  504c78750607e154 810a7d10 88042ce37800 
0010
[  343.972055]  2003 8807ff480c48 8807e5072cc0 
c90004ec4ff8
[  343.972057]  a06b9b86 88080010 0282 
88042ce37800
[  343.972058] Call Trace:
[  343.972094]  [] qedf_initiate_tmf+0x346/0x3e0 [qedf]
[  343.972120]  [] scsi_try_bus_device_reset+0x26/0x40 
[scsi_mod]
[  343.972133]  [] scsi_ioctl_reset+0x13e/0x260 [scsi_mod]
[  343.972145]  [] scsi_ioctl+0x136/0x3d0 [scsi_mod]
[  343.972154]  [] blkdev_ioctl+0x6bb/0x950
[  343.972164]  [] block_ioctl+0x3d/0x40
[  343.972170]  [] do_vfs_ioctl+0x2cd/0x4a0
[  343.972186]  [] SyS_ioctl+0x74/0x80
[  343.972193]  [] entry_SYSCALL_64_fastpath+0x12/0x6d
[  343.975285] DWARF2 unwinder stuck at entry_SYSCALL_64_fastpath+0x12/0x6d

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_io.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 50a50c4249d0..94d6455c9ddc 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1414,6 +1414,12 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, 
int lun)
if (!fcport)
return;
 
+   /* Check that fcport is still offloaded */
+   if (!test_bit(QEDF_RPORT_SESSION_READY, >flags)) {
+   QEDF_ERR(NULL, "fcport is no longer offloaded.\n");
+   return;
+   }
+
qedf = fcport->qedf;
cmd_mgr = qedf->cmd_mgr;
 
-- 
2.12.3



[PATCH 01/21] qedf: Synchronize rport restarts when multiple ELS commands time out.

2018-04-25 Thread Chad Dupuis
If multiple ELS commands time out, such as aborts, they could all try to
restart the same rport and the same time.  This could mean multiple
multiple processes trying to clean up any outstanding commands or trying
to upload the same port.

Add a new flag (QEDF_RPORT_IN_RESET) and check other fcport state flags
before trying to reset the port.

Fixes the crash:

[17501.824701] [ cut here ]
[17501.824733] kernel BUG at include/asm-generic/dma-mapping-common.h:65!
[17501.824760] invalid opcode:  [#1] SMP
[17501.824781] Modules linked in: xt_CHECKSUM iptable_mangle ipt_MASQUERADE 
nf_nat_masquerade_ipv4 iptable_nat nf_nat_ipv4 nf_nat nf_conntrack_ipv4 
nf_defrag_ipv4 xt_conntrack nf_conntrack ipt_REJECT nf_reject_ipv4 tun bridge 
stp llc ebtable_filter ebtables ip6table_filter ip6_tables iptable_filter ses 
enclosure dm_service_time vfat fat sb_edac edac_core intel_powerclamp coretemp 
intel_rapl iosf_mbi kvm_intel kvm irqbypass joydev btrfs hpilo raid6_pq 
iTCO_wdt iTCO_vendor_support xor hpwdt ipmi_ssif sg crc32_pclmul 
ghash_clmulni_intel aesni_intel lrw gf128mul ioatdma lpc_ich glue_helper 
ablk_helper i2c_i801 shpchp cryptd ipmi_si pcspkr acpi_power_meter ipmi_devintf 
pcc_cpufreq dca wmi ipmi_msghandler dm_multipath nfsd auth_rpcgss nfs_acl lockd 
grace sunrpc ip_tables xfs libcrc32c sr_mod cdrom sd_mod
[17501.825119]  crc_t10dif crct10dif_generic mgag200 i2c_algo_bit 
drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm qedf(OE) drm 
libfcoe ahci qedi(OE) crct10dif_pclmul libfc libahci uio crct10dif_common 
crc32c_intel libiscsi libata scsi_transport_iscsi scsi_transport_fc tg3 
qede(OE) scsi_tgt hpsa qed(OE) i2c_core ptp scsi_transport_sas pps_core 
iscsi_boot_sysfs dm_mirror dm_region_hash dm_log dm_mod
[17501.825292] CPU: 8 PID: 10531 Comm: kworker/u96:1 Tainted: G   OE  
   3.10.0-693.el7.x86_64 #1
[17501.825330] Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS 
P89 06/02/2016
[17501.825372] Workqueue: fc_rport_eq fc_rport_work [libfc]
[17501.825395] task: 88101bca8000 ti: 881025278000 task.ti: 
881025278000
[17501.825424] RIP: 0010:[]  [] 
qedf_unmap_sg_list.isra.15+0x89/0x90 [qedf]
[17501.825471] RSP: 0018:88102527bb98  EFLAGS: 00010212
[17501.825493] RAX: 8800224eac00 RBX: c9000cd05210 RCX: 1000
[17501.825520] RDX: 7e655e40 RSI: 1000 RDI: 88107fe3b098
[17501.826683] RBP: 88102527bba0 R08: 81a13200 R09: 0286
[17501.827747] R10: 0004 R11: 0005 R12: c9000cd051b8
[17501.828804] R13: 881037640c28 R14: 0007 R15: c9000cd05200
[17501.829850] FS:  () GS:88103fa0() 
knlGS:
[17501.830910] CS:  0010 DS:  ES:  CR0: 80050033
[17501.831966] CR2: 7f9b94005f38 CR3: 019f2000 CR4: 003407e0
[17501.833027] DR0:  DR1:  DR2: 
[17501.834087] DR3:  DR6: fffe0ff0 DR7: 0400
[17501.835142] Stack:
[17501.836201]  881033ddbb80 88102527bc30 c042f834 
2710
[17501.837264]  88102527bbd0 8133d9dd c9000cd052a0 
88102527bc30
[17501.838325]  816a9c65 0001 88101bca8000 
810c4810
[17501.839388] Call Trace:
[17501.840446]  [] qedf_scsi_done+0x54/0x1d0 [qedf]
[17501.841504]  [] ? list_del+0xd/0x30
[17501.842537]  [] ? wait_for_completion_timeout+0x125/0x140
[17501.843560]  [] ? wake_up_state+0x20/0x20
[17501.844577]  [] qedf_initiate_cleanup+0x2e1/0x310 [qedf]
[17501.845587]  [] qedf_flush_active_ios+0x10e/0x260 [qedf]
[17501.846612]  [] qedf_cleanup_fcport+0x5f/0x370 [qedf]
[17501.847613]  [] qedf_rport_event_handler+0x398/0x950 [qedf]
[17501.848602]  [] ? dequeue_entity+0x11c/0x5d0
[17501.849581]  [] ? __internal_add_timer+0xab/0x130
[17501.850555]  [] ? dequeue_task_fair+0x41e/0x660
[17501.851528]  [] fc_rport_work+0xf4/0x6c0 [libfc]
[17501.852490]  [] process_one_work+0x17a/0x440
[17501.853446]  [] worker_thread+0x126/0x3c0

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf.h |  1 +
 drivers/scsi/qedf/qedf_els.c | 12 
 2 files changed, 13 insertions(+)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index c105a2e48ac1..996bd791783d 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -180,6 +180,7 @@ struct qedf_rport {
spinlock_t rport_lock;
 #define QEDF_RPORT_SESSION_READY 1
 #define QEDF_RPORT_UPLOADING_CONNECTION2
+#define QEDF_RPORT_IN_RESET 3
unsigned long flags;
unsigned long retry_delay_timestamp;
struct fc_rport *rport;
diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index aa22b11436ba..7024a2154ed1 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -322,6 +322,17 @@ void qedf_restart_rport(

[PATCH 09/21] qedf: Release RRQ reference correctly when RRQ command times out.

2018-04-25 Thread Chad Dupuis
When an RRQ request times out the reference is not getting decremented
correctly as there are still ELS commands leftover when we flush any
pending I/Os during offload:

[  281.788553] [:21:00.3]:[qedf_cmd_timeout:58]:4: ELS timeout, xid=0x96a.
...
[  281.788553] [:21:00.3]:[qedf_cmd_timeout:58]:4: ELS timeout, xid=0x96a.
[  281.788772] [:21:00.3]:[qedf_rrq_compl:182]:4: Entered.
[  281.788774] [:21:00.3]:[qedf_rrq_compl:200]:4: rrq_compl: orig io = 
c90004c556f8, orig xid = 0x81b, rrq_xid = 0x96a, refcount=1
...
[  331.448032] [:21:00.3]:[qedf_flush_els_req:1512]:4: Flushing ELS request 
xid=0x96a refcount=2.

The fix is to call kref_put on the rrq_req in case of timeout as the
timeout handler will call rrq_compl directly vs. a normal completion where
it is call from els_compl.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_els.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
index 7024a2154ed1..816f693ef4a8 100644
--- a/drivers/scsi/qedf/qedf_els.c
+++ b/drivers/scsi/qedf/qedf_els.c
@@ -201,6 +201,14 @@ static void qedf_rrq_compl(struct qedf_els_cb_arg *cb_arg)
kref_put(_io_req->refcount, qedf_release_cmd);
 
 out_free:
+   /*
+* Release a reference to the rrq request if we timed out as the
+* rrq completion handler is called directly from the timeout handler
+* and not from els_compl where the reference would have normally been
+* released.
+*/
+   if (rrq_req->event == QEDF_IOREQ_EV_ELS_TMO)
+   kref_put(_req->refcount, qedf_release_cmd);
kfree(cb_arg);
 }
 
-- 
2.12.3



[PATCH 11/21] qedf: Check if link is alraedy up when receiving a link up event from qed.

2018-04-25 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 64491ae60059..866989ccd66e 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -485,6 +485,11 @@ static void qedf_link_update(void *dev, struct 
qed_link_output *link)
struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
 
if (link->link_up) {
+   if (atomic_read(>link_state) == QEDF_LINK_UP) {
+   QEDF_INFO((>dbg_ctx), QEDF_LOG_DISC,
+   "Ignoring link up event as link is already up.\n");
+   return;
+   }
QEDF_ERR(&(qedf->dbg_ctx), "LINK UP (%d GB/s).\n",
link->speed / 1000);
 
-- 
2.12.3



[PATCH 12/21] qedf: Add task id to kref_get_unless_zero() debug messages when flushing requests.

2018-04-25 Thread Chad Dupuis
Helps to corroborate which requests we can't get reference on and if it's
real bug or not.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 78cbd126c7e5..589414f06376 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1445,8 +1445,8 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int 
lun)
rc = kref_get_unless_zero(_req->refcount);
if (!rc) {
QEDF_ERR(&(qedf->dbg_ctx),
-   "Could not get kref for io_req=0x%p.\n",
-   io_req);
+   "Could not get kref for ELS io_req=0x%p 
xid=0x%x.\n",
+   io_req, io_req->xid);
continue;
}
qedf_flush_els_req(qedf, io_req);
@@ -1472,7 +1472,7 @@ void qedf_flush_active_ios(struct qedf_rport *fcport, int 
lun)
rc = kref_get_unless_zero(_req->refcount);
if (!rc) {
QEDF_ERR(&(qedf->dbg_ctx), "Could not get kref for "
-   "io_req=0x%p\n", io_req);
+   "io_req=0x%p xid=0x%x\n", io_req, io_req->xid);
continue;
}
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
-- 
2.12.3



[PATCH 08/21] qedf: Honor priority from DCBX FCoE App tag.

2018-04-25 Thread Chad Dupuis
We currently hard code the priority in the 8021q tag to 3 for FCoE
traffic.  The vast majority of the time this is fine but if the priority
is something else besides 3, any VLAN ID comparison either in the
non-offload path or offload path will fail and cause dropped frames where
none are expected.

Change the behavior so that the driver default is 3 if we do not get any
DCBX convergence.

If DCBX does converge, then set the FIP/FCoE priority in the following
manner:

1. If the qedf_default_prio modparam is set use that
2. If the DCBX FCoE priority is not in range (0..7) use 3
3. Use the DCBX FCoE priority we get in the driver's DCBX handler

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf.h  |  1 +
 drivers/scsi/qedf/qedf_main.c | 52 +++
 2 files changed, 39 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 996bd791783d..1dffe21873d0 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -301,6 +301,7 @@ struct qedf_ctx {
 #define QEDF_FALLBACK_VLAN 1002
 #define QEDF_DEFAULT_PRIO  3
int vlan_id;
+   u8 prio;
struct qed_dev *cdev;
struct qed_dev_fcoe_info dev_info;
struct qed_int_info int_info;
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 8df151ec143d..64491ae60059 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -54,10 +54,10 @@ module_param_named(fallback_vlan, qedf_fallback_vlan, int, 
S_IRUGO);
 MODULE_PARM_DESC(fallback_vlan, " VLAN ID to try if fip vlan request fails "
"(default 1002).");
 
-static uint qedf_default_prio = QEDF_DEFAULT_PRIO;
+static int qedf_default_prio = -1;
 module_param_named(default_prio, qedf_default_prio, int, S_IRUGO);
-MODULE_PARM_DESC(default_prio, " Default 802.1q priority for FIP and FCoE"
-   " traffic (default 3).");
+MODULE_PARM_DESC(default_prio, " Override 802.1q priority for FIP and FCoE"
+   " traffic (value between 0 and 7, default 3).");
 
 uint qedf_dump_frames;
 module_param_named(dump_frames, qedf_dump_frames, int, S_IRUGO | S_IWUSR);
@@ -114,9 +114,9 @@ static struct kmem_cache *qedf_io_work_cache;
 void qedf_set_vlan_id(struct qedf_ctx *qedf, int vlan_id)
 {
qedf->vlan_id = vlan_id;
-   qedf->vlan_id |= qedf_default_prio << VLAN_PRIO_SHIFT;
+   qedf->vlan_id |= qedf->prio << VLAN_PRIO_SHIFT;
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, "Setting vlan_id=%04x "
-  "prio=%d.\n", vlan_id, qedf_default_prio);
+  "prio=%d.\n", vlan_id, qedf->prio);
 }
 
 /* Returns true if we have a valid vlan, false otherwise */
@@ -521,7 +521,7 @@ static void qedf_link_update(void *dev, struct 
qed_link_output *link)
"Starting link down tmo.\n");
atomic_set(>link_down_tmo_valid, 1);
}
-   qedf->vlan_id  = 0;
+   qedf->vlan_id = 0;
qedf_update_link_speed(qedf, link);
queue_delayed_work(qedf->link_update_wq, >link_update,
qedf_link_down_tmo * HZ);
@@ -532,6 +532,7 @@ static void qedf_link_update(void *dev, struct 
qed_link_output *link)
 static void qedf_dcbx_handler(void *dev, struct qed_dcbx_get *get, u32 
mib_type)
 {
struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
+   u8 tmp_prio;
 
QEDF_ERR(&(qedf->dbg_ctx), "DCBx event valid=%d enabled=%d fcoe "
"prio=%d.\n", get->operational.valid, get->operational.enabled,
@@ -547,6 +548,24 @@ static void qedf_dcbx_handler(void *dev, struct 
qed_dcbx_get *get, u32 mib_type)
 
atomic_set(>dcbx, QEDF_DCBX_DONE);
 
+   /*
+* Set the 8021q priority in the following manner:
+*
+* 1. If a modparam is set use that
+* 2. If the value is not between 0..7 use the default
+* 3. Use the priority we get from the DCBX app tag
+*/
+   tmp_prio = get->operational.app_prio.fcoe;
+   if (qedf_default_prio > -1)
+   qedf->prio = qedf_default_prio;
+   else if (tmp_prio < 0 || tmp_prio > 7) {
+   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
+   "FIP/FCoE prio %d out of range, setting to %d.\n",
+   tmp_prio, QEDF_DEFAULT_PRIO);
+   qedf->prio = QEDF_DEFAULT_PRIO;
+   } else
+   qedf->prio = tmp_prio;
+
if (atomic_read(>link_state) == QEDF_LINK_UP &&
!qedf_dcbx_no_wait) {

[PATCH 07/21] qedf: Add dcbx_not_wait module parameter so we won't wait for DCBX convergence to start discovery.

2018-04-25 Thread Chad Dupuis
This module parameter is to work around cases where we do not receive the DCBX
handler notification from qed but discovery is still possible if we send out
a FIP VLAN request irregardless of the DCBX state.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 1a58f4a9cdf9..8df151ec143d 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -89,6 +89,11 @@ module_param_named(retry_delay, qedf_retry_delay, bool, 
S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(retry_delay, " Enable/disable handling of FCP_RSP IU retry "
"delay handling (default off).");
 
+bool qedf_dcbx_no_wait;
+module_param_named(dcbx_no_wait, qedf_dcbx_no_wait, bool, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(dcbx_no_wait, " Do not wait for DCBX convergence to start "
+   "sending FIP VLAN requests on link up (Default: off).");
+
 static uint qedf_dp_module;
 module_param_named(dp_module, qedf_dp_module, uint, S_IRUGO);
 MODULE_PARM_DESC(dp_module, " bit flags control for verbose printk passed "
@@ -489,7 +494,8 @@ static void qedf_link_update(void *dev, struct 
qed_link_output *link)
atomic_set(>link_state, QEDF_LINK_UP);
qedf_update_link_speed(qedf, link);
 
-   if (atomic_read(>dcbx) == QEDF_DCBX_DONE) {
+   if (atomic_read(>dcbx) == QEDF_DCBX_DONE ||
+   qedf_dcbx_no_wait) {
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
 "DCBx done.\n");
if (atomic_read(>link_down_tmo_valid) > 0)
@@ -541,7 +547,8 @@ static void qedf_dcbx_handler(void *dev, struct 
qed_dcbx_get *get, u32 mib_type)
 
atomic_set(>dcbx, QEDF_DCBX_DONE);
 
-   if (atomic_read(>link_state) == QEDF_LINK_UP) {
+   if (atomic_read(>link_state) == QEDF_LINK_UP &&
+   !qedf_dcbx_no_wait) {
if (atomic_read(>link_down_tmo_valid) > 0)
queue_delayed_work(qedf->link_update_wq,
>link_recovery, 0);
-- 
2.12.3



Re: [PATCH 6/6] scsi: qedf: use correct strncpy() size

2018-02-07 Thread Chad Dupuis

On Fri, 2 Feb 2018, 8:12am, Arnd Bergmann wrote:

> gcc-8 warns during link-time optimization that the strncpy() call
> passes the size of the source buffer rather than the destination:
> 
> drivers/scsi/qedf/qedf_dbg.c: In function 'qedf_uevent_emit':
> include/linux/string.h:253: error: 'strncpy' specified bound depends on the 
> length of the source argument [-Werror=stringop-overflow=]
> 
> This changes it to strscpy() with the correct length, guaranteeing
> a properly nul-terminated string of the right size.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/scsi/qedf/qedf_dbg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reasonable security precaution.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH 4/6] scsi: qedf: fix LTO-enabled build

2018-02-07 Thread Chad Dupuis

On Fri, 2 Feb 2018, 8:12am, Arnd Bergmann wrote:

> The prototype for qedf_dbg_fops/qedf_debugfs_ops doesn't match the definition,
> which causes the final link to fail with link-time optimizations:
> 
> drivers/scsi/qedf/qedf_main.c:34: error: type of 'qedf_dbg_fops' does not 
> match original declaration [-Werror=lto-type-mismatch]
>  extern struct file_operations qedf_dbg_fops;
> 
> drivers/scsi/qedf/qedf_debugfs.c:443: note: 'qedf_dbg_fops' was previously 
> declared here
>  const struct file_operations qedf_dbg_fops[] = {
> 
> drivers/scsi/qedf/qedf_main.c:33: error: type of 'qedf_debugfs_ops' does not 
> match original declaration [-Werror=lto-type-mismatch]
>  extern struct qedf_debugfs_ops qedf_debugfs_ops;
> 
> drivers/scsi/qedf/qedf_debugfs.c:102: note: 'qedf_debugfs_ops' was previously 
> declared here
>  struct qedf_debugfs_ops qedf_debugfs_ops[] = {
> 
> This corrects the prototype and moves it into a shared header file where it
> belongs. The file operations can also be marked 'const' like the
> qedf_debugfs_ops.
> 
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/scsi/qedf/qedf_dbg.h | 17 ++---
>  drivers/scsi/qedf/qedf_debugfs.c |  6 +++---
>  drivers/scsi/qedf/qedf_main.c|  8 +++-
>  3 files changed, 16 insertions(+), 15 deletions(-)
> 

Thanks.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi: qedf: remove redundant initialization of 'fcport'

2018-02-06 Thread Chad Dupuis

On Tue, 6 Feb 2018, 9:03am, Colin King wrote:

> From: Colin Ian King <colin.k...@canonical.com>
> 
> Pointer fcport is initialized with a value that is never read, it is
> re-assigned a new value later on, hence the initialization is redundant
> and can be removed.
> 
> Cleans up clang warning:
> drivers/scsi/qedf/qedf_io.c:920:21: warning: Value stored to 'fcport'
> during its initialization is never read
> 
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
> ---
>  drivers/scsi/qedf/qedf_io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
> index b15e69586a36..50a50c4249d0 100644
> --- a/drivers/scsi/qedf/qedf_io.c
> +++ b/drivers/scsi/qedf/qedf_io.c
> @@ -917,7 +917,7 @@ qedf_queuecommand(struct Scsi_Host *host, struct 
> scsi_cmnd *sc_cmd)
>   struct qedf_ctx *qedf = lport_priv(lport);
>   struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
>   struct fc_rport_libfc_priv *rp = rport->dd_data;
> - struct qedf_rport *fcport = rport->dd_data;
> + struct qedf_rport *fcport;
>   struct qedf_ioreq *io_req;
>   int rc = 0;
>   int rval;
> 

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


[PATCH] bnx2fc: Fix check in SCSI completion handler when reqeust has already timed out.

2018-01-24 Thread Chad Dupuis
When a request times out we set the io_req flag BNX2FC_FLAG_IO_COMPL so
that if a subsequent completion comes in on that task ID we will ignore
it.  The issue is that in the check for this flag there is a missing
return so we will continue to process a request which may have already
been returned to the ownership of the SCSI layer.  This can cause
unpredictable results.

Solution is to add in the missing return.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 8e2f767147cb..5a645b8b9af1 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1889,6 +1889,7 @@ void bnx2fc_process_scsi_cmd_compl(struct bnx2fc_cmd 
*io_req,
/* we will not receive ABTS response for this IO */
BNX2FC_IO_DBG(io_req, "Timer context finished processing "
   "this scsi cmd\n");
+   return;
}
 
/* Cancel the timeout_work, as we received IO completion */
-- 
2.12.3



Re: [PATCH -next] scsi: qedf: Fix error return code in __qedf_probe()

2018-01-17 Thread Chad Dupuis

On Wed, 17 Jan 2018, 7:42am, Wei Yongjun wrote:

> Fix to return error code -ENOMEM from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Signed-off-by: Wei Yongjun <weiyongj...@huawei.com>
> ---
>  drivers/scsi/qedf/qedf_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 

Yeah, we should be returning -ENOMEM in those cases.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [RESEND PATCH 1/2] scsi: bnx2fc: Use zeroing allocator rather than allocator/memset

2018-01-10 Thread Chad Dupuis

On Tue, 9 Jan 2018, 4:06am, Himanshu Jha wrote:

> Use dma_zalloc_coherent instead of dma_alloc_coherent followed by
> memset 0.
> 
> Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci
> 
> Suggested-by: Luis R. Rodriguez <mcg...@kernel.org>
> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_hwi.c | 60 
> +---
>  drivers/scsi/bnx2fc/bnx2fc_tgt.c | 51 +++---
>  2 files changed, 47 insertions(+), 64 deletions(-)
> 

Sorry, didn't realize I needed to ack the resend.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH 7/9] scsi: bnx2fc: Use zeroing allocator rather than allocator/memset

2018-01-02 Thread Chad Dupuis
>cq_mem_size);
>  
>   /* Allocate and map RQ and RQ PBL */
>   tgt->rq_mem_size = tgt->max_rqes * BNX2FC_RQ_WQE_SIZE;
>   tgt->rq_mem_size = (tgt->rq_mem_size + (CNIC_PAGE_SIZE - 1)) &
>  CNIC_PAGE_MASK;
>  
> - tgt->rq = dma_alloc_coherent(>pcidev->dev, tgt->rq_mem_size,
> - >rq_dma, GFP_KERNEL);
> + tgt->rq = dma_zalloc_coherent(>pcidev->dev, tgt->rq_mem_size,
> +   >rq_dma, GFP_KERNEL);
>   if (!tgt->rq) {
>   printk(KERN_ERR PFX "unable to allocate RQ memory %d\n",
>   tgt->rq_mem_size);
>   goto mem_alloc_failure;
>   }
> - memset(tgt->rq, 0, tgt->rq_mem_size);
>  
>   tgt->rq_pbl_size = (tgt->rq_mem_size / CNIC_PAGE_SIZE) * sizeof(void *);
>   tgt->rq_pbl_size = (tgt->rq_pbl_size + (CNIC_PAGE_SIZE - 1)) &
>  CNIC_PAGE_MASK;
>  
> - tgt->rq_pbl = dma_alloc_coherent(>pcidev->dev, tgt->rq_pbl_size,
> -  >rq_pbl_dma, GFP_KERNEL);
> + tgt->rq_pbl = dma_zalloc_coherent(>pcidev->dev, tgt->rq_pbl_size,
> +   >rq_pbl_dma, GFP_KERNEL);
>   if (!tgt->rq_pbl) {
>   printk(KERN_ERR PFX "unable to allocate RQ PBL %d\n",
>   tgt->rq_pbl_size);
>   goto mem_alloc_failure;
>   }
>  
> - memset(tgt->rq_pbl, 0, tgt->rq_pbl_size);
>   num_pages = tgt->rq_mem_size / CNIC_PAGE_SIZE;
>   page = tgt->rq_dma;
>   pbl = (u32 *)tgt->rq_pbl;
> @@ -739,44 +735,43 @@ static int bnx2fc_alloc_session_resc(struct bnx2fc_hba 
> *hba,
>   tgt->xferq_mem_size = (tgt->xferq_mem_size + (CNIC_PAGE_SIZE - 1)) &
>  CNIC_PAGE_MASK;
>  
> - tgt->xferq = dma_alloc_coherent(>pcidev->dev, tgt->xferq_mem_size,
> - >xferq_dma, GFP_KERNEL);
> + tgt->xferq = dma_zalloc_coherent(>pcidev->dev,
> +  tgt->xferq_mem_size, >xferq_dma,
> +  GFP_KERNEL);
>   if (!tgt->xferq) {
>   printk(KERN_ERR PFX "unable to allocate XFERQ %d\n",
>   tgt->xferq_mem_size);
>   goto mem_alloc_failure;
>   }
> - memset(tgt->xferq, 0, tgt->xferq_mem_size);
>  
>   /* Allocate and map CONFQ & CONFQ PBL */
>   tgt->confq_mem_size = tgt->max_sqes * BNX2FC_CONFQ_WQE_SIZE;
>   tgt->confq_mem_size = (tgt->confq_mem_size + (CNIC_PAGE_SIZE - 1)) &
>  CNIC_PAGE_MASK;
>  
> - tgt->confq = dma_alloc_coherent(>pcidev->dev, tgt->confq_mem_size,
> - >confq_dma, GFP_KERNEL);
> + tgt->confq = dma_zalloc_coherent(>pcidev->dev,
> +  tgt->confq_mem_size, >confq_dma,
> +  GFP_KERNEL);
>   if (!tgt->confq) {
>   printk(KERN_ERR PFX "unable to allocate CONFQ %d\n",
>   tgt->confq_mem_size);
>   goto mem_alloc_failure;
>   }
> - memset(tgt->confq, 0, tgt->confq_mem_size);
>  
>   tgt->confq_pbl_size =
>   (tgt->confq_mem_size / CNIC_PAGE_SIZE) * sizeof(void *);
>   tgt->confq_pbl_size =
>   (tgt->confq_pbl_size + (CNIC_PAGE_SIZE - 1)) & CNIC_PAGE_MASK;
>  
> - tgt->confq_pbl = dma_alloc_coherent(>pcidev->dev,
> - tgt->confq_pbl_size,
> - >confq_pbl_dma, GFP_KERNEL);
> + tgt->confq_pbl = dma_zalloc_coherent(>pcidev->dev,
> +  tgt->confq_pbl_size,
> +  >confq_pbl_dma, GFP_KERNEL);
>   if (!tgt->confq_pbl) {
>   printk(KERN_ERR PFX "unable to allocate CONFQ PBL %d\n",
>   tgt->confq_pbl_size);
>   goto mem_alloc_failure;
>   }
>  
> - memset(tgt->confq_pbl, 0, tgt->confq_pbl_size);
>   num_pages = tgt->confq_mem_size / CNIC_PAGE_SIZE;
>   page = tgt->confq_dma;
>   pbl = (u32 *)tgt->confq_pbl;
> @@ -792,15 +787,14 @@ static int bnx2fc_alloc_session_resc(struct bnx2fc_hba 
> *hba,
>   /* Allocate and map ConnDB */
>   tgt->conn_db_mem_size = sizeof(struct fcoe_conn_db);
>  
> - tgt->conn_db = dma_alloc_coherent(>pcidev->dev,
> -   tgt->conn_db_mem_size,
> -   >conn_db_dma, GFP_KERNEL);
> + tgt->conn_db = dma_zalloc_coherent(>pcidev->dev,
> +tgt->conn_db_mem_size,
> +>conn_db_dma, GFP_KERNEL);
>   if (!tgt->conn_db) {
>   printk(KERN_ERR PFX "unable to allocate conn_db %d\n",
>   tgt->conn_db_mem_size);
>   goto mem_alloc_failure;
>   }
> - memset(tgt->conn_db, 0, tgt->conn_db_mem_size);
>  
>  
>   /* Allocate and map LCQ */
> @@ -808,15 +802,14 @@ static int bnx2fc_alloc_session_resc(struct bnx2fc_hba 
> *hba,
>   tgt->lcq_mem_size = (tgt->lcq_mem_size + (CNIC_PAGE_SIZE - 1)) &
>CNIC_PAGE_MASK;
>  
> - tgt->lcq = dma_alloc_coherent(>pcidev->dev, tgt->lcq_mem_size,
> -   >lcq_dma, GFP_KERNEL);
> + tgt->lcq = dma_zalloc_coherent(>pcidev->dev, tgt->lcq_mem_size,
> +>lcq_dma, GFP_KERNEL);
>  
>   if (!tgt->lcq) {
>   printk(KERN_ERR PFX "unable to allocate lcq %d\n",
>  tgt->lcq_mem_size);
>   goto mem_alloc_failure;
>   }
> - memset(tgt->lcq, 0, tgt->lcq_mem_size);
>  
>   tgt->conn_db->rq_prod = 0x8000;
>  
> 

Conversion looks sane.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


[PATCH] bnx2fc: Fix hung task messages when a cleanup response is not received during abort.

2017-11-15 Thread Chad Dupuis
If a cleanup task is not responded to while we are in bnx2fc_abts_cleanup, it
will hang the SCSI error handler since we use wait_for_completion instead of
wait_for_completion_timeout.  So, use wait_for_completion_timeout so that we
don't hang the SCSI error handler thread forever.

Fixes the call trace:

[183373.131468] INFO: task scsi_eh_16:110146 blocked for more than 120 seconds.
[183373.131469] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables 
this message.
[183373.131470] scsi_eh_16  D 88103f2fca14 0 110146  2 
0x0080
[183373.131472]  880855e77cb0 0046 881050654e70 
880855e77fd8
[183373.131474]  880855e77fd8 880855e77fd8 881050654e70 
88103f2fcb48
[183373.131475]  88103f2fcb50 7fff 881050654e70 
88103f2fca14
[183373.131477] Call Trace:
[183373.131479]  [] schedule+0x29/0x70
[183373.131481]  [] schedule_timeout+0x239/0x2d0
[183373.131486]  [] ? __dev_printk+0x3e/0x90
[183373.131487]  [] ? dev_printk+0x5d/0x80
[183373.131490]  [] wait_for_completion+0x116/0x170
[183373.131492]  [] ? wake_up_state+0x20/0x20
[183373.131494]  [] bnx2fc_abts_cleanup+0x3d/0x62 [bnx2fc]
[183373.131497]  [] bnx2fc_eh_abort+0x470/0x580 [bnx2fc]
[183373.131500]  [] scsi_error_handler+0x59f/0x8b0
[183373.131501]  [] ? scsi_eh_get_sense+0x250/0x250
[183373.131503]  [] kthread+0xcf/0xe0
[183373.131505]  [] ? kthread_create_on_node+0x140/0x140
[183373.131507]  [] ret_from_fork+0x58/0x90
[183373.131509]  [] ? kthread_create_on_node+0x140/0x140

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 5b6153f23f01..2cbb5be98ecb 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1084,24 +1084,35 @@ static int bnx2fc_abts_cleanup(struct bnx2fc_cmd 
*io_req)
 {
struct bnx2fc_rport *tgt = io_req->tgt;
int rc = SUCCESS;
+   unsigned int time_left;
 
io_req->wait_for_comp = 1;
bnx2fc_initiate_cleanup(io_req);
 
spin_unlock_bh(>tgt_lock);
 
-   wait_for_completion(_req->tm_done);
-
+   /*
+* Can't wait forever on cleanup response lest we let the SCSI error
+* handler wait forever
+*/
+   time_left = wait_for_completion_timeout(_req->tm_done,
+   BNX2FC_FW_TIMEOUT);
io_req->wait_for_comp = 0;
+   if (!time_left)
+   BNX2FC_IO_DBG(io_req, "%s(): Wait for cleanup timed out.\n",
+   __func__);
+
/*
-* release the reference taken in eh_abort to allow the
-* target to re-login after flushing IOs
+* Release reference held by SCSI command the cleanup completion
+* hits the BNX2FC_CLEANUP case in bnx2fc_process_cq_compl() and
+* thus the SCSI command is not returnedi by bnx2fc_scsi_done().
 */
kref_put(_req->refcount, bnx2fc_cmd_release);
 
spin_lock_bh(>tgt_lock);
return rc;
 }
+
 /**
  * bnx2fc_eh_abort - eh_abort_handler api to abort an outstanding
  * SCSI command
@@ -1118,6 +1129,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
struct fc_lport *lport;
struct bnx2fc_rport *tgt;
int rc;
+   unsigned int time_left;
 
rc = fc_block_scsi_eh(sc_cmd);
if (rc)
@@ -1194,6 +1206,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
if (cancel_delayed_work(_req->timeout_work))
kref_put(_req->refcount,
 bnx2fc_cmd_release); /* drop timer hold */
+   /*
+* We don't want to hold off the upper layer timer so simply
+* cleanup the command and return that I/O was successfully
+* aborted.
+*/
rc = bnx2fc_abts_cleanup(io_req);
/* This only occurs when an task abort was requested while ABTS
   is in progress.  Setting the IO_CLEANUP flag will skip the
@@ -1201,7 +1218,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
   was a result from the ABTS request rather than the CLEANUP
   request */
set_bit(BNX2FC_FLAG_IO_CLEANUP, _req->req_flags);
-   goto out;
+   goto done;
}
 
/* Cancel the current timer running on this io_req */
@@ -1221,7 +1238,11 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
}
spin_unlock_bh(>tgt_lock);
 
-   wait_for_completion(_req->tm_done);
+   /* Wait 2 * RA_TOV + 1 to be sure timeout function hasn't fired */
+   time_left = wait_for_completion_timeout(_req->tm_done,
+   (2 * rp->r_a_tov + 1) * HZ);
+   if (time_left)
+  

Re: [PATCH 1/1] scsi: bnx: use setup_timer

2017-09-21 Thread Chad Dupuis

On Thu, 21 Sep 2017, 7:47am, Allen Pais wrote:

> Use setup_timer function instead of initializing timer with the
> function and data fields.
> 
> Signed-off-by: Allen Pais <allen.l...@gmail.com>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index 6844ba3..a056211 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -1946,11 +1946,10 @@ static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba)
>  {
>   if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, >flags)) {
>   if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) {
> - init_timer(>destroy_timer);
> + setup_timer(>destroy_timer, bnx2fc_destroy_timer,
> + (unsigned long)hba);
>   hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT +
>   jiffies;
> - hba->destroy_timer.function = bnx2fc_destroy_timer;
> - hba->destroy_timer.data = (unsigned long)hba;
>   add_timer(>destroy_timer);
>   wait_event_interruptible(hba->destroy_wait,
>   test_bit(BNX2FC_FLAG_DESTROY_CMPL,
> 

The title of the patch should be fixed up since the driver is 'bnx2fc'.  
But besides that nit the patch looks good.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi_transport_fc: set scsi_target_id upon rescan

2017-09-20 Thread Chad Dupuis

On Wed, 20 Sep 2017, 2:58am, Hannes Reinecke wrote:

> From: Hannes Reinecke <h...@suse.com>
> 
> When an rport is found in the bindings array there is no guarantee that
> it had been a target port, so we need to call fc_remote_port_rolechg()
> here to ensure the scsi_target_id is set correctly.
> Otherwise the port will never be scanned.
> 
> Signed-off-by: Hannes Reinecke <h...@suse.com>
> ---
>  drivers/scsi/scsi_transport_fc.c | 11 +--
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 

Verified that port is scanned after applying this patch.

Tested-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi: qedf: Fix a potential NULL pointer dereference

2017-08-23 Thread Chad Dupuis

On Sun, 20 Aug 2017, 1:09pm, Christophe JAILLET wrote:

> At the beginning of 'qedf_srr_compl()' and of 'qedf_rec_compl()', we check
> if 'orig_io_req' is NULL. If this happens, a NULL pointer dereference will
> occur in the error handling path.
> 
> Fix it by adding an additionnal label in the error handling path in order
> to avoid this NULL pointer dereference.
> 
> Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver 
> framework.")
> Signed-off-by: Christophe JAILLET <christophe.jail...@wanadoo.fr>
> ---
>  drivers/scsi/qedf/qedf_els.c | 14 --
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
> index eb07f1de8afa..59c18ca4cda9 100644
> --- a/drivers/scsi/qedf/qedf_els.c
> +++ b/drivers/scsi/qedf/qedf_els.c
> @@ -489,7 +489,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
>  
>   /* If a SRR times out, simply free resources */
>   if (srr_req->event == QEDF_IOREQ_EV_ELS_TMO)
> - goto out_free;
> + goto out_put;
>  
>   /* Normalize response data into struct fc_frame */
>   mp_req = &(srr_req->mp_req);
> @@ -501,7 +501,7 @@ static void qedf_srr_compl(struct qedf_els_cb_arg *cb_arg)
>   if (!fp) {
>   QEDF_ERR(&(qedf->dbg_ctx),
>   "fc_frame_alloc failure.\n");
> - goto out_free;
> + goto out_put;
>   }
>  
>   /* Copy frame header from firmware into fp */
> @@ -526,9 +526,10 @@ static void qedf_srr_compl(struct qedf_els_cb_arg 
> *cb_arg)
>   }
>  
>   fc_frame_free(fp);
> -out_free:
> +out_put:
>   /* Put reference for original command since SRR completed */
>   kref_put(_io_req->refcount, qedf_release_cmd);
> +out_free:
>   kfree(cb_arg);
>  }
>  
> @@ -780,7 +781,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>  
>   /* If a REC times out, free resources */
>   if (rec_req->event == QEDF_IOREQ_EV_ELS_TMO)
> - goto out_free;
> + goto out_put;
>  
>   /* Normalize response data into struct fc_frame */
>   mp_req = &(rec_req->mp_req);
> @@ -792,7 +793,7 @@ static void qedf_rec_compl(struct qedf_els_cb_arg *cb_arg)
>   if (!fp) {
>   QEDF_ERR(&(qedf->dbg_ctx),
>   "fc_frame_alloc failure.\n");
> - goto out_free;
> + goto out_put;
>   }
>  
>   /* Copy frame header from firmware into fp */
> @@ -884,9 +885,10 @@ static void qedf_rec_compl(struct qedf_els_cb_arg 
> *cb_arg)
>  
>  out_free_frame:
>   fc_frame_free(fp);
> -out_free:
> +out_put:
>   /* Put reference for original command since REC completed */
>   kref_put(_io_req->refcount, qedf_release_cmd);
> +out_free:
>   kfree(cb_arg);
>  }
>  
> 

Thanks for the catch.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


[PATCH 6/6] qedf: Update driver version to 8.20.5.0.

2017-08-15 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_version.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_version.h b/drivers/scsi/qedf/qedf_version.h
index 6fa442061c32..397b3b8ee51a 100644
--- a/drivers/scsi/qedf/qedf_version.h
+++ b/drivers/scsi/qedf/qedf_version.h
@@ -7,9 +7,9 @@
  *  this source tree.
  */
 
-#define QEDF_VERSION   "8.18.22.0"
+#define QEDF_VERSION   "8.20.5.0"
 #define QEDF_DRIVER_MAJOR_VER  8
-#define QEDF_DRIVER_MINOR_VER  18
-#define QEDF_DRIVER_REV_VER22
+#define QEDF_DRIVER_MINOR_VER  20
+#define QEDF_DRIVER_REV_VER5
 #define QEDF_DRIVER_ENG_VER0
 
-- 
2.12.3



[PATCH 5/6] qedf: Fix up modinfo parameter name for 'debug' in modinfo output.

2017-08-15 Thread Chad Dupuis
Because we were passing 'qedf_debug' instead of 'debug' to the
MODULE_PARM_DESC() macro, modinfo listed the parameter name as 'qedf_debug'
instead of it's proper name 'debug'.  Correct the parameter name.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 24e8d2ab099c..e192bde73147 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(dev_loss_tmo,  " dev_loss_tmo setting for 
attached "
 
 uint qedf_debug = QEDF_LOG_INFO;
 module_param_named(debug, qedf_debug, uint, S_IRUGO);
-MODULE_PARM_DESC(qedf_debug, " Debug mask. Pass '1' to enable default 
debugging"
+MODULE_PARM_DESC(debug, " Debug mask. Pass '1' to enable default debugging"
" mask");
 
 static uint qedf_fipvlan_retries = 30;
-- 
2.12.3



[PATCH 4/6] qedf: Covert single-threaded workqueues to regular workqueues.

2017-08-15 Thread Chad Dupuis
There is no ordering required for the various workqueues the driver uses
so they can be converted to regular workqueues.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 0520dd1be749..24e8d2ab099c 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2987,7 +2987,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
sprintf(host_buf, "qedf_%u_link",
qedf->lport->host->host_no);
-   qedf->link_update_wq = create_singlethread_workqueue(host_buf);
+   qedf->link_update_wq = create_workqueue(host_buf);
INIT_DELAYED_WORK(>link_update, qedf_handle_link_update);
INIT_DELAYED_WORK(>link_recovery, qedf_link_recovery);
 
@@ -3157,7 +3157,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
/* Start LL2 processing thread */
snprintf(host_buf, 20, "qedf_%d_ll2", host->host_no);
qedf->ll2_recv_wq =
-   create_singlethread_workqueue(host_buf);
+   create_workqueue(host_buf);
if (!qedf->ll2_recv_wq) {
QEDF_ERR(&(qedf->dbg_ctx), "Failed to LL2 workqueue.\n");
goto err7;
@@ -3199,7 +3199,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
sprintf(host_buf, "qedf_%u_timer", qedf->lport->host->host_no);
qedf->timer_work_queue =
-   create_singlethread_workqueue(host_buf);
+   create_workqueue(host_buf);
if (!qedf->timer_work_queue) {
QEDF_ERR(&(qedf->dbg_ctx), "Failed to start timer "
  "workqueue.\n");
@@ -3210,7 +3210,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
if (mode != QEDF_MODE_RECOVERY) {
sprintf(host_buf, "qedf_%u_dpc",
qedf->lport->host->host_no);
-   qedf->dpc_wq = create_singlethread_workqueue(host_buf);
+   qedf->dpc_wq = create_workqueue(host_buf);
}
 
/*
-- 
2.12.3



[PATCH 3/6] qedf: Corrent VLAN tag insertion in fallback VLAN case.

2017-08-15 Thread Chad Dupuis
Currently in the driver the qedf_ctx attribute vlan_hw_insert is used to
which whether to insert a VLAN tag in FIP frames (except for FIP VLAN
request which is explicitly sent out untagged at least from the driver's
point of view).

When we receive a FIP VLAN response, we set qedf->vlan_hw_insert to 0 which
makes the qedf_fip_send function insert the VLAN.  However when we exhaust
our FIP VLAN retries, we do not set qedf->vlan_hw_insert to 0 which means
that the driver will not tag the FIP frame with the correct VLAN ID.  The
result that was observed on the wire is that some entity either int he LL2
or L2 firmware is adding a NULL VLAN tag which can cause FIP solicitation
to fail.

The offload FCoE frame function, qedf_xmit, does not use the vlan_hw_insert
attribute to decide whether to tag frames with the FIP/FCoE VLAN.  Instead
it unilaterially tags the offload frames with the VLAN ID stored in
qedf->vlan_id. This is the correct behavior so the driver can guarantee
that non-offload FIP frames go out with the correct VLAN ID.

Also use the Linux network layer helpers instead of doing the VLAN insert
manually.

Also fix setting the fallback VLAN so that it used the module parameter and
is not hardcoded to 1002 (though 1002 is the default).

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf.h  |  1 -
 drivers/scsi/qedf/qedf_fip.c  | 18 +++---
 drivers/scsi/qedf/qedf_main.c | 12 
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index e05ec331557b..9bf7b227e69a 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -300,7 +300,6 @@ struct qedf_ctx {
 #define QEDF_FALLBACK_VLAN 1002
 #define QEDF_DEFAULT_PRIO  3
int vlan_id;
-   uint vlan_hw_insert:1;
struct qed_dev *cdev;
struct qed_dev_fcoe_info dev_info;
struct qed_int_info int_info;
diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c
index 28ce0f7ffc7b..773558fc0697 100644
--- a/drivers/scsi/qedf/qedf_fip.c
+++ b/drivers/scsi/qedf/qedf_fip.c
@@ -108,7 +108,6 @@ void qedf_fip_send(struct fcoe_ctlr *fip, struct sk_buff 
*skb)
 {
struct qedf_ctx *qedf = container_of(fip, struct qedf_ctx, ctlr);
struct ethhdr *eth_hdr;
-   struct vlan_ethhdr *vlan_hdr;
struct fip_header *fiph;
u16 op, vlan_tci = 0;
u8 sub;
@@ -124,16 +123,14 @@ void qedf_fip_send(struct fcoe_ctlr *fip, struct sk_buff 
*skb)
op = ntohs(fiph->fip_op);
sub = fiph->fip_subcode;
 
-   if (!qedf->vlan_hw_insert) {
-   vlan_hdr = skb_push(skb, sizeof(*vlan_hdr) - sizeof(*eth_hdr));
-   memcpy(vlan_hdr, eth_hdr, 2 * ETH_ALEN);
-   vlan_hdr->h_vlan_proto = htons(ETH_P_8021Q);
-   vlan_hdr->h_vlan_encapsulated_proto = eth_hdr->h_proto;
-   vlan_hdr->h_vlan_TCI = vlan_tci =  htons(qedf->vlan_id);
-   }
+   /*
+* Add VLAN tag to non-offload FIP frame based on current stored VLAN
+* for FIP/FCoE traffic.
+*/
+   __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), qedf->vlan_id);
 
-   /* Update eth_hdr since we added a VLAN tag */
-   eth_hdr = (struct ethhdr *)skb_mac_header(skb);
+   /* Get VLAN ID from skb for printing purposes */
+   __vlan_hwaccel_get_tag(skb, _tci);
 
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_LL2, "FIP frame send: "
"dest=%pM op=%x sub=%x vlan=%04x.", eth_hdr->h_dest, op, sub,
@@ -174,7 +171,6 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff 
*skb)
/* Handle FIP VLAN resp in the driver */
if (op == FIP_OP_VLAN && sub == FIP_SC_VL_NOTE) {
qedf_fcoe_process_vlan_resp(qedf, skb);
-   qedf->vlan_hw_insert = 0;
kfree_skb(skb);
} else if (op == FIP_OP_CTRL && sub == FIP_SC_CLR_VLINK) {
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, "Clear virtual "
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 1df80aa03da1..0520dd1be749 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -164,7 +164,7 @@ static void qedf_handle_link_update(struct work_struct 
*work)
QEDF_WARN(&(qedf->dbg_ctx), "Did not receive FIP VLAN "
   "response, falling back to default VLAN %d.\n",
   qedf_fallback_vlan);
-   qedf_set_vlan_id(qedf, QEDF_FALLBACK_VLAN);
+   qedf_set_vlan_id(qedf, qedf_fallback_vlan);
 
/*
 * Zero out data_src_addr so we'll update it with the new
@@ -361,8 +361,9 @@ static void qedf_link_recovery(struct work_struct *work)
/* Since the link when down and up to verify which vlan we're on */
  

[PATCH 1/6] qedf: Set WWNN and WWPN based on values from qed.

2017-08-15 Thread Chad Dupuis
If dev_info.wwpn and dev_info.wwnn are set by qed use these values to set
the WWNs of the port. Otherwise fall back to the old method using
fcoe_wwn_from_mac().

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf_main.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 1d13c9ca517d..9744b6aa2a03 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3056,9 +3056,24 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, "MAC address is %pM.\n",
   qedf->mac);
 
-   /* Set the WWNN and WWPN based on the MAC address */
-   qedf->wwnn = fcoe_wwn_from_mac(qedf->mac, 1, 0);
-   qedf->wwpn = fcoe_wwn_from_mac(qedf->mac, 2, 0);
+   /*
+* Set the WWNN and WWPN in the following way:
+*
+* If the info we get from qed is non-zero then use that to set the
+* WWPN and WWNN. Otherwise fall back to use fcoe_wwn_from_mac() based
+* on the MAC address.
+*/
+   if (qedf->dev_info.wwnn != 0 && qedf->dev_info.wwpn != 0) {
+   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
+   "Setting WWPN and WWNN from qed dev_info.\n");
+   qedf->wwnn = qedf->dev_info.wwnn;
+   qedf->wwpn = qedf->dev_info.wwpn;
+   } else {
+   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
+   "Setting WWPN and WWNN using fcoe_wwn_from_mac().\n");
+   qedf->wwnn = fcoe_wwn_from_mac(qedf->mac, 1, 0);
+   qedf->wwpn = fcoe_wwn_from_mac(qedf->mac, 2, 0);
+   }
QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,  "WWNN=%016llx "
   "WWPN=%016llx.\n", qedf->wwnn, qedf->wwpn);
 
-- 
2.12.3



[PATCH 0/6] Update qedf to version 8.20.5.0.

2017-08-15 Thread Chad Dupuis
From: "Chad Dupuis" <chad.dup...@cavium.com>

Hi Martin,

Please apply the following patches at your earliest convenience.

Thanks,
Chad

Chad Dupuis (6):
  qedf: Set WWNN and WWPN based on values from qed.
  qedf: Use granted MAC from the FCF for the FCoE source address if it
is available.
  qedf: Corrent VLAN tag insertion in fallback VLAN case.
  qedf: Covert single-threaded workqueues to regular workqueues.
  qedf: Fix up modinfo parameter name for 'debug' in modinfo output.
  qedf: Update driver version to 8.20.5.0.

 drivers/scsi/qedf/qedf.h |   2 -
 drivers/scsi/qedf/qedf_fip.c |  35 +++---
 drivers/scsi/qedf/qedf_main.c| 102 +++
 drivers/scsi/qedf/qedf_version.h |   6 +--
 4 files changed, 92 insertions(+), 53 deletions(-)

-- 
2.12.3



[PATCH 2/6] qedf: Use granted MAC from the FCF for the FCoE source address if it is available.

2017-08-15 Thread Chad Dupuis
Currently in the driver we've been using the fc_fcoe_set_mac() function to
set the source MAC for FCoE traffic.  This works well in most cases as it
uses the spec. default FCF-MAC.  However, if the administrator changes the
FCF-MAC switch, then any FCoE traffic we send will be dropped by the
switch.

Instead we should check the granted MAC from the FLOGI payload and use that
address if it is present.  Otherwise, fall back to using the the default
FCF-MAC and the fabric ID of the port as the FCoE MAC address.

Once this address is known we need to set it when doing non-offload
traffic, offload traffic and setting the data_src_address libfcoe uses for
FIP keep alive messages.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/qedf/qedf.h  |  1 -
 drivers/scsi/qedf/qedf_fip.c  | 17 -
 drivers/scsi/qedf/qedf_main.c | 59 +--
 3 files changed, 51 insertions(+), 26 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 351f06dfc5a0..e05ec331557b 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -443,7 +443,6 @@ extern void qedf_cmd_mgr_free(struct qedf_cmd_mgr *cmgr);
 extern int qedf_queuecommand(struct Scsi_Host *host,
struct scsi_cmnd *sc_cmd);
 extern void qedf_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb);
-extern void qedf_update_src_mac(struct fc_lport *lport, u8 *addr);
 extern u8 *qedf_get_src_mac(struct fc_lport *lport);
 extern void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff *skb);
 extern void qedf_fcoe_send_vlan_req(struct qedf_ctx *qedf);
diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c
index aefd24ca9604..28ce0f7ffc7b 100644
--- a/drivers/scsi/qedf/qedf_fip.c
+++ b/drivers/scsi/qedf/qedf_fip.c
@@ -242,26 +242,9 @@ void qedf_fip_recv(struct qedf_ctx *qedf, struct sk_buff 
*skb)
}
 }
 
-void qedf_update_src_mac(struct fc_lport *lport, u8 *addr)
-{
-   struct qedf_ctx *qedf = lport_priv(lport);
-
-   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
-   "Setting data_src_addr=%pM.\n", addr);
-   ether_addr_copy(qedf->data_src_addr, addr);
-}
-
 u8 *qedf_get_src_mac(struct fc_lport *lport)
 {
-   u8 mac[ETH_ALEN];
-   u8 port_id[3];
struct qedf_ctx *qedf = lport_priv(lport);
 
-   /* We need to use the lport port_id to create the data_src_addr */
-   if (is_zero_ether_addr(qedf->data_src_addr)) {
-   hton24(port_id, lport->port_id);
-   fc_fcoe_set_mac(mac, port_id);
-   qedf->ctlr.update_mac(lport, mac);
-   }
return qedf->data_src_addr;
 }
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 9744b6aa2a03..1df80aa03da1 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -187,6 +188,50 @@ static void qedf_handle_link_update(struct work_struct 
*work)
}
 }
 
+#defineQEDF_FCOE_MAC_METHOD_GRANGED_MAC1
+#define QEDF_FCOE_MAC_METHOD_FCF_MAP   2
+#define QEDF_FCOE_MAC_METHOD_FCOE_SET_MAC  3
+static void qedf_set_data_src_addr(struct qedf_ctx *qedf, struct fc_frame *fp)
+{
+   u8 *granted_mac;
+   struct fc_frame_header *fh = fc_frame_header_get(fp);
+   u8 fc_map[3];
+   int method = 0;
+
+   /* Get granted MAC address from FIP FLOGI payload */
+   granted_mac = fr_cb(fp)->granted_mac;
+
+   /*
+* We set the source MAC for FCoE traffic based on the Granted MAC
+* address from the switch.
+*
+* If granted_mac is non-zero, we used that.
+* If the granted_mac is zeroed out, created the FCoE MAC based on
+* the sel_fcf->fc_map and the d_id fo the FLOGI frame.
+* If sel_fcf->fc_map is 0 then we use the default FCF-MAC plus the
+* d_id of the FLOGI frame.
+*/
+   if (!is_zero_ether_addr(granted_mac)) {
+   ether_addr_copy(qedf->data_src_addr, granted_mac);
+   method = QEDF_FCOE_MAC_METHOD_GRANGED_MAC;
+   } else if (qedf->ctlr.sel_fcf->fc_map != 0) {
+   hton24(fc_map, qedf->ctlr.sel_fcf->fc_map);
+   qedf->data_src_addr[0] = fc_map[0];
+   qedf->data_src_addr[1] = fc_map[1];
+   qedf->data_src_addr[2] = fc_map[2];
+   qedf->data_src_addr[3] = fh->fh_d_id[0];
+   qedf->data_src_addr[4] = fh->fh_d_id[1];
+   qedf->data_src_addr[5] = fh->fh_d_id[2];
+   method = QEDF_FCOE_MAC_METHOD_FCF_MAP;
+   } else {
+   fc_fcoe_set_mac(qedf->data_src_addr, fh->fh_d_id);
+   method = QEDF_FCOE_MAC_METHOD_FCOE_SET_MAC;
+   }
+
+   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
+   "

Re: [PATCH v2] scsi: qedf: Limit number of CQs

2017-07-25 Thread Chad Dupuis

On Tue, 25 Jul 2017, 5:19am, Thomas Bogendoerfer wrote:

> From: Thomas Bogendoerfer <tbogendoer...@suse.de>
> 
> FCOE offloading failed with:
> 
> [qed_sp_fcoe_func_start:150(sp-0-3b:00.02)]Cannot satisfy CQ amount. CQs
>requested 8, CQs available 6. Aborting function start
> [qed_fcoe_start:821()]Failed to start fcoe
> [__qedf_probe:3041]:6: Cannot start FCoE function.
> 
> The reason is a newly introduced check in the qed main part. This change
> also provides the information about how many CQs are available, so we
> simply limit the number of requested CQs..
> 
> Fixes: 3c5da9427802 ("qed: Share additional information with qedf")
> Signed-off-by: Thomas Bogendoerfer <tbogendoer...@suse.de>
> ---
> 
> Changes in v2:
> - integrated suggested change from Chad Dupuis
> 
>  drivers/scsi/qedf/qedf.h  |  3 ++-
>  drivers/scsi/qedf/qedf_main.c | 20 +---
>  2 files changed, 11 insertions(+), 12 deletions(-)
> 

V2 looks good.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [patch 0/5] scsi/bnx2*: Plug hotplug race, correct locking and simplify hotplug code

2017-07-25 Thread Chad Dupuis

On Mon, 24 Jul 2017, 6:52am, Thomas Gleixner wrote:

> The conversion of the cpu hotplug locking to a percpu rwsem does not longer
> allow recursive locking of the hotplug lock.
> 
> The BNX2I and BNX2FC drivers install/remove hotplug states with the hotplug
> lock held. The install/removal code acquired the hotplug lock as well.
> 
> While looking into this, I noticed an interesting hotplug race in the
> BNX2FC driver, which could result in dereferencing a NULL pointer or freed
> and potentially reused memory.
> 
> The following series addresses these problems and as a final step on top it
> simplifies the hotplug code in both drivers.
> 
> Thanks,
> 
>   tglx
> 
> 
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   68 
> --
>  drivers/scsi/bnx2fc/bnx2fc_hwi.c  |   45 -
>  drivers/scsi/bnx2i/bnx2i_init.c   |   64 ---
>  include/linux/cpuhotplug.h|2 -
>  4 files changed, 53 insertions(+), 126 deletions(-)
> 

We tested the series and everything was fine.  Ack to the series.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi: qedf: Limit number of CQs

2017-07-20 Thread Chad Dupuis

On Thu, 13 Jul 2017, 12:19pm, Thomas Bogendoerfer wrote:

> From: Thomas Bogendoerfer 
> 
> FCOE offloading on qedf devices fails with:
> 
> [qed_sp_fcoe_func_start:150(sp-0-3b:00.02)]Cannot satisfy CQ amount. CQs
>requested 8, CQs available 6. Aborting function start
> [qed_fcoe_start:821()]Failed to start fcoe
> [__qedf_probe:3041]:6: Cannot start FCoE function.
> 
> The reason is a newly introduced check in the qed main part. This change
> also provides the information about how many CQs are available, so we
> simply limit the number of requested CQs.
> 
> Fixes: 3c5da9427802 qed: Share additional information with qedf
> Signed-off-by: Thomas Bogendoerfer 
> ---
>  drivers/scsi/qedf/qedf_main.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index b58bba4604e8..5778218734fa 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -2765,6 +2765,8 @@ static int qedf_set_fcoe_pf_param(struct qedf_ctx *qedf)
>*/
>   qedf->num_queues = min((unsigned int)QEDF_MAX_NUM_CQS,
>   num_online_cpus());
> + /* limit to acutal available CQs */
> + qedf->num_queues = min(qedf->num_queues, qedf->dev_info.num_cqs);

We do need to account for the case where there are less CPUs than CQs.  
Does this look reasonable:

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 4d03892..3c1d6fd 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -528,7 +528,7 @@ struct fip_vlan {
 #define QEDF_WRITE(1 << 0)
 #define MAX_FIBRE_LUNS 0x
 
-#define QEDF_MAX_NUM_CQS   8
+#define MIN_NUM_CPUS_MSIX(x)   min((u32)x->dev_info.num_cqs, 
num_online_cpus())
 
 /*
  * PCI function probe defines
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 937df5b..f4facd3 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2760,11 +2760,9 @@ static int qedf_set_fcoe_pf_param(struct qedf_ctx 
*qedf)
 * we allocation is the minimum off:
 *
 * Number of CPUs
-* Number of MSI-X vectors
-* Max number allocated in hardware (QEDF_MAX_NUM_CQS)
+* Number allocated by qed for our PCI function
 */
-   qedf->num_queues = min((unsigned int)QEDF_MAX_NUM_CQS,
-   num_online_cpus());
+   qedf->num_queues = MIN_NUM_CPUS_MSIX(qedf);

Otherwise this patch looks good.

>  
>   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, "Number of CQs is %d.\n",
>  qedf->num_queues);
> @@ -2962,6 +2964,13 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
>   goto err1;
>   }
>  
> + /* Learn information crucial for qedf to progress */
> + rc = qed_ops->fill_dev_info(qedf->cdev, >dev_info);
> + if (rc) {
> + QEDF_ERR(&(qedf->dbg_ctx), "Failed to dev info.\n");
> + goto err1;
> + }
> +
>   /* queue allocation code should come here
>* order should be
>*  slowpath_start
> @@ -2977,13 +2986,6 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
>   }
>   qed_ops->common->update_pf_params(qedf->cdev, >pf_params);
>  
> - /* Learn information crucial for qedf to progress */
> - rc = qed_ops->fill_dev_info(qedf->cdev, >dev_info);
> - if (rc) {
> - QEDF_ERR(&(qedf->dbg_ctx), "Failed to dev info.\n");
> - goto err1;
> - }
> -
>   /* Record BDQ producer doorbell addresses */
>   qedf->bdq_primary_prod = qedf->dev_info.primary_dbq_rq_addr;
>   qedf->bdq_secondary_prod = qedf->dev_info.secondary_bdq_rq_addr;
> 


Re: [PATCH 1/5] scsi: bnx2i: convert to workqueue

2017-07-07 Thread Chad Dupuis


On Fri, 7 Jul 2017, 9:14am, Sebastian Andrzej Siewior wrote:

> On 2017-06-29 15:57:56 [+0200], Johannes Thumshirn wrote:
> > So here we are again,
> > Tested-by: Johannes Thumshirn 
> > 
> > FCoE will follow as soon as my setup can speak FCoE again.
> 
> So it all looks good, doesn't it? Chad never responded to my question
> on his patch. I still doubt that it fixes the problem he observed.
> 
> Sebastian
> 

What was the question?  My observation is that the patch I proposed fixed 
the issue we saw on testing the patch set.  With that small change 
(essentially modulo by the number of active CPUs vs. the total number) 
your patch set worked ok.


Re: [PATCH][V2] scsi: qedf: fix spelling mistake: "offlading" -> "offloading"

2017-07-05 Thread Chad Dupuis

On Mon, 3 Jul 2017, 3:21pm, Colin King wrote:

> From: Colin Ian King <colin.k...@canonical.com>
> 
> Trivial fix to spelling mistake in QEDF_INFO message and 
> remove duplicated "since" (thanks to Tyrel Datwyler for spotting
> the latter issue).
> 
> Signed-off-by: Colin Ian King <colin.k...@canonical.com>
> ---
>  drivers/scsi/qedf/qedf_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index b58bba4604e8..7786c97e033f 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -1227,7 +1227,7 @@ static void qedf_rport_event_handler(struct fc_lport 
> *lport,
>  
>   if (rdata->spp_type != FC_TYPE_FCP) {
>   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
> - "Not offlading since since spp type isn't FCP\n");
> + "Not offloading since spp type isn't FCP\n");
>   break;
>   }
>   if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) {
> 

Thanks.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH 19/28] qedf: drop bus reset handler

2017-06-28 Thread Chad Dupuis

On Wed, 28 Jun 2017, 10:37am, Christoph Hellwig wrote:

> 
> sg_reset / SG_SCSI_RESET are designed to escalatae to to the bigger
> hammers if the method isn't implemented or doesn't succeed.
> 
> Use the -N / --no-esc option to disable that.  I wish that behavior had
> been the default from the beginning, but we can't fix that anymore.
> 

Yeah, for a sg_reset prespective that would be the better behavior.  I 
removed the bus_reset handler and used the --no-esc parameter which causes 
sg_reset to behave more reasonably:

# sg_reset -b --no-esc /dev/sdj
sg_reset: reset (for value=0x102) may not be available

Given this I don't have an objection to this patch.

Tested-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH 19/28] qedf: drop bus reset handler

2017-06-28 Thread Chad Dupuis

On Wed, 28 Jun 2017, 9:58am, Christoph Hellwig wrote:

> On Wed, Jun 28, 2017 at 10:25:07AM +0200, Hannes Reinecke wrote:
> > qedf has a host reset handler, but as the bus reset handler is
> > a stub always returning SUCCESS the host reset is never invoked.
> > So drop the bus reset handler.
> 
> Given that comment this needs a lot more explanation, as the current
> behavior seems to be an odd/buggy workaround.
> 
> I hope this patch won't block the rest of the series, which all seems
> nice and simple material for this late merge window :(
> 

The test case this was meant to fix as using the sg_reset utility with the 
-b option which forces a bus reset with NPIV ports attached.  What we were 
finding is that some of the devices attached to the vport were being 
brought offline after 5 seconds as escalating to the host reset handler in 
this case was taking too long.

For this specific test case, returning SUCCESS allowed us to bypass the 
host reset escalation and force the SCSI error handler to send a TUR to 
the devices which of course would succeed since the device weren't 
physically offline keeping them from going offline.


Re: [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups

2017-06-12 Thread Chad Dupuis

On Sun, 11 Jun 2017, 2:16am, Christophe JAILLET wrote:

> This patch serie first fixes a case where an error code was missing.
> The 2 other patches are just cleanups in the same area.
> 
> Christophe JAILLET (3):
>   scsi: qedf: Fix a return value in case of error in
> 'qedf_alloc_global_queues'
>   scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity.
>   scsi: qedf: Merge a few quoted strings split across lines
> 
>  drivers/scsi/qedf/qedf_main.c | 38 +-
>  1 file changed, 13 insertions(+), 25 deletions(-)
> 
> 

All are sensible small improvements.  Ack the series.

series-acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH 00/15] qedf: Update driver to version 8.18.22.0.

2017-05-24 Thread Chad Dupuis

On Wed, 24 May 2017, 3:12pm, Martin K. Petersen wrote:

> 
> Chad,
> 
> > Please apply the following patches to the scsi tree at your earliest
> > convenience.
> 
> Please address Bart's comments and resubmit.
> 
> Thanks!
> 
> 

Sure, will submit a V2 that addresses Bart's comments.


Re: [REEEEPOST] bnx2i + bnx2fc: convert to generic workqueue (#3)

2017-05-17 Thread Chad Dupuis

On Wed, 17 May 2017, 11:01am, Sebastian Andrzej Siewior wrote:

> On 2017-05-12 11:55:52 [-0400], Chad Dupuis wrote:
> > Ok, I believe I've found the issue here.  The machine that the test has 
> > performed on had many more possible CPUs than active CPUs.  We calculate 
> > which CPU to the work time on in bnx2fc_process_new_cqes() like this:
> > 
> > unsigned int cpu = wqe % num_possible_cpus();
> > 
> > Since not all CPUs are active, we were trying to schedule work on 
> > non-active CPUs which meant that the upper layers were never notified of 
> > the completion.  With this change:
> > 
> > diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c 
> > b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> > index c2288d6..6f08e43 100644
> > --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> > +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> > @@ -1042,7 +1042,12 @@ static int bnx2fc_process_new_cqes(struct 
> > bnx2fc_rport *tgt)
> > /* Pending work request completion */
> > struct bnx2fc_work *work = NULL;
> > struct bnx2fc_percpu_s *fps = NULL;
> > -   unsigned int cpu = wqe % num_possible_cpus();
> > +   unsigned int cpu = wqe % num_active_cpus();
> > +
> > +   /* Sanity check cpu to make sure it's online */
> > +   if (!cpu_active(cpu))
> > +   /* Default to CPU 0 */
> > +   cpu = 0;
> >  
> > work = bnx2fc_alloc_work(tgt, wqe);
> > if (work) {
> > 
> > The issue is fixed.
> > 
> > Sebastian, can you add this change to your patch set?
> 
> Are sure that you can reliably reproduce the issue and fix it with the
> patch above? Because this patch:

Yes it was reproducible each time we would start the FCoE interface.  With 
the above patch, our sanity test passed with no issues seen.

> 
> diff --git a/init/main.c b/init/main.c
> index b0c11cbf5ddf..483a971b1fd2 100644
> --- a/init/main.c
> +++ b/init/main.c
> @@ -997,6 +997,12 @@ static int __ref kernel_init(void *unused)
>   "See Linux Documentation/admin-guide/init.rst for guidance.");
>  }
>  
> +static void workfn(struct work_struct *work)
> +{
> +   pr_err("%s() %d\n", __func__, raw_smp_processor_id());
> +}
> +static DECLARE_WORK(work, workfn);
> +
>  static noinline void __init kernel_init_freeable(void)
>  {
> /*
> @@ -1040,6 +1046,15 @@ static noinline void __init kernel_init_freeable(void)
>  
> (void) sys_dup(0);
> (void) sys_dup(0);
> +   {
> +
> +   cpu_down(3);
> +   pr_err("%s() num possible: %d\n", __func__, 
> num_possible_cpus());
> +   pr_err("%s() num online  : %d\n", __func__, 
> num_online_cpus());
> +   pr_err("%s() 3 active: %d\n", __func__, cpu_active(3));
> +   schedule_work_on(3, );
> +   ssleep(5);
> +   }
> /*
>  * check if there is an early userspace init.  If yes, let it do all
>  * the work
> 
> produces this output:
> [1.960313] Unregister pv shared memory for cpu 3
> [1.997000] kernel_init_freeable() num possible: 8
> [1.998073] kernel_init_freeable() num online  : 7
> [1.999125] kernel_init_freeable() 3 active: 0
> [2.000337] workfn() 1
> 
> which means, CPU3 is offline and work runs on CPU1 instead. So it does
> already what you suggest except that chances are, that it is not run on
> CPU0 in this case (but on another CPU).
> 
> So it either takes some time for wait_for_completion(_req->tm_done);
> to come back _or_ there is a leak somewhere where a complete() is
> somehow missing / racing against something.
> 
> Sebastian
> 


Re: [REEEEPOST] bnx2i + bnx2fc: convert to generic workqueue (#3)

2017-05-12 Thread Chad Dupuis

On Tue, 9 May 2017, 11:18am, James Bottomley wrote:

> On Tue, 2017-05-09 at 10:17 -0400, Chad Dupuis wrote:
> > On Mon, 8 May 2017, 10:04pm, Martin K. Petersen wrote:
> > 
> > > 
> > > Sebastian,
> > > 
> > > > Martin, do you see any chance to get this merged? Chad replied to
> > the
> > > > list that he is going to test it on 2017-04-10, didn't respond to
> > the
> > > > ping 10 days later. The series stalled last time in the same way.
> > > 
> > > I am very reluctant to merge something when a driver has an active
> > > maintainer and that person has not acked the change.
> > > 
> > > That said, Chad: You have been sitting on this for quite a while.
> > Please
> > > make it a priority. In exchange for veto rights you do have to
> > provide
> > > timely feedback on anything that touches your driver.
> > > 
> > > Thanks!
> > > 
> > 
> > We did do some testing and hit a calltrace during device discovery:
> > 
> > [ 1332.551799] INFO: task scsi_eh_15:1970 blocked for more than 120 
> > seconds.
> > [ 1332.551804] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs"
> > disables 
> > this message.
> > [ 1332.551807] scsi_eh_15  D 880823488c14 0  1970  2 
> > 0x0080
> > [ 1332.551813]  881053a17cb0 0046 88084d693ec0 
> > 881053a17fd8
> > [ 1332.551817]  881053a17fd8 881053a17fd8 88084d693ec0 
> > 880823488d48
> > [ 1332.551821]  880823488d50 7fff 88084d693ec0 
> > 880823488c14
> > [ 1332.551825] Call Trace:
> > [ 1332.551838]  [] schedule+0x29/0x70
> > [ 1332.551844]  [] schedule_timeout+0x239/0x2d0
> > [ 1332.551850]  [] ? console_unlock+0x208/0x400
> > [ 1332.551855]  [] ? vprintk_emit+0x3c4/0x510
> > [ 1332.551861]  [] ?
> > lock_timer_base.isra.33+0x2b/0x50
> > [ 1332.551866]  [] wait_for_completion+0x116/0x170
> > [ 1332.551874]  [] ? wake_up_state+0x20/0x20
> > [ 1332.551885]  [] bnx2fc_abts_cleanup+0x3d/0x62 
> > [bnx2fc]
> > [ 1332.551892]  [] bnx2fc_eh_abort+0x470/0x580
> > [bnx2fc]
> > [ 1332.551900]  [] scsi_error_handler+0x59f/0x8b0
> > [ 1332.551904]  [] ? scsi_eh_get_sense+0x250/0x250
> > [ 1332.551911]  [] kthread+0xcf/0xe0
> > [ 1332.551916]  [] ?
> > kthread_create_on_node+0x140/0x140
> > [ 1332.551923]  [] ret_from_fork+0x58/0x90
> > [ 1332.551928]  [] ?
> > kthread_create_on_node+0x140/0x140 
> 
> Reporting this when you found it would have been helpful ...
> 
> That said, it does look like a genuine hang in the workqueues, so it
> rather invalidates the current patch set.
> 
> > To be honest, I'm reluctant to merge these patches on bnx2fc as the
> > I/O path on this driver has been stable for quite some time and given
> > that it's an older driver I'm not looking to make changes there.
> 
> OK, so find a way to achieve both sets of goals because there's a limit
> to how long we allow "stable" drivers to hold up infrastructure changes
> within the kernel.  The main goal of the current patch set is to remove
> the cpu hotplug calls from the drivers because they want to remove them
> from the kernel.  This is rather complex because you're using per cpu
> work queues so you currently have to manage starting and stopping them
> as the CPUs come up or go down ... getting rid of that for standard
> kernel infrastructure will make the driver easier to keep in
> maintenance mode for longer.
> 
> James
> 

Ok, I believe I've found the issue here.  The machine that the test has 
performed on had many more possible CPUs than active CPUs.  We calculate 
which CPU to the work time on in bnx2fc_process_new_cqes() like this:

unsigned int cpu = wqe % num_possible_cpus();

Since not all CPUs are active, we were trying to schedule work on 
non-active CPUs which meant that the upper layers were never notified of 
the completion.  With this change:

diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c 
b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
index c2288d6..6f08e43 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
@@ -1042,7 +1042,12 @@ static int bnx2fc_process_new_cqes(struct 
bnx2fc_rport *tgt)
/* Pending work request completion */
struct bnx2fc_work *work = NULL;
struct bnx2fc_percpu_s *fps = NULL;
-   unsigned int cpu = wqe % num_possible_cpus();
+   unsigned int cpu = wqe % num_active_cpus();
+
+   /* Sanity check cpu to make sure it's online */
+   if (!cpu_active(cpu))
+   /* Default to CPU 0 */
+   cpu = 0;
 
work = bnx2fc_alloc_work(tgt, wqe);
if (work) {

The issue is fixed.

Sebastian, can you add this change to your patch set?


Re: [REEEEPOST] bnx2i + bnx2fc: convert to generic workqueue (#3)

2017-05-09 Thread Chad Dupuis

On Mon, 8 May 2017, 10:04pm, Martin K. Petersen wrote:

> 
> Sebastian,
> 
> > Martin, do you see any chance to get this merged? Chad replied to the
> > list that he is going to test it on 2017-04-10, didn't respond to the
> > ping 10 days later. The series stalled last time in the same way.
> 
> I am very reluctant to merge something when a driver has an active
> maintainer and that person has not acked the change.
> 
> That said, Chad: You have been sitting on this for quite a while. Please
> make it a priority. In exchange for veto rights you do have to provide
> timely feedback on anything that touches your driver.
> 
> Thanks!
> 

We did do some testing and hit a calltrace during device discovery:

[ 1332.551799] INFO: task scsi_eh_15:1970 blocked for more than 120 
seconds.
[ 1332.551804] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables 
this message.
[ 1332.551807] scsi_eh_15  D 880823488c14 0  1970  2 
0x0080
[ 1332.551813]  881053a17cb0 0046 88084d693ec0 
881053a17fd8
[ 1332.551817]  881053a17fd8 881053a17fd8 88084d693ec0 
880823488d48
[ 1332.551821]  880823488d50 7fff 88084d693ec0 
880823488c14
[ 1332.551825] Call Trace:
[ 1332.551838]  [] schedule+0x29/0x70
[ 1332.551844]  [] schedule_timeout+0x239/0x2d0
[ 1332.551850]  [] ? console_unlock+0x208/0x400
[ 1332.551855]  [] ? vprintk_emit+0x3c4/0x510
[ 1332.551861]  [] ? lock_timer_base.isra.33+0x2b/0x50
[ 1332.551866]  [] wait_for_completion+0x116/0x170
[ 1332.551874]  [] ? wake_up_state+0x20/0x20
[ 1332.551885]  [] bnx2fc_abts_cleanup+0x3d/0x62 
[bnx2fc]
[ 1332.551892]  [] bnx2fc_eh_abort+0x470/0x580 [bnx2fc]
[ 1332.551900]  [] scsi_error_handler+0x59f/0x8b0
[ 1332.551904]  [] ? scsi_eh_get_sense+0x250/0x250
[ 1332.551911]  [] kthread+0xcf/0xe0
[ 1332.551916]  [] ? kthread_create_on_node+0x140/0x140
[ 1332.551923]  [] ret_from_fork+0x58/0x90
[ 1332.551928]  [] ? kthread_create_on_node+0x140/0x140 

To be honest, I'm reluctant to merge these patches on bnx2fc as the I/O 
path on this driver has been stable for quite some time and given that 
it's an older driver I'm not looking to make changes there.


Re: [PATCH] scsi: qedf: Avoid reading past end of buffer

2017-05-06 Thread Chad Dupuis

On Fri, 5 May 2017, 7:10pm, Kees Cook wrote:

> On Fri, May 5, 2017 at 4:01 PM, Bart Van Assche
> <bart.vanass...@sandisk.com> wrote:
> > On Fri, 2017-05-05 at 15:42 -0700, Kees Cook wrote:
> >> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> >> index cceddd995a4b..a5c97342fd5d 100644
> >> --- a/drivers/scsi/qedf/qedf_main.c
> >> +++ b/drivers/scsi/qedf/qedf_main.c
> >> @@ -2895,7 +2895,7 @@ static int __qedf_probe(struct pci_dev *pdev, int 
> >> mode)
> >>   slowpath_params.drv_minor = QEDF_DRIVER_MINOR_VER;
> >>   slowpath_params.drv_rev = QEDF_DRIVER_REV_VER;
> >>   slowpath_params.drv_eng = QEDF_DRIVER_ENG_VER;
> >> - memcpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE);
> >> + strncpy(slowpath_params.name, "qedf", QED_DRV_VER_STR_SIZE);
> >>   rc = qed_ops->common->slowpath_start(qedf->cdev, _params);
> >>   if (rc) {
> >>   QEDF_ERR(&(qedf->dbg_ctx), "Cannot start slowpath.\n");
> >
> > Hello Kees,
> >
> > Although this patch looks fine to me, isn't strlcpy() preferred over 
> > strncpy()?
> 
> strlcpy doesn't zero-pad, so I think strncpy is preferred here,
> otherwise we may risk leaving portions of the destination buffer
> filled with uninitialized data, maybe leaking kernel memory contents.
> 
> -Kees
> 

I'd agree with strncpy so we zero out the rest of the buffer.

Acked-by: Chad Dupuis <chad.dup...@cavium.com> 


Re: [PATCH] scsi: qedf: properly update arguments position in function call

2017-05-04 Thread Chad Dupuis

On Wed, 3 May 2017, 3:17pm, Gustavo A. R. Silva wrote:

> Properly update the position of the arguments in function call.
> 
> Addresses-Coverity-ID: 1402010
> Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
> ---
>  drivers/scsi/qedf/qedf_els.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_els.c b/drivers/scsi/qedf/qedf_els.c
> index 59f3e5c..107ed2b 100644
> --- a/drivers/scsi/qedf/qedf_els.c
> +++ b/drivers/scsi/qedf/qedf_els.c
> @@ -106,7 +106,7 @@ static int qedf_initiate_els(struct qedf_rport *fcport, 
> unsigned int op,
>   did = fcport->rdata->ids.port_id;
>   sid = fcport->sid;
>  
> - __fc_fill_fc_hdr(fc_hdr, FC_RCTL_ELS_REQ, sid, did,
> + __fc_fill_fc_hdr(fc_hdr, FC_RCTL_ELS_REQ, did, sid,
>  FC_TYPE_ELS, FC_FC_FIRST_SEQ | FC_FC_END_SEQ |
>  FC_FC_SEQ_INIT, 0);
>  
> 

Thanks.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi: qedf: Cleanup the type of io_log->op

2017-05-04 Thread Chad Dupuis

On Wed, 3 May 2017, 5:23pm, Dan Carpenter wrote:

> We store sc_cmd->cmnd[0] which is an unsigned char in io_log->op so
> this should also be unsigned char.  The other thing is that this is
> displayed in the debugfs:
> 
>   seq_printf(s, "0x%02x:", io_log->op);
> 
> Smatch complains that the formatting won't work for negative values so
> changing it to unsigned silences that warning as well.
> 
> Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>
> 
> diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
> index 40aeb6bb96a2..07ee88200e91 100644
> --- a/drivers/scsi/qedf/qedf.h
> +++ b/drivers/scsi/qedf/qedf.h
> @@ -259,7 +259,7 @@ struct qedf_io_log {
>   uint16_t task_id;
>   uint32_t port_id; /* Remote port fabric ID */
>   int lun;
> - char op; /* SCSI CDB */
> + unsigned char op; /* SCSI CDB */
>   uint8_t lba[4];
>   unsigned int bufflen; /* SCSI buffer length */
>   unsigned int sg_count; /* Number of SG elements */
> 

Makes sense.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [scsi-qedf] question about parameter ordering

2017-05-03 Thread Chad Dupuis

On Wed, 3 May 2017, 2:36pm, Randy Dunlap wrote:

> On 05/03/17 11:29, Chad Dupuis wrote:
> > 
> > On Wed, 3 May 2017, 1:58pm, Gustavo A. R. Silva wrote:
> > 
> >>
> >> Hello everybody,
> >>
> >> While looking into Coverity ID 1402011 I ran into the following piece of 
> >> code
> >> at drivers/scsi/qedf/qedf_io.c:2057:
> >>
> >> /* Fill FC header */
> >> fc_hdr = &(tm_req->req_fc_hdr);
> >> sid = fcport->sid;
> >> did = fcport->rdata->ids.port_id;
> >> __fc_fill_fc_hdr(fc_hdr, FC_RCTL_DD_UNSOL_CMD, sid, did,
> >>   FC_TYPE_FCP, FC_FC_FIRST_SEQ | FC_FC_END_SEQ |
> >>   FC_FC_SEQ_INIT, 0);
> >>
> >> The issue here is that the position of arguments in the call to
> >> __fc_fill_fc_hdr() function do not match the ordering of the parameters:
> >>
> >> _sid_ is passed to _did_
> >> _did_ is passed to _sid_
> >>
> >> this is the function prototype:
> >>
> >> static inline void __fc_fill_fc_hdr(struct fc_frame_header *fh,
> >>enum fc_rctl r_ctl,
> >>u32 did, u32 sid, enum fc_fh_type type,
> >>u32 f_ctl, u32 parm_offset)
> >>
> >> My question here is if this is intentionala?
> > 
> > This may have been but this code has been superseded by commit  
> > be086e7c53f1fac51eed14523b28f2214b548dd2.B
> 
> what git tree is that in?
> 
> Thanks.
>

Apologies, a couple of stray characters got into the commit ID.  This is 
in mainline:

commit be086e7c53f1fac51eed14523b28f2214b548dd2
Author: Mintz, Yuval <yuval.mi...@cavium.com>
Date:   Sat Mar 11 18:39:18 2017 +0200

qed*: Utilize Firmware 8.15.3.0
 
> >> In case it is not, I will send a patch to fix it. But first it would be 
> >> great
> >> to hear any comment about it.
> >>
> >> By the way... the same is happening at drivers/scsi/qedf/qedf_els.c:109
> > 
> > May be a bug here so you could send a patch.
> 
> 
> 


Re: [scsi-qedf] question about parameter ordering

2017-05-03 Thread Chad Dupuis

On Wed, 3 May 2017, 1:58pm, Gustavo A. R. Silva wrote:

> 
> Hello everybody,
> 
> While looking into Coverity ID 1402011 I ran into the following piece of code
> at drivers/scsi/qedf/qedf_io.c:2057:
> 
> /* Fill FC header */
> fc_hdr = &(tm_req->req_fc_hdr);
> sid = fcport->sid;
> did = fcport->rdata->ids.port_id;
> __fc_fill_fc_hdr(fc_hdr, FC_RCTL_DD_UNSOL_CMD, sid, did,
>   FC_TYPE_FCP, FC_FC_FIRST_SEQ | FC_FC_END_SEQ |
>   FC_FC_SEQ_INIT, 0);
> 
> The issue here is that the position of arguments in the call to
> __fc_fill_fc_hdr() function do not match the ordering of the parameters:
> 
> _sid_ is passed to _did_
> _did_ is passed to _sid_
> 
> this is the function prototype:
> 
> static inline void __fc_fill_fc_hdr(struct fc_frame_header *fh,
>enum fc_rctl r_ctl,
>u32 did, u32 sid, enum fc_fh_type type,
>u32 f_ctl, u32 parm_offset)
> 
> My question here is if this is intentionala?

This may have been but this code has been superseded by commit  
be086e7c53f1fac51eed14523b28f2214b548dd2.B
> 
> In case it is not, I will send a patch to fix it. But first it would be great
> to hear any comment about it.
> 
> By the way... the same is happening at drivers/scsi/qedf/qedf_els.c:109

May be a bug here so you could send a patch.

> 
> Thank you
> --
> Gustavo A. R. Silva
> 
> 
> 
> 


Re: [REEEEPOST] bnx2i + bnx2fc: convert to generic workqueue (#3)

2017-04-10 Thread Chad Dupuis

On Mon, 10 Apr 2017, 5:12pm -, Sebastian Andrzej Siewior wrote:

> This is a repost to get the patches applied against v4.11-rc6. mkp's scsi
> for-next tree can be merged with no conflicts.
> 
> The last repost [0] was not merged and stalled after Martin pinged Chad
> [1]. He didn't even reply after tglx pinged him approx two weeks later.
> 
> Johannes Thumshirn was so kind to test the FCoE part of the old series
> [2]. I did not add a tested-by tag due to the rebase.
> 
> If my memory is correct then my first attempt on this (with hotplug
> threads back then) was around December 2015.
> 
> The whole series is also available at
>  git://git.kernel.org/pub/scm/linux/kernel/git/bigeasy/hotplug-staging.git 
> scsi/bnx2_v2
> 
> [0] http://www.spinics.net/lists/linux-scsi/msg102143.html
> [1] http://www.spinics.net/lists/linux-scsi/msg102295.html
> [2] http://www.spinics.net/lists/linux-scsi/msg102716.html
> 
> Sebastian
> 

Sebastian, will take a look. 


Re: [PATCH] scsi: libfc: directly call ELS request handlers

2017-04-07 Thread Chad Dupuis


On Fri, 7 Apr 2017, 1:42pm -, Johannes Thumshirn wrote:

> Directly call ELS request handler functions in fc_lport_recv_els_req
> instead of saving the pointer to the handler's receive function and then
> later dereferencing this pointer.
> 
> This makes the code a bit more obvious.
> 
> Signed-off-by: Johannes Thumshirn <jthumsh...@suse.de>
> ---
>  drivers/scsi/libfc/fc_lport.c | 20 +---
>  1 file changed, 9 insertions(+), 11 deletions(-)
> 

A reasonable refactoring.

Reviewed-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] qedf: fix wrong le16 conversion

2017-03-20 Thread Chad Dupuis

On Mon, 20 Mar 2017, 8:49am -, Arnd Bergmann wrote:

> gcc points out that we are converting a 16-bit integer into a 32-bit
> little-endian type and assigning that to 16-bit little-endian
> will end up with a zero:
> 
> drivers/scsi/qedf/drv_fcoe_fw_funcs.c: In function 
> 'init_initiator_rw_fcoe_task':
> include/uapi/linux/byteorder/big_endian.h:32:26: error: large integer 
> implicitly truncated to unsigned type [-Werror=overflow]
>   t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
> 
> The correct solution appears to be to just use a 16-bit byte swap instead.
> 
> Fixes: be086e7c53f1 ("qed*: Utilize Firmware 8.15.3.0")
> Signed-off-by: Arnd Bergmann <a...@arndb.de>
> ---
>  drivers/scsi/qedf/drv_fcoe_fw_funcs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/drv_fcoe_fw_funcs.c 
> b/drivers/scsi/qedf/drv_fcoe_fw_funcs.c
> index bb812db48da6..8c65e3b034dc 100644
> --- a/drivers/scsi/qedf/drv_fcoe_fw_funcs.c
> +++ b/drivers/scsi/qedf/drv_fcoe_fw_funcs.c
> @@ -8,7 +8,7 @@
>  #include "drv_fcoe_fw_funcs.h"
>  #include "drv_scsi_fw_funcs.h"
>  
> -#define FCOE_RX_ID ((u32)0x)
> +#define FCOE_RX_ID (0xu)
>  
>  static inline void init_common_sqe(struct fcoe_task_params *task_params,
>  enum fcoe_sqe_request_type request_type)
> @@ -59,7 +59,7 @@ int init_initiator_rw_fcoe_task(struct fcoe_task_params 
> *task_params,
>   t_st_ctx->read_only.task_type = task_params->task_type;
>   SET_FIELD(t_st_ctx->read_write.flags,
> FCOE_TSTORM_FCOE_TASK_ST_CTX_READ_WRITE_EXP_FIRST_FRAME, 1);
> - t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
> + t_st_ctx->read_write.rx_id = cpu_to_le16(FCOE_RX_ID);
>  
>   /* Ustorm ctx */
>   u_ag_ctx = >ustorm_ag_context;
> @@ -151,7 +151,7 @@ int init_initiator_midpath_unsolicited_fcoe_task(
>   t_st_ctx->read_only.task_type = task_params->task_type;
>   SET_FIELD(t_st_ctx->read_write.flags,
> FCOE_TSTORM_FCOE_TASK_ST_CTX_READ_WRITE_EXP_FIRST_FRAME, 1);
> - t_st_ctx->read_write.rx_id = cpu_to_le32(FCOE_RX_ID);
> + t_st_ctx->read_write.rx_id = cpu_to_le16(FCOE_RX_ID);
>  
>   /* Init Ustorm */
>   u_ag_ctx = >ustorm_ag_context;
> 

Arnd, thanks for fixing this up.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi: qedf: Use vsprintf extension %pad

2017-03-06 Thread Chad Dupuis

On Mon, 6 Mar 2017, 6:32pm -, Joe Perches wrote:

> Using %llx for a dma_addr_t can lead to format/argument mismatches.
> Use %pad and the address of the dma_addr_t instead.
> 
> Signed-off-by: Joe Perches <j...@perches.com>
> ---
>  drivers/scsi/qedf/qedf_main.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index d9d7a86b5f8b..8e2a160490e6 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -2456,8 +2456,8 @@ static int qedf_alloc_bdq(struct qedf_ctx *qedf)
>   }
>  
>   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC,
> - "BDQ PBL addr=0x%p dma=0x%llx.\n", qedf->bdq_pbl,
> - qedf->bdq_pbl_dma);
> +   "BDQ PBL addr=0x%p dma=%pad\n",
> +   qedf->bdq_pbl, >bdq_pbl_dma);
>  
>   /*
>* Populate BDQ PBL with physical and virtual address of individual
> 

Looks good.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] scsi: qedf: Fix defective logging format and argument mismatches

2017-03-06 Thread Chad Dupuis

On Sat, 4 Mar 2017, 8:07am -, Joe Perches wrote:

> Add __printf compiler verification of format and arguments.
> Fix fallout.
> 
> Signed-off-by: Joe Perches <j...@perches.com>
> ---
>  drivers/scsi/qedf/qedf_dbg.h | 13 -
>  drivers/scsi/qedf/qedf_fip.c |  2 +-
>  drivers/scsi/qedf/qedf_io.c  |  4 ++--
>  3 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_dbg.h b/drivers/scsi/qedf/qedf_dbg.h

Thanks.

Acked-by: Chad Dupuis <chad.dup...@cavium.com>


Re: [PATCH] qedf: fixup compilation warning about atomic_t usage

2017-02-23 Thread Chad Dupuis


On Thu, 23 Feb 2017, 11:44am -, Hannes Reinecke wrote:

> The driver didn't follow the atomic_t vs refcount_t change, and
> anyway one should be using kref_read() instead of accessing the
> counter inside an kref.
> 
> Fixes: 61d8658b4a435e ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver 
> framework.)
> Cc: Chad Dupuis <chad.dup...@cavium.com>
> Cc: Nilesh Javali <nilesh.jav...@cavium.com>
> Signed-off-by: Hannes Reinecke <h...@suse.com>
> ---
>  drivers/scsi/qedf/qedf_io.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
> index 486c045..ee0dcf9 100644
> --- a/drivers/scsi/qedf/qedf_io.c
> +++ b/drivers/scsi/qedf/qedf_io.c
> @@ -998,7 +998,7 @@ static void qedf_trace_io(struct qedf_rport *fcport, 
> struct qedf_ioreq *io_req,
>   io_log->sg_count = scsi_sg_count(sc_cmd);
>   io_log->result = sc_cmd->result;
>   io_log->jiffies = jiffies;
> - io_log->refcount = atomic_read(_req->refcount.refcount);
> + io_log->refcount = kref_read(_req->refcount);
>  
>   if (direction == QEDF_IO_TRACE_REQ) {
>   /* For requests we only care abot the submission CPU */
> @@ -1340,7 +1340,7 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct 
> fcoe_cqe *cqe,
>   /* Good I/O completion */
>   sc_cmd->result = DID_OK << 16;
>   } else {
> - refcount = atomic_read(_req->refcount.refcount);
> + refcount = kref_read(_req->refcount);
>   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
>   "%d:0:%d:%d xid=0x%0x op=0x%02x "
>   "lba=%02x%02x%02x%02x cdb_status=%d "
> @@ -1425,7 +1425,7 @@ void qedf_scsi_done(struct qedf_ctx *qedf, struct 
> qedf_ioreq *io_req,
>   qedf_unmap_sg_list(qedf, io_req);
>  
>   sc_cmd->result = result << 16;
> - refcount = atomic_read(_req->refcount.refcount);
> + refcount = kref_read(_req->refcount);
>   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "%d:0:%d:%d: Completing "
>   "sc_cmd=%p result=0x%08x op=0x%02x lba=0x%02x%02x%02x%02x, "
>   "allowed=%d retries=%d refcount=%d.\n",
> @@ -1556,7 +1556,7 @@ static void qedf_flush_els_req(struct qedf_ctx *qedf,
>  {
>   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO,
>   "Flushing ELS request xid=0x%x refcount=%d.\n", els_req->xid,
> - atomic_read(_req->refcount.refcount));
> + kref_read(_req->refcount));
>  
>   /*
>* Need to distinguish this from a timeout when calling the
>

Thanks for the patch Hannes though it looks like the atomic_read's in 
qedf_els.c need to be converted as well.  Will post a patch shortly. 


Re: [PATCH V3 2/2] qedf: Add QLogic FastLinQ offload FCoE driver framework.

2017-02-06 Thread Chad Dupuis

On Mon, 6 Feb 2017, 3:56pm -, Hannes Reinecke wrote:

> On 02/03/2017 08:17 PM, Dupuis, Chad wrote:
> > From: "Dupuis, Chad" <chad.dup...@cavium.com>
> > 
> > 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 <nilesh.jav...@cavium.com>
> > Signed-off-by: Manish Rangankar <manish.rangan...@cavium.com>
> > Signed-off-by: Saurav Kashyap <saurav.kash...@cavium.com>
> > Signed-off-by: Arun Easi <arun.e...@cavium.com>
> > Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
> > ---
> [ .. ]
> > +static void qedf_process_l2_frame_compl(struct qedf_rport *fcport,
> > +   unsigned char *buf,
> > +   u32 frame_len, u16 l2_oxid)
> > +{
> > +   struct fc_lport *lport = fcport->qedf->lport;
> > +   struct fc_frame_header *fh;
> > +   struct fc_frame *fp;
> > +   u32 payload_len;
> > +   u32 crc;
> > +
> > +   payload_len = frame_len - sizeof(struct fc_frame_header);
> > +
> > +   fp = fc_frame_alloc(lport, payload_len);
> > +   if (!fp) {
> > +   QEDF_ERR(&(fcport->qedf->dbg_ctx),
> > +   "fc_frame_alloc failure.\n");
> > +   return;
> > +   }
> > +
> > +   /* Copy FC Frame header and payload into the frame */
> > +   fh = (struct fc_frame_header *)fc_frame_header_get(fp);
> > +   memcpy(fh, buf, frame_len);
> > +
> > +   /* Set the OXID we return to what libfc used */
> > +   if (l2_oxid != FC_XID_UNKNOWN)
> > +   fh->fh_ox_id = htons(l2_oxid);
> > +
> > +   /* Setup header fields */
> > +   fh->fh_r_ctl = FC_RCTL_ELS_REP;
> > +   fh->fh_type = FC_TYPE_ELS;
> > +   /* Last sequence, end sequence */
> > +   fh->fh_f_ctl[0] = 0x98;
> > +   hton24(fh->fh_d_id, lport->port_id);
> > +   hton24(fh->fh_s_id, fcport->rdata->ids.port_id);
> > +   fh->fh_rx_id = 0x;
> > +
> > +   /* Set frame attributes */
> > +   crc = fcoe_fc_crc(fp);
> > +   fc_frame_init(fp);
> > +   fr_dev(fp) = lport;
> > +   fr_sof(fp) = FC_SOF_I3;
> > +   fr_eof(fp) = FC_EOF_T;
> > +   fr_crc(fp) = cpu_to_le32(~crc);
> > +
> > +   /* Send completed request to libfc */
> > +   fc_exch_recv(lport, fp);
> > +}
> > +
> > +/*
> > + * In instances where an ELS command times out we may need to restart the
> > + * rport by logging out and then logging back in.
> > + */
> > +void qedf_restart_rport(struct qedf_rport *fcport)
> > +{
> > +   struct fc_lport *lport;
> > +   struct fc_rport_priv *rdata;
> > +   u32 port_id;
> > +
> > +   if (!fcport)
> > +   return;
> > +
> > +   rdata = fcport->rdata;
> > +   if (rdata) {
> > +   lport = fcport->qedf->lport;
> > +   port_id = rdata->ids.port_id;
> > +   QEDF_ERR(&(fcport->qedf->dbg_ctx),
> > +   "LOGO port_id=%x.\n", port_id);
> > +   fc_rport_logoff(rdata);
> > +   /* Recreate the rport and log back in */
> > +   rdata = fc_rport_create(lport, port_id);
> > +   if (rdata)
> > +   fc_rport_login(rdata);
> > +   }
> > +}
> > +
> > +static void qedf_l2_els_compl(struct qedf_els_cb_arg *cb_arg)
> > +{
> > +   struct qedf_ioreq *els_req;
> > +   struct qedf_rport *fcport;
> > +   struct qedf_mp_req *mp_req;
> > +   struct fc_frame_header *fc_hdr;
> > +   unsigned char *buf;
> > +   void *resp_buf;
> > +   u32 resp_len, hdr_len;
> > +   u16 l2_oxid;
> > +   int frame_len;
> > +
> > +   l2_oxid = cb_arg->l2_oxid;
> > +   els_req = cb_arg->io_req;
> > +
> > +   if (!els_req) {
> > + 

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

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

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

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

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


Re: [Open-FCoE] [PATCH RFC 5/5] qedf: Add FIP request handling

2017-01-09 Thread Chad Dupuis

On Wed, 28 Dec 2016, 9:11am -, Hannes Reinecke wrote:

> On 12/23/2016 08:17 PM, Dupuis, Chad wrote:
> > From: "Dupuis, Chad" <chad.dup...@cavium.com>
> > 
> > This patch adds handling for FIP requests and responses that are handled by
> > the driver itself and not by libfcoe.
> > 
> > Signed-off-by: Nilesh Javali <nilesh.jav...@cavium.com>
> > Signed-off-by: Manish Rangankar <manish.rangan...@cavium.com>
> > Signed-off-by: Saurav Kashyap <saurav.kash...@cavium.com>
> > Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
> > ---
> >  drivers/scsi/qedf/qedf_fip.c | 267 
> > +++
> >  1 file changed, 267 insertions(+)
> >  create mode 100644 drivers/scsi/qedf/qedf_fip.c
> > 
> > diff --git a/drivers/scsi/qedf/qedf_fip.c b/drivers/scsi/qedf/qedf_fip.c
> > new file mode 100644
> > index 000..4f185c6
> > --- /dev/null
> > +++ b/drivers/scsi/qedf/qedf_fip.c
> > @@ -0,0 +1,267 @@
> > +/*
> > + *  QLogic FCoE Offload Driver
> > + *  Copyright (c) 2016 Cavium Inc.
> > + *
> > + *  This software is available under the terms of the GNU General Public 
> > License
> > + *  (GPL) Version 2, available from the file COPYING in the main directory 
> > of
> > + *  this source tree.
> > + */
> > +#include 
> > +#include 
> > +#include "qedf.h"
> > +
> > +extern const struct qed_fcoe_ops *qed_ops;
> > +/*
> > + * FIP VLAN functions that will eventually move to libfcoe.
> > + */
> > +
> > +void qedf_fcoe_send_vlan_req(struct qedf_ctx *qedf)
> > +{
> > +   struct sk_buff *skb;
> > +   char *eth_fr;
> > +   int fr_len;
> > +   struct fip_vlan *vlan;
> > +#define MY_FIP_ALL_FCF_MACS((__u8[6]) { 1, 0x10, 0x18, 1, 0, 2 })
> > +   static u8 my_fcoe_all_fcfs[ETH_ALEN] = MY_FIP_ALL_FCF_MACS;
> 
> Do you support VN2VN, too?

Not currently, no.

> 
> Cheers,
> 
> Hannes
> 
--
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 RFC 3/5] qedf: Add offloaded I/O request functions.

2017-01-09 Thread Chad Dupuis

On Wed, 28 Dec 2016, 9:08am -, Hannes Reinecke wrote:

> On 12/23/2016 08:17 PM, Dupuis, Chad wrote:
> > From: "Dupuis, Chad" <chad.dup...@cavium.com>
> > 
> > This patch adds various I/O requests types that are handled in firmware:
> > 
> > - Normal I/O requests
> > - ABTS requests
> > - Cleanup requests
> > - Task management requests
> > 
> > It also contains:
> > 
> > - I/O request initialization
> > - Firmware completion handling
> > 
> > Signed-off-by: Nilesh Javali <nilesh.jav...@cavium.com>
> > Signed-off-by: Manish Rangankar <manish.rangan...@cavium.com>
> > Signed-off-by: Saurav Kashyap <saurav.kash...@cavium.com>
> > Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
> > ---
> >  drivers/scsi/qedf/qedf_hsi.h |  427 
> >  drivers/scsi/qedf/qedf_io.c  | 2303 
> > ++
> >  2 files changed, 2730 insertions(+)
> >  create mode 100644 drivers/scsi/qedf/qedf_hsi.h
> >  create mode 100644 drivers/scsi/qedf/qedf_io.c
> > 
> [ .. ]
> 
> > +static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd 
> > *sc_cmd,
> > +   uint8_t tm_flags)
> > +{
> > +   struct qedf_ioreq *io_req;
> > +   struct qedf_mp_req *tm_req;
> > +   struct fcoe_task_context *task;
> > +   struct fc_frame_header *fc_hdr;
> > +   struct fcp_cmnd *fcp_cmnd;
> > +   struct qedf_ctx *qedf = fcport->qedf;
> > +   int rc = 0;
> > +   uint16_t xid;
> > +   uint32_t sid, did;
> > +   int tmo = 0;
> > +   unsigned long flags;
> > +
> > +   if (!sc_cmd) {
> > +   QEDF_ERR(&(qedf->dbg_ctx), "invalid arg\n");
> > +   return FAILED;
> > +   }
> > +
> > +   if (!(test_bit(QEDF_RPORT_SESSION_READY, >flags))) {
> > +   QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n");
> > +   rc = FAILED;
> > +   return FAILED;
> > +   }
> > +
> > +   scsi_block_requests(qedf->lport->host);
> > +
> Typically, EH commands will be executed after the scsi host is stopped
> and no commands are outstanding.
> So there's no point in issuing 'scsi_block_requests()' here.
> 

Will remove.

> Cheers,
> 
> Hannes
> 
--
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 RFC 2/5] qedf: Add QLogic FastLinQ offload FCoE driver framework.

2017-01-09 Thread Chad Dupuis

On Wed, 28 Dec 2016, 9:00am -, Hannes Reinecke wrote:

> On 12/23/2016 08:17 PM, Dupuis, Chad wrote:
> > From: "Dupuis, Chad" <chad.dup...@cavium.com>
> > 
> > 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
> > 
> > Signed-off-by: Nilesh Javali <nilesh.jav...@cavium.com>
> > Signed-off-by: Manish Rangankar <manish.rangan...@cavium.com>
> > Signed-off-by: Saurav Kashyap <saurav.kash...@cavium.com>
> > Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
> > ---
> >  MAINTAINERS  |6 +
> >  drivers/scsi/Kconfig |1 +
> >  drivers/scsi/qedf/Kconfig|   11 +
> >  drivers/scsi/qedf/Makefile   |5 +
> >  drivers/scsi/qedf/qedf.h |  555 ++
> >  drivers/scsi/qedf/qedf_attr.c|  165 ++
> >  drivers/scsi/qedf/qedf_dbg.c |  192 +++
> >  drivers/scsi/qedf/qedf_dbg.h |  153 ++
> >  drivers/scsi/qedf/qedf_debugfs.c |  472 +
> >  drivers/scsi/qedf/qedf_main.c| 3519 
> > ++
> >  drivers/scsi/qedf/qedf_version.h |   15 +
> >  11 files changed, 5094 insertions(+)
> >  create mode 100644 drivers/scsi/qedf/Kconfig
> >  create mode 100644 drivers/scsi/qedf/Makefile
> >  create mode 100644 drivers/scsi/qedf/qedf.h
> >  create mode 100644 drivers/scsi/qedf/qedf_attr.c
> >  create mode 100644 drivers/scsi/qedf/qedf_dbg.c
> >  create mode 100644 drivers/scsi/qedf/qedf_dbg.h
> >  create mode 100644 drivers/scsi/qedf/qedf_debugfs.c
> >  create mode 100644 drivers/scsi/qedf/qedf_main.c
> >  create mode 100644 drivers/scsi/qedf/qedf_version.h
> > 
> [ .. ]
> > +/* Returns true if we have a valid vlan, false otherwise */
> > +static bool qedf_initiate_fipvlan_req(struct qedf_ctx *qedf)
> > +{
> > +   int rc;
> > +
> > +   if (atomic_read(>link_state) != QEDF_LINK_UP) {
> > +   QEDF_ERR(&(qedf->dbg_ctx), "Link not up.\n");
> > +   return  false;
> > +   }
> > +
> > +   while (qedf->fipvlan_retries--) {
> > +   if (qedf->vlan_id > 0)
> > +   return true;
> Some weird FCoE bridges (most notably HP VirtualConnect) return a VLAN
> ID of '0'. Shouldn't you rather test for '>= 0' here?

Will look into this but isn't a VLAN ID of 0 not valid?

> 
> [ .. ]
> > +
> > +static void qedf_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
> > +   void *arg)
> > +{
> > +   struct fc_exch *exch = fc_seq_exch(seq);
> > +   struct fc_lport *lport = exch->lp;
> > +   struct qedf_ctx *qedf = lport_priv(lport);
> > +
> > +   if (!qedf) {
> > +   QEDF_ERR(NULL, "qedf is NULL.\n");
> > +   return;
> > +   }
> > +
> > +   /*
> > +* If ERR_PTR is set then don't try to stat anything as it will cause
> > +* a crash when we access fp.
> > +*/
> > +   if (fp == ERR_PTR(-FC_EX_TIMEOUT) ||
> > +   fp == ERR_PTR(-FC_EX_CLOSED)) {
> > +   QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_ELS,
> > +   "fp has ERR_PTR() set.\n");
> > +   goto skip_stat;
> > +   }
> 
> Please use
> 
> if (IS_ERR(fp)) {
> 
> here instead of checking for individual error codes; if 'fp' has a
> different error value you'll continue with an invalid fp from here on.
>

Will fix up.
 
> [ .. ]
> 
> > +/**
> > + * qedf_xmit - qedf FCoE frame transmit function
> > + *
> > + */
> > +static int qedf_xmit(struct fc_lport *lport, struct fc_frame *fp)
> > +{
> > +   struct fc_lport *base_lport;
> > +   struct qedf_ctx *qedf;
> > +   struct ethhdr   *eh;
> > +   struct fcoe_crc_eof *cp;
> > +   struct sk_buff  *skb;
> > +   struct fc_frame_header  *fh;
> > +   struct fcoe_hdr *hp;
> > +   u8  sof, eof;
> > +   u32 crc;
> > +   unsigned inthlen, tlen, elen;
> > +   int   

Re: [PATCH 13/20] libfc: Remove fc_rport_init()

2016-10-19 Thread Chad Dupuis


On Tue, 18 Oct 2016, 8:01am -, Hannes Reinecke wrote:

> Function is empty now and can be removed.
> 
> Signed-off-by: Hannes Reinecke <h...@suse.com>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c |  1 -
>  drivers/scsi/fcoe/fcoe_ctlr.c |  1 -
>  drivers/scsi/libfc/fc_rport.c | 10 --
>  include/scsi/libfc.h  |  1 -
>  4 files changed, 13 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index f9ddb61..0990130 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -970,7 +970,6 @@ static int bnx2fc_libfc_config(struct fc_lport *lport)
>   sizeof(struct libfc_function_template));
>   fc_elsct_init(lport);
>   fc_exch_init(lport);
> - fc_rport_init(lport);
>   fc_disc_init(lport);
>   fc_disc_config(lport, lport);
>   return 0;
> diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
> index 12efc1d..cea57e2 100644
> --- a/drivers/scsi/fcoe/fcoe_ctlr.c
> +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
> @@ -3235,7 +3235,6 @@ int fcoe_libfc_config(struct fc_lport *lport, struct 
> fcoe_ctlr *fip,
>   fc_exch_init(lport);
>   fc_elsct_init(lport);
>   fc_lport_init(lport);
> - fc_rport_init(lport);
>   fc_disc_init(lport);
>   fcoe_ctlr_mode_set(lport, fip, fip->mode);
>   return 0;
> diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
> index 6e50226..110a707 100644
> --- a/drivers/scsi/libfc/fc_rport.c
> +++ b/drivers/scsi/libfc/fc_rport.c
> @@ -2182,16 +2182,6 @@ void fc_rport_flush_queue(void)
>  EXPORT_SYMBOL(fc_rport_flush_queue);
>  
>  /**
> - * fc_rport_init() - Initialize the remote port layer for a local port
> - * @lport: The local port to initialize the remote port layer for
> - */
> -int fc_rport_init(struct fc_lport *lport)
> -{
> - return 0;
> -}
> -EXPORT_SYMBOL(fc_rport_init);
> -
> -/**
>   * fc_rport_fcp_prli() - Handle incoming PRLI for the FCP initiator.
>   * @rdata: remote port private
>   * @spp_len: service parameter page length
> diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
> index 57630c5..a776901 100644
> --- a/include/scsi/libfc.h
> +++ b/include/scsi/libfc.h
> @@ -978,7 +978,6 @@ static inline bool fc_fcp_is_read(const struct fc_fcp_pkt 
> *fsp)
>  /*
>   * REMOTE PORT LAYER
>   */
> -int fc_rport_init(struct fc_lport *);
>  void fc_rport_terminate_io(struct fc_rport *);
>  struct fc_rport_priv *fc_rport_lookup(const struct fc_lport *lport,
> u32 port_id);
> 

Reviewed-by: Chad Dupuis <chad.dup...@cavium.com>
--
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 10/20] libfc: Replace ->rport_logoff callback with function call

2016-10-19 Thread Chad Dupuis


On Tue, 18 Oct 2016, 8:01am -, Hannes Reinecke wrote:

> The ->rport_logoff callback only ever had one implementation,
> so we can as well call it directly and drop the callback.
> 
> Signed-off-by: Hannes Reinecke <h...@suse.com>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_tgt.c |  3 +--
>  drivers/scsi/fcoe/fcoe_ctlr.c|  8 
>  drivers/scsi/libfc/fc_disc.c |  8 
>  drivers/scsi/libfc/fc_lport.c| 10 +-
>  drivers/scsi/libfc/fc_rport.c|  8 +++-
>  include/scsi/libfc.h |  9 +
>  6 files changed, 18 insertions(+), 28 deletions(-)
> 

Straightforward conversion.

Reviewed-by: Chad Dupuis <chad.dup...@cavium.com>
--
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 00/20] libfc callback cleanup

2016-10-19 Thread Chad Dupuis

On Tue, 18 Oct 2016, 8:01am -, Hannes Reinecke wrote:

> Hi all,
> 
> it has been bugging me for a while that libfc has tons of callbacks
> in an attempt to abstract things away. But as it turned out
> no-one ever used those, rendering them quite pointless.
> As I got some time to kill on the train back from Vienna I've decided
> to finally kill them and call the functions directly.
> 
> As usual, comments and reviews are welcome.
> 
> Hannes Reinecke (20):
>   libfc: Replace ->seq_els_rsp_send callback with function call
>   libfc: Replace ->lport_reset callback with function call
>   libfc: Replace ->lport_recv with function call
>   libfc: Replace ->exch_seq_send callback with function call
>   libfc: Replace ->rport_destroy callback with function call
>   libfc: Replace ->rport_lookup callback with function call
>   scsi_transport_fc: rename 'fc_rport_create' to 'fc_remote_port_create'
>   libfc: Replace ->rport_create callback with function call
>   libfc: Replace ->rport_login callback with function call
>   libfc: Replace ->rport_logoff callback with function call
>   libfc: Replace ->rport_recv_req callback with function call
>   libfc: Replace ->rport_flush_queue callback with function call
>   libfc: Remove fc_rport_init()
>   libfc: Replace ->seq_send callback with function call
>   libfc: Replace ->seq_exch_abort callback with function call
>   libfc: Replace ->exch_done callback with function call
>   libfc: Replace ->seq_start_next callback with function call
>   libfc: Replace ->seq_set_resp callback with direct function call
>   libfc: Replace ->seq_assign callback with function call
>   libfc: Replace ->seq_release callback with function call
> 
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c |   1 -
>  drivers/scsi/bnx2fc/bnx2fc_tgt.c  |   3 +-
>  drivers/scsi/fcoe/fcoe_ctlr.c |  35 ---
>  drivers/scsi/fnic/fnic_scsi.c |   2 +-
>  drivers/scsi/libfc/fc_disc.c  |  33 ---
>  drivers/scsi/libfc/fc_elsct.c |   2 +-
>  drivers/scsi/libfc/fc_exch.c  | 104 ++--
>  drivers/scsi/libfc/fc_fcp.c   |  45 -
>  drivers/scsi/libfc/fc_libfc.c |   2 +-
>  drivers/scsi/libfc/fc_lport.c |  62 ++--
>  drivers/scsi/libfc/fc_rport.c | 167 ++--
>  drivers/scsi/scsi_transport_fc.c  |   8 +-
>  drivers/target/tcm_fc/tfc_cmd.c   |  20 ++--
>  drivers/target/tcm_fc/tfc_io.c|   4 +-
>  include/scsi/libfc.h  | 195 
> ++
>  15 files changed, 254 insertions(+), 429 deletions(-)
> 

Hannes, thanks for doing this.  Should make the code much more readable. 
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/2] libfc/fcoe Fixes

2016-09-29 Thread Chad Dupuis


On Thu, 29 Sep 2016, 8:06am -, Hannes Reinecke wrote:

> Hi Chad,
> 
> On 09/28/2016 07:30 PM, Chad Dupuis wrote:
> > 
> > During testing we fixed a deadlock we found in libfc while logging off from 
> > the
> > fabric if an ELS command was still outstanding.  Also we wanted to make 
> > clear
> > virtual link handling a little more robust when the fcoe_ctlr is not logged
> > into the fabric.
> > 
> > Please apply at your earliest convenience.
> > 
> > Thanks,
> > Chad
> > 
> > Chad Dupuis (2):
> >   fcoe: Harden CVL handling when we have not logged into the fabric.
> >   libfc: Do not take rdata->rp_mutex when processing a -FC_EX_CLOSED ELS
> > response.
> > 
> >  drivers/scsi/fcoe/fcoe_ctlr.c | 35 ---
> >  drivers/scsi/libfc/fc_rport.c | 32 
> >  2 files changed, 56 insertions(+), 11 deletions(-)
> > 
> I'm currently preparing a larger FCoE patchset (for my VN2VN fixes),
> which also includes the second patch.
> Should I take the first one, too, and submit it in one bunch or do you
> prefer to keep both separate?
> 
> Cheers,
> 
> Hannes
> 

I'm fine either way to be honest...whatever is easier for Martin.
--
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/2] libfc/fcoe Fixes

2016-09-28 Thread Chad Dupuis
Hi James, Martin

During testing we fixed a deadlock we found in libfc while logging off from the
fabric if an ELS command was still outstanding.  Also we wanted to make clear
virtual link handling a little more robust when the fcoe_ctlr is not logged
into the fabric.

Please apply at your earliest convenience.

Thanks,
Chad

Chad Dupuis (2):
  fcoe: Harden CVL handling when we have not logged into the fabric.
  libfc: Do not take rdata->rp_mutex when processing a -FC_EX_CLOSED ELS
response.

 drivers/scsi/fcoe/fcoe_ctlr.c | 35 ---
 drivers/scsi/libfc/fc_rport.c | 32 
 2 files changed, 56 insertions(+), 11 deletions(-)

-- 
1.8.5.6

--
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] fcoe: Harden CVL handling when we have not logged into the fabric.

2016-09-28 Thread Chad Dupuis
If we haven't logged into the fabric yet we want to be a little more nuanced
with our CVL handling than what we've been:

- If the FCF has been selected, check the source MAC to make sure the frame is
from the FCF we've selected.
- If a FCF is selected and the CVL is from the FCF but we have not logged in
yet, then reset everything and go back to solicitation.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/fcoe/fcoe_ctlr.c | 35 ---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index dcf3653..aed8a52 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -1316,7 +1316,7 @@ drop:
  * The overall length has already been checked.
  */
 static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
-struct fip_header *fh)
+struct sk_buff *skb)
 {
struct fip_desc *desc;
struct fip_mac_desc *mp;
@@ -1331,14 +1331,18 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr 
*fip,
int num_vlink_desc;
int reset_phys_port = 0;
struct fip_vn_desc **vlink_desc_arr = NULL;
+   struct fip_header *fh = (struct fip_header *)skb->data;
+   struct ethhdr *eh = eth_hdr(skb);
 
LIBFCOE_FIP_DBG(fip, "Clear Virtual Link received\n");
 
-   if (!fcf || !lport->port_id) {
+   if (!fcf) {
/*
 * We are yet to select best FCF, but we got CVL in the
 * meantime. reset the ctlr and let it rediscover the FCF
 */
+   LIBFCOE_FIP_DBG(fip, "Resetting fcoe_ctlr as FCF has not been "
+   "selected yet\n");
mutex_lock(>ctlr_mutex);
fcoe_ctlr_reset(fip);
mutex_unlock(>ctlr_mutex);
@@ -1346,6 +1350,31 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr 
*fip,
}
 
/*
+* If we've selected an FCF check that the CVL is from there to avoid
+* processing CVLs from an unexpected source.  If it is from an
+* unexpected source drop it on the floor.
+*/
+   if (!ether_addr_equal(eh->h_source, fcf->fcf_mac)) {
+   LIBFCOE_FIP_DBG(fip, "Dropping CVL due to source address "
+   "mismatch with FCF src=%pM\n", eh->h_source);
+   return;
+   }
+
+   /*
+* If we haven't logged into the fabric but receive a CVL we should
+* reset everything and go back to solicitation.
+*/
+   if (!lport->port_id) {
+   LIBFCOE_FIP_DBG(fip, "lport not logged in, resoliciting\n");
+   mutex_lock(>ctlr_mutex);
+   fcoe_ctlr_reset(fip);
+   mutex_unlock(>ctlr_mutex);
+   fc_lport_reset(fip->lp);
+   fcoe_ctlr_solicit(fip, NULL);
+   return;
+   }
+
+   /*
 * mask of required descriptors.  Validating each one clears its bit.
 */
desc_mask = BIT(FIP_DT_MAC) | BIT(FIP_DT_NAME);
@@ -1576,7 +1605,7 @@ static int fcoe_ctlr_recv_handler(struct fcoe_ctlr *fip, 
struct sk_buff *skb)
if (op == FIP_OP_DISC && sub == FIP_SC_ADV)
fcoe_ctlr_recv_adv(fip, skb);
else if (op == FIP_OP_CTRL && sub == FIP_SC_CLR_VLINK)
-   fcoe_ctlr_recv_clr_vlink(fip, fiph);
+   fcoe_ctlr_recv_clr_vlink(fip, skb);
kfree_skb(skb);
return 0;
 drop:
-- 
1.8.5.6

--
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] libfc: Do not take rdata->rp_mutex when processing a -FC_EX_CLOSED ELS response.

2016-09-28 Thread Chad Dupuis
When an ELS response handler receives a -FC_EX_CLOSED, the rdata->rp_mutex is
already held which can lead to a deadlock condition like the following stack 
trace:

[] fc_rport_plogi_resp+0x28/0x200 [libfc]
[] fc_invoke_resp+0x6a/0xe0 [libfc]
[] fc_exch_mgr_reset+0x1b8/0x280 [libfc]
[] fc_rport_logoff+0x43/0xd0 [libfc]
[] fc_disc_stop+0x6d/0xf0 [libfc]
[] fc_disc_stop_final+0xe/0x20 [libfc]
[] fc_fabric_logoff+0x17/0x70 [libfc]

The other ELS handlers need to follow the FLOGI response handler and simply do
a kref_put against the fc_rport_priv struct and exit when receving a
-FC_EX_CLOSED response.

Signed-off-by: Chad Dupuis <chad.dup...@cavium.com>
---
 drivers/scsi/libfc/fc_rport.c | 32 
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
index 93f5961..6f19c12 100644
--- a/drivers/scsi/libfc/fc_rport.c
+++ b/drivers/scsi/libfc/fc_rport.c
@@ -884,10 +884,13 @@ static void fc_rport_plogi_resp(struct fc_seq *sp, struct 
fc_frame *fp,
u16 cssp_seq;
u8 op;
 
-   mutex_lock(>rp_mutex);
-
FC_RPORT_DBG(rdata, "Received a PLOGI %s\n", fc_els_resp_type(fp));
 
+   if (fp == ERR_PTR(-FC_EX_CLOSED))
+   goto put;
+
+   mutex_lock(>rp_mutex);
+
if (rdata->rp_state != RPORT_ST_PLOGI) {
FC_RPORT_DBG(rdata, "Received a PLOGI response, but in state "
 "%s\n", fc_rport_state(rdata));
@@ -926,6 +929,7 @@ out:
fc_frame_free(fp);
 err:
mutex_unlock(>rp_mutex);
+put:
kref_put(>kref, lport->tt.rport_destroy);
 }
 
@@ -1008,10 +1012,13 @@ static void fc_rport_prli_resp(struct fc_seq *sp, 
struct fc_frame *fp,
u8 op;
u8 resp_code = 0;
 
-   mutex_lock(>rp_mutex);
-
FC_RPORT_DBG(rdata, "Received a PRLI %s\n", fc_els_resp_type(fp));
 
+   if (fp == ERR_PTR(-FC_EX_CLOSED))
+   goto put;
+
+   mutex_lock(>rp_mutex);
+
if (rdata->rp_state != RPORT_ST_PRLI) {
FC_RPORT_DBG(rdata, "Received a PRLI response, but in state "
 "%s\n", fc_rport_state(rdata));
@@ -1079,6 +1086,7 @@ out:
fc_frame_free(fp);
 err:
mutex_unlock(>rp_mutex);
+put:
kref_put(>kref, rdata->local_port->tt.rport_destroy);
 }
 
@@ -1156,10 +1164,13 @@ static void fc_rport_rtv_resp(struct fc_seq *sp, struct 
fc_frame *fp,
struct fc_rport_priv *rdata = rdata_arg;
u8 op;
 
-   mutex_lock(>rp_mutex);
-
FC_RPORT_DBG(rdata, "Received a RTV %s\n", fc_els_resp_type(fp));
 
+   if (fp == ERR_PTR(-FC_EX_CLOSED))
+   goto put;
+
+   mutex_lock(>rp_mutex);
+
if (rdata->rp_state != RPORT_ST_RTV) {
FC_RPORT_DBG(rdata, "Received a RTV response, but in state "
 "%s\n", fc_rport_state(rdata));
@@ -1201,6 +1212,7 @@ out:
fc_frame_free(fp);
 err:
mutex_unlock(>rp_mutex);
+put:
kref_put(>kref, rdata->local_port->tt.rport_destroy);
 }
 
@@ -1292,10 +1304,13 @@ static void fc_rport_adisc_resp(struct fc_seq *sp, 
struct fc_frame *fp,
struct fc_els_adisc *adisc;
u8 op;
 
-   mutex_lock(>rp_mutex);
-
FC_RPORT_DBG(rdata, "Received a ADISC response\n");
 
+   if (fp == ERR_PTR(-FC_EX_CLOSED))
+   goto put;
+
+   mutex_lock(>rp_mutex);
+
if (rdata->rp_state != RPORT_ST_ADISC) {
FC_RPORT_DBG(rdata, "Received a ADISC resp but in state %s\n",
 fc_rport_state(rdata));
@@ -1330,6 +1345,7 @@ out:
fc_frame_free(fp);
 err:
mutex_unlock(>rp_mutex);
+put:
kref_put(>kref, rdata->local_port->tt.rport_destroy);
 }
 
-- 
1.8.5.6

--
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: [REPOST PATCH 1/5] scsi: bnx2i: convert to kworker

2016-09-13 Thread Chad Dupuis

On Fri, 9 Sep 2016, 11:28am -, Martin K. Petersen wrote:

> > "Johannes" == Johannes Thumshirn  writes:
> 
> >> On Wed, Aug 17, 2016 at 12:09:59PM +0200, Sebastian Andrzej Siewior
> wrote:
> >> The driver creates its own per-CPU threads which are updated based on
> >> CPU hotplug events. It is also possible to use kworkers and remove
> >> some of the infrastructure get the same job done while saving a few
> >> lines of code.
> 
> Johannes> I'm sorry it took so long but for the whole series: Tested-by:
> Johannes> Johannes Thumshirn  Acked-by: Johannes
> Johannes> Thumshirn 
> 
> Johannes> Testing was conducted by booting from a QLogic BCM57840 CNA.
> 
> Chad?
> 

We're regression testing the patches now.  Please hold off on applying 
them. 
--
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] bnx2fc: Simplify code

2016-09-08 Thread Chad Dupuis

On Sat, 3 Sep 2016, 7:05am -, Christophe JAILLET wrote:

> Calling 'list_splice' followed by 'INIT_LIST_HEAD' is equivalent to
> 'list_splice_init'.
> 
> This has been spotted with the following coccinelle script:
> /
> @@
> expression y,z;
> @@
> 
> -   list_splice(y,z);
> -   INIT_LIST_HEAD(y);
> +   list_splice_init(y,z);
> 
> Signed-off-by: Christophe JAILLET <christophe.jail...@wanadoo.fr>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index a5052dd8d7e6..88be12a02764 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -2765,8 +2765,7 @@ static void __exit bnx2fc_mod_exit(void)
>* held.
>*/
>   mutex_lock(_dev_lock);
> - list_splice(_list, _be_deleted);
> - INIT_LIST_HEAD(_list);
> + list_splice_init(_list, _be_deleted);
>   adapter_count = 0;
>   mutex_unlock(_dev_lock);
>  
> 

Looks ok to me.

Acked-by: Chad Dupuis <chad.dup...@qlogic.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] [SCSI] bnx2fc: mark symbols static where possible

2016-09-08 Thread Chad Dupuis

On Sun, 4 Sep 2016, 6:52am -, Baoyou Xie wrote:

> We get a few warnings when building kernel with W=1:
> drivers/scsi/bnx2fc/bnx2fc_els.c:257:6: warning: no previous prototype for 
> 'bnx2fc_srr_compl' [-Wmissing-prototypes]
> drivers/scsi/bnx2fc/bnx2fc_els.c:367:6: warning: no previous prototype for 
> 'bnx2fc_rec_compl' [-Wmissing-prototypes]
> drivers/scsi/bnx2fc/bnx2fc_fcoe.c:628:5: warning: no previous prototype for 
> 'bnx2fc_percpu_io_thread' [-Wmissing-prototypes]
> drivers/scsi/bnx2fc/bnx2fc_fcoe.c:1413:26: warning: no previous prototype for 
> 'bnx2fc_interface_create' [-Wmissing-prototypes]
> drivers/scsi/bnx2fc/bnx2fc_hwi.c:997:21: warning: no previous prototype for 
> 'bnx2fc_alloc_work' [-Wmissing-prototypes]
> drivers/scsi/bnx2fc/bnx2fc_io.c:1082:5: warning: no previous prototype for 
> 'bnx2fc_abts_cleanup' [-Wmissing-prototypes]
> 
> 
> In fact, these functions are only used in the file in which they are
> declared and don't need a declaration, but can be made static.
> so this patch marks these functions with 'static'.
> 
> Signed-off-by: Baoyou Xie <baoyou@linaro.org>
> ---
>  drivers/scsi/bnx2fc/bnx2fc_els.c  | 4 ++--
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 9 +
>  drivers/scsi/bnx2fc/bnx2fc_hwi.c  | 2 +-
>  drivers/scsi/bnx2fc/bnx2fc_io.c   | 2 +-
>  4 files changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_els.c 
> b/drivers/scsi/bnx2fc/bnx2fc_els.c
> index 5beea77..68ca518 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_els.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_els.c
> @@ -254,7 +254,7 @@ int bnx2fc_send_rls(struct bnx2fc_rport *tgt, struct 
> fc_frame *fp)
>   return rc;
>  }
>  
> -void bnx2fc_srr_compl(struct bnx2fc_els_cb_arg *cb_arg)
> +static void bnx2fc_srr_compl(struct bnx2fc_els_cb_arg *cb_arg)
>  {
>   struct bnx2fc_mp_req *mp_req;
>   struct fc_frame_header *fc_hdr, *fh;
> @@ -364,7 +364,7 @@ srr_compl_done:
>   kref_put(_io_req->refcount, bnx2fc_cmd_release);
>  }
>  
> -void bnx2fc_rec_compl(struct bnx2fc_els_cb_arg *cb_arg)
> +static void bnx2fc_rec_compl(struct bnx2fc_els_cb_arg *cb_arg)
>  {
>   struct bnx2fc_cmd *orig_io_req, *new_io_req;
>   struct bnx2fc_cmd *rec_req;
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
> b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index a5052dd..5eb38c7 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -625,7 +625,7 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
>   *
>   * @arg: ptr to bnx2fc_percpu_info structure
>   */
> -int bnx2fc_percpu_io_thread(void *arg)
> +static int bnx2fc_percpu_io_thread(void *arg)
>  {
>   struct bnx2fc_percpu_s *p = arg;
>   struct bnx2fc_work *work, *tmp;
> @@ -1410,9 +1410,10 @@ bind_err:
>   return NULL;
>  }
>  
> -struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba,
> -   struct net_device *netdev,
> -   enum fip_state fip_mode)
> +static struct bnx2fc_interface *
> +bnx2fc_interface_create(struct bnx2fc_hba *hba,
> + struct net_device *netdev,
> + enum fip_state fip_mode)
>  {
>   struct fcoe_ctlr_device *ctlr_dev;
>   struct bnx2fc_interface *interface;
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_hwi.c 
> b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> index 28c671b..5ff9f89 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_hwi.c
> @@ -994,7 +994,7 @@ void bnx2fc_arm_cq(struct bnx2fc_rport *tgt)
>  
>  }
>  
> -struct bnx2fc_work *bnx2fc_alloc_work(struct bnx2fc_rport *tgt, u16 wqe)
> +static struct bnx2fc_work *bnx2fc_alloc_work(struct bnx2fc_rport *tgt, u16 
> wqe)
>  {
>   struct bnx2fc_work *work;
>   work = kzalloc(sizeof(struct bnx2fc_work), GFP_ATOMIC);
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
> index 8f24d60..f501095 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
> @@ -1079,7 +1079,7 @@ int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
>   return bnx2fc_initiate_tmf(sc_cmd, FCP_TMF_LUN_RESET);
>  }
>  
> -int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req)
> +static int bnx2fc_abts_cleanup(struct bnx2fc_cmd *io_req)
>  {
>   struct bnx2fc_rport *tgt = io_req->tgt;
>   int rc = SUCCESS;
> 

Looks ok.

Acked-by: Chad Dupuis <chad.dup...@qlogic.com>
--
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: [RFC PATCH 0/4] libfc: Do not send ABTS when resetting exchanges

2016-08-18 Thread Chad Dupuis

On Fri, 5 Aug 2016, 12:54pm -, Hannes Reinecke wrote:

> Hi all,
> 
> here's a patchset to fixup an issue reported by QLogic: when running
> against a certain target the libfc stack would get in an infinite loop
> sending ABTS when trying to reset a connection.
> The problem is that the libfc stack is sending ABTS for any open exchanges
> when removing an rport, totally ignorant of the fact that in most cases
> we are already logged out of the said remote port.
> This patchset alters the handling slightly so that we will only ever reset
> open exchanges after we have either logged out of the port or an implicit
> logout can be assumed.
> With that we don't need to send ABTS any more during rport reset.
> 
> As usual, comments and reviews are welcome.
> 
> Hannes Reinecke (4):
>   libfc: Issue PRLI after a PRLO has been received
>   libfc: send LOGO for PLOGI failure
>   libfc: reset exchange manager during LOGO handling
>   libfc: do not send ABTS when resetting exchanges
> 
>  drivers/scsi/libfc/fc_exch.c  |  1 -
>  drivers/scsi/libfc/fc_rport.c | 26 +++---
>  2 files changed, 23 insertions(+), 4 deletions(-)
> 
> 

Hannes, thanks for posting this.  I've been working witih a customer of 
ours and have successfully tested this patch set.

Reviewed-by: Chad Dupuis <chad.dup...@qlogic.com>
Tested-by: Chad Dupuis <chad.dup...@qlogic.com>
--
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/22] libfc: Revisit kref handling

2016-08-18 Thread Chad Dupuis


On Wed, 3 Aug 2016, 1:13pm -, Hannes Reinecke wrote:

> The kref handling in fc_rport is a mess. This patch updates
> the kref handling according to the following rules:
> 
> - Take a reference whenever scheduling a workqueue
> - Take a reference whenever an ELS command is send
> - Drop the reference at the end of the workqueue function
> - Drop the reference at the end of handling ELS replies
> - Take a reference when allocating an rport
> - Drop the reference when removing an rport
> 
> Signed-off-by: Hannes Reinecke <h...@suse.com>
> ---
>  drivers/scsi/libfc/fc_rport.c | 134 
> --
>  1 file changed, 103 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/scsi/libfc/fc_rport.c b/drivers/scsi/libfc/fc_rport.c
> index 93f5961..6a98bb8 100644
> --- a/drivers/scsi/libfc/fc_rport.c
> +++ b/drivers/scsi/libfc/fc_rport.c
> @@ -44,6 +44,17 @@
>   * path this potential over-use of the mutex is acceptable.
>   */
>  

<-- snip -->

Yes, this took quite a few iterations to get right but your rules make 
sense.  I've tested with this patch and it successfully passed.

Tested-by: Chad Dupuis <chad.dup...@qlogic.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] scsi: bnx2i: convert to kworker

2016-08-16 Thread Chad Dupuis

On Fri, 12 Aug 2016, 9:24pm -, Martin K. Petersen wrote:

> > "Sebastian" == Sebastian Andrzej Siewior  writes:
> 
> Sebastian> On 2016-07-04 19:40:37 [+0200], To linux-scsi@vger.kernel.org 
> wrote:
> >> The driver creates its own per-CPU threads which are updated based on
> >> CPU hotplug events. It is also possible to use kworkers and remove
> >> some of the infrastructure get the same job done while saving a few
> >> lines of code.
> 
> Sebastian> ping
> 
> People generally don't rummage through their inboxes looking for old
> stuff to review. If nobody has responded to your patch within a week or
> two it's best to resubmit and get the proposed changes back on their
> screens.
> 

Yes, please repost. 
--
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] bnx2fc: replace printk() with BNX2FC_IO_DBG()

2016-05-31 Thread Chad Dupuis
> The "fcp_rsp_code = %d" message isn't an error, it's meant to
> be informative only.
> This patch prevents a flood of such messages in some situations.
>
> Tested-by: Laurence Oberman <lober...@redhat.com>
> Signed-off-by: Maurizio Lombardi <mlomb...@redhat.com>
> ---
> drivers/scsi/bnx2fc/bnx2fc_io.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c
>b/drivers/scsi/bnx2fc/bnx2fc_io.c
> index 026f394..8f24d60 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_io.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
> @@ -1758,7 +1758,7 @@ static void bnx2fc_parse_fcp_rsp(struct bnx2fc_cmd
>*io_req,
 >  if ((fcp_rsp_len == 4) || (fcp_rsp_len == 8)) {
 >  /* Only for task management function */
 >  io_req->fcp_rsp_code = rq_data[3];
> - printk(KERN_ERR PFX "fcp_rsp_code = %d\n",
> + BNX2FC_IO_DBG(io_req, "fcp_rsp_code = %d\n",
 >  io_req->fcp_rsp_code);
 >  }
 
> -- 
> Maurizio Lombardi

Make sense to move this to a debug level.

Acked-by: Chad Dupuis <chad.dup...@qlogic.com>


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


[PATCH v2 5/5] bnx2fc: Update version number to 2.10.3.

2016-04-07 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 106788f..fdd4eb4 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -65,7 +65,7 @@
 #include "bnx2fc_constants.h"
 
 #define BNX2FC_NAME"bnx2fc"
-#define BNX2FC_VERSION "2.9.6"
+#define BNX2FC_VERSION "2.10.3"
 
 #define PFX"bnx2fc: "
 
-- 
2.0.0.rc0.26.g779792a

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


[PATCH v2 4/5] bnx2fc: Check sc_cmd device and host pointer before returning the command to the mid-layer.

2016-04-07 Thread Chad Dupuis
When we are in connection recovery and the internal command timer on a request
pops, either the scsi_cmnd->device or scsi_cmnd->device->host back pointers may
be NULL as the device that the command that the request was submitted on may
have been subsequently reaped due to the connection recovery. This can cause
one or both of the pointers above to be NULL and cause a system crash if we try
to return the command to the midlayer.

Instead, double check the pointers before the return to the midlayer so as to
prevent the crash and let the upper layers finish the session recovery and
rediscover the device.

Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index ac8fb2a..25a1e19 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -179,12 +179,24 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, 
int err_code)
 
bnx2fc_unmap_sg_list(io_req);
io_req->sc_cmd = NULL;
+
+   /* Sanity checks before returning command to mid-layer */
if (!sc_cmd) {
printk(KERN_ERR PFX "scsi_done - sc_cmd NULL. "
"IO(0x%x) already cleaned up\n",
   io_req->xid);
return;
}
+   if (!sc_cmd->device) {
+   pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid);
+   return;
+   }
+   if (!sc_cmd->device->host) {
+   pr_err(PFX "0x%x: sc_cmd->device->host is NULL.\n",
+   io_req->xid);
+   return;
+   }
+
sc_cmd->result = err_code << 16;
 
BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n",
-- 
2.0.0.rc0.26.g779792a

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


[PATCH v2 2/5] bnx2fc: Print when we send a fip keep alive.

2016-04-07 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index b0305b0..365101a 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -122,6 +122,11 @@ module_param_named(queue_depth, bnx2fc_queue_depth, uint, 
S_IRUGO);
 MODULE_PARM_DESC(queue_depth, " Change the default queue depth of SCSI devices 
"
"attached via bnx2fc.");
 
+uint bnx2fc_log_fka;
+module_param_named(log_fka, bnx2fc_log_fka, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is "
+   "initiating a FIP keep alive when debug logging is enabled.");
+
 static int bnx2fc_cpu_callback(struct notifier_block *nfb,
 unsigned long action, void *hcpu);
 /* notification function for CPU hotplug events */
@@ -1076,6 +1081,20 @@ static u8 *bnx2fc_get_src_mac(struct fc_lport *lport)
  */
 static void bnx2fc_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
 {
+   struct fip_header *fiph;
+   struct ethhdr *eth_hdr;
+   u16 op;
+   u8 sub;
+
+   fiph = (struct fip_header *) ((void *)skb->data + 2 * ETH_ALEN + 2);
+   eth_hdr = (struct ethhdr *)skb_mac_header(skb);
+   op = ntohs(fiph->fip_op);
+   sub = fiph->fip_subcode;
+
+   if (op == FIP_OP_CTRL && sub == FIP_SC_SOL && bnx2fc_log_fka)
+   BNX2FC_MISC_DBG("Sending FKA from %pM to %pM.\n",
+   eth_hdr->h_source, eth_hdr->h_dest);
+
skb->dev = bnx2fc_from_ctlr(fip)->netdev;
dev_queue_xmit(skb);
 }
-- 
2.0.0.rc0.26.g779792a

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


[PATCH v2 0/5] bnx2fc: Update driver to version 2.10.3.

2016-04-07 Thread Chad Dupuis
Hi James, Martin,

Please apply the patch series for the next merge window at your earliest
convenience.

V2 changes:

- Made netdev device name print pr_info instead of pr_err.
- Made TMF timeout settable via sysfs node instead of modparam.

Thanks,
Chad

Chad Dupuis (4):
  bnx2fc: Print when we send a fip keep alive.
  bnx2fc: Print netdev device name when FCoE is successfully
initialized.
  bnx2fc: Check sc_cmd device and host pointer before returning the
command to the mid-layer.
  bnx2fc: Update version number to 2.10.3.

Joe Carnuccio (1):
  bnx2fc: Add driver tunables.

 drivers/scsi/bnx2fc/bnx2fc.h  |   3 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 100 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c   |  14 +-
 3 files changed, 114 insertions(+), 3 deletions(-)

-- 
2.0.0.rc0.26.g779792a

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


[PATCH v2 3/5] bnx2fc: Print netdev device name when FCoE is successfully initialized.

2016-04-07 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 365101a..a188199 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2039,6 +2039,8 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
return;
}
 
+   pr_info(PFX "FCoE initialized for %s.\n", dev->netdev->name);
+
/* Add HBA to the adapter list */
mutex_lock(_dev_lock);
list_add_tail(>list, _list);
-- 
2.0.0.rc0.26.g779792a

--
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] bnx2fc: Fix locking requirements in bnx2fc_init_tgt

2016-04-05 Thread Chad Dupuis



On Tue, 5 Apr 2016, Bastien Philbert wrote:


This fixes the locking around the call to bnx2fc_alloc_id to comply
with the comments about this particular function's definition about
requiring the need to hold the hba mutex before and after calling
it.
Signed-off-by: Bastien Philbert 
---
drivers/scsi/bnx2fc/bnx2fc_tgt.c | 6 +-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_tgt.c b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
index 08ec318..f2988cd 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_tgt.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_tgt.c
@@ -368,9 +368,13 @@ static int bnx2fc_init_tgt(struct bnx2fc_rport *tgt,
return -1;
}

+   mutex_lock(>hba_mutex);
tgt->fcoe_conn_id = bnx2fc_alloc_conn_id(hba, tgt);
-   if (tgt->fcoe_conn_id == -1)
+   if (tgt->fcoe_conn_id == -1) {
+   mutex_unlock(>hba_mutex);
return -1;
+   }
+   mutex_unlock(>hba_mutex);

BNX2FC_TGT_DBG(tgt, "init_tgt - conn_id = 0x%x\n", tgt->fcoe_conn_id);




Taking the mutex here is not needed as it is already taken in 
bnx2fc_rport_event_handler() in the call chain 
bnx2fc_rport_event_handler->bnx2fc_offload_session->bnx2fc_init_tgt->bnx2fc_alloc_conn_id

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


Re: [PATCH 1/5] bnx2fc: Add driver tunables.

2016-04-04 Thread Chad Dupuis


On Fri, 1 Apr 2016, James Bottomley wrote:


On Fri, 2016-04-01 at 10:06 -0400, Chad Dupuis wrote:

On Fri, 1 Apr 2016, Johannes Thumshirn wrote:


On 2016-04-01 15:10, Chad Dupuis wrote:

From: Joe Carnuccio <joe.carnuc...@qlogic.com>

Per customer request, add the following driver tunables:

o devloss_tmo
o max_luns
o queue_depth
o tm_timeout

Signed-off-by: Joe Carnuccio <joe.carnuc...@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 38
+-
 drivers/scsi/bnx2fc/bnx2fc_io.c   |  4 +++-
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d7029ea..600c29d 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -107,6 +107,26 @@ MODULE_PARM_DESC(debug_logging,
"\t\t0x10 - fcoe L2 fame related logs.\n"
"\t\t0xff - LOG all messages.");

+uint bnx2fc_devloss_tmo;
+module_param_named(devloss_tmo, bnx2fc_devloss_tmo, uint,
S_IRUGO);
+MODULE_PARM_DESC(devloss_tmo, " Change devloss_tmo for the
remote ports "
+   "attached via bnx2fc.");
+
+uint bnx2fc_max_luns = BNX2FC_MAX_LUN;
+module_param_named(max_luns, bnx2fc_max_luns, uint, S_IRUGO);
+MODULE_PARM_DESC(max_luns, " Change the default max_lun per SCSI
host. Default "
+   "0x.");
+
+uint bnx2fc_queue_depth;
+module_param_named(queue_depth, bnx2fc_queue_depth, uint,
S_IRUGO);
+MODULE_PARM_DESC(queue_depth, " Change the default queue depth
of
SCSI devices "
+   "attached via bnx2fc.");
+
+uint bnx2fc_tm_timeout = BNX2FC_TM_TIMEOUT;
+module_param_named(tm_timeout, bnx2fc_tm_timeout, uint,
S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(tm_timeout, " Change the default timeout for "
+   "task management commands. Default 60 seconds.");
+


Just a question, can't this be made dynamically adjustable via
sysfs instead
of a module parameter?



I presume you're talking about something like a
/sys/class/scsi_host/hostX/tm_timeout sysfs node?


Yes, but there's also the question of whether they should be generic
rather than bnx2fc specific.  At least queue_depth, max_luns and
possibly tm_timeout would seem to belong to the SCSI host itself.
devloss_tmo looks like it should be a host parameter within the fc
transport class.

James



The use case for this is so that someone can administratively set these 
parameters on driver load so that all devices discovered via our driver 
will get these parameters set automatically usually via the 
slave_configure callback.  So functionally that's what is trying to 
be accomplished with this patch and what we would be looking for in a 
generic solution.  Would the scsi_host_template and/or fc_host_template 
be the appropriate place to set this then so the values could be 
initialized during scsi_host/fc_host discovery?

--
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/5] bnx2fc: Print netdev device name when FCoE is successfully initialized.

2016-04-01 Thread Chad Dupuis


On Fri, 1 Apr 2016, Johannes Thumshirn wrote:


On 2016-04-01 15:10, Chad Dupuis wrote:

Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d95eee6..60423cf 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2044,6 +2044,8 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
return;
}

+   pr_err(PFX "FCoE initialized for %s.\n", dev->netdev->name);
+
/* Add HBA to the adapter list */
mutex_lock(_dev_lock);
list_add_tail(>list, _list);


I don't think KERN_ERR is the appropriate log level for this, can you change 
it to pr_info()?




Yes, I'll change it to a pr_info in a V2 set.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/5] bnx2fc: Add driver tunables.

2016-04-01 Thread Chad Dupuis


On Fri, 1 Apr 2016, Johannes Thumshirn wrote:


On 2016-04-01 15:10, Chad Dupuis wrote:

From: Joe Carnuccio <joe.carnuc...@qlogic.com>

Per customer request, add the following driver tunables:

o devloss_tmo
o max_luns
o queue_depth
o tm_timeout

Signed-off-by: Joe Carnuccio <joe.carnuc...@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 38 
+-

 drivers/scsi/bnx2fc/bnx2fc_io.c   |  4 +++-
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d7029ea..600c29d 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -107,6 +107,26 @@ MODULE_PARM_DESC(debug_logging,
"\t\t0x10 - fcoe L2 fame related logs.\n"
"\t\t0xff - LOG all messages.");

+uint bnx2fc_devloss_tmo;
+module_param_named(devloss_tmo, bnx2fc_devloss_tmo, uint, S_IRUGO);
+MODULE_PARM_DESC(devloss_tmo, " Change devloss_tmo for the remote ports "
+   "attached via bnx2fc.");
+
+uint bnx2fc_max_luns = BNX2FC_MAX_LUN;
+module_param_named(max_luns, bnx2fc_max_luns, uint, S_IRUGO);
+MODULE_PARM_DESC(max_luns, " Change the default max_lun per SCSI
host. Default "
+   "0x.");
+
+uint bnx2fc_queue_depth;
+module_param_named(queue_depth, bnx2fc_queue_depth, uint, S_IRUGO);
+MODULE_PARM_DESC(queue_depth, " Change the default queue depth of
SCSI devices "
+   "attached via bnx2fc.");
+
+uint bnx2fc_tm_timeout = BNX2FC_TM_TIMEOUT;
+module_param_named(tm_timeout, bnx2fc_tm_timeout, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(tm_timeout, " Change the default timeout for "
+   "task management commands. Default 60 seconds.");
+


Just a question, can't this be made dynamically adjustable via sysfs instead 
of a module parameter?




I presume you're talking about something like a 
/sys/class/scsi_host/hostX/tm_timeout sysfs node?



--
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/5] bnx2fc: Add driver tunables.

2016-04-01 Thread Chad Dupuis
From: Joe Carnuccio <joe.carnuc...@qlogic.com>

Per customer request, add the following driver tunables:

o devloss_tmo
o max_luns
o queue_depth
o tm_timeout

Signed-off-by: Joe Carnuccio <joe.carnuc...@qlogic.com>
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 38 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c   |  4 +++-
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d7029ea..600c29d 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -107,6 +107,26 @@ MODULE_PARM_DESC(debug_logging,
"\t\t0x10 - fcoe L2 fame related logs.\n"
"\t\t0xff - LOG all messages.");
 
+uint bnx2fc_devloss_tmo;
+module_param_named(devloss_tmo, bnx2fc_devloss_tmo, uint, S_IRUGO);
+MODULE_PARM_DESC(devloss_tmo, " Change devloss_tmo for the remote ports "
+   "attached via bnx2fc.");
+
+uint bnx2fc_max_luns = BNX2FC_MAX_LUN;
+module_param_named(max_luns, bnx2fc_max_luns, uint, S_IRUGO);
+MODULE_PARM_DESC(max_luns, " Change the default max_lun per SCSI host. Default 
"
+   "0x.");
+
+uint bnx2fc_queue_depth;
+module_param_named(queue_depth, bnx2fc_queue_depth, uint, S_IRUGO);
+MODULE_PARM_DESC(queue_depth, " Change the default queue depth of SCSI devices 
"
+   "attached via bnx2fc.");
+
+uint bnx2fc_tm_timeout = BNX2FC_TM_TIMEOUT;
+module_param_named(tm_timeout, bnx2fc_tm_timeout, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(tm_timeout, " Change the default timeout for "
+   "task management commands. Default 60 seconds.");
+
 static int bnx2fc_cpu_callback(struct notifier_block *nfb,
 unsigned long action, void *hcpu);
 /* notification function for CPU hotplug events */
@@ -692,7 +712,7 @@ static int bnx2fc_shost_config(struct fc_lport *lport, 
struct device *dev)
int rc = 0;
 
shost->max_cmd_len = BNX2FC_MAX_CMD_LEN;
-   shost->max_lun = BNX2FC_MAX_LUN;
+   shost->max_lun = bnx2fc_max_luns;
shost->max_id = BNX2FC_MAX_FCP_TGT;
shost->max_channel = 0;
if (lport->vport)
@@ -1102,6 +1122,9 @@ static int bnx2fc_vport_create(struct fc_vport *vport, 
bool disabled)
return -EIO;
}
 
+   if (bnx2fc_devloss_tmo)
+   fc_host_dev_loss_tmo(vn_port->host) = bnx2fc_devloss_tmo;
+
if (disabled) {
fc_vport_set_state(vport, FC_VPORT_DISABLED);
} else {
@@ -1495,6 +1518,9 @@ static struct fc_lport *bnx2fc_if_create(struct 
bnx2fc_interface *interface,
}
fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN;
 
+   if (bnx2fc_devloss_tmo)
+   fc_host_dev_loss_tmo(shost) = bnx2fc_devloss_tmo;
+
/* Allocate exchange manager */
if (!npiv)
rc = bnx2fc_em_config(lport, hba);
@@ -2612,6 +2638,15 @@ static int bnx2fc_cpu_callback(struct notifier_block 
*nfb,
return NOTIFY_OK;
 }
 
+static int bnx2fc_slave_configure(struct scsi_device *sdev)
+{
+   if (!bnx2fc_queue_depth)
+   return 0;
+
+   scsi_change_queue_depth(sdev, bnx2fc_queue_depth);
+   return 0;
+}
+
 /**
  * bnx2fc_mod_init - module init entry point
  *
@@ -2877,6 +2912,7 @@ static struct scsi_host_template bnx2fc_shost_template = {
.sg_tablesize   = BNX2FC_MAX_BDS_PER_CMD,
.max_sectors= 1024,
.track_queue_depth  = 1,
+   .slave_configure = bnx2fc_slave_configure,
 };
 
 static struct libfc_function_template bnx2fc_libfc_fcn_templ = {
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 0002caf..0f60e22 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -15,6 +15,8 @@
 
 #define RESERVE_FREE_LIST_INDEX num_possible_cpus()
 
+extern uint bnx2fc_tm_timeout;
+
 static int bnx2fc_split_bd(struct bnx2fc_cmd *io_req, u64 addr, int sg_len,
   int bd_index);
 static int bnx2fc_map_sg(struct bnx2fc_cmd *io_req);
@@ -770,7 +772,7 @@ retry_tmf:
spin_unlock_bh(>tgt_lock);
 
rc = wait_for_completion_timeout(_req->tm_done,
-BNX2FC_TM_TIMEOUT * HZ);
+bnx2fc_tm_timeout * HZ);
spin_lock_bh(>tgt_lock);
 
io_req->wait_for_comp = 0;
-- 
2.0.0.rc0.26.g779792a

--
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/5] bnx2fc: Update version number to 2.10.3.

2016-04-01 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 499e369..9ce361a 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -65,7 +65,7 @@
 #include "bnx2fc_constants.h"
 
 #define BNX2FC_NAME"bnx2fc"
-#define BNX2FC_VERSION "2.9.6"
+#define BNX2FC_VERSION "2.10.3"
 
 #define PFX"bnx2fc: "
 
-- 
2.0.0.rc0.26.g779792a

--
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 4/5] bnx2fc: Check sc_cmd device and host pointer before returning the command to the mid-layer.

2016-04-01 Thread Chad Dupuis
When we are in connection recovery and the internal command timer on a request
pops, either the scsi_cmnd->device or scsi_cmnd->device->host back pointers may
be NULL as the device that the command that the request was submitted on may
have been subsequently reaped due to the connection recovery. This can cause
one or both of the pointers above to be NULL and cause a system crash if we try
to return the command to the midlayer.

Instead, double check the pointers before the return to the midlayer so as to
prevent the crash and let the upper layers finish the session recovery and
rediscover the device.

Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 0f60e22..33e519d 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -181,12 +181,24 @@ static void bnx2fc_scsi_done(struct bnx2fc_cmd *io_req, 
int err_code)
 
bnx2fc_unmap_sg_list(io_req);
io_req->sc_cmd = NULL;
+
+   /* Sanity checks before returning command to mid-layer */
if (!sc_cmd) {
printk(KERN_ERR PFX "scsi_done - sc_cmd NULL. "
"IO(0x%x) already cleaned up\n",
   io_req->xid);
return;
}
+   if (!sc_cmd->device) {
+   pr_err(PFX "0x%x: sc_cmd->device is NULL.\n", io_req->xid);
+   return;
+   }
+   if (!sc_cmd->device->host) {
+   pr_err(PFX "0x%x: sc_cmd->device->host is NULL.\n",
+   io_req->xid);
+   return;
+   }
+
sc_cmd->result = err_code << 16;
 
BNX2FC_IO_DBG(io_req, "sc=%p, result=0x%x, retries=%d, allowed=%d\n",
-- 
2.0.0.rc0.26.g779792a

--
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/5] bnx2fc: Print netdev device name when FCoE is successfully initialized.

2016-04-01 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index d95eee6..60423cf 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -2044,6 +2044,8 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev)
return;
}
 
+   pr_err(PFX "FCoE initialized for %s.\n", dev->netdev->name);
+
/* Add HBA to the adapter list */
mutex_lock(_dev_lock);
list_add_tail(>list, _list);
-- 
2.0.0.rc0.26.g779792a

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


[PATCH 2/5] bnx2fc: Print when we send a fip keep alive.

2016-04-01 Thread Chad Dupuis
Signed-off-by: Chad Dupuis <chad.dup...@qlogic.com>
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c 
b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index 600c29d..d95eee6 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -127,6 +127,11 @@ module_param_named(tm_timeout, bnx2fc_tm_timeout, uint, 
S_IRUGO|S_IWUSR);
 MODULE_PARM_DESC(tm_timeout, " Change the default timeout for "
"task management commands. Default 60 seconds.");
 
+uint bnx2fc_log_fka;
+module_param_named(log_fka, bnx2fc_log_fka, uint, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(log_fka, " Print message to kernel log when fcoe is "
+   "initiating a FIP keep alive when debug logging is enabled.");
+
 static int bnx2fc_cpu_callback(struct notifier_block *nfb,
 unsigned long action, void *hcpu);
 /* notification function for CPU hotplug events */
@@ -1081,6 +1086,20 @@ static u8 *bnx2fc_get_src_mac(struct fc_lport *lport)
  */
 static void bnx2fc_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
 {
+   struct fip_header *fiph;
+   struct ethhdr *eth_hdr;
+   u16 op;
+   u8 sub;
+
+   fiph = (struct fip_header *) ((void *)skb->data + 2 * ETH_ALEN + 2);
+   eth_hdr = (struct ethhdr *)skb_mac_header(skb);
+   op = ntohs(fiph->fip_op);
+   sub = fiph->fip_subcode;
+
+   if (op == FIP_OP_CTRL && sub == FIP_SC_SOL && bnx2fc_log_fka)
+   BNX2FC_MISC_DBG("Sending FKA from %pM to %pM.\n",
+   eth_hdr->h_source, eth_hdr->h_dest);
+
skb->dev = bnx2fc_from_ctlr(fip)->netdev;
dev_queue_xmit(skb);
 }
-- 
2.0.0.rc0.26.g779792a

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


[PATCH 0/5] bnx2fc: Update driver to 2.10.3.

2016-04-01 Thread Chad Dupuis
Hi James, Martin,

Please add the following patches to the scsi tree at your earliest
convenience.

Chad Dupuis (4):
  bnx2fc: Print when we send a fip keep alive.
  bnx2fc: Print netdev device name when FCoE is successfully
initialized.
  bnx2fc: Check sc_cmd device and host pointer before returning the
command to the mid-layer.
  bnx2fc: Update version number to 2.10.3.

Joe Carnuccio (1):
  bnx2fc: Add driver tunables.

 drivers/scsi/bnx2fc/bnx2fc.h  |  2 +-
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 59 ++-
 drivers/scsi/bnx2fc/bnx2fc_io.c   | 16 ++-
 3 files changed, 74 insertions(+), 3 deletions(-)

-- 
2.0.0.rc0.26.g779792a

--
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] bnx2fc: bnx2fc_eh_abort(): fix wrong return code.

2016-02-01 Thread Chad Dupuis


On Mon, 1 Feb 2016, Maurizio Lombardi wrote:


If the link is not ready, the bnx2fc_eh_abort() function
should return FAILED.

Signed-off-by: Maurizio Lombardi <mlomb...@redhat.com>
---
drivers/scsi/bnx2fc/bnx2fc_io.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 0002caf..2230dab 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1104,8 +1104,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
struct bnx2fc_cmd *io_req;
struct fc_lport *lport;
struct bnx2fc_rport *tgt;
-   int rc = FAILED;
-
+   int rc;

rc = fc_block_scsi_eh(sc_cmd);
if (rc)
@@ -1114,7 +1113,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd)
lport = shost_priv(sc_cmd->device->host);
if ((lport->state != LPORT_ST_READY) || !(lport->link_up)) {
printk(KERN_ERR PFX "eh_abort: link not ready\n");
-   return rc;
+   return FAILED;
}

tgt = (struct bnx2fc_rport *)[1];



Yes, nice catch.

Acked-by: Chad Dupuis <chad.dup...@qlogic.com>
--
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


  1   2   3   >