From c50442b0a712e443420a33b8e409e0afce24bb86 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Tue, 20 Oct 2020 10:13:34 +0100 Subject: [PATCH] net/sfc: support flow item UDP in transfer rules Add support for this flow item to MAE-specific RTE flow implementation. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- doc/guides/nics/sfc_efx.rst | 2 ++ drivers/net/sfc/sfc_mae.c | 53 +++++++++++++++++++++++++++++++++++++ drivers/net/sfc/sfc_mae.h | 4 +++ 3 files changed, 59 insertions(+) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 58b81ea359..1f6058e57a 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -210,6 +210,8 @@ Supported pattern items (***transfer*** rules): - TCP (source/destination ports, TCP header length + TCP flags) +- UDP (source/destination ports) + Supported actions (***transfer*** rules): - OF_POP_VLAN diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c index 59c53a96f3..3dd233c6dc 100644 --- a/drivers/net/sfc/sfc_mae.c +++ b/drivers/net/sfc/sfc_mae.c @@ -1115,6 +1115,52 @@ sfc_mae_rule_parse_item_tcp(const struct rte_flow_item *item, ctx_mae->match_spec_action, error); } +static const struct sfc_mae_field_locator flocs_udp[] = { + { + EFX_MAE_FIELD_L4_SPORT_BE, + RTE_SIZEOF_FIELD(struct rte_flow_item_udp, hdr.src_port), + offsetof(struct rte_flow_item_udp, hdr.src_port), + }, + { + EFX_MAE_FIELD_L4_DPORT_BE, + RTE_SIZEOF_FIELD(struct rte_flow_item_udp, hdr.dst_port), + offsetof(struct rte_flow_item_udp, hdr.dst_port), + }, +}; + +static int +sfc_mae_rule_parse_item_udp(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; + struct sfc_mae_pattern_data *pdata = &ctx_mae->pattern_data; + struct rte_flow_item_udp supp_mask; + const uint8_t *spec = NULL; + const uint8_t *mask = NULL; + int rc; + + sfc_mae_item_build_supp_mask(flocs_udp, RTE_DIM(flocs_udp), + &supp_mask, sizeof(supp_mask)); + + rc = sfc_flow_parse_init(item, + (const void **)&spec, (const void **)&mask, + (const void *)&supp_mask, + &rte_flow_item_udp_mask, + sizeof(struct rte_flow_item_udp), error); + if (rc != 0) + return rc; + + pdata->l3_next_proto_restriction_value = IPPROTO_UDP; + pdata->l3_next_proto_restriction_mask = 0xff; + + if (spec == NULL) + return 0; + + return sfc_mae_parse_item(flocs_udp, RTE_DIM(flocs_udp), spec, mask, + ctx_mae->match_spec_action, error); +} + static const struct sfc_flow_item sfc_flow_items[] = { { .type = RTE_FLOW_ITEM_TYPE_PORT_ID, @@ -1195,6 +1241,13 @@ static const struct sfc_flow_item sfc_flow_items[] = { .ctx_type = SFC_FLOW_PARSE_CTX_MAE, .parse = sfc_mae_rule_parse_item_tcp, }, + { + .type = RTE_FLOW_ITEM_TYPE_UDP, + .prev_layer = SFC_FLOW_ITEM_L3, + .layer = SFC_FLOW_ITEM_L4, + .ctx_type = SFC_FLOW_PARSE_CTX_MAE, + .parse = sfc_mae_rule_parse_item_udp, + }, }; int diff --git a/drivers/net/sfc/sfc_mae.h b/drivers/net/sfc/sfc_mae.h index 71046f2308..8d9b4039f3 100644 --- a/drivers/net/sfc/sfc_mae.h +++ b/drivers/net/sfc/sfc_mae.h @@ -128,6 +128,9 @@ struct sfc_mae_pattern_data { * * - If a L3 item is followed by an item TCP, the former has * its "proto" set to either 0x06/0xff or 0x00/0x00. + * + * - If a L3 item is followed by an item UDP, the former has + * its "proto" set to either 0x11/0xff or 0x00/0x00. */ uint8_t l3_next_proto_value; uint8_t l3_next_proto_mask; @@ -136,6 +139,7 @@ struct sfc_mae_pattern_data { * L4 requirement for L3 item's "proto". * This contains one of: * - 0x06/0xff: TCP + * - 0x11/0xff: UDP * - 0x00/0x00: no L4 item */ uint8_t l3_next_proto_restriction_value; -- 2.20.1