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 8507CA0350; Mon, 3 Jan 2022 06:57:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5CFC74114F; Mon, 3 Jan 2022 06:57:42 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id CE3D14003C 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 202MENtu027084 for ; Sun, 2 Jan 2022 21:57:38 -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=x0eB4SZ8coiWYT6JO8a3SjyFlZbOnzW7EqjxjnbnpBM=; b=R3sfqW141UkcxUeddrXNnpNSnb3ihY2kGTaNbVzmGu3cbZTrvvfgGtd8gAMGfD3IRPJJ L+YU5XrRM9/YGNwSHEPH+kDLxpkUIHsXTNHsb9O9/P0I02TXX0jC8nSqEX+Z24kspwPZ /Ufc48xN8tlhxDrqSVES39EVQ9zpDJjf0ZuFRZO5Bsf+oJOLd1qDrGhX0Pd/Zh4B+Ldy D8OMoW3n897uqO8fDsJakcLrCv5DyamFWvC7VpjubxNU+AUz73XwZfUtSeqwHkhZnz9p mA4iKcZ7SHtQkuULgBm1pYQNinDqJbbdH/wrttWn3jm7f+UlC+HYKsxg6/Wg79uzCMqD CQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3daqbrkxwh-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sun, 02 Jan 2022 21:57:38 -0800 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.18; Sun, 2 Jan 2022 21:57:34 -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:34 -0800 Received: from localhost.localdomain (unknown [10.28.34.33]) by maili.marvell.com (Postfix) with ESMTP id 0690F3F7051; Sun, 2 Jan 2022 21:57:31 -0800 (PST) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao CC: , Satheesh Paul , sa_ip-toolkits-Jenkins Subject: [dpdk-dev] [PATCH 4/4] common/cnxk: support extensions attributes in IPv6 item Date: Mon, 3 Jan 2022 11:27:09 +0530 Message-ID: <20220103055709.82768-4-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: VIR5ZcZyIG32K7nl8Zg_0d_T8LC1tIbV X-Proofpoint-ORIG-GUID: VIR5ZcZyIG32K7nl8Zg_0d_T8LC1tIbV 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: Satheesh Paul Support matching existence of specific extension headers after RTE_FLOW_ITEM_TYPE_IPV6 item. Signed-off-by: Satheesh Paul Change-Id: I8c7d58af242d6d991b718787a6c9b8e79c6ff409 Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/66900 Tested-by: sa_ip-toolkits-Jenkins Reviewed-by: Kiran Kumar Kokkilagadda Reviewed-on: https://sj1git1.cavium.com/c/IP/SW/dataplane/dpdk/+/67409 --- drivers/common/cnxk/hw/npc.h | 17 ++++++++ drivers/common/cnxk/roc_npc.h | 33 +++++++++++++++ drivers/common/cnxk/roc_npc_mcam.c | 47 ++++++++++++++++++++- drivers/common/cnxk/roc_npc_parse.c | 65 +++++++++++++++++++++++++++-- drivers/common/cnxk/roc_npc_priv.h | 6 +++ 5 files changed, 162 insertions(+), 6 deletions(-) diff --git a/drivers/common/cnxk/hw/npc.h b/drivers/common/cnxk/hw/npc.h index 6f896de9f0..b8218e25af 100644 --- a/drivers/common/cnxk/hw/npc.h +++ b/drivers/common/cnxk/hw/npc.h @@ -320,6 +320,23 @@ enum npc_kpu_lc_uflag { NPC_F_LC_U_IP6_FRAG = 0x40, }; +enum npc_kpu_lc_lflag { + NPC_F_LC_L_IP_IN_IP = 1, + NPC_F_LC_L_6TO4, + NPC_F_LC_L_MPLS_IN_IP, + NPC_F_LC_L_IP6_TUN_IP6, + NPC_F_LC_L_IP6_MPLS_IN_IP, + NPC_F_LC_L_MPLS_4_LABELS, + NPC_F_LC_L_MPLS_3_LABELS, + NPC_F_LC_L_MPLS_2_LABELS, + NPC_F_LC_L_EXT_HOP, + NPC_F_LC_L_EXT_DEST, + NPC_F_LC_L_EXT_ROUT, + NPC_F_LC_L_EXT_MOBILITY, + NPC_F_LC_L_EXT_HOSTID, + NPC_F_LC_L_EXT_SHIM6, +}; + /* Structures definitions */ struct npc_kpu_profile_cam { uint8_t state; diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.h index 634c67e6f6..2098810ee3 100644 --- a/drivers/common/cnxk/roc_npc.h +++ b/drivers/common/cnxk/roc_npc.h @@ -112,6 +112,39 @@ struct roc_npc_flow_item_vlan { uint32_t reserved : 31; /**< Reserved, must be zero. */ }; +struct roc_ipv6_hdr { + uint32_t vtc_flow; /**< IP version, traffic class & flow label. */ + uint16_t payload_len; /**< IP payload size, including ext. headers */ + uint8_t proto; /**< Protocol, next header. */ + uint8_t hop_limits; /**< Hop limits. */ + uint8_t src_addr[16]; /**< IP address of source host. */ + uint8_t dst_addr[16]; /**< IP address of destination host(s). */ +} __plt_packed; + +struct roc_npc_flow_item_ipv6 { + struct roc_ipv6_hdr hdr; /**< IPv6 header definition. */ + uint32_t has_hop_ext : 1; + /**< Header contains Hop-by-Hop Options extension header. */ + uint32_t has_route_ext : 1; + /**< Header contains Routing extension header. */ + uint32_t has_frag_ext : 1; + /**< Header contains Fragment extension header. */ + uint32_t has_auth_ext : 1; + /**< Header contains Authentication extension header. */ + uint32_t has_esp_ext : 1; + /**< Header contains Encapsulation Security Payload extension header. */ + uint32_t has_dest_ext : 1; + /**< Header contains Destination Options extension header. */ + uint32_t has_mobil_ext : 1; + /**< Header contains Mobility extension header. */ + uint32_t has_hip_ext : 1; + /**< Header contains Host Identity Protocol extension header. */ + uint32_t has_shim6_ext : 1; + /**< Header contains Shim6 Protocol extension header. */ + uint32_t reserved : 23; + /**< Reserved for future extension headers, must be zero. */ +}; + #define ROC_NPC_MAX_ACTION_COUNT 19 enum roc_npc_action_type { diff --git a/drivers/common/cnxk/roc_npc_mcam.c b/drivers/common/cnxk/roc_npc_mcam.c index 2349317c5c..da5815ada0 100644 --- a/drivers/common/cnxk/roc_npc_mcam.c +++ b/drivers/common/cnxk/roc_npc_mcam.c @@ -283,8 +283,8 @@ npc_get_kex_capability(struct npc *npc) /* Custom L3 frame: varied offset and lengths */ kex_cap.bit.custom_l3 = npc_is_kex_enabled(npc, NPC_LID_LC, NPC_LT_LC_CUSTOM0, 0, 0); - kex_cap.bit.custom_l3 |= - npc_is_kex_enabled(npc, NPC_LID_LC, NPC_LT_LC_CUSTOM1, 0, 0); + kex_cap.bit.custom_l3 |= (uint64_t)npc_is_kex_enabled( + npc, NPC_LID_LC, NPC_LT_LC_CUSTOM1, 0, 0); /* SCTP sport : offset 0B, len 2B */ kex_cap.bit.sctp_sport = npc_is_kex_enabled( npc, NPC_LID_LD, NPC_LT_LD_SCTP, 0 * 8, 2 * 8); @@ -635,6 +635,46 @@ npc_set_vlan_ltype(struct npc_parse_state *pst) pst->flow->mcam_mask[0] |= (0xeULL << lb_offset); } +static void +npc_set_ipv6ext_ltype_mask(struct npc_parse_state *pst) +{ + uint8_t lc_offset, lcflag_offset; + uint64_t val, mask; + + lc_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LTYPE_LC_OFFSET) - 1)); + lc_offset *= 4; + + mask = ~((0xfULL << lc_offset)); + pst->flow->mcam_data[0] &= mask; + pst->flow->mcam_mask[0] &= mask; + /* NPC_LT_LC_IP6: 0b0100, NPC_LT_LC_IP6_EXT: 0b0101 + * Set LC layertype/mask as 0b0100/0b1110 to match both. + */ + val = ((uint64_t)(NPC_LT_LC_IP6 & NPC_LT_LC_IP6_EXT)) << lc_offset; + pst->flow->mcam_data[0] |= val; + pst->flow->mcam_mask[0] |= (0xeULL << lc_offset); + + /* If LC LFLAG is non-zero, set the LC LFLAG mask to 0xF. In general + * case flag mask is set same as the value in data. For example, to + * match 3 VLANs, flags have to match a range of values. But, for IPv6 + * extended attributes matching, we need an exact match. Hence, set the + * mask as 0xF. This is done only if LC LFLAG value is non-zero, + * because for AH and ESP, LC LFLAG is zero and we don't want to match + * zero in LFLAG. + */ + lcflag_offset = + __builtin_popcount(pst->npc->keyx_supp_nmask[pst->nix_intf] & + ((1ULL << NPC_LFLAG_LC_OFFSET) - 1)); + lcflag_offset *= 4; + + mask = (0xfULL << lcflag_offset); + val = pst->flow->mcam_data[0] & mask; + if (val) + pst->flow->mcam_mask[0] |= mask; +} + int npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) { @@ -709,6 +749,9 @@ npc_program_mcam(struct npc *npc, struct npc_parse_state *pst, bool mcam_alloc) if (pst->set_vlan_ltype_mask) npc_set_vlan_ltype(pst); + if (pst->set_ipv6ext_ltype_mask) + npc_set_ipv6ext_ltype_mask(pst); + if (pst->is_vf) { (void)mbox_alloc_msg_npc_read_base_steer_rule(npc->mbox); rc = mbox_process_msg(npc->mbox, (void *)&base_rule_rsp); diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 75724661da..1f21693369 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -480,16 +480,69 @@ npc_check_lc_ip_tunnel(struct npc_parse_state *pst) pst->tunnel = 1; } +static int +npc_handle_ipv6ext_attr(const struct roc_npc_flow_item_ipv6 *ipv6_spec, + struct npc_parse_state *pst, uint8_t *flags) +{ + int flags_count = 0; + + if (ipv6_spec->has_hop_ext) { + *flags = NPC_F_LC_L_EXT_HOP; + flags_count++; + } + if (ipv6_spec->has_route_ext) { + *flags = NPC_F_LC_L_EXT_ROUT; + flags_count++; + } + if (ipv6_spec->has_frag_ext) { + *flags = NPC_F_LC_U_IP6_FRAG; + flags_count++; + } + if (ipv6_spec->has_dest_ext) { + *flags = NPC_F_LC_L_EXT_DEST; + flags_count++; + } + if (ipv6_spec->has_mobil_ext) { + *flags = NPC_F_LC_L_EXT_MOBILITY; + flags_count++; + } + if (ipv6_spec->has_hip_ext) { + *flags = NPC_F_LC_L_EXT_HOSTID; + flags_count++; + } + if (ipv6_spec->has_shim6_ext) { + *flags = NPC_F_LC_L_EXT_SHIM6; + flags_count++; + } + if (ipv6_spec->has_auth_ext) { + pst->lt[NPC_LID_LD] = NPC_LT_LD_AH; + flags_count++; + } + if (ipv6_spec->has_esp_ext) { + pst->lt[NPC_LID_LE] = NPC_LT_LE_ESP; + flags_count++; + } + + if (flags_count > 1) + return -EINVAL; + + if (flags_count) + pst->set_ipv6ext_ltype_mask = true; + + 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]; uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN]; struct npc_parse_item_info info; - int lid, lt, len = 0; - int rc; + int rc, lid, lt, len = 0; + uint8_t flags = 0; if (pst->pattern->type == ROC_NPC_ITEM_TYPE_MPLS) return npc_parse_mpls(pst, NPC_LID_LC); @@ -506,9 +559,13 @@ 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; - info.len = pst->pattern->size; + 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; @@ -558,7 +615,7 @@ npc_parse_lc(struct npc_parse_state *pst) if (rc != 0) return rc; - return npc_update_parse_state(pst, &info, lid, lt, 0); + return npc_update_parse_state(pst, &info, lid, lt, flags); } int diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc_npc_priv.h index ef7985f4cf..44d61ba641 100644 --- a/drivers/common/cnxk/roc_npc_priv.h +++ b/drivers/common/cnxk/roc_npc_priv.h @@ -71,6 +71,11 @@ /* LB OFFSET : START + LA (2b flags + 1b ltype) + LB (2b flags) */ #define NPC_LTYPE_LB_OFFSET (NPC_LTYPE_OFFSET_START + 5) #define NPC_LFLAG_LB_OFFSET (NPC_LTYPE_OFFSET_START + 3) +/* LC OFFSET : START + LA (2b flags + 1b ltype) + LB (2b flags + 1b ltype) + LC + * (2b flags) + */ +#define NPC_LFLAG_LC_OFFSET (NPC_LTYPE_OFFSET_START + 6) +#define NPC_LTYPE_LC_OFFSET (NPC_LTYPE_OFFSET_START + 8) struct npc_action_vtag_info { uint16_t vlan_id; @@ -183,6 +188,7 @@ struct npc_parse_state { bool is_vf; /* adjust ltype in MCAM to match at least one vlan */ bool set_vlan_ltype_mask; + bool set_ipv6ext_ltype_mask; }; enum npc_kpu_parser_flag { -- 2.25.4