From patchwork Tue Aug 27 07:07:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Saxena X-Patchwork-Id: 172267 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp5398977ily; Tue, 27 Aug 2019 00:12:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxx4s04+t3Mnj9ac6wpiA46OafEJ01V5OVKaWJ30Gn/hd737t3RW10absOTgHgmYJ91GUzf X-Received: by 2002:a17:906:852:: with SMTP id f18mr20296226ejd.18.1566889946017; Tue, 27 Aug 2019 00:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566889946; cv=none; d=google.com; s=arc-20160816; b=mHnIaJMBMzeT+5grjrv315MZHSkEqzcG0AO7K5ZJkiZ6J1RFCqc3UCKPUr6KPqvXkl SCT90qLczVipmRlUukQ0EzZP+CEG85B3FJ+vWenS4w1+cKjHtmfaRcJ6FTVDIZhf0kr8 DfuJUmOyj7zWLoaYS6NYliBvH3+dhfqtZYZKKTkStB2AswaGvPdSAbVfbwOu+RZC+Ziw USrsjk9JrfVyTYcIXKXNnfJOnmb0ExIlLyZ8O00Ttp7GXGSi8L5myzWKOhdgjO065G28 HMsznL9AkKBCjftz1gN6j8w8a1vNdFJf16Wi/cotIqrCGek953FUJGeNDxeBFQIYTDtp KzJA== 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=yY+PbLstWWZwm2r8YxIPG6f1qjLNYEwSoK8cs88ccsk=; b=mekBnLno7bsATHcCyhuyQn66mh/XG/mPkx7ps+RNdYp93wY30l33JOnGt0Ry+II3KZ 25amKac1/zgfZG7J5rjsWQQ8d3swGfvs3vB8OFIagLinFnkXTVCjRLQaYF5/O5uEpNuX 0ahiXDR6AalD6Xot88frSvw6D0HSoSdrB2TUepaK90Jj1q+xYTFQNBkzy8Lnox5UfDpV xpZlhsoiMLGtmQLXXA7AebIzBau4LyOHQPJHbztAQM1zRMDplkUMgz9Z7Jehe98gH3Gb F2KsOAv5m2gGOYvsXQC3e4mR0Rdocj+aPRp2N4K+1vUdqXpVyCyuj1TbwbJXqxerO8yK JjVQ== 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 s8si6805598ejo.45.2019.08.27.00.12.25; Tue, 27 Aug 2019 00:12:26 -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 C28FE1C194; Tue, 27 Aug 2019 09:10:06 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id A4F7B1BFE3 for ; Tue, 27 Aug 2019 09:09:28 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 8523E1A0586; Tue, 27 Aug 2019 09:09:28 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 4DAF71A05A4; Tue, 27 Aug 2019 09:09:26 +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 32B2E402EB; Tue, 27 Aug 2019 15:09:23 +0800 (SGT) From: Sachin Saxena To: dev@dpdk.org Cc: thomas@monjalon.net, Hemant Agrawal Date: Tue, 27 Aug 2019 12:37:20 +0530 Message-Id: <20190827070730.11206-21-sachin.saxena@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190827070730.11206-1-sachin.saxena@nxp.com> References: <20190827070730.11206-1-sachin.saxena@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Subject: [dpdk-dev] [PATCH v1 20/30] net/dpaa2: support dpdmux classification on eth type 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: Hemant Agrawal Signed-off-by: Hemant Agrawal --- drivers/net/dpaa2/dpaa2_mux.c | 84 +++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 29 deletions(-) -- 2.17.1 diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c index e487c6b54..1910cc418 100644 --- a/drivers/net/dpaa2/dpaa2_mux.c +++ b/drivers/net/dpaa2/dpaa2_mux.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2018 NXP + * Copyright 2018-2019 NXP */ #include @@ -60,19 +60,13 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id, { struct dpaa2_dpdmux_dev *dpdmux_dev; struct dpkg_profile_cfg kg_cfg; - const struct rte_flow_item_ipv4 *spec; const struct rte_flow_action_vf *vf_conf; struct dpdmux_cls_action dpdmux_action; struct rte_flow *flow = NULL; void *key_iova, *mask_iova, *key_cfg_iova = NULL; + uint8_t key_size = 0; int ret; - if (pattern[0]->type != RTE_FLOW_ITEM_TYPE_IPV4) { - DPAA2_PMD_ERR("Not supported pattern type: %d", - pattern[0]->type); - return NULL; - } - /* Find the DPDMUX from dpdmux_id in our list */ dpdmux_dev = get_dpdmux_from_id(dpdmux_id); if (!dpdmux_dev) { @@ -86,16 +80,63 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id, DPAA2_PMD_ERR("Unable to allocate flow-dist parameters"); return NULL; } + flow = rte_zmalloc(NULL, sizeof(struct rte_flow) + + (2 * DIST_PARAM_IOVA_SIZE), RTE_CACHE_LINE_SIZE); + if (!flow) { + DPAA2_PMD_ERR( + "Memory allocation failure for rule configration\n"); + goto creation_error; + } + key_iova = (void *)((size_t)flow + sizeof(struct rte_flow)); + mask_iova = (void *)((size_t)key_iova + DIST_PARAM_IOVA_SIZE); /* Currently taking only IP protocol as an extract type. * This can be exended to other fields using pattern->type. */ memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg)); - kg_cfg.extracts[0].extract.from_hdr.prot = NET_PROT_IP; - kg_cfg.extracts[0].extract.from_hdr.field = NH_FLD_IP_PROTO; - kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_HDR; - kg_cfg.extracts[0].extract.from_hdr.type = DPKG_FULL_FIELD; - kg_cfg.num_extracts = 1; + + switch (pattern[0]->type) { + case RTE_FLOW_ITEM_TYPE_IPV4: + { + const struct rte_flow_item_ipv4 *spec; + kg_cfg.extracts[0].extract.from_hdr.prot = NET_PROT_IP; + kg_cfg.extracts[0].extract.from_hdr.field = NH_FLD_IP_PROTO; + kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_HDR; + kg_cfg.extracts[0].extract.from_hdr.type = DPKG_FULL_FIELD; + kg_cfg.num_extracts = 1; + + spec = (const struct rte_flow_item_ipv4 *)pattern[0]->spec; + memcpy(key_iova, (const void *)(&spec->hdr.next_proto_id), + sizeof(uint8_t)); + memcpy(mask_iova, pattern[0]->mask, sizeof(uint8_t)); + key_size = sizeof(uint8_t); + } + break; + + case RTE_FLOW_ITEM_TYPE_ETH: + { + const struct rte_flow_item_eth *spec; + uint16_t eth_type; + kg_cfg.extracts[0].extract.from_hdr.prot = NET_PROT_ETH; + kg_cfg.extracts[0].extract.from_hdr.field = NH_FLD_ETH_TYPE; + kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_HDR; + kg_cfg.extracts[0].extract.from_hdr.type = DPKG_FULL_FIELD; + kg_cfg.num_extracts = 1; + + spec = (const struct rte_flow_item_eth *)pattern[0]->spec; + eth_type = rte_constant_bswap16(spec->type); + memcpy((void *)key_iova, (const void *)ð_type, + sizeof(rte_be16_t)); + memcpy(mask_iova, pattern[0]->mask, sizeof(uint16_t)); + key_size = sizeof(uint16_t); + } + break; + + default: + DPAA2_PMD_ERR("Not supported pattern type: %d", + pattern[0]->type); + goto creation_error; + } ret = dpkg_prepare_key_cfg(&kg_cfg, key_cfg_iova); if (ret) { @@ -114,24 +155,9 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id, /* As now our key extract parameters are set, let us configure * the rule. */ - flow = rte_zmalloc(NULL, sizeof(struct rte_flow) + - (2 * DIST_PARAM_IOVA_SIZE), RTE_CACHE_LINE_SIZE); - if (!flow) { - DPAA2_PMD_ERR( - "Memory allocation failure for rule configration\n"); - goto creation_error; - } - key_iova = (void *)((size_t)flow + sizeof(struct rte_flow)); - mask_iova = (void *)((size_t)key_iova + DIST_PARAM_IOVA_SIZE); - - spec = (const struct rte_flow_item_ipv4 *)pattern[0]->spec; - memcpy(key_iova, (const void *)&spec->hdr.next_proto_id, - sizeof(uint8_t)); - memcpy(mask_iova, pattern[0]->mask, sizeof(uint8_t)); - flow->rule.key_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(key_iova)); flow->rule.mask_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(mask_iova)); - flow->rule.key_size = sizeof(uint8_t); + flow->rule.key_size = key_size; vf_conf = (const struct rte_flow_action_vf *)(actions[0]->conf); if (vf_conf->id == 0 || vf_conf->id > dpdmux_dev->num_ifs) {