From patchwork Sat Jul 13 23:43:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732550 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24457158A3D for ; Sat, 13 Jul 2024 23:44:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914243; cv=none; b=OzcK7MGNfL1pJWfnxKywN26isawETTPmZGifJdV/KCY8sEKk7t5cQXL7kBSxV64fCKKZrcRfJ++FzpF7wbjlhCXcJp3HyZ0g5yLPygjer5N74qFn8cuHUnhoWucqwgWK2nC3Wcn7e6JXHOZlqg4eL0++GcmdaPzzjJeMdW/dbtk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914243; c=relaxed/simple; bh=5LGpVoNPv2zBHysh7o7ZZGAFjmz2XZV9kk5nlfvlgCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OjyhpVgGExOvPBCylXRe3VlxlnY5iv26lgsptCJUoOHO9e3unXQoHSwsbVFUcTXEvkOPv6ThHkgmdp0/CdSKCa91+EuXfjyop4wA9u3zsXlvvRuIGpxoQj+QfwZ/K9TYMqECtE3Gi0buZXTN7l63vJcArpEvpRhjiuThEdsnO8M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=JVPrM1DU; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JVPrM1DU" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-79f0e7faafcso247883485a.3 for ; Sat, 13 Jul 2024 16:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914241; x=1721519041; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=tWbyFey4/Ke8Fix12qt6SfN37g8pC8iWjHgC0Z1CcYA=; b=JVPrM1DUgNp3jk/M4EFVx/HsZ0HuaczgARMZHU8kh9hAOWrcaxMD+So/oJ8nL0ebJX uraDqvUW2Y85FNmDN+YhNvcxqKQeOaHIeUCV2/rdtkNhqiFYYtO1+Jh2hnZbljraazkr X02yUZ3BOA4YSbSP9SKbO5SCjjQ8P42gu5vVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914241; x=1721519041; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=tWbyFey4/Ke8Fix12qt6SfN37g8pC8iWjHgC0Z1CcYA=; b=NdOurzJ6iGhleR9PGLFGh+cM3oSqNpzdDIIWZk1o/vN7RoA7Bn1JoN8oO6y+dk7dBr spDQJUXuFVZMb/WrQDIfKT3+1Lo1k4FVWPlgxk/iMEw+pkYHRlvXgPTeMmbNgj3cqrDt rVgpu0w/l908O+zaBfWScuQ8/28ETdTL7BlrwqKvZrOmZZCrYNBICiDB9c7D38cxnLLr +//MlomJ00iw/l/jfgxukL8deTFtq05DlBJeQ4ZziIA1DBO2UzfGGrHfT5Qefg5bGsY7 aq11APQMKqC5PCMef8hJRY+TcviibsdR92OonI1PCkgiKntp7xsmqU6wOLzVZRrP4Q7M XH+Q== X-Gm-Message-State: AOJu0YwHKJIQ3ZODxbh7f4jzFeA0MqGM/Xse4nBITGV5Llo6mDyYjTwz uqh+q2dZNC5/5o2+D5ogG7w+c0OwzjGk6bWizQaAviZAqaAH9JN9U7XWPvnBjQ== X-Google-Smtp-Source: AGHT+IG5CxsgnSXS59LLrKItDi/ikqXtX83AUAeVCI/ayTOlLpFcTtPj5RfKXKvmrOWfSmU8YvhDOA== X-Received: by 2002:a05:620a:468a:b0:79e:ff22:b23c with SMTP id af79cd13be357-79f199f62bamr2398925685a.9.1720914240611; Sat, 13 Jul 2024 16:44:00 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.43.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:43:59 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Vikas Gupta , Somnath Kotur Subject: [PATCH net-next 1/9] bnxt_en: add support for storing crash dump into host memory Date: Sat, 13 Jul 2024 16:43:31 -0700 Message-ID: <20240713234339.70293-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Vikas Gupta Newer firmware supports automatic DMA of crash dump to host memory when it crashes. If the feature is supported, allocate the required memory using the existing context memory infrastructure. Communicate the page table containing the DMA addresses to the firmware. Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 93 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 + .../ethernet/broadcom/bnxt/bnxt_coredump.c | 18 +++- .../ethernet/broadcom/bnxt/bnxt_coredump.h | 8 ++ 4 files changed, 117 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index bb3be33c1bbd..37da16b39f77 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -69,6 +69,7 @@ #include "bnxt_tc.h" #include "bnxt_devlink.h" #include "bnxt_debugfs.h" +#include "bnxt_coredump.h" #include "bnxt_hwmon.h" #define BNXT_TX_TIMEOUT (5 * HZ) @@ -8939,6 +8940,82 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp) return 0; } +#define BNXT_SET_CRASHDUMP_PAGE_ATTR(attr) \ +do { \ + if (BNXT_PAGE_SIZE == 0x2000) \ + attr = DBG_CRASHDUMP_MEDIUM_CFG_REQ_PG_SIZE_PG_8K; \ + else if (BNXT_PAGE_SIZE == 0x10000) \ + attr = DBG_CRASHDUMP_MEDIUM_CFG_REQ_PG_SIZE_PG_64K; \ + else \ + attr = DBG_CRASHDUMP_MEDIUM_CFG_REQ_PG_SIZE_PG_4K; \ +} while (0) + +static int bnxt_hwrm_crash_dump_mem_cfg(struct bnxt *bp) +{ + struct hwrm_dbg_crashdump_medium_cfg_input *req; + u16 page_attr = 0; + int rc; + + if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) + return 0; + + rc = hwrm_req_init(bp, req, HWRM_DBG_CRASHDUMP_MEDIUM_CFG); + if (rc) + return rc; + + BNXT_SET_CRASHDUMP_PAGE_ATTR(page_attr); + req->pg_size_lvl = cpu_to_le16(page_attr | + bp->fw_crash_mem->ring_mem.depth); + req->pbl = cpu_to_le64(bp->fw_crash_mem->ring_mem.pg_tbl_map); + req->size = cpu_to_le32(bp->fw_crash_len); + req->output_dest_flags = cpu_to_le16(BNXT_DBG_CR_DUMP_MDM_CFG_DDR); + return hwrm_req_send(bp, req); +} + +static void bnxt_free_crash_dump_mem(struct bnxt *bp) +{ + if (bp->fw_crash_mem) { + bnxt_free_ctx_pg_tbls(bp, bp->fw_crash_mem); + kfree(bp->fw_crash_mem); + bp->fw_crash_len = 0; + bp->fw_crash_mem = NULL; + } +} + +static int bnxt_alloc_crash_dump_mem(struct bnxt *bp) +{ + u32 mem_size = 0; + int rc; + + if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) + return 0; + + rc = bnxt_hwrm_get_dump_len(bp, BNXT_DUMP_CRASH, &mem_size); + if (rc) + return rc; + + mem_size = round_up(mem_size, 4); + + if (bp->fw_crash_mem && mem_size == bp->fw_crash_len) + return 0; + + bnxt_free_crash_dump_mem(bp); + + bp->fw_crash_mem = kzalloc(sizeof(*bp->fw_crash_mem), GFP_KERNEL); + if (!bp->fw_crash_mem) + return -ENOMEM; + + rc = bnxt_alloc_ctx_pg_tbls(bp, bp->fw_crash_mem, mem_size, 1, NULL); + if (rc) { + bnxt_free_crash_dump_mem(bp); + return rc; + } + + bp->fw_crash_len = mem_size; + + return 0; +} + int bnxt_hwrm_func_resc_qcaps(struct bnxt *bp, bool all) { struct hwrm_func_resource_qcaps_output *resp; @@ -13959,6 +14036,19 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp) if (rc) return -ENODEV; + rc = bnxt_alloc_crash_dump_mem(bp); + if (rc) + netdev_warn(bp->dev, "crash dump mem alloc failure rc: %d\n", + rc); + if (!rc) { + rc = bnxt_hwrm_crash_dump_mem_cfg(bp); + if (rc) { + bnxt_free_crash_dump_mem(bp); + netdev_warn(bp->dev, + "hwrm crash dump mem failure rc: %d\n", rc); + } + } + if (bnxt_fw_pre_resv_vnics(bp)) bp->fw_cap |= BNXT_FW_CAP_PRE_RESV_VNICS; @@ -15237,6 +15327,7 @@ static void bnxt_remove_one(struct pci_dev *pdev) bp->fw_health = NULL; bnxt_cleanup_pci(bp); bnxt_free_ctx_mem(bp); + bnxt_free_crash_dump_mem(bp); kfree(bp->rss_indir_tbl); bp->rss_indir_tbl = NULL; bnxt_free_port_stats(bp); @@ -15875,6 +15966,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) bp->fw_health = NULL; bnxt_cleanup_pci(bp); bnxt_free_ctx_mem(bp); + bnxt_free_crash_dump_mem(bp); kfree(bp->rss_indir_tbl); bp->rss_indir_tbl = NULL; @@ -15928,6 +16020,7 @@ static int bnxt_suspend(struct device *device) bnxt_hwrm_func_drv_unrgtr(bp); pci_disable_device(bp->pdev); bnxt_free_ctx_mem(bp); + bnxt_free_crash_dump_mem(bp); rtnl_unlock(); return rc; } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 6bbdc718c3a7..77bd36812293 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2644,6 +2644,9 @@ struct bnxt { #endif u32 thermal_threshold_type; enum board_idx board_idx; + + struct bnxt_ctx_pg_info *fw_crash_mem; + u32 fw_crash_len; }; #define BNXT_NUM_RX_RING_STATS 8 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c index c06789882036..ebbad9ccab6a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c @@ -385,7 +385,7 @@ int bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, u32 *dump_len) } } -static int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len) +int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len) { struct hwrm_dbg_qcfg_output *resp; struct hwrm_dbg_qcfg_input *req; @@ -395,7 +395,8 @@ static int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len) return -EOPNOTSUPP; if (dump_type == BNXT_DUMP_CRASH && - !(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR)) + !(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR || + (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR))) return -EOPNOTSUPP; rc = hwrm_req_init(bp, req, HWRM_DBG_QCFG); @@ -403,8 +404,12 @@ static int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len) return rc; req->fid = cpu_to_le16(0xffff); - if (dump_type == BNXT_DUMP_CRASH) - req->flags = cpu_to_le16(DBG_QCFG_REQ_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR); + if (dump_type == BNXT_DUMP_CRASH) { + if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR) + req->flags = cpu_to_le16(BNXT_DBG_FL_CR_DUMP_SIZE_SOC); + else + req->flags = cpu_to_le16(BNXT_DBG_FL_CR_DUMP_SIZE_HOST); + } resp = hwrm_req_hold(bp, req); rc = hwrm_req_send(bp, req); @@ -412,7 +417,10 @@ static int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len) goto get_dump_len_exit; if (dump_type == BNXT_DUMP_CRASH) { - *dump_len = le32_to_cpu(resp->crashdump_size); + if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR) + *dump_len = BNXT_CRASH_DUMP_LEN; + else + *dump_len = le32_to_cpu(resp->crashdump_size); } else { /* Driver adds coredump header and "HWRM_VER_GET response" * segment additionally to coredump. diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h index b1a1b2fffb19..a76d5c281413 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.h @@ -111,7 +111,15 @@ struct hwrm_dbg_cmn_output { #define HWRM_DBG_CMN_FLAGS_MORE 1 }; +#define BNXT_DBG_FL_CR_DUMP_SIZE_SOC \ + DBG_QCFG_REQ_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_SOC_DDR +#define BNXT_DBG_FL_CR_DUMP_SIZE_HOST \ + DBG_QCFG_REQ_FLAGS_CRASHDUMP_SIZE_FOR_DEST_DEST_HOST_DDR +#define BNXT_DBG_CR_DUMP_MDM_CFG_DDR \ + DBG_CRASHDUMP_MEDIUM_CFG_REQ_TYPE_DDR + int bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, u32 *dump_len); +int bnxt_hwrm_get_dump_len(struct bnxt *bp, u16 dump_type, u32 *dump_len); u32 bnxt_get_coredump_length(struct bnxt *bp, u16 dump_type); #endif From patchwork Sat Jul 13 23:43:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732551 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 026301CFB6 for ; Sat, 13 Jul 2024 23:44:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914245; cv=none; b=VnuhSjv1qezJtHGURuraTZdItczdAujRXpxJmE3rh4icpUugWxggIzWxCJMoD0CwPjDklFlbcRXqKWK0Zx06Ur7PPRF2edojU2C7NabR3FHWZPY2MYcbv6DpSQ1FrcPE71h1ZZmSlD5CXAy3D5BcQ371/9lRlt0Sdb3d41tF+5g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914245; c=relaxed/simple; bh=pWkCACW6CMmRMxpuNn5/+muyCuGRXZODp6Itx6SIoTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nwasMZHkDRTgyk2kCcs+rY3W3yM62F3pL94rEdEvIxNnkzqCuVSIt0a0GrV7z3nqPJJdEZYPg+5UUKnVRgr4rXBR8oHl0HQT9LxO9Ff7kosScVGaAd5Yy+1vYf4OVFcJ6jTasf2sxlaTmDzh8LqxdCWe9X2IYU2N63mYu/86eZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=QOQjI8Bj; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="QOQjI8Bj" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-44f666d9607so143001cf.1 for ; Sat, 13 Jul 2024 16:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914243; x=1721519043; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Ht24nYjeEFaELDrdwiXs89uTywrxH7j64O/abMLZNFw=; b=QOQjI8BjlwlnbPAeYY6IUv+cXzN+RPTCuxO0ppVh4VQP7Yap7I9bOkTOdRxnkE24rO nh2zDqB+vWseGqrCinHsohL+XUkQ47cDKjlms1E0wghH0UzwZimFSwr06Re8YRSt2+QV kh5WVXCee1qyHZom9QQW38+O4+iFbaY8p3AiQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914243; x=1721519043; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ht24nYjeEFaELDrdwiXs89uTywrxH7j64O/abMLZNFw=; b=HtVG78dVilOWORUM1+JfunG7s/PGehmiyLf2Yx8BtUovfKDLdkIYgqctfoPuAZXa2n zTk8Sh/49Z+4oS7VhdcyUzYPsKO2LpmWdFrVXQujGjD5F2/PvuA3UjmkJcATpeo447bT ij8vog3VWtSn1F+F2JUU8zQ2yJ/h+qxgLrA2GyPpelUI2z9RCz8OkJGTdC1ZuPmLoyrN WDuhu6eckUkpc7OWz8ZyDA83l6ELJklN/olyC2AFXbCL650SdIYPMB3MlFyo5rpFUxKo SwAy2KNazA9EuVGnZtVeROxAvQ7wtVX4x15ByZMZ+6PjZ0DTwk3lgc8gL+dt0CooRkaQ gU7Q== X-Gm-Message-State: AOJu0YzPSRMhTloFoS55w9+RWw+R9o0iUYyGDVaDac+kF6mFj0CYHhKR +eocVEWaOKp1WGWqe8vVBC1tX0lxK1eIZHTSb0sxA/aB1yd2vEdjOIlFBxIGXw== X-Google-Smtp-Source: AGHT+IFG36GQgY4uCjZVXfvzOA+CLsaqzqWLJJzVuABtpMBQX73k8Fp0qhp2LdItmxdajN/JAxzpeg== X-Received: by 2002:ac8:7e92:0:b0:447:f12f:38dd with SMTP id d75a77b69052e-447faacbf83mr192085311cf.59.1720914242797; Sat, 13 Jul 2024 16:44:02 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.00 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:01 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Vikas Gupta , Somnath Kotur Subject: [PATCH net-next 2/9] bnxt_en: add support for retrieving crash dump using ethtool Date: Sat, 13 Jul 2024 16:43:32 -0700 Message-ID: <20240713234339.70293-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Vikas Gupta Add support for retrieving crash dump using ethtool -w on the supported interface. Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Reviewed-by: Andy Gospodarek Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- .../ethernet/broadcom/bnxt/bnxt_coredump.c | 83 +++++++++++++++++-- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 13 ++- 2 files changed, 87 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c index ebbad9ccab6a..9ed915e4c618 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c @@ -372,14 +372,78 @@ static int __bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len) return rc; } +static u32 bnxt_copy_crash_data(struct bnxt_ring_mem_info *rmem, void *buf, + u32 dump_len) +{ + u32 data_copied = 0; + u32 data_len; + int i; + + for (i = 0; i < rmem->nr_pages; i++) { + data_len = rmem->page_size; + if (data_copied + data_len > dump_len) + data_len = dump_len - data_copied; + memcpy(buf + data_copied, rmem->pg_arr[i], data_len); + data_copied += data_len; + if (data_copied >= dump_len) + break; + } + return data_copied; +} + +static int bnxt_copy_crash_dump(struct bnxt *bp, void *buf, u32 dump_len) +{ + struct bnxt_ring_mem_info *rmem; + u32 offset = 0; + + if (!bp->fw_crash_mem) + return -EEXIST; + + rmem = &bp->fw_crash_mem->ring_mem; + + if (rmem->depth > 1) { + int i; + + for (i = 0; i < rmem->nr_pages; i++) { + struct bnxt_ctx_pg_info *pg_tbl; + + pg_tbl = bp->fw_crash_mem->ctx_pg_tbl[i]; + offset += bnxt_copy_crash_data(&pg_tbl->ring_mem, + buf + offset, + dump_len - offset); + if (offset >= dump_len) + break; + } + } else { + bnxt_copy_crash_data(rmem, buf, dump_len); + } + + return 0; +} + +static bool bnxt_crash_dump_avail(struct bnxt *bp) +{ + u32 sig = 0; + + /* First 4 bytes(signature) of crash dump is always non-zero */ + bnxt_copy_crash_dump(bp, &sig, sizeof(u32)); + if (!sig) + return false; + + return true; +} + int bnxt_get_coredump(struct bnxt *bp, u16 dump_type, void *buf, u32 *dump_len) { if (dump_type == BNXT_DUMP_CRASH) { + if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR) + return bnxt_copy_crash_dump(bp, buf, *dump_len); #ifdef CONFIG_TEE_BNXT_FW - return tee_bnxt_copy_coredump(buf, 0, *dump_len); -#else - return -EOPNOTSUPP; + else if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR) + return tee_bnxt_copy_coredump(buf, 0, *dump_len); #endif + else + return -EOPNOTSUPP; } else { return __bnxt_get_coredump(bp, buf, dump_len); } @@ -442,10 +506,17 @@ u32 bnxt_get_coredump_length(struct bnxt *bp, u16 dump_type) { u32 len = 0; + if (dump_type == BNXT_DUMP_CRASH && + bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR && + bp->fw_crash_mem) { + if (!bnxt_crash_dump_avail(bp)) + return 0; + + return bp->fw_crash_len; + } + if (bnxt_hwrm_get_dump_len(bp, dump_type, &len)) { - if (dump_type == BNXT_DUMP_CRASH) - len = BNXT_CRASH_DUMP_LEN; - else + if (dump_type != BNXT_DUMP_CRASH) __bnxt_get_coredump(bp, NULL, &len); } return len; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index f121a5e9691f..1e720aa69568 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4983,9 +4983,16 @@ static int bnxt_set_dump(struct net_device *dev, struct ethtool_dump *dump) return -EINVAL; } - if (!IS_ENABLED(CONFIG_TEE_BNXT_FW) && dump->flag == BNXT_DUMP_CRASH) { - netdev_info(dev, "Cannot collect crash dump as TEE_BNXT_FW config option is not enabled.\n"); - return -EOPNOTSUPP; + if (dump->flag == BNXT_DUMP_CRASH) { + if (bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_SOC_DDR && + (!IS_ENABLED(CONFIG_TEE_BNXT_FW))) { + netdev_info(dev, + "Cannot collect crash dump as TEE_BNXT_FW config option is not enabled.\n"); + return -EOPNOTSUPP; + } else if (!(bp->fw_dbg_cap & DBG_QCAPS_RESP_FLAGS_CRASHDUMP_HOST_DDR)) { + netdev_info(dev, "Crash dump collection from host memory is not supported on this interface.\n"); + return -EOPNOTSUPP; + } } bp->dump_flag = dump->flag; From patchwork Sat Jul 13 23:43:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732552 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F26E158A3D for ; Sat, 13 Jul 2024 23:44:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914247; cv=none; b=KcQOvQntfN9yG15FVlvKNrSvflSEnVJ5RdeYxreT+oLFtlN6WqaKG+sWS94zlOfcX9/PV9J+s7K5mslMRLYlW0TKfvGE5KBhLvS+Ui//42ZKOe04RjfoT0wXOwozYpHR5K6lCuo9fehEh+7mO+FQV7ejCbU8ONneqApeVFMxCKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914247; c=relaxed/simple; bh=S16Ojt4+3M0OEnu13HDWuvSBF86tu1UY2+2ptdWjy0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uwJEzHvEK0zfEutYpLGXFRgwQ2tgXB5MroopyyTzoTWGCyL5ouU43rl5HHMPAcH99HgoZGMsvhxhp6L09ToiiUkbAi4o0QM9W8tlxaXzmCBKgA6I7s3eeZ6DSZ9mwDhEiFM01BqXT2Y/oQXAoRpdkOtfI7kINiJC/wK+qZeENoM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=PKtq18LM; arc=none smtp.client-ip=209.85.222.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="PKtq18LM" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-79efd2151d9so213324485a.0 for ; Sat, 13 Jul 2024 16:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914244; x=1721519044; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=lRstUM1/Ax0qtJG1kX00Fg7S46TxruHPJqXmHJ8RXPQ=; b=PKtq18LMyQ2mlI48CVopwMeW5BAuNl8evGdSC/pPSjkmB3sZ7bX+jyChQMjIq3NbDH XLaFLJrLGv9I4woRiQkzSOHSZWbZriSW4IDyX2nwshnENMp62MuV9e9Y8jEp/Ig+GMdU dMEwydzB7Fq5RsaEwWwQb5O2ngN7RqnyRCj+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914244; x=1721519044; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lRstUM1/Ax0qtJG1kX00Fg7S46TxruHPJqXmHJ8RXPQ=; b=wKCNeQ2VpdPVgCcYQHUmG+lbTc/7aTH4akxRWRtsOqaKGaW6h57+iBLSJPeLga9L+q N1VhIzXMU0MhTIGCt8tyHJ6Q9Y9JEXWf9KsV2/bSXYcIsWNVI4QC0iPGu1sXN7EuLqpJ zd5nxtBMhKwrWI7Svlt0dLJHyVry6tMBhX5rUF/TtAsOxuWsa0H2x5t+UNRlJSDtDWUF jBgVSnT3X3gskrByoI0bqyUwmfNsXKpLiO2FHoGWAi4BVRw/0mWk2zjHV9MmUktvsA7Y ki86flSVj99OS5N8Xmc4JXpNqSiSwldCQ3NQlsvAAg8TuVJaxa1REJCc6RGOsaQtFyIr /V/A== X-Gm-Message-State: AOJu0YxnFNNL+r9bePxDDpr4PRCJRBgM/YiJ+Nr36s9Bmvch671uFwn4 oDImX2bP1OkY3cVL/Phlalt/5urAu+LZKP+Qo7iclclEvDlpVzpLeJi+0OKRoQ== X-Google-Smtp-Source: AGHT+IHWCHmLU/DqfBUPxtUpJyhxNsVJnO4+USiFi+hkDyZi64KcnyzFHqpd9NWNT2gaxNTXGFQKMg== X-Received: by 2002:a05:620a:2915:b0:7a1:417a:9d05 with SMTP id af79cd13be357-7a1417a9ff3mr1531164285a.56.1720914244335; Sat, 13 Jul 2024 16:44:04 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:03 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Sreekanth Reddy Subject: [PATCH net-next 3/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Date: Sat, 13 Jul 2024 16:43:33 -0700 Message-ID: <20240713234339.70293-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Sreekanth Reddy With recent changes in the .ndo_set_vf_*() guidelines, resubmitting this patch that was reverted eariler in 2023: c27153682eac ("Revert "bnxt_en: Support QOS and TPID settings for the SRIOV VLAN") Add these missing settings in the .ndo_set_vf_vlan() method. Older firmware does not support the TPID setting so check for proper support. Remove the unused BNXT_VF_QOS flag. Signed-off-by: Sreekanth Reddy Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - .../net/ethernet/broadcom/bnxt/bnxt_sriov.c | 24 ++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 37da16b39f77..4f9d9a1d9c88 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9191,6 +9191,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp) bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF; if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED)) bp->fw_cap |= BNXT_FW_CAP_LIVEPATCH; + if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_DFLT_VLAN_TPID_PCP_SUPPORTED)) + bp->fw_cap |= BNXT_FW_CAP_DFLT_VLAN_TPID_PCP; if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_BS_V2_SUPPORTED) bp->fw_cap |= BNXT_FW_CAP_BACKING_STORE_V2; if (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_TX_COAL_CMPL_CAP) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 77bd36812293..af4d9bb947b3 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1355,7 +1355,6 @@ struct bnxt_vf_info { u16 vlan; u16 func_qcfg_flags; u32 flags; -#define BNXT_VF_QOS 0x1 #define BNXT_VF_SPOOFCHK 0x2 #define BNXT_VF_LINK_FORCED 0x4 #define BNXT_VF_LINK_UP 0x8 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index 22898d3d088b..58bd84b59f0e 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "bnxt_hsi.h" #include "bnxt.h" #include "bnxt_hwrm.h" @@ -196,11 +197,8 @@ int bnxt_get_vf_config(struct net_device *dev, int vf_id, memcpy(&ivi->mac, vf->vf_mac_addr, ETH_ALEN); ivi->max_tx_rate = vf->max_tx_rate; ivi->min_tx_rate = vf->min_tx_rate; - ivi->vlan = vf->vlan; - if (vf->flags & BNXT_VF_QOS) - ivi->qos = vf->vlan >> VLAN_PRIO_SHIFT; - else - ivi->qos = 0; + ivi->vlan = vf->vlan & VLAN_VID_MASK; + ivi->qos = vf->vlan >> VLAN_PRIO_SHIFT; ivi->spoofchk = !!(vf->flags & BNXT_VF_SPOOFCHK); ivi->trusted = bnxt_is_trusted_vf(bp, vf); if (!(vf->flags & BNXT_VF_LINK_FORCED)) @@ -256,21 +254,21 @@ int bnxt_set_vf_vlan(struct net_device *dev, int vf_id, u16 vlan_id, u8 qos, if (bp->hwrm_spec_code < 0x10201) return -ENOTSUPP; - if (vlan_proto != htons(ETH_P_8021Q)) + if (vlan_proto != htons(ETH_P_8021Q) && + (vlan_proto != htons(ETH_P_8021AD) || + !(bp->fw_cap & BNXT_FW_CAP_DFLT_VLAN_TPID_PCP))) return -EPROTONOSUPPORT; rc = bnxt_vf_ndo_prep(bp, vf_id); if (rc) return rc; - /* TODO: needed to implement proper handling of user priority, - * currently fail the command if there is valid priority - */ - if (vlan_id > 4095 || qos) + if (vlan_id >= VLAN_N_VID || qos >= IEEE_8021Q_MAX_PRIORITIES || + (!vlan_id && qos)) return -EINVAL; vf = &bp->pf.vf[vf_id]; - vlan_tag = vlan_id; + vlan_tag = vlan_id | (u16)qos << VLAN_PRIO_SHIFT; if (vlan_tag == vf->vlan) return 0; @@ -279,6 +277,10 @@ int bnxt_set_vf_vlan(struct net_device *dev, int vf_id, u16 vlan_id, u8 qos, req->fid = cpu_to_le16(vf->fw_fid); req->dflt_vlan = cpu_to_le16(vlan_tag); req->enables = cpu_to_le32(FUNC_CFG_REQ_ENABLES_DFLT_VLAN); + if (bp->fw_cap & BNXT_FW_CAP_DFLT_VLAN_TPID_PCP) { + req->enables |= cpu_to_le32(FUNC_CFG_REQ_ENABLES_TPID); + req->tpid = vlan_proto; + } rc = hwrm_req_send(bp, req); if (!rc) vf->vlan = vlan_tag; From patchwork Sat Jul 13 23:43:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732553 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DA7516C69E for ; Sat, 13 Jul 2024 23:44:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914249; cv=none; b=UEONjpAmxKMNkuIkPNBiHCpGIorWww7rqiFwNIIlXvQPbVZlcWmNoDdSFivrghf67KlaS8rYq8OWSBjsMEyt8IdmZV8CLMUlQX+IhUwGo25/o6ONyfg5Ds1Tn9S1adK0xd3BEFKl+LGBEUMqnqF+hDOP0y7Ff4zzRdE1XNrKJ/o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914249; c=relaxed/simple; bh=JO5unTtKVFCWh7olQ9fNM8OwAtk5emmSZB+l5awaUSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FtnL7AW3YgyFKHZ5m/Hlx2hUXwshBXajDw18qIsEriyXe9HUl5pkZ59QFGvLLQLywspMZxvuumNPwC3cdokIGPJjfjw+GXej+a3NJAJ6WGbTV6rOsoVKuzN1aeiRS7gtoje0EzBkfnu8FlCSoTtxy0VhUnnRxfL8lx3/OzW5YBE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=T7TdXpGM; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="T7TdXpGM" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-79efb4a46b6so215518385a.2 for ; Sat, 13 Jul 2024 16:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914246; x=1721519046; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=LWkis2EbV5Qx1HwZk5h5XIa/3JXLabK7UZPW1SNVhJg=; b=T7TdXpGMel6T/qrXfkvf2ZSEr4KdBp4WWqWPgqFiW0Je3jvbmlFtjSjXdTf9iPPUQl Ucakiey6VtkWfvDRAWMCFRE45bjCTXxlqteuAhEi8toX/c55AHjs0kCIAUzKc6bDHy2k N6uX+5/3aeDGMqsmB+zDiid/eB2GZn3rgq6+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914246; x=1721519046; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LWkis2EbV5Qx1HwZk5h5XIa/3JXLabK7UZPW1SNVhJg=; b=YfDAPWHgMjgw4VPL1dHKHOOGKt4VfxjsNNGe/ndYoJLcPiAmrCUyMHY52wN8fOhIZK r065NDa0G5Be0LwkFz97zBREGqb6soMRCuWCKtZnycIjtap+tJSYgsibttlcxTm07JTo szICCGwYFrfBAjdj6Ix1ghI1nmQR4SFvHisSZmgCSVdIkeHbiimAogQQiPoa7T1LD65W kEJRHX73pYRuniDK0Pc0S8WKex6kAqBg1BDeJhtX99I6ch9XmgenmLnX+0RDwIAOKuVJ iA6ofegy8sJV5Y5kqm/9Z0/1qgovgUBzD/B9gAvH3Kx2My8dP6icysPWTE3Fmcffu+Wf nbjQ== X-Gm-Message-State: AOJu0Yy3AakPMdk5lQIRj0s2NLKN63EtTvSDtqctMrgGb006Xojj5ZqA LeK88Qt97bHHQ0b6hPkXhEASstouxcxCd6BKuRzQ5tuD2rZGPRTuUv8oKTFGAg== X-Google-Smtp-Source: AGHT+IHjvHnKlNF/p2g6E11m1jsrdE35aOZYfewnxn665b0/+i+/Y00+uUqseTih0QLr9LUXcaLgug== X-Received: by 2002:a05:620a:1a0c:b0:79f:a53:5638 with SMTP id af79cd13be357-79f19a6a830mr2221383185a.44.1720914246178; Sat, 13 Jul 2024 16:44:06 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:05 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Hongguang Gao , Kalesh AP , Somnath Kotur Subject: [PATCH net-next 4/9] bnxt_en: Deprecate support for legacy INTX mode Date: Sat, 13 Jul 2024 16:43:34 -0700 Message-ID: <20240713234339.70293-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Firmware has deprecated support for legacy INTX in 2022 and INTX hasn't been tested for many years before that. If MSIX capability is not found in probe, abort. Reviewed-by: Hongguang Gao Reviewed-by: Kalesh AP Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 41 ++++------------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 4f9d9a1d9c88..7599fc3f8e27 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10745,7 +10745,7 @@ static int bnxt_get_num_msix(struct bnxt *bp) return bnxt_nq_rings_in_use(bp); } -static int bnxt_init_msix(struct bnxt *bp) +static int bnxt_init_int_mode(struct bnxt *bp) { int i, total_vecs, max, rc = 0, min = 1, ulp_msix, tx_cp; struct msix_entry *msix_ent; @@ -10803,7 +10803,7 @@ static int bnxt_init_msix(struct bnxt *bp) return 0; msix_setup_exit: - netdev_err(bp->dev, "bnxt_init_msix err: %x\n", rc); + netdev_err(bp->dev, "bnxt_init_int_mode err: %x\n", rc); kfree(bp->irq_tbl); bp->irq_tbl = NULL; pci_disable_msix(bp->pdev); @@ -10811,35 +10811,6 @@ static int bnxt_init_msix(struct bnxt *bp) return rc; } -static int bnxt_init_inta(struct bnxt *bp) -{ - bp->irq_tbl = kzalloc(sizeof(struct bnxt_irq), GFP_KERNEL); - if (!bp->irq_tbl) - return -ENOMEM; - - bp->total_irqs = 1; - bp->rx_nr_rings = 1; - bp->tx_nr_rings = 1; - bp->cp_nr_rings = 1; - bp->flags |= BNXT_FLAG_SHARED_RINGS; - bp->irq_tbl[0].vector = bp->pdev->irq; - return 0; -} - -static int bnxt_init_int_mode(struct bnxt *bp) -{ - int rc = -ENODEV; - - if (bp->flags & BNXT_FLAG_MSIX_CAP) - rc = bnxt_init_msix(bp); - - if (!(bp->flags & BNXT_FLAG_USING_MSIX) && BNXT_PF(bp)) { - /* fallback to INTA */ - rc = bnxt_init_inta(bp); - } - return rc; -} - static void bnxt_clear_int_mode(struct bnxt *bp) { if (bp->flags & BNXT_FLAG_USING_MSIX) @@ -12885,7 +12856,7 @@ bool bnxt_rfs_capable(struct bnxt *bp, bool new_rss_ctx) !BNXT_SUPPORTS_NTUPLE_VNIC(bp)) return bnxt_rfs_supported(bp); - if (!(bp->flags & BNXT_FLAG_MSIX_CAP) || !bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) + if (!bnxt_can_reserve_rings(bp) || !bp->rx_nr_rings) return false; hwr.grp = bp->rx_nr_rings; @@ -15743,8 +15714,10 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (BNXT_PF(bp)) SET_NETDEV_DEVLINK_PORT(dev, &bp->dl_port); - if (pdev->msix_cap) - bp->flags |= BNXT_FLAG_MSIX_CAP; + if (!pdev->msix_cap) { + dev_err(&pdev->dev, "MSIX capability not found, aborting\n"); + return -ENODEV; + } rc = bnxt_init_board(pdev, dev); if (rc < 0) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index af4d9bb947b3..06030244d740 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2199,7 +2199,6 @@ struct bnxt { #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ BNXT_FLAG_LRO) #define BNXT_FLAG_USING_MSIX 0x40 - #define BNXT_FLAG_MSIX_CAP 0x80 #define BNXT_FLAG_RFS 0x100 #define BNXT_FLAG_SHARED_RINGS 0x200 #define BNXT_FLAG_PORT_STATS 0x400 From patchwork Sat Jul 13 23:43:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732554 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4923F16D9AC for ; Sat, 13 Jul 2024 23:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914251; cv=none; b=fI6hxD/jVJ2t8JFlhY8fnprkzMySrt1IjkEh+Tibku6zXVsktIf84Dhkc8PixzsMqspsb+CvglFTBSv0UE1JiS4xvSv0er114b5pgVByb+PJcjVsknb9mGAxYnAQeEQHFPLZADVEOImVh+aYb6TjpQMxSlTgYhtpvekw3g9QVbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914251; c=relaxed/simple; bh=2LFycrL+1ZqNbnVUEvLGCwtlYDYUlmIFUA0YHzIQcp4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uBLfGwtfTiup/ym/CQlx6L7H73UcmPU3L9Cc0aBQf4KstLTZF2rTgBa2jAUaOuPvxJwWr97Jc/DuS6LfKfSfkiY7hkMB2nkZjxBBCVuwdjj5tMABk7lkAPYpyZ4jUaWp+qZZzlQYiWOhtqYcB4sdbe5mBWOOYZdteOqo/96AWug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=WpsaTkZz; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="WpsaTkZz" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-447f7c7c5fcso19025881cf.0 for ; Sat, 13 Jul 2024 16:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914248; x=1721519048; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=2tYYoWBCJNopWccKay4PdX1EibY8ZSHIfBXU7LbAaTM=; b=WpsaTkZz181NYF/ZKzNDGkybkSLFVz7FNGdVfoCPTmb9cGr6SsWKQ4rBEmFsj6DoOh iWT+FYpmUOg7BZbRLso0qRghys+7nQYSv/D4mpNFsVp/ogVdzebhFbYj0K4JIou18MC3 fRuN/moYse1K2krNRIHyCiUBZwntfDBy8EvTQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914248; x=1721519048; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2tYYoWBCJNopWccKay4PdX1EibY8ZSHIfBXU7LbAaTM=; b=t6+Ey+lWIDnk5dU5aDRryPRMrk2feF15O9Lw9xgvIUlYLLepouhZtft/RFaI7Hyak9 jcNQN1N/GEg40DMV4m5WerVxQt7d5TiNNxFd2kSPcHknv/+OwfzRpv00W/w1Io7ECmtU bsZDbczs4sM6Py47/RKVPneHHPnMt8/x45ZO19m5Fl9vDZx7CMcYG8LcGlKiqRuSGqbP V389F9eKOWlisR9kC8U2UnMpzvYLgziwth2phZTw+6nzI33hKDGXol/GwcPOOkhjzpWu alxkdDcAM1Gjo9Io7uaq9UKMY+6GFYdNsdC2CFOyM3EgIZfO1e0n++ms2Nc0DZxn1SoM Ic2A== X-Gm-Message-State: AOJu0YxSZNSbcKn1TWJqhp9Qnbx7G2RRUliv1dc/ubx24VR97sZYECHm fXuAcl15wpLHrFuIwheza5L0Ysu+oKFRQTvwwEBTzrfIzvrEWhAYEyuSx3rBOg== X-Google-Smtp-Source: AGHT+IED9JzC2sXkwXvICAfcj2M2MYx79ekUOZTnEjbjdsJO/jQOlSYW4QQoePphgtaojn1hn7EfZg== X-Received: by 2002:a05:622a:43:b0:447:e3da:8041 with SMTP id d75a77b69052e-447fa8adcd4mr200257401cf.4.1720914248081; Sat, 13 Jul 2024 16:44:08 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:07 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Kalesh AP , Somnath Kotur , Hongguang Gao Subject: [PATCH net-next 5/9] bnxt_en: Remove BNXT_FLAG_USING_MSIX flag Date: Sat, 13 Jul 2024 16:43:35 -0700 Message-ID: <20240713234339.70293-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Now that we only support MSIX, the BNXT_FLAG_USING_MSIX is always true. Remove it and any if conditions checking for it. Remove the INTX handler and associated logic. Reviewed-by: Kalesh AP Reviewed-by: Somnath Kotur Reviewed-by: Hongguang Gao Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 99 ++++--------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - .../net/ethernet/broadcom/bnxt/bnxt_sriov.c | 5 - 3 files changed, 17 insertions(+), 88 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7599fc3f8e27..39407b7c8958 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2854,34 +2854,6 @@ static inline int bnxt_has_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr) return TX_CMP_VALID(txcmp, raw_cons); } -static irqreturn_t bnxt_inta(int irq, void *dev_instance) -{ - struct bnxt_napi *bnapi = dev_instance; - struct bnxt *bp = bnapi->bp; - struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; - u32 cons = RING_CMP(cpr->cp_raw_cons); - u32 int_status; - - prefetch(&cpr->cp_desc_ring[CP_RING(cons)][CP_IDX(cons)]); - - if (!bnxt_has_work(bp, cpr)) { - int_status = readl(bp->bar0 + BNXT_CAG_REG_LEGACY_INT_STATUS); - /* return if erroneous interrupt */ - if (!(int_status & (0x10000 << cpr->cp_ring_struct.fw_ring_id))) - return IRQ_NONE; - } - - /* disable ring IRQ */ - BNXT_CP_DB_IRQ_DIS(cpr->cp_db.doorbell); - - /* Return here if interrupt is shared and is disabled. */ - if (unlikely(atomic_read(&bp->intr_sem) != 0)) - return IRQ_HANDLED; - - napi_schedule(&bnapi->napi); - return IRQ_HANDLED; -} - static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr, int budget) { @@ -6872,15 +6844,14 @@ static int hwrm_ring_alloc_send_msg(struct bnxt *bp, req->cq_handle = cpu_to_le64(ring->handle); req->enables |= cpu_to_le32( RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID); - } else if (bp->flags & BNXT_FLAG_USING_MSIX) { + } else { req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; } break; case HWRM_RING_ALLOC_NQ: req->ring_type = RING_ALLOC_REQ_RING_TYPE_NQ; req->length = cpu_to_le32(bp->cp_ring_mask + 1); - if (bp->flags & BNXT_FLAG_USING_MSIX) - req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; + req->int_mode = RING_ALLOC_REQ_INT_MODE_MSIX; break; default: netdev_err(bp->dev, "hwrm alloc invalid ring type %d\n", @@ -10628,20 +10599,6 @@ static void bnxt_setup_msix(struct bnxt *bp) } } -static void bnxt_setup_inta(struct bnxt *bp) -{ - const int len = sizeof(bp->irq_tbl[0].name); - - if (bp->num_tc) { - netdev_reset_tc(bp->dev); - bp->num_tc = 0; - } - - snprintf(bp->irq_tbl[0].name, len, "%s-%s-%d", bp->dev->name, "TxRx", - 0); - bp->irq_tbl[0].handler = bnxt_inta; -} - static int bnxt_init_int_mode(struct bnxt *bp); static int bnxt_setup_int_mode(struct bnxt *bp) @@ -10654,10 +10611,7 @@ static int bnxt_setup_int_mode(struct bnxt *bp) return rc ?: -ENODEV; } - if (bp->flags & BNXT_FLAG_USING_MSIX) - bnxt_setup_msix(bp); - else - bnxt_setup_inta(bp); + bnxt_setup_msix(bp); rc = bnxt_set_real_num_queues(bp); return rc; @@ -10798,7 +10752,6 @@ static int bnxt_init_int_mode(struct bnxt *bp) rc = -ENOMEM; goto msix_setup_exit; } - bp->flags |= BNXT_FLAG_USING_MSIX; kfree(msix_ent); return 0; @@ -10813,12 +10766,10 @@ static int bnxt_init_int_mode(struct bnxt *bp) static void bnxt_clear_int_mode(struct bnxt *bp) { - if (bp->flags & BNXT_FLAG_USING_MSIX) - pci_disable_msix(bp->pdev); + pci_disable_msix(bp->pdev); kfree(bp->irq_tbl); bp->irq_tbl = NULL; - bp->flags &= ~BNXT_FLAG_USING_MSIX; } int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) @@ -10916,9 +10867,6 @@ static int bnxt_request_irq(struct bnxt *bp) #ifdef CONFIG_RFS_ACCEL rmap = bp->dev->rx_cpu_rmap; #endif - if (!(bp->flags & BNXT_FLAG_USING_MSIX)) - flags = IRQF_SHARED; - for (i = 0, j = 0; i < bp->cp_nr_rings; i++) { int map_idx = bnxt_cp_num_to_irq_num(bp, i); struct bnxt_irq *irq = &bp->irq_tbl[map_idx]; @@ -10983,29 +10931,22 @@ static void bnxt_del_napi(struct bnxt *bp) static void bnxt_init_napi(struct bnxt *bp) { - int i; + int (*poll_fn)(struct napi_struct *, int) = bnxt_poll; unsigned int cp_nr_rings = bp->cp_nr_rings; struct bnxt_napi *bnapi; + int i; - if (bp->flags & BNXT_FLAG_USING_MSIX) { - int (*poll_fn)(struct napi_struct *, int) = bnxt_poll; - - if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) - poll_fn = bnxt_poll_p5; - else if (BNXT_CHIP_TYPE_NITRO_A0(bp)) - cp_nr_rings--; - for (i = 0; i < cp_nr_rings; i++) { - bnapi = bp->bnapi[i]; - netif_napi_add(bp->dev, &bnapi->napi, poll_fn); - } - if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { - bnapi = bp->bnapi[cp_nr_rings]; - netif_napi_add(bp->dev, &bnapi->napi, - bnxt_poll_nitroa0); - } - } else { - bnapi = bp->bnapi[0]; - netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll); + if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) + poll_fn = bnxt_poll_p5; + else if (BNXT_CHIP_TYPE_NITRO_A0(bp)) + cp_nr_rings--; + for (i = 0; i < cp_nr_rings; i++) { + bnapi = bp->bnapi[i]; + netif_napi_add(bp->dev, &bnapi->napi, poll_fn); + } + if (BNXT_CHIP_TYPE_NITRO_A0(bp)) { + bnapi = bp->bnapi[cp_nr_rings]; + netif_napi_add(bp->dev, &bnapi->napi, bnxt_poll_nitroa0); } } @@ -12124,12 +12065,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) rc = bnxt_reserve_rings(bp, irq_re_init); if (rc) return rc; - if ((bp->flags & BNXT_FLAG_RFS) && - !(bp->flags & BNXT_FLAG_USING_MSIX)) { - /* disable RFS if falling back to INTA */ - bp->dev->hw_features &= ~NETIF_F_NTUPLE; - bp->flags &= ~BNXT_FLAG_RFS; - } rc = bnxt_alloc_mem(bp, irq_re_init); if (rc) { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 06030244d740..10e642abacf1 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2198,7 +2198,6 @@ struct bnxt { #define BNXT_FLAG_STRIP_VLAN 0x20 #define BNXT_FLAG_AGG_RINGS (BNXT_FLAG_JUMBO | BNXT_FLAG_GRO | \ BNXT_FLAG_LRO) - #define BNXT_FLAG_USING_MSIX 0x40 #define BNXT_FLAG_RFS 0x100 #define BNXT_FLAG_SHARED_RINGS 0x200 #define BNXT_FLAG_PORT_STATS 0x400 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index 58bd84b59f0e..7bb8a5d74430 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -902,11 +902,6 @@ int bnxt_sriov_configure(struct pci_dev *pdev, int num_vfs) struct net_device *dev = pci_get_drvdata(pdev); struct bnxt *bp = netdev_priv(dev); - if (!(bp->flags & BNXT_FLAG_USING_MSIX)) { - netdev_warn(dev, "Not allow SRIOV if the irq mode is not MSIX\n"); - return 0; - } - rtnl_lock(); if (!netif_running(dev)) { netdev_warn(dev, "Reject SRIOV config request since if is down!\n"); From patchwork Sat Jul 13 23:43:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732555 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB67516C69E for ; Sat, 13 Jul 2024 23:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914252; cv=none; b=r2Ai8s1o/AMTy3SAX/8yQLWnCN6u1YAkY47ZwdA9jBGbmNrMIF6aE5bKJibhXH0YvBFZqL+Qg0J+Jr1eWTPE5ldcfCNtdqpNZN8D3xehe+2R2LG8FaCXBpzg0JHPjgjOgpk626rarIscCESrC0L8IgSnCsorDCXcgQ741ootzf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914252; c=relaxed/simple; bh=TYnk3Sj1dpQqAD8x/xP4qIeRHhQDDYTvUb3mrZCE6mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nAdwixkWD8ttF4CSxQhTz2THTwf/zmEoF66mT0IgCuZ2TBCnRhBsBUlJZucm6C1ymRZXAK2f75f7b8+zq0xtE0rTSeEkaIomm8qmnjHx0ux5FKWhJI0sS0rdRLhoj3JjvObBO1MiEb65sE5Ji716B94WMTvCnxucQJ2fj02eIBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=VZ+VBH91; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="VZ+VBH91" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7a05b7c8e38so197992685a.0 for ; Sat, 13 Jul 2024 16:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914250; x=1721519050; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=8iSO18cKwRVFZCgDza7Do32W5XQ/XJhhejeUqBJC/pw=; b=VZ+VBH91jqLizYWgfH618iLGV+mfvnRWnZmLEFoFZdSOQsSkUu2wZQ4c9EYaevuDTR dmfHq8HkKOzThJOZt0+A77sdVLmPELfs/lKDFQ7nwVYm0KTA+bkK870+SmC2PXmbBUN+ SPyvUaFtPevzBp40iW7COKuHu0yXt9Rdamzjk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914250; x=1721519050; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8iSO18cKwRVFZCgDza7Do32W5XQ/XJhhejeUqBJC/pw=; b=h1ELaPGc5MuTDcqpOCDEOwvmXW3NNBoCsdn2HhFq8WshXTnOC+eoC6suqyjx6MkWAt VFnyeXGuzlnrHv6jsCoi3Bt+KB9taPsdYB46cwawjg6sa6lQIYYBx4liHgrrRqIOMvAv Py1xfb4m0nORZJ8AsLkdeFqzrtAZHszFaep58Ata45uJ/NTBcWHY49vEiLtbOBu6K8RC 3D+lK4XRuR6wFOK+FQu7So2e+YYr8lNWf1CuA0MHtepJjXXd9ozcZiYQBebPHO1YHfS/ 5a7xDOa1KWnzMtac9D/1yDW6ntaswI2tQUPg+Xvg2xhDZd7fUZKUgDzSH7RdFooQoUv8 b3+Q== X-Gm-Message-State: AOJu0Yyne6/Eak6rh21Qlxjx3gKLRYDgPxd2XIEp9Qgsv4sz150BrmgL t8x2QsYNv7zfzTmjn0SR1WrhgETrZtWv0lKjaIDGT7mndC54izfoxPm7xVPiWA== X-Google-Smtp-Source: AGHT+IFVlpb09uzgXQbIZ0OpPcJ+hYEQ1B4Ys1MroV59yyldkItk+Ytof+Y6fsV8EBaxTFt7RLurdQ== X-Received: by 2002:ae9:f701:0:b0:79f:15ca:b786 with SMTP id af79cd13be357-79f19a51dbemr1556234085a.16.1720914249723; Sat, 13 Jul 2024 16:44:09 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:09 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Somnath Kotur , Hongguang Gao Subject: [PATCH net-next 6/9] bnxt_en: Remove register mapping to support INTX Date: Sat, 13 Jul 2024 16:43:36 -0700 Message-ID: <20240713234339.70293-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org In legacy INTX mode, a register is mapped so that the INTX handler can read it to determine if the NIC is the source of the interrupt. This and all the related macros are no longer needed. Reviewed-by: Somnath Kotur Reviewed-by: Hongguang Gao Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 19 ------------------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 -- 2 files changed, 21 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 39407b7c8958..085dffcbe6f2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -302,10 +302,6 @@ static bool bnxt_vf_pciid(enum board_idx idx) #define DB_CP_REARM_FLAGS (DB_KEY_CP | DB_IDX_VALID) #define DB_CP_FLAGS (DB_KEY_CP | DB_IDX_VALID | DB_IRQ_DIS) -#define DB_CP_IRQ_DIS_FLAGS (DB_KEY_CP | DB_IRQ_DIS) - -#define BNXT_CP_DB_IRQ_DIS(db) \ - writel(DB_CP_IRQ_DIS_FLAGS, db) #define BNXT_DB_CQ(db, idx) \ writel(DB_CP_FLAGS | DB_RING_IDX(db, idx), (db)->doorbell) @@ -11934,20 +11930,6 @@ static int bnxt_update_phy_setting(struct bnxt *bp) return rc; } -/* Common routine to pre-map certain register block to different GRC window. - * A PF has 16 4K windows and a VF has 4 4K windows. However, only 15 windows - * in PF and 3 windows in VF that can be customized to map in different - * register blocks. - */ -static void bnxt_preset_reg_win(struct bnxt *bp) -{ - if (BNXT_PF(bp)) { - /* CAG registers map to GRC window #4 */ - writel(BNXT_CAG_REG_BASE, - bp->bar0 + BNXT_GRCPF_REG_WINDOW_BASE_OUT + 12); - } -} - static int bnxt_init_dflt_ring_mode(struct bnxt *bp); static int bnxt_reinit_after_abort(struct bnxt *bp) @@ -12052,7 +12034,6 @@ static int __bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) { int rc = 0; - bnxt_preset_reg_win(bp); netif_carrier_off(bp->dev); if (irq_re_init) { /* Reserve rings now if none were reserved at driver probe. */ diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 10e642abacf1..6598c8ef9ccb 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1754,8 +1754,6 @@ struct bnxt_test_info { #define BNXT_GRCPF_REG_CHIMP_COMM 0x0 #define BNXT_GRCPF_REG_CHIMP_COMM_TRIGGER 0x100 #define BNXT_GRCPF_REG_WINDOW_BASE_OUT 0x400 -#define BNXT_CAG_REG_LEGACY_INT_STATUS 0x4014 -#define BNXT_CAG_REG_BASE 0x300000 #define BNXT_GRC_REG_STATUS_P5 0x520 From patchwork Sat Jul 13 23:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732556 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B07716D9AC for ; Sat, 13 Jul 2024 23:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914253; cv=none; b=fTWbt/yatf5ClLGE5uk+ewVyV1PJcFPmqvtRhIOg3xTjzevkiIkjE40gjZLUAAcD7I+U1uxgKBulO+iQ8SHnSONzq5AEJF+FfmBa2R0Zxw0kmBjAu9DnFQcz8TgHkQ9fhNeMmP5l/VWve/UT1LLF2Rwdw/RWfHQ05LcdaNBIe6A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914253; c=relaxed/simple; bh=P1WfGf4A+k4zp8T8UMLY+eQrWiaPQVxK9mq4A+jrKnk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QFIpmLrZ2SFFEWGe08W7CuByLkNFnd/i7/eNf/AXJ5aH66DMfoYcL0hthFTa8knmrt2hrhz3BJfooL7KvpDbz3ReUNvAmbqwSiSFjf2u+rlztiFCYpJ/uhffphOxn42J6kvm+uastHniCrW3GZaka69JvBEior9OBGyezV43ojs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Uuz+5vaA; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Uuz+5vaA" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-79f08b01ba6so270597485a.0 for ; Sat, 13 Jul 2024 16:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914251; x=1721519051; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Ub+FoEYnFCQMABszXrLYdr7VdK1IJzfQULaMgBRK7f0=; b=Uuz+5vaAtwuKPh554cqXXawEahVjevmLsfna2nBpCP60VV82kasU/ugPwdz0GqeFDM 3mdrJRYosMSfEgfU1Koel79OA6rL7z81VuAuPZVoeCTACXeut19TcCk/7UYwW6LK669L +9oOuQslTYCeRKC9xOvm0IuSyjXxc6Y1Fe/hM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914251; x=1721519051; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Ub+FoEYnFCQMABszXrLYdr7VdK1IJzfQULaMgBRK7f0=; b=E1JI/rCe2J7pfNK7pqk4wOv6ko4fbKUKUbyL17gKOvFnEo0afSZeUNcYqIdm1rsfRQ j59rI0HJ4a7WUJBWcSMyCau3CXUDiCMp+UF7YHte2cPorgncp/mXpatkSfP7fcXBt32H iZHHkHZhD9yG4YXe2r3eWlYocs17PM0lC6gakurPeKNxtqsoYHJ3eoA54UMquUVuUVaM x4I6bZoT3iPm5IwrJo0C41HL4bImCPPmsEBwIgnx1oS6/EwZzmcbORQa5oK3FkhNi5ew qq5OvZNr70NtZ8Y853Dg2Jb+Eg92d024PTEYno9vuH/NGlQ+7YBF5sr8J7VWyr6hW+rZ 6O3w== X-Gm-Message-State: AOJu0YxFPC8dCPiwrb6IHLPg0X4khO0FkttNdcmZl6hSdKpCI96DVjQc UorZHVN2wnCICE5on6SQsasZb6/DD+6WkUHo8wOkhZWN4WTAgo53+TF8RGOX/w== X-Google-Smtp-Source: AGHT+IE+FOMefFnaMQnYMWSS+alyYpSqDp1jzIW1pyzdeWrL4rwPjy5OSimvjFYOB45i03c0cZ4D/A== X-Received: by 2002:a05:620a:55b4:b0:79f:1bb:e7e6 with SMTP id af79cd13be357-7a153252629mr1027739785a.18.1720914251286; Sat, 13 Jul 2024 16:44:11 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:10 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Somnath Kotur Subject: [PATCH net-next 7/9] bnxt_en: Replace deprecated PCI MSIX APIs Date: Sat, 13 Jul 2024 16:43:37 -0700 Message-ID: <20240713234339.70293-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Use the new pci_alloc_irq_vectors() and pci_free_irq_vectors() to replace the deprecated pci_enable_msix_range() and pci_disable_msix(). Reviewed-by: Somnath Kotur Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 085dffcbe6f2..c0695a06744d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10698,7 +10698,6 @@ static int bnxt_get_num_msix(struct bnxt *bp) static int bnxt_init_int_mode(struct bnxt *bp) { int i, total_vecs, max, rc = 0, min = 1, ulp_msix, tx_cp; - struct msix_entry *msix_ent; total_vecs = bnxt_get_num_msix(bp); max = bnxt_get_max_func_irqs(bp); @@ -10708,19 +10707,11 @@ static int bnxt_init_int_mode(struct bnxt *bp) if (!total_vecs) return 0; - msix_ent = kcalloc(total_vecs, sizeof(struct msix_entry), GFP_KERNEL); - if (!msix_ent) - return -ENOMEM; - - for (i = 0; i < total_vecs; i++) { - msix_ent[i].entry = i; - msix_ent[i].vector = 0; - } - if (!(bp->flags & BNXT_FLAG_SHARED_RINGS)) min = 2; - total_vecs = pci_enable_msix_range(bp->pdev, msix_ent, min, total_vecs); + total_vecs = pci_alloc_irq_vectors(bp->pdev, min, total_vecs, + PCI_IRQ_MSIX); ulp_msix = bnxt_get_ulp_msix_num(bp); if (total_vecs < 0 || total_vecs < ulp_msix) { rc = -ENODEV; @@ -10730,7 +10721,7 @@ static int bnxt_init_int_mode(struct bnxt *bp) bp->irq_tbl = kcalloc(total_vecs, sizeof(struct bnxt_irq), GFP_KERNEL); if (bp->irq_tbl) { for (i = 0; i < total_vecs; i++) - bp->irq_tbl[i].vector = msix_ent[i].vector; + bp->irq_tbl[i].vector = pci_irq_vector(bp->pdev, i); bp->total_irqs = total_vecs; /* Trim rings based upon num of vectors allocated */ @@ -10748,21 +10739,19 @@ static int bnxt_init_int_mode(struct bnxt *bp) rc = -ENOMEM; goto msix_setup_exit; } - kfree(msix_ent); return 0; msix_setup_exit: netdev_err(bp->dev, "bnxt_init_int_mode err: %x\n", rc); kfree(bp->irq_tbl); bp->irq_tbl = NULL; - pci_disable_msix(bp->pdev); - kfree(msix_ent); + pci_free_irq_vectors(bp->pdev); return rc; } static void bnxt_clear_int_mode(struct bnxt *bp) { - pci_disable_msix(bp->pdev); + pci_free_irq_vectors(bp->pdev); kfree(bp->irq_tbl); bp->irq_tbl = NULL; From patchwork Sat Jul 13 23:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732557 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C94715E5D0 for ; Sat, 13 Jul 2024 23:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914255; cv=none; b=fQdK+vSBUJWSWoerrF+Tt7v6tG+R0vkJsIhO2IOVFHaePqNtXZe3BSk9CqOc/ppITVAENoIH0AC1AOHM08MUgvd9iOkEFbCF3KlFHoMveyF+f5L4NVWyAQPwIBCRAYdtL2XcbiKa4A5bn68chMw1G+41pTvsp5kay9D3XoTx3r8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914255; c=relaxed/simple; bh=rcBiMb5GCzfSy5v6UQvVcSh7pYaWsaCzjES9fPEr1x0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sBYRl6ESl9OUTHxNk+RoHOQMwdaGzF0IahtogDH8MWU2Ft8FFheNxV7yChe4wkpg3MX2taJgjACscr6JB/SLIlqqVJV3031DJr81daMWBBp9gIl+cN11Gg4cRjU147N20uAPyrXBIcM7y2VK2oWplx7i7TX6YJxSxDlvcLCuG7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=U6dnOHjw; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="U6dnOHjw" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-79ef8fe0e90so218713485a.3 for ; Sat, 13 Jul 2024 16:44:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914253; x=1721519053; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=ZUZL+0wphrv8rvFSV2QuTjXM/nNYD28JxEJYojq1Ooo=; b=U6dnOHjwEHbfOS01bdGLv5UI6zZ6+C27wpJr388txGlPdQWzrgo8TFLy7+kwAKAIvw K7S6estQbMzWDa1rdIboueaOYnmCotwgnh/P3mMSYwwVXSgNpz+sixuT9QA6H5AdLbfQ nsERedVk5lMTQY/O+mkVS5VSF1/8voorlDpxM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914253; x=1721519053; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZUZL+0wphrv8rvFSV2QuTjXM/nNYD28JxEJYojq1Ooo=; b=oHB3+Yd8HIbSFTmw7IjMkN1ve5GgY7yH9cGPaEILHyxFXhmVDaHjff8yEuaYfF4J/T SJf5J4ChH7n1Uao/arZMGAMEYzUvobBIlZDilFI4BHsex1q/06DSA2+iMyAdQJzVkNoU rXi4pxV/ShaJZt4MmCYDVVtdTHsGgdmb5ubPNAqatYX/BJtKvq3aRG4PJaKaA0wuyh13 iDm9Pr8/f2O8dCyHlCXuuckbwObFyzCFVDGI8pxbxI6OT87cQViZVSxDmhWwkIHiyX7c 5uxgoEM3vf21VUnXPg44CcYgsZZ2d/t76+L6/FwdkjweM1JPWpgf0SsanQiS1mZBiNT0 I23g== X-Gm-Message-State: AOJu0Yz9evKxUtXlYXko8YMdLox6C0MLIPCVW7cxD2UMpZef/kpwGPg6 2ir7htng74uc8+SIsp/0eNu0UOxYSxGqW8vTBeZ+iIjTM7ePjLGp8jyk37glAw== X-Google-Smtp-Source: AGHT+IFiot0AmrMSmvO1WKYeT0+IyMvTZ7s25aklo9QOmbpmViwIrIjjityB0a9IP4b4f0dIQho6RA== X-Received: by 2002:a05:620a:2490:b0:79e:f9f8:155f with SMTP id af79cd13be357-79f199f5024mr2214344885a.10.1720914252968; Sat, 13 Jul 2024 16:44:12 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:12 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Hongguang Gao , Somnath Kotur Subject: [PATCH net-next 8/9] bnxt_en: Allocate the max bp->irq_tbl size for dynamic msix allocation Date: Sat, 13 Jul 2024 16:43:38 -0700 Message-ID: <20240713234339.70293-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org If dynamic MSIX allocation is supported, additional MSIX can be allocated at run-time without reinitializing the existing MSIX entries. The first step to support this dynamic scheme is to alloacte a large enough bp->irq_tbl if dynamic allocation is supported. Reviewed-by: Hongguang Gao Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index c0695a06744d..7483ea246c9d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10697,7 +10697,7 @@ static int bnxt_get_num_msix(struct bnxt *bp) static int bnxt_init_int_mode(struct bnxt *bp) { - int i, total_vecs, max, rc = 0, min = 1, ulp_msix, tx_cp; + int i, total_vecs, max, rc = 0, min = 1, ulp_msix, tx_cp, tbl_size; total_vecs = bnxt_get_num_msix(bp); max = bnxt_get_max_func_irqs(bp); @@ -10718,7 +10718,10 @@ static int bnxt_init_int_mode(struct bnxt *bp) goto msix_setup_exit; } - bp->irq_tbl = kcalloc(total_vecs, sizeof(struct bnxt_irq), GFP_KERNEL); + tbl_size = total_vecs; + if (pci_msix_can_alloc_dyn(bp->pdev)) + tbl_size = max; + bp->irq_tbl = kcalloc(tbl_size, sizeof(struct bnxt_irq), GFP_KERNEL); if (bp->irq_tbl) { for (i = 0; i < total_vecs; i++) bp->irq_tbl[i].vector = pci_irq_vector(bp->pdev, i); From patchwork Sat Jul 13 23:43:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13732558 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9103016D9AC for ; Sat, 13 Jul 2024 23:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914257; cv=none; b=P9EH+3E2R6JKGUiZAIhUd8ghsX+P93Fr4NaITLKOg5YI5j2D5jTz4qdNgarqG6MZPoz4ONlm4niUG2nZXeI8KBlFvwkwuYnGvSExwlPzOgaK7fvR2DtEDEQXzTYxDItKq9LCP+9V4Rpt1w/BuIoX1GfNATZl7RbdU15W2rsNSL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720914257; c=relaxed/simple; bh=FQSlL4ckG/Uw7ciNvLyJOMsaN8n1iL+y/TfQiPByeVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uDXQHtpnF54un+UdeTNTL34kWCK0a7RpZhoC0K+BykrJ9ginJqAzh7HTtxDdfRLnUiLmxdzY6vyW0fKJ3uq+HESRxvsAs/mR9fdAfSBU9pDKLbpTBn+xOhpQTwRPrnUApHW01GHzk8d5Q0Zvof1K+tuU/JTctoUljrtcl8eyRe0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=g05XVfzp; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="g05XVfzp" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-79efd2151d9so213329485a.0 for ; Sat, 13 Jul 2024 16:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1720914254; x=1721519054; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=lsB48AihHIi6XV9k58M2cfdXObYOIPb4O8A08KshAMc=; b=g05XVfzpSDvZ5prLytBCoXobrYrHV/8Fo1jQMaHLB3mL9E/Cm8HkPbjJ9HCbFEn70L 4cf7JIr7GafdiLRdGYBnnzmbc6tMKawXP4VY2FQKnfMkgHnoeKiLLgKXQHR/nMWBcc3k 23szg18K0YTwydDUJkQJhJhXfIKk/XfqJ/nT8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720914254; x=1721519054; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lsB48AihHIi6XV9k58M2cfdXObYOIPb4O8A08KshAMc=; b=Fo+lcRDdiE09i84etFR3X+VICXUbkXcNwHL/2u/Bkr0NundCMiPcipblxEnHIsHoG4 aFz7Ha8oyly8TfJR1rKl5E6cz97Ugnawaxm11xqJ8dg+w4EuIJFK1NRbzsRIUJmeXUuy UX6XyT7uSKEPD3ppX53vwqifUG6DJQySZEfxHSxMkpv0/zUw15jLMpztbfIH58qGED+l 2SPpKh0mPsZgx9wAJWF+0HYKbKFMdcILjI0QX7bTS0VZ7ltWGNtKDg9/uPbVsWWYI4bp YegDtJ3r98yTvFM8PKmHXaF54LhgRy5sG87qCFct6Xlpdo5UvtklqdAYGrtyJPT6mbYf 9kdQ== X-Gm-Message-State: AOJu0YziSCpTOiUYobFpX5MwXtRPVgXcpbbAD4SMgp5xDLP6dbvF9pQ3 WSpBn53re6DDRo8FKyGepADw3LZEt2buR2HlPSI00hwAlPolYIr2h6QHEk/YiQ== X-Google-Smtp-Source: AGHT+IHG/GTGEXJTXCln37EKeljXZ1HWDjO2WcSk2EG8mgGrNkloLd5QyStXcUgBzKlK8j4TUJAW8A== X-Received: by 2002:a05:620a:1a0c:b0:79d:6bba:4a66 with SMTP id af79cd13be357-79f19c08427mr2279038085a.66.1720914254579; Sat, 13 Jul 2024 16:44:14 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a160bbe6f7sm78124585a.37.2024.07.13.16.44.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Jul 2024 16:44:14 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, Hongguang Gao , Somnath Kotur Subject: [PATCH net-next 9/9] bnxt_en: Support dynamic MSIX Date: Sat, 13 Jul 2024 16:43:39 -0700 Message-ID: <20240713234339.70293-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240713234339.70293-1-michael.chan@broadcom.com> References: <20240713234339.70293-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org A range of MSIX vectors are allocated at initializtion for the number needed for RocE and L2. During run-time, if the user increases or decreases the number of L2 rings, all the MSIX vectors have to be freed and a new range has to be allocated. This is not optimal and causes disruptions to RoCE traffic every time there is a change in L2 MSIX. If the system supports dynamic MSIX allocations, use dynamic allocation to add new L2 MSIX vectors or free unneeded L2 MSIX vectors. RoCE traffic is not affected using this scheme. Reviewed-by: Hongguang Gao Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 57 +++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7483ea246c9d..c987a9dd969c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10597,6 +10597,43 @@ static void bnxt_setup_msix(struct bnxt *bp) static int bnxt_init_int_mode(struct bnxt *bp); +static int bnxt_add_msix(struct bnxt *bp, int total) +{ + int i; + + if (bp->total_irqs >= total) + return total; + + for (i = bp->total_irqs; i < total; i++) { + struct msi_map map; + + map = pci_msix_alloc_irq_at(bp->pdev, i, NULL); + if (map.index < 0) + break; + bp->irq_tbl[i].vector = map.virq; + bp->total_irqs++; + } + return bp->total_irqs; +} + +static int bnxt_trim_msix(struct bnxt *bp, int total) +{ + int i; + + if (bp->total_irqs <= total) + return total; + + for (i = bp->total_irqs; i > total; i--) { + struct msi_map map; + + map.index = i - 1; + map.virq = bp->irq_tbl[i - 1].vector; + pci_msix_free_irq(bp->pdev, map); + bp->total_irqs--; + } + return bp->total_irqs; +} + static int bnxt_setup_int_mode(struct bnxt *bp) { int rc; @@ -10763,6 +10800,7 @@ static void bnxt_clear_int_mode(struct bnxt *bp) int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) { bool irq_cleared = false; + bool irq_change = false; int tcs = bp->num_tc; int irqs_required; int rc; @@ -10781,15 +10819,28 @@ int bnxt_reserve_rings(struct bnxt *bp, bool irq_re_init) } if (irq_re_init && BNXT_NEW_RM(bp) && irqs_required != bp->total_irqs) { - bnxt_ulp_irq_stop(bp); - bnxt_clear_int_mode(bp); - irq_cleared = true; + irq_change = true; + if (!pci_msix_can_alloc_dyn(bp->pdev)) { + bnxt_ulp_irq_stop(bp); + bnxt_clear_int_mode(bp); + irq_cleared = true; + } } rc = __bnxt_reserve_rings(bp); if (irq_cleared) { if (!rc) rc = bnxt_init_int_mode(bp); bnxt_ulp_irq_restart(bp, rc); + } else if (irq_change && !rc) { + int total; + + if (irqs_required > bp->total_irqs) + total = bnxt_add_msix(bp, irqs_required); + else + total = bnxt_trim_msix(bp, irqs_required); + + if (total != irqs_required) + rc = -ENOSPC; } if (rc) { netdev_err(bp->dev, "ring reservation/IRQ init failure rc: %d\n", rc);