From patchwork Fri Aug 23 19:56:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775864 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 6A0EA192B69 for ; Fri, 23 Aug 2024 19:57:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443068; cv=none; b=mB99qDRTAWvKto4PGVDqFISsRb38ikByIztHcj/iOKQ+QWK2y2tOwsrQaD6eyHQxhtVlj+rzAcDT0eTqk4CgnS2oA04mJYgAv6IXTvxoDAQTLNPurtbesh2EzNGiATDy88MH8CVMzqrOBpYCmw77ci+FkyqdFAVTnqgeNmd9qmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443068; c=relaxed/simple; bh=OPkHgywan4pAdjeDTTRklzZigZ/niNTose8FVg24H6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PIMBbbASzkBJB9ZHJc7tuT0zvL0sNYVdZ3vtVgpGLg4QDIgIC908bNZ633lLdZKyS8Lf5U+RzR9/4U2dR6UGWvXjy4hWy1E+ZXjvN22rLCXNXA/mjvb1fYKhkdSSKoWbX5ZyOy5qCN13v0ZEzMZk8ac4lxER1frxUqHY0Sgi8MI= 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=LKdiQalc; arc=none smtp.client-ip=209.85.215.181 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="LKdiQalc" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7cf5e179b68so372992a12.1 for ; Fri, 23 Aug 2024 12:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443066; x=1725047866; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=htnpmBn0SVgwb0Npl2UPKffsYy++gKd/KngsYfEY4Po=; b=LKdiQalcc17SMAP6CCVV5MKU36V3JYKbwfFlPbT0dgQt6L6E5JEsIas1y6lN0Neuof y+djU6Ke69Wtq1u0TUTbSr2UU89bC6eaSZZraRXD5V34mGtkIBwjFrxLCQWiPtQzrZFv xt7ztTbPFEodyCcLyl1yfnBn8N3Ci0xhRTUFY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443066; x=1725047866; h=content-transfer-encoding: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=htnpmBn0SVgwb0Npl2UPKffsYy++gKd/KngsYfEY4Po=; b=L64x9Rby9oyRlglGL8w1QSV6WJino7QyIR/i/zzTc1Gxc5eCv+pTLH6U9etGjJ2JFG 9NI7lXsfYIGYYXmH9iXJemhZwRXP+SnFwMOOAcbArIifmFv1h6uDaEJg7c6OdI65orPx C4CHHCNVyfZYvctM8FpCRLVh+rW3suvW0YgJgO02UuV4BxslwnM7uRY4OFbfwKanKX1k S5YZFfzmXSRXc8hwgSguv/doq0qfHDQ41BX4Qhk/rBqqGqGosOxj3LE7WUy6Pg/++6AN Lg+lg/j0ZQd2cv/NExvdWyVd7vBNI97fIPub4KmdJTegOjfTXUnJdphWI26sZgL5QBBy 3n3g== X-Gm-Message-State: AOJu0Yy6ovEIqqjRX0ubP0+mKwZcfFFLhVuHpuVTvFtrfCv7QREyEDrb ZzNIXq6WNTENIZuzdPKNcSjX+Kq9TuEZBqSRylPmbBwxTiF5AfQLFlWNtvjC6g== X-Google-Smtp-Source: AGHT+IGApcWfGmlqWLJOzcbZvcge38GRjNVjxiBqXhylfRmkGsjtHnFEqc5P4K3MuBshZXzr5a1yyw== X-Received: by 2002:a05:6a20:d818:b0:1ca:9ca3:2e6e with SMTP id adf61e73a8af0-1cc89d6ba5emr6082185637.8.1724443065471; Fri, 23 Aug 2024 12:57:45 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:44 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Vikas Gupta , Somnath Kotur Subject: [PATCH net-next v3 1/9] bnxt_en: add support for storing crash dump into host memory Date: Fri, 23 Aug 2024 12:56:49 -0700 Message-ID: <20240823195657.31588-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 Reviewed-by: Simon Horman Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- v3: 1. Remove one-time use BNXT_SET_CRASHDUMP_PAGE_ATTR() macro 2. Optimize memory reallocation if the existing pages can support the new memory size 3. Fix suspend/resume code paths --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 92 +++++++++++++++++++ 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, 116 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b26a7e2aa132..671dc598324a 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) @@ -8946,6 +8947,80 @@ static int bnxt_alloc_ctx_mem(struct bnxt *bp) return 0; } +static int bnxt_hwrm_crash_dump_mem_cfg(struct bnxt *bp) +{ + struct hwrm_dbg_crashdump_medium_cfg_input *req; + u16 page_attr; + 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; + + if (BNXT_PAGE_SIZE == 0x2000) + page_attr = DBG_CRASHDUMP_MEDIUM_CFG_REQ_PG_SIZE_PG_8K; + else if (BNXT_PAGE_SIZE == 0x10000) + page_attr = DBG_CRASHDUMP_MEDIUM_CFG_REQ_PG_SIZE_PG_64K; + else + page_attr = DBG_CRASHDUMP_MEDIUM_CFG_REQ_PG_SIZE_PG_4K; + 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_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); + + /* keep and use the existing pages */ + if (bp->fw_crash_mem && + mem_size <= bp->fw_crash_mem->nr_pages * BNXT_PAGE_SIZE) + goto alloc_done; + + if (bp->fw_crash_mem) + bnxt_free_ctx_pg_tbls(bp, bp->fw_crash_mem); + else + 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; + } + +alloc_done: + 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; @@ -13986,6 +14061,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; @@ -15294,6 +15382,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); @@ -15933,6 +16022,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; @@ -16024,6 +16114,8 @@ static int bnxt_resume(struct device *device) rc = -ENODEV; goto resume_exit; } + if (bp->fw_crash_mem) + bnxt_hwrm_crash_dump_mem_cfg(bp); bnxt_get_wol_settings(bp); if (netif_running(dev)) { diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 610c0fe468ad..e7dcb59c3cdd 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2649,6 +2649,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 Fri Aug 23 19:56:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775865 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (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 573BF192B89 for ; Fri, 23 Aug 2024 19:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443069; cv=none; b=Cm7Jv3UbAJdHwd8rMcD2ucYmY7QYHY0CDS/CloOyejplXyGNBXDeOLlGxMX2fbOv9KsqTKe+HQ/PsAc5cifB49uRI/+cHAIDjh9VIM0FWnn9mDHL8lAbomrvJvQHmZtteuj9j+F8vG7FnEchdexOMY8I1ppLQ0OmXnwUIdqIGbs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443069; c=relaxed/simple; bh=p/Hh7YzexZ6Cek3mLObiHs1Y+/vZrPiBs7ASdZ3o0Ow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mbazl8UoGjp6XGn9XkA1t3XVi6pvxBismZlw1Snif0rUT4YFrAWqVKjTZqKDGxAK86WjCzo6szh+ZWE6Q2YbToBKO3strugXxefG93iUHDeHS0anpc+ViQProiuW4A65hZOzaOkTxw4KnxMYIs+7lS6Ajjy9rUXiP+FFkzX5Khw= 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=E+UElyha; arc=none smtp.client-ip=209.85.215.181 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="E+UElyha" Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-7c691c8f8dcso1660561a12.1 for ; Fri, 23 Aug 2024 12:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443067; x=1725047867; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GGvR6GdaT5T/PVKxJdkjtQc6O/COK+biMtyRnUMP/MY=; b=E+UElyha4gKDf5su47rP4GAUY702eWBvIvE2mlC85wQtEsgj00x9zCg8pWjRW2ekJI 1oJVYYgNBe+Jn+z148bzZf/Slsin06JDtHbH1HiTcI0+7Ynd/hgxWevshtfId9S/iJ2R R5CYqeBqDPWf0Kkn1fHNOy3Ps4oh8+AxjWlz4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443067; x=1725047867; h=content-transfer-encoding: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=GGvR6GdaT5T/PVKxJdkjtQc6O/COK+biMtyRnUMP/MY=; b=Lvno2RDwuoA4piyPM0D3Rz1MGgGIWP0nhls4w09yKDqwYauB3x7YJMSj5Mh2gP2x0x RYgyWLUCbD2RLuGS5FfrV9ZrviniBs6+yGC0wfTD08FPUnTq/1pzgDmjK2/6c+Vdhhtr uKo5HGczV1k/CCvDppj9L/1QA3DYUZfC5ygeVjuGxMu3W4V6+E7uOHXbuVzaTi5T+JGn qxO6Ez6VqwC9aiNtGBO0aE2JeV35XXgARGH4rOTDbkP3N9Ypcwu6OE1HBo2ZB789SfBn FFQtkVDQlX6s6IJjx/NR/lhZ8Sw6LQPPXC2SpBRq9C6ZdjC5vgJ42c2Htlj3aMD5wJZr x5uw== X-Gm-Message-State: AOJu0YydLyYN0P3SQt0FYWy4xzv+DLvPWvA45II9omOWGj9NisznJWNE Gg7pf99T3+ZkqAirUOXDFckTmNG6bDDrhkHknm2OKVjcbPN+J8Qt9MseCNYnhS6E+JABzBwYD08 = X-Google-Smtp-Source: AGHT+IG9l+/R9WI3vs1yRLoaXhXnL3y7IyfzXyl3dyaUHXN0pJyqLzcb37ROVGh8J6LMFcsCgwrMmw== X-Received: by 2002:a05:6a20:d497:b0:1c4:230b:5ec7 with SMTP id adf61e73a8af0-1cc89d4cbe4mr3914323637.15.1724443067250; Fri, 23 Aug 2024 12:57:47 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:46 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Vikas Gupta , Somnath Kotur Subject: [PATCH net-next v3 2/9] bnxt_en: add support for retrieving crash dump using ethtool Date: Fri, 23 Aug 2024 12:56:50 -0700 Message-ID: <20240823195657.31588-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 Reviewed-by: Simon Horman Signed-off-by: Vikas Gupta Signed-off-by: Michael Chan --- v3: 1. Use -ENOENT 2. Optimize bnxt_crash_dump_avail() --- .../ethernet/broadcom/bnxt/bnxt_coredump.c | 80 +++++++++++++++++-- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 13 ++- 2 files changed, 84 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..4e2b938ed1f7 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c @@ -372,14 +372,75 @@ 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 -ENOENT; + + 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(sig)); + return !!sig; +} + 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 +503,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 194f47316c77..7392a716f28d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4989,9 +4989,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 Fri Aug 23 19:56:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775866 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 51C3D192D70 for ; Fri, 23 Aug 2024 19:57:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443071; cv=none; b=o9mmhJMRbUnJR5KEQk7Nst+6lseiu+uCWB1vqpplZ7r5RE0GhO+AQEk+Ha/c3WdaPQ+4+kjeOYx8NHXrh6ev0sTAmZdAlwK0sNIe1TnCt90Evvy0r5cXycFRBZZhFdkqRIRS0M4lNkwEJX/g1h7rmyeEyfh+UqSHFhfFgoxk9DI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443071; c=relaxed/simple; bh=Rp1+8VlUlh/Lb16JEZft1iICqKNnRsNpqTLjxywUjGU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L/Z9GJBn+qATA5q7g5WgDmYT+MLy8SzegEskrM2PeiNS9Zhruce9+bwjWXvw37VgCIral5wbE/tHUI/e/mNuJdC5hB3LN8WZqJ3t+0XyOEY+he+6CgklRIP8He+BcB8ZtmX+WrYWCDFddCM9LUQ3dn/6jD8Td6SnY+7CB5E5xVE= 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=G2Hi1yOJ; arc=none smtp.client-ip=209.85.215.182 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="G2Hi1yOJ" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-7c6b4222fe3so1555508a12.3 for ; Fri, 23 Aug 2024 12:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443069; x=1725047869; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=epLaBEyvQjUoXaa0Uj7itTI7QXW9p1kALohHY6dbCjo=; b=G2Hi1yOJr3busp127EPrxpy1yNZwqHuq7eXTxECkj93hZ2BYpiiXPanriJm7km3EDl el/MQOM28MWq4RDtl+Ggn51Qdc/48X5fsvFqI+7n4r2ZdFqzoa0oRbkRNpmbmioNvG+F zycmBqAbinthPSwy1wKS1bOS85/tAjj2Pgxz8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443069; x=1725047869; h=content-transfer-encoding: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=epLaBEyvQjUoXaa0Uj7itTI7QXW9p1kALohHY6dbCjo=; b=I50G2veHBPQzXlirvKgvTCIkLYVaLpcEt5/J/rVfoUnydzZyM12Y7ltEqFEAmPE+s1 YKqe75RkIHOO6t88vMv/B3UV7WKIAvYNfVZiYjP2I70682nwnpDCIc7Xv72uelBgfqSe 7yEVGuyzj/jdV8XnNHBzqXUdctViPVPlrYdu/+birYN7GOgCdepS9ogQcqB9Lnd4CvQJ Bu1/RMM6Dp4HibWm297HXtTCu2aL0s9H+CM9NA4BSzLjekZ54Ju1StgItwJg453elnFY xR6TixAArkq04C5ON5uKygIIVjD1Q6uwc8pjQoseHepMFSO9/gn+jCsITcZUamaSYroP 8qzQ== X-Gm-Message-State: AOJu0YwgddRk5bf8FD/hU4iPpNrO7bNdUcAWk1hpcxF8Ul4Xlucy4yGL Unym9FWNjamaKvqqN3SlqN87k0fGBl9UsiQmI9f7rYT2AXsIlUGeP1mNpAfZ7A== X-Google-Smtp-Source: AGHT+IHtmuc2O2wKKbCmf/YnKHOupolqd5Ux6gAarLYlVu4h1TuIZmI/hyhU7x0flK6G/MxkINgquQ== X-Received: by 2002:a05:6a21:9786:b0:1ca:cd6c:2ab3 with SMTP id adf61e73a8af0-1cc89d1998bmr4516256637.10.1724443069298; Fri, 23 Aug 2024 12:57:49 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:48 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Sreekanth Reddy Subject: [PATCH net-next v3 3/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Date: Fri, 23 Aug 2024 12:56:51 -0700 Message-ID: <20240823195657.31588-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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. Reviewed-by: Simon Horman Signed-off-by: Sreekanth Reddy Signed-off-by: Michael Chan --- 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 671dc598324a..b236a76c0188 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9196,6 +9196,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 e7dcb59c3cdd..da6fad403f52 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1356,7 +1356,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 Fri Aug 23 19:56:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775867 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.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 3C0E4192B68 for ; Fri, 23 Aug 2024 19:57:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443073; cv=none; b=Nk1YgXn7T+HTXmKibKNbXVvGft/DAGK16Mu504l4oB18lZNUj1TLk7NKHUb1+g5+N1sHD+O3M4eijnq0qwd8AFD8JLIYpwUgh3vMDPgL0Fyz6AFwZ+8f5Qs7UcOBUhs6pTxWoYyHjDYWkcv/51QqMmwBcw2WzVBtW6R/kf9iShg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443073; c=relaxed/simple; bh=+Quhs+GcmcvCNJ67S9TdSosAPU6p9yKFBTy6cg3ykgc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q6YNW7EXzaGW0IwKD9B0vxRfWNZX/YpAR8gjMTvP0NX6ReI4fohJ9lGzplHX4T/M4rWSLJWz4wst/reF3G6NOhk5vGUV7BOF8cXvIc+9+Biq//dACDbAa3YBect7umNnZQrT7HNo9jbvvgQ7H9Gxe41j8F6qx6ZwOlw1TxQ5xk0= 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=PcEePCe9; arc=none smtp.client-ip=209.85.215.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="PcEePCe9" Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-6c5bcb8e8edso1769320a12.2 for ; Fri, 23 Aug 2024 12:57:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443071; x=1725047871; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ICqtqN+lT+gy/ZNlwHRQ7RE0sHXMmNuHqivUFb84cy8=; b=PcEePCe9ypWR8q1knovYEastgcvCOOea/mhM4/M8zp9xLgWO8GVN1rwJ6u51jCEcZs 7U9SEPSsMSjPg3xnLNuN17vkP9Buwpzr1iy+NNzML41E4t/7uKkZIVPpzHKQGt8jPa6d Si6F2PZ0DtOPAAGFVHP6oi4Mjl0oYg6bJOYi8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443071; x=1725047871; h=content-transfer-encoding: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=ICqtqN+lT+gy/ZNlwHRQ7RE0sHXMmNuHqivUFb84cy8=; b=Jl7X0ZHniAH2QVnQCge6vowE3g9eDRJ+8Y5a/JeMyWXGYWnC2TYU5oXNlQGUG2pvXO JhzS3Hq2lDDw4N7FYamxJiTxY36u+IXr6YN/57wM9lukE4LEGeWXZOLy9WTbU3IVzkbH iEzr1V7HCnKALHN0qxGiBhwU5QP9yyXXwp7uO2JqeJMl76HkaMZW/3UhBEVZMR60RC4h Io3nI4t/H65F6QOpoTD6WCdncEE06z59lUqj+6A4XiRcK/EYu8f0IA/i4I4xXEPyu75P qy8HhOwm3FlcrmGFp38FtoH5ZNV/sP3BKHF46Y2HzosiLE5OZMkKQxuW0+e/0ME2Huhe bgyg== X-Gm-Message-State: AOJu0Ywlk8Xmw+XIuA/2C6nFsBs9yL3P0DNNMLHHtJIwCiMKS+cQu4tG jnAB0+suDx2IWaar4emaWfwm58Gr4y+kK/8Hlld+SoMjEcx2BLX/ltwInhHcuQ== X-Google-Smtp-Source: AGHT+IEXaHNGlflwrKsX1VJzqem6DvxTx1w1uq4l99I7cppivF3E7zcEOV2wx3YO2kyzw+OIbde2tw== X-Received: by 2002:a05:6a20:c78f:b0:1c0:ede4:9a73 with SMTP id adf61e73a8af0-1cc8b4290ebmr4433231637.7.1724443071231; Fri, 23 Aug 2024 12:57:51 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:50 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Hongguang Gao , Kalesh AP , Somnath Kotur Subject: [PATCH net-next v3 4/9] bnxt_en: Deprecate support for legacy INTX mode Date: Fri, 23 Aug 2024 12:56:52 -0700 Message-ID: <20240823195657.31588-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 (since v2.27) and INTX hasn't been tested for many years before that. INTX was only used as a fallback mechansim in case MSIX wasn't available. MSIX is always supported by all firmware. If MSIX capability in PCI config space is not found during probe, abort. Reviewed-by: Hongguang Gao Reviewed-by: Kalesh AP Reviewed-by: Somnath Kotur Signed-off-by: Michael Chan --- v2: Fix memory leak, update changelog --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 43 +++++------------------ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 - 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b236a76c0188..b5a5c4911143 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10770,7 +10770,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; @@ -10828,7 +10828,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); @@ -10836,35 +10836,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) @@ -12910,7 +12881,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; @@ -15772,6 +15743,11 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (pci_is_bridge(pdev)) return -ENODEV; + if (!pdev->msix_cap) { + dev_err(&pdev->dev, "MSIX capability not found, aborting\n"); + return -ENODEV; + } + /* Clear any pending DMA transactions from crash kernel * while loading driver in capture kernel. */ @@ -15798,9 +15774,6 @@ 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; - rc = bnxt_init_board(pdev, dev); if (rc < 0) goto init_err_free; diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index da6fad403f52..9192cf26c871 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2200,7 +2200,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 Fri Aug 23 19:56:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775868 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.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 97E07192B6D for ; Fri, 23 Aug 2024 19:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443075; cv=none; b=VHt/BCAWordx7aXqAoCA1wr7lpt1y5C5IEM+Z/W6nkLAK3ulWfBU5ugWKoulMM0Lnnyimj1tVpEDH65x6yXmeorIJLjP5RhKjxi3UD417UVscPWT5JlPR+D8MjrcvaDaulpdJQDL4n4hWARnQb2siQwIuYN7WUM/U5JK7wbKtt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443075; c=relaxed/simple; bh=9HHibu9dmHUzfYWGObAYufSKDig2J9G5O1A+PVFH6Go=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iJMLv68qZISnYHSt8DDKoSfdhjJC7tG9MqD7vyJTNXWcqDLlhT+UFpEInK1LwitIf69dtqk9hVpHp6VkgsnitZk7F2gxQHG5evkgu3VXEvPFFySitgjX1FzXjDYR3kZMr4IaVpgo1DdxNuNMD+L3ZTG+bIQmZEYlfHB1hgVBKHQ= 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=binYaUHr; arc=none smtp.client-ip=209.85.210.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="binYaUHr" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7142014d8dfso2025301b3a.3 for ; Fri, 23 Aug 2024 12:57:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443073; x=1725047873; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UOR12VouuMtqBOBdTtiTEX8qrbvpXj6gt5a2tTIdmDo=; b=binYaUHrTqi9tMeM2axLKWP0gGcE2295AEBhO+iGuG1lV6ADQBLtS1AlWV5Thq6X/g TGM1MzFgq0wI3wFdcT2y4eLRMTIsfEgfHSUsvZSbob/4NTTCSzmYVo5HuAWeUjpI2/wI 0+GFTL77HQ9RKPW4n1C6wslUjgwEDSsZntMaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443073; x=1725047873; h=content-transfer-encoding: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=UOR12VouuMtqBOBdTtiTEX8qrbvpXj6gt5a2tTIdmDo=; b=DRBA5dykfpcCyOLmSSY9+aUiUsCIuD6I3VWDCJn76REqfFHUGkePHq56KgYZa4Lh9f q3AzzmT6/7JSGPIcbimez3XJ0tlTA+CjMWoCoidlFcpTnDMsTx6z7CpqP3r9PdJJjPER /lus44uuIpvLLV+h/004eFeBasreATk8WZjaSbzenYq8ok+qFutN3QZOo+FrQJ7us+D+ NW5bRQP9mL871gTkWLo1EFTZU5izHwJbAoQ4DcmX2GbduND/j7ZqKfM3rzcjxD53TE7s 35EV8WyoYDis1vvLwcQN1PIHFfpKDbsoZaz2HmE8Kx5bMkHJdnwaILPUh3YrhpTW4p+K Wocg== X-Gm-Message-State: AOJu0Yy1/V2Z+IKyDwUiUV2NPczWt8jOnPZrebjbtWp7R2ZN9T49kCdk pKmBkg5qqPpXsgD5shNuaOj97AVgaGe2fdkAP1DnxBP+wxBylRUWgwFLqwtQRg== X-Google-Smtp-Source: AGHT+IE0/A1r4mf8npni4QJ7Fc/ofu7HThntrlJ3UV0gACy3ftWBCATej0sgInZ7HkNv1UxpFQszCg== X-Received: by 2002:a05:6a00:2789:b0:704:2b6e:f10b with SMTP id d2e1a72fcca58-71445d5b19fmr3749494b3a.15.1724443072701; Fri, 23 Aug 2024 12:57:52 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:52 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Kalesh AP , Somnath Kotur , Hongguang Gao Subject: [PATCH net-next v3 5/9] bnxt_en: Remove BNXT_FLAG_USING_MSIX flag Date: Fri, 23 Aug 2024 12:56:53 -0700 Message-ID: <20240823195657.31588-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 Reviewed-by: Simon Horman Signed-off-by: Michael Chan --- 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 b5a5c4911143..67f09e22a25c 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) { @@ -6876,15 +6848,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", @@ -10653,20 +10624,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) @@ -10679,10 +10636,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; @@ -10823,7 +10777,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; @@ -10838,12 +10791,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) @@ -10941,9 +10892,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]; @@ -11008,29 +10956,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); } } @@ -12149,12 +12090,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 9192cf26c871..b1903a1617f1 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_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 Fri Aug 23 19:56:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775869 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) (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 A5C19193089 for ; Fri, 23 Aug 2024 19:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443077; cv=none; b=JhcV98TNN1FWM/w3aXmqaHhcyaaFjHtybs96nrX6//FtonhijuDlw8laBm7mFimMSJgtiOSILzNYGKxahyqBT58epNwxNQ+pnkeCv+pOoxHqm5GuXgXJUypowjkQP+d/5WVPnseP9gJYQJDAAlScF439++OHtogO49Bjo3ywJCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443077; c=relaxed/simple; bh=uVfYXnO7KEr4MbCNM2tPLz1fBzFWKDDMSgAG33nKbo4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PZlI0KV5T6KnefrnIx6tVRDIjjDhejKKykx63MU1ZC90OFV+ALvoiQwN957KSACTltX3G26JaNO9r3tpRNmYU9MsdawH3tRIHyjmQ5uPg0Bjl/yLq2RdJa5la7fj78fo/cCvcTEdHYn6Z5DIR2gXPStnQKhoGZ1jXyVF8STf0FU= 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=ZgXu1FEO; arc=none smtp.client-ip=209.85.210.179 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="ZgXu1FEO" Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-714262f1bb4so1951620b3a.3 for ; Fri, 23 Aug 2024 12:57:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443075; x=1725047875; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xSRkRd1bUOamWqoWx9cZCQwg3atj77uWWzgwowWKD7U=; b=ZgXu1FEO4yvB74x5jgsiD91eB2HPkk5XYUXpQcQk3V0D2KJW1LAlU70N5BmAi+X9H3 w9PhUCdrT3IR0j3MfjVp+QzAK9jTi2IPD09sRBXZ3nKGXn4N7nzF7IgHfDoJu4OdBsTW VYHP19yvJXR8QtRpPZwTXm6nakrmT9D++q+KI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443075; x=1725047875; h=content-transfer-encoding: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=xSRkRd1bUOamWqoWx9cZCQwg3atj77uWWzgwowWKD7U=; b=dWvox2XCToun4SplOI/w7cJQOgewTszL5MZwghyeCfST2NVTfFYG1/1D9Cj2/sUYB6 RqoQhzL5gMJO3j6mP6gwHrP0PSJjWagN+JduyJ34/pEQnthU2X56DL7F96ZHU5VYN/+R QptvJEExzInblr/g+3Tt7V/XH9Jy06N6Tl5T6u1YFwlxxgXFR3k/bJzMe/HcJq7GZehU TFUkX/20fAC6QBD+o26ArliHtC1dnIgHcX6eHojYj6gbG0aeT6ZFuJgYzxyQZj+HcB44 DjaNNTG3ez0o12CYXH0VoZ8LKnuSieBcB4vImKPE40jJbzUacHzhKO+jWRzz+JNqTcla pGuA== X-Gm-Message-State: AOJu0YxVaPFr4usxiKRAtVkvDN6Zu1kQh4w9/1cJgRwRP1oOyhBAnV0G SPfahar5J6qdaETJly3z2c+wIK7ADnT1FCFvat/B91Itk3tB8+oLUhSTcKJA6A== X-Google-Smtp-Source: AGHT+IGR1SpTAHGJNjeOJtj0a81kfpODiLz02ywZ/ZlkLVs/EdKZZeKsu692xK4yhaIEI6MJqQBC6A== X-Received: by 2002:a05:6a00:cc9:b0:714:1f68:7efa with SMTP id d2e1a72fcca58-71445d51e12mr4152215b3a.12.1724443074737; Fri, 23 Aug 2024 12:57:54 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:53 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Somnath Kotur , Hongguang Gao Subject: [PATCH net-next v3 6/9] bnxt_en: Remove register mapping to support INTX Date: Fri, 23 Aug 2024 12:56:54 -0700 Message-ID: <20240823195657.31588-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 now that INTX is no longer supported. Reviewed-by: Somnath Kotur Reviewed-by: Hongguang Gao Reviewed-by: Simon Horman Signed-off-by: Michael Chan --- v2: Update changelog --- 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 67f09e22a25c..2ecf9e324f2e 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) @@ -11959,20 +11955,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) @@ -12077,7 +12059,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 b1903a1617f1..3b805ed433ed 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1755,8 +1755,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 Fri Aug 23 19:56:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775870 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.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 2B436192B6D for ; Fri, 23 Aug 2024 19:57:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443078; cv=none; b=bCIqDfX1ak2MZiKTCV06PB+czy6k2E1tN/c3ojk4IMxVA2qq/RFy8rwxODJKYr9iwrzULepeq6GR3YJLOlp3NQEyjwQq1EPidCvEOPqpKZX/RMhwIJ51/5Og1KMVmqAE4VitdNmJJd/1xSaDRomRCUo75p9nXNsH5+yBusqmxmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443078; c=relaxed/simple; bh=zfqLIEOmlkAnG7Cb3I49mhzjQ6/j062qMSRb2OM/yp0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KMH7aNGAwjCi2cqkkouoUn3N6VP1W7pvp84yx+ozF65cdycI6/T7WOxI0WFA60Wh1jKfO4jFRBKadpQGJDFvPYHQbwpoL5TDAjgM0IuDV9TxBRfasioiCDO/D0EeJbIrVwOX1cXyGqX2Q0ZiiSylHw1TgXpUVnS255gIaf00nCw= 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=gCyW1YEP; arc=none smtp.client-ip=209.85.215.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="gCyW1YEP" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-7c6aee8e8daso1656575a12.0 for ; Fri, 23 Aug 2024 12:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443076; x=1725047876; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FEqlfxI0DH+Q1pLerFT9U0gFrolsvWqiRo0L9mCCOq8=; b=gCyW1YEPu00ChL4fh7qAgCS0MFJZqcAzA2ACHjKYHT7igpxji9r7sK7naHPOlzNEtH QYgCqEs/B8r0+/zkigwq4rOjIQR00Mj3oeJWendkOMyaHulSDNdL6by9AHGemKat5665 Bs8tgtDLoB8ej1nYr8v7YSS6tzve85YelQjaU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443076; x=1725047876; h=content-transfer-encoding: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=FEqlfxI0DH+Q1pLerFT9U0gFrolsvWqiRo0L9mCCOq8=; b=wBHS0I62ABNsZfKKCeAF2Qo/IS1FnSTTeoexGpaJNcZRQRFIZhcn5dQ1M8VZcSL8vY uW64cyvxc3n4x2D0e3+P1QjXtdeRFDzmRcuEBq831uUygB9pNB6AjXtOAxkGsuXLTntz ybOB+NJv6OUsny8Wr1MBhJzih1AKVFyIkwmms9hacJ+3mtbhAUYvysKhZTUpyepYoneI iYzSwMV2yZrT3J+SZ5o0U8/RRRufh4rcHd66FfbNzr28SUYPeNGpkhTSIFU7xfFan+Vj W8I0wPNmyTmQ4xkBlioX5ODLTmZ90IQJLFiMEOTI668/4fmFm/Csh5XZM580hjd4534U I1Cg== X-Gm-Message-State: AOJu0YzMGWu7yJo51/yMJQ1iA3doHlmHi/OdzabFKNGtrpjxUhto2AFh 9YpCWw98X9Ff/sJSxl9y3oAhJji7mtW8BK3oXrlIrAh9hodevwpHDaKO5XXohvTlPAp2pbnmDPk = X-Google-Smtp-Source: AGHT+IGD0iskTQ7O2h1rDRJvcuVNfFKN3HFvzoHLmBAJh971vL8TJnXfEif7rZhwYUPPNS9fqQGbrA== X-Received: by 2002:a05:6a21:4603:b0:1c0:e997:7081 with SMTP id adf61e73a8af0-1cc8b50ebebmr3941700637.29.1724443076183; Fri, 23 Aug 2024 12:57:56 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:55 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Somnath Kotur Subject: [PATCH net-next v3 7/9] bnxt_en: Replace deprecated PCI MSIX APIs Date: Fri, 23 Aug 2024 12:56:55 -0700 Message-ID: <20240823195657.31588-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 Reviewed-by: Simon Horman Reviewed-by: Przemek Kitszel Signed-off-by: Michael Chan --- 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 2ecf9e324f2e..03598f8e0e07 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10723,7 +10723,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); @@ -10733,19 +10732,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; @@ -10755,7 +10746,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 */ @@ -10773,21 +10764,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 Fri Aug 23 19:56:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775871 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 BE354193407 for ; Fri, 23 Aug 2024 19:57:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443080; cv=none; b=pQNLQCWRNywuoLLoK2qhjYoqe2x5YofbJZeHJxysnbF0Ro0zXnJ4+865bGT1d0s89sQpWMi+9pJ6ab/hUgeJ7JKL2paXG13vaulS6Hl2RQuQGmJIcC9qdSDeUncpvA9i/HsrGwFH62mzfGlZpLbybjzQOOgt/HfTA9Uw70BbDSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443080; c=relaxed/simple; bh=2QKsv57NUo4zAWVK7Bix5ZO6GStNOAXAteSt6+xb6MM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oLqY79fgM7mu4VpBkZV9wV59ESo92pc2+1djrIxIHnvBwWpks/OAlAUimSyZdcMsvEDz639sR6rlgEaZ8ButnoXiGrasICSPiknGp4C6vIXgMlm46Q/S2ppkP2MMvDLIG+/2toIJl6SniPDgKF/WZ+u/lVfSSuGA+yGCJV8v6gg= 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=ItaKFh1K; arc=none smtp.client-ip=209.85.210.172 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="ItaKFh1K" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71423273c62so1850573b3a.0 for ; Fri, 23 Aug 2024 12:57:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443078; x=1725047878; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HgfNrEJq6HRA04vzTkra13bJoUTfLD1DdGwFWycZ0Zk=; b=ItaKFh1KtKoGyEG+8hQO938pZrk8RtSsReD+7nC+05JJMwOfgUbPsxUEeS+yWSoz7O icJqcSBBPsOKlVhySbmKgSB2AUUXQbXqdMDUN9Ivhy0bLEdlnvSkdNBvL6ZtCfQzBkZG +SGupyUxS5jtDxf4ZJKSJA0pIytlWfxQoHpDw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443078; x=1725047878; h=content-transfer-encoding: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=HgfNrEJq6HRA04vzTkra13bJoUTfLD1DdGwFWycZ0Zk=; b=HqeEUrPZYfNvvL0q7OPNvyyWhCFjgyr8cCENJCB5ho2bUus/TnMZUMqcnY/Ttx6OL5 uDzGJ7lj5xYXvB/zRcttWqV1lEwvDLGzfy12rHRRr8RQ+p2rYxw1TP2CR7Jt7gZFHUGb +/AyFbIooXmeqJtQ1hSgXZOMoc7fXV8+ZXvaJK/NRQ1Lx4NnFW+paMCwtXTWfowhYQ/p 21oBOKGKwTOlCuW81MTU6FJXPjCRdBc4PyLDYjVUIODDDEYfyRbd8t0OUvyodUKNaZID +CvUiQIrOJRzGKKQWhByX2UEU8rPhnMHMFcGorBufmp1s7YYGZXp7rFTCnT02J7rg2Yw a4bg== X-Gm-Message-State: AOJu0YwkoAefmH5mMK5FGzbGDiRRi2id0J9RC8sy2Pyw8tlPXXpjsUz1 iZGB4e/HJxhbQ0EI9WBxif4hwz1btVYNPmoMl+BVMh0BBkmelcp+PH/d4XXCIA== X-Google-Smtp-Source: AGHT+IGvke3JHhJbdlfY6rQEDFuphVtj5WHBRXAQ55YqgOB8RF9QbKn3jplceayMKNmjMnwaQNXP4Q== X-Received: by 2002:a05:6a20:c896:b0:1c9:1605:2a3a with SMTP id adf61e73a8af0-1cc8b0e74a1mr4677254637.0.1724443078079; Fri, 23 Aug 2024 12:57:58 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57:57 -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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Hongguang Gao , Somnath Kotur Subject: [PATCH net-next v3 8/9] bnxt_en: Allocate the max bp->irq_tbl size for dynamic msix allocation Date: Fri, 23 Aug 2024 12:56:56 -0700 Message-ID: <20240823195657.31588-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 allocate a large enough bp->irq_tbl if dynamic allocation is supported. Reviewed-by: Hongguang Gao Reviewed-by: Somnath Kotur Reviewed-by: Simon Horman Reviewed-by: Przemek Kitszel Signed-off-by: Michael Chan --- v3: Use sizeof(*bp->irq_tbl) v2: Fix typo in changelog --- 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 03598f8e0e07..fa4115f6dafe 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10722,7 +10722,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); @@ -10743,7 +10743,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(*bp->irq_tbl), 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 Fri Aug 23 19:56:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13775872 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.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 23D8B193417 for ; Fri, 23 Aug 2024 19:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443081; cv=none; b=VELOgdQsLPMNTiIMHv5rrcrtiYR3owFxYNb+d16xFHvpRZHUHwb6/68fTGA/irT1MlSNItTAuQQ1mfSueY8i4Zd6LUqVG5jMbQ5xYroBLMrOln49zk0UcWBhZUgca6Z4CE08FzQ6uNSQYyeQORI+8eSJw37YpbxrxjteVojy3xI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724443081; c=relaxed/simple; bh=XDVWMEChUAV07AyjrtSlsUYEIscL77rGn9pTSzxYfEM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hdhAeTvQE45+5v6G35PtPzayVL9u4UB//9lCVOqPl3MK8gQnmMQVdRJjiKkL+xnsZ5o+/OPUcWNdbxqjsUYyeuqM9Iz+c2CRNwzTDzorrE3xKxD2BoZ/baXFoV2KVSR1DNUr8Zjm+8fFANIm+l3b8shYHijppEnJiGi3TEkP7NU= 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=gVQEhtbb; arc=none smtp.client-ip=209.85.215.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="gVQEhtbb" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-7cd895682fcso985160a12.0 for ; Fri, 23 Aug 2024 12:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724443079; x=1725047879; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=duOFN3rsXulcVtkmQeA9EW5HMUC8/DLo1WtDwbYu5/A=; b=gVQEhtbbp9nZ4znInRm88Ao5UGdq9WniJM8DS3kKbkHbM0N4qrd4VmSAJ2fqvqOPfi GDiMZp/i99n10HwTT/FdYmsXL12jy6bNPph4zCO1oHAa6G3OYlugmEefIJ/zEJn3NC9d fzkJNaUrGgAwwFUyef83VIOYdwBTZrVLXVcCM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724443079; x=1725047879; h=content-transfer-encoding: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=duOFN3rsXulcVtkmQeA9EW5HMUC8/DLo1WtDwbYu5/A=; b=XPypUjsJZug4A9fkojAvKYI8nONjS0zfxV+f0Qe+q1J424m66IuK1fikysWZcVpHEl rZUEwSKW8OMP4rkU/POFM1rC6eVMh38MLlXRFQFQY7aVI3Eo9hGJ6naiM9nYM1SgNXAa X2Bj0+V9KiVyjnh9owJtCmWjthQ4MQO2QwkMZAcdByAtT4jJgWAnpC9uFXjsRmmUaSSt XKkn+MufmKH9jCqr96p6m6wMiVCw/8uVH+HitfBnoiQ3OXr9P1Id2nFNZKlnJdHPX24B RUYj/nWtqweeRDnE3S7iUOHcZ6xt1O1MMV6KIiftHADlqgBkVEz5LJ6GJm9hs8H1qons 5qFQ== X-Gm-Message-State: AOJu0YyZC2SK31HGZ9RXtTk666ox+fviQT8TH2oHy5rnyr8LVbspFjzN XZWVXDCutmf2BDzmfyPEiVig9eMAsFZZkg6dwuM0Sn8FztduaqFgk3Tc9YgzGQ== X-Google-Smtp-Source: AGHT+IFEkTA71uEpSBaSwI14V89O0wbgYhog96C115TAPMhfBxmlgPaCwc9d50YmrBraXNO6Y1KfAA== X-Received: by 2002:a05:6a21:1584:b0:1ca:cbf5:5b0 with SMTP id adf61e73a8af0-1cc8b459221mr3650736637.21.1724443079359; Fri, 23 Aug 2024 12:57:59 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71434253dbesm3417424b3a.76.2024.08.23.12.57.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Aug 2024 12:57: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, horms@kernel.org, helgaas@kernel.org, przemyslaw.kitszel@intel.com, Hongguang Gao , Somnath Kotur Subject: [PATCH net-next v3 9/9] bnxt_en: Support dynamic MSIX Date: Fri, 23 Aug 2024 12:56:57 -0700 Message-ID: <20240823195657.31588-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240823195657.31588-1-michael.chan@broadcom.com> References: <20240823195657.31588-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 initialization 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 Reviewed-by: Simon Horman Reviewed-by: Przemek Kitszel Signed-off-by: Michael Chan --- v2: Fix typo in changelog --- 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 fa4115f6dafe..39dc67dbe9b2 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10622,6 +10622,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; @@ -10788,6 +10825,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; @@ -10806,15 +10844,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);