You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmod-redhat-bnxt_en/SOURCES/0085-netdrv-bnxt_en-Fix-the...

139 lines
5.4 KiB

From 4efc1d44bba3790e80c873c904d7ea492a95c266 Mon Sep 17 00:00:00 2001
From: Jonathan Toppins <jtoppins@redhat.com>
Date: Fri, 6 Dec 2019 20:12:41 -0500
Subject: [PATCH 85/96] [netdrv] bnxt_en: Fix the size of devlink MSIX
parameters
Message-id: <1b368014d051a2c3530a23412e08b2275d988c8c.1575651771.git.jtoppins@redhat.com>
Patchwork-id: 291380
O-Subject: [PATCH rhel8 01/13] bnxt_en: Fix the size of devlink MSIX parameters.
Bugzilla: 1773724
RH-Acked-by: Steve Best <sbest@redhat.com>
RH-Acked-by: David Arcari <darcari@redhat.com>
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
RH-Acked-by: John Linville <linville@redhat.com>
The current code that rounds up the NVRAM parameter bit size to the next
byte size for the devlink parameter is not always correct. The MSIX
devlink parameters are 4 bytes and we don't get the correct size
using this method.
Fix it by adding a new dl_num_bytes member to the bnxt_dl_nvm_param
structure which statically provides bytesize information according
to the devlink parameter type definition.
Fixes: 782a624d00fa ("bnxt_en: Add bnxt_en initial port params table and register it")
Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
(cherry picked from commit c329230ce886f449a6e559b636096b75ab00d18a)
Bugzilla: 1773724
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=25154853
Tested: simple boot test
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 28 +++++++++++------------
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h | 3 ++-
2 files changed, 16 insertions(+), 15 deletions(-)
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
===================================================================
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c 2020-02-06 16:23:21.001464585 +0100
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c 2020-02-06 16:23:21.809457168 +0100
@@ -215,15 +215,15 @@
static const struct bnxt_dl_nvm_param nvm_params[] = {
{DEVLINK_PARAM_GENERIC_ID_ENABLE_SRIOV, NVM_OFF_ENABLE_SRIOV,
- BNXT_NVM_SHARED_CFG, 1},
+ BNXT_NVM_SHARED_CFG, 1, 1},
{DEVLINK_PARAM_GENERIC_ID_IGNORE_ARI, NVM_OFF_IGNORE_ARI,
- BNXT_NVM_SHARED_CFG, 1},
+ BNXT_NVM_SHARED_CFG, 1, 1},
{DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MAX,
- NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10},
+ NVM_OFF_MSIX_VEC_PER_PF_MAX, BNXT_NVM_SHARED_CFG, 10, 4},
{DEVLINK_PARAM_GENERIC_ID_MSIX_VEC_PER_PF_MIN,
- NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7},
+ NVM_OFF_MSIX_VEC_PER_PF_MIN, BNXT_NVM_SHARED_CFG, 7, 4},
{BNXT_DEVLINK_PARAM_ID_GRE_VER_CHECK, NVM_OFF_DIS_GRE_VER_CHECK,
- BNXT_NVM_SHARED_CFG, 1},
+ BNXT_NVM_SHARED_CFG, 1, 1},
};
static int bnxt_hwrm_nvm_req(struct bnxt *bp, u32 param_id, void *msg,
@@ -232,8 +232,8 @@
struct hwrm_nvm_get_variable_input *req = msg;
void *data_addr = NULL, *buf = NULL;
struct bnxt_dl_nvm_param nvm_param;
- int bytesize, idx = 0, rc, i;
dma_addr_t data_dma_addr;
+ int idx = 0, rc, i;
/* Get/Set NVM CFG parameter is supported only on PFs */
if (BNXT_VF(bp))
@@ -254,10 +254,9 @@
else if (nvm_param.dir_type == BNXT_NVM_FUNC_CFG)
idx = bp->pf.fw_fid - BNXT_FIRST_PF_FID;
- bytesize = roundup(nvm_param.num_bits, BITS_PER_BYTE) / BITS_PER_BYTE;
- switch (bytesize) {
+ switch (nvm_param.dl_num_bytes) {
case 1:
- if (nvm_param.num_bits == 1)
+ if (nvm_param.nvm_num_bits == 1)
buf = &val->vbool;
else
buf = &val->vu8;
@@ -272,29 +271,30 @@
return -EFAULT;
}
- data_addr = dma_alloc_coherent(&bp->pdev->dev, bytesize,
+ data_addr = dma_alloc_coherent(&bp->pdev->dev, nvm_param.dl_num_bytes,
&data_dma_addr, GFP_KERNEL);
if (!data_addr)
return -ENOMEM;
req->dest_data_addr = cpu_to_le64(data_dma_addr);
- req->data_len = cpu_to_le16(nvm_param.num_bits);
+ req->data_len = cpu_to_le16(nvm_param.nvm_num_bits);
req->option_num = cpu_to_le16(nvm_param.offset);
req->index_0 = cpu_to_le16(idx);
if (idx)
req->dimensions = cpu_to_le16(1);
if (req->req_type == cpu_to_le16(HWRM_NVM_SET_VARIABLE)) {
- memcpy(data_addr, buf, bytesize);
+ memcpy(data_addr, buf, nvm_param.dl_num_bytes);
rc = hwrm_send_message(bp, msg, msg_len, HWRM_CMD_TIMEOUT);
} else {
rc = hwrm_send_message_silent(bp, msg, msg_len,
HWRM_CMD_TIMEOUT);
}
if (!rc && req->req_type == cpu_to_le16(HWRM_NVM_GET_VARIABLE))
- memcpy(buf, data_addr, bytesize);
+ memcpy(buf, data_addr, nvm_param.dl_num_bytes);
- dma_free_coherent(&bp->pdev->dev, bytesize, data_addr, data_dma_addr);
+ dma_free_coherent(&bp->pdev->dev, nvm_param.dl_num_bytes, data_addr,
+ data_dma_addr);
if (rc == -EACCES)
netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n");
return rc;
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h
===================================================================
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h 2020-02-06 16:23:20.308470946 +0100
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.h 2020-02-06 16:23:21.809457168 +0100
@@ -52,7 +52,8 @@
u16 id;
u16 offset;
u16 dir_type;
- u16 num_bits;
+ u16 nvm_num_bits;
+ u8 dl_num_bytes;
};
void bnxt_devlink_health_report(struct bnxt *bp, unsigned long event);