[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230816143912.34540-10-louis.peens@corigine.com>
Date: Wed, 16 Aug 2023 16:39:08 +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 v2 09/13] nfp: apply one port per PF for multi-PF setup
From: Tianyu Yuan <tianyu.yuan@...igine.com>
Only one port per PF is allowed in multi-PF setup. While eth_table
still carries the total port info, each PF need bind itself with
correct port according to PF id.
Signed-off-by: Tianyu Yuan <tianyu.yuan@...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/main.c | 2 +-
drivers/net/ethernet/netronome/nfp/bpf/main.c | 2 +-
.../net/ethernet/netronome/nfp/flower/main.c | 17 ++++++++++-------
drivers/net/ethernet/netronome/nfp/nfp_main.h | 6 ++++++
.../net/ethernet/netronome/nfp/nfp_net_main.c | 11 ++++++++---
drivers/net/ethernet/netronome/nfp/nfp_port.c | 4 +++-
drivers/net/ethernet/netronome/nfp/nic/main.c | 3 ++-
7 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c
index 5d3df28c648f..d4acaa15629d 100644
--- a/drivers/net/ethernet/netronome/nfp/abm/main.c
+++ b/drivers/net/ethernet/netronome/nfp/abm/main.c
@@ -451,7 +451,7 @@ static int nfp_abm_init(struct nfp_app *app)
nfp_err(pf->cpp, "ABM NIC requires ETH table\n");
return -EINVAL;
}
- if (pf->max_data_vnics != pf->eth_tbl->count) {
+ if (pf->max_data_vnics != pf->eth_tbl->count && !pf->multi_pf.en) {
nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n",
pf->max_data_vnics, pf->eth_tbl->count);
return -EINVAL;
diff --git a/drivers/net/ethernet/netronome/nfp/bpf/main.c b/drivers/net/ethernet/netronome/nfp/bpf/main.c
index f469950c7265..3d928dfba114 100644
--- a/drivers/net/ethernet/netronome/nfp/bpf/main.c
+++ b/drivers/net/ethernet/netronome/nfp/bpf/main.c
@@ -70,7 +70,7 @@ nfp_bpf_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
nfp_err(pf->cpp, "No ETH table\n");
return -EINVAL;
}
- if (pf->max_data_vnics != pf->eth_tbl->count) {
+ if (pf->max_data_vnics != pf->eth_tbl->count && !pf->multi_pf.en) {
nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n",
pf->max_data_vnics, pf->eth_tbl->count);
return -EINVAL;
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c
index 565987f0a595..2e79b6d981de 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/main.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/main.c
@@ -428,10 +428,10 @@ nfp_flower_spawn_vnic_reprs(struct nfp_app *app,
goto err_reprs_clean;
}
if (repr_type == NFP_REPR_TYPE_PF) {
- port->pf_id = i;
+ port->pf_id = nfp_net_get_id(app->pf, i);
port->vnic = priv->nn->dp.ctrl_bar;
} else {
- port->pf_id = 0;
+ port->pf_id = nfp_net_get_id(app->pf, 0);
port->vf_id = i;
port->vnic =
app->pf->vf_cfg_mem + i * NFP_NET_CFG_BAR_SZ;
@@ -496,28 +496,31 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
struct nfp_eth_table *eth_tbl = app->pf->eth_tbl;
atomic_t *replies = &priv->reify_replies;
struct nfp_flower_repr_priv *repr_priv;
+ int err, reify_cnt, phy_reprs_num;
struct nfp_repr *nfp_repr;
struct sk_buff *ctrl_skb;
struct nfp_reprs *reprs;
- int err, reify_cnt;
unsigned int i;
ctrl_skb = nfp_flower_cmsg_mac_repr_start(app, eth_tbl->count);
if (!ctrl_skb)
return -ENOMEM;
+ phy_reprs_num = app->pf->multi_pf.en ? app->pf->max_data_vnics : eth_tbl->count;
reprs = nfp_reprs_alloc(eth_tbl->max_index + 1);
if (!reprs) {
err = -ENOMEM;
goto err_free_ctrl_skb;
}
- for (i = 0; i < eth_tbl->count; i++) {
- unsigned int phys_port = eth_tbl->ports[i].index;
+ for (i = 0; i < phy_reprs_num; i++) {
+ int idx = nfp_net_get_id(app->pf, i);
struct net_device *repr;
+ unsigned int phys_port;
struct nfp_port *port;
u32 cmsg_port_id;
+ phys_port = eth_tbl->ports[idx].index;
repr = nfp_repr_alloc(app);
if (!repr) {
err = -ENOMEM;
@@ -542,7 +545,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
nfp_repr_free(repr);
goto err_reprs_clean;
}
- err = nfp_port_init_phy_port(app->pf, app, port, i);
+ err = nfp_port_init_phy_port(app->pf, app, port, idx);
if (err) {
kfree(repr_priv);
nfp_port_free(port);
@@ -609,7 +612,7 @@ nfp_flower_spawn_phy_reprs(struct nfp_app *app, struct nfp_flower_priv *priv)
static int nfp_flower_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
unsigned int id)
{
- if (id > 0) {
+ if (id > 0 && !app->pf->multi_pf.en) {
nfp_warn(app->cpp, "FlowerNIC doesn't support more than one data vNIC\n");
goto err_invalid_port;
}
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.h b/drivers/net/ethernet/netronome/nfp/nfp_main.h
index 7f76c718fef8..4f6763ca1c92 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.h
@@ -210,4 +210,10 @@ 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);
+
+static inline unsigned int nfp_net_get_id(const struct nfp_pf *pf, unsigned int id)
+{
+ return pf->multi_pf.en ? pf->multi_pf.id : id;
+}
+
#endif /* NFP_MAIN_H */
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index cbe4972ba104..98e155d79eb8 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -141,7 +141,7 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
{
int err;
- nn->id = id;
+ nn->id = nfp_net_get_id(pf, id);
if (nn->port) {
err = nfp_devlink_port_register(pf->app, nn->port);
@@ -183,8 +183,8 @@ nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
int err;
for (i = 0; i < pf->max_data_vnics; i++) {
- nn = nfp_net_pf_alloc_vnic(pf, true, ctrl_bar, qc_bar,
- stride, i);
+ nn = nfp_net_pf_alloc_vnic(pf, true, ctrl_bar, qc_bar, stride,
+ nfp_net_get_id(pf, i));
if (IS_ERR(nn)) {
err = PTR_ERR(nn);
goto err_free_prev;
@@ -707,6 +707,11 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
if ((int)pf->max_data_vnics < 0)
return pf->max_data_vnics;
+ if (pf->multi_pf.en && pf->max_data_vnics != 1) {
+ nfp_err(pf->cpp, "Only one data_vnic per PF is supported in multiple PF setup.\n");
+ return -EINVAL;
+ }
+
err = nfp_net_pci_map_mem(pf);
if (err)
return err;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c
index 54640bcb70fb..c1612a464b5d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -189,7 +189,9 @@ int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
port->eth_port = &pf->eth_tbl->ports[id];
port->eth_id = pf->eth_tbl->ports[id].index;
- port->netdev->dev_port = id;
+ if (!pf->multi_pf.en)
+ port->netdev->dev_port = id;
+
if (pf->mac_stats_mem)
port->eth_stats =
pf->mac_stats_mem + port->eth_id * NFP_MAC_STATS_SIZE;
diff --git a/drivers/net/ethernet/netronome/nfp/nic/main.c b/drivers/net/ethernet/netronome/nfp/nic/main.c
index 9dd5afe37f6e..e7a2d01bcbff 100644
--- a/drivers/net/ethernet/netronome/nfp/nic/main.c
+++ b/drivers/net/ethernet/netronome/nfp/nic/main.c
@@ -12,7 +12,8 @@ static int nfp_nic_init(struct nfp_app *app)
{
struct nfp_pf *pf = app->pf;
- if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count) {
+ if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count &&
+ !pf->multi_pf.en) {
nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n",
pf->max_data_vnics, pf->eth_tbl->count);
return -EINVAL;
--
2.34.1
Powered by blists - more mailing lists