From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6B627A0350; Mon, 3 Jan 2022 06:57:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4AEB24069F; Mon, 3 Jan 2022 06:57:40 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 18D3E4003C for ; Mon, 3 Jan 2022 06:57:38 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 202N0CC7022898 for ; Sun, 2 Jan 2022 21:57:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=fQhrg7o9e6tdRDsMpdLtoZ6a8E8MVoyvtVFDfEn2KMI=; b=X5NaL9J4JYjgee0IQNxthICearZqTwg8CDgmrqhqRyboJJ2pHIPYT83GYqgjJkdisodh ys+gsSpxbUaBXl4lRLrseY6OvOvHatAYrawNTo4JcKtkAbFt1sQ30tWb0q/ajvzxbg8V VWo954m5cuFENvwWiNJBQjgL/LdVJOoun+QDXMH5JnjwRROxDWsTTlRcxsn1U5V53Dtx nRolV8gTx/GUo/SXbH7z9sQe5c/l83JvPn3CkOOS5QJNIH1hjujcYAOzojtZkk+DytJt xn8pH/2hmkQQ4vKRs8p+u8F9om+20PKzijVnI3ilulJPKx/mgEoldNi22nGjQv/h18p4 GA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3daqbrkxy2-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 02 Jan 2022 21:57:37 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 2 Jan 2022 21:57:25 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sun, 2 Jan 2022 21:57:25 -0800 Received: from localhost.localdomain (unknown [10.28.34.33]) by maili.marvell.com (Postfix) with ESMTP id 1D6E03F7051; Sun, 2 Jan 2022 21:57:22 -0800 (PST) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , sa_ip-toolkits-Jenkins , Satheesh Paul , Jerin Jacob Kollanukkaran Subject: [dpdk-dev] [PATCH 2/4] common/cnxk: support custom pre L2 header parsing as raw Date: Mon, 3 Jan 2022 11:27:07 +0530 Message-ID: <20220103055709.82768-2-psatheesh@marvell.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20220103055709.82768-1-psatheesh@marvell.com> References: <20220103055709.82768-1-psatheesh@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: sM6l7BBVfbIkPKG-0D0izJlIt8Ujme4T X-Proofpoint-ORIG-GUID: sM6l7BBVfbIkPKG-0D0izJlIt8Ujme4T X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-03_02,2022-01-01_01,2021-12-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Kiran Kumar K 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. ci: skip_klocwork Signed-off-by: Kiran Kumar K Change-Id: I2840244715e2c849e8b96145dc1b642dd8e3583b Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/65070 Tested-by: sa_ip-toolkits-Jenkins Reviewed-by: Satheesh Paul Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/67030 Tested-by: Jerin Jacob Kollanukkaran --- 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