DPDK patches and discussions
 help / color / mirror / Atom feed
From: Chaoyong He <chaoyong.he@corigine.com>
To: dev@dpdk.org
Cc: oss-drivers@corigine.com, Long Wu <long.wu@corigine.com>,
	Chaoyong He <chaoyong.he@corigine.com>
Subject: [PATCH 2/2] net/nfp: flow rule supports match Ethernet type
Date: Fri, 30 Aug 2024 11:10:25 +0800	[thread overview]
Message-ID: <20240830031025.2422579-3-chaoyong.he@corigine.com> (raw)
In-Reply-To: <20240830031025.2422579-1-chaoyong.he@corigine.com>

From: Long Wu <long.wu@corigine.com>

Add the support of match ethernet type item when
using flower firmware, with a limit that it can
only be used alone.

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_cmsg.h | 14 ++++++++++
 drivers/net/nfp/flower/nfp_flower_flow.c | 34 ++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

diff --git a/drivers/net/nfp/flower/nfp_flower_cmsg.h b/drivers/net/nfp/flower/nfp_flower_cmsg.h
index 5d23227c24..5fc4210d8b 100644
--- a/drivers/net/nfp/flower/nfp_flower_cmsg.h
+++ b/drivers/net/nfp/flower/nfp_flower_cmsg.h
@@ -708,6 +708,20 @@ struct nfp_flower_ipv6_gre_tun {
 	rte_be32_t reserved2;
 };
 
+/*
+ * L3 other (1W/4B)
+ *    3                   2                   1
+ *  1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |            reserved           |           ethertype           |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * Note: This is only used when no specific L3 header available.
+ */
+struct nfp_flower_l3_other {
+	rte_be16_t reserved;
+	rte_be16_t ethertype;
+};
+
 struct nfp_fl_act_head {
 	uint8_t jump_id;
 	uint8_t len_lw;
diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index 50b0742b18..21a53eab68 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -26,6 +26,7 @@
 #define NFP_FLOWER_LAYER_VXLAN          RTE_BIT32(7)
 
 #define NFP_FLOWER_LAYER2_GRE           RTE_BIT32(0)
+#define NFP_FLOWER_LAYER2_L3_OTHER      RTE_BIT32(3)
 #define NFP_FLOWER_LAYER2_QINQ          RTE_BIT32(4)
 #define NFP_FLOWER_LAYER2_GENEVE        RTE_BIT32(5)
 #define NFP_FLOWER_LAYER2_GENEVE_OP     RTE_BIT32(6)
@@ -962,10 +963,15 @@ struct nfp_item_flag {
 	bool outer_ip6_flag;
 };
 
+struct nfp_item_shared_flag {
+	bool l3_other_flag;
+};
+
 struct nfp_item_calculate_param {
 	const struct rte_flow_item *item;
 	struct nfp_fl_key_ls *key_ls;
 	struct nfp_item_flag *flag;
+	struct nfp_item_shared_flag shared_flag;
 };
 
 typedef int (*nfp_flow_key_check_item_fn)(struct nfp_item_calculate_param *param);
@@ -1068,6 +1074,9 @@ nfp_flow_key_layers_check_items(const struct rte_flow_item items[],
 			PMD_DRV_LOG(ERR, "Flow item %d check fail", item->type);
 			return ret;
 		}
+
+		if (item->type != RTE_FLOW_ITEM_TYPE_ETH)
+			param->shared_flag.l3_other_flag = true;
 	}
 
 	return 0;
@@ -1092,6 +1101,13 @@ nfp_flow_item_calculate_eth(struct nfp_item_calculate_param *param)
 
 	key_ls->key_layer |= NFP_FLOWER_LAYER_MAC;
 	key_ls->key_size += sizeof(struct nfp_flower_mac_mpls);
+
+	if (!param->shared_flag.l3_other_flag && spec->type != 0) {
+		key_ls->key_layer |= NFP_FLOWER_LAYER_EXT_META;
+		key_ls->key_size += sizeof(struct nfp_flower_ext_meta);
+		key_ls->key_layer_two |= NFP_FLOWER_LAYER2_L3_OTHER;
+		key_ls->key_size += sizeof(struct nfp_flower_l3_other);
+	}
 }
 
 static void
@@ -1873,6 +1889,9 @@ nfp_flow_merge_eth(struct nfp_flow_merge_param *param)
 	const struct rte_flow_item *item;
 	const struct rte_flow_item_eth *spec;
 	const struct rte_flow_item_eth *mask;
+	struct nfp_flower_l3_other *l3_other;
+	struct nfp_flower_meta_tci *meta_tci;
+	struct nfp_flower_ext_meta *ext_meta = NULL;
 
 	item = param->item;
 	spec = item->spec;
@@ -1895,6 +1914,21 @@ nfp_flow_merge_eth(struct nfp_flow_merge_param *param)
 	eth->mpls_lse = 0;
 	*param->mbuf_off += sizeof(struct nfp_flower_mac_mpls);
 
+	meta_tci = (struct nfp_flower_meta_tci *)param->nfp_flow->payload.unmasked_data;
+	if ((meta_tci->nfp_flow_key_layer & NFP_FLOWER_LAYER_EXT_META) != 0)
+		ext_meta = (struct nfp_flower_ext_meta *)(meta_tci + 1);
+
+	if (ext_meta != NULL &&
+			(ext_meta->nfp_flow_key_layer2 & NFP_FLOWER_LAYER2_L3_OTHER) != 0) {
+		l3_other = (void *)(*param->mbuf_off);
+		if (param->is_mask)
+			l3_other->ethertype = mask->type;
+		else
+			l3_other->ethertype = spec->type;
+
+		*param->mbuf_off += sizeof(struct nfp_flower_l3_other);
+	}
+
 eth_end:
 	return 0;
 }
-- 
2.39.1


  parent reply	other threads:[~2024-08-30  3:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30  3:10 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He
2024-08-30  3:10 ` [PATCH 1/2] net/nfp: refactor flow item calculate function arguments Chaoyong He
2024-08-30  3:10 ` Chaoyong He [this message]
2024-08-30  7:13 [PATCH 0/2] Support match flow rule Ethernet type field Chaoyong He
2024-08-30  7:13 ` [PATCH 2/2] net/nfp: flow rule supports match Ethernet type Chaoyong He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240830031025.2422579-3-chaoyong.he@corigine.com \
    --to=chaoyong.he@corigine.com \
    --cc=dev@dpdk.org \
    --cc=long.wu@corigine.com \
    --cc=oss-drivers@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).