From patchwork Thu Apr 16 08:43:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492543 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 331BB112C for ; Thu, 16 Apr 2020 09:04:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A9A820787 for ; Thu, 16 Apr 2020 09:04:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="Yub+8XYN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503422AbgDPJEq (ORCPT ); Thu, 16 Apr 2020 05:04:46 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:16108 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502721AbgDPIoq (ORCPT ); Thu, 16 Apr 2020 04:44:46 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8eWY9013932; Thu, 16 Apr 2020 01:43:19 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=htcZ1UOImIzyq3lsTp1CZDOryypRUSuVGFxKLD0B5sI=; b=Yub+8XYNyROiRWUTW10/ptXyy9VrEFPzlZC7odjuZanVl4fqqvAC6fUiU4ovksgXfU6J Nz+L+H9wyqet3JBNbkL+cY9hhBnyxG1Nahosb5yAuf9Qv8sulFhbilUTlzXwTMQOCOtx vKZKwMW54dda6KS6d/+4rP7e4QlhUA5cUYTTPXm0MIBJCHV0an/tHbvPxtXQst1dnyPy pLYzlodSgwcdo7+kC89p1qWrhNYgEpImEYgTtoX17a/9u91K0OrdRWZ3JgvLb4VwSZpd flCz3/VHYs54fr06pD4sBxFBgGk6o+wkAcksaXqcAICr227hjB+5vWEHYDmGfnJvREeW yg== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 30dn8gp588-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:19 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:17 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:17 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 8EABE3F7040; Thu, 16 Apr 2020 01:43:17 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hHcd018890; Thu, 16 Apr 2020 01:43:17 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hHS5018889; Thu, 16 Apr 2020 01:43:17 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 1/9] qedf: Keep track of num of pending flogi. Date: Thu, 16 Apr 2020 01:43:06 -0700 Message-ID: <20200416084314.18851-2-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 --- 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); From patchwork Thu Apr 16 08:43:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492541 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89B6681 for ; Thu, 16 Apr 2020 09:04:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71B61206B9 for ; Thu, 16 Apr 2020 09:04:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="yCZln6z7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503435AbgDPJEl (ORCPT ); Thu, 16 Apr 2020 05:04:41 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:43638 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502682AbgDPIos (ORCPT ); Thu, 16 Apr 2020 04:44:48 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8dtGr020179; Thu, 16 Apr 2020 01:43:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=WzxkJ4o8LoGFpShMUF55K4KiIgtnqKK8d70wY8a0oyM=; b=yCZln6z714S5ydkCqnxoEG9D9OsIgdw0izIwbCLecq7vxLKHya5U6y8mX0RKShPEA3tP 3Z0tfe5wau1M9L5xzmMAmPJvjfOsiHaH4X0RaCIhRmpwtvEeJicRM82oC4G9muZulEhV MOFdMXymTrhCNpmMNiMlUGXXRYCx5RzMnOSpuyCiY6i8J8oT6THsdvaAOUm6PpHdpQom HkcxLCCe3NElnohp4VJDMstzaXWlrijIdw6WsWZJpKST7M4yXJay9qSDugGoRRjmuxk3 xlUAGVGdl+/qccm9yqZRecjxol8qY3zPlxHxYvT971vj1fQ9+f8wiYN7qZG9vdzRYNw5 LQ== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7q7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:25 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:20 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:20 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id BEBA83F7041; Thu, 16 Apr 2020 01:43:20 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hK7J018894; Thu, 16 Apr 2020 01:43:20 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hKCj018893; Thu, 16 Apr 2020 01:43:20 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 2/9] qedf: Increase the upper limit of retry delay. Date: Thu, 16 Apr 2020 01:43:07 -0700 Message-ID: <20200416084314.18851-3-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Javed Hasan Max time to hold the IO in case of SAM_STAT_TASK_SET_FULL or SAM_STAT_BUSY. Signed-off-by: Javed Hasan Signed-off-by: Saurav Kashyap --- 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; From patchwork Thu Apr 16 08:43:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 69EDB14B4 for ; Thu, 16 Apr 2020 09:10:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51B7920787 for ; Thu, 16 Apr 2020 09:10:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="vReO1hvQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503135AbgDPJKC (ORCPT ); Thu, 16 Apr 2020 05:10:02 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:8378 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502732AbgDPIoq (ORCPT ); Thu, 16 Apr 2020 04:44:46 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8e3Eu020307; Thu, 16 Apr 2020 01:43:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=QLdcEkyQglP3Ab6yjllvArNRYXHdiYvwHvoMy2go6vA=; b=vReO1hvQuOWAjZX4id7P3Xq4g6TmBEVdBpGd4LrvOdS6zknHkRPNdMP4tG1wpAChg1n7 kOIGU2VM8VolZgwRVfDF0SLKuctmTncpSt9Mbkc3eO0USN6h0ZNQjbssvSo4TcwMbNtK d7syYm8TsLo/qvOeY6MvecmNmH5qJuMiolg51cJa+N6LrNpYiZoXQ/1++WLC6tW2d56o CBjKsB9fWCU5wpvnnTfXsKnHtlYeOuqF3N22UwpAgugJwH+Xr7us13PjfwJhBI9yeYHZ vH7RZSd7BNWpgRb83AJS6FirmkZ9zqFkDQeA2a9McX1PsWEWkLg24hhg3ILeDdXnFtKP jw== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7qe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:26 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:24 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:24 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id EEF153F703F; Thu, 16 Apr 2020 01:43:23 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hNrj018898; Thu, 16 Apr 2020 01:43:23 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hNB5018897; Thu, 16 Apr 2020 01:43:23 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 3/9] qedf: Acquire rport_lock for resetting the delay_timestamp Date: Thu, 16 Apr 2020 01:43:08 -0700 Message-ID: <20200416084314.18851-4-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Javed Hasan retry delay timestamp is updated in queuecommand as well qedf_scsi_completion routine, protect it using lock. Signed-off-by: Javed Hasan Signed-off-by: Saurav Kashyap --- 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); From patchwork Thu Apr 16 08:43:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492555 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EA3881 for ; Thu, 16 Apr 2020 09:10:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1661E20771 for ; Thu, 16 Apr 2020 09:10:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="bD+UBbhL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503482AbgDPJKF (ORCPT ); Thu, 16 Apr 2020 05:10:05 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:30178 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502519AbgDPIoq (ORCPT ); Thu, 16 Apr 2020 04:44:46 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8e7mW020358; Thu, 16 Apr 2020 01:43:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=MEgF6h97D59/JP6Sru30e3+Sb6rlVFxWUEs1gmDxoH0=; b=bD+UBbhLSLHCy332P8iM2B71NxlCl7iNxg3qWWWoR/l43SfdXsUNfRdXeYPHcAsuEaOl jNXpqyrJa4rh5TdeqkfaYVY7v9EcUgj7ysk+wiQKLXmzwjDiAymlkv1IVG5MKsMiyLLi UuAZGJyPnEbIvfXUE7giNOlDbwxnT3Jw30/GWst9treHpZKueBrZgAIOcMauo2Zxmjeu U5abos/mY13B1/N7hkyap6mGhkHYQb6Svs6wFKaGDoTiWb955nuw6byTNSajf0GZWKxs 4Q12LbHyWvVLyA0WDstJjYVArG5L9ZZSgap5UyGY7ItF1c+HG2QQXFsdKPEjzsJaEaE+ ew== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7qs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:30 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:28 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:27 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:27 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 283533F703F; Thu, 16 Apr 2020 01:43:27 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hRBm018902; Thu, 16 Apr 2020 01:43:27 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hQJr018901; Thu, 16 Apr 2020 01:43:26 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 4/9] qedf: Honor status qualifier in FCP_RSP per spec. Date: Thu, 16 Apr 2020 01:43:09 -0700 Message-ID: <20200416084314.18851-5-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Javed Hasan Handle scope and qualifier on SAM_STAT_TASK_SET_FULL or SAM_STAT_BUSY Signed-off-by: Javed Hasan Signed-off-by: Saurav Kashyap --- 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", From patchwork Thu Apr 16 08:43:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492553 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8C655112C for ; Thu, 16 Apr 2020 09:09:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7460D20771 for ; Thu, 16 Apr 2020 09:09:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="hs9w0Amv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503419AbgDPJER (ORCPT ); Thu, 16 Apr 2020 05:04:17 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:50872 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502536AbgDPIos (ORCPT ); Thu, 16 Apr 2020 04:44:48 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8e7dH020366; Thu, 16 Apr 2020 01:43:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=PDQAKmv2brTdTZRLKJMNmsauJBAFXBZ3lx7TNn1516k=; b=hs9w0Amvoidcli1dkH7zRtpYoYL2NAFXLUDIT6R5MHVZwllj6QPoEcH2vOXSKeoG6DEE f6B19yHB2+EAYrmqR/8lrcOC0x1dzRGEp33t2l3xenlX2QOQpiTLxTIPrOmbLw7jd8Yx QuZ4nrYXZdv0sg1HXsQC3QTGAn5hcqD2zzv0fqNiKxlBC9bxrD1cl3HyFN+lLh8KDJZk RTsik9f5VG3rEXrbMyclS34kW4AWQ55X4HzB44e/PQAmvEOrWQh9axDSja6PSM4x7zgk 8ySSzU0wJ3Quh6Ey9kYtAlg5UFi3TkUWMb4dxbfsNPSMw+ufNN0e+wnUij48iScmS+qK 8A== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7qw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:33 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:31 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:30 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:30 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 548703F703F; Thu, 16 Apr 2020 01:43:30 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hUu2018906; Thu, 16 Apr 2020 01:43:30 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hUS8018905; Thu, 16 Apr 2020 01:43:30 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 5/9] qed: Send BW update notifications to the protocol drivers. Date: Thu, 16 Apr 2020 01:43:10 -0700 Message-ID: <20200416084314.18851-6-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Sudarsana Reddy Kalluru 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 Signed-off-by: Saurav Kashyap --- 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 { From patchwork Thu Apr 16 08:43:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 754CD81 for ; Thu, 16 Apr 2020 09:04:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DD9520787 for ; Thu, 16 Apr 2020 09:04:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="h8VF1F/1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502915AbgDPJEY (ORCPT ); Thu, 16 Apr 2020 05:04:24 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:51202 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502734AbgDPIos (ORCPT ); Thu, 16 Apr 2020 04:44:48 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8dtsA020184; Thu, 16 Apr 2020 01:43:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=BngFCdsi668MTGoNPxKvkeBU12eJulG2ylUtX0dNcf4=; b=h8VF1F/1ccJj1C+5nNDit9eU3UXoYJnA/KRFQ5iVAY00+rXu6J5V/AQ+4QREJ0rBOP5t xTwjMWOoX2+DS4xMePpEuu7Fwnwh9Uy5f2wLOjwAAlatd6oMHvi6l0Rs2pf8+tcbwv8M Y47gkhFOXLyQjh6QHbSZPVmld8OX/+LyGf4WZJgGhFG+WcVC4s3M9bPkFu/sQckp3QqB oiKryfA5JogjOFmkYNbYpZjb6J2v60hRPiDWVN6nKDQ/l1pU2QSVb9MoWejg2wImsRgn BYXon/BWHwDhXOHl3DH/oT6SSxwwz/kZiS/E7w8cchsfwFym8wUeMzPhr4zVhyoKNvE8 aA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7r4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:35 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:33 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:33 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 7D0093F703F; Thu, 16 Apr 2020 01:43:33 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hXQg018910; Thu, 16 Apr 2020 01:43:33 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hX4O018909; Thu, 16 Apr 2020 01:43:33 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 6/9] qedf: Implement callback for bw_update. Date: Thu, 16 Apr 2020 01:43:11 -0700 Message-ID: <20200416084314.18851-7-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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 --- 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, From patchwork Thu Apr 16 08:43:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492545 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 40D6A112C for ; Thu, 16 Apr 2020 09:05:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27D5520771 for ; Thu, 16 Apr 2020 09:05:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="xJWKP2WM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503254AbgDPJEf (ORCPT ); Thu, 16 Apr 2020 05:04:35 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:64066 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502760AbgDPIos (ORCPT ); Thu, 16 Apr 2020 04:44:48 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8e9ST020373; Thu, 16 Apr 2020 01:43:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=1dLxUL708N1kPYtIsSgsWTjySaOlnVQkgeO2T9lwRX0=; b=xJWKP2WMg+RonOv6rtsLU9RsSSmLruZEeo6TvSqkrbq4DoZLBCuWdtmoudgXDdSBWMas dxPw34OFpA/Jp/iR2x5Ns0oolNzTOw92IBEYqdoHxtyQviIBDeeWqv1FZlLGg3/lFQZA kjEj8618B17XHRJfx1/Js0emh2yo6HnE+1IjwN4qyvNm/WYy9yN66OqNc7Dzg/ym1g+h AdR+jCUA1Etwqr8L6iGSvsWKy5Oixwa/ry1syvif17lKMVITeAHfyXbvcYMDcUUcnnoU 0HDYwIyE37aJsRSP34O3TjRvl3Q87QL3lZ4/YEBHmQNGy7YqB6nEFHjqVH41AgvSddeC 2g== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:38 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:36 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:36 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id AA4473F7040; Thu, 16 Apr 2020 01:43:36 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hawn018914; Thu, 16 Apr 2020 01:43:36 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8haha018913; Thu, 16 Apr 2020 01:43:36 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 7/9] qedf: Add schedule recovery handler. Date: Thu, 16 Apr 2020 01:43:12 -0700 Message-ID: <20200416084314.18851-8-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Chad Dupuis 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 Signed-off-by: Saurav Kashyap --- 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) { From patchwork Thu Apr 16 08:43:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492535 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B815112C for ; Thu, 16 Apr 2020 09:04:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1308D206B9 for ; Thu, 16 Apr 2020 09:04:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="LKbRRoVb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503398AbgDPJEJ (ORCPT ); Thu, 16 Apr 2020 05:04:09 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:6696 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502766AbgDPIou (ORCPT ); Thu, 16 Apr 2020 04:44:50 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8eWww013923; Thu, 16 Apr 2020 01:43:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=pTZ5Hl51Ej6SUhKKJ3OLZ3SyT4RBg306Yfvbv6Nps+A=; b=LKbRRoVbS4tOBWyBfUgXTv/EzvhKGndf8BsPAg0Ya3ly4T6jpbCRoIXyLbuo397vRQ6d itxzfdi8jp2CEzwB5G0XGsKLDKkrkIMMk/c4iGJxuVTpOgt2fEi36OeIflwuF/h+dn/h tLfSy62V3kL9etkq/HZfy6KZlz7FF5DUnILTVIEQlC4KTtUa2fuiZcjCZTx0a5VAECYs w+jgh/2Wiu/ZUWHMKfRQ/vhDd4gur5aSdRbxfkTOQJl1z147CVHEznMAe7KZyEAla1Wc 4741URtpy0+AQqTu63kdWGm2awH0cBZJS79XB1m1WsxXqPWewbO7P+s6iI9HB18dwIoC lw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 30dn8gp599-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:42 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:41 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:40 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:40 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id DECDD3F703F; Thu, 16 Apr 2020 01:43:39 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hdHr018918; Thu, 16 Apr 2020 01:43:39 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hdRW018917; Thu, 16 Apr 2020 01:43:39 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 8/9] qedf: Fix crash when MFW calls for protocol stats while function is still probing. Date: Thu, 16 Apr 2020 01:43:13 -0700 Message-ID: <20200416084314.18851-9-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Chad Dupuis 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 Signed-off-by: Saurav Kashyap --- 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); From patchwork Thu Apr 16 08:43:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11492537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA95F81 for ; Thu, 16 Apr 2020 09:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92796206B9 for ; Thu, 16 Apr 2020 09:04:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=marvell.com header.i=@marvell.com header.b="QfVhdw0N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503409AbgDPJEN (ORCPT ); Thu, 16 Apr 2020 05:04:13 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:27850 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502769AbgDPIou (ORCPT ); Thu, 16 Apr 2020 04:44:50 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03G8dtsD020184; Thu, 16 Apr 2020 01:43:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=RsMZzWEe15RgqHqAwHvHuBYjDy6BZByaXxfi4czSNNA=; b=QfVhdw0NKvaFEvI79mgo0glFERlx1j/ZH+OOGfQX9PcxDHFUDzZCjREwjJRkBPBFt8sW w/uSaLEo2NqnPxd6hlWFLpDoytii2BIvvm8dhE++BlgVwSxg3np9rBxPPs6NcLGGcGnN Y2ndiVODmqnDqM3a9gjofCZcSxa1Xq2igsEGlk2YzREtUh/NWuVHcSvv/jyJJXX4czmi csX7ZPH49G67QHD+hRAgG7Gt+tLBC+rfI8xwEx0EnUNICDMe2i1kdxnDT8F4gn18/Z9V 4YGBdU0CG+XyVolU8FlVOx7jQntQjfnKCVktI/68+XmzAflTbZ6K9Xu+gthZYFEvHsgQ aA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 30dn84p7rh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 01:43:45 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 16 Apr 2020 01:43:43 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 16 Apr 2020 01:43:43 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 10F9E3F7040; Thu, 16 Apr 2020 01:43:43 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id 03G8hg2f018922; Thu, 16 Apr 2020 01:43:42 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 03G8hglg018921; Thu, 16 Apr 2020 01:43:42 -0700 From: Saurav Kashyap To: CC: , , , Subject: [PATCH v4 9/9] qedf: Get dev info after updating the params. Date: Thu, 16 Apr 2020 01:43:14 -0700 Message-ID: <20200416084314.18851-10-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200416084314.18851-1-skashyap@marvell.com> References: <20200416084314.18851-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_03:2020-04-14,2020-04-16 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org An update to pf params can change the devinfo, get an updated device information. Signed-off-by: Saurav Kashyap --- 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;