DPDK patches and discussions
 help / color / mirror / Atom feed
From: <psatheesh@marvell.com>
To: Nithin Dabilpuram <ndabilpuram@marvell.com>,
	Kiran Kumar K <kirankumark@marvell.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	Satha Rao <skoteshwar@marvell.com>
Cc: <dev@dpdk.org>, Satheesh Paul <psatheesh@marvell.com>
Subject: [dpdk-dev] [PATCH v2 2/4] common/cnxk: support custom pre L2 header parsing as raw
Date: Mon, 3 Jan 2022 11:49:07 +0530	[thread overview]
Message-ID: <20220103061909.83319-2-psatheesh@marvell.com> (raw)
In-Reply-To: <20220103061909.83319-1-psatheesh@marvell.com>

From: Kiran Kumar K <kirankumark@marvell.com>

Add roc API for parsing custom pre L2 headers as raw data.
Only relative offset is supported and search and limit is
not supported with this raw item type.

Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
Reviewed-by: Satheesh Paul <psatheesh@marvell.com>
---
 drivers/common/cnxk/roc_npc.c           |   8 +-
 drivers/common/cnxk/roc_npc_mcam_dump.c |   2 +
 drivers/common/cnxk/roc_npc_parse.c     | 103 +++++++++++++++++-------
 drivers/common/cnxk/roc_npc_priv.h      |   1 +
 4 files changed, 81 insertions(+), 33 deletions(-)

diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c
index d18dfd4259..e3961bfbc6 100644
--- a/drivers/common/cnxk/roc_npc.c
+++ b/drivers/common/cnxk/roc_npc.c
@@ -566,10 +566,10 @@ npc_parse_pattern(struct npc *npc, const struct roc_npc_item_info pattern[],
 		  struct roc_npc_flow *flow, struct npc_parse_state *pst)
 {
 	npc_parse_stage_func_t parse_stage_funcs[] = {
-		npc_parse_meta_items, npc_parse_cpt_hdr, npc_parse_higig2_hdr,
-		npc_parse_la,	      npc_parse_lb,	 npc_parse_lc,
-		npc_parse_ld,	      npc_parse_le,	 npc_parse_lf,
-		npc_parse_lg,	      npc_parse_lh,
+		npc_parse_meta_items, npc_parse_pre_l2, npc_parse_cpt_hdr,
+		npc_parse_higig2_hdr, npc_parse_la,	npc_parse_lb,
+		npc_parse_lc,	      npc_parse_ld,	npc_parse_le,
+		npc_parse_lf,	      npc_parse_lg,	npc_parse_lh,
 	};
 	uint8_t layer = 0;
 	int key_offset;
diff --git a/drivers/common/cnxk/roc_npc_mcam_dump.c b/drivers/common/cnxk/roc_npc_mcam_dump.c
index 278056591e..679e3d7657 100644
--- a/drivers/common/cnxk/roc_npc_mcam_dump.c
+++ b/drivers/common/cnxk/roc_npc_mcam_dump.c
@@ -69,6 +69,8 @@ static const char *const ltype_str[NPC_MAX_LID][NPC_MAX_LT] = {
 	[NPC_LID_LA][NPC_LT_LA_IH_NIX_ETHER] = "LA_IH_NIX_ETHER",
 	[NPC_LID_LA][NPC_LT_LA_HIGIG2_ETHER] = "LA_HIGIG2_ETHER",
 	[NPC_LID_LA][NPC_LT_LA_IH_NIX_HIGIG2_ETHER] = "LA_IH_NIX_HIGIG2_ETHER",
+	[NPC_LID_LA][NPC_LT_LA_CUSTOM_PRE_L2_ETHER] =
+		"NPC_LT_LA_CUSTOM_PRE_L2_ETHER",
 	[NPC_LID_LB][0] = "NONE",
 	[NPC_LID_LB][NPC_LT_LB_CTAG] = "LB_CTAG",
 	[NPC_LID_LB][NPC_LT_LB_STAG_QINQ] = "LB_STAG_QINQ",
diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c
index 8125035dd8..c9ab9aef28 100644
--- a/drivers/common/cnxk/roc_npc_parse.c
+++ b/drivers/common/cnxk/roc_npc_parse.c
@@ -21,6 +21,80 @@ npc_parse_meta_items(struct npc_parse_state *pst)
 	return 0;
 }
 
+static int
+npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec,
+			  const struct roc_npc_flow_item_raw *raw_mask,
+			  struct npc_parse_item_info *info, uint8_t *spec_buf,
+			  uint8_t *mask_buf)
+{
+
+	memset(spec_buf, 0, NPC_MAX_RAW_ITEM_LEN);
+	memset(mask_buf, 0, NPC_MAX_RAW_ITEM_LEN);
+
+	memcpy(spec_buf + raw_spec->offset, raw_spec->pattern,
+	       raw_spec->length);
+
+	if (raw_mask && raw_mask->pattern) {
+		memcpy(mask_buf + raw_spec->offset, raw_mask->pattern,
+		       raw_spec->length);
+	} else {
+		memset(mask_buf + raw_spec->offset, 0xFF, raw_spec->length);
+	}
+
+	info->len = NPC_MAX_RAW_ITEM_LEN;
+	info->spec = spec_buf;
+	info->mask = mask_buf;
+	return 0;
+}
+
+int
+npc_parse_pre_l2(struct npc_parse_state *pst)
+{
+	uint8_t raw_spec_buf[NPC_MAX_RAW_ITEM_LEN] = {0};
+	uint8_t raw_mask_buf[NPC_MAX_RAW_ITEM_LEN] = {0};
+	uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN] = {0};
+	const struct roc_npc_flow_item_raw *raw_spec;
+	struct npc_parse_item_info info;
+	int lid, lt, len;
+	int rc;
+
+	if (pst->npc->switch_header_type != ROC_PRIV_FLAGS_PRE_L2)
+		return 0;
+
+	/* Identify the pattern type into lid, lt */
+	if (pst->pattern->type != ROC_NPC_ITEM_TYPE_RAW)
+		return 0;
+
+	lid = NPC_LID_LA;
+	lt = NPC_LT_LA_CUSTOM_PRE_L2_ETHER;
+	info.hw_hdr_len = 0;
+
+	raw_spec = pst->pattern->spec;
+	len = raw_spec->length + raw_spec->offset;
+	if (len > NPC_MAX_RAW_ITEM_LEN)
+		return -EINVAL;
+
+	if (raw_spec->relative == 0 || raw_spec->search || raw_spec->limit ||
+	    raw_spec->offset < 0)
+		return -EINVAL;
+
+	npc_flow_raw_item_prepare(
+		(const struct roc_npc_flow_item_raw *)pst->pattern->spec,
+		(const struct roc_npc_flow_item_raw *)pst->pattern->mask, &info,
+		raw_spec_buf, raw_mask_buf);
+
+	info.hw_mask = &hw_mask;
+	npc_get_hw_supp_mask(pst, &info, lid, lt);
+
+	/* Basic validation of item parameters */
+	rc = npc_parse_item_basic(pst->pattern, &info);
+	if (rc)
+		return rc;
+
+	/* Update pst if not validate only? clash check? */
+	return npc_update_parse_state(pst, &info, lid, lt, 0);
+}
+
 int
 npc_parse_cpt_hdr(struct npc_parse_state *pst)
 {
@@ -136,35 +210,6 @@ npc_parse_la(struct npc_parse_state *pst)
 	return npc_update_parse_state(pst, &info, lid, lt, 0);
 }
 
-static int
-npc_flow_raw_item_prepare(const struct roc_npc_flow_item_raw *raw_spec,
-			  const struct roc_npc_flow_item_raw *raw_mask,
-			  struct npc_parse_item_info *info, uint8_t *spec_buf,
-			  uint8_t *mask_buf)
-{
-	uint32_t custom_hdr_size = 0;
-
-	memset(spec_buf, 0, NPC_MAX_RAW_ITEM_LEN);
-	memset(mask_buf, 0, NPC_MAX_RAW_ITEM_LEN);
-	custom_hdr_size = raw_spec->offset + raw_spec->length;
-
-	memcpy(spec_buf + raw_spec->offset, raw_spec->pattern,
-	       raw_spec->length);
-
-	if (raw_mask->pattern) {
-		memcpy(mask_buf + raw_spec->offset, raw_mask->pattern,
-		       raw_spec->length);
-	} else {
-		memset(mask_buf + raw_spec->offset, 0xFF, raw_spec->length);
-	}
-
-	info->len = custom_hdr_size;
-	info->spec = spec_buf;
-	info->mask = mask_buf;
-
-	return 0;
-}
-
 int
 npc_parse_lb(struct npc_parse_state *pst)
 {
diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h
index 86c10ea082..1a40192599 100644
--- a/drivers/common/cnxk/roc_npc_priv.h
+++ b/drivers/common/cnxk/roc_npc_priv.h
@@ -408,6 +408,7 @@ void npc_get_hw_supp_mask(struct npc_parse_state *pst,
 int npc_parse_item_basic(const struct roc_npc_item_info *item,
 			 struct npc_parse_item_info *info);
 int npc_parse_meta_items(struct npc_parse_state *pst);
+int npc_parse_pre_l2(struct npc_parse_state *pst);
 int npc_parse_higig2_hdr(struct npc_parse_state *pst);
 int npc_parse_cpt_hdr(struct npc_parse_state *pst);
 int npc_parse_la(struct npc_parse_state *pst);
-- 
2.25.4


  reply	other threads:[~2022-01-03  6:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03  5:57 [dpdk-dev] [PATCH 1/4] drivers: add support for switch header type pre L2 psatheesh
2022-01-03  5:57 ` [dpdk-dev] [PATCH 2/4] common/cnxk: support custom pre L2 header parsing as raw psatheesh
2022-01-03  5:57 ` [dpdk-dev] [PATCH 3/4] common/cnxk: support matching VLAN existence in RTE Flow psatheesh
2022-01-03  5:57 ` [dpdk-dev] [PATCH 4/4] common/cnxk: support extensions attributes in IPv6 item psatheesh
2022-01-03  6:19 ` [dpdk-dev] [PATCH v2 1/4] drivers: add support for switch header type pre L2 psatheesh
2022-01-03  6:19   ` psatheesh [this message]
2022-01-03  6:19   ` [dpdk-dev] [PATCH v2 3/4] common/cnxk: support matching VLAN existence in RTE Flow psatheesh
2022-01-03  6:19   ` [dpdk-dev] [PATCH v2 4/4] common/cnxk: support extensions attributes in IPv6 item psatheesh
2022-01-20  6:54   ` [dpdk-dev] [PATCH v2 1/4] drivers: add support for switch header type pre L2 Jerin Jacob
2022-01-21  6:26 ` [dpdk-dev v3] [PATCH 1/4] drivers: support for switch header type pre_L2 psatheesh
2022-01-21  6:26   ` [dpdk-dev v3] [PATCH 2/4] common/cnxk: support custom pre L2 header parsing as raw psatheesh
2022-01-21  6:26   ` [dpdk-dev v3] [PATCH 3/4] common/cnxk: support matching VLAN existence in RTE Flow psatheesh
2022-01-21  6:26   ` [dpdk-dev v3] [PATCH 4/4] common/cnxk: support extensions attributes in IPv6 item psatheesh
2022-01-22 14:08   ` [dpdk-dev v3] [PATCH 1/4] drivers: support for switch header type pre_L2 Jerin Jacob

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=20220103061909.83319-2-psatheesh@marvell.com \
    --to=psatheesh@marvell.com \
    --cc=dev@dpdk.org \
    --cc=kirankumark@marvell.com \
    --cc=ndabilpuram@marvell.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.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).