}
static int
-sfc_mae_rule_parse_item_port_representor(const struct rte_flow_item *item,
- struct sfc_flow_parse_ctx *ctx,
- struct rte_flow_error *error)
+sfc_mae_rule_parse_item_ethdev_based(const struct rte_flow_item *item,
+ struct sfc_flow_parse_ctx *ctx,
+ struct rte_flow_error *error)
{
struct sfc_mae_parse_ctx *ctx_mae = ctx->mae;
const struct rte_flow_item_ethdev supp_mask = {
if (mask->port_id != supp_mask.port_id) {
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ITEM, item,
- "Bad mask in the PORT_REPRESENTOR pattern item");
+ "Bad mask in the ethdev-based pattern item");
}
/* If "spec" is not set, could be any port ID */
if (spec == NULL)
return 0;
- rc = sfc_mae_switch_get_ethdev_mport(
- ctx_mae->sa->mae.switch_domain_id,
- spec->port_id, &mport_sel);
- if (rc != 0) {
- return rte_flow_error_set(error, rc,
+ switch (item->type) {
+ case RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR:
+ rc = sfc_mae_switch_get_ethdev_mport(
+ ctx_mae->sa->mae.switch_domain_id,
+ spec->port_id, &mport_sel);
+ if (rc != 0) {
+ return rte_flow_error_set(error, rc,
+ RTE_FLOW_ERROR_TYPE_ITEM, item,
+ "Can't get m-port for the given ethdev");
+ }
+ break;
+ case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
+ rc = sfc_mae_switch_get_entity_mport(
+ ctx_mae->sa->mae.switch_domain_id,
+ spec->port_id, &mport_sel);
+ if (rc != 0) {
+ return rte_flow_error_set(error, rc,
+ RTE_FLOW_ERROR_TYPE_ITEM, item,
+ "Can't get m-port for the given ethdev");
+ }
+ break;
+ default:
+ return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ITEM, item,
- "Can't get m-port for the given ethdev");
+ "Unsupported ethdev-based flow item");
}
rc = efx_mae_match_spec_mport_set(ctx_mae->match_spec,
.prev_layer = SFC_FLOW_ITEM_ANY_LAYER,
.layer = SFC_FLOW_ITEM_ANY_LAYER,
.ctx_type = SFC_FLOW_PARSE_CTX_MAE,
- .parse = sfc_mae_rule_parse_item_port_representor,
+ .parse = sfc_mae_rule_parse_item_ethdev_based,
+ },
+ {
+ .type = RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT,
+ .name = "REPRESENTED_PORT",
+ /*
+ * In terms of RTE flow, this item is a META one,
+ * and its position in the pattern is don't care.
+ */
+ .prev_layer = SFC_FLOW_ITEM_ANY_LAYER,
+ .layer = SFC_FLOW_ITEM_ANY_LAYER,
+ .ctx_type = SFC_FLOW_PARSE_CTX_MAE,
+ .parse = sfc_mae_rule_parse_item_ethdev_based,
},
{
.type = RTE_FLOW_ITEM_TYPE_PHY_PORT,
return rc;
}
+int
+sfc_mae_switch_get_entity_mport(uint16_t switch_domain_id,
+ uint16_t ethdev_port_id,
+ efx_mport_sel_t *mport_sel)
+{
+ static struct sfc_mae_switch_port *port;
+ int rc;
+
+ rte_spinlock_lock(&sfc_mae_switch.lock);
+ rc = sfc_mae_find_switch_port_by_ethdev(switch_domain_id,
+ ethdev_port_id, &port);
+ if (rc != 0)
+ goto unlock;
+
+ if (port->type == SFC_MAE_SWITCH_PORT_INDEPENDENT &&
+ !port->data.indep.mae_admin) {
+ /* See sfc_mae_assign_entity_mport() */
+ rc = ENOTSUP;
+ goto unlock;
+ }
+
+ *mport_sel = port->entity_mport;
+
+unlock:
+ rte_spinlock_unlock(&sfc_mae_switch.lock);
+
+ return rc;
+}
+
int
sfc_mae_switch_port_id_by_entity(uint16_t switch_domain_id,
const efx_mport_sel_t *entity_mportp,