net/sfc: support flow item UDP in transfer rules
authorIvan Malov <ivan.malov@oktetlabs.ru>
Tue, 20 Oct 2020 09:13:34 +0000 (10:13 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:25 +0000 (23:24 +0100)
Add support for this flow item to MAE-specific RTE flow implementation.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
doc/guides/nics/sfc_efx.rst
drivers/net/sfc/sfc_mae.c
drivers/net/sfc/sfc_mae.h

index 58b81ea..1f6058e 100644 (file)
@@ -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
index 59c53a9..3dd233c 100644 (file)
@@ -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
index 71046f2..8d9b403 100644 (file)
@@ -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;