From patchwork Tue Jul 7 09:22:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 234975 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp739129ilg; Tue, 7 Jul 2020 02:31:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD4EcAXsYxk7Ep85UPAoFKdDLlvUnK7F5WMtX8Y3mIwDmY14y0R2mQgm7/v3nExM9KxClw X-Received: by 2002:a25:50cc:: with SMTP id e195mr89008812ybb.452.1594114303603; Tue, 07 Jul 2020 02:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594114303; cv=none; d=google.com; s=arc-20160816; b=PPNeAyTNGYfr9q+l99qxPJ5fy86elpJ7meGgHpfnq1ztCuwh9AKWQXwiqOactGp/J9 kC3NuxyxQ/TsynuJV+WFVI6Qpq9jV37qv+BCVQM5eQgxSl8fBZvy6WFxPUU4tnTpEmw6 +oOn95Z5FYC5jWgrrCzXQOofA9tesTTJj3JRggT9bHNIbcywUWb+blRaZiAI81jbImfH Klh/HT44QxeM5ldBwos9WE9dpq4+Z8xWep0bx794Z2kyP8G2BO4KdBAao5cKtj8figci MryUuqpb/8V1JndumftS0m8aIksojHg2i6u8BNJBPtW3n+RXXYWdFj1t7VmiHDbTpX+c FuMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:cc:to:from; bh=zl40onH5z+ipC0kb26u4cN42RLtd4TpgznjRvs9O2nQ=; b=Ek/BB2z1DupOr0BHgFSYDKWPBxz/fjGJj/DuRQBMudndqIQEV7033IAWjdiDqYcXqN MC0P6Q4u8gD3pHMtSD3NVKyHlxU3tPh2x/y0QgHUekNLSnJNfWc0zOfzMA9EAer9NP25 ahfBo27J09+vPr0/EWa9/K7NJDZxi78iIAhoq7EJLKDr9h5AlwdhivRyesZ/KLzKuaqP hPrgjgeFgzPlAvMErGYb5mvl2mFZd15NJnSc8Wd//rXdhaqKMS5DoU8C5wrma/bHPBOX W/5KqLMK8bNzbzqoXpa/LED3ncaEuz0nQZj7oXeWyFSwn2C47XVnFTNOQqRiJX1/Y+Aq zwoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id t5si22194191ybp.39.2020.07.07.02.31.43; Tue, 07 Jul 2020 02:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 24A891DD37; Tue, 7 Jul 2020 11:27:34 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by dpdk.org (Postfix) with ESMTP id 7ABD81DD44 for ; Tue, 7 Jul 2020 11:27:14 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 4F31120060D; Tue, 7 Jul 2020 11:27:14 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 683162008E1; Tue, 7 Jul 2020 11:27:12 +0200 (CEST) Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.133.63]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id C816F40305; Tue, 7 Jul 2020 17:27:09 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Jun Yang Date: Tue, 7 Jul 2020 14:52:37 +0530 Message-Id: <20200707092244.12791-23-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707092244.12791-1-hemant.agrawal@nxp.com> References: <20200527132326.1382-1-hemant.agrawal@nxp.com> <20200707092244.12791-1-hemant.agrawal@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v2 22/29] net/dpaa2: support iscrimination between IPv4 and IPv6 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jun Yang Discriminate between IPv4 and IPv6 in generic IP flow setup. Signed-off-by: Jun Yang --- drivers/net/dpaa2/dpaa2_flow.c | 153 +++++++++++++++++---------------- 1 file changed, 80 insertions(+), 73 deletions(-) -- 2.17.1 diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index 95756bf7b..6f3139f86 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -1284,6 +1284,70 @@ dpaa2_configure_flow_vlan(struct rte_flow *flow, return 0; } +static int +dpaa2_configure_flow_ip_discrimation( + struct dpaa2_dev_priv *priv, struct rte_flow *flow, + const struct rte_flow_item *pattern, + int *local_cfg, int *device_configured, + uint32_t group) +{ + int index, ret; + struct proto_discrimination proto; + + index = dpaa2_flow_extract_search( + &priv->extract.qos_key_extract.dpkg, + NET_PROT_ETH, NH_FLD_ETH_TYPE); + if (index < 0) { + ret = dpaa2_flow_proto_discrimination_extract( + &priv->extract.qos_key_extract, + RTE_FLOW_ITEM_TYPE_ETH); + if (ret) { + DPAA2_PMD_ERR( + "QoS Extract ETH_TYPE to discriminate IP failed."); + return -1; + } + (*local_cfg) |= DPAA2_QOS_TABLE_RECONFIGURE; + } + + index = dpaa2_flow_extract_search( + &priv->extract.tc_key_extract[group].dpkg, + NET_PROT_ETH, NH_FLD_ETH_TYPE); + if (index < 0) { + ret = dpaa2_flow_proto_discrimination_extract( + &priv->extract.tc_key_extract[group], + RTE_FLOW_ITEM_TYPE_ETH); + if (ret) { + DPAA2_PMD_ERR( + "FS Extract ETH_TYPE to discriminate IP failed."); + return -1; + } + (*local_cfg) |= DPAA2_FS_TABLE_RECONFIGURE; + } + + ret = dpaa2_flow_rule_move_ipaddr_tail(flow, priv, group); + if (ret) { + DPAA2_PMD_ERR( + "Move ipaddr before IP discrimination set failed"); + return -1; + } + + proto.type = RTE_FLOW_ITEM_TYPE_ETH; + if (pattern->type == RTE_FLOW_ITEM_TYPE_IPV4) + proto.eth_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); + else + proto.eth_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); + ret = dpaa2_flow_proto_discrimination_rule(priv, flow, proto, group); + if (ret) { + DPAA2_PMD_ERR("IP discrimination rule set failed"); + return -1; + } + + (*device_configured) |= (*local_cfg); + + return 0; +} + + static int dpaa2_configure_flow_generic_ip( struct rte_flow *flow, @@ -1327,73 +1391,16 @@ dpaa2_configure_flow_generic_ip( flow->tc_id = group; flow->tc_index = attr->priority; - if (!spec_ipv4 && !spec_ipv6) { - /* Don't care any field of IP header, - * only care IP protocol. - * Example: flow create 0 ingress pattern ipv6 / - */ - /* Eth type is actually used for IP identification. - */ - /* TODO: Current design only supports Eth + IP, - * Eth + vLan + IP needs to add. - */ - struct proto_discrimination proto; - - index = dpaa2_flow_extract_search( - &priv->extract.qos_key_extract.dpkg, - NET_PROT_ETH, NH_FLD_ETH_TYPE); - if (index < 0) { - ret = dpaa2_flow_proto_discrimination_extract( - &priv->extract.qos_key_extract, - RTE_FLOW_ITEM_TYPE_ETH); - if (ret) { - DPAA2_PMD_ERR( - "QoS Ext ETH_TYPE to discriminate IP failed."); - - return -1; - } - local_cfg |= DPAA2_QOS_TABLE_RECONFIGURE; - } - - index = dpaa2_flow_extract_search( - &priv->extract.tc_key_extract[group].dpkg, - NET_PROT_ETH, NH_FLD_ETH_TYPE); - if (index < 0) { - ret = dpaa2_flow_proto_discrimination_extract( - &priv->extract.tc_key_extract[group], - RTE_FLOW_ITEM_TYPE_ETH); - if (ret) { - DPAA2_PMD_ERR( - "FS Ext ETH_TYPE to discriminate IP failed"); - - return -1; - } - local_cfg |= DPAA2_FS_TABLE_RECONFIGURE; - } - - ret = dpaa2_flow_rule_move_ipaddr_tail(flow, priv, group); - if (ret) { - DPAA2_PMD_ERR( - "Move ipaddr before IP discrimination set failed"); - return -1; - } - - proto.type = RTE_FLOW_ITEM_TYPE_ETH; - if (pattern->type == RTE_FLOW_ITEM_TYPE_IPV4) - proto.eth_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); - else - proto.eth_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6); - ret = dpaa2_flow_proto_discrimination_rule(priv, flow, - proto, group); - if (ret) { - DPAA2_PMD_ERR("IP discrimination rule set failed"); - return -1; - } - - (*device_configured) |= local_cfg; + ret = dpaa2_configure_flow_ip_discrimation(priv, + flow, pattern, &local_cfg, + device_configured, group); + if (ret) { + DPAA2_PMD_ERR("IP discrimation failed!"); + return -1; + } + if (!spec_ipv4 && !spec_ipv6) return 0; - } if (mask_ipv4) { if (dpaa2_flow_extract_support((const uint8_t *)mask_ipv4, @@ -1433,10 +1440,10 @@ dpaa2_configure_flow_generic_ip( NET_PROT_IP, NH_FLD_IP_SRC); if (index < 0) { ret = dpaa2_flow_extract_add( - &priv->extract.qos_key_extract, - NET_PROT_IP, - NH_FLD_IP_SRC, - 0); + &priv->extract.qos_key_extract, + NET_PROT_IP, + NH_FLD_IP_SRC, + 0); if (ret) { DPAA2_PMD_ERR("QoS Extract add IP_SRC failed."); @@ -1519,10 +1526,10 @@ dpaa2_configure_flow_generic_ip( else size = NH_FLD_IPV6_ADDR_SIZE; ret = dpaa2_flow_extract_add( - &priv->extract.qos_key_extract, - NET_PROT_IP, - NH_FLD_IP_DST, - size); + &priv->extract.qos_key_extract, + NET_PROT_IP, + NH_FLD_IP_DST, + size); if (ret) { DPAA2_PMD_ERR("QoS Extract add IP_DST failed.");