X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fsfc%2Fsfc_switch.c;h=5cd9b46d26a1d3780fc508b900974206721545e2;hb=6ded2e01380e5f3bd48154ca8f23eaad35ffe839;hp=f72f6648b830ea48d4cba88aed677f1ed69d6732;hpb=44db08d53be366d69bb7d16bffc3e55ba2d7398a;p=dpdk.git diff --git a/drivers/net/sfc/sfc_switch.c b/drivers/net/sfc/sfc_switch.c index f72f6648b8..5cd9b46d26 100644 --- a/drivers/net/sfc/sfc_switch.c +++ b/drivers/net/sfc/sfc_switch.c @@ -63,6 +63,8 @@ struct sfc_mae_switch_port { enum sfc_mae_switch_port_type type; /** RTE switch port ID */ uint16_t id; + + union sfc_mae_switch_port_data data; }; TAILQ_HEAD(sfc_mae_switch_ports, sfc_mae_switch_port); @@ -277,6 +279,58 @@ 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; +} + +int sfc_mae_switch_domain_get_intf(uint16_t switch_domain_id, + int controller, + efx_pcie_interface_t *intf) +{ + const efx_pcie_interface_t *controllers; + size_t nb_controllers; + int rc; + + rc = sfc_mae_switch_domain_controllers(switch_domain_id, &controllers, + &nb_controllers); + if (rc != 0) + return rc; + + if (controllers == NULL) + return ENOENT; + + if ((size_t)controller > nb_controllers) + return EINVAL; + + *intf = controllers[controller]; + + return 0; +} + /* 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, @@ -335,6 +389,18 @@ done: port->ethdev_mport = *req->ethdev_mportp; port->ethdev_port_id = req->ethdev_port_id; + switch (req->type) { + case SFC_MAE_SWITCH_PORT_INDEPENDENT: + /* No data */ + break; + case SFC_MAE_SWITCH_PORT_REPRESENTOR: + memcpy(&port->data.repr, &req->port_data, + sizeof(port->data.repr)); + break; + default: + SFC_ASSERT(B_FALSE); + } + *switch_port_id = port->id; rte_spinlock_unlock(&sfc_mae_switch.lock);