@@ -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;
@@ -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;
@@ -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;
}
@@ -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 */
@@ -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;
@@ -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;
@@ -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;