From patchwork Thu Mar 26 07:07:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459435 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 109E013A4 for ; Thu, 26 Mar 2020 07:08:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9C252083E for ; Thu, 26 Mar 2020 07:08:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="PU8jkY99" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727822AbgCZHIP (ORCPT ); Thu, 26 Mar 2020 03:08:15 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:30096 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727721AbgCZHIN (ORCPT ); Thu, 26 Mar 2020 03:08:13 -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 02Q710o1017925; Thu, 26 Mar 2020 00:08:12 -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=bEbBpMHJ1dTu47WzB0edpN82n0kY4N1K0lJ9y/kPL5w=; b=PU8jkY99bEh5WVq4gUh03xFAglybSLwozwU4rqFbz/wzYQseGT4Ip8gqnKvlZZRkUVaG dGn4oh380ugwdPf1Rku2emtcgv5P1tNzsWuaSZSC2RAOsM/qzagPlwi9USO3Q8OnFjf2 kMd9jCVgeYXE++NpAWQ/rVGpIAX31c5Ih+UvCZ/GgVxIP0uVicxS1IkoVRAK9Npqtvln LabRmONIXj3EoXcvIE1Mun9tBdDZkfIDUh84lcJR7oFoZzD2LG2NPN6uWFa5494pXaKM UYgTDTs14NA9u0v+GotbccLiFn3/XfrCs926BwYWt8a6Dz842zcnDH4DyHotCUiIAvtP CA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpctnby-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:11 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:09 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:09 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 0169C3F7040; Thu, 26 Mar 2020 00:08:09 -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 02Q7899V025532; Thu, 26 Mar 2020 00:08:09 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q7893u025531; Thu, 26 Mar 2020 00:08:09 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 1/8] qedf: Keep track of num of pending flogi. Date: Thu, 26 Mar 2020 00:07:59 -0700 Message-ID: <20200326070806.25493-2-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org - Problem: Port not coming up after bringing down the port for longer duration. - Bring down the port from the switch - wait for fipvlan to exhaust, driver will use default vlan (1002) and call fcoe_ctlr_link_up - libfc/fcoe will start sending FLOGI - bring back the port and switch discard FLOGI because vlan is different. - keep track of pending flogi and if it increases certain number then do ctx reset and it will do fipvlan again. 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 Mar 26 07:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459427 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 1245713A4 for ; Thu, 26 Mar 2020 07:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CCF3A20719 for ; Thu, 26 Mar 2020 07:08:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="f/Ngo/l9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbgCZHIS (ORCPT ); Thu, 26 Mar 2020 03:08:18 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:27948 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727817AbgCZHIR (ORCPT ); Thu, 26 Mar 2020 03:08:17 -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 02Q710lV017932; Thu, 26 Mar 2020 00:08:15 -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=nHVnZAkGjwhXrL8d4bc64Ctkm8kDGblmwH/Pb8ZFUk4=; b=f/Ngo/l9D4nUYASOVXMAhuDg6esKlv4TwGbPUsoPFrjTaimpSVauw1dOYtq9O7PM/Syj 4izLKhe/X03smpwonuvigw0gINYUbhQDwDih6WvfYSIYReG8xkTdxIptLJYHVS/cUu2i JwHNfO8o4oUdENOLtJZjMgJvK1g02s4H0XXHSPm0rxfdL1HxPPaUUg3MhojnFuWv6Ezo zWOW1BkbX45M763G7T/4MPygQ0QsRv37flbNUFNNKGltLzM1M0qg8NV7TwE5lN+/WPTD 9+1R6BptgMdjuhep8UF7lCXAP/1wsgmL7Wl2UzwX+tkiVS0IkxD8xDUaWUrZZ4OIKROr 9Q== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpctnc9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:15 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:12 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:12 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 28C613F7041; Thu, 26 Mar 2020 00:08:13 -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 02Q78DKc025536; Thu, 26 Mar 2020 00:08:13 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78CiA025535; Thu, 26 Mar 2020 00:08:13 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 2/8] qedf: Fix for the deviations from the SAM-4 spec. Date: Thu, 26 Mar 2020 00:08:00 -0700 Message-ID: <20200326070806.25493-3-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Javed Hasan - Upper limit for retry delay(QEDF_RETRY_DELAY_MAX) increased from 20 sec to 1 min. - Log an event/message indicating throttling of I/O for the target and include scope and retry delay time returned by the target and the driver enforced delay. - Synchronizing the update of the fcport->retry_delay_timestamp between qedf_queuecommand() and qedf_scsi_completion(). Signed-off-by: Saurav Kashyap Signed-off-by: Javed Hasan --- drivers/scsi/qedf/qedf.h | 2 +- drivers/scsi/qedf/qedf_io.c | 47 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 38 insertions(+), 11 deletions(-) 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; diff --git a/drivers/scsi/qedf/qedf_io.c b/drivers/scsi/qedf/qedf_io.c index e749a2d..f0f455e 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); @@ -1134,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; @@ -1267,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) @@ -1287,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 Mar 26 07:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459431 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 D2B3B913 for ; Thu, 26 Mar 2020 07:08:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A745F2083E for ; Thu, 26 Mar 2020 07:08:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="Hsnj7fZ9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbgCZHIU (ORCPT ); Thu, 26 Mar 2020 03:08:20 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:30866 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbgCZHIU (ORCPT ); Thu, 26 Mar 2020 03:08:20 -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 02Q710o2017925; Thu, 26 Mar 2020 00:08:18 -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=aquEnToZsWMQZdaaH5Ow2eN8zxiSdlMVIuuTyRL8K0I=; b=Hsnj7fZ9lwGpBVJuRzGxQaJmIHO+cBHZ1/eX4keufIl+90PZSgTLEWpuMzUhOEarZhKh LUWFrB0BvxKgmSoMSxxOO8pxVsRNTM9odGFpGGsF5EX3KK9PkGzhJ7k1+u6UYL92aHy8 2VbUpAs4E1YinYQKAbVlQX0O0rhvRXfvMgzDtjL2JE8jtEEDlEguj6614ttWpEUkuMQI BkqaenkWky6FgKqORjIxKSCeH/0jxUgCwy/Str93QpEipvnxRuAEwzhNwNgHQ/Xhvp6D TRkglzyDCOq+XXQIpZgu1DjaRXQrCnV4RWvPufp+MQagjw2ebigXbgklzsGYoJwCy+pZ EA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpctncg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:18 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:16 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:15 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 569893F703F; Thu, 26 Mar 2020 00:08:16 -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 02Q78GiY025540; Thu, 26 Mar 2020 00:08:16 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78GvB025539; Thu, 26 Mar 2020 00:08:16 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 3/8] qed: Send BW update notifications to the protocol drivers. Date: Thu, 26 Mar 2020 00:08:01 -0700 Message-ID: <20200326070806.25493-4-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 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 --- 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 Mar 26 07:08:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459433 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 162BA13A4 for ; Thu, 26 Mar 2020 07:08:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DF4B22083E for ; Thu, 26 Mar 2020 07:08:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="J7H0ziHg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbgCZHIX (ORCPT ); Thu, 26 Mar 2020 03:08:23 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:60050 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727639AbgCZHIW (ORCPT ); Thu, 26 Mar 2020 03:08:22 -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 02Q70cnn019549; Thu, 26 Mar 2020 00:08:21 -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=zM4RrSO2DvizfKXmC6pIIS8Jn6nIkU2uKlXMEB2FSnE=; b=J7H0ziHguX2rEveQCvf3lEFoAhPqfW1kC2OSBBfkE3Y8EaBEPyvQKOKlKKjkrHmXUUvs 0/F6yfEYlTs88WAceC8r/TEFZxC0YImByRK2t6REaEy5bN0NClK6GujhSpnbm96H2xvt TWhE03OXL9Y1WoBhTVE8CbvUB+64miEbzsW7SM6qTkUk6SDhe9zMmrm0003MxTo8UDmS 0AZribbd0ZFtIymTL14icW8fLfKLaMDWJi6YbX+wemGI2ITXXzFHTyaTkG0F+hEcoVQe hJkMJATx+2QHRpxU5+DUH5zxa7nwbPOvGzh1FC1AXN8l7qcGX1gszIEsAr5ejs096VT1 3w== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2ywg9nv951-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:21 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:19 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:19 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 7D6BA3F703F; Thu, 26 Mar 2020 00:08:19 -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 02Q78Jsp025544; Thu, 26 Mar 2020 00:08:19 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78JCY025543; Thu, 26 Mar 2020 00:08:19 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 4/8] qedf: Implement callback for bw_update. Date: Thu, 26 Mar 2020 00:08:02 -0700 Message-ID: <20200326070806.25493-5-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org This is extension of bw common callback provided by qed. This is called whenever there is a change in the BW. 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 Mar 26 07:08:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459437 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 C83EF913 for ; Thu, 26 Mar 2020 07:08:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9DC442083E for ; Thu, 26 Mar 2020 07:08:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="puwTr+Yc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbgCZHIZ (ORCPT ); Thu, 26 Mar 2020 03:08:25 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:1176 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727639AbgCZHIZ (ORCPT ); Thu, 26 Mar 2020 03:08:25 -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 02Q70Pe4019422; Thu, 26 Mar 2020 00:08:24 -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=wVla8zrZkVOBS+1JOisI/L2w2eFV3Ww+XRtXLjxLwcU=; b=puwTr+YcE/XK1RvhYTHRAQEsxU29hGkYYwhq7mN6KwGVnw7+lKqzkO649H9cBkHPhqDX 3Z+U2vmR7QleiXAWaDAmoYG2MiFpVmVumjKt0qMHSnRrNCa6y3/VCXSfSwXqM94p69n1 0KZoT5C7WI0fss5MV1b+n5biznuYqbWadLVtpcQy8Fktspe/eJkuhV2YdKFgJdj6W9yu bmsZSybjf5vcy5XhXK0cZNdBpC5cpXklHuHSzc6YYJzJ07LJZJuzRMjI1MdH9/DmUJH4 BIvq+6zQ9C69977N8fg8qnTwx9Yf6Ef7SZNeY9fQvfs1pieN5sb8V36Ha01O2QkAKSeN sw== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 2ywg9nv95c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:24 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:22 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:22 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id A3E983F7043; Thu, 26 Mar 2020 00:08:22 -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 02Q78MLv025548; Thu, 26 Mar 2020 00:08:22 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78Mmk025547; Thu, 26 Mar 2020 00:08:22 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 5/8] qedf: Add schedule recovery handler. Date: Thu, 26 Mar 2020 00:08:03 -0700 Message-ID: <20200326070806.25493-6-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Chad Dupuis - Add recovery handler, this will be triggered by QED. Signed-off-by: Chad Dupuis Signed-off-by: Saurav Kashyap --- drivers/scsi/qedf/qedf.h | 3 +++ drivers/scsi/qedf/qedf_main.c | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/scsi/qedf/qedf.h b/drivers/scsi/qedf/qedf.h index aaa2ac9..a5134c7 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; @@ -527,6 +528,8 @@ extern void qedf_scsi_done(struct qedf_ctx *qedf, struct qedf_ioreq *io_req, extern void qedf_process_unsol_compl(struct qedf_ctx *qedf, uint16_t que_idx, struct fcoe_cqe *cqe); extern void qedf_restart_rport(struct qedf_rport *fcport); +void qedf_schedule_recovery_handler(void *dev); +void qedf_recovery_handler(struct work_struct *work); extern int qedf_send_rec(struct qedf_ioreq *orig_io_req); extern int qedf_post_io_req(struct qedf_rport *fcport, struct qedf_ioreq *io_req); diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index ba66216..b3fa21a 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -662,6 +662,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 +3511,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 +3827,45 @@ static void qedf_shutdown(struct pci_dev *pdev) __qedf_remove(pdev, QEDF_MODE_NORMAL); } +/* + * Recovery handler code + */ +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); +} + +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 Mar 26 07:08:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459439 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 E506413A4 for ; Thu, 26 Mar 2020 07:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB2B220719 for ; Thu, 26 Mar 2020 07:08:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="gvPF3GP2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727876AbgCZHI3 (ORCPT ); Thu, 26 Mar 2020 03:08:29 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:47112 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727639AbgCZHI3 (ORCPT ); Thu, 26 Mar 2020 03:08:29 -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 02Q710o4017925; Thu, 26 Mar 2020 00:08:28 -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=RHHB/ZeJuwqE3Z1kGSUcKuQdU3QxPHroyh2aKRaYXQw=; b=gvPF3GP2vGuWs49asOtAG6ipiE916JNotMDY188Ugkh4XIe+ZuFDVu49/gckxvAPy1hN 8sB+mrVmpXPnl7v+MHF+zXVSsy4euCc/LEYd0rlnrDLxjTJbVaKSUQgf7Z4M0wZssiRy O5OTeX7LCBawXa6OLq/ioN15fsLSqjvm0bcGFrhIr6OUIoylanglZ7MmUh8cJRXAkAyA StJLgJ5bnwxbv7vTN+mjrZ2kDUWM1wEzbcY9rqCpz2a+jYf4gur5oEAqAB9g/5SVfXmk NfRz3ekyv4N24AlkT/o0HKd1TnmHM7vEDfzn/zXT2MnwySQb1Ca3+W5CfjVLZsjTHaN0 5A== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpctndb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:28 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:25 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:25 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id D84113F703F; Thu, 26 Mar 2020 00:08:25 -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 02Q78Pdl025552; Thu, 26 Mar 2020 00:08:25 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78P34025551; Thu, 26 Mar 2020 00:08:25 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 6/8] qedf: Fix crash when MFW calls for protocol stats while function is still probing. Date: Thu, 26 Mar 2020 00:08:04 -0700 Message-ID: <20200326070806.25493-7-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 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 a5134c7..951425b 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 b3fa21a..bbad015 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -3196,7 +3196,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; @@ -3226,6 +3226,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; @@ -3250,9 +3251,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 */ @@ -3559,6 +3563,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; @@ -3584,6 +3592,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; } @@ -3733,11 +3746,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 Mar 26 07:08:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saurav Kashyap X-Patchwork-Id: 11459441 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 3004613A4 for ; Thu, 26 Mar 2020 07:08:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 04D0F20719 for ; Thu, 26 Mar 2020 07:08:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="luQZi+Dm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727731AbgCZHId (ORCPT ); Thu, 26 Mar 2020 03:08:33 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:31586 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgCZHIc (ORCPT ); Thu, 26 Mar 2020 03:08:32 -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 02Q710LH017933; Thu, 26 Mar 2020 00:08: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=qHPq8rdK92ELKTaBex6dyt4dM2hWopqM5W+p4Cu48QM=; b=luQZi+DmoL9Z64ZviRdCrtRXlxlREtcy52M21Ha/wE20fbz9bKxd4PDtcreG5MbP3JR9 e2ZnQgXafryIo66CMDSHIK2/QC0/w+JIq6TXF8WYNRvCmmWAXRCng0aFctWIZ/yHZakR NfXu8wEuLHEXNpUtOIIkYYOa48CVcLeMwUVKDL9Y1zMFZn2dBap21pfbccwG0M5ekw5A ZrjIaSxQU5GRUg1fmrGRVye1mCZz6v2QSFTyLcJFciW6HzOIULP8sf+q5OSZgSkDcAXE uw8qPepmVNggwCEB6r0THtKZxxuOzJubhL9bdWc42kutkZSUXDRuyuy6DVkznO72hXlV nw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpctndq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:31 -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, 26 Mar 2020 00:08:30 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:29 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:28 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 0A2493F703F; Thu, 26 Mar 2020 00:08:29 -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 02Q78SAj025556; Thu, 26 Mar 2020 00:08:28 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78S8X025555; Thu, 26 Mar 2020 00:08:28 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 7/8] qedf: Get dev info after updating the params. Date: Thu, 26 Mar 2020 00:08:05 -0700 Message-ID: <20200326070806.25493-8-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org - Get the dev info after updating the params. 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 bbad015..49e6d12 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c @@ -3330,6 +3330,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; From patchwork Thu Mar 26 07:08: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: 11459445 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 88B3E913 for ; Thu, 26 Mar 2020 07:08:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DCB02082D for ; Thu, 26 Mar 2020 07:08:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=marvell.com header.i=@marvell.com header.b="zM0EQ/dB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727887AbgCZHIg (ORCPT ); Thu, 26 Mar 2020 03:08:36 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:56940 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726359AbgCZHIf (ORCPT ); Thu, 26 Mar 2020 03:08:35 -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 02Q710pv017922; Thu, 26 Mar 2020 00:08:34 -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=7gGr11O9pJ8x+bhlsX0sq/SG/BniIeMo/dlvqZux8FM=; b=zM0EQ/dBKmFioJ3D6szG1DL5tyIq/lDZDIv8sJhAV8Oud8VYrLS63l4Dcro0qdTXUGYO pfbvDDHw/072M1swaltZw+XEZruHTRsWG8iHZXHdY9dtjyMFTRRl7ZpfO7eCdBE6VxI7 wSHBWpgVbYU01pFqeTArO+rFkLDEZr4hDMkqpJtdtbUkRrcjepfbt8zWBdDeZeLDHTPR lsZxkVip7KsNLPKz8w66fr9+QlhAaDY5I8AxPYyjVdwq9nFPU+Q54Faq9PGsnE+v6+tL f8MRW88+GiDs5Zm7uRSkMRH2vH/WqpaXc7SqJk/52LbFI7R8UaaKY1ERhwoD7IHPWI2d mw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpctndt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 00:08:34 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 00:08:32 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 00:08:31 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 3707C3F7041; Thu, 26 Mar 2020 00:08:32 -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 02Q78WnB025561; Thu, 26 Mar 2020 00:08:32 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id 02Q78Wl6025559; Thu, 26 Mar 2020 00:08:32 -0700 From: Saurav Kashyap To: CC: , , Subject: [PATCH 8/8] qedf: Update the driver version to 8.42.3.5. Date: Thu, 26 Mar 2020 00:08:06 -0700 Message-ID: <20200326070806.25493-9-skashyap@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20200326070806.25493-1-skashyap@marvell.com> References: <20200326070806.25493-1-skashyap@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.645 definitions=2020-03-25_15:2020-03-24,2020-03-25 signatures=0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org - Update version to 8.42.3.5. Signed-off-by: Saurav Kashyap --- 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 b0e37af..7661a5d 100644 --- a/drivers/scsi/qedf/qedf_version.h +++ b/drivers/scsi/qedf/qedf_version.h @@ -4,9 +4,9 @@ * Copyright (c) 2016-2018 Cavium Inc. */ -#define QEDF_VERSION "8.42.3.0" +#define QEDF_VERSION "8.42.3.5" #define QEDF_DRIVER_MAJOR_VER 8 #define QEDF_DRIVER_MINOR_VER 42 #define QEDF_DRIVER_REV_VER 3 -#define QEDF_DRIVER_ENG_VER 0 +#define QEDF_DRIVER_ENG_VER 5