net/sfc: include controller and port in representor name
Make representor names unique on multi-host configurations. Signed-off-by: Viacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
This commit is contained in:
parent
768d1e44df
commit
c75d560db3
@ -1028,11 +1028,35 @@ sfc_repr_create(struct rte_eth_dev *parent,
|
||||
{
|
||||
struct sfc_repr_init_data repr_data;
|
||||
char name[RTE_ETH_NAME_MAX_LEN];
|
||||
int controller;
|
||||
int ret;
|
||||
int rc;
|
||||
struct rte_eth_dev *dev;
|
||||
|
||||
if (snprintf(name, sizeof(name), "net_%s_representor_%u",
|
||||
parent->device->name, entity->vf) >= (int)sizeof(name)) {
|
||||
controller = -1;
|
||||
rc = sfc_mae_switch_domain_get_controller(switch_domain_id,
|
||||
entity->intf, &controller);
|
||||
if (rc != 0) {
|
||||
SFC_GENERIC_LOG(ERR, "%s() failed to get DPDK controller for %d",
|
||||
__func__, entity->intf);
|
||||
return -rc;
|
||||
}
|
||||
|
||||
switch (entity->type) {
|
||||
case RTE_ETH_REPRESENTOR_VF:
|
||||
ret = snprintf(name, sizeof(name), "net_%s_representor_c%upf%uvf%u",
|
||||
parent->device->name, controller, entity->pf,
|
||||
entity->vf);
|
||||
break;
|
||||
case RTE_ETH_REPRESENTOR_PF:
|
||||
ret = snprintf(name, sizeof(name), "net_%s_representor_c%upf%u",
|
||||
parent->device->name, controller, entity->pf);
|
||||
break;
|
||||
default:
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (ret >= (int)sizeof(name)) {
|
||||
SFC_GENERIC_LOG(ERR, "%s() failed name too long", __func__);
|
||||
return -ENAMETOOLONG;
|
||||
}
|
||||
|
@ -279,6 +279,34 @@ sfc_mae_switch_domain_map_controllers(uint16_t switch_domain_id,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sfc_mae_switch_domain_get_controller(uint16_t switch_domain_id,
|
||||
efx_pcie_interface_t intf,
|
||||
int *controller)
|
||||
{
|
||||
const efx_pcie_interface_t *controllers;
|
||||
size_t nb_controllers;
|
||||
size_t i;
|
||||
int rc;
|
||||
|
||||
rc = sfc_mae_switch_domain_controllers(switch_domain_id, &controllers,
|
||||
&nb_controllers);
|
||||
if (rc != 0)
|
||||
return rc;
|
||||
|
||||
if (controllers == NULL)
|
||||
return ENOENT;
|
||||
|
||||
for (i = 0; i < nb_controllers; i++) {
|
||||
if (controllers[i] == intf) {
|
||||
*controller = i;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
/* This function expects to be called only when the lock is held */
|
||||
static struct sfc_mae_switch_port *
|
||||
sfc_mae_find_switch_port_by_entity(const struct sfc_mae_switch_domain *domain,
|
||||
|
@ -63,6 +63,10 @@ int sfc_mae_switch_domain_map_controllers(uint16_t switch_domain_id,
|
||||
efx_pcie_interface_t *controllers,
|
||||
size_t nb_controllers);
|
||||
|
||||
int sfc_mae_switch_domain_get_controller(uint16_t switch_domain_id,
|
||||
efx_pcie_interface_t intf,
|
||||
int *controller);
|
||||
|
||||
int sfc_mae_assign_switch_port(uint16_t switch_domain_id,
|
||||
const struct sfc_mae_switch_port_request *req,
|
||||
uint16_t *switch_port_id);
|
||||
|
Loading…
Reference in New Issue
Block a user