[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230724094821.14295-8-louis.peens@corigine.com>
Date: Mon, 24 Jul 2023 11:48:16 +0200
From: Louis Peens <louis.peens@...igine.com>
To: David Miller <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>
Cc: Simon Horman <simon.horman@...igine.com>,
Yinjun Zhang <yinjun.zhang@...igine.com>,
Tianyu Yuan <tianyu.yuan@...igine.com>,
netdev@...r.kernel.org,
oss-drivers@...igine.com
Subject: [PATCH net-next 07/12] nfp: redefine PF id used to format symbols
From: Yinjun Zhang <yinjun.zhang@...igine.com>
Taking account that NFP3800 supports 4 physical functions per
controller, now recalculate PF id to be used to format symbols
to communicate with application firmware.
Signed-off-by: Yinjun Zhang <yinjun.zhang@...igine.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@...igine.com>
Acked-by: Simon Horman <simon.horman@...igine.com>
Signed-off-by: Louis Peens <louis.peens@...igine.com>
---
drivers/net/ethernet/netronome/nfp/abm/ctrl.c | 2 +-
.../net/ethernet/netronome/nfp/flower/main.c | 2 +-
drivers/net/ethernet/netronome/nfp/nfp_main.c | 18 +++++++++++-------
drivers/net/ethernet/netronome/nfp/nfp_main.h | 2 ++
.../ethernet/netronome/nfp/nfpcore/nfp_dev.c | 2 ++
.../ethernet/netronome/nfp/nfpcore/nfp_dev.h | 1 +
6 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/abm/ctrl.c b/drivers/net/ethernet/netronome/nfp/abm/ctrl.c
index 69e84ff7f2e5..41d18df97c85 100644
--- a/drivers/net/ethernet/netronome/nfp/abm/ctrl.c
+++ b/drivers/net/ethernet/netronome/nfp/abm/ctrl.c
@@ -362,7 +362,7 @@ int nfp_abm_ctrl_find_addrs(struct nfp_abm *abm)
const struct nfp_rtsym *sym;
int res;
- abm->pf_id = nfp_cppcore_pcie_unit(pf->cpp);
+ abm->pf_id = nfp_get_pf_id(pf);
/* Check if Qdisc offloads are supported */
res = nfp_pf_rtsym_read_optional(pf, NFP_RED_SUPPORT_SYM_NAME, 1);
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c
index 83eaa5ae3cd4..565987f0a595 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/main.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/main.c
@@ -378,10 +378,10 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
enum nfp_flower_cmsg_port_vnic_type vnic_type,
enum nfp_repr_type repr_type, unsigned int cnt)
{
- u8 nfp_pcie = nfp_cppcore_pcie_unit(app->pf->cpp);
struct nfp_flower_priv *priv = app->priv;
atomic_t *replies = &priv->reify_replies;
struct nfp_flower_repr_priv *repr_priv;
+ u8 nfp_pcie = nfp_get_pf_id(app->pf);
enum nfp_port_type port_type;
struct nfp_repr *nfp_repr;
struct nfp_reprs *reprs;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c
index 489113c53596..74767729e542 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c
@@ -69,6 +69,13 @@ static const struct pci_device_id nfp_pci_device_ids[] = {
};
MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids);
+u8 nfp_get_pf_id(struct nfp_pf *pf)
+{
+ return nfp_cppcore_pcie_unit(pf->cpp) *
+ pf->dev_info->pf_num_per_unit +
+ pf->multi_pf.id;
+}
+
int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
unsigned int default_val)
{
@@ -76,7 +83,7 @@ int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
int err = 0;
u64 val;
- snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp));
+ snprintf(name, sizeof(name), format, nfp_get_pf_id(pf));
val = nfp_rtsym_read_le(pf->rtbl, name, &err);
if (err) {
@@ -95,8 +102,7 @@ nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
{
char pf_symbol[256];
- snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
- nfp_cppcore_pcie_unit(pf->cpp));
+ snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt, nfp_get_pf_id(pf));
return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area);
}
@@ -803,10 +809,8 @@ static void nfp_fw_unload(struct nfp_pf *pf)
static int nfp_pf_find_rtsyms(struct nfp_pf *pf)
{
+ unsigned int pf_id = nfp_get_pf_id(pf);
char pf_symbol[256];
- unsigned int pf_id;
-
- pf_id = nfp_cppcore_pcie_unit(pf->cpp);
/* Optional per-PCI PF mailbox */
snprintf(pf_symbol, sizeof(pf_symbol), NFP_MBOX_SYM_NAME, pf_id);
@@ -832,7 +836,7 @@ static u64 nfp_net_pf_get_app_cap(struct nfp_pf *pf)
int err = 0;
u64 val;
- snprintf(name, sizeof(name), "_pf%u_net_app_cap", nfp_cppcore_pcie_unit(pf->cpp));
+ snprintf(name, sizeof(name), "_pf%u_net_app_cap", nfp_get_pf_id(pf));
val = nfp_rtsym_read_le(pf->rtbl, name, &err);
if (err) {
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h
index c58849a332b0..7f76c718fef8 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h
@@ -208,4 +208,6 @@ void nfp_devlink_params_unregister(struct nfp_pf *pf);
unsigned int nfp_net_lr2speed(unsigned int linkrate);
unsigned int nfp_net_speed2lr(unsigned int speed);
+
+u8 nfp_get_pf_id(struct nfp_pf *pf);
#endif /* NFP_MAIN_H */
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c
index 0725b51c2a95..8a7c5de0de77 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.c
@@ -19,6 +19,7 @@ const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT] = {
.pcie_cfg_expbar_offset = 0x0a00,
.pcie_expl_offset = 0xd000,
.qc_area_sz = 0x100000,
+ .pf_num_per_unit = 4,
},
[NFP_DEV_NFP3800_VF] = {
.dma_mask = DMA_BIT_MASK(48),
@@ -38,6 +39,7 @@ const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT] = {
.pcie_cfg_expbar_offset = 0x0400,
.pcie_expl_offset = 0x1000,
.qc_area_sz = 0x80000,
+ .pf_num_per_unit = 1,
},
[NFP_DEV_NFP6000_VF] = {
.dma_mask = DMA_BIT_MASK(40),
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h
index e4d38178de0f..d948c9c4a09a 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_dev.h
@@ -35,6 +35,7 @@ struct nfp_dev_info {
u32 pcie_cfg_expbar_offset;
u32 pcie_expl_offset;
u32 qc_area_sz;
+ u8 pf_num_per_unit;
};
extern const struct nfp_dev_info nfp_dev_info[NFP_DEV_CNT];
--
2.34.1
Powered by blists - more mailing lists