From patchwork Fri Aug 16 21:28:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766817 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 7F6611C4635 for ; Fri, 16 Aug 2024 21:29:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843751; cv=none; b=A2PczprzZsHw1xFPsN+2h8M/fBvQi54wgJtR9J3cqsygHL8e7D84fewYE5prB7KSHYXTwUpArfkZDuzd6hd74nuueM4XNQxgpqpVkhSPcGPp0GHyVIcwuyG6DXB+9F5bj2uCGfqinmLHhOmEnEs6F7qnEP1hi8N0dibLQf33skU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843751; c=relaxed/simple; bh=dMyOTtbGeU08rlqhMaCTEY1xQhvMAnu0t7IGw0HYFh8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U2l5Nu1aOt7MRgcLtrGln2Nko9kWefqnZMY1AELHYFoocmqoXciHRWfSvZ1vn79GeL2B2inCRsxy6Are465vnvg44L+CgSS1HxHjrpYZkGt0pgV5SnSSGGkLelefh2mxlKbjvnUbvCGH1JIbUR64c8RpIw4N4RrnxuO6Zlyl4V0= 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=g43KNSq3; arc=none smtp.client-ip=209.85.160.176 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="g43KNSq3" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-44ff6f3c427so13080751cf.1 for ; Fri, 16 Aug 2024 14:29:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843748; x=1724448548; 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=MhllNDGEPMByP4+mAbI5CDmYoRy/YZP9+zxlvzqePgE=; b=g43KNSq3guP51YXgKfKiyfHD0gb+fPibjyUjDa6Zh5bkb0ddKafLXXTIpDHuuV0m7N Bqt9XhVL/wZNleNXvUBUXAUXF+zVSnkYeyXMej7mWbVDUoEf2S1Fv+qmCu8yObIsoyuJ rm58tgZDvZN+74hgVcpurGkv1veiuMf9FLxOk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843748; x=1724448548; 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=MhllNDGEPMByP4+mAbI5CDmYoRy/YZP9+zxlvzqePgE=; b=I/lpC1dIlhQgfJgK2rG8lCpI9RawDvDjFsHQbYvzhrj77M/Lpr4TaCZW4KIgqKNKLL UbTiJEHmrBHLKOhCyq9A4eSetIszFut5wNNLvjRDwGQF4WClfFdc6HhN9psjHxYJfs3q ZAaTMt5//MFbWIrmgTOZZ/wSA1wvsQk9e5Il0kF34mm3vaZMTddSO5HZHD4I6dplrS9i OdewjDs4ebUvwKg+UBFw9Zi1NSQVyNDfBUFK57ywHKnjhwfXX5a6pqZ4SsNLXZeAHkO6 jbDftp87gnOmvXaG/7Hfq9OWmIR/9COsNgvPK8o7gzgMduSxh5lKH5cZf9vIZYHQ5uI2 7pMA== X-Gm-Message-State: AOJu0YweXaktkLXiFmuE5az9nynfBwXG37egVRa5zuLTmaly6q41Yo95 FspQPi5LZF8vkXGcFa9WE/Kp/kiOjsuF1LYykG3FS+wJbMafcEoJVrjWTF4JnA== X-Google-Smtp-Source: AGHT+IEpJoYbuNb3M3gujHGgsqumo1mP7HFtRE7nILIB23hHm7or8G7TA9C2nUtuHEX5Y1V5ZLsYyg== X-Received: by 2002:a05:622a:4015:b0:447:eb4e:7cc1 with SMTP id d75a77b69052e-453743a9f52mr47445181cf.44.1723843748249; Fri, 16 Aug 2024 14:29:08 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29: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, horms@kernel.org, helgaas@kernel.org, Vikas Gupta , Somnath Kotur Subject: [PATCH net-next v2 1/9] bnxt_en: add support for storing crash dump into host memory Date: Fri, 16 Aug 2024 14:28:24 -0700 Message-ID: <20240816212832.185379-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 --- 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 75e2cfed5769..017eefd78ba4 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,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; @@ -13986,6 +14063,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 +15384,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 +16024,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; @@ -15986,6 +16078,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 62e637c5be31..2fa6572b6b1d 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 16 21:28:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766818 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (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 46E681C57A2 for ; Fri, 16 Aug 2024 21:29:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843752; cv=none; b=TkgZp3CXZF6sEumAg6wIisN72vUp1utHr2PBIM4fnuX+SKp0E9D8DuTAbLZsPgjS891V5oVODHs/JJKxJ75dmZdMaxz+O5WOcV+6jaodCcK1MiVZgZkP1+D7S5WeU8jPByEXq/Vu6P0cdQpThwEWXksqK48vInJ8sUCz3543FuY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843752; c=relaxed/simple; bh=1nOV9NJhiAnXZXQKEFut1HoiD2NU3klj7LgbNmzIVog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nGctRfEVYot2u7MX9moeTefBXug/0VKZHsaMxuTgn7rZdHXFQOdUujdns8OId6V/fcwt8BbOMD+aoXK1UVrxZCGJwCEhG0eLLHZMMwGJAUMk/v2vk94xbxRbBk7X1Vtw1xNKs1+ghoZ2OlRTtphPEl4TnTDtGK6FUZe7QsLiQxM= 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=A5RVxM6g; arc=none smtp.client-ip=209.85.160.176 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="A5RVxM6g" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-45007373217so30872721cf.0 for ; Fri, 16 Aug 2024 14:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843750; x=1724448550; 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=NjME3nwxz9HWeGOa1mL9WO34Qnb+mfms6zKQSzQjD+8=; b=A5RVxM6gvUD8x9XcfLHlxU8xaktEeEu+hXWVcwwhVELi7hQWeIfHKzTOZk+5IhIy4I hLNzfLwGQEvRwVOEugMrrtSIxK+hCZUMCwWp2IZ3HMkzjfuZ2RJ2kdX7kM8W+wxO0Eo4 pNAyHRLKfHRPWog391qhmTfwLj7fGZjs6u3bw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843750; x=1724448550; 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=NjME3nwxz9HWeGOa1mL9WO34Qnb+mfms6zKQSzQjD+8=; b=LD4CjcuDOciEEjQC0T03mrzSc/zZCdxBvLhTffMjqE4WbljdAbpw+PaOSZYt9ukKrX qZaSO+qp1bJ7THPN4kqwR39kBTCWq4VUUFdoIQv/FFLMkF0GXQ1NyIVKVq2sbkOYPj6Z rffYELD0RwVhxG5AF1TqSePuq3iPjBZ1F4UOXChyXLNZyomETxPR1X3JV3nbXXXw93/l kfhrs+l3BuLi1sn4blSEZjHmXRkGfYkjcj+pcy3+eonS1Ap6Mh2eq6/E7gxOtfMCMA42 Qdl8CFlDxlzFZW1uYJYrYJPrU+MMl3mcsn3BHyJp3OMpkdj/LgZxZ5ycXU1/dTGMYdcY BxGQ== X-Gm-Message-State: AOJu0YwtMuAewqvsnUiYm5z8oTYgsI91z2uiYRmOWB82nwmLXsBL3Ahr 8bMM4uwNC4wASI/ntKBAxAhgmMvlGwjBj0uzMG9eYQGh76DR0XBMPVnVff620g== X-Google-Smtp-Source: AGHT+IGX4bWVhzhMxG90cNUb9KVlMZFP3xao8QguU6N8FMwSTkzepszpWV1KthkbNF8wOY04dYu78g== X-Received: by 2002:a05:622a:260d:b0:451:8b27:381c with SMTP id d75a77b69052e-453751dff4emr81956431cf.14.1723843749958; Fri, 16 Aug 2024 14:29:09 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29: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, horms@kernel.org, helgaas@kernel.org, Vikas Gupta , Somnath Kotur Subject: [PATCH net-next v2 2/9] bnxt_en: add support for retrieving crash dump using ethtool Date: Fri, 16 Aug 2024 14:28:25 -0700 Message-ID: <20240816212832.185379-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 --- .../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 39eed5831e3a..265956c45ff5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -4993,9 +4993,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 16 21:28:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766820 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (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 DA6F41C4635 for ; Fri, 16 Aug 2024 21:29:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843757; cv=none; b=VhXHnzXBPoQ0MsA+l5wS9V0GgU+gx+SwVXaflXl9LvrdbS4ltaP/gZEdEsZqz/EQ1h7SaDoHg3lH/dvzlGnLbFaUWEb4oBXLkK/2uQcockYrecWC235QvGxZ5EOhWl4P+DJtZ3dbsGZwA5J7BlOHbn74HE8zsTnsOc09fGW2P48= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843757; c=relaxed/simple; bh=7JU+C2nHXIPqBUyDit0UAkvIFFzzRONrcFntu+mQWZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rSpz1zNx3mInRB8+jhmKBGfgrFTrTrnoDC9p9Weph5onNq8BIQJM45GnyWlOUeIl4qQg1bZuDZKcc/f+baPes3IggARjoDEyl9bEUtsAzDCBqCYDRNN809QgbrbH0/hDLOS/ezCbn9AxkycZwpVLwJFdMYwkwbVDIw5+sqZrKtA= 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=AJkTP7yp; arc=none smtp.client-ip=209.85.210.43 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="AJkTP7yp" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7093abb12edso1741934a34.3 for ; Fri, 16 Aug 2024 14:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843752; x=1724448552; 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=aK2V/GEhL2UJaDYEeRsE1/r/nEBhY5fhK5WxIZZVrqw=; b=AJkTP7ypSpgQiZHqjaYX1HUP4S5Bf3F2cF5WSJCVoYRZ9cPz0UWSiNKR+F5kUg8zpL 2dxXV5+x5YX3PEGvAUnOFJVzV5L2a4gomhj0b/wFVZ418zOgOFywVqiWXDi8Lti3hnRw zM4V26tiSx8MIEI/YtYoM4BtomCN65YfJvV9M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843752; x=1724448552; 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=aK2V/GEhL2UJaDYEeRsE1/r/nEBhY5fhK5WxIZZVrqw=; b=HIRH9L0SfEZWouTpNEBQKkqZmeDBwWgvtLbOueUf8CYp0kdaULQJf2gn+RtKAp+ygA zZM3BGAqJzDGxXjJSSg5cxI/c9WGtdgWgt4667+X+YZd5tD8ik17kwbxTR4CuQNw6tpI Fn6jjRDIhAcQdrnSWBiRA3FFQA1M0tNoJrT9mhjRoQCTiD2gp+elkM1FaJLinHmDQuZR gDi9udOus9nIv8usc/pY2++Ctpx1EQx03402kz33FsB9Cgvgu83w3T8hs7VzEhk1hx9f 2/AfsEsEXWL0WO4BYo4MZnnRyoXiWyscLIsw8mOuPxTwJ14eKgNxxsBA86M5273cxbfi utMg== X-Gm-Message-State: AOJu0YxoN2j9+y/5ymNrf6X/SZv/3vb3cH3nqvVRrDJXfnDWYdb1zbtM MN5Jx/RgpnMvMxu3u5eh0jjFOjMYtX1OK+427ElwC/jA2NRWx1tTVukQPmf4Gw== X-Google-Smtp-Source: AGHT+IGrS233rAo/tjkWxvzAX09WSwojWRuvfdZlWeaeSoXIZYU84KFGOnc3WhbZBTgaL1arvQNc2g== X-Received: by 2002:a05:6830:6e85:b0:703:5ccb:85f3 with SMTP id 46e09a7af769-70cac8b1dadmr4461170a34.22.1723843751630; Fri, 16 Aug 2024 14:29:11 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:11 -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, Sreekanth Reddy Subject: [PATCH net-next v2 3/9] bnxt_en: Support QOS and TPID settings for the SRIOV VLAN Date: Fri, 16 Aug 2024 14:28:26 -0700 Message-ID: <20240816212832.185379-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 017eefd78ba4..149ec5bda477 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -9198,6 +9198,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 2fa6572b6b1d..aa2eb78a8763 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 16 21:28:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766819 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.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 976CD1C6890 for ; Fri, 16 Aug 2024 21:29:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843756; cv=none; b=FPawE4+EvYT8EnmCU22hjFIaqiwYDtkGWRTndERn8tGPMIbccbGvMiox4dFjHXaVnCJn4iPoSdEthcM5YR2Aw5WZ03RK1YJT1zLKYMdj4PMHH1to6umqgFH3RH7KrlB3DjRbubBbrCHIxAEqc+Y00GR/CNEZo2YCBeCMrbMUvEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843756; c=relaxed/simple; bh=ohL978brj/DCtaYUBlWZQq16OJiewoBDDZZhHwjho8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CsssfsFI16BWtMfs/BfHV23f9hVAwd0/jd1i23bx43ot8Cj93MrezamdnOWz4XeJX1RIP+++AhtWdh5U8XHp20GJJONvSuiv1/24gxDwPePBB7Afw2IQ5qactaBe2vkRfZUM1GpkcsDodVmIhbvfbODaFvbTTO11hj7ui/iuF0Y= 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=T4rbMkTt; arc=none smtp.client-ip=209.85.160.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="T4rbMkTt" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-44ff6dd158cso14397331cf.3 for ; Fri, 16 Aug 2024 14:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843753; x=1724448553; 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=U3IQACyrz1sqR74RBooMlydhPg+qkxHpMk7ZN7MUVrw=; b=T4rbMkTteaBmQUWHWbhXRZJziX7g3ELxGeV2bVQqi+99bu0viflUO9AePzpXHDCQZJ fZ/cAVNKLNIsWrW44iJPZcPrtE0ShxP1yV90caW504ZZksDyTNfSFe4XBSHmCCN4zvMA 5F6cqBmE5GhYtgrz2u8NPjVcc2GSRFs77b534= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843753; x=1724448553; 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=U3IQACyrz1sqR74RBooMlydhPg+qkxHpMk7ZN7MUVrw=; b=tVemIcxewwesuBqFegqRiwf+lBjz18J9tTPNqvNbgQsxQtBwqjxJHh9FhzmeYB69qU QD7lvPvxegzdTHFElhX1BFyeJkgiyQsuhM2OCiwulYUB3QwGoA9gYK4ZRxemyRbocVWZ 0mGItU+b9nqrbFiVlk49r9mYv1ZjuBqXOVG+rxtRofCXkzomXCzvnokN9KdZDIZJ7Age OILTDNPS2Xz9oQWRQiHF+hOpY+Rm21uhOfbdd9IiKrU0ZPOwjO068KuS6BzBhMY+PxLZ Cz4UZOCOflwJWi5/N1oniklzF1DaN/shQ79SCgrzpDieKXB0u+9N0qOWrFmKrZGiKW/D ll9A== X-Gm-Message-State: AOJu0Yy5E+jf7ft/a4WviBKtzqn3gYdJG9wTSVl40mE/LqoUvb9tC2No f1jFHEQVXsg3cm+7Oe42atgt3RJAItvA4WipatMi65/3CxtuBloVvTXqTJKMwg== X-Google-Smtp-Source: AGHT+IF9HSIx13GInV19bzuxEaMQZSTrS0N1/evid9ltxtngDiJEl0Vqubhu6OzLCXwhHmcCGe5Aeg== X-Received: by 2002:a05:622a:2485:b0:447:eb33:410d with SMTP id d75a77b69052e-45374233d66mr60015981cf.18.1723843753535; Fri, 16 Aug 2024 14:29:13 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:13 -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, Hongguang Gao , Kalesh AP , Somnath Kotur Subject: [PATCH net-next v2 4/9] bnxt_en: Deprecate support for legacy INTX mode Date: Fri, 16 Aug 2024 14:28:27 -0700 Message-ID: <20240816212832.185379-5-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 Reviewed-by: Simon Horman --- 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 149ec5bda477..54d82e54456c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10772,7 +10772,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; @@ -10830,7 +10830,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); @@ -10838,35 +10838,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) @@ -12912,7 +12883,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; @@ -15774,6 +15745,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. */ @@ -15800,9 +15776,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 aa2eb78a8763..e2e2986a976b 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 16 21:28:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766821 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 B913D1C68A0 for ; Fri, 16 Aug 2024 21:29:16 +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=1723843758; cv=none; b=YedlsW+MsQc7N/zW7f1qSTkgSmwa6LmGNpC6M6qMCn0MHx+JF4Y7VkCsN2/d0KhUXD9ViOgoXrMITtjJq/zpaeByxx1rKin5j9DGRvbKsoWz0Yaki1zivL1l2TcyDJ/lEQ78ua6ESrXzqLVVKNE6JjAlklmJgshH8ry6tjpqabA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843758; c=relaxed/simple; bh=ye3Q+8yIGczFY9PKKUyOx5b+6M+C7UqJA4gbSHS44Yo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eqcbt7CYMsus7tmpmNJyfkm5rMMm0UhIMKarDET4xIdXiJt0I/iPnoSZu3gPDrNxeQwlZFmlEfRnX/vV1Wc2VUZq12gRy7KFGf6YXinHqB4jhSa9+6J9sLgFndQ8RyDJen2jQjCksz2cviqBYy4+2ZoalMtQod8K8SyONaYrNT8= 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=Xf4Hw7AE; 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="Xf4Hw7AE" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7a1e0ff6871so160620985a.2 for ; Fri, 16 Aug 2024 14:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843756; x=1724448556; 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=+9pCI+VyqhnD5xznIBfY84/Za6K9cJpKNKj6kGlQKX8=; b=Xf4Hw7AEcn2L3cMoN4j4ntF2R0TOyFWJB1o3EMPiRvosSPhgxIXMXDwA9hMeZcQ8uo pL+s8wT8SynWxHDBvDIU9qp+AAljSuexy/AUaqE84r9y8ZgYsVjLR/oKJ2Bq7JeyEiRP Bzncf8vrag4oJC1XVMz5RutgLpaK18cJNpbSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843756; x=1724448556; 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=+9pCI+VyqhnD5xznIBfY84/Za6K9cJpKNKj6kGlQKX8=; b=WypIQI1ME9MPM74va8KxTeKZw19cHwPN+rj0c7UKniLP/EDZlPETP44ILUhe5lVYY1 qXamFmkQv8gSd/uIyMd4dCUMRCGySeatKateCtCDBw/Yvxembk2g2RO0CYh/oyLdDOTc gyGE4ty56rNsbf5kOO8UnF8SGjgIpU3VKeEHf6foszNjio0mnEGllqABc1UcsfjkQnv3 2CPLNhPr7EzX2/WMCUxAEjn/b+JcBQwv5uH3iVsIUBnRxG4wg9YXc+l2XV3pEk7qP4DQ yc3GgqhgmrnhFg1pjHWy3TfyXsmHmSjFn4HEc5IT4+9BtdQdw0fbBZf6fXvEeZnVQxB1 CMaw== X-Gm-Message-State: AOJu0YxstqBmSeHtqLsFm612tS1w5M5h8doFacEuSw6QExHYxwgfOan6 BYOJAyWZZZxjFm+lWcbJ9yUW569cP6A78viKpdrpxKp/KxKRCMNOqVMZ6bn7mQ== X-Google-Smtp-Source: AGHT+IGXRfG5onPKMuogKDaa11oY+NeFqErAmPME/RizIDzdH9QtxoFKhJ0OHXL61Y/F/HL3+8N1eQ== X-Received: by 2002:a05:622a:2596:b0:447:d4ce:dd26 with SMTP id d75a77b69052e-454b68f2734mr11291371cf.56.1723843755451; Fri, 16 Aug 2024 14:29:15 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:15 -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, Kalesh AP , Somnath Kotur , Hongguang Gao Subject: [PATCH net-next v2 5/9] bnxt_en: Remove BNXT_FLAG_USING_MSIX flag Date: Fri, 16 Aug 2024 14:28:28 -0700 Message-ID: <20240816212832.185379-6-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 54d82e54456c..8d3970ccdc21 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", @@ -10655,20 +10626,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) @@ -10681,10 +10638,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; @@ -10825,7 +10779,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; @@ -10840,12 +10793,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) @@ -10943,9 +10894,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]; @@ -11010,29 +10958,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); } } @@ -12151,12 +12092,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 e2e2986a976b..043d2a849674 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 16 21:28:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766822 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 164BA1C579D for ; Fri, 16 Aug 2024 21:29:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843759; cv=none; b=RexfYVoQheVuDv9JG0sVCcAf74XIWDgo9sNmZg18+5uS6W65zKJHDCZLx7QNluXIg7UQfDVHQQU8NPWMEoLwhYqYQ10bAC7rw0zvpJ1l6PpUE/8S4XcB0h4TcvK/rAVdMAj3nZN/cseJegSa3RugyvrHTCOcn2o4Qt9EXbYFzNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843759; c=relaxed/simple; bh=j2HHGXx8bK0TLDRdB0zXS7YCJQG7jxrT8hGHyc9lkPE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mq72zfiVArWZmv+fbqwdZT/sp5M6bb1VHOxHoR/qC5D1+XyyBdEnISIOXXSzizfdkifrnW4iTMBUFvWj8ROOP/bHAWqZz8EwFRKPEDHxckQbBSEjzWIZbSHGMaAXbHroXkqxCSqeA6ub17ensb3UcDCRQgS8PG3PtHkCaM8doug= 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=Cb07auRt; arc=none smtp.client-ip=209.85.210.50 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="Cb07auRt" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-70936061d0dso1712788a34.2 for ; Fri, 16 Aug 2024 14:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843757; x=1724448557; 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=2Sj5uy6qcsV6EfwMJkgO154ju0jKDy7oK4R0LZFICE0=; b=Cb07auRtPysKd7km4uHutGmpS4AkI0fKRsXpTjdYxECrWHo5mwexRflozQEjQvoFQC vhRKFLG8v81fiPlzrSJ9vJTPmyYDygYjvkhk2Fs5asd0DNH4yU/dnowBsSt8tW73V80o aASODzaI7nuFsbqTQzIDkeN0cGOc6ozXjXZyQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843757; x=1724448557; 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=2Sj5uy6qcsV6EfwMJkgO154ju0jKDy7oK4R0LZFICE0=; b=nSef6wPHydINuDvzsKpLzTwi4h7gFX3hq872zbtdcH4I5hFtyFNhsXEqCwdp/7ENtr a3JDcGq35gIbXKrvtub0O8dMpuh8BubypGjEMaff0+gyft8QEhBvC7gw12GnB/JMDCxw 8c/eCZn4mBznixwMammdfvI0u9QhwTd/RYTwH38gela+f93UkpeI59iFQNPPOZ6ynoAC NHIFihS/Lt0EP0aE503PHbhrDU2doN27ZLGeIpYocHjt2Uiz4Su6iZVSnvFrp/dke+N7 WFen/K/PIXzKs5Z4O4RdpYgaKGquaKDcogMlvRnTspaf80Jxms4UiSsWjxPHX5jBMpHt 3viQ== X-Gm-Message-State: AOJu0YwfHwAkagGUNVb4Tru0gy973Ovixv3MKh4WvJ/B7eLllyeJWIgG odTIGjYbz9Iv0Beuv5K0MIsT3a6fHv7xmeZ2nJ8QTp//iGuWzMBO+gS9fRTukA== X-Google-Smtp-Source: AGHT+IEMzfw76iTpeQERoCTMBrjlqNnJp1lHFqp0P1cDTxk7F/oyld9+8SJKxP1nQnYN3+eYg1CLcA== X-Received: by 2002:a05:6830:3708:b0:703:6341:5171 with SMTP id 46e09a7af769-70cac8567a2mr5018866a34.15.1723843757150; Fri, 16 Aug 2024 14:29:17 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:16 -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, Somnath Kotur , Hongguang Gao Subject: [PATCH net-next v2 6/9] bnxt_en: Remove register mapping to support INTX Date: Fri, 16 Aug 2024 14:28:29 -0700 Message-ID: <20240816212832.185379-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 8d3970ccdc21..0666bf0e5dc6 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) @@ -11961,20 +11957,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) @@ -12079,7 +12061,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 043d2a849674..93e00215819a 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 16 21:28:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13766823 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (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 114141C7B7C for ; Fri, 16 Aug 2024 21:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843761; cv=none; b=bOYS0JsmSTnVTXzndXJQv5uGhGjDeXbepTVuKK8mirmyHbvIUmu8rEVFpumHhUbyuPTwDEi63JMphmpRokgNcB8+EEnVtxIHC5n5Di7zpY9xAJnMtTrwHYZLsh1D2DB/u3D4UYQ4ZFvxdFJVXkfQafViFHbgI4lcgvfQuG49Cmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843761; c=relaxed/simple; bh=CTrxxlKCLKeylesgUbLA47h8BxyyPcpt1EaDEvS9EfI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q6D07Rn4kKaBO6cJ3AGq/RQhMryBGA3f971T8RF3/t12++R93L7WKl3gUuho8jrjNqXzSs1l6d09vZF8hZyq387gSmkl8xTX5buwkLa/Z97Yn8/S2XfK2Mqi21pseVfsKS+P8RLUCXlf2Hp9gz+7JIOGjftT5zk0y5i0rJmr5us= 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=FQYnxA0K; arc=none smtp.client-ip=209.85.167.176 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="FQYnxA0K" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3db145c8010so1521523b6e.3 for ; Fri, 16 Aug 2024 14:29:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843759; x=1724448559; 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=/XmNeikEmcv/JzzuTRyvb8CpnWK2tXjyoAycIU0hhoI=; b=FQYnxA0KeKbSzSmgesStYpg5B3ciISA0KuaVMKBWxNSIfRyn5ERqFImtJMKeoev5Rb SKY9tHf2m+jOERU3kMSeElDOnmtHdxVjvvYOhWNNWQzfMmiiW5Ueg3dejMrrcwcjiWAA BJ/zveVIPyRyu/zAm0nQ8e/owLu+lBw0oHSDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843759; x=1724448559; 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=/XmNeikEmcv/JzzuTRyvb8CpnWK2tXjyoAycIU0hhoI=; b=tBNrOgZeRdX3arTvIls4vNvTLeWlMiOZ0vLcnidWJBOc3YdB2SjfSlMIRM8epA1Rfm 8qySJaTbQYcnYZjGWbsS4ONkgJXQpUEABy3CBCpl1NAotYkmwiLtWCoJj7Iz3M1siiJC itCNf3T8H9lLvkhNwrSYjW94QtcNBQ4eTX99BH96w5KDAR8jkUJiENMxhdLKP8e+wS2X Uqgi7V3AzxjJM0UrgRrb6dUbe6immxzcU7CgZnlpTgTxCG3T0yr5+HjFzHpPfKsOVyxw T9Y/ZiX5qi0hehlUMPqekjnWdgtAWmiXDCS6jfgOF/CmY9QI61Rg7/e1EjjAOi1MBHw6 Lgyg== X-Gm-Message-State: AOJu0YxAwVaJZW/gFZp2x/NkwIyKvNOCGB4Li7CqkyBa9oJ9a+qcpwwn AiOfNDqgrs90zqkKwx6IVXU9itiyy+qUOnCNiVmqyGcArdWokHB6oMC1L/d6Fw== X-Google-Smtp-Source: AGHT+IG38lT/LXiFdsVwHJpG5/FakB8yxScuipvBsshalF6t2ceYUtKRlaHcgJirlHyU/V9Bg8Vo2w== X-Received: by 2002:a05:6808:ecf:b0:3d9:ad9d:622f with SMTP id 5614622812f47-3dd3ad4f38dmr3895587b6e.27.1723843758957; Fri, 16 Aug 2024 14:29:18 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:18 -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, Somnath Kotur Subject: [PATCH net-next v2 7/9] bnxt_en: Replace deprecated PCI MSIX APIs Date: Fri, 16 Aug 2024 14:28:30 -0700 Message-ID: <20240816212832.185379-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 Signed-off-by: Michael Chan Reviewed-by: Przemek Kitszel --- 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 0666bf0e5dc6..5d0d40d78c37 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10725,7 +10725,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); @@ -10735,19 +10734,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; @@ -10757,7 +10748,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 */ @@ -10775,21 +10766,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 16 21:28: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: 13766824 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.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 BE54B7F460 for ; Fri, 16 Aug 2024 21:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843763; cv=none; b=WWhN4MmdygRCd8uiAAC+ChxPJBbrvFTtakGVZ5iMzKhUJ4jM4EaH9jGjP/4JDYV53U3nNgLGTq2jTQjv7jfKnkzCXcfN1RHSaA1OAeGCsfpchc9mFzMYtNbQT7Tr2YYpdBnuX7jUVMzKR6hxhNBOs5OEpQMnlMxcO2VE88wu+6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843763; c=relaxed/simple; bh=hH9Y7/JeY6R4A6e0y6SlIed+6faiNm05g2RQpE+1Vts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LRk/EmIHDe65MFLf5TH5xKEE+BwgxclCzuMaWgUm+3O05i0ePscRddN8+lwwvRKfRsKJDyT0qntjbUuC2Ex67QgpGXWHVBVDVdza6Vc4fQSinnPh8NtRGwr0AufDyhAVIVOvj7bumN7Q6bhOspSvclHGgd8gYUFXS0NRgsTWbdc= 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=H3etuSNU; arc=none smtp.client-ip=209.85.160.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="H3etuSNU" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-451a0b04f6bso15198041cf.2 for ; Fri, 16 Aug 2024 14:29:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843760; x=1724448560; 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=RpdcMYzLhy1ANz15Ap65NGpAKNJ0pXRsyTGjNNNtlQM=; b=H3etuSNUtyLH04VtdlWSPG4FPO2k4rXOXoAHo6ciTJa3oLfJWopnnnZWNxEmhfAEhE uAYO3rLYZ2pze7osCHIN3pVVMFML+AF7BJOSOq6QJ008Fge6L3CQbh2C5Is9qOBGLtPQ ypHT3Hp6aQiHjWYp64CCK1wDvGUJXAdnVcifQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843760; x=1724448560; 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=RpdcMYzLhy1ANz15Ap65NGpAKNJ0pXRsyTGjNNNtlQM=; b=E3xaoTkBExIhyINWStsNdorB7riNDUUs2yUSLY98j+PYoAfXVF6FgyazdEgKvjoQWZ 0zdaiOcSOHlFgcmWfNKcgPHvr4Crc3+X2e5pjUP95IupNDNTIyFfWPGhKWp76G72VPYw QkvedpdjqzbFrA6DYQUi4zUNxbeeWMDnEGimJper1xYJEegWmdrvRVZ3qGVm/dM1N6VJ szuHDOHZ6JL+XkWkXFjfslpipwcm3ZO23mSSZ8EH0VuFVhjMylUEaNob/Kh2+BeOIjfJ HJGxHWiFKaJrEPQQnJwrIp3hsBWv5/AM2Y5R4Efdd+7d97rObSKZMy9AWfWmDn08uDzt R5Fg== X-Gm-Message-State: AOJu0YzQiKnVw8mZ0sROO7wDhP/OA4fdXKo2B/IuP/Eq3rYm4ws7NU3J DRhcobnsZsb42MCiUIIhA25t0IqUo8Bc1KaLvEjY50om3woK/rW8RHPdEZP/Kg== X-Google-Smtp-Source: AGHT+IFBwVhdUgX1a4V9IkrHPJbXc4eUMoGOUChnuw8uN0gNsB5+cEfWE7LrqbCZh4VflZE0Y9a0wA== X-Received: by 2002:a05:622a:a13:b0:44f:ea67:1012 with SMTP id d75a77b69052e-45374207271mr54412991cf.13.1723843760676; Fri, 16 Aug 2024 14:29:20 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.19 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:20 -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, Hongguang Gao , Somnath Kotur Subject: [PATCH net-next v2 8/9] bnxt_en: Allocate the max bp->irq_tbl size for dynamic msix allocation Date: Fri, 16 Aug 2024 14:28:31 -0700 Message-ID: <20240816212832.185379-9-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 Signed-off-by: Michael Chan Reviewed-by: Przemek Kitszel --- 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 5d0d40d78c37..b969ace6b4d1 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10724,7 +10724,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); @@ -10745,7 +10745,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 Fri Aug 16 21:28: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: 13766825 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 CA6B11C7B89 for ; Fri, 16 Aug 2024 21:29:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843765; cv=none; b=EKSrDsbZRgRKJHbiYFcl2QvUr3L3NHhzBhC4bwRmo4SLxCyUAdBno8QmZgN0jHHbocZQxtW9E9x7cKIaJwuNclqJnV3PkNoaZvfiZkrKdFLpOEYJjpr0TSSlj4xRL9GPo4Cj4bvu9gX181sGf3Nd+KDDI+mSUBpvFCzT5bWLMkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723843765; c=relaxed/simple; bh=ugfagNAGfpNF1G/OPRly4OeWcOsgg0mnSoDCqpLhQZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=plK5df71mi7OuKiOXwArv1Ip/yY5W2kYZORc/O9EydHTaAFjB28rv+PN4TAj0+6Bdsa4yppd1w7FlEoCpZrtoZ6RWCKajcxZZgHCStYuxExw4UQTBEdXAeH5jnLnDnvSXwB+kKjMpjGS3s5ND3LUdLKbys9zHLrBshwbCIgOIbI= 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=Y+tNqgoG; arc=none smtp.client-ip=209.85.167.170 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="Y+tNqgoG" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3db19caec60so1565202b6e.1 for ; Fri, 16 Aug 2024 14:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1723843763; x=1724448563; 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=n4wzEYtouvzxVOFaYuVyAO9v0SPQDvtZHLZuX95GPPY=; b=Y+tNqgoGlsvevztoo1BHJ8/MEOOmTwQB4NKMuf5qQXgFjsoLqv742U1BG9KCIUxAvh fB+MNwtFvVa+gNobVAKzADsBW1uGnX86SmsYQdmuHiI++UuV7A9nNBVpCQmfbTfH1Ycr JMCia60ONjmk3b4P8lw/axWw9ayyxVrqJL9N0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723843763; x=1724448563; 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=n4wzEYtouvzxVOFaYuVyAO9v0SPQDvtZHLZuX95GPPY=; b=GqsEaUfuvoUhRq2eY2JeGTForbVn9Y1YRvLnyAPzF9bKNB3lAvkAPNCaWDg0muPyAY Mh3vQdSShyS1R5TWABCy2VZiIMS+CtJ7FJgeeS7+XUOk4W55ycfq6Fn2f9Glix2bgEtM 2AQ62Br7qrHolZdhbMnPDQgV9FE8qNgMrL0HMQMoB1dO4AHLJHEx2/14ZSW+psWUgHDx HogfMga0pdSt7FJQfm59SN/pE+ky/ELZtEZYTBtZj8lT0a8SPwT3ouWEnjLgK0Dxb4/7 6ZY8zQWgYpctsGieZucDcXr6kTD3USePsvRDgH2EnHTxWTTYuLGQqjROsH1Ed7WIR7Ht JDVA== X-Gm-Message-State: AOJu0YxPM1imrgLsizs5A0lH8nyylxWg9G6M35pUB53KWvFa48C3RDaK ywa/g4uohBcFUhz5Xr0iqKbBwkiBxv6cbNp94orX6zXZDUXeMuVKWtof4tS79g== X-Google-Smtp-Source: AGHT+IGaYuz1JDUOUaAAKoamxNcM5LuSyyNGRajAugWNOiAvLeygMqEbN3lJ9t2Kb3MjjK33KL/wKQ== X-Received: by 2002:a05:6808:170c:b0:3d9:28d0:fcdb with SMTP id 5614622812f47-3dd3ad330a2mr5378104b6e.12.1723843762899; Fri, 16 Aug 2024 14:29:22 -0700 (PDT) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-45369fd72aasm20752221cf.9.2024.08.16.14.29.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2024 14:29:22 -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, Hongguang Gao , Somnath Kotur Subject: [PATCH net-next v2 9/9] bnxt_en: Support dynamic MSIX Date: Fri, 16 Aug 2024 14:28:32 -0700 Message-ID: <20240816212832.185379-10-michael.chan@broadcom.com> X-Mailer: git-send-email 2.43.4 In-Reply-To: <20240816212832.185379-1-michael.chan@broadcom.com> References: <20240816212832.185379-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 Signed-off-by: Michael Chan Reviewed-by: Przemek Kitszel --- 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 b969ace6b4d1..d702fc1d9ed5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -10624,6 +10624,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; @@ -10790,6 +10827,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; @@ -10808,15 +10846,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);