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 39DB942909 for ; Mon, 10 Apr 2023 07:46:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 142BD40DDC; Mon, 10 Apr 2023 07:46:35 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 14C5D40A81 for ; Mon, 10 Apr 2023 07:46:33 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 339NW14B013920 for ; Sun, 9 Apr 2023 22:46:33 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=WmRbbUGtyqDHYxphxoZ2tPtiAPEbB/8rE83BPo+a0os=; b=kSBwhnd+beBCvfG+xS5GhJRL91Bo3zqZI+q/0oAftdCnS3SQxj6ZvlVIxklIpCf2bHru G3dcia9sfYbaz+zeIkOaJ6HWv2gxgQ7aiQtimenTZqosgNyP0gX+6jBJMOpXQu4ccK0D nJTLUqUvDKJdA6XN8AgVye9s2+r7hIbbZ4nCJf5m1ljfL2Oq8bgPjc5kixCC1uLTtFqd mOb+FfdCVpRwrqKm0iO3x2OeJ+CU4+Ns0GaJZ3gvTBYtyPcKYxOhsfiMu65zn7lGrfA1 2IekjoOvq0jl6bGuvvtMa4VFNT6hPXv1vGJ/+6D1fGQhc7w6kZgkM/L04NPLATKWKQVB 3g== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3purfs3ef0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 09 Apr 2023 22:46:33 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sun, 9 Apr 2023 22:46:30 -0700 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.48 via Frontend Transport; Sun, 9 Apr 2023 22:46:30 -0700 Received: from satheeshpaullabpc.. (unknown [10.28.34.33]) by maili.marvell.com (Postfix) with ESMTP id C05693F704A; Sun, 9 Apr 2023 22:46:28 -0700 (PDT) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , Satheesh Paul Subject: [PATCH 22.11] common/cnxk: fix IPv6 extension header parsing Date: Mon, 10 Apr 2023 11:16:25 +0530 Message-ID: <20230410054625.1363658-1-psatheesh@marvell.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: PyBHXC5K6qqDkjcKGKHMXrP1owW04PIq X-Proofpoint-GUID: PyBHXC5K6qqDkjcKGKHMXrP1owW04PIq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-10_02,2023-04-06_03,2023-02-09_01 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org From: Satheesh Paul [ upstream commit 0a6a4437631de7b41352326123b366f31cf7d0f7 ] RTE_FLOW_ITEM_TYPE_IPV6_EXT and RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT pattern items can be specified following a RTE_FLOW_ITEM_TYPE_IPV6. Modified layer C parsing logic to handle this. Fixes: a800675b06f9 ("net/cnxk: support IPv6 fragment flow pattern item") Signed-off-by: Satheesh Paul --- drivers/common/cnxk/roc_npc.h | 11 +++ drivers/common/cnxk/roc_npc_parse.c | 143 +++++++++++++++++++++++----- 2 files changed, 130 insertions(+), 24 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 1b4e5521cb..60f9c5d634 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -123,6 +123,17 @@ struct roc_ipv6_hdr { uint8_t dst_addr[16]; /**< IP address of destination host(s). */ } __plt_packed; +struct roc_ipv6_fragment_ext { + uint8_t next_header; /**< Next header type */ + uint8_t reserved; /**< Reserved */ + uint16_t frag_data; /**< All fragmentation data */ + uint32_t id; /**< Packet ID */ +} __plt_packed; + +struct roc_flow_item_ipv6_ext { + uint8_t next_hdr; /**< Next header. */ +}; + struct roc_npc_flow_item_ipv6 { struct roc_ipv6_hdr hdr; /**< IPv6 header definition. */ uint32_t has_hop_ext : 1; diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 670f920117..6d834aae11 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -662,10 +662,125 @@ npc_handle_ipv6ext_attr(const struct roc_npc_flow_item_ipv6 *ipv6_spec, return 0; } +static int +npc_process_ipv6_item(struct npc_parse_state *pst) +{ + uint8_t ipv6_hdr_mask[sizeof(struct roc_ipv6_hdr) + sizeof(struct roc_ipv6_fragment_ext)]; + uint8_t ipv6_hdr_buf[sizeof(struct roc_ipv6_hdr) + sizeof(struct roc_ipv6_fragment_ext)]; + const struct roc_npc_flow_item_ipv6 *ipv6_spec, *ipv6_mask; + const struct roc_npc_item_info *pattern = pst->pattern; + int offset = 0, rc = 0, lid, item_count = 0; + struct npc_parse_item_info parse_info; + char hw_mask[NPC_MAX_EXTRACT_HW_LEN]; + uint8_t flags = 0, ltype; + + memset(ipv6_hdr_buf, 0, sizeof(ipv6_hdr_buf)); + memset(ipv6_hdr_mask, 0, sizeof(ipv6_hdr_mask)); + + ipv6_spec = pst->pattern->spec; + ipv6_mask = pst->pattern->mask; + + parse_info.def_mask = NULL; + parse_info.spec = ipv6_hdr_buf; + parse_info.mask = ipv6_hdr_mask; + parse_info.def_mask = NULL; + parse_info.hw_hdr_len = 0; + parse_info.len = sizeof(ipv6_spec->hdr); + + pst->set_ipv6ext_ltype_mask = true; + + lid = NPC_LID_LC; + ltype = NPC_LT_LC_IP6; + + if (pattern->type == ROC_NPC_ITEM_TYPE_IPV6) { + item_count++; + if (ipv6_spec) { + memcpy(ipv6_hdr_buf, &ipv6_spec->hdr, sizeof(struct roc_ipv6_hdr)); + rc = npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); + if (rc) + return rc; + } + if (ipv6_mask) + memcpy(ipv6_hdr_mask, &ipv6_mask->hdr, sizeof(struct roc_ipv6_hdr)); + } + + offset = sizeof(struct roc_ipv6_hdr); + + while (pattern->type != ROC_NPC_ITEM_TYPE_END) { + /* Don't support ranges */ + if (pattern->last != NULL) + return NPC_ERR_INVALID_RANGE; + + /* If spec is NULL, both mask and last must be NULL, this + * makes it to match ANY value (eq to mask = 0). + * Setting either mask or last without spec is + * an error + */ + if (pattern->spec == NULL) { + if (pattern->last != NULL && pattern->mask != NULL) + return NPC_ERR_INVALID_SPEC; + } + /* Either one ROC_NPC_ITEM_TYPE_IPV6_EXT or + * one ROC_NPC_ITEM_TYPE_IPV6_FRAG_EXT is supported + * following an ROC_NPC_ITEM_TYPE_IPV6 item. + */ + if (pattern->type == ROC_NPC_ITEM_TYPE_IPV6_EXT) { + item_count++; + ltype = NPC_LT_LC_IP6_EXT; + parse_info.len = + sizeof(struct roc_ipv6_hdr) + sizeof(struct roc_flow_item_ipv6_ext); + if (pattern->spec) + memcpy(ipv6_hdr_buf + offset, pattern->spec, + sizeof(struct roc_flow_item_ipv6_ext)); + if (pattern->mask) + memcpy(ipv6_hdr_mask + offset, pattern->mask, + sizeof(struct roc_flow_item_ipv6_ext)); + break; + } else if (pattern->type == ROC_NPC_ITEM_TYPE_IPV6_FRAG_EXT) { + item_count++; + ltype = NPC_LT_LC_IP6_EXT; + flags = NPC_F_LC_U_IP6_FRAG; + parse_info.len = + sizeof(struct roc_ipv6_hdr) + sizeof(struct roc_ipv6_fragment_ext); + if (pattern->spec) + memcpy(ipv6_hdr_buf + offset, pattern->spec, + sizeof(struct roc_ipv6_fragment_ext)); + if (pattern->mask) + memcpy(ipv6_hdr_mask + offset, pattern->mask, + sizeof(struct roc_ipv6_fragment_ext)); + + break; + } + + pattern++; + pattern = npc_parse_skip_void_and_any_items(pattern); + } + + memset(hw_mask, 0, sizeof(hw_mask)); + + parse_info.hw_mask = &hw_mask; + npc_get_hw_supp_mask(pst, &parse_info, lid, ltype); + + rc = npc_mask_is_supported(parse_info.mask, parse_info.hw_mask, parse_info.len); + if (!rc) + return NPC_ERR_INVALID_MASK; + + rc = npc_update_parse_state(pst, &parse_info, lid, ltype, flags); + if (rc) + return rc; + + /* npc_update_parse_state() increments pattern once. + * Check if additional increment is required. + */ + if (item_count == 2) + pst->pattern++; + + return 0; +} + int npc_parse_lc(struct npc_parse_state *pst) { - const struct roc_npc_flow_item_ipv6 *ipv6_spec; const struct roc_npc_flow_item_raw *raw_spec; uint8_t raw_spec_buf[NPC_MAX_RAW_ITEM_LEN]; uint8_t raw_mask_buf[NPC_MAX_RAW_ITEM_LEN]; @@ -690,32 +805,12 @@ npc_parse_lc(struct npc_parse_state *pst) info.len = pst->pattern->size; break; case ROC_NPC_ITEM_TYPE_IPV6: - ipv6_spec = pst->pattern->spec; - lid = NPC_LID_LC; - lt = NPC_LT_LC_IP6; - if (ipv6_spec) { - rc = npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); - if (rc) - return rc; - } - info.len = sizeof(ipv6_spec->hdr); - break; - case ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4: - lt = NPC_LT_LC_ARP; - info.len = pst->pattern->size; - break; case ROC_NPC_ITEM_TYPE_IPV6_EXT: - lid = NPC_LID_LC; - lt = NPC_LT_LC_IP6_EXT; - info.len = pst->pattern->size; - info.hw_hdr_len = 40; - break; case ROC_NPC_ITEM_TYPE_IPV6_FRAG_EXT: - lid = NPC_LID_LC; - lt = NPC_LT_LC_IP6_EXT; - flags = NPC_F_LC_U_IP6_FRAG; + return npc_process_ipv6_item(pst); + case ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4: + lt = NPC_LT_LC_ARP; info.len = pst->pattern->size; - info.hw_hdr_len = 40; break; case ROC_NPC_ITEM_TYPE_L3_CUSTOM: lt = NPC_LT_LC_CUSTOM0; -- 2.39.2