[1/7] net/nfp: set a new parameter to hwinfo
Checks
Commit Message
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(+)
@@ -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;
@@ -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);
+}
@@ -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)