From: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org,
Vasundhara Volam <vasundhara-v.volam@broadcom.com>,
Michael Chan <michael.chan@broadcom.com>
Subject: [PATCH net-next 04/11] bnxt_en: Refactor bnxt_hwrm_get_nvm_cfg_ver()
Date: Tue, 17 Mar 2020 20:44:41 +0530 [thread overview]
Message-ID: <1584458082-29207-5-git-send-email-vasundhara-v.volam@broadcom.com> (raw)
In-Reply-To: <1584458082-29207-1-git-send-email-vasundhara-v.volam@broadcom.com>
Refactor bnxt_hwrm_get_nvm_cfg_ver() and move hwrm specific
code to bnxt_hwrm_nvm_get_var(), to be called multiple times.
Also, rename bnxt_hwrm_get_nvm_cfg_ver() to bnxt_get_nvm_cfg_ver()
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c | 27 +++++++++++++++--------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
index 4a623ff..f08db49 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
@@ -359,25 +359,34 @@ static void bnxt_copy_from_nvm_data(union devlink_param_value *dst,
dst->vu8 = (u8)val32;
}
-static int bnxt_hwrm_get_nvm_cfg_ver(struct bnxt *bp,
- union devlink_param_value *nvm_cfg_ver)
+static int bnxt_hwrm_nvm_get_var(struct bnxt *bp, dma_addr_t data_dma_addr,
+ u16 offset, u16 num_bits)
{
struct hwrm_nvm_get_variable_input req = {0};
+
+ bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_VARIABLE, -1, -1);
+ req.dest_data_addr = cpu_to_le64(data_dma_addr);
+ req.option_num = cpu_to_le16(offset);
+ req.data_len = cpu_to_le16(num_bits);
+
+ return hwrm_send_message_silent(bp, &req, sizeof(req),
+ HWRM_CMD_TIMEOUT);
+}
+
+static int bnxt_get_nvm_cfg_ver(struct bnxt *bp,
+ union devlink_param_value *nvm_cfg_ver)
+{
union bnxt_nvm_data *data;
dma_addr_t data_dma_addr;
int rc;
- bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_NVM_GET_VARIABLE, -1, -1);
data = dma_alloc_coherent(&bp->pdev->dev, sizeof(*data),
&data_dma_addr, GFP_KERNEL);
if (!data)
return -ENOMEM;
- req.dest_data_addr = cpu_to_le64(data_dma_addr);
- req.data_len = cpu_to_le16(BNXT_NVM_CFG_VER_BITS);
- req.option_num = cpu_to_le16(NVM_OFF_NVM_CFG_VER);
-
- rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
+ rc = bnxt_hwrm_nvm_get_var(bp, data_dma_addr, NVM_OFF_NVM_CFG_VER,
+ BNXT_NVM_CFG_VER_BITS);
if (!rc)
bnxt_copy_from_nvm_data(nvm_cfg_ver, data,
BNXT_NVM_CFG_VER_BITS,
@@ -439,7 +448,7 @@ static int bnxt_dl_info_get(struct devlink *dl, struct devlink_info_req *req,
return rc;
}
- if (BNXT_PF(bp) && !bnxt_hwrm_get_nvm_cfg_ver(bp, &nvm_cfg_ver)) {
+ if (BNXT_PF(bp) && !bnxt_get_nvm_cfg_ver(bp, &nvm_cfg_ver)) {
u32 ver = nvm_cfg_ver.vu32;
sprintf(buf, "%X.%X.%X", (ver >> 16) & 0xF, (ver >> 8) & 0xF,
--
1.8.3.1
next prev parent reply other threads:[~2020-03-17 15:16 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 15:14 [PATCH net-next 00/11] bnxt_en updates to devlink cmd Vasundhara Volam
2020-03-17 15:14 ` [PATCH net-next 01/11] devlink: add macro for "drv.spec" Vasundhara Volam
2020-03-17 17:40 ` Jakub Kicinski
2020-03-17 18:33 ` Jacob Keller
2020-03-18 4:21 ` Vasundhara Volam
2020-03-18 20:04 ` Jakub Kicinski
2020-03-19 0:05 ` Jacob Keller
2020-03-19 0:47 ` Michael Chan
2020-03-19 2:14 ` Jakub Kicinski
2020-03-17 15:14 ` [PATCH net-next 02/11] bnxt_en: Add driver HWRM spec version to devlink info_get cb Vasundhara Volam
2020-03-17 15:14 ` [PATCH net-next 03/11] devlink: add macro for "hw.addr" Vasundhara Volam
2020-03-17 15:14 ` Vasundhara Volam [this message]
2020-03-17 15:14 ` [PATCH net-next 05/11] bnxt_en: Add hw addr and multihost base hw addr to devlink info_get cb Vasundhara Volam
2020-03-17 17:47 ` Jakub Kicinski
2020-03-18 4:16 ` Vasundhara Volam
2020-03-18 20:10 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1584458082-29207-5-git-send-email-vasundhara-v.volam@broadcom.com \
--to=vasundhara-v.volam@broadcom.com \
--cc=davem@davemloft.net \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox