From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Zerun Fu <zerun.fu@corigine.com>,
Long Wu <long.wu@corigine.com>,
Peng Zhang <peng.zhang@corigine.com>,
Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 1/7] net/nfp: set a new parameter to hwinfo
Date: Mon, 11 Dec 2023 11:08:52 +0800 [thread overview]
Message-ID: <20231211030858.1693240-2-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20231211030858.1693240-1-chaoyong.he@corigine.com>
From: Zerun Fu <zerun.fu@corigine.com>
When switching speed the BSP needs to be informed whether
the firmware needs to be switched. Considering that whether
application firmware is indifferent to port speed is a
firmware property instead of port property, now use a new
rtsym to get the property. So 'sp_indiff' is written to
hwinfo to notify BSP.
Signed-off-by: Zerun Fu <zerun.fu@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
drivers/net/nfp/nfp_ethdev.c | 51 +++++++++++++++++++++++++++++++
drivers/net/nfp/nfpcore/nfp_nsp.c | 17 +++++++++++
drivers/net/nfp/nfpcore/nfp_nsp.h | 3 ++
3 files changed, 71 insertions(+)
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 336d18491e..ef0b0dcd48 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -25,6 +25,9 @@
#include "nfp_logs.h"
#include "nfp_net_flow.h"
+/* 64-bit per app capabilities */
+#define NFP_NET_APP_CAP_SP_INDIFF RTE_BIT64(0) /* Indifferent to port speed */
+
#define NFP_PF_DRIVER_NAME net_nfp_pf
static void
@@ -1227,6 +1230,46 @@ nfp_init_app_fw_nic(struct nfp_pf_dev *pf_dev,
return ret;
}
+static int
+nfp_net_hwinfo_set(uint8_t function_id,
+ struct nfp_rtsym_table *sym_tbl,
+ struct nfp_cpp *cpp)
+{
+ int ret = 0;
+ uint64_t app_cap;
+ uint8_t sp_indiff;
+ struct nfp_nsp *nsp;
+ char hw_info[RTE_ETH_NAME_MAX_LEN];
+ char app_cap_name[RTE_ETH_NAME_MAX_LEN];
+
+ /* Read the app capabilities of the firmware loaded */
+ snprintf(app_cap_name, sizeof(app_cap_name), "_pf%u_net_app_cap", function_id);
+ app_cap = nfp_rtsym_read_le(sym_tbl, app_cap_name, &ret);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Couldn't read app_fw_cap from firmware.");
+ return ret;
+ }
+
+ /* Calculate the value of sp_indiff and write to hw_info */
+ sp_indiff = app_cap & NFP_NET_APP_CAP_SP_INDIFF;
+ snprintf(hw_info, sizeof(hw_info), "sp_indiff=%u", sp_indiff);
+
+ nsp = nfp_nsp_open(cpp);
+ if (nsp == NULL) {
+ PMD_INIT_LOG(ERR, "Couldn't get NSP.");
+ return -EIO;
+ }
+
+ ret = nfp_nsp_hwinfo_set(nsp, hw_info, sizeof(hw_info));
+ nfp_nsp_close(nsp);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to set parameter to hwinfo.");
+ return ret;
+ }
+
+ return 0;
+}
+
static int
nfp_pf_init(struct rte_pci_device *pci_dev)
{
@@ -1337,6 +1380,14 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
goto sym_tbl_cleanup;
}
+ /* Write sp_indiff to hw_info */
+ ret = nfp_net_hwinfo_set(function_id, sym_tbl, cpp);
+ if (ret != 0) {
+ PMD_INIT_LOG(ERR, "Failed to set hwinfo.");
+ ret = -EIO;
+ goto sym_tbl_cleanup;
+ }
+
/* Populate the newly created PF device */
pf_dev->app_fw_id = app_fw_id;
pf_dev->cpp = cpp;
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.c b/drivers/net/nfp/nfpcore/nfp_nsp.c
index e5aaef8d55..e57176adb3 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.c
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.c
@@ -711,3 +711,20 @@ nfp_nsp_read_sensors(struct nfp_nsp *state,
return nfp_nsp_command_buf(state, &sensors);
}
+
+int
+nfp_nsp_hwinfo_set(struct nfp_nsp *state,
+ const void *buf,
+ size_t size)
+{
+ struct nfp_nsp_command_buf_arg hwinfo_set = {
+ {
+ .code = SPCODE_HWINFO_SET,
+ .option = size,
+ },
+ .in_buf = buf,
+ .in_size = size,
+ };
+
+ return nfp_nsp_command_buf(state, &hwinfo_set);
+}
diff --git a/drivers/net/nfp/nfpcore/nfp_nsp.h b/drivers/net/nfp/nfpcore/nfp_nsp.h
index 9f506a0b2e..f99ca941d5 100644
--- a/drivers/net/nfp/nfpcore/nfp_nsp.h
+++ b/drivers/net/nfp/nfpcore/nfp_nsp.h
@@ -169,6 +169,9 @@ void *nfp_nsp_config_entries(struct nfp_nsp *state);
struct nfp_cpp *nfp_nsp_cpp(struct nfp_nsp *state);
bool nfp_nsp_config_modified(struct nfp_nsp *state);
uint32_t nfp_nsp_config_idx(struct nfp_nsp *state);
+int nfp_nsp_hwinfo_set(struct nfp_nsp *state,
+ const void *buf,
+ size_t size);
static inline bool
nfp_eth_can_support_fec(struct nfp_eth_table_port *eth_port)
--
2.39.1
next prev parent reply other threads:[~2023-12-11 3:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-11 3:08 [PATCH 0/7] support link auto negotiation Chaoyong He
2023-12-11 3:08 ` Chaoyong He [this message]
2023-12-11 3:08 ` [PATCH 2/7] net/nfp: support getting speed capability Chaoyong He
2023-12-11 3:08 ` [PATCH 3/7] net/nfp: support setting port speed Chaoyong He
2023-12-11 3:08 ` [PATCH 4/7] net/nfp: modify the link update function Chaoyong He
2023-12-11 3:08 ` [PATCH 5/7] net/nfp: support getting FEC capability Chaoyong He
2023-12-11 3:08 ` [PATCH 6/7] net/nfp: support getting FEC mode Chaoyong He
2023-12-11 3:08 ` [PATCH 7/7] net/nfp: support setting " Chaoyong He
2023-12-12 15:28 ` [PATCH 0/7] support link auto negotiation Ferruh Yigit
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=20231211030858.1693240-2-chaoyong.he@corigine.com \
--to=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=long.wu@corigine.com \
--cc=oss-drivers@corigine.com \
--cc=peng.zhang@corigine.com \
--cc=zerun.fu@corigine.com \
/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;
as well as URLs for NNTP newsgroup(s).