netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes.
@ 2020-04-16  8:43 Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 1/9] qedf: Keep track of num of pending flogi Saurav Kashyap
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

Hi Martin,

Kindly apply this series to scsi tree at your earliest convenience.

v3->v4
 - Description updated for patches 1,6,7 and 9.
 - Patch "Fix for the deviations from the SAM-4 spec." divided into 3
	- Increase the upper limit of retry delay.
	- Acquire rport_lock for resetting the delay_timestamp
	- Honor status qualifier in FCP_RSP per spec.

v2->v3
 - Removed version update patch.

v1->v2
 - Function qedf_schedule_recovery_handler marked static
 - Function qedf_recovery_handler marked static

Thanks,
~Saurav
 

Chad Dupuis (2):
  qedf: Add schedule recovery handler.
  qedf: Fix crash when MFW calls for protocol stats while function is
    still probing.

Javed Hasan (3):
  qedf: Increase the upper limit of retry delay.
  qedf: Acquire rport_lock for resetting the delay_timestamp
  qedf: Honor status qualifier in FCP_RSP per spec.

Saurav Kashyap (3):
  qedf: Keep track of num of pending flogi.
  qedf: Implement callback for bw_update.
  qedf: Get dev info after updating the params.

Sudarsana Reddy Kalluru (1):
  qed: Send BW update notifications to the protocol drivers.

 drivers/net/ethernet/qlogic/qed/qed.h      |   1 +
 drivers/net/ethernet/qlogic/qed/qed_main.c |   9 ++
 drivers/scsi/qedf/qedf.h                   |   6 +-
 drivers/scsi/qedf/qedf_io.c                |  47 +++++++---
 drivers/scsi/qedf/qedf_main.c              | 135 ++++++++++++++++++++++++++++-
 include/linux/qed/qed_if.h                 |   1 +
 6 files changed, 184 insertions(+), 15 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v4 1/9] qedf: Keep track of num of pending flogi.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 2/9] qedf: Increase the upper limit of retry delay Saurav Kashyap
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

If a port is brought down for an extended period of time, the
fipvlan counter gets exhausted and the driver will fall back to
default VLAN 1002 and call fcoe_ctlr_link_up to log in. However, the
switch will discard the FLOGI attempt because the VLAN is now
different.

Keep track of the number of FLOGI attempts and if a threshold of
QEDF_FLOGI_RETRY_CNT is exceeded, perform a context soft reset.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf.h      |  2 ++
 drivers/scsi/qedf/qedf_main.c | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index f3f399f..042ebf6 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -388,6 +388,7 @@ struct qedf_ctx {
 	mempool_t *io_mempool;
 	struct workqueue_struct *dpc_wq;
 	struct delayed_work grcdump_work;
+	struct delayed_work stag_work;
 
 	u32 slow_sge_ios;
 	u32 fast_sge_ios;
@@ -403,6 +404,7 @@ struct qedf_ctx {
 
 	u32 flogi_cnt;
 	u32 flogi_failed;
+	u32 flogi_pending;
 
 	/* Used for fc statistics */
 	struct mutex stats_mutex;
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 604856e..ee468102 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -282,6 +282,7 @@ static void qedf_flogi_resp(struct fc_seq *seq, struct fc_frame *fp,
 	else if (fc_frame_payload_op(fp) == ELS_LS_ACC) {
 		/* Set the source MAC we will use for FCoE traffic */
 		qedf_set_data_src_addr(qedf, fp);
+		qedf->flogi_pending = 0;
 	}
 
 	/* Complete flogi_compl so we can proceed to sending ADISCs */
@@ -307,6 +308,11 @@ static struct fc_seq *qedf_elsct_send(struct fc_lport *lport, u32 did,
 	 */
 	if (resp == fc_lport_flogi_resp) {
 		qedf->flogi_cnt++;
+		if (qedf->flogi_pending >= QEDF_FLOGI_RETRY_CNT) {
+			schedule_delayed_work(&qedf->stag_work, 2);
+			return NULL;
+		}
+		qedf->flogi_pending++;
 		return fc_elsct_send(lport, did, fp, op, qedf_flogi_resp,
 		    arg, timeout);
 	}
@@ -850,6 +856,7 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
 
 	qedf = lport_priv(lport);
 
+	qedf->flogi_pending = 0;
 	/* For host reset, essentially do a soft link up/down */
 	atomic_set(&qedf->link_state, QEDF_LINK_DOWN);
 	QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC,
@@ -3205,6 +3212,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 		init_completion(&qedf->fipvlan_compl);
 		mutex_init(&qedf->stats_mutex);
 		mutex_init(&qedf->flush_mutex);
+		qedf->flogi_pending = 0;
 
 		QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_INFO,
 		   "QLogic FastLinQ FCoE Module qedf %s, "
@@ -3235,6 +3243,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	INIT_DELAYED_WORK(&qedf->link_update, qedf_handle_link_update);
 	INIT_DELAYED_WORK(&qedf->link_recovery, qedf_link_recovery);
 	INIT_DELAYED_WORK(&qedf->grcdump_work, qedf_wq_grcdump);
+	INIT_DELAYED_WORK(&qedf->stag_work, qedf_stag_change_work);
 	qedf->fipvlan_retries = qedf_fipvlan_retries;
 	/* Set a default prio in case DCBX doesn't converge */
 	if (qedf_default_prio > -1) {
@@ -3770,6 +3779,20 @@ void qedf_get_protocol_tlv_data(void *dev, void *data)
 	fcoe->scsi_tsk_full = qedf->task_set_fulls;
 }
 
+/* Deferred work function to perform soft context reset on STAG change */
+void qedf_stag_change_work(struct work_struct *work)
+{
+	struct qedf_ctx *qedf =
+	    container_of(work, struct qedf_ctx, stag_work.work);
+
+	if (!qedf) {
+		QEDF_ERR(&qedf->dbg_ctx, "qedf is NULL");
+		return;
+	}
+	QEDF_ERR(&qedf->dbg_ctx, "Performing software context reset.\n");
+	qedf_ctx_soft_reset(qedf->lport);
+}
+
 static void qedf_shutdown(struct pci_dev *pdev)
 {
 	__qedf_remove(pdev, QEDF_MODE_NORMAL);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 2/9] qedf: Increase the upper limit of retry delay.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 1/9] qedf: Keep track of num of pending flogi Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 3/9] qedf: Acquire rport_lock for resetting the delay_timestamp Saurav Kashyap
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

From: Javed Hasan <jhasan@marvell.com>

Max time to hold the IO in case of SAM_STAT_TASK_SET_FULL
or SAM_STAT_BUSY.

Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index 042ebf6..aaa2ac9 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -470,7 +470,7 @@ static inline void qedf_stop_all_io(struct qedf_ctx *qedf)
 extern uint qedf_io_tracing;
 extern uint qedf_stop_io_on_error;
 extern uint qedf_link_down_tmo;
-#define QEDF_RETRY_DELAY_MAX		20 /* 2 seconds */
+#define QEDF_RETRY_DELAY_MAX		600 /* 60 seconds */
 extern bool qedf_retry_delay;
 extern uint qedf_debug;
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 3/9] qedf: Acquire rport_lock for resetting the delay_timestamp
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 1/9] qedf: Keep track of num of pending flogi Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 2/9] qedf: Increase the upper limit of retry delay Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 4/9] qedf: Honor status qualifier in FCP_RSP per spec Saurav Kashyap
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

From: Javed Hasan <jhasan@marvell.com>

retry delay timestamp is updated in queuecommand as well
qedf_scsi_completion routine, protect it using lock.

Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf_io.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index e749a2d..64c1769 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1021,14 +1021,18 @@ int qedf_post_io_req(struct qedf_rport *fcport, struct qedf_ioreq *io_req)
 	atomic_inc(&fcport->ios_to_queue);
 
 	if (fcport->retry_delay_timestamp) {
+		/* Take fcport->rport_lock for resetting the delay_timestamp */
+		spin_lock_irqsave(&fcport->rport_lock, flags);
 		if (time_after(jiffies, fcport->retry_delay_timestamp)) {
 			fcport->retry_delay_timestamp = 0;
 		} else {
+			spin_unlock_irqrestore(&fcport->rport_lock, flags);
 			/* If retry_delay timer is active, flow off the ML */
 			rc = SCSI_MLQUEUE_TARGET_BUSY;
 			atomic_dec(&fcport->ios_to_queue);
 			goto exit_qcmd;
 		}
+		spin_unlock_irqrestore(&fcport->rport_lock, flags);
 	}
 
 	io_req = qedf_alloc_cmd(fcport, QEDF_SCSI_CMD);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 4/9] qedf: Honor status qualifier in FCP_RSP per spec.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (2 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 3/9] qedf: Acquire rport_lock for resetting the delay_timestamp Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 5/9] qed: Send BW update notifications to the protocol drivers Saurav Kashyap
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

From: Javed Hasan <jhasan@marvell.com>

Handle scope and qualifier on SAM_STAT_TASK_SET_FULL
or SAM_STAT_BUSY

Signed-off-by: Javed Hasan <jhasan@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf_io.c | 43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c
index 64c1769..f0f455e 100644
--- a/drivers/scsi/qedf/qedf_io.c
+++ b/drivers/scsi/qedf/qedf_io.c
@@ -1138,6 +1138,8 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
 	int refcount;
 	u16 scope, qualifier = 0;
 	u8 fw_residual_flag = 0;
+	unsigned long flags = 0;
+	u16 chk_scope = 0;
 
 	if (!io_req)
 		return;
@@ -1271,16 +1273,8 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
 				/* Lower 14 bits */
 				qualifier = fcp_rsp->retry_delay_timer & 0x3FFF;
 
-				if (qedf_retry_delay &&
-				    scope > 0 && qualifier > 0 &&
-				    qualifier <= 0x3FEF) {
-					/* Check we don't go over the max */
-					if (qualifier > QEDF_RETRY_DELAY_MAX)
-						qualifier =
-						    QEDF_RETRY_DELAY_MAX;
-					fcport->retry_delay_timestamp =
-					    jiffies + (qualifier * HZ / 10);
-				}
+				if (qedf_retry_delay)
+					chk_scope = 1;
 				/* Record stats */
 				if (io_req->cdb_status ==
 				    SAM_STAT_TASK_SET_FULL)
@@ -1291,6 +1285,35 @@ void qedf_scsi_completion(struct qedf_ctx *qedf, struct fcoe_cqe *cqe,
 		}
 		if (io_req->fcp_resid)
 			scsi_set_resid(sc_cmd, io_req->fcp_resid);
+
+		if (chk_scope == 1)
+			if ((scope == 1 || scope == 2) &&
+			    (qualifier > 0 && qualifier <= 0x3FEF)) {
+				/* Check we don't go over the max */
+				if (qualifier > QEDF_RETRY_DELAY_MAX) {
+					qualifier = QEDF_RETRY_DELAY_MAX;
+					QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
+						  "qualifier = %d\n",
+						  (fcp_rsp->retry_delay_timer &
+						  0x3FFF));
+				}
+				QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
+					  "Scope = %d and qualifier = %d",
+					  scope, qualifier);
+				/*  Take fcport->rport_lock to
+				 *  update the retry_delay_timestamp
+				 */
+				spin_lock_irqsave(&fcport->rport_lock, flags);
+				fcport->retry_delay_timestamp =
+					jiffies + (qualifier * HZ / 10);
+				spin_unlock_irqrestore(&fcport->rport_lock,
+						       flags);
+
+			} else {
+				QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_IO,
+					  "combination of scope = %d and qualifier = %d is not handled in qedf.\n",
+					  scope, qualifier);
+			}
 		break;
 	default:
 		QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_IO, "fcp_status=%d.\n",
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 5/9] qed: Send BW update notifications to the protocol drivers.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (3 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 4/9] qedf: Honor status qualifier in FCP_RSP per spec Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 6/9] qedf: Implement callback for bw_update Saurav Kashyap
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

From: Sudarsana Reddy Kalluru <skalluru@marvell.com>

Management firmware (MFW) send a notification whenever there is a change in
the bandwidth values. The patch adds driver support to send this info to
the upper layer drivers (e.g., qedf).

Signed-off-by: Sudarsana Reddy Kalluru <skalluru@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/net/ethernet/qlogic/qed/qed.h      | 1 +
 drivers/net/ethernet/qlogic/qed/qed_main.c | 9 +++++++++
 include/linux/qed/qed_if.h                 | 1 +
 3 files changed, 11 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qed/qed.h b/drivers/net/ethernet/qlogic/qed/qed.h
index fa41bf0..d006639 100644
--- a/drivers/net/ethernet/qlogic/qed/qed.h
+++ b/drivers/net/ethernet/qlogic/qed/qed.h
@@ -1016,6 +1016,7 @@ void qed_set_fw_mac_addr(__le16 *fw_msb,
 int qed_fill_dev_info(struct qed_dev *cdev,
 		      struct qed_dev_info *dev_info);
 void qed_link_update(struct qed_hwfn *hwfn, struct qed_ptt *ptt);
+void qed_bw_update(struct qed_hwfn *hwfn, struct qed_ptt *ptt);
 u32 qed_unzip_data(struct qed_hwfn *p_hwfn,
 		   u32 input_len, u8 *input_buf,
 		   u32 max_size, u8 *unzip_buf);
diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
index 2c189c6..8d82d65 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_main.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
@@ -1949,6 +1949,15 @@ void qed_link_update(struct qed_hwfn *hwfn, struct qed_ptt *ptt)
 		op->link_update(cookie, &if_link);
 }
 
+void qed_bw_update(struct qed_hwfn *hwfn, struct qed_ptt *ptt)
+{
+	void *cookie = hwfn->cdev->ops_cookie;
+	struct qed_common_cb_ops *op = hwfn->cdev->protocol_ops.common;
+
+	if (IS_LEAD_HWFN(hwfn) && cookie && op && op->bw_update)
+		op->bw_update(cookie);
+}
+
 static int qed_drain(struct qed_dev *cdev)
 {
 	struct qed_hwfn *hwfn;
diff --git a/include/linux/qed/qed_if.h b/include/linux/qed/qed_if.h
index 8f29e0d..c495637 100644
--- a/include/linux/qed/qed_if.h
+++ b/include/linux/qed/qed_if.h
@@ -817,6 +817,7 @@ struct qed_common_cb_ops {
 	void	(*dcbx_aen)(void *dev, struct qed_dcbx_get *get, u32 mib_type);
 	void (*get_generic_tlv_data)(void *dev, struct qed_generic_tlvs *data);
 	void (*get_protocol_tlv_data)(void *dev, void *data);
+	void (*bw_update)(void *dev);
 };
 
 struct qed_selftest_ops {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 6/9] qedf: Implement callback for bw_update.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (4 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 5/9] qed: Send BW update notifications to the protocol drivers Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 7/9] qedf: Add schedule recovery handler Saurav Kashyap
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

Add support for the common qed bw_update callback to qedf.  This
function is called whenever there is a reported change in the
bandwidth and update corresponding values in sysfs.

Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf_main.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index ee468102..ba66216 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -509,6 +509,32 @@ static void qedf_update_link_speed(struct qedf_ctx *qedf,
 	fc_host_supported_speeds(lport->host) = lport->link_supported_speeds;
 }
 
+static void qedf_bw_update(void *dev)
+{
+	struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
+	struct qed_link_output link;
+
+	/* Get the latest status of the link */
+	qed_ops->common->get_link(qedf->cdev, &link);
+
+	if (test_bit(QEDF_UNLOADING, &qedf->flags)) {
+		QEDF_ERR(&qedf->dbg_ctx,
+			 "Ignore link update, driver getting unload.\n");
+		return;
+	}
+
+	if (link.link_up) {
+		if (atomic_read(&qedf->link_state) == QEDF_LINK_UP)
+			qedf_update_link_speed(qedf, &link);
+		else
+			QEDF_ERR(&qedf->dbg_ctx,
+				 "Ignore bw update, link is down.\n");
+
+	} else {
+		QEDF_ERR(&qedf->dbg_ctx, "link_up is not set.\n");
+	}
+}
+
 static void qedf_link_update(void *dev, struct qed_link_output *link)
 {
 	struct qedf_ctx *qedf = (struct qedf_ctx *)dev;
@@ -635,6 +661,7 @@ static u32 qedf_get_login_failures(void *cookie)
 static struct qed_fcoe_cb_ops qedf_cb_ops = {
 	{
 		.link_update = qedf_link_update,
+		.bw_update = qedf_bw_update,
 		.dcbx_aen = qedf_dcbx_handler,
 		.get_generic_tlv_data = qedf_get_generic_tlv_data,
 		.get_protocol_tlv_data = qedf_get_protocol_tlv_data,
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 7/9] qedf: Add schedule recovery handler.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (5 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 6/9] qedf: Implement callback for bw_update Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 8/9] qedf: Fix crash when MFW calls for protocol stats while function is still probing Saurav Kashyap
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

From: Chad Dupuis <cdupuis@marvell.com>

Recovery handler is used by QED to notify the need
for recovery to come out of an error condition like
ramrod struck and firmware context reset.

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf.h      |  1 +
 drivers/scsi/qedf/qedf_main.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index aaa2ac9..f8a98e5 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -387,6 +387,7 @@ struct qedf_ctx {
 #define QEDF_IO_WORK_MIN		64
 	mempool_t *io_mempool;
 	struct workqueue_struct *dpc_wq;
+	struct delayed_work recovery_work;
 	struct delayed_work grcdump_work;
 	struct delayed_work stag_work;
 
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index ba66216..39a66e4 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -28,6 +28,8 @@
 static int qedf_probe(struct pci_dev *pdev, const struct pci_device_id *id);
 static void qedf_remove(struct pci_dev *pdev);
 static void qedf_shutdown(struct pci_dev *pdev);
+static void qedf_schedule_recovery_handler(void *dev);
+static void qedf_recovery_handler(struct work_struct *work);
 
 /*
  * Driver module parameters.
@@ -662,6 +664,7 @@ static u32 qedf_get_login_failures(void *cookie)
 	{
 		.link_update = qedf_link_update,
 		.bw_update = qedf_bw_update,
+		.schedule_recovery_handler = qedf_schedule_recovery_handler,
 		.dcbx_aen = qedf_dcbx_handler,
 		.get_generic_tlv_data = qedf_get_generic_tlv_data,
 		.get_protocol_tlv_data = qedf_get_protocol_tlv_data,
@@ -3510,6 +3513,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 		    qedf->lport->host->host_no);
 		qedf->dpc_wq = create_workqueue(host_buf);
 	}
+	INIT_DELAYED_WORK(&qedf->recovery_work, qedf_recovery_handler);
 
 	/*
 	 * GRC dump and sysfs parameters are not reaped during the recovery
@@ -3825,6 +3829,45 @@ static void qedf_shutdown(struct pci_dev *pdev)
 	__qedf_remove(pdev, QEDF_MODE_NORMAL);
 }
 
+/*
+ * Recovery handler code
+ */
+static void qedf_schedule_recovery_handler(void *dev)
+{
+	struct qedf_ctx *qedf = dev;
+
+	QEDF_ERR(&qedf->dbg_ctx, "Recovery handler scheduled.\n");
+	schedule_delayed_work(&qedf->recovery_work, 0);
+}
+
+static void qedf_recovery_handler(struct work_struct *work)
+{
+	struct qedf_ctx *qedf =
+	    container_of(work, struct qedf_ctx, recovery_work.work);
+
+	if (test_and_set_bit(QEDF_IN_RECOVERY, &qedf->flags))
+		return;
+
+	/*
+	 * Call common_ops->recovery_prolog to allow the MFW to quiesce
+	 * any PCI transactions.
+	 */
+	qed_ops->common->recovery_prolog(qedf->cdev);
+
+	QEDF_ERR(&qedf->dbg_ctx, "Recovery work start.\n");
+	__qedf_remove(qedf->pdev, QEDF_MODE_RECOVERY);
+	/*
+	 * Reset link and dcbx to down state since we will not get a link down
+	 * event from the MFW but calling __qedf_remove will essentially be a
+	 * link down event.
+	 */
+	atomic_set(&qedf->link_state, QEDF_LINK_DOWN);
+	atomic_set(&qedf->dcbx, QEDF_DCBX_PENDING);
+	__qedf_probe(qedf->pdev, QEDF_MODE_RECOVERY);
+	clear_bit(QEDF_IN_RECOVERY, &qedf->flags);
+	QEDF_ERR(&qedf->dbg_ctx, "Recovery work complete.\n");
+}
+
 /* Generic TLV data callback */
 void qedf_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data)
 {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 8/9] qedf: Fix crash when MFW calls for protocol stats while function is still probing.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (6 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 7/9] qedf: Add schedule recovery handler Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  8:43 ` [PATCH v4 9/9] qedf: Get dev info after updating the params Saurav Kashyap
  2020-04-17 21:57 ` [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Martin K. Petersen
  9 siblings, 0 replies; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

From: Chad Dupuis <cdupuis@marvell.com>

The MFW may make an call to qed and then to qedf for protocol statistics
while the function is still probing.  If this happens it's possible that
some members of the struct qedf_ctx may not be fully initialized which can
result in a NULL pointer dereference or general protection fault.

To prevent this, add a new flag call QEDF_PROBING and set it when the
__qedf_probe() function is active. Then in the qedf_get_protocol_tlv_data()
function we can check if the function is still probing and return
immediantely before any uninitialized structures can be touched.

Signed-off-by: Chad Dupuis <cdupuis@marvell.com>
Signed-off-by: Saurav Kashyap <skashyap@marvell.com>
---
 drivers/scsi/qedf/qedf.h      |  1 +
 drivers/scsi/qedf/qedf_main.c | 35 +++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h
index f8a98e5..e163be8 100644
--- a/drivers/scsi/qedf/qedf.h
+++ b/drivers/scsi/qedf/qedf.h
@@ -355,6 +355,7 @@ struct qedf_ctx {
 #define QEDF_GRCDUMP_CAPTURE		4
 #define QEDF_IN_RECOVERY		5
 #define QEDF_DBG_STOP_IO		6
+#define QEDF_PROBING			8
 	unsigned long flags; /* Miscellaneous state flags */
 	int fipvlan_retries;
 	u8 num_queues;
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 39a66e4..52673b4 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3198,7 +3198,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 {
 	int rc = -EINVAL;
 	struct fc_lport *lport;
-	struct qedf_ctx *qedf;
+	struct qedf_ctx *qedf = NULL;
 	struct Scsi_Host *host;
 	bool is_vf = false;
 	struct qed_ll2_params params;
@@ -3228,6 +3228,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 
 		/* Initialize qedf_ctx */
 		qedf = lport_priv(lport);
+		set_bit(QEDF_PROBING, &qedf->flags);
 		qedf->lport = lport;
 		qedf->ctlr.lp = lport;
 		qedf->pdev = pdev;
@@ -3252,9 +3253,12 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	} else {
 		/* Init pointers during recovery */
 		qedf = pci_get_drvdata(pdev);
+		set_bit(QEDF_PROBING, &qedf->flags);
 		lport = qedf->lport;
 	}
 
+	QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC, "Probe started.\n");
+
 	host = lport->host;
 
 	/* Allocate mempool for qedf_io_work structs */
@@ -3561,6 +3565,10 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	else
 		fc_fabric_login(lport);
 
+	QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC, "Probe done.\n");
+
+	clear_bit(QEDF_PROBING, &qedf->flags);
+
 	/* All good */
 	return 0;
 
@@ -3586,6 +3594,11 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 err1:
 	scsi_host_put(lport->host);
 err0:
+	if (qedf) {
+		QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_DISC, "Probe done.\n");
+
+		clear_bit(QEDF_PROBING, &qedf->flags);
+	}
 	return rc;
 }
 
@@ -3735,11 +3748,25 @@ void qedf_get_protocol_tlv_data(void *dev, void *data)
 {
 	struct qedf_ctx *qedf = dev;
 	struct qed_mfw_tlv_fcoe *fcoe = data;
-	struct fc_lport *lport = qedf->lport;
-	struct Scsi_Host *host = lport->host;
-	struct fc_host_attrs *fc_host = shost_to_fc_host(host);
+	struct fc_lport *lport;
+	struct Scsi_Host *host;
+	struct fc_host_attrs *fc_host;
 	struct fc_host_statistics *hst;
 
+	if (!qedf) {
+		QEDF_ERR(NULL, "qedf is null.\n");
+		return;
+	}
+
+	if (test_bit(QEDF_PROBING, &qedf->flags)) {
+		QEDF_ERR(&qedf->dbg_ctx, "Function is still probing.\n");
+		return;
+	}
+
+	lport = qedf->lport;
+	host = lport->host;
+	fc_host = shost_to_fc_host(host);
+
 	/* Force a refresh of the fc_host stats including offload stats */
 	hst = qedf_fc_get_host_stats(host);
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v4 9/9] qedf: Get dev info after updating the params.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (7 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 8/9] qedf: Fix crash when MFW calls for protocol stats while function is still probing Saurav Kashyap
@ 2020-04-16  8:43 ` Saurav Kashyap
  2020-04-16  9:41   ` Sergei Shtylyov
  2020-04-17 21:57 ` [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Martin K. Petersen
  9 siblings, 1 reply; 12+ messages in thread
From: Saurav Kashyap @ 2020-04-16  8:43 UTC (permalink / raw)
  To: martin.petersen; +Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

An update to pf params can change the devinfo, get
an updated device information.

Signed-off-by: Saurav Kashyap <skashyap@marvell.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 52673b4..dc5ac55 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3332,6 +3332,13 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
 	}
 	qed_ops->common->update_pf_params(qedf->cdev, &qedf->pf_params);
 
+	/* Learn information crucial for qedf to progress */
+	rc = qed_ops->fill_dev_info(qedf->cdev, &qedf->dev_info);
+	if (rc) {
+		QEDF_ERR(&qedf->dbg_ctx, "Failed to dev info.\n");
+		goto err2;
+	}
+
 	/* 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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 9/9] qedf: Get dev info after updating the params.
  2020-04-16  8:43 ` [PATCH v4 9/9] qedf: Get dev info after updating the params Saurav Kashyap
@ 2020-04-16  9:41   ` Sergei Shtylyov
  0 siblings, 0 replies; 12+ messages in thread
From: Sergei Shtylyov @ 2020-04-16  9:41 UTC (permalink / raw)
  To: Saurav Kashyap, martin.petersen
  Cc: GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev

Hello!

On 16.04.2020 11:43, Saurav Kashyap wrote:

> An update to pf params can change the devinfo, get
> an updated device information.
> 
> Signed-off-by: Saurav Kashyap <skashyap@marvell.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 52673b4..dc5ac55 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -3332,6 +3332,13 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
>   	}
>   	qed_ops->common->update_pf_params(qedf->cdev, &qedf->pf_params);
>   
> +	/* Learn information crucial for qedf to progress */
> +	rc = qed_ops->fill_dev_info(qedf->cdev, &qedf->dev_info);
> +	if (rc) {
> +		QEDF_ERR(&qedf->dbg_ctx, "Failed to dev info.\n");

    "to fill dev info", perhaps?

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes.
  2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
                   ` (8 preceding siblings ...)
  2020-04-16  8:43 ` [PATCH v4 9/9] qedf: Get dev info after updating the params Saurav Kashyap
@ 2020-04-17 21:57 ` Martin K. Petersen
  9 siblings, 0 replies; 12+ messages in thread
From: Martin K. Petersen @ 2020-04-17 21:57 UTC (permalink / raw)
  To: Saurav Kashyap
  Cc: martin.petersen, GR-QLogic-Storage-Upstream, linux-scsi, jhasan, netdev


Saurav,

> Kindly apply this series to scsi tree at your earliest convenience.

Fixed a few things, including a sparse warning and the error message
pointed out by Sergei. Applied to 5.8/scsi-queue, thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-04-17 21:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16  8:43 [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 1/9] qedf: Keep track of num of pending flogi Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 2/9] qedf: Increase the upper limit of retry delay Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 3/9] qedf: Acquire rport_lock for resetting the delay_timestamp Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 4/9] qedf: Honor status qualifier in FCP_RSP per spec Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 5/9] qed: Send BW update notifications to the protocol drivers Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 6/9] qedf: Implement callback for bw_update Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 7/9] qedf: Add schedule recovery handler Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 8/9] qedf: Fix crash when MFW calls for protocol stats while function is still probing Saurav Kashyap
2020-04-16  8:43 ` [PATCH v4 9/9] qedf: Get dev info after updating the params Saurav Kashyap
2020-04-16  9:41   ` Sergei Shtylyov
2020-04-17 21:57 ` [PATCH v4 0/9] qed/qedf: Firmware recovery, bw update and misc fixes Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).