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 9D44341DC9 for ; Fri, 3 Mar 2023 15:50:21 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8A3EE427E9; Fri, 3 Mar 2023 15:50:21 +0100 (CET) Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by mails.dpdk.org (Postfix) with ESMTP id 485C240ED9; Fri, 3 Mar 2023 15:50:19 +0100 (CET) Received: by mail-vs1-f49.google.com with SMTP id o32so2557705vsv.12; Fri, 03 Mar 2023 06:50:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/0L99flhlL2UWhDRw7IDJy6hUHqf0hB7L0q6kP4eRHQ=; b=ks9kwN/+UsaMJG8+/H4GrtHSsjxA23ozJETVI1dJNNkhhepf8uWwzPhf6+GHSYWhjO VCAlqi4QaV+nwzgU5ujRc+0Vkm3O0ExbJMv0rMgrLOW61bZqrIVvxFtiTHHxZXnrj+Rt Gj30s2RpNjaMFncnCqY2q5KZgI4JfIkkn/3LJGxPvegopEriX/PKucHsSZPIRjMDnQp7 6zqedhyU9o2zEKVjZII4awCK2o/wNlHO55rry6sjfI+ZThaAcHUeGVlNOBJcrisnKlb4 qpJCzSCIOx8viIAafyGmHYTCo8pSSdWzf5rMOszljLbdQ4ZoEDkV9FlGNcXZAErwammK RrQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/0L99flhlL2UWhDRw7IDJy6hUHqf0hB7L0q6kP4eRHQ=; b=WWME2bCY9KNpcIT/DhotbdCfUrXdnBM3d9iY8mNOkhEFFy0hJUYZ9PCbn/QRL7Q/1Y Phd5t/HqV34pQz9OaemC5qmd8SKfFCHHP0MChpA1c+4hRT6bMX+or0+gdpeiW1vikmyj TiXtQb4gYJ54o/h3y7n+DQPUK1MAw8s5GfP+0RtRqJKGGrerC5EfjnfEh6z8wfctbFG+ OvTOd8pRadRXAo27je0qhf6fWDhLpgnhAi3gANvDhSpjBcc/l62OipxxJ+xPR8eW59dB dsuh7vTyDTnKTV+uzi9+f+QE/KOAjeRSbN8fcAnKXZQJao35/CdaQ6fd9t+oCjMpdrh0 OyVQ== X-Gm-Message-State: AO0yUKVKYtBI7tIAUmOF9OFvqw39ne3lAdNaULPF2aqoAvdTaLhkLNsM TEk75cWSOJnGShOC71GzF9rCaDEbpUJvO40Z8vk= X-Google-Smtp-Source: AK7set8U2ZMEJazpRwzDlHJukR+JC4X7bADObB4ZLxnLx3YQUMXM7rsmTalt8SsNfJNRynFxs7W1IVd99PArd1PbqpM= X-Received: by 2002:a67:1a87:0:b0:415:2063:e403 with SMTP id a129-20020a671a87000000b004152063e403mr1340758vsa.3.1677855018418; Fri, 03 Mar 2023 06:50:18 -0800 (PST) MIME-Version: 1.0 References: <20230222040452.3751925-1-psatheesh@marvell.com> In-Reply-To: <20230222040452.3751925-1-psatheesh@marvell.com> From: Jerin Jacob Date: Fri, 3 Mar 2023 20:19:52 +0530 Message-ID: Subject: Re: [dpdk-dev] [PATCH] common/cnxk: fix IPv6 extension header parsing To: psatheesh@marvell.com Cc: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , dev@dpdk.org, stable@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, Feb 22, 2023 at 9:35=E2=80=AFAM wrote: > > From: Satheesh Paul > > 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") > Cc: stable@dpdk.org > > Signed-off-by: Satheesh Paul > Reviewed-by: Kiran Kumar K Applied to dpdk-next-net-mrvl/for-next-net. Thanks > --- > drivers/common/cnxk/roc_npc.h | 11 ++ > drivers/common/cnxk/roc_npc_parse.c | 150 ++++++++++++++++++++-------- > drivers/common/cnxk/roc_npc_priv.h | 2 +- > drivers/common/cnxk/roc_npc_utils.c | 4 +- > 4 files changed, 123 insertions(+), 44 deletions(-) > > diff --git a/drivers/common/cnxk/roc_npc.h b/drivers/common/cnxk/roc_npc.= h > index cea627e16c..5e07e26a91 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/ro= c_npc_parse.c > index 085fb4618f..f746b9cb6d 100644 > --- a/drivers/common/cnxk/roc_npc_parse.c > +++ b/drivers/common/cnxk/roc_npc_parse.c > @@ -664,41 +664,123 @@ npc_handle_ipv6ext_attr(const struct roc_npc_flow_= item_ipv6 *ipv6_spec, > } > > static int > -npc_process_ipv6_item(const struct roc_npc_flow_item_ipv6 *ipv6_spec, > - const struct roc_npc_flow_item_ipv6 *ipv6_mask, str= uct npc_parse_state *pst) > +npc_process_ipv6_item(struct npc_parse_state *pst) > { > - uint8_t hw_mask[NPC_MAX_EXTRACT_HW_LEN]; > - struct npc_parse_item_info info; > - int rc, lid, lt; > - uint8_t flags =3D 0; > + 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 =3D pst->pattern; > + int offset =3D 0, rc =3D 0, lid, item_count =3D 0; > + struct npc_parse_item_info parse_info; > + char hw_mask[NPC_MAX_EXTRACT_HW_LEN]; > + uint8_t flags =3D 0, ltype; > + > + memset(ipv6_hdr_buf, 0, sizeof(ipv6_hdr_buf)); > + memset(ipv6_hdr_mask, 0, sizeof(ipv6_hdr_mask)); > + > + ipv6_spec =3D pst->pattern->spec; > + ipv6_mask =3D pst->pattern->mask; > + > + parse_info.def_mask =3D NULL; > + parse_info.spec =3D ipv6_hdr_buf; > + parse_info.mask =3D ipv6_hdr_mask; > + parse_info.def_mask =3D NULL; > + parse_info.hw_hdr_len =3D 0; > + parse_info.len =3D sizeof(ipv6_spec->hdr); > + > + pst->set_ipv6ext_ltype_mask =3D true; > > - info.def_mask =3D NULL; > - info.hw_mask =3D &hw_mask; > - info.spec =3D NULL; > - info.mask =3D NULL; > - info.hw_hdr_len =3D 0; > lid =3D NPC_LID_LC; > + ltype =3D NPC_LT_LC_IP6; > + > + if (pattern->type =3D=3D ROC_NPC_ITEM_TYPE_IPV6) { > + item_count++; > + if (ipv6_spec) { > + memcpy(ipv6_hdr_buf, &ipv6_spec->hdr, sizeof(stru= ct roc_ipv6_hdr)); > + rc =3D npc_handle_ipv6ext_attr(ipv6_spec, pst, &f= lags); > + if (rc) > + return rc; > + } > + if (ipv6_mask) > + memcpy(ipv6_hdr_mask, &ipv6_mask->hdr, sizeof(str= uct roc_ipv6_hdr)); > + } > > - lt =3D NPC_LT_LC_IP6; > - if (ipv6_spec) { > - rc =3D npc_handle_ipv6ext_attr(ipv6_spec, pst, &flags); > - if (rc) > - return rc; > + offset =3D sizeof(struct roc_ipv6_hdr); > + > + while (pattern->type !=3D ROC_NPC_ITEM_TYPE_END) { > + /* Don't support ranges */ > + if (pattern->last !=3D 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 =3D 0). > + * Setting either mask or last without spec is > + * an error > + */ > + if (pattern->spec =3D=3D NULL) { > + if (pattern->last !=3D NULL && pattern->mask !=3D= 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 =3D=3D ROC_NPC_ITEM_TYPE_IPV6_EXT) { > + item_count++; > + ltype =3D NPC_LT_LC_IP6_EXT; > + parse_info.len =3D > + sizeof(struct roc_ipv6_hdr) + sizeof(stru= ct roc_flow_item_ipv6_ext); > + if (pattern->spec) > + memcpy(ipv6_hdr_buf + offset, pattern->sp= ec, > + sizeof(struct roc_flow_item_ipv6_e= xt)); > + if (pattern->mask) > + memcpy(ipv6_hdr_mask + offset, pattern->m= ask, > + sizeof(struct roc_flow_item_ipv6_e= xt)); > + break; > + } else if (pattern->type =3D=3D ROC_NPC_ITEM_TYPE_IPV6_FR= AG_EXT) { > + item_count++; > + ltype =3D NPC_LT_LC_IP6_EXT; > + flags =3D NPC_F_LC_U_IP6_FRAG; > + parse_info.len =3D > + sizeof(struct roc_ipv6_hdr) + sizeof(stru= ct roc_ipv6_fragment_ext); > + if (pattern->spec) > + memcpy(ipv6_hdr_buf + offset, pattern->sp= ec, > + sizeof(struct roc_ipv6_fragment_ex= t)); > + if (pattern->mask) > + memcpy(ipv6_hdr_mask + offset, pattern->m= ask, > + sizeof(struct roc_ipv6_fragment_ex= t)); > + > + break; > + } > + > + pattern++; > + pattern =3D npc_parse_skip_void_and_any_items(pattern); > } > - info.len =3D sizeof(ipv6_spec->hdr); > > - npc_get_hw_supp_mask(pst, &info, lid, lt); > - rc =3D npc_parse_item_basic(pst->pattern, &info); > + memset(hw_mask, 0, sizeof(hw_mask)); > > - if (rc !=3D 0) > - return rc; > + parse_info.hw_mask =3D &hw_mask; > + npc_get_hw_supp_mask(pst, &parse_info, lid, ltype); > + > + rc =3D npc_mask_is_supported(parse_info.mask, parse_info.hw_mask,= parse_info.len); > + if (!rc) > + return NPC_ERR_INVALID_MASK; > > - rc =3D npc_update_parse_state(pst, &info, lid, lt, flags); > + rc =3D npc_update_parse_state(pst, &parse_info, lid, ltype, flags= ); > if (rc) > return rc; > > - if (pst->npc->hash_extract_cap) > - return npc_process_ipv6_field_hash(ipv6_spec, ipv6_mask, = pst); > + if (pst->npc->hash_extract_cap) { > + rc =3D npc_process_ipv6_field_hash(parse_info.spec, parse= _info.mask, pst, ltype); > + if (rc) > + return rc; > + } > + > + /* npc_update_parse_state() increments pattern once. > + * Check if additional increment is required. > + */ > + if (item_count =3D=3D 2) > + pst->pattern++; > > return 0; > } > @@ -706,7 +788,6 @@ npc_process_ipv6_item(const struct roc_npc_flow_item_= ipv6 *ipv6_spec, > int > npc_parse_lc(struct npc_parse_state *pst) > { > - const struct roc_npc_flow_item_ipv6 *ipv6_spec, *ipv6_mask; > 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]; > @@ -731,25 +812,12 @@ npc_parse_lc(struct npc_parse_state *pst) > info.len =3D pst->pattern->size; > break; > case ROC_NPC_ITEM_TYPE_IPV6: > - ipv6_spec =3D pst->pattern->spec; > - ipv6_mask =3D pst->pattern->mask; > - return npc_process_ipv6_item(ipv6_spec, ipv6_mask, pst); > - case ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4: > - lt =3D NPC_LT_LC_ARP; > - info.len =3D pst->pattern->size; > - break; > case ROC_NPC_ITEM_TYPE_IPV6_EXT: > - lid =3D NPC_LID_LC; > - lt =3D NPC_LT_LC_IP6_EXT; > - info.len =3D pst->pattern->size; > - info.hw_hdr_len =3D 40; > - break; > case ROC_NPC_ITEM_TYPE_IPV6_FRAG_EXT: > - lid =3D NPC_LID_LC; > - lt =3D NPC_LT_LC_IP6_EXT; > - flags =3D NPC_F_LC_U_IP6_FRAG; > + return npc_process_ipv6_item(pst); > + case ROC_NPC_ITEM_TYPE_ARP_ETH_IPV4: > + lt =3D NPC_LT_LC_ARP; > info.len =3D pst->pattern->size; > - info.hw_hdr_len =3D 40; > break; > case ROC_NPC_ITEM_TYPE_L3_CUSTOM: > lt =3D NPC_LT_LC_CUSTOM0; > diff --git a/drivers/common/cnxk/roc_npc_priv.h b/drivers/common/cnxk/roc= _npc_priv.h > index 9c21934add..08d763eeb4 100644 > --- a/drivers/common/cnxk/roc_npc_priv.h > +++ b/drivers/common/cnxk/roc_npc_priv.h > @@ -466,7 +466,7 @@ int npc_program_mcam(struct npc *npc, struct npc_pars= e_state *pst, bool mcam_all > uint64_t npc_get_kex_capability(struct npc *npc); > int npc_process_ipv6_field_hash(const struct roc_npc_flow_item_ipv6 *ipv= 6_spec, > const struct roc_npc_flow_item_ipv6 *ipv6= _mask, > - struct npc_parse_state *pst); > + struct npc_parse_state *pst, uint8_t type= ); > int npc_rss_free_grp_get(struct npc *npc, uint32_t *grp); > int npc_rss_action_configure(struct roc_npc *roc_npc, const struct roc_n= pc_action_rss *rss, > uint8_t *alg_idx, uint32_t *rss_grp, uint32_= t mcam_id); > diff --git a/drivers/common/cnxk/roc_npc_utils.c b/drivers/common/cnxk/ro= c_npc_utils.c > index f4f9cc0916..a507df994f 100644 > --- a/drivers/common/cnxk/roc_npc_utils.c > +++ b/drivers/common/cnxk/roc_npc_utils.c > @@ -384,7 +384,7 @@ npc_hash_field_get(struct npc_xtract_info *xinfo, con= st struct roc_npc_flow_item > int > npc_process_ipv6_field_hash(const struct roc_npc_flow_item_ipv6 *ipv6_sp= ec, > const struct roc_npc_flow_item_ipv6 *ipv6_mas= k, > - struct npc_parse_state *pst) > + struct npc_parse_state *pst, uint8_t ltype) > { > struct npc_lid_lt_xtract_info *lid_lt_xinfo; > uint8_t hash_field[ROC_IPV6_ADDR_LEN]; > @@ -397,7 +397,7 @@ npc_process_ipv6_field_hash(const struct roc_npc_flow= _item_ipv6 *ipv6_spec, > memset(hash_field, 0, sizeof(hash_field)); > > intf =3D pst->nix_intf; > - lid_lt_xinfo =3D &pst->npc->prx_dxcfg[intf][NPC_LID_LC][NPC_LT_LC= _IP6]; > + lid_lt_xinfo =3D &pst->npc->prx_dxcfg[intf][NPC_LID_LC][ltype]; > > for (i =3D 0; i < NPC_MAX_LD; i++) { > xinfo =3D &lid_lt_xinfo->xtract[i]; > -- > 2.35.3 >