From patchwork Tue Jul 7 09:22:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 234978 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp739686ilg; Tue, 7 Jul 2020 02:32:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB/0E2v9XqtOE6ZZRbPFvBXUipWxy0D5K0j4SQXN8ohZu4VrLuT6g+h+hqRBe0j23UipaT X-Received: by 2002:a25:cc12:: with SMTP id l18mr18696122ybf.480.1594114349426; Tue, 07 Jul 2020 02:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594114349; cv=none; d=google.com; s=arc-20160816; b=iY0fhS+aimGJdSu1acEYaPC3YPil47yVgWjfCROZL+vYIWvYI4SX0ZhOJcpEoyKv7K qgdrIQDpvtD4Y6TSP6xDYGhZRMws4HuPpIwG8C6fXHmAMavR9VVcXxDEl2zcGZvsl9yq depxwbTmcLt64brWc+MmrBv41tlg1jlu1u6QVRnOYHPvrKA1AizhW74vKmRI6vKqGnN8 YPN3vapOLNvaGsqX2pbbzmMFWYLKqtTLhRNaCnT2jYEVd6lKiUeL2cofGxJzaZfTVVlu 8XZuFGqMMGqueTn5+O0JZm8y5YImMFJbBktoXDKJ/EiQnJHqVb7VTRpuHYANKNySnQ1G YjbQ== 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=fKGyYC4C5sAlWuN5ugDMjBcZswrsytswd5yTg1kQoKg=; b=NkbNbJZgL9YDfSuWc2Esr4R2Zlyfq/dnlH3q3woXU8Zl+VqsRE0szrq53HAEKTBcZ9 WUeM02FLrUmyZH/XAy0WyKlqrEVyKE+NiciZQtwq6hnEWNzO8IkukLQ5RTE0iRQn5fnU QV7kfywSnyOJEw+sYrL7GZZ716LpmgnB3FkY9/OPibqasDXCPrmoLOquVGkPnt9QZ+F0 I4p7E8xluZ/qRdjuuOHYCW5IVbEMi/nCfkJYh+JoMoPOibG1v/tnW++IgUp9SGi9SmDF 5Aip3dcdhs2DkxIZRaXXMXKVk0RcrAYq5vnrJdMl0Zo46mXJCEl4JTdT9KfCQ6AJt/2N heFg== 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 a27si9467220ybj.43.2020.07.07.02.32.29; Tue, 07 Jul 2020 02:32:29 -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 DFA001DE15; Tue, 7 Jul 2020 11:27:37 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by dpdk.org (Postfix) with ESMTP id 22E1D1DD3C for ; Tue, 7 Jul 2020 11:27:16 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 096181A0A30; Tue, 7 Jul 2020 11:27:16 +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 185651A0A4E; Tue, 7 Jul 2020 11:27:14 +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 CE564402C8; Tue, 7 Jul 2020 17:27:11 +0800 (SGT) From: Hemant Agrawal To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Jun Yang Date: Tue, 7 Jul 2020 14:52:40 +0530 Message-Id: <20200707092244.12791-26-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 25/29] net/dpaa2: add flow data sanity check 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 Check flow attributions and actions before creating flow. Otherwise, the QoS table and FS table need to re-build if checking fails. Signed-off-by: Jun Yang --- drivers/net/dpaa2/dpaa2_flow.c | 84 ++++++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c index 76f68b903..3601829c9 100644 --- a/drivers/net/dpaa2/dpaa2_flow.c +++ b/drivers/net/dpaa2/dpaa2_flow.c @@ -3124,6 +3124,67 @@ dpaa2_flow_verify_attr( return 0; } +static inline int +dpaa2_flow_verify_action( + struct dpaa2_dev_priv *priv, + const struct rte_flow_attr *attr, + const struct rte_flow_action actions[]) +{ + int end_of_list = 0, i, j = 0; + const struct rte_flow_action_queue *dest_queue; + const struct rte_flow_action_rss *rss_conf; + struct dpaa2_queue *rxq; + + while (!end_of_list) { + switch (actions[j].type) { + case RTE_FLOW_ACTION_TYPE_QUEUE: + dest_queue = (const struct rte_flow_action_queue *) + (actions[j].conf); + rxq = priv->rx_vq[dest_queue->index]; + if (attr->group != rxq->tc_index) { + DPAA2_PMD_ERR( + "RXQ[%d] does not belong to the group %d", + dest_queue->index, attr->group); + + return -1; + } + break; + case RTE_FLOW_ACTION_TYPE_RSS: + rss_conf = (const struct rte_flow_action_rss *) + (actions[j].conf); + if (rss_conf->queue_num > priv->dist_queues) { + DPAA2_PMD_ERR( + "RSS number exceeds the distrbution size"); + return -ENOTSUP; + } + for (i = 0; i < (int)rss_conf->queue_num; i++) { + if (rss_conf->queue[i] >= priv->nb_rx_queues) { + DPAA2_PMD_ERR( + "RSS queue index exceeds the number of RXQs"); + return -ENOTSUP; + } + rxq = priv->rx_vq[rss_conf->queue[i]]; + if (rxq->tc_index != attr->group) { + DPAA2_PMD_ERR( + "Queue/Group combination are not supported\n"); + return -ENOTSUP; + } + } + + break; + case RTE_FLOW_ACTION_TYPE_END: + end_of_list = 1; + break; + default: + DPAA2_PMD_ERR("Invalid action type"); + return -ENOTSUP; + } + j++; + } + + return 0; +} + static int dpaa2_generic_flow_set(struct rte_flow *flow, struct rte_eth_dev *dev, @@ -3150,6 +3211,10 @@ dpaa2_generic_flow_set(struct rte_flow *flow, if (ret) return ret; + ret = dpaa2_flow_verify_action(priv, attr, actions); + if (ret) + return ret; + /* Parse pattern list to get the matching parameters */ while (!end_of_list) { switch (pattern[i].type) { @@ -3405,25 +3470,6 @@ dpaa2_generic_flow_set(struct rte_flow *flow, break; case RTE_FLOW_ACTION_TYPE_RSS: rss_conf = (const struct rte_flow_action_rss *)(actions[j].conf); - if (rss_conf->queue_num > priv->dist_queues) { - DPAA2_PMD_ERR( - "RSS number exceeds the distrbution size"); - return -ENOTSUP; - } - - for (i = 0; i < (int)rss_conf->queue_num; i++) { - if (rss_conf->queue[i] >= priv->nb_rx_queues) { - DPAA2_PMD_ERR( - "RSS RXQ number exceeds the total number"); - return -ENOTSUP; - } - rxq = priv->rx_vq[rss_conf->queue[i]]; - if (rxq->tc_index != attr->group) { - DPAA2_PMD_ERR( - "RSS RXQ distributed is not in current group"); - return -ENOTSUP; - } - } flow->action = RTE_FLOW_ACTION_TYPE_RSS; ret = dpaa2_distset_to_dpkg_profile_cfg(rss_conf->types,