{
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;
}
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,
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);