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.
405 lines
11 KiB
405 lines
11 KiB
5 years ago
|
From ba2d2e2bd59c1dcd20c30fa6f05a847dc613b85d Mon Sep 17 00:00:00 2001
|
||
|
From: Jonathan Toppins <jtoppins@redhat.com>
|
||
|
Date: Wed, 2 Oct 2019 18:23:15 -0400
|
||
|
Subject: [PATCH 60/96] [netdrv] bnxt_en: Convert error code in firmware
|
||
|
message response to standard code
|
||
|
|
||
|
Message-id: <6fad2b5f944f9ec2522f438afff3f55d8099ac99.1570027456.git.jtoppins@redhat.com>
|
||
|
Patchwork-id: 276478
|
||
|
O-Subject: [RHEL-8.2 PATCH 53/78] bnxt_en: Convert error code in firmware message response to standard code.
|
||
|
Bugzilla: 1724766
|
||
|
RH-Acked-by: John Linville <linville@redhat.com>
|
||
|
RH-Acked-by: Jarod Wilson <jarod@redhat.com>
|
||
|
|
||
|
The main firmware messaging function returns the firmware defined error
|
||
|
code and many callers have to convert to standard error code for proper
|
||
|
propagation to userspace. Convert bnxt_hwrm_do_send_msg() to return
|
||
|
standard error code so we can do away with all the special error code
|
||
|
handling by the many callers.
|
||
|
|
||
|
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
|
||
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||
|
(cherry picked from commit d4f1420d365633490aa134abfe408453d1c7c238)
|
||
|
Bugzilla: 1724766
|
||
|
Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=23809532
|
||
|
Tested: build, boot, basic ping
|
||
|
Signed-off-by: Jonathan Toppins <jtoppins@redhat.com>
|
||
|
Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
|
||
|
---
|
||
|
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 60 ++++++++++++++---------
|
||
|
drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c | 4 --
|
||
|
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 8 +--
|
||
|
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 20 ++------
|
||
|
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 12 ++---
|
||
|
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 17 -------
|
||
|
6 files changed, 44 insertions(+), 77 deletions(-)
|
||
|
|
||
|
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt.c
|
||
|
===================================================================
|
||
|
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt.c 2020-02-06 16:23:18.179490489 +0100
|
||
|
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt.c 2020-02-06 16:23:18.306489323 +0100
|
||
|
@@ -4053,6 +4053,32 @@
|
||
|
req->resp_addr = cpu_to_le64(bp->hwrm_cmd_resp_dma_addr);
|
||
|
}
|
||
|
|
||
|
+static int bnxt_hwrm_to_stderr(u32 hwrm_err)
|
||
|
+{
|
||
|
+ switch (hwrm_err) {
|
||
|
+ case HWRM_ERR_CODE_SUCCESS:
|
||
|
+ return 0;
|
||
|
+ case HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED:
|
||
|
+ return -EACCES;
|
||
|
+ case HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR:
|
||
|
+ return -ENOSPC;
|
||
|
+ case HWRM_ERR_CODE_INVALID_PARAMS:
|
||
|
+ case HWRM_ERR_CODE_INVALID_FLAGS:
|
||
|
+ case HWRM_ERR_CODE_INVALID_ENABLES:
|
||
|
+ case HWRM_ERR_CODE_UNSUPPORTED_TLV:
|
||
|
+ case HWRM_ERR_CODE_UNSUPPORTED_OPTION_ERR:
|
||
|
+ return -EINVAL;
|
||
|
+ case HWRM_ERR_CODE_NO_BUFFER:
|
||
|
+ return -ENOMEM;
|
||
|
+ case HWRM_ERR_CODE_HOT_RESET_PROGRESS:
|
||
|
+ return -EAGAIN;
|
||
|
+ case HWRM_ERR_CODE_CMD_NOT_SUPPORTED:
|
||
|
+ return -EOPNOTSUPP;
|
||
|
+ default:
|
||
|
+ return -EIO;
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
|
||
|
int timeout, bool silent)
|
||
|
{
|
||
|
@@ -4227,7 +4253,7 @@
|
||
|
netdev_err(bp->dev, "hwrm req_type 0x%x seq id 0x%x error 0x%x\n",
|
||
|
le16_to_cpu(resp->req_type),
|
||
|
le16_to_cpu(resp->seq_id), rc);
|
||
|
- return rc;
|
||
|
+ return bnxt_hwrm_to_stderr(rc);
|
||
|
}
|
||
|
|
||
|
int _hwrm_send_message(struct bnxt *bp, void *msg, u32 msg_len, int timeout)
|
||
|
@@ -4340,10 +4366,8 @@
|
||
|
|
||
|
mutex_lock(&bp->hwrm_cmd_lock);
|
||
|
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
- else if (resp->flags &
|
||
|
- cpu_to_le32(FUNC_DRV_RGTR_RESP_FLAGS_IF_CHANGE_SUPPORTED))
|
||
|
+ if (!rc && (resp->flags &
|
||
|
+ cpu_to_le32(FUNC_DRV_RGTR_RESP_FLAGS_IF_CHANGE_SUPPORTED)))
|
||
|
bp->fw_cap |= BNXT_FW_CAP_IF_CHANGE;
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
return rc;
|
||
|
@@ -4766,7 +4790,7 @@
|
||
|
}
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
if (rc)
|
||
|
- return -EIO;
|
||
|
+ return rc;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
@@ -5526,7 +5550,7 @@
|
||
|
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
if (rc) {
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
- return -EIO;
|
||
|
+ return rc;
|
||
|
}
|
||
|
|
||
|
hw_resc->resv_tx_rings = le16_to_cpu(resp->alloc_tx_rings);
|
||
|
@@ -5690,7 +5714,7 @@
|
||
|
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
if (rc)
|
||
|
- return -ENOMEM;
|
||
|
+ return rc;
|
||
|
|
||
|
if (bp->hwrm_spec_code < 0x10601)
|
||
|
bp->hw_resc.resv_tx_rings = tx_rings;
|
||
|
@@ -5715,7 +5739,7 @@
|
||
|
cp_rings, stats, vnics);
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
if (rc)
|
||
|
- return -ENOMEM;
|
||
|
+ return rc;
|
||
|
|
||
|
rc = bnxt_hwrm_get_rings(bp);
|
||
|
return rc;
|
||
|
@@ -5896,9 +5920,7 @@
|
||
|
|
||
|
req.flags = cpu_to_le32(flags);
|
||
|
rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- return -ENOMEM;
|
||
|
- return 0;
|
||
|
+ return rc;
|
||
|
}
|
||
|
|
||
|
static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings,
|
||
|
@@ -5926,9 +5948,7 @@
|
||
|
|
||
|
req.flags = cpu_to_le32(flags);
|
||
|
rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- return -ENOMEM;
|
||
|
- return 0;
|
||
|
+ return rc;
|
||
|
}
|
||
|
|
||
|
static int bnxt_hwrm_check_rings(struct bnxt *bp, int tx_rings, int rx_rings,
|
||
|
@@ -6488,8 +6508,6 @@
|
||
|
}
|
||
|
req.flags = cpu_to_le32(flags);
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -6751,10 +6769,8 @@
|
||
|
mutex_lock(&bp->hwrm_cmd_lock);
|
||
|
rc = _hwrm_send_message_silent(bp, &req, sizeof(req),
|
||
|
HWRM_CMD_TIMEOUT);
|
||
|
- if (rc) {
|
||
|
- rc = -EIO;
|
||
|
+ if (rc)
|
||
|
goto hwrm_func_resc_qcaps_exit;
|
||
|
- }
|
||
|
|
||
|
hw_resc->max_tx_sch_inputs = le16_to_cpu(resp->max_tx_scheduler_inputs);
|
||
|
if (!all)
|
||
|
@@ -7262,8 +7278,6 @@
|
||
|
else
|
||
|
return -EINVAL;
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -7283,8 +7297,6 @@
|
||
|
req.options = FUNC_CFG_REQ_OPTIONS_CACHE_LINESIZE_SIZE_128;
|
||
|
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c
|
||
|
===================================================================
|
||
|
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c 2020-02-06 16:23:12.277544664 +0100
|
||
|
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_dcb.c 2020-02-06 16:23:18.306489323 +0100
|
||
|
@@ -377,8 +377,6 @@
|
||
|
set.data_len = cpu_to_le16(sizeof(*data) + sizeof(*fw_app) * n);
|
||
|
set.hdr_cnt = 1;
|
||
|
rc = hwrm_send_message(bp, &set, sizeof(set), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
|
||
|
set_app_exit:
|
||
|
dma_free_coherent(&bp->pdev->dev, data_len, data, mapping);
|
||
|
@@ -433,8 +431,6 @@
|
||
|
dscp2pri->pri = app->priority;
|
||
|
req.entry_cnt = cpu_to_le16(1);
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
dma_free_coherent(&bp->pdev->dev, sizeof(*dscp2pri), dscp2pri,
|
||
|
mapping);
|
||
|
return rc;
|
||
|
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:15.606514107 +0100
|
||
|
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c 2020-02-06 16:23:18.306489323 +0100
|
||
|
@@ -109,13 +109,9 @@
|
||
|
memcpy(buf, data_addr, bytesize);
|
||
|
|
||
|
dma_free_coherent(&bp->pdev->dev, bytesize, data_addr, data_dma_addr);
|
||
|
- if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
|
||
|
+ if (rc == -EACCES)
|
||
|
netdev_err(bp->dev, "PF does not have admin privileges to modify NVM config\n");
|
||
|
- return -EACCES;
|
||
|
- } else if (rc) {
|
||
|
- return -EIO;
|
||
|
- }
|
||
|
- return 0;
|
||
|
+ return rc;
|
||
|
}
|
||
|
|
||
|
static int bnxt_dl_nvm_param_get(struct devlink *dl, u32 id,
|
||
|
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
|
||
|
===================================================================
|
||
|
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c 2020-02-06 16:23:18.049491682 +0100
|
||
|
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c 2020-02-06 16:23:18.307489314 +0100
|
||
|
@@ -1743,12 +1743,8 @@
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), FLASH_NVRAM_TIMEOUT);
|
||
|
dma_free_coherent(&bp->pdev->dev, data_len, kmem, dma_handle);
|
||
|
|
||
|
- if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
|
||
|
+ if (rc == -EACCES)
|
||
|
bnxt_print_admin_err(bp);
|
||
|
- rc = -EACCES;
|
||
|
- } else if (rc) {
|
||
|
- rc = -EIO;
|
||
|
- }
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -1798,12 +1794,8 @@
|
||
|
}
|
||
|
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
|
||
|
+ if (rc == -EACCES)
|
||
|
bnxt_print_admin_err(bp);
|
||
|
- rc = -EACCES;
|
||
|
- } else if (rc) {
|
||
|
- rc = -EIO;
|
||
|
- }
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -2098,12 +2090,8 @@
|
||
|
flash_pkg_exit:
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
err_exit:
|
||
|
- if (hwrm_err == HWRM_ERR_CODE_RESOURCE_ACCESS_DENIED) {
|
||
|
+ if (hwrm_err == -EACCES)
|
||
|
bnxt_print_admin_err(bp);
|
||
|
- rc = -EACCES;
|
||
|
- } else if (hwrm_err) {
|
||
|
- rc = -EOPNOTSUPP;
|
||
|
- }
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -2642,8 +2630,6 @@
|
||
|
led_cfg->led_group_id = bp->leds[i].led_group_id;
|
||
|
}
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
|
||
|
===================================================================
|
||
|
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 2020-02-06 16:22:54.758705473 +0100
|
||
|
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 2020-02-06 16:23:18.307489314 +0100
|
||
|
@@ -133,7 +133,7 @@
|
||
|
rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
if (rc) {
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
- return -EIO;
|
||
|
+ return rc;
|
||
|
}
|
||
|
vf->func_qcfg_flags = le16_to_cpu(resp->flags);
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
@@ -164,9 +164,7 @@
|
||
|
else
|
||
|
req.flags = cpu_to_le32(FUNC_CFG_REQ_FLAGS_TRUSTED_VF_DISABLE);
|
||
|
rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
|
||
|
- if (rc)
|
||
|
- return -EIO;
|
||
|
- return 0;
|
||
|
+ return rc;
|
||
|
}
|
||
|
|
||
|
int bnxt_set_vf_trust(struct net_device *dev, int vf_id, bool trusted)
|
||
|
@@ -564,10 +562,8 @@
|
||
|
req.vf_id = cpu_to_le16(pf->first_vf_id + i);
|
||
|
rc = _hwrm_send_message(bp, &req, sizeof(req),
|
||
|
HWRM_CMD_TIMEOUT);
|
||
|
- if (rc) {
|
||
|
- rc = -ENOMEM;
|
||
|
+ if (rc)
|
||
|
break;
|
||
|
- }
|
||
|
pf->active_vfs = i + 1;
|
||
|
pf->vf[i].fw_fid = pf->first_vf_id + i;
|
||
|
}
|
||
|
@@ -664,8 +660,6 @@
|
||
|
total_vf_tx_rings += vf_tx_rsvd;
|
||
|
}
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
- if (rc)
|
||
|
- rc = -ENOMEM;
|
||
|
if (pf->active_vfs) {
|
||
|
hw_resc->max_tx_rings -= total_vf_tx_rings;
|
||
|
hw_resc->max_rx_rings -= vf_rx_rings * num_vfs;
|
||
|
Index: src/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
|
||
|
===================================================================
|
||
|
--- src.orig/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c 2020-02-06 16:23:15.476515300 +0100
|
||
|
+++ src/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c 2020-02-06 16:23:18.307489314 +0100
|
||
|
@@ -319,8 +319,6 @@
|
||
|
if (rc)
|
||
|
netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc);
|
||
|
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -515,11 +513,6 @@
|
||
|
}
|
||
|
}
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
-
|
||
|
- if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR)
|
||
|
- rc = -ENOSPC;
|
||
|
- else if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -591,8 +584,6 @@
|
||
|
}
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -609,8 +600,6 @@
|
||
|
if (rc)
|
||
|
netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc);
|
||
|
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -660,8 +649,6 @@
|
||
|
}
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -678,8 +665,6 @@
|
||
|
if (rc)
|
||
|
netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc);
|
||
|
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|
||
|
@@ -1457,8 +1442,6 @@
|
||
|
}
|
||
|
mutex_unlock(&bp->hwrm_cmd_lock);
|
||
|
|
||
|
- if (rc)
|
||
|
- rc = -EIO;
|
||
|
return rc;
|
||
|
}
|
||
|
|