+
+/* This function expects to be called only when the lock is held */
+static int
+sfc_mae_find_switch_port_by_ethdev(uint16_t switch_domain_id,
+ uint16_t ethdev_port_id,
+ efx_mport_sel_t *mport_sel)
+{
+ struct sfc_mae_switch_domain *domain;
+ struct sfc_mae_switch_port *port;
+
+ SFC_ASSERT(rte_spinlock_is_locked(&sfc_mae_switch.lock));
+
+ if (ethdev_port_id == RTE_MAX_ETHPORTS)
+ return EINVAL;
+
+ domain = sfc_mae_find_switch_domain_by_id(switch_domain_id);
+ if (domain == NULL)
+ return EINVAL;
+
+ TAILQ_FOREACH(port, &domain->ports, switch_domain_ports) {
+ if (port->ethdev_port_id == ethdev_port_id) {
+ *mport_sel = port->ethdev_mport;
+ return 0;
+ }
+ }
+
+ return ENOENT;
+}
+
+int
+sfc_mae_switch_port_by_ethdev(uint16_t switch_domain_id,
+ uint16_t ethdev_port_id,
+ efx_mport_sel_t *mport_sel)
+{
+ int rc;
+
+ rte_spinlock_lock(&sfc_mae_switch.lock);
+ rc = sfc_mae_find_switch_port_by_ethdev(switch_domain_id,
+ ethdev_port_id, mport_sel);
+ rte_spinlock_unlock(&sfc_mae_switch.lock);
+
+ return rc;
+}