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 B712B45B37; Mon, 14 Oct 2024 14:04:52 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A6BFD40E44; Mon, 14 Oct 2024 14:02:09 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id BEA2A40A7A for ; Mon, 14 Oct 2024 14:01:41 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9803E200966; Mon, 14 Oct 2024 14:01:41 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 58979200744; Mon, 14 Oct 2024 14:01:41 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id BFCC2183DC02; Mon, 14 Oct 2024 20:01:40 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena Cc: Jun Yang Subject: [v3 31/43] net/dpaa2: add GTP flow support Date: Mon, 14 Oct 2024 17:31:14 +0530 Message-Id: <20241014120126.170790-32-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241014120126.170790-1-vanshika.shukla@nxp.com> References: <20240918075056.1838654-2-vanshika.shukla@nxp.com> <20241014120126.170790-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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: Jun Yang Configure gtp flow to support RSS and FS. Check FAF of parser result to identify GTP frame. Signed-off-by: Jun Yang --- drivers/net/dpaa2/dpaa2_flow.c | 170 ++++++++++++++++++++++++++------- 1 file changed, 137 insertions(+), 33 deletions(-) diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index f64562340c..ce551e8174 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -75,6 +75,7 @@ enum rte_flow_item_type dpaa2_supported_pattern_type[] = { RTE_FLOW_ITEM_TYPE_TCP, RTE_FLOW_ITEM_TYPE_SCTP, RTE_FLOW_ITEM_TYPE_GRE, + RTE_FLOW_ITEM_TYPE_GTP }; static const @@ -163,6 +164,11 @@ static const struct rte_flow_item_ecpri dpaa2_flow_item_ecpri_mask = { .hdr.dummy[1] = RTE_BE32(0xffffffff), .hdr.dummy[2] = RTE_BE32(0xffffffff), }; + +static const struct rte_flow_item_gtp dpaa2_flow_item_gtp_mask = { + .teid = RTE_BE32(0xffffffff), +}; + #endif #define DPAA2_FLOW_DUMP printf @@ -238,6 +244,12 @@ dpaa2_prot_field_string(uint32_t prot, uint32_t field, strcat(string, ".type"); else strcat(string, ".unknown field"); + } else if (prot == NET_PROT_GTP) { + strcpy(string, "gtp"); + if (field == NH_FLD_GTP_TEID) + strcat(string, ".teid"); + else + strcat(string, ".unknown field"); } else { strcpy(string, "unknown protocol"); } @@ -1567,6 +1579,10 @@ dpaa2_flow_extract_support(const uint8_t *mask_src, mask_support = (const char *)&dpaa2_flow_item_ecpri_mask; size = sizeof(struct rte_flow_item_ecpri); break; + case RTE_FLOW_ITEM_TYPE_GTP: + mask_support = (const char *)&dpaa2_flow_item_gtp_mask; + size = sizeof(struct rte_flow_item_gtp); + break; default: return -EINVAL; } @@ -3573,6 +3589,84 @@ dpaa2_configure_flow_ecpri(struct dpaa2_dev_flow *flow, return 0; } +static int +dpaa2_configure_flow_gtp(struct dpaa2_dev_flow *flow, + struct rte_eth_dev *dev, + const struct rte_flow_attr *attr, + const struct rte_dpaa2_flow_item *dpaa2_pattern, + const struct rte_flow_action actions[] __rte_unused, + struct rte_flow_error *error __rte_unused, + int *device_configured) +{ + int ret, local_cfg = 0; + uint32_t group; + const struct rte_flow_item_gtp *spec, *mask; + struct dpaa2_dev_priv *priv = dev->data->dev_private; + const struct rte_flow_item *pattern = + &dpaa2_pattern->generic_item; + + group = attr->group; + + /* Parse pattern list to get the matching parameters */ + spec = pattern->spec; + mask = pattern->mask ? + pattern->mask : &dpaa2_flow_item_gtp_mask; + + /* Get traffic class index and flow id to be configured */ + flow->tc_id = group; + flow->tc_index = attr->priority; + + if (dpaa2_pattern->in_tunnel) { + DPAA2_PMD_ERR("Tunnel-GTP distribution not support"); + return -ENOTSUP; + } + + if (!spec) { + ret = dpaa2_flow_identify_by_faf(priv, flow, + FAF_GTP_FRAM, DPAA2_FLOW_QOS_TYPE, + group, &local_cfg); + if (ret) + return ret; + + ret = dpaa2_flow_identify_by_faf(priv, flow, + FAF_GTP_FRAM, DPAA2_FLOW_FS_TYPE, + group, &local_cfg); + if (ret) + return ret; + + (*device_configured) |= local_cfg; + return 0; + } + + if (dpaa2_flow_extract_support((const uint8_t *)mask, + RTE_FLOW_ITEM_TYPE_GTP)) { + DPAA2_PMD_WARN("Extract field(s) of GTP not support."); + + return -1; + } + + if (!mask->teid) + return 0; + + ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_GTP, + NH_FLD_GTP_TEID, &spec->teid, + &mask->teid, sizeof(rte_be32_t), + priv, group, &local_cfg, DPAA2_FLOW_QOS_TYPE); + if (ret) + return ret; + + ret = dpaa2_flow_add_hdr_extract_rule(flow, NET_PROT_GTP, + NH_FLD_GTP_TEID, &spec->teid, + &mask->teid, sizeof(rte_be32_t), + priv, group, &local_cfg, DPAA2_FLOW_FS_TYPE); + if (ret) + return ret; + + (*device_configured) |= local_cfg; + + return 0; +} + static int dpaa2_configure_flow_raw(struct dpaa2_dev_flow *flow, struct rte_eth_dev *dev, @@ -4107,9 +4201,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, switch (pattern[i].type) { case RTE_FLOW_ITEM_TYPE_ETH: ret = dpaa2_configure_flow_eth(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("ETH flow config failed!"); goto end_flow_set; @@ -4117,9 +4211,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_VLAN: ret = dpaa2_configure_flow_vlan(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("vLan flow config failed!"); goto end_flow_set; @@ -4127,9 +4221,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_IPV4: ret = dpaa2_configure_flow_ipv4(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("IPV4 flow config failed!"); goto end_flow_set; @@ -4137,9 +4231,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_IPV6: ret = dpaa2_configure_flow_ipv6(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("IPV6 flow config failed!"); goto end_flow_set; @@ -4147,9 +4241,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_ICMP: ret = dpaa2_configure_flow_icmp(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("ICMP flow config failed!"); goto end_flow_set; @@ -4157,9 +4251,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_UDP: ret = dpaa2_configure_flow_udp(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("UDP flow config failed!"); goto end_flow_set; @@ -4167,9 +4261,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_TCP: ret = dpaa2_configure_flow_tcp(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("TCP flow config failed!"); goto end_flow_set; @@ -4177,9 +4271,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_SCTP: ret = dpaa2_configure_flow_sctp(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("SCTP flow config failed!"); goto end_flow_set; @@ -4187,9 +4281,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_GRE: ret = dpaa2_configure_flow_gre(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("GRE flow config failed!"); goto end_flow_set; @@ -4197,9 +4291,9 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, break; case RTE_FLOW_ITEM_TYPE_VXLAN: ret = dpaa2_configure_flow_vxlan(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("VXLAN flow config failed!"); goto end_flow_set; @@ -4215,11 +4309,21 @@ dpaa2_generic_flow_set(struct dpaa2_dev_flow *flow, goto end_flow_set; } break; + case RTE_FLOW_ITEM_TYPE_GTP: + ret = dpaa2_configure_flow_gtp(flow, + dev, attr, &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); + if (ret) { + DPAA2_PMD_ERR("GTP flow config failed!"); + goto end_flow_set; + } + break; case RTE_FLOW_ITEM_TYPE_RAW: ret = dpaa2_configure_flow_raw(flow, dev, attr, - &dpaa2_pattern[i], - actions, error, - &is_keycfg_configured); + &dpaa2_pattern[i], + actions, error, + &is_keycfg_configured); if (ret) { DPAA2_PMD_ERR("RAW flow config failed!"); goto end_flow_set; -- 2.25.1