From patchwork Tue Sep 4 07:10:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44210 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8CC822BF3; Tue, 4 Sep 2018 09:10:35 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 727E42B92 for ; Tue, 4 Sep 2018 09:10:33 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id f6-v6so1197696plo.1 for ; Tue, 04 Sep 2018 00:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=y8U6gYDQP9+l7c5h3ZcJ0DaVjlhx9ObAKd++8V34sQU=; b=YaumliVrDs29UOniOzM8VEhunldBjFsSVzYihKA8EYZCiXTHsUbKFyI+qI5gjq3f9b QyUALTIo4JioMjnuOzpvRnH4pJi6OcamJ40AX5ig27Kl2eYSt4nplPE01/A/rOI9o65w HxN/e47Wr106xpRfHYjGdZgczc8fCJ9s3MWTa0y9bIdAyKPON+hWgicvTZCAozOna594 QBA67JV06AXnUVKQGlXO0rNoLV10zfotaiHeymdQd3v9dSBWIgNLznsaRLN1M0wVIqrE dGDccVaBZhpt4rF5hISa8a7ilreLED1n1iFXCaNRPCwIHkZuYY1WLmYxcXBsSS71W/Kv otXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=y8U6gYDQP9+l7c5h3ZcJ0DaVjlhx9ObAKd++8V34sQU=; b=d/pSpf/GMP/0TQbjhgV6GqDMdTHK4VYdWJUZ+sEiYB8s2MTwUcS0Ockgn0faAfv1R+ 5q2x6ImiQc97wjta10rUB5fOOGPqwP7DXrgjjES24trMJK/X1f/qpnaZxY37iFPp30pL EHUhBF+rdteEUzO2iZCdgIain6MR0CCKPkFLwU/UplhwHvliT8U3oNKCXf03S8m1E45o KHMAS6uv4y1nBdTYt8j0/9GthNouNlOsBjdsJMeHRfIAAs4Uon8tnLRyBkAW5I76MvU/ AbOCIEmm7XTyWcY2u9zbfah5wxgfjX6DitV5ysFgkqBYOHBGUqJH8+TrzdcuvViNVBNO CFbw== X-Gm-Message-State: APzg51D57KoTBSg94SKpJCODp7WB+eQNvmGnlR2rmb6xsH3l10sXEGIa t3lEjpz15BiirisfyEnkpiXfgVDmzvkX0g== X-Google-Smtp-Source: ANB0VdaSOV5sE8oedz7AXfmfdMC6a7Bt4btYlDbNcnTQJ4ZN9yxK2BLZ4Gl2eg5pm3FuYPJJPvY1cg== X-Received: by 2002:a17:902:8bc4:: with SMTP id r4-v6mr31261181plo.124.1536045032200; Tue, 04 Sep 2018 00:10:32 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:31 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com Date: Tue, 4 Sep 2018 09:10:09 +0200 Message-Id: <1536045016-32008-2-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 1/8] net/mvpp2: initialize ppio only once 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: Natalie Samsonov This changes stop/start/configure behavior due to issue in MUSDK library itself. From now on, ppio can be reconfigured only after interface is closed. Signed-off-by: Natalie Samsonov Reviewed-by: Yuval Caduri --- drivers/net/mvpp2/mrvl_ethdev.c | 53 +++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 6824445..f022cad 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -304,6 +304,11 @@ mrvl_dev_configure(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; int ret; + if (priv->ppio) { + MRVL_LOG(INFO, "Device reconfiguration is not supported"); + return -EINVAL; + } + if (dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_NONE && dev->data->dev_conf.rxmode.mq_mode != ETH_MQ_RX_RSS) { MRVL_LOG(INFO, "Unsupported rx multi queue mode %d", @@ -525,6 +530,9 @@ mrvl_dev_start(struct rte_eth_dev *dev) char match[MRVL_MATCH_LEN]; int ret = 0, i, def_init_size; + if (priv->ppio) + return mrvl_dev_set_link_up(dev); + snprintf(match, sizeof(match), "ppio-%d:%d", priv->pp_id, priv->ppio_id); priv->ppio_params.match = match; @@ -749,28 +757,7 @@ mrvl_flush_bpool(struct rte_eth_dev *dev) static void mrvl_dev_stop(struct rte_eth_dev *dev) { - struct mrvl_priv *priv = dev->data->dev_private; - mrvl_dev_set_link_down(dev); - mrvl_flush_rx_queues(dev); - mrvl_flush_tx_shadow_queues(dev); - if (priv->cls_tbl) { - pp2_cls_tbl_deinit(priv->cls_tbl); - priv->cls_tbl = NULL; - } - if (priv->qos_tbl) { - pp2_cls_qos_tbl_deinit(priv->qos_tbl); - priv->qos_tbl = NULL; - } - if (priv->ppio) - pp2_ppio_deinit(priv->ppio); - priv->ppio = NULL; - - /* policer must be released after ppio deinitialization */ - if (priv->policer) { - pp2_cls_plcr_deinit(priv->policer); - priv->policer = NULL; - } } /** @@ -785,6 +772,9 @@ mrvl_dev_close(struct rte_eth_dev *dev) struct mrvl_priv *priv = dev->data->dev_private; size_t i; + mrvl_flush_rx_queues(dev); + mrvl_flush_tx_shadow_queues(dev); + for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) { struct pp2_ppio_tc_params *tc_params = &priv->ppio_params.inqs_params.tcs_params[i]; @@ -795,7 +785,28 @@ mrvl_dev_close(struct rte_eth_dev *dev) } } + if (priv->cls_tbl) { + pp2_cls_tbl_deinit(priv->cls_tbl); + priv->cls_tbl = NULL; + } + + if (priv->qos_tbl) { + pp2_cls_qos_tbl_deinit(priv->qos_tbl); + priv->qos_tbl = NULL; + } + mrvl_flush_bpool(dev); + + if (priv->ppio) { + pp2_ppio_deinit(priv->ppio); + priv->ppio = NULL; + } + + /* policer must be released after ppio deinitialization */ + if (priv->policer) { + pp2_cls_plcr_deinit(priv->policer); + priv->policer = NULL; + } } /** From patchwork Tue Sep 4 07:10:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44211 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 012462C55; Tue, 4 Sep 2018 09:10:36 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id C0AE32C38 for ; Tue, 4 Sep 2018 09:10:35 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id f6-v6so1197776plo.1 for ; Tue, 04 Sep 2018 00:10:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=woBXmNVHqSgg2F1hFxpFNXtegsYGXF4hmvppsjeSKRU=; b=2BD9OzzPhRuXaJ9zhYp894BH2shoba5DQj56TJrT+ePQy7MGu18o4O+sQNTvH81aN0 h/P0pWrUCXY5ZeXFiQ1+vI3wHfxvUdml7k5o807z8y/ZY0MSwY+iLnTvybBUASTonr+l kEB3kpO9pp1JYqleZmkQiknl8Ciu6t7oCw1xpIzk2Egxix/rxdH45H6IIgI+fbAnQ8kp lgXRC2M+6Fm23wWRt/eSOKRAfL8jI3McOZxmXrfuOp/wCLQEDL1dTaNgDZr2vlvC9RSy OEWooBaFZxmFZa0pkRni3xZCFiuUl/fsDbDDXxV3D7y4H1o5rDL5yCGJF5ToNlJ4s+Yv FeCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=woBXmNVHqSgg2F1hFxpFNXtegsYGXF4hmvppsjeSKRU=; b=LuP9CvEa23nVAWG+DehBCF9pn3UhUlemFHcFH1t1fg8qQMtmHMzyC6HUW/PA43GMFI 4ThDPVI8aRk6FihS51YS541thcuvyNMZxLQSocNrR2te6fJXwUzz5t/8HcnzvxfKEvRu FgmgL0ygQFcn/f4cnhNZOEwgyjrojdxkOAsuFuAhkR7ZxszHiUV/WllDiw1+9mNVVfQb PYepDysPtvIdJUezZ5Uzy4O9LV+wXeaTokkB910mt+LrM2JtAYqYlNNVUOu8HsxxZZGE 7/RDZr4ViYrJvcFia4SOXznmvsXPlswK2HJok5zmpjejXnAE1v4EJVAjZxpoGGT/sJ4t J2Gg== X-Gm-Message-State: APzg51DDnF214p9hlGh84bDmtkcpiLY93kEwWlcf9oh+g6BVWwdH0uzp EPFXa/lvbLs053oJzHE3OYxEVvN/CTyJ/g== X-Google-Smtp-Source: ANB0VdbJhn7/qGDWeAVbCnR4JaZKz9TZWd9fBONxfkET0fhZe+VzukROU9uPOn1i/pIxWs4IADj80w== X-Received: by 2002:a17:902:6a83:: with SMTP id n3-v6mr31784606plk.246.1536045034637; Tue, 04 Sep 2018 00:10:34 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:33 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 09:10:10 +0200 Message-Id: <1536045016-32008-3-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 2/8] net/mvpp2: move common code 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" Cleanup sources by moving common code to the pmd header file. Signed-off-by: Tomasz Duszynski Signed-off-by: Natalie Samsonov Reviewed-by: Liron Himi --- drivers/net/mvpp2/mrvl_ethdev.c | 9 --------- drivers/net/mvpp2/mrvl_ethdev.h | 11 +++++++++++ drivers/net/mvpp2/mrvl_flow.c | 5 ----- drivers/net/mvpp2/mrvl_qos.c | 9 --------- 4 files changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index f022cad..adb07d0 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -10,15 +10,6 @@ #include #include -/* Unluckily, container_of is defined by both DPDK and MUSDK, - * we'll declare only one version. - * - * Note that it is not used in this PMD anyway. - */ -#ifdef container_of -#undef container_of -#endif - #include #include #include diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index 3726f78..2204be2 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.h +++ b/drivers/net/mvpp2/mrvl_ethdev.h @@ -10,12 +10,23 @@ #include #include +/* + * container_of is defined by both DPDK and MUSDK, + * we'll declare only one version. + * + * Note that it is not used in this PMD anyway. + */ +#ifdef container_of +#undef container_of +#endif + #include #include #include #include #include #include +#include "env/mv_common.h" /* for BIT() */ /** Maximum number of rx queues per port */ #define MRVL_PP2_RXQ_MAX 32 diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 13295e6..db750f4 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -11,13 +11,8 @@ #include -#ifdef container_of -#undef container_of -#endif - #include "mrvl_ethdev.h" #include "mrvl_qos.h" -#include "env/mv_common.h" /* for BIT() */ /** Number of rules in the classifier table. */ #define MRVL_CLS_MAX_NUM_RULES 20 diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index 71856c1..eeb46f8 100644 --- a/drivers/net/mvpp2/mrvl_qos.c +++ b/drivers/net/mvpp2/mrvl_qos.c @@ -15,15 +15,6 @@ #include #include -/* Unluckily, container_of is defined by both DPDK and MUSDK, - * we'll declare only one version. - * - * Note that it is not used in this PMD anyway. - */ -#ifdef container_of -#undef container_of -#endif - #include "mrvl_qos.h" /* Parsing tokens. Defined conveniently, so that any correction is easy. */ From patchwork Tue Sep 4 07:10:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44212 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5321C326C; Tue, 4 Sep 2018 09:10:40 +0200 (CEST) Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id DEB57325F for ; Tue, 4 Sep 2018 09:10:38 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id k21-v6so1212317pff.11 for ; Tue, 04 Sep 2018 00:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9F0lDYfvYyV6SgxLky9++TLqdBjOu7Cs+qGbiCEfTqY=; b=w6KINwN6G99B/1MUw7gnF2ghk1C4FTXQYfXKsWPpXejWEy0AKDg9GMGy5PCn3kVTtu Kj2nqmFQmAUR95bNtNYCgav0vCSUukaIZZPxt0TIwnjAqr8GAd3GbSsgd/RAcCsEV9vb WIJNOKRdlFZaEmvmOhZLZM9bqLjcNLfRk21vqcVdKxGZip7R0AceaovpxcTVHhm787GE czI9lZp1ZghoAHhQqhU/zRKr05fld3kjq3er2LJSTEYUzyOQ+swAWiaUVcQhMEh81t+D 3R/HLKBRvEgi1mBa5LJqXo6sMusUOO4cC7FzpumXP7zQ+3MLCtkb3jLbVprNvaQycWeQ VPBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9F0lDYfvYyV6SgxLky9++TLqdBjOu7Cs+qGbiCEfTqY=; b=Vy+tHgUHCoRB31f9uYOQS2f3UClfO3p6sHUPdOLZpE35tw3xl43JSj78dTIp/C7cJj lNa9s73sjpn+YOFnYunnOoN/1sMZmpp5vPIcmvtZLLeCRrDN8og9aIMn8RmVml97jQ15 PX7R87+SBoO9mTYyaM3MfQKX3tSZofpD2WxPxpjUE71hm5kbpcXVTpNLrvZmPEKtGG// Yd2P0RejXw2sWTRXwPLKpSoMuaczHZjHhZYdnpumjumHlSd3AVTygz0nAKBVMVRRfZSF yez1zxBcrNDDkaJG5+z8pMeyKJCwayzqoiEq5HiAWiLfBqCJTvathzPdOq+BX3eZgR0x 4YUQ== X-Gm-Message-State: APzg51BwCfWtKbDuBmcwbcFXBB3eB7+bc1UpHOFO4US1qR412Aou6UKj RSQg/hUdTViSalnwhpfV0zyCYGvsx3BF1Q== X-Google-Smtp-Source: ANB0VdY96jOBqOYxlmbgH3jmKoJNmQSUs4P0LcY1fYz0aW7KrCVX60J4SEmAVN4StYvs4hcm0E4jYA== X-Received: by 2002:a63:550b:: with SMTP id j11-v6mr29117093pgb.167.1536045037543; Tue, 04 Sep 2018 00:10:37 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:36 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 09:10:11 +0200 Message-Id: <1536045016-32008-4-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 3/8] net/mvpp2: add metering support 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" Add support for configuring plcr via DPDK generic metering API. Signed-off-by: Tomasz Duszynski Signed-off-by: Natalie Samsonov Reviewed-by: Liron Himi --- drivers/net/mvpp2/Makefile | 1 + drivers/net/mvpp2/meson.build | 3 +- drivers/net/mvpp2/mrvl_ethdev.c | 24 ++ drivers/net/mvpp2/mrvl_ethdev.h | 71 ++++++ drivers/net/mvpp2/mrvl_flow.c | 91 +++---- drivers/net/mvpp2/mrvl_mtr.c | 512 ++++++++++++++++++++++++++++++++++++++++ drivers/net/mvpp2/mrvl_mtr.h | 15 ++ 7 files changed, 673 insertions(+), 44 deletions(-) create mode 100644 drivers/net/mvpp2/mrvl_mtr.c create mode 100644 drivers/net/mvpp2/mrvl_mtr.h diff --git a/drivers/net/mvpp2/Makefile b/drivers/net/mvpp2/Makefile index 211d398..4848d65 100644 --- a/drivers/net/mvpp2/Makefile +++ b/drivers/net/mvpp2/Makefile @@ -39,5 +39,6 @@ LDLIBS += -lrte_bus_vdev -lrte_common_mvep SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c +SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/mvpp2/meson.build b/drivers/net/mvpp2/meson.build index 3620659..f475511 100644 --- a/drivers/net/mvpp2/meson.build +++ b/drivers/net/mvpp2/meson.build @@ -19,7 +19,8 @@ endif sources = files( 'mrvl_ethdev.c', 'mrvl_flow.c', - 'mrvl_qos.c' + 'mrvl_qos.c', + 'mrvl_mtr.c' ) deps += ['cfgfile', 'common_mvep'] diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index adb07d0..a4951d3 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -23,6 +23,7 @@ #include #include "mrvl_ethdev.h" #include "mrvl_qos.h" +#include "mrvl_mtr.h" /* bitmask with reserved hifs */ #define MRVL_MUSDK_HIFS_RESERVED 0x0F @@ -627,6 +628,8 @@ mrvl_dev_start(struct rte_eth_dev *dev) goto out; } + mrvl_mtr_init(dev); + return 0; out: MRVL_LOG(ERR, "Failed to start device"); @@ -765,6 +768,7 @@ mrvl_dev_close(struct rte_eth_dev *dev) mrvl_flush_rx_queues(dev); mrvl_flush_tx_shadow_queues(dev); + mrvl_mtr_deinit(dev); for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) { struct pp2_ppio_tc_params *tc_params = @@ -1868,6 +1872,25 @@ mrvl_eth_filter_ctrl(struct rte_eth_dev *dev __rte_unused, } } +/** + * DPDK callback to get rte_mtr callbacks. + * + * @param dev + * Pointer to the device structure. + * @param ops + * Pointer to pass the mtr ops. + * + * @return + * Always 0. + */ +static int +mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops) +{ + *(const void **)ops = &mrvl_mtr_ops; + + return 0; +} + static const struct eth_dev_ops mrvl_ops = { .dev_configure = mrvl_dev_configure, .dev_start = mrvl_dev_start, @@ -1905,6 +1928,7 @@ static const struct eth_dev_ops mrvl_ops = { .rss_hash_update = mrvl_rss_hash_update, .rss_hash_conf_get = mrvl_rss_hash_conf_get, .filter_ctrl = mrvl_eth_filter_ctrl, + .mtr_ops_get = mrvl_mtr_ops_get, }; /** diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index 2204be2..ecb8fdc 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.h +++ b/drivers/net/mvpp2/mrvl_ethdev.h @@ -9,6 +9,7 @@ #include #include +#include /* * container_of is defined by both DPDK and MUSDK, @@ -70,6 +71,69 @@ /** Minimum number of sent buffers to release from shadow queue to BM */ #define MRVL_PP2_BUF_RELEASE_BURST_SIZE 64 +/** Maximum length of a match string */ +#define MRVL_MATCH_LEN 16 + +/** Parsed fields in processed rte_flow_item. */ +enum mrvl_parsed_fields { + /* eth flags */ + F_DMAC = BIT(0), + F_SMAC = BIT(1), + F_TYPE = BIT(2), + /* vlan flags */ + F_VLAN_PRI = BIT(3), + F_VLAN_ID = BIT(4), + F_VLAN_TCI = BIT(5), /* not supported by MUSDK yet */ + /* ip4 flags */ + F_IP4_TOS = BIT(6), + F_IP4_SIP = BIT(7), + F_IP4_DIP = BIT(8), + F_IP4_PROTO = BIT(9), + /* ip6 flags */ + F_IP6_TC = BIT(10), /* not supported by MUSDK yet */ + F_IP6_SIP = BIT(11), + F_IP6_DIP = BIT(12), + F_IP6_FLOW = BIT(13), + F_IP6_NEXT_HDR = BIT(14), + /* tcp flags */ + F_TCP_SPORT = BIT(15), + F_TCP_DPORT = BIT(16), + /* udp flags */ + F_UDP_SPORT = BIT(17), + F_UDP_DPORT = BIT(18), +}; + +/** PMD-specific definition of a flow rule handle. */ +struct mrvl_mtr; +struct rte_flow { + LIST_ENTRY(rte_flow) next; + struct mrvl_mtr *mtr; + + enum mrvl_parsed_fields pattern; + + struct pp2_cls_tbl_rule rule; + struct pp2_cls_cos_desc cos; + struct pp2_cls_tbl_action action; +}; + +struct mrvl_mtr_profile { + LIST_ENTRY(mrvl_mtr_profile) next; + uint32_t profile_id; + int refcnt; + struct rte_mtr_meter_profile profile; +}; + +struct mrvl_mtr { + LIST_ENTRY(mrvl_mtr) next; + uint32_t mtr_id; + int refcnt; + int shared; + int enabled; + int plcr_bit; + struct mrvl_mtr_profile *profile; + struct pp2_cls_plcr *plcr; +}; + struct mrvl_priv { /* Hot fields, used in fast path. */ struct pp2_bpool *bpool; /**< BPool pointer */ @@ -105,11 +169,18 @@ struct mrvl_priv { LIST_HEAD(mrvl_flows, rte_flow) flows; struct pp2_cls_plcr *policer; + + LIST_HEAD(profiles, mrvl_mtr_profile) profiles; + LIST_HEAD(mtrs, mrvl_mtr) mtrs; + uint32_t used_plcrs; }; /** Flow operations forward declaration. */ extern const struct rte_flow_ops mrvl_flow_ops; +/** Meter operations forward declaration. */ +extern const struct rte_mtr_ops mrvl_mtr_ops; + /** Current log type. */ extern int mrvl_logtype; diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index db750f4..e6953e4 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -20,46 +20,6 @@ /** Size of the classifier key and mask strings. */ #define MRVL_CLS_STR_SIZE_MAX 40 -/** Parsed fields in processed rte_flow_item. */ -enum mrvl_parsed_fields { - /* eth flags */ - F_DMAC = BIT(0), - F_SMAC = BIT(1), - F_TYPE = BIT(2), - /* vlan flags */ - F_VLAN_ID = BIT(3), - F_VLAN_PRI = BIT(4), - F_VLAN_TCI = BIT(5), /* not supported by MUSDK yet */ - /* ip4 flags */ - F_IP4_TOS = BIT(6), - F_IP4_SIP = BIT(7), - F_IP4_DIP = BIT(8), - F_IP4_PROTO = BIT(9), - /* ip6 flags */ - F_IP6_TC = BIT(10), /* not supported by MUSDK yet */ - F_IP6_SIP = BIT(11), - F_IP6_DIP = BIT(12), - F_IP6_FLOW = BIT(13), - F_IP6_NEXT_HDR = BIT(14), - /* tcp flags */ - F_TCP_SPORT = BIT(15), - F_TCP_DPORT = BIT(16), - /* udp flags */ - F_UDP_SPORT = BIT(17), - F_UDP_DPORT = BIT(18), -}; - -/** PMD-specific definition of a flow rule handle. */ -struct rte_flow { - LIST_ENTRY(rte_flow) next; - - enum mrvl_parsed_fields pattern; - - struct pp2_cls_tbl_rule rule; - struct pp2_cls_cos_desc cos; - struct pp2_cls_tbl_action action; -}; - static const enum rte_flow_item_type pattern_eth[] = { RTE_FLOW_ITEM_TYPE_ETH, RTE_FLOW_ITEM_TYPE_END @@ -2295,19 +2255,59 @@ mrvl_flow_parse_actions(struct mrvl_priv *priv, flow->action.type = PP2_CLS_TBL_ACT_DONE; flow->action.cos = &flow->cos; specified++; + } else if (action->type == RTE_FLOW_ACTION_TYPE_METER) { + const struct rte_flow_action_meter *meter; + struct mrvl_mtr *mtr; + + meter = action->conf; + if (!meter) + return -rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, "Invalid meter\n"); + + LIST_FOREACH(mtr, &priv->mtrs, next) + if (mtr->mtr_id == meter->mtr_id) + break; + + if (!mtr) + return -rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "Meter id does not exist\n"); + + if (!mtr->shared && mtr->refcnt) + return -rte_flow_error_set(error, EPERM, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "Meter cannot be shared\n"); + + /* + * In case cos has already been set + * do not modify it. + */ + if (!flow->cos.ppio) { + flow->cos.ppio = priv->ppio; + flow->cos.tc = 0; + } + + flow->action.type = PP2_CLS_TBL_ACT_DONE; + flow->action.cos = &flow->cos; + flow->action.plcr = mtr->enabled ? mtr->plcr : NULL; + flow->mtr = mtr; + mtr->refcnt++; + specified++; } else { rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "Action not supported"); return -rte_errno; } - } if (!specified) { rte_flow_error_set(error, EINVAL, - RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "Action not specified"); + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, + "Action not specified"); return -rte_errno; } @@ -2657,6 +2657,11 @@ mrvl_flow_remove(struct mrvl_priv *priv, struct rte_flow *flow, mrvl_free_all_key_mask(&flow->rule); + if (flow->mtr) { + flow->mtr->refcnt--; + flow->mtr = NULL; + } + return 0; } diff --git a/drivers/net/mvpp2/mrvl_mtr.c b/drivers/net/mvpp2/mrvl_mtr.c new file mode 100644 index 0000000..9cd53be --- /dev/null +++ b/drivers/net/mvpp2/mrvl_mtr.c @@ -0,0 +1,512 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Marvell International Ltd. + * Copyright(c) 2018 Semihalf. + * All rights reserved. + */ + +#include +#include + +#include "mrvl_mtr.h" + +/** Maximum meter rate */ +#define MRVL_SRTCM_RFC2697_CIR_MAX 1023000 + +/** Invalid plcr bit */ +#define MRVL_PLCR_BIT_INVALID -1 + +/** + * Return meter object capabilities. + * + * @param dev Pointer to the device (unused). + * @param cap Pointer to the meter object capabilities. + * @param error Pointer to the error (unused). + * @returns 0 always. + */ +static int +mrvl_capabilities_get(struct rte_eth_dev *dev __rte_unused, + struct rte_mtr_capabilities *cap, + struct rte_mtr_error *error __rte_unused) +{ + struct rte_mtr_capabilities capa = { + .n_max = PP2_CLS_PLCR_NUM, + .n_shared_max = PP2_CLS_PLCR_NUM, + .shared_n_flows_per_mtr_max = -1, + .meter_srtcm_rfc2697_n_max = PP2_CLS_PLCR_NUM, + .meter_rate_max = MRVL_SRTCM_RFC2697_CIR_MAX, + }; + + memcpy(cap, &capa, sizeof(capa)); + + return 0; +} + +/** + * Get profile using it's id. + * + * @param priv Pointer to the port's private data. + * @param meter_profile_id Profile id used by the meter. + * @returns Pointer to the profile if exists, NULL otherwise. + */ +static struct mrvl_mtr_profile * +mrvl_mtr_profile_from_id(struct mrvl_priv *priv, uint32_t meter_profile_id) +{ + struct mrvl_mtr_profile *profile = NULL; + + LIST_FOREACH(profile, &priv->profiles, next) + if (profile->profile_id == meter_profile_id) + break; + + return profile; +} + +/** + * Add profile to the list of profiles. + * + * @param dev Pointer to the device. + * @param meter_profile_id Id of the new profile. + * @param profile Pointer to the profile configuration. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_meter_profile_add(struct rte_eth_dev *dev, uint32_t meter_profile_id, + struct rte_mtr_meter_profile *profile, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr_profile *prof; + + if (!profile) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + if (profile->alg != RTE_MTR_SRTCM_RFC2697) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Only srTCM RFC 2697 is supported\n"); + + prof = mrvl_mtr_profile_from_id(priv, meter_profile_id); + if (prof) + return -rte_mtr_error_set(error, EEXIST, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, "Profile id already exists\n"); + + prof = rte_zmalloc_socket(NULL, sizeof(*prof), 0, rte_socket_id()); + if (!prof) + return -rte_mtr_error_set(error, ENOMEM, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + prof->profile_id = meter_profile_id; + memcpy(&prof->profile, profile, sizeof(*profile)); + + LIST_INSERT_HEAD(&priv->profiles, prof, next); + + return 0; +} + +/** + * Remove profile from the list of profiles. + * + * @param dev Pointer to the device. + * @param meter_profile_id Id of the profile to remove. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_meter_profile_delete(struct rte_eth_dev *dev, + uint32_t meter_profile_id, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr_profile *profile; + + profile = mrvl_mtr_profile_from_id(priv, meter_profile_id); + if (!profile) + return -rte_mtr_error_set(error, ENODEV, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, "Profile id does not exist\n"); + + if (profile->refcnt) + return -rte_mtr_error_set(error, EPERM, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, "Profile is used\n"); + + LIST_REMOVE(profile, next); + rte_free(profile); + + return 0; +} + +/** + * Get meter using it's id. + * + * @param priv Pointer to port's private data. + * @param mtr_id Id of the meter. + * @returns Pointer to the meter if exists, NULL otherwise. + */ +static struct mrvl_mtr * +mrvl_mtr_from_id(struct mrvl_priv *priv, uint32_t mtr_id) +{ + struct mrvl_mtr *mtr = NULL; + + LIST_FOREACH(mtr, &priv->mtrs, next) + if (mtr->mtr_id == mtr_id) + break; + + return mtr; +} + +/** + * Reserve a policer bit in a bitmap. + * + * @param plcrs Pointer to the policers bitmap. + * @returns Reserved bit number on success, negative value otherwise. + */ +static int +mrvl_reserve_plcr(uint32_t *plcrs) +{ + uint32_t i, num; + + num = PP2_CLS_PLCR_NUM; + if (num > sizeof(uint32_t) * 8) { + num = sizeof(uint32_t) * 8; + MRVL_LOG(WARNING, "Plcrs number was limited to 32."); + } + + for (i = 0; i < num; i++) { + uint32_t bit = BIT(i); + + if (!(*plcrs & bit)) { + *plcrs |= bit; + + return i; + } + } + + return -1; +} + +/** + * Enable meter object. + * + * @param dev Pointer to the device. + * @param mtr_id Id of the meter. + * @param error Pointer to the error. + * @returns 0 in success, negative value otherwise. + */ +static int +mrvl_meter_enable(struct rte_eth_dev *dev, uint32_t mtr_id, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr *mtr = mrvl_mtr_from_id(priv, mtr_id); + struct pp2_cls_plcr_params params; + char match[MRVL_MATCH_LEN]; + struct rte_flow *flow; + int ret; + + if (!priv->ppio) + return -rte_mtr_error_set(error, EPERM, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is uninitialized\n"); + + if (!mtr) + return -rte_mtr_error_set(error, ENODEV, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter id does not exist\n"); + + if (mtr->plcr) + goto skip; + + mtr->plcr_bit = mrvl_reserve_plcr(&priv->used_plcrs); + if (mtr->plcr_bit < 0) + return -rte_mtr_error_set(error, ENOSPC, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, + "Failed to reserve plcr entry\n"); + + memset(¶ms, 0, sizeof(params)); + snprintf(match, sizeof(match), "policer-%d:%d", priv->pp_id, + mtr->plcr_bit); + params.match = match; + params.token_unit = PP2_CLS_PLCR_BYTES_TOKEN_UNIT; + params.color_mode = PP2_CLS_PLCR_COLOR_BLIND_MODE; + params.cir = mtr->profile->profile.srtcm_rfc2697.cir; + params.cbs = mtr->profile->profile.srtcm_rfc2697.cbs; + params.ebs = mtr->profile->profile.srtcm_rfc2697.ebs; + + ret = pp2_cls_plcr_init(¶ms, &mtr->plcr); + if (ret) { + priv->used_plcrs &= ~BIT(mtr->plcr_bit); + mtr->plcr_bit = MRVL_PLCR_BIT_INVALID; + + return -rte_mtr_error_set(error, -ret, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, "Failed to setup policer\n"); + } + + mtr->enabled = 1; +skip: + /* iterate over flows that have this mtr attached */ + LIST_FOREACH(flow, &priv->flows, next) { + if (flow->mtr != mtr) + continue; + + flow->action.plcr = mtr->plcr; + + ret = pp2_cls_tbl_modify_rule(priv->cls_tbl, &flow->rule, + &flow->action); + if (ret) + return -rte_mtr_error_set(error, -ret, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, "Failed to update cls rule\n"); + } + + return 0; +} + +/** + * Disable meter object. + * + * @param dev Pointer to the device. + * @param mtr Id of the meter. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_meter_disable(struct rte_eth_dev *dev, uint32_t mtr_id, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr *mtr = mrvl_mtr_from_id(priv, mtr_id); + struct rte_flow *flow; + int ret; + + if (!mtr) + return -rte_mtr_error_set(error, ENODEV, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter id does not exist\n"); + + LIST_FOREACH(flow, &priv->flows, next) { + if (flow->mtr != mtr) + continue; + + flow->action.plcr = NULL; + + ret = pp2_cls_tbl_modify_rule(priv->cls_tbl, &flow->rule, + &flow->action); + if (ret) + return -rte_mtr_error_set(error, -ret, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, "Failed to disable meter\n"); + } + + mtr->enabled = 0; + + return 0; +} + +/** + * Create new meter. + * + * @param dev Pointer to the device. + * @param mtr_id Id of the meter. + * @param params Pointer to the meter parameters. + * @param shared Flags indicating whether meter is shared. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_create(struct rte_eth_dev *dev, uint32_t mtr_id, + struct rte_mtr_params *params, int shared, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr_profile *profile; + struct mrvl_mtr *mtr; + + mtr = mrvl_mtr_from_id(priv, mtr_id); + if (mtr) + return -rte_mtr_error_set(error, EEXIST, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter id already exists\n"); + + mtr = rte_zmalloc_socket(NULL, sizeof(*mtr), 0, rte_socket_id()); + if (!mtr) + return -rte_mtr_error_set(error, ENOMEM, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + profile = mrvl_mtr_profile_from_id(priv, params->meter_profile_id); + if (!profile) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, "Profile id does not exist\n"); + + mtr->shared = shared; + mtr->mtr_id = mtr_id; + mtr->plcr_bit = MRVL_PLCR_BIT_INVALID; + mtr->profile = profile; + profile->refcnt++; + LIST_INSERT_HEAD(&priv->mtrs, mtr, next); + + if (params->meter_enable) + return mrvl_meter_enable(dev, mtr_id, error); + + return 0; +} + +/** + * Destroy meter object. + * + * @param dev Pointer to the device. + * @param mtr_id Id of the meter object. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_destroy(struct rte_eth_dev *dev, uint32_t mtr_id, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr *mtr; + + if (!priv->ppio) + return -rte_mtr_error_set(error, EPERM, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is uninitialized\n"); + + mtr = mrvl_mtr_from_id(priv, mtr_id); + if (!mtr) + return -rte_mtr_error_set(error, EEXIST, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter id does not exist\n"); + + if (mtr->refcnt) + return -rte_mtr_error_set(error, EPERM, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter is used\n"); + + LIST_REMOVE(mtr, next); + mtr->profile->refcnt--; + + if (mtr->plcr_bit != MRVL_PLCR_BIT_INVALID) + priv->used_plcrs &= ~BIT(mtr->plcr_bit); + + if (mtr->plcr) + pp2_cls_plcr_deinit(mtr->plcr); + + rte_free(mtr); + + return 0; +} + +/** + * Update profile used by the meter. + * + * @param dev Pointer to the device. + * @param mtr_id Id of the meter object. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_meter_profile_update(struct rte_eth_dev *dev, uint32_t mtr_id, + uint32_t meter_profile_id, + struct rte_mtr_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr_profile *profile; + struct mrvl_mtr *mtr; + int ret, enabled; + + if (!priv->ppio) + return -rte_mtr_error_set(error, EPERM, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is uninitialized\n"); + + mtr = mrvl_mtr_from_id(priv, mtr_id); + if (!mtr) + return -rte_mtr_error_set(error, EEXIST, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter id does not exist\n"); + + profile = mrvl_mtr_profile_from_id(priv, meter_profile_id); + if (!profile) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_METER_PROFILE_ID, + NULL, "Profile id does not exist\n"); + + ret = mrvl_meter_disable(dev, mtr_id, error); + if (ret) + return -rte_mtr_error_set(error, EPERM, + RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, + NULL); + + if (mtr->plcr) { + enabled = 1; + pp2_cls_plcr_deinit(mtr->plcr); + mtr->plcr = NULL; + } + + mtr->profile->refcnt--; + mtr->profile = profile; + profile->refcnt++; + + if (enabled) + return mrvl_meter_enable(dev, mtr_id, error); + + return 0; +} + +const struct rte_mtr_ops mrvl_mtr_ops = { + .capabilities_get = mrvl_capabilities_get, + .meter_profile_add = mrvl_meter_profile_add, + .meter_profile_delete = mrvl_meter_profile_delete, + .create = mrvl_create, + .destroy = mrvl_destroy, + .meter_enable = mrvl_meter_enable, + .meter_disable = mrvl_meter_disable, + .meter_profile_update = mrvl_meter_profile_update, +}; + +/** + * Initialize metering resources. + * + * @param dev Pointer to the device. + */ +void +mrvl_mtr_init(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + LIST_INIT(&priv->profiles); + LIST_INIT(&priv->mtrs); +} + +/** + * Cleanup metering resources. + * + * @param dev Pointer to the device. + */ +void +mrvl_mtr_deinit(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_mtr_profile *profile, *tmp_profile; + struct mrvl_mtr *mtr, *tmp_mtr; + + for (mtr = LIST_FIRST(&priv->mtrs); + mtr && (tmp_mtr = LIST_NEXT(mtr, next), 1); + mtr = tmp_mtr) + mrvl_destroy(dev, mtr->mtr_id, NULL); + + for (profile = LIST_FIRST(&priv->profiles); + profile && (tmp_profile = LIST_NEXT(profile, next), 1); + profile = tmp_profile) + mrvl_meter_profile_delete(dev, profile->profile_id, NULL); +} diff --git a/drivers/net/mvpp2/mrvl_mtr.h b/drivers/net/mvpp2/mrvl_mtr.h new file mode 100644 index 0000000..302a20f --- /dev/null +++ b/drivers/net/mvpp2/mrvl_mtr.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Marvell International Ltd. + * Copyright(c) 2018 Semihalf. + * All rights reserved. + */ + +#ifndef _MRVL_MTR_H_ +#define _MRVL_MTR_H_ + +#include "mrvl_ethdev.h" + +void mrvl_mtr_init(struct rte_eth_dev *dev); +void mrvl_mtr_deinit(struct rte_eth_dev *dev); + +#endif /* _MRVL_MTR_H_ */ From patchwork Tue Sep 4 07:10:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44213 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 716E14CBB; Tue, 4 Sep 2018 09:10:42 +0200 (CEST) Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by dpdk.org (Postfix) with ESMTP id 1707E4C77 for ; Tue, 4 Sep 2018 09:10:41 +0200 (CEST) Received: by mail-pl1-f195.google.com with SMTP id e11-v6so1194816plb.3 for ; Tue, 04 Sep 2018 00:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=km0r2/3X5bFV+JjPzMoTdZiHPDQXGZn3X2vpyUjVupM=; b=ZBaGLb2RVbkTXeFzMveRuvRcIQBjSW7v4B0ezlfmm1FpeM0/RtTTDCzUlBpUPQxF4Q Xf1iU9d3EFVdyZLdt8FdVz1cU2AYfIlNRl1WMtLc3q73Se4YRWQQ05HvGcngP7sdnjuu y0ulGtJ4uOqUJvREPcU8yZkmnxp+B5MXYEHANp2I+yO4/ECzGOiryzLNTHsyouDtgSRE /fD0PPEZo7+DBVR16wiTicFMlmSSaEXlp54DyjWCjMDa1b9fLJ2+40ETP9Y7VUp3yVl6 Oc5ilhFsMThc0wYVuozwmhD/l666SocxwtgMXCKQzUp9cxjggkZqPCBhLPC4D9GDVLiV BtSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=km0r2/3X5bFV+JjPzMoTdZiHPDQXGZn3X2vpyUjVupM=; b=nv7GBJDNuK8HpWdHjdU5H8y3ziKdaT6n+QKdeXYfD7CZG7EDDXMXfk0kLr30lrNZUb 20yHAmKsdZQTRFxmXjf7MsuxpxzUFUO1OweUEsbLNxWBpXuUxz9L2HYT/GSkYNMDMZOZ +x6+A38GnASh7K+0PRXI0skql4DaZ6jCjGe3y14iFpZzH8YZaX8Y9G51Sq1qcRwGk8ML GqRNgkvnR4W0K0fSYEgyxvxgLMAFfMSKpSi32MQ0EDQoRPbcpWOzgEdncQKQFDJEBlaJ Em3GYq5l1mKnTbTn9iWMM4hlCkZu32o89FRHI0ZX4kFuhVi1/LN0Q84GcA+/iP/p2cqc QrvA== X-Gm-Message-State: APzg51BhrvVoGzuLOHOiCyIyl4qKLf6joyPv50q+zcEA2GncMEwXBMYM nHJNNvaWrJuX2AkIrR9Ci9U6uqozkt7EjQ== X-Google-Smtp-Source: ANB0VdaaB8doTGSOCYc6Aeu/sbwyahW+fnAjCYJLGGeesoz1Nq/ODBA0pMS88CHg0sOhiiySuHPDaQ== X-Received: by 2002:a17:902:7447:: with SMTP id e7-v6mr7931706plt.186.1536045039986; Tue, 04 Sep 2018 00:10:39 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:39 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 09:10:12 +0200 Message-Id: <1536045016-32008-5-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 4/8] net/mvpp2: change default policer configuration 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" Change QoS configuration file syntax for port's default policer setup. Since default policer configuration is performed before any other policer configuration we can pick a default id. This simplifies default policer configuration since user no longer has to choose ids from range [0, PP2_CLS_PLCR_NUM]. Explicitly document values for rate_limit_enable field. Signed-off-by: Tomasz Duszynski Signed-off-by: Natalie Samsonov Reviewed-by: Liron Himi --- doc/guides/nics/mvpp2.rst | 31 ++++--- drivers/net/mvpp2/mrvl_ethdev.c | 6 +- drivers/net/mvpp2/mrvl_ethdev.h | 2 +- drivers/net/mvpp2/mrvl_qos.c | 198 ++++++++++++++++++++++------------------ drivers/net/mvpp2/mrvl_qos.h | 2 +- 5 files changed, 134 insertions(+), 105 deletions(-) diff --git a/doc/guides/nics/mvpp2.rst b/doc/guides/nics/mvpp2.rst index 0408752..a452c8a 100644 --- a/doc/guides/nics/mvpp2.rst +++ b/doc/guides/nics/mvpp2.rst @@ -152,20 +152,23 @@ Configuration syntax .. code-block:: console - [port default] - default_tc = - mapping_priority = - policer_enable = + [policer ] token_unit = color = cir = ebs = cbs = + [port default] + default_tc = + mapping_priority = + rate_limit_enable = rate_limit = burst_size = + default_policer = + [port tc ] rxq = pcp = @@ -201,7 +204,9 @@ Where: - ````: List of DSCP values to handle in particular TC (e.g. 0-12 32-48 63). -- ````: Enable ingress policer. +- ````: Id of the policer configuration section to be used as default. + +- ````: Id of the policer configuration section (0..31). - ````: Policer token unit (`bytes` or `packets`). @@ -215,7 +220,7 @@ Where: - ````: Default color for specific tc. -- ````: Enables per port or per txq rate limiting. +- ````: Enables per port or per txq rate limiting (`0`/`1` to disable/enable). - ````: Committed information rate, in kilo bits per second. @@ -234,6 +239,13 @@ Configuration file example .. code-block:: console + [policer 0] + token_unit = bytes + color = blind + cir = 100000 + ebs = 64 + cbs = 64 + [port 0 default] default_tc = 0 mapping_priority = ip @@ -265,12 +277,7 @@ Configuration file example default_tc = 0 mapping_priority = vlan/ip - policer_enable = 1 - token_unit = bytes - color = blind - cir = 100000 - ebs = 64 - cbs = 64 + default_policer = 0 [port 1 tc 0] rxq = 0 diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index a4951d3..1464385 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -798,9 +798,9 @@ mrvl_dev_close(struct rte_eth_dev *dev) } /* policer must be released after ppio deinitialization */ - if (priv->policer) { - pp2_cls_plcr_deinit(priv->policer); - priv->policer = NULL; + if (priv->default_policer) { + pp2_cls_plcr_deinit(priv->default_policer); + priv->default_policer = NULL; } } diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index ecb8fdc..de423a9 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.h +++ b/drivers/net/mvpp2/mrvl_ethdev.h @@ -168,7 +168,7 @@ struct mrvl_priv { uint32_t cls_tbl_pattern; LIST_HEAD(mrvl_flows, rte_flow) flows; - struct pp2_cls_plcr *policer; + struct pp2_cls_plcr *default_policer; LIST_HEAD(profiles, mrvl_mtr_profile) profiles; LIST_HEAD(mtrs, mrvl_mtr) mtrs; diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index eeb46f8..e039635 100644 --- a/drivers/net/mvpp2/mrvl_qos.c +++ b/drivers/net/mvpp2/mrvl_qos.c @@ -42,7 +42,8 @@ #define MRVL_TOK_WRR_WEIGHT "wrr_weight" /* policer specific configuration tokens */ -#define MRVL_TOK_PLCR_ENABLE "policer_enable" +#define MRVL_TOK_PLCR "policer" +#define MRVL_TOK_PLCR_DEFAULT "default_policer" #define MRVL_TOK_PLCR_UNIT "token_unit" #define MRVL_TOK_PLCR_UNIT_BYTES "bytes" #define MRVL_TOK_PLCR_UNIT_PACKETS "packets" @@ -368,6 +369,9 @@ parse_tc_cfg(struct rte_cfgfile *file, int port, int tc, cfg->port[port].tc[tc].dscps = n; } + if (!cfg->port[port].setup_policer) + return 0; + entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_DEFAULT_COLOR); if (entry) { @@ -390,6 +394,85 @@ parse_tc_cfg(struct rte_cfgfile *file, int port, int tc, } /** + * Parse default port policer. + * + * @param file Config file handle. + * @param sec_name Section name with policer configuration + * @param port Port number. + * @param cfg[out] Parsing results. + * @returns 0 in case of success, negative value otherwise. + */ +static int +parse_policer(struct rte_cfgfile *file, int port, const char *sec_name, + struct mrvl_qos_cfg *cfg) +{ + const char *entry; + uint32_t val; + + /* Read policer token unit */ + entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_UNIT); + if (entry) { + if (!strncmp(entry, MRVL_TOK_PLCR_UNIT_BYTES, + sizeof(MRVL_TOK_PLCR_UNIT_BYTES))) { + cfg->port[port].policer_params.token_unit = + PP2_CLS_PLCR_BYTES_TOKEN_UNIT; + } else if (!strncmp(entry, MRVL_TOK_PLCR_UNIT_PACKETS, + sizeof(MRVL_TOK_PLCR_UNIT_PACKETS))) { + cfg->port[port].policer_params.token_unit = + PP2_CLS_PLCR_PACKETS_TOKEN_UNIT; + } else { + RTE_LOG(ERR, PMD, "Unknown token: %s\n", entry); + return -1; + } + } + + /* Read policer color mode */ + entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_COLOR); + if (entry) { + if (!strncmp(entry, MRVL_TOK_PLCR_COLOR_BLIND, + sizeof(MRVL_TOK_PLCR_COLOR_BLIND))) { + cfg->port[port].policer_params.color_mode = + PP2_CLS_PLCR_COLOR_BLIND_MODE; + } else if (!strncmp(entry, MRVL_TOK_PLCR_COLOR_AWARE, + sizeof(MRVL_TOK_PLCR_COLOR_AWARE))) { + cfg->port[port].policer_params.color_mode = + PP2_CLS_PLCR_COLOR_AWARE_MODE; + } else { + RTE_LOG(ERR, PMD, "Error in parsing: %s\n", entry); + return -1; + } + } + + /* Read policer cir */ + entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_CIR); + if (entry) { + if (get_val_securely(entry, &val) < 0) + return -1; + cfg->port[port].policer_params.cir = val; + } + + /* Read policer cbs */ + entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_CBS); + if (entry) { + if (get_val_securely(entry, &val) < 0) + return -1; + cfg->port[port].policer_params.cbs = val; + } + + /* Read policer ebs */ + entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_EBS); + if (entry) { + if (get_val_securely(entry, &val) < 0) + return -1; + cfg->port[port].policer_params.ebs = val; + } + + cfg->port[port].setup_policer = 1; + + return 0; +} + +/** * Parse QoS configuration - rte_kvargs_process handler. * * Opens configuration file and parses its content. @@ -457,88 +540,6 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, return -1; } - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_PLCR_ENABLE); - if (entry) { - if (get_val_securely(entry, &val) < 0) - return -1; - (*cfg)->port[n].policer_enable = val; - } - - if ((*cfg)->port[n].policer_enable) { - enum pp2_cls_plcr_token_unit unit; - - /* Read policer token unit */ - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_PLCR_UNIT); - if (entry) { - if (!strncmp(entry, MRVL_TOK_PLCR_UNIT_BYTES, - sizeof(MRVL_TOK_PLCR_UNIT_BYTES))) { - unit = PP2_CLS_PLCR_BYTES_TOKEN_UNIT; - } else if (!strncmp(entry, - MRVL_TOK_PLCR_UNIT_PACKETS, - sizeof(MRVL_TOK_PLCR_UNIT_PACKETS))) { - unit = PP2_CLS_PLCR_PACKETS_TOKEN_UNIT; - } else { - MRVL_LOG(ERR, "Unknown token: %s", - entry); - return -1; - } - (*cfg)->port[n].policer_params.token_unit = - unit; - } - - /* Read policer color mode */ - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_PLCR_COLOR); - if (entry) { - enum pp2_cls_plcr_color_mode mode; - - if (!strncmp(entry, MRVL_TOK_PLCR_COLOR_BLIND, - sizeof(MRVL_TOK_PLCR_COLOR_BLIND))) { - mode = PP2_CLS_PLCR_COLOR_BLIND_MODE; - } else if (!strncmp(entry, - MRVL_TOK_PLCR_COLOR_AWARE, - sizeof(MRVL_TOK_PLCR_COLOR_AWARE))) { - mode = PP2_CLS_PLCR_COLOR_AWARE_MODE; - } else { - MRVL_LOG(ERR, - "Error in parsing: %s", - entry); - return -1; - } - (*cfg)->port[n].policer_params.color_mode = - mode; - } - - /* Read policer cir */ - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_PLCR_CIR); - if (entry) { - if (get_val_securely(entry, &val) < 0) - return -1; - (*cfg)->port[n].policer_params.cir = val; - } - - /* Read policer cbs */ - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_PLCR_CBS); - if (entry) { - if (get_val_securely(entry, &val) < 0) - return -1; - (*cfg)->port[n].policer_params.cbs = val; - } - - /* Read policer ebs */ - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_PLCR_EBS); - if (entry) { - if (get_val_securely(entry, &val) < 0) - return -1; - (*cfg)->port[n].policer_params.ebs = val; - } - } - /* * Read per-port rate limiting. Setting that will * disable per-queue rate limiting. @@ -597,6 +598,20 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, PP2_CLS_QOS_TBL_VLAN_IP_PRI; } + /* Parse policer configuration (if any) */ + entry = rte_cfgfile_get_entry(file, sec_name, + MRVL_TOK_PLCR_DEFAULT); + if (entry) { + if (get_val_securely(entry, &val) < 0) + return -1; + + snprintf(sec_name, sizeof(sec_name), "%s %d", + MRVL_TOK_PLCR, val); + ret = parse_policer(file, n, sec_name, *cfg); + if (ret) + return -1; + } + for (i = 0; i < MRVL_PP2_RXQ_MAX; ++i) { ret = get_outq_cfg(file, n, i, *cfg); if (ret < 0) @@ -659,6 +674,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs, * * @param priv Port's private data. * @param params Pointer to the policer's configuration. + * @param plcr_id Policer id. * @returns 0 in case of success, negative values otherwise. */ static int @@ -667,17 +683,23 @@ setup_policer(struct mrvl_priv *priv, struct pp2_cls_plcr_params *params) char match[16]; int ret; - snprintf(match, sizeof(match), "policer-%d:%d\n", - priv->pp_id, priv->ppio_id); + /* + * At this point no other policers are used which means + * any policer can be picked up and used as a default one. + * + * Lets use 0th then. + */ + sprintf(match, "policer-%d:%d\n", priv->pp_id, 0); params->match = match; - ret = pp2_cls_plcr_init(params, &priv->policer); + ret = pp2_cls_plcr_init(params, &priv->default_policer); if (ret) { MRVL_LOG(ERR, "Failed to setup %s", match); return -1; } - priv->ppio_params.inqs_params.plcr = priv->policer; + priv->ppio_params.inqs_params.plcr = priv->default_policer; + priv->used_plcrs = BIT(0); return 0; } @@ -809,7 +831,7 @@ mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid, priv->ppio_params.inqs_params.num_tcs = i; - if (port_cfg->policer_enable) + if (port_cfg->setup_policer) return setup_policer(priv, &port_cfg->policer_params); return 0; diff --git a/drivers/net/mvpp2/mrvl_qos.h b/drivers/net/mvpp2/mrvl_qos.h index fa9ddec..f03e773 100644 --- a/drivers/net/mvpp2/mrvl_qos.h +++ b/drivers/net/mvpp2/mrvl_qos.h @@ -43,7 +43,7 @@ struct mrvl_qos_cfg { uint8_t default_tc; uint8_t use_global_defaults; struct pp2_cls_plcr_params policer_params; - uint8_t policer_enable; + uint8_t setup_policer; } port[RTE_MAX_ETHPORTS]; }; From patchwork Tue Sep 4 07:10:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44214 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3EE5F4D3A; Tue, 4 Sep 2018 09:10:45 +0200 (CEST) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 4F3C52BF7 for ; Tue, 4 Sep 2018 09:10:43 +0200 (CEST) Received: by mail-pf1-f193.google.com with SMTP id p12-v6so1235557pfh.2 for ; Tue, 04 Sep 2018 00:10:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j8KUDWso1N84oCd1YwrgDHqam7TiIe6PQ4Sy/GDxrtc=; b=PUXtUIHLTqDODfAfKmqtiiQiHHcWNh9zJbFSeHbFx+CK52aWsoSrgCSIngS3TcDRxN OSvvF99mN19wy3Jjk7dOeyl4B0nJRoFbJzuQaVV7N44Tfi2h7IHMQSYgNIW4YLvZvjsX FkOp/AGm5R+M6/eYnyfEdQyTMGuhyvGjriIwVbAmX/H3jojLYLPeM2TQVNLsaha6IeRG eLBGR2yk8fWwyNq1bnN6dm4sMtqMuuGjnWlyqHpI9nk68QkII+6ZwWJiTU5E04Jo50zz Erk+Z2XR8f6Q1OkDN8gLYS6797/GZLDXy4keXZbiTFoc2limDFPJowW4r/BuK4ICJP7q qiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j8KUDWso1N84oCd1YwrgDHqam7TiIe6PQ4Sy/GDxrtc=; b=t68DULBsX4YXHg/JLuEuLsLmZXAPihvKncEYvNTgbGb6wNFN1tkyxFAur5W617A7gT iHZZEWYo04kqkZhu9U4iLgUOfV+HNsQYLYdHtSu5K2gBpeSuz+/J83lVy4l/OK/ReSdj Yrvh/ge9anOQFJsm6G5A6XkTGnthqV/Z8B7IS3e069UCmtLsQJAcFY79pALP8BgbjAK7 z8+sA/UvIa4dfDOI4HsfxonLcyubOekNzO0AUhNifMYvMTH80wDU2jTxt7xSURxfsl77 mfd6gjOQJLaOx2VcQvk5MQR1qUaf/RVZtIafKgOrSUhM1a3og7qeHYIliRvy+4JmemoT 1ymw== X-Gm-Message-State: APzg51BAQ6SztOUl6atz6e8oPTU24I2dw4bp6/911KL0zD8W9sH77oIS 1oXNeHeJJmZW36rvPuy164+AAd0/Sg+PBA== X-Google-Smtp-Source: ANB0VdZPYtzzYy5eCPbqrh9Dvf3MeNcyFk/vOKaDAqtcDv6tGtuq+0LeEVuzZihXzsA+KgHLe0Tm7Q== X-Received: by 2002:a63:e001:: with SMTP id e1-v6mr3917251pgh.380.1536045042480; Tue, 04 Sep 2018 00:10:42 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:41 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 09:10:13 +0200 Message-Id: <1536045016-32008-6-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 5/8] net/mvpp2: add init and deinit to flow 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" Add init and deinit functionality to flow implementation. Init puts structures used by flow in a sane sate. Deinit deallocates all resources used by flow. Signed-off-by: Tomasz Duszynski Signed-off-by: Natalie Samsonov Reviewed-by: Liron Himi Reviewed-by: Shlomi Gridish --- drivers/net/mvpp2/mrvl_ethdev.c | 3 +++ drivers/net/mvpp2/mrvl_flow.c | 33 ++++++++++++++++++++++++++++++++- drivers/net/mvpp2/mrvl_flow.h | 15 +++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 drivers/net/mvpp2/mrvl_flow.h diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 1464385..5e3a106 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -23,6 +23,7 @@ #include #include "mrvl_ethdev.h" #include "mrvl_qos.h" +#include "mrvl_flow.h" #include "mrvl_mtr.h" /* bitmask with reserved hifs */ @@ -628,6 +629,7 @@ mrvl_dev_start(struct rte_eth_dev *dev) goto out; } + mrvl_flow_init(dev); mrvl_mtr_init(dev); return 0; @@ -768,6 +770,7 @@ mrvl_dev_close(struct rte_eth_dev *dev) mrvl_flush_rx_queues(dev); mrvl_flush_tx_shadow_queues(dev); + mrvl_flow_deinit(dev); mrvl_mtr_deinit(dev); for (i = 0; i < priv->ppio_params.inqs_params.num_tcs; ++i) { diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index e6953e4..065b1aa 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -11,7 +11,7 @@ #include -#include "mrvl_ethdev.h" +#include "mrvl_flow.h" #include "mrvl_qos.h" /** Number of rules in the classifier table. */ @@ -2790,3 +2790,34 @@ const struct rte_flow_ops mrvl_flow_ops = { .flush = mrvl_flow_flush, .isolate = mrvl_flow_isolate }; + +/** + * Initialize flow resources. + * + * @param dev Pointer to the device. + */ +void +mrvl_flow_init(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + LIST_INIT(&priv->flows); +} + +/** + * Cleanup flow resources. + * + * @param dev Pointer to the device. + */ +void +mrvl_flow_deinit(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + mrvl_flow_flush(dev, NULL); + + if (priv->cls_tbl) { + pp2_cls_tbl_deinit(priv->cls_tbl); + priv->cls_tbl = NULL; + } +} diff --git a/drivers/net/mvpp2/mrvl_flow.h b/drivers/net/mvpp2/mrvl_flow.h new file mode 100644 index 0000000..f63747c --- /dev/null +++ b/drivers/net/mvpp2/mrvl_flow.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Marvell International Ltd. + * Copyright(c) 2018 Semihalf. + * All rights reserved. + */ + +#ifndef _MRVL_FLOW_H_ +#define _MRVL_FLOW_H_ + +#include "mrvl_ethdev.h" + +void mrvl_flow_init(struct rte_eth_dev *dev); +void mrvl_flow_deinit(struct rte_eth_dev *dev); + +#endif /* _MRVL_FLOW_H_ */ From patchwork Tue Sep 4 07:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44215 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 990B9325F; Tue, 4 Sep 2018 09:10:48 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 20584325F for ; Tue, 4 Sep 2018 09:10:46 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id s15-v6so1193266pgv.8 for ; Tue, 04 Sep 2018 00:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fIafgEIxECBIfJTho83JgbTda30Dmxn9ZApXp0Z/VFc=; b=Sm0TRnQlq/OzYaPdUYBo9yrEX8PQAPQMLnFXoR8VN9cPPYDQJEbx2zQQ2Ihmp2XAJb jg2GMjgzZj3H2aY1sKfrcvvVBOo1cWlmbbM2V7wSUPybC3lHMibL7nG0jRh8HE84+8QA XdMuvML0G+jAEcfNUIJxpMiSOdtCSLPWUax/pjyOxL7hyA3flfBTpJJfN99S9FIWmxQT ifad8lU0vq7CAAl35d/oNsSZ6kupKceXnlAi4eGF7QS8ZnF2KWFRo6Lk8lm8JGR2KcIy Ju32/JJfvW608q2F3jq4GzQO9vpVioAncgAXPMQo+0acOPFzh4NsFL/w1PJ4Q/IQ6qAx f0jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fIafgEIxECBIfJTho83JgbTda30Dmxn9ZApXp0Z/VFc=; b=C+zH+5WCnRbbbxqkSzvsUCjA7Su0bkhjnDdcTW8uGNx79nnNGZtW0Eg1OrZF9pcGWv JO59EEDazHWan/WNwnx/54Th3Cc+fT56VyXlsNe0ocASDy937GYGAJRReYafuRSRxpAY 2e4ySObeswhWiEmPZbE4jDtOzQ/hFBlaPufgMa8HtcsJ59v6Wy4YRZIq5Xjpj00MbUFS 3QyXwzZc8VuGfVEi+8gpMOvpc8zorEwJq+Cbms1tbkmfQ1VcwLaz0SUMYZVDnUYTV9tE qrkd/k6DBONE/sl3oLOKM+JY02W5Vw5vkSIgPDAYDYM5KFp2w4krxelcIQh3a4GI/UfL 0wNQ== X-Gm-Message-State: APzg51AMX9TzUvDvZN41tOk8EYtB7N8GFQVCxWVBXRB0OoGtTV8iM7n7 R+RzoBYuKPg+ExrW+KP//vVEhcNkdL53cA== X-Google-Smtp-Source: ANB0VdannODrVCEGjBC/TJYdHFGo7nhuxBYlMD4oVjzvkFAOtizYHMgbox8OC0wSyXiaCVqCewdLWw== X-Received: by 2002:a63:60c1:: with SMTP id u184-v6mr30032416pgb.266.1536045045275; Tue, 04 Sep 2018 00:10:45 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:44 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 09:10:14 +0200 Message-Id: <1536045016-32008-7-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 6/8] net/mvpp2: add traffic manager support 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" Add traffic manager support. Signed-off-by: Tomasz Duszynski Signed-off-by: Natalie Samsonov Reviewed-by: Liron Himi --- drivers/net/mvpp2/Makefile | 1 + drivers/net/mvpp2/meson.build | 3 +- drivers/net/mvpp2/mrvl_ethdev.c | 26 + drivers/net/mvpp2/mrvl_ethdev.h | 31 ++ drivers/net/mvpp2/mrvl_tm.c | 1009 +++++++++++++++++++++++++++++++++++++++ drivers/net/mvpp2/mrvl_tm.h | 15 + 6 files changed, 1084 insertions(+), 1 deletion(-) create mode 100644 drivers/net/mvpp2/mrvl_tm.c create mode 100644 drivers/net/mvpp2/mrvl_tm.h diff --git a/drivers/net/mvpp2/Makefile b/drivers/net/mvpp2/Makefile index 4848d65..661d2cd 100644 --- a/drivers/net/mvpp2/Makefile +++ b/drivers/net/mvpp2/Makefile @@ -40,5 +40,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_ethdev.c SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_qos.c SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_flow.c SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_mtr.c +SRCS-$(CONFIG_RTE_LIBRTE_MVPP2_PMD) += mrvl_tm.c include $(RTE_SDK)/mk/rte.lib.mk diff --git a/drivers/net/mvpp2/meson.build b/drivers/net/mvpp2/meson.build index f475511..70ef2d6 100644 --- a/drivers/net/mvpp2/meson.build +++ b/drivers/net/mvpp2/meson.build @@ -20,7 +20,8 @@ sources = files( 'mrvl_ethdev.c', 'mrvl_flow.c', 'mrvl_qos.c', - 'mrvl_mtr.c' + 'mrvl_mtr.c', + 'mrvl_tm.c' ) deps += ['cfgfile', 'common_mvep'] diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 5e3a106..a1dc6b1 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -25,6 +25,7 @@ #include "mrvl_qos.h" #include "mrvl_flow.h" #include "mrvl_mtr.h" +#include "mrvl_tm.h" /* bitmask with reserved hifs */ #define MRVL_MUSDK_HIFS_RESERVED 0x0F @@ -340,6 +341,10 @@ mrvl_dev_configure(struct rte_eth_dev *dev) priv->ppio_params.maintain_stats = 1; priv->nb_rx_queues = dev->data->nb_rx_queues; + ret = mrvl_tm_init(dev); + if (ret < 0) + return ret; + if (dev->data->nb_rx_queues == 1 && dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS) { MRVL_LOG(WARNING, "Disabling hash for 1 rx queue"); @@ -794,6 +799,7 @@ mrvl_dev_close(struct rte_eth_dev *dev) } mrvl_flush_bpool(dev); + mrvl_tm_deinit(dev); if (priv->ppio) { pp2_ppio_deinit(priv->ppio); @@ -1894,6 +1900,25 @@ mrvl_mtr_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops) return 0; } +/** + * DPDK callback to get rte_tm callbacks. + * + * @param dev + * Pointer to the device structure. + * @param ops + * Pointer to pass the tm ops. + * + * @return + * Always 0. + */ +static int +mrvl_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops) +{ + *(const void **)ops = &mrvl_tm_ops; + + return 0; +} + static const struct eth_dev_ops mrvl_ops = { .dev_configure = mrvl_dev_configure, .dev_start = mrvl_dev_start, @@ -1932,6 +1957,7 @@ static const struct eth_dev_ops mrvl_ops = { .rss_hash_conf_get = mrvl_rss_hash_conf_get, .filter_ctrl = mrvl_eth_filter_ctrl, .mtr_ops_get = mrvl_mtr_ops_get, + .tm_ops_get = mrvl_tm_ops_get, }; /** diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index de423a9..984f31e 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.h +++ b/drivers/net/mvpp2/mrvl_ethdev.h @@ -10,6 +10,7 @@ #include #include #include +#include /* * container_of is defined by both DPDK and MUSDK, @@ -134,6 +135,29 @@ struct mrvl_mtr { struct pp2_cls_plcr *plcr; }; +struct mrvl_tm_shaper_profile { + LIST_ENTRY(mrvl_tm_shaper_profile) next; + uint32_t id; + int refcnt; + struct rte_tm_shaper_params params; +}; + +enum { + MRVL_NODE_PORT, + MRVL_NODE_QUEUE, +}; + +struct mrvl_tm_node { + LIST_ENTRY(mrvl_tm_node) next; + uint32_t id; + uint32_t type; + int refcnt; + struct mrvl_tm_node *parent; + struct mrvl_tm_shaper_profile *profile; + uint8_t weight; + uint64_t stats_mask; +}; + struct mrvl_priv { /* Hot fields, used in fast path. */ struct pp2_bpool *bpool; /**< BPool pointer */ @@ -173,6 +197,10 @@ struct mrvl_priv { LIST_HEAD(profiles, mrvl_mtr_profile) profiles; LIST_HEAD(mtrs, mrvl_mtr) mtrs; uint32_t used_plcrs; + + LIST_HEAD(shaper_profiles, mrvl_tm_shaper_profile) shaper_profiles; + LIST_HEAD(nodes, mrvl_tm_node) nodes; + uint64_t rate_max; }; /** Flow operations forward declaration. */ @@ -181,6 +209,9 @@ extern const struct rte_flow_ops mrvl_flow_ops; /** Meter operations forward declaration. */ extern const struct rte_mtr_ops mrvl_mtr_ops; +/** Traffic manager operations forward declaration. */ +extern const struct rte_tm_ops mrvl_tm_ops; + /** Current log type. */ extern int mrvl_logtype; diff --git a/drivers/net/mvpp2/mrvl_tm.c b/drivers/net/mvpp2/mrvl_tm.c new file mode 100644 index 0000000..3de8997 --- /dev/null +++ b/drivers/net/mvpp2/mrvl_tm.c @@ -0,0 +1,1009 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Marvell International Ltd. + * Copyright(c) 2018 Semihalf. + * All rights reserved. + */ + +#include + +#include +#include +#include +#include + +#include "mrvl_tm.h" + +/** Minimum rate value in Bytes/s */ +#define MRVL_RATE_MIN (PP2_PPIO_MIN_CIR * 1000 / 8) + +/** Minimum burst size in Bytes */ +#define MRVL_BURST_MIN (PP2_PPIO_MIN_CBS * 1000) + +/** Maximum burst size in Bytes */ +#define MRVL_BURST_MAX 256000000 + +/** Maximum WRR weight */ +#define MRVL_WEIGHT_MAX 255 + +/** + * Get maximum port rate in Bytes/s. + * + * @param dev Pointer to the device. + * @param rate Pointer to the rate. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_get_max_rate(struct rte_eth_dev *dev, uint64_t *rate) +{ + struct ethtool_cmd edata; + struct ifreq req; + int ret, fd; + + memset(&edata, 0, sizeof(edata)); + memset(&req, 0, sizeof(req)); + edata.cmd = ETHTOOL_GSET; + strcpy(req.ifr_name, dev->data->name); + req.ifr_data = (void *)&edata; + + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd == -1) + return -1; + + ret = ioctl(fd, SIOCETHTOOL, &req); + if (ret == -1) { + close(fd); + return -1; + } + + close(fd); + + *rate = ethtool_cmd_speed(&edata) * 1000 * 1000 / 8; + + return 0; +} + +/** + * Initialize traffic manager related data. + * + * @param dev Pointer to the device. + * @returns 0 on success, failure otherwise. + */ +int +mrvl_tm_init(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + LIST_INIT(&priv->shaper_profiles); + LIST_INIT(&priv->nodes); + + if (priv->rate_max) + return 0; + + return mrvl_get_max_rate(dev, &priv->rate_max); +} + +/** + * Cleanup traffic manager related data. + * + * @param dev Pointer to the device. + */ +void mrvl_tm_deinit(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_shaper_profile *profile = + LIST_FIRST(&priv->shaper_profiles); + struct mrvl_tm_node *node = LIST_FIRST(&priv->nodes); + + while (profile) { + struct mrvl_tm_shaper_profile *next = LIST_NEXT(profile, next); + + LIST_REMOVE(profile, next); + rte_free(profile); + profile = next; + } + + while (node) { + struct mrvl_tm_node *next = LIST_NEXT(node, next); + + LIST_REMOVE(node, next); + rte_free(node); + node = next; + } +} + +/** + * Get node using its id. + * + * @param priv Pointer to the port's private data. + * @param node_id Id used by this node. + * @returns Pointer to the node if exists, NULL otherwise. + */ +static struct mrvl_tm_node * +mrvl_node_from_id(struct mrvl_priv *priv, uint32_t node_id) +{ + struct mrvl_tm_node *node; + + LIST_FOREACH(node, &priv->nodes, next) + if (node->id == node_id) + return node; + + return NULL; +} + +/** + * Check whether node is leaf or root. + * + * @param dev Pointer to the device. + * @param node_id Id used by this node. + * @param is_leaf Pointer to flag indicating whether node is a leaf. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_type_get(struct rte_eth_dev *dev, uint32_t node_id, int *is_leaf, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + + if (!is_leaf) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + *is_leaf = node->type == MRVL_NODE_QUEUE ? 1 : 0; + + return 0; +} + +/** + * Get traffic manager capabilities. + * + * @param dev Pointer to the device (unused). + * @param cap Pointer to the capabilities. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_capabilities_get(struct rte_eth_dev *dev, + struct rte_tm_capabilities *cap, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + if (!cap) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Capabilities are missing\n"); + + memset(cap, 0, sizeof(*cap)); + + cap->n_nodes_max = 1 + dev->data->nb_tx_queues; /* port + txqs number */ + cap->n_levels_max = 2; /* port level + txqs level */ + cap->non_leaf_nodes_identical = 1; + cap->leaf_nodes_identical = 1; + + cap->shaper_n_max = cap->n_nodes_max; + cap->shaper_private_n_max = cap->shaper_n_max; + cap->shaper_private_rate_min = MRVL_RATE_MIN; + cap->shaper_private_rate_max = priv->rate_max; + + cap->sched_n_children_max = dev->data->nb_tx_queues; + cap->sched_sp_n_priorities_max = dev->data->nb_tx_queues; + cap->sched_wfq_n_children_per_group_max = dev->data->nb_tx_queues; + cap->sched_wfq_n_groups_max = 1; + cap->sched_wfq_weight_max = MRVL_WEIGHT_MAX; + + cap->dynamic_update_mask = RTE_TM_UPDATE_NODE_SUSPEND_RESUME | + RTE_TM_UPDATE_NODE_STATS; + cap->stats_mask = RTE_TM_STATS_N_PKTS | RTE_TM_STATS_N_BYTES; + + return 0; +} + +/** + * Get traffic manager hierarchy level capabilities. + * + * @param dev Pointer to the device. + * @param level_id Id of the level. + * @param cap Pointer to the level capabilities. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_level_capabilities_get(struct rte_eth_dev *dev, + uint32_t level_id, + struct rte_tm_level_capabilities *cap, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + if (!cap) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + memset(cap, 0, sizeof(*cap)); + + if (level_id != MRVL_NODE_PORT && level_id != MRVL_NODE_QUEUE) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_LEVEL_ID, + NULL, "Wrong level id\n"); + + if (level_id == MRVL_NODE_PORT) { + cap->n_nodes_max = 1; + cap->n_nodes_nonleaf_max = 1; + cap->non_leaf_nodes_identical = 1; + + cap->nonleaf.shaper_private_supported = 1; + cap->nonleaf.shaper_private_rate_min = MRVL_RATE_MIN; + cap->nonleaf.shaper_private_rate_max = priv->rate_max; + + cap->nonleaf.sched_n_children_max = dev->data->nb_tx_queues; + cap->nonleaf.sched_sp_n_priorities_max = 1; + cap->nonleaf.sched_wfq_n_children_per_group_max = + dev->data->nb_tx_queues; + cap->nonleaf.sched_wfq_n_groups_max = 1; + cap->nonleaf.sched_wfq_weight_max = MRVL_WEIGHT_MAX; + cap->nonleaf.stats_mask = RTE_TM_STATS_N_PKTS | + RTE_TM_STATS_N_BYTES; + } else { /* level_id == MRVL_NODE_QUEUE */ + cap->n_nodes_max = dev->data->nb_tx_queues; + cap->n_nodes_leaf_max = dev->data->nb_tx_queues; + cap->leaf_nodes_identical = 1; + + cap->leaf.shaper_private_supported = 1; + cap->leaf.shaper_private_rate_min = MRVL_RATE_MIN; + cap->leaf.shaper_private_rate_max = priv->rate_max; + cap->leaf.stats_mask = RTE_TM_STATS_N_PKTS; + } + + return 0; +} + +/** + * Get node capabilities. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param cap Pointer to the capabilities. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_capabilities_get(struct rte_eth_dev *dev, uint32_t node_id, + struct rte_tm_node_capabilities *cap, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + + if (!cap) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + memset(cap, 0, sizeof(*cap)); + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + cap->shaper_private_supported = 1; + cap->shaper_private_rate_min = MRVL_RATE_MIN; + cap->shaper_private_rate_max = priv->rate_max; + + if (node->type == MRVL_NODE_PORT) { + cap->nonleaf.sched_n_children_max = dev->data->nb_tx_queues; + cap->nonleaf.sched_sp_n_priorities_max = 1; + cap->nonleaf.sched_wfq_n_children_per_group_max = + dev->data->nb_tx_queues; + cap->nonleaf.sched_wfq_n_groups_max = 1; + cap->nonleaf.sched_wfq_weight_max = MRVL_WEIGHT_MAX; + cap->stats_mask = RTE_TM_STATS_N_PKTS | RTE_TM_STATS_N_BYTES; + } else { + cap->stats_mask = RTE_TM_STATS_N_PKTS; + } + + return 0; +} + +/** + * Get shaper profile using its id. + * + * @param priv Pointer to the port's private data. + * @param shaper_profile_id Id used by the shaper. + * @returns Pointer to the shaper profile if exists, NULL otherwise. + */ +static struct mrvl_tm_shaper_profile * +mrvl_shaper_profile_from_id(struct mrvl_priv *priv, uint32_t shaper_profile_id) +{ + struct mrvl_tm_shaper_profile *profile; + + LIST_FOREACH(profile, &priv->shaper_profiles, next) + if (profile->id == shaper_profile_id) + return profile; + + return NULL; +} + +/** + * Add a new shaper profile. + * + * @param dev Pointer to the device. + * @param shaper_profile_id Id of the new profile. + * @param params Pointer to the shaper profile parameters. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_shaper_profile_add(struct rte_eth_dev *dev, uint32_t shaper_profile_id, + struct rte_tm_shaper_params *params, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_shaper_profile *profile; + + if (!params) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + if (params->committed.rate) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE, + NULL, "Committed rate not supported\n"); + + if (params->committed.size) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE, + NULL, "Committed bucket size not supported\n"); + + if (params->peak.rate < MRVL_RATE_MIN || + params->peak.rate > priv->rate_max) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_RATE, + NULL, "Peak rate is out of range\n"); + + if (params->peak.size < MRVL_BURST_MIN || + params->peak.size > MRVL_BURST_MAX) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE, + NULL, "Peak size is out of range\n"); + + if (shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID, + NULL, "Wrong shaper profile id\n"); + + profile = mrvl_shaper_profile_from_id(priv, shaper_profile_id); + if (profile) + return -rte_tm_error_set(error, EEXIST, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID, + NULL, "Profile id already exists\n"); + + profile = rte_zmalloc_socket(NULL, sizeof(*profile), 0, + rte_socket_id()); + if (!profile) + return -rte_tm_error_set(error, ENOMEM, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + profile->id = shaper_profile_id; + rte_memcpy(&profile->params, params, sizeof(profile->params)); + + LIST_INSERT_HEAD(&priv->shaper_profiles, profile, next); + + return 0; +} + +/** + * Remove a shaper profile. + * + * @param dev Pointer to the device. + * @param shaper_profile_id Id of the shaper profile. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_shaper_profile_delete(struct rte_eth_dev *dev, uint32_t shaper_profile_id, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_shaper_profile *profile; + + profile = mrvl_shaper_profile_from_id(priv, shaper_profile_id); + if (!profile) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID, + NULL, "Profile id does not exist\n"); + + if (profile->refcnt) + return -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID, + NULL, "Profile is used\n"); + + LIST_REMOVE(profile, next); + rte_free(profile); + + return 0; +} + +/** + * Check node parameters. + * + * @param dev Pointer to the device. + * @param node_id Id used by the node. + * @param priority Priority value. + * @param weight Weight value. + * @param level_id Id of the level. + * @param params Pointer to the node parameters. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_check_params(struct rte_eth_dev *dev, uint32_t node_id, + uint32_t priority, uint32_t weight, uint32_t level_id, + struct rte_tm_node_params *params, + struct rte_tm_error *error) +{ + if (node_id == RTE_TM_NODE_ID_NULL) + return -rte_tm_error_set(error, EINVAL, RTE_TM_NODE_ID_NULL, + NULL, "Node id is invalid\n"); + + if (priority) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PRIORITY, + NULL, "Priority should be 0\n"); + + if (weight > MRVL_WEIGHT_MAX) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_WEIGHT, + NULL, "Weight is out of range\n"); + + if (level_id != MRVL_NODE_PORT && level_id != MRVL_NODE_QUEUE) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_LEVEL_ID, + NULL, "Wrong level id\n"); + + if (!params) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + if (params->shared_shaper_id) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_SHAPER_ID, + NULL, "Shared shaper is not supported\n"); + + if (params->n_shared_shapers) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_SHAPERS, + NULL, "Shared shaper is not supported\n"); + + /* verify port (root node) settings */ + if (node_id >= dev->data->nb_tx_queues) { + if (params->nonleaf.wfq_weight_mode) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_WFQ_WEIGHT_MODE, + NULL, "WFQ is not supported\n"); + + if (params->nonleaf.n_sp_priorities != 1) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SP_PRIORITIES, + NULL, "SP is not supported\n"); + + if (params->stats_mask & ~(RTE_TM_STATS_N_PKTS | + RTE_TM_STATS_N_BYTES)) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS, + NULL, + "Requested port stats are not supported\n"); + + return 0; + } + + /* verify txq (leaf node) settings */ + if (params->leaf.cman) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_CMAN, + NULL, + "Congestion mngmt is not supported\n"); + + if (params->leaf.wred.wred_profile_id) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_WRED_PROFILE_ID, + NULL, "WRED is not supported\n"); + + if (params->leaf.wred.shared_wred_context_id) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_SHARED_WRED_CONTEXT_ID, + NULL, "WRED is not supported\n"); + + if (params->leaf.wred.n_shared_wred_contexts) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_N_SHARED_WRED_CONTEXTS, + NULL, "WRED is not supported\n"); + + if (params->stats_mask & ~RTE_TM_STATS_N_PKTS) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS, + NULL, + "Requested txq stats are not supported\n"); + + return 0; +} + +/** + * Add a new node. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param parent_node_id Id of the parent node. + * @param priority Priority value. + * @param weight Weight value. + * @param level_id Id of the level. + * @param params Pointer to the node parameters. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_add(struct rte_eth_dev *dev, uint32_t node_id, + uint32_t parent_node_id, uint32_t priority, uint32_t weight, + uint32_t level_id, struct rte_tm_node_params *params, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_shaper_profile *profile = NULL; + struct mrvl_tm_node *node, *parent = NULL; + int ret; + + if (priv->ppio) + return -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is already started\n"); + + ret = mrvl_node_check_params(dev, node_id, priority, weight, level_id, + params, error); + if (ret) + return ret; + + if (params->shaper_profile_id != RTE_TM_SHAPER_PROFILE_ID_NONE) { + profile = mrvl_shaper_profile_from_id(priv, + params->shaper_profile_id); + if (!profile) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID, + NULL, "Shaper id does not exist\n"); + } + + if (parent_node_id == RTE_TM_NODE_ID_NULL) { + LIST_FOREACH(node, &priv->nodes, next) { + if (node->type != MRVL_NODE_PORT) + continue; + + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Root node exists\n"); + } + } else { + parent = mrvl_node_from_id(priv, parent_node_id); + if (!parent) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARENT_NODE_ID, + NULL, "Node id does not exist\n"); + } + + node = mrvl_node_from_id(priv, node_id); + if (node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id already exists\n"); + + node = rte_zmalloc_socket(NULL, sizeof(*node), 0, rte_socket_id()); + if (!node) + return -rte_tm_error_set(error, ENOMEM, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, NULL); + + node->id = node_id; + node->type = parent_node_id == RTE_TM_NODE_ID_NULL ? MRVL_NODE_PORT : + MRVL_NODE_QUEUE; + + if (parent) { + node->parent = parent; + parent->refcnt++; + } + + if (profile) { + node->profile = profile; + profile->refcnt++; + } + + node->weight = weight; + node->stats_mask = params->stats_mask; + + LIST_INSERT_HEAD(&priv->nodes, node, next); + + return 0; +} + +/** + * Delete a node. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_delete(struct rte_eth_dev *dev, uint32_t node_id, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + + if (priv->ppio) { + return -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is already started\n"); + } + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + if (node->refcnt) + return -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id is used\n"); + + if (node->parent) + node->parent->refcnt--; + + if (node->profile) + node->profile->refcnt--; + + LIST_REMOVE(node, next); + rte_free(node); + + return 0; +} + +/** + * Helper for suspending specific tx queue. + * + * @param dev Pointer to the device. + * @param node_id Id used by this node. + * @returns 0 on success, negative value otherwise. + */ +static int mrvl_node_suspend_one(struct rte_eth_dev *dev, uint32_t node_id, + struct rte_tm_error *error) +{ + int ret = dev->dev_ops->tx_queue_stop(dev, node_id); + if (ret) + return -rte_tm_error_set(error, ret, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Failed to suspend a txq\n"); + + return 0; +} + +/** + * Suspend a node. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param error Pointer to the error. + * returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_suspend(struct rte_eth_dev *dev, uint32_t node_id, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node, *tmp; + int ret; + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + if (!node->parent) { + LIST_FOREACH(tmp, &priv->nodes, next) { + if (!tmp->parent) + continue; + + if (node != tmp->parent) + continue; + + ret = mrvl_node_suspend_one(dev, tmp->id, error); + if (ret) + return ret; + } + + return 0; + } + + return mrvl_node_suspend_one(dev, node_id, error); +} + +/** + * Resume a node. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param error Pointer to the error. + * returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_resume(struct rte_eth_dev *dev, uint32_t node_id, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + int ret; + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + + if (!node->parent) + return -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Cannot suspend a port\n"); + + ret = dev->dev_ops->tx_queue_start(dev, node_id); + if (ret) + return -rte_tm_error_set(error, ret, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Failed to resume a txq\n"); + return 0; +} + +/** + * Apply traffic manager hierarchy. + * + * @param dev Pointer to the device. + * @param clear_on_fail Flag indicating whether to do cleanup on the failure. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_hierarchy_commit(struct rte_eth_dev *dev, int clear_on_fail, + struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + int ret; + + if (priv->ppio) { + ret = -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is already started\n"); + goto out; + } + + LIST_FOREACH(node, &priv->nodes, next) { + struct pp2_ppio_outq_params *p; + + if (node->type == MRVL_NODE_PORT) { + if (!node->profile) + continue; + + priv->ppio_params.rate_limit_enable = 1; + priv->ppio_params.rate_limit_params.cir = + node->profile->params.peak.rate * 8 / 1000; + priv->ppio_params.rate_limit_params.cbs = + node->profile->params.peak.size / 1000; + + MRVL_LOG(INFO, + "Port rate limit overrides txqs rate limit"); + + continue; + } + + if (node->id >= dev->data->nb_tx_queues) { + ret = -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_ID, NULL, + "Not enough txqs are configured\n"); + goto out; + } + + p = &priv->ppio_params.outqs_params.outqs_params[node->id]; + + if (node->weight) { + p->sched_mode = PP2_PPIO_SCHED_M_WRR; + p->weight = node->weight; + } else { + p->sched_mode = PP2_PPIO_SCHED_M_SP; + p->weight = 0; + } + + if (node->profile) { + p->rate_limit_enable = 1; + /* convert Bytes/s to kilo bits/s */ + p->rate_limit_params.cir = + node->profile->params.peak.rate * 8 / 1000; + /* convert bits to kilo bits */ + p->rate_limit_params.cbs = + node->profile->params.peak.size / 1000; + } else { + p->rate_limit_enable = 0; + p->rate_limit_params.cir = 0; + p->rate_limit_params.cbs = 0; + } + } + + /* reset to defaults in case applied tm hierarchy is empty */ + if (LIST_EMPTY(&priv->nodes)) { + int i; + + for (i = 0; i < priv->ppio_params.outqs_params.num_outqs; i++) { + struct pp2_ppio_outq_params *p = + &priv->ppio_params.outqs_params.outqs_params[i]; + + p->sched_mode = PP2_PPIO_SCHED_M_WRR; + p->weight = 0; + p->rate_limit_enable = 0; + p->rate_limit_params.cir = 0; + p->rate_limit_params.cbs = 0; + } + } + + return 0; +out: + if (clear_on_fail) { + mrvl_tm_deinit(dev); + mrvl_tm_init(dev); + } + + return ret; +} + +/** + * Read statistics counters for current node. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param stats Pointer to the statistics counters. + * @param stats_mask Pointer to mask of enabled statistics counters + * that are retrieved. + * @param clear Flag indicating whether to clear statistics. + * Non-zero value clears statistics. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_stats_read(struct rte_eth_dev *dev, uint32_t node_id, + struct rte_tm_node_stats *stats, uint64_t *stats_mask, + int clear, struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + int ret; + + if (!priv->ppio) { + return -rte_tm_error_set(error, EPERM, + RTE_TM_ERROR_TYPE_UNSPECIFIED, + NULL, "Port is not started\n"); + } + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + if (stats_mask) + *stats_mask = node->stats_mask; + + if (!stats) + return 0; + + memset(stats, 0, sizeof(*stats)); + + if (!node->parent) { + struct pp2_ppio_statistics s; + + memset(&s, 0, sizeof(s)); + ret = pp2_ppio_get_statistics(priv->ppio, &s, clear); + if (ret) + return -rte_tm_error_set(error, -ret, + RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL, + "Failed to read port statistics\n"); + + if (node->stats_mask & RTE_TM_STATS_N_PKTS) + stats->n_pkts = s.tx_packets; + + if (node->stats_mask & RTE_TM_STATS_N_BYTES) + stats->n_bytes = s.tx_bytes; + } else { + struct pp2_ppio_outq_statistics s; + + memset(&s, 0, sizeof(s)); + ret = pp2_ppio_outq_get_statistics(priv->ppio, node_id, &s, + clear); + if (ret) + return -rte_tm_error_set(error, -ret, + RTE_TM_ERROR_TYPE_UNSPECIFIED, NULL, + "Failed to read txq statistics\n"); + + if (node->stats_mask & RTE_TM_STATS_N_PKTS) + stats->n_pkts = s.deq_desc; + } + + return 0; +} + +/** + * Update node statistics. + * + * @param dev Pointer to the device. + * @param node_id Id of the node. + * @param stats_mask Bitmask of statistics counters to be enabled. + * @param error Pointer to the error. + * @returns 0 on success, negative value otherwise. + */ +static int +mrvl_node_stats_update(struct rte_eth_dev *dev, uint32_t node_id, + uint64_t stats_mask, struct rte_tm_error *error) +{ + struct mrvl_priv *priv = dev->data->dev_private; + struct mrvl_tm_node *node; + + node = mrvl_node_from_id(priv, node_id); + if (!node) + return -rte_tm_error_set(error, ENODEV, + RTE_TM_ERROR_TYPE_NODE_ID, + NULL, "Node id does not exist\n"); + + if (!node->parent) { + if (stats_mask & ~(RTE_TM_STATS_N_PKTS | RTE_TM_STATS_N_BYTES)) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS, + NULL, + "Requested port stats are not supported\n"); + } else { + if (stats_mask & ~RTE_TM_STATS_N_PKTS) + return -rte_tm_error_set(error, EINVAL, + RTE_TM_ERROR_TYPE_NODE_PARAMS_STATS, + NULL, + "Requested txq stats are not supported\n"); + } + + node->stats_mask = stats_mask; + + return 0; +} + +const struct rte_tm_ops mrvl_tm_ops = { + .node_type_get = mrvl_node_type_get, + .capabilities_get = mrvl_capabilities_get, + .level_capabilities_get = mrvl_level_capabilities_get, + .node_capabilities_get = mrvl_node_capabilities_get, + .shaper_profile_add = mrvl_shaper_profile_add, + .shaper_profile_delete = mrvl_shaper_profile_delete, + .node_add = mrvl_node_add, + .node_delete = mrvl_node_delete, + .node_suspend = mrvl_node_suspend, + .node_resume = mrvl_node_resume, + .hierarchy_commit = mrvl_hierarchy_commit, + .node_stats_update = mrvl_node_stats_update, + .node_stats_read = mrvl_node_stats_read, +}; diff --git a/drivers/net/mvpp2/mrvl_tm.h b/drivers/net/mvpp2/mrvl_tm.h new file mode 100644 index 0000000..9d81ede --- /dev/null +++ b/drivers/net/mvpp2/mrvl_tm.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2018 Marvell International Ltd. + * Copyright(c) 2018 Semihalf. + * All rights reserved. + */ + +#ifndef _MRVL_TM_H_ +#define _MRVL_TM_H_ + +#include "mrvl_ethdev.h" + +int mrvl_tm_init(struct rte_eth_dev *dev); +void mrvl_tm_deinit(struct rte_eth_dev *dev); + +#endif /* _MRVL_TM_H_ */ From patchwork Tue Sep 4 07:10:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44216 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 841E158C4; Tue, 4 Sep 2018 09:10:50 +0200 (CEST) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by dpdk.org (Postfix) with ESMTP id AE05C4F9B for ; Tue, 4 Sep 2018 09:10:48 +0200 (CEST) Received: by mail-pf1-f177.google.com with SMTP id i26-v6so1211665pfo.12 for ; Tue, 04 Sep 2018 00:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=saXJDORWKb77RlWzNFSe18BbyNH46U4cBEul0wRwrRs=; b=xYMjg6Ti+jyzJRAMfFteOumjsB0W7wyl4LVIDKHxURki0PAxLmOFHvtagHFjtzOFpR TgK60TYNwc8aGQhyzGPl0Qo1dFgh1VXGcLRmPj/Fvvce9Qoo54kTFKBXslI4DAeY6Mwm +pAc2utv8Z89xECIvctxGcqgHn/gLepCZkvO4LlHLksgyILilN479bJlbEn+QD6ABya7 xw2OLxB9T9+kx22wmesKltlhFwW+yd2OIpTreKYj4yZQxZvYS8VRLToBqy6T0OPKj/Cw Mm+Akt3mkihyoSR9scSxxWXWcUAHIwc2eCnqv9nTPANSpJ4Au91CDM4ix2ASkEWo064U yf0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=saXJDORWKb77RlWzNFSe18BbyNH46U4cBEul0wRwrRs=; b=pNuSNjdmtViTAlHMMGTdwuV2nGF119xuh6FrzoUCHf36vEh45QUfcsJiXadRmbVSPt IbNREjgpQhSCIHGJ1QqzJIFKs2KzcgYrVEvsWz4MC/BnbjYs9+bllRoVZ2qV5NaqPBWx Jlvhs1ulleTe/NvdPb1VPwt046CEaAqLMajQBiYWmiMg709JfXUvMsrpATPkVPwIAclE BRYiQtP6nj1/FgBS+ekfXLMzYYYu3dbdM1W+H41oMkxih+BDjoSMpScDw4AHI4FstlXu ymSz2Ag/s14qndNY/oa0i8G97qZ0D+fxaE5DVgmbquG5vZs7pdQC5pJEUnXZOKSpj/Ah iycw== X-Gm-Message-State: APzg51CigE+OAsYUiuJnOP2S4AHl4L3O6S/9IWEq8TqeY7DA8m3KCPRI dgQtRRLFy9hhBeoQ3/LDqH/Jocoxpg6tlA== X-Google-Smtp-Source: ANB0Vdbs33DniuhClK/o9EcvrgchlrR45HgZzqNccAC+lruQ3b45x17cFM7P6ko01DSjYhQcHut/BA== X-Received: by 2002:a63:24c4:: with SMTP id k187-v6mr25077289pgk.162.1536045047694; Tue, 04 Sep 2018 00:10:47 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:46 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Yuval Caduri Date: Tue, 4 Sep 2018 09:10:15 +0200 Message-Id: <1536045016-32008-8-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 7/8] net/mvpp2: detach tx_qos from rx cls/qos config 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: Yuval Caduri Functional change: Open receive cls/qos related features, only if the config file contains an rx_related configuration entry. This allows to configure tx_related entries, w/o unintentionally opening rx cls/qos. Code: 'use_global_defaults' is by default set to '1'. Only if an rx_related entry was configured, it is updated to '0'. rx cls/qos is performed only if 'use_global_defaults' is '0'. Default TC configuration is now only mandatory when 'use_global_defaults' is '0'. Signed-off-by: Yuval Caduri Reviewed-by: Natalie Samsonov Tested-by: Natalie Samsonov --- drivers/net/mvpp2/mrvl_ethdev.c | 3 ++- drivers/net/mvpp2/mrvl_qos.c | 41 +++++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index a1dc6b1..5643e7d 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -602,7 +602,8 @@ mrvl_dev_start(struct rte_eth_dev *dev) } /* For default QoS config, don't start classifier. */ - if (mrvl_qos_cfg) { + if (mrvl_qos_cfg && + mrvl_qos_cfg->port[dev->data->port_id].use_global_defaults == 0) { ret = mrvl_start_qos_mapping(priv); if (ret) { MRVL_LOG(ERR, "Failed to setup QoS mapping"); diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index e039635..5d80c3e 100644 --- a/drivers/net/mvpp2/mrvl_qos.c +++ b/drivers/net/mvpp2/mrvl_qos.c @@ -324,6 +324,7 @@ parse_tc_cfg(struct rte_cfgfile *file, int port, int tc, if (rte_cfgfile_num_sections(file, sec_name, strlen(sec_name)) <= 0) return 0; + cfg->port[port].use_global_defaults = 0; entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_RXQ); if (entry) { n = get_entry_values(entry, @@ -421,7 +422,7 @@ parse_policer(struct rte_cfgfile *file, int port, const char *sec_name, cfg->port[port].policer_params.token_unit = PP2_CLS_PLCR_PACKETS_TOKEN_UNIT; } else { - RTE_LOG(ERR, PMD, "Unknown token: %s\n", entry); + MRVL_LOG(ERR, "Unknown token: %s", entry); return -1; } } @@ -438,7 +439,7 @@ parse_policer(struct rte_cfgfile *file, int port, const char *sec_name, cfg->port[port].policer_params.color_mode = PP2_CLS_PLCR_COLOR_AWARE_MODE; } else { - RTE_LOG(ERR, PMD, "Error in parsing: %s\n", entry); + MRVL_LOG(ERR, "Error in parsing: %s", entry); return -1; } } @@ -518,28 +519,15 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, snprintf(sec_name, sizeof(sec_name), "%s %d %s", MRVL_TOK_PORT, n, MRVL_TOK_DEFAULT); + /* Use global defaults, unless an override occurs */ + (*cfg)->port[n].use_global_defaults = 1; + /* Skip ports non-existing in configuration. */ if (rte_cfgfile_num_sections(file, sec_name, strlen(sec_name)) <= 0) { - (*cfg)->port[n].use_global_defaults = 1; - (*cfg)->port[n].mapping_priority = - PP2_CLS_QOS_TBL_VLAN_IP_PRI; continue; } - entry = rte_cfgfile_get_entry(file, sec_name, - MRVL_TOK_DEFAULT_TC); - if (entry) { - if (get_val_securely(entry, &val) < 0 || - val > USHRT_MAX) - return -1; - (*cfg)->port[n].default_tc = (uint8_t)val; - } else { - MRVL_LOG(ERR, - "Default Traffic Class required in custom configuration!"); - return -1; - } - /* * Read per-port rate limiting. Setting that will * disable per-queue rate limiting. @@ -573,6 +561,7 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_MAPPING_PRIORITY); if (entry) { + (*cfg)->port[n].use_global_defaults = 0; if (!strncmp(entry, MRVL_TOK_VLAN_IP, sizeof(MRVL_TOK_VLAN_IP))) (*cfg)->port[n].mapping_priority = @@ -602,6 +591,7 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, entry = rte_cfgfile_get_entry(file, sec_name, MRVL_TOK_PLCR_DEFAULT); if (entry) { + (*cfg)->port[n].use_global_defaults = 0; if (get_val_securely(entry, &val) < 0) return -1; @@ -627,6 +617,21 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path, "Error %d parsing port %d tc %d!\n", ret, n, i); } + + entry = rte_cfgfile_get_entry(file, sec_name, + MRVL_TOK_DEFAULT_TC); + if (entry) { + if (get_val_securely(entry, &val) < 0 || + val > USHRT_MAX) + return -1; + (*cfg)->port[n].default_tc = (uint8_t)val; + } else { + if ((*cfg)->port[n].use_global_defaults == 0) { + MRVL_LOG(ERR, + "Default Traffic Class required in custom configuration!"); + return -1; + } + } } return 0; From patchwork Tue Sep 4 07:10:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44217 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D77EF58FA; Tue, 4 Sep 2018 09:10:52 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id ED92B58FA for ; Tue, 4 Sep 2018 09:10:50 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id t19-v6so1173185ply.13 for ; Tue, 04 Sep 2018 00:10:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mCc0MspjeAoopubxZmXTX5O+cBaEOu3Z86WGw9tSwsU=; b=skrCw6LmG8LQPwxDUMmnzfL3lspY/AVRDEX+fLqH7f+2XvqzUfVAjBNLnbqs8d1Wjl /P06x4gSgOvyP7h48jwT11nq1vcjBTzF+fe7T6gFj5yEZZwgaDEHmwlmH4yJJ8PkRm3d L9Wn86CiJLMeQsSi4qvta7bJTjzQb3ygWXOY6XP74UWXFqewXgf2m0K9w4p4/fuLRrTt 7wCRxtJYTUgWJ7D7Yn3jPxGFx6ZdD6Ib+tJ0dw5DWYvCHNATJWbopW6SumOGf0zYeubZ MgasPXI8cPDb6QohBTN/017sLknpFRGdFo68TtbvZN9Zn+1d5r5c+YW3I8sWILLfV+uZ 6+qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mCc0MspjeAoopubxZmXTX5O+cBaEOu3Z86WGw9tSwsU=; b=Dy7ZsXQDI5vtlc+HV4GJzKaEcMPSBkj2vghBbwNe7asxu5KUI7NQdYjjDQuqOwRrWE hoGRDAQNsMALE/xz2Q555mKtK0rh4yWQ65lxHp8LzR16nNahcVdndFM+Ctq89wmAcYIa UMZafeZnHPn+QezCpCsdJzH2y4TOJuxHJQKaj+LnO8BncRuX/t3uX0MxZ33jv2zZgva8 qfsIqSOlh+BRBAVit2i/Lx+tsD7uVJJA5VXmyMQ2ECJEHg+Nl8+6AVZS3pk5TTOfP5uX t3AZClcjmNFriPvi378gbj5vA6h1AUOXaapeM8zzwbISSoxDTMFQB9zMNSlM2t4K+zc/ hj9g== X-Gm-Message-State: APzg51DESPf6hNJqyZjanoMCqL4ev+xmV4P8pREaa+0eryNAcFhrFD7E o7aj0reH68ZSbbRAtn7axmIrN/bsF204gA== X-Google-Smtp-Source: ANB0VdbE42Tmj8lRF68bbnrvvtd1I+0NBoG3IJMYjIgJY0tI0mHe3hcyfIQK5JCg4IiibgMISN0DiQ== X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr32651638plf.286.1536045049930; Tue, 04 Sep 2018 00:10:49 -0700 (PDT) Received: from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id l79-v6sm31229451pfb.111.2018.09.04.00.10.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 00:10:49 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com Date: Tue, 4 Sep 2018 09:10:16 +0200 Message-Id: <1536045016-32008-9-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536045016-32008-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH 8/8] net/mvpp2: update MTU and MRU related calculations 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: Natalie Samsonov This commit updates MTU and MRU related calculations. Signed-off-by: Natalie Samsonov Reviewed-by: Yelena Krivosheev Reviewed-by: Dmitri Epshtein --- drivers/net/mvpp2/mrvl_ethdev.c | 70 +++++++++++++++++++++++++++++++---------- drivers/net/mvpp2/mrvl_ethdev.h | 7 +++++ 2 files changed, 61 insertions(+), 16 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 5643e7d..035ee81 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -325,7 +325,7 @@ mrvl_dev_configure(struct rte_eth_dev *dev) if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len - - ETHER_HDR_LEN - ETHER_CRC_LEN; + MRVL_PP2_ETH_HDRS_LEN; ret = mrvl_configure_rxqs(priv, dev->data->port_id, dev->data->nb_rx_queues); @@ -375,21 +375,55 @@ static int mrvl_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) { struct mrvl_priv *priv = dev->data->dev_private; - /* extra MV_MH_SIZE bytes are required for Marvell tag */ - uint16_t mru = mtu + MV_MH_SIZE + ETHER_HDR_LEN + ETHER_CRC_LEN; + uint16_t mru; + uint16_t mbuf_data_size = 0; /* SW buffer size */ int ret; - if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX) + mru = MRVL_PP2_MTU_TO_MRU(mtu); + /* + * min_rx_buf_size is equal to mbuf data size + * if pmd didn't set it differently + */ + mbuf_data_size = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM; + /* Prevent PMD from: + * - setting mru greater than the mbuf size resulting in + * hw and sw buffer size mismatch + * - setting mtu that requires the support of scattered packets + * when this feature has not been enabled/supported so far + * (TODO check scattered_rx flag here once scattered RX is supported). + */ + if (mru + MRVL_PKT_OFFS > mbuf_data_size) { + mru = mbuf_data_size - MRVL_PKT_OFFS; + mtu = MRVL_PP2_MRU_TO_MTU(mru); + MRVL_LOG(WARNING, "MTU too big, max MTU possible limitted " + "by current mbuf size: %u. Set MTU to %u, MRU to %u", + mbuf_data_size, mtu, mru); + } + + if (mtu < ETHER_MIN_MTU || mru > MRVL_PKT_SIZE_MAX) { + MRVL_LOG(ERR, "Invalid MTU [%u] or MRU [%u]", mtu, mru); return -EINVAL; + } + + dev->data->mtu = mtu; + dev->data->dev_conf.rxmode.max_rx_pkt_len = mru - MV_MH_SIZE; if (!priv->ppio) return 0; ret = pp2_ppio_set_mru(priv->ppio, mru); - if (ret) + if (ret) { + MRVL_LOG(ERR, "Failed to change MRU"); return ret; + } + + ret = pp2_ppio_set_mtu(priv->ppio, mtu); + if (ret) { + MRVL_LOG(ERR, "Failed to change MTU"); + return ret; + } - return pp2_ppio_set_mtu(priv->ppio, mtu); + return 0; } /** @@ -600,6 +634,9 @@ mrvl_dev_start(struct rte_eth_dev *dev) } priv->vlan_flushed = 1; } + ret = mrvl_mtu_set(dev, dev->data->mtu); + if (ret) + MRVL_LOG(ERR, "Failed to set MTU to %d", dev->data->mtu); /* For default QoS config, don't start classifier. */ if (mrvl_qos_cfg && @@ -1552,8 +1589,8 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, { struct mrvl_priv *priv = dev->data->dev_private; struct mrvl_rxq *rxq; - uint32_t min_size, - max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len; + uint32_t frame_size, buf_size = rte_pktmbuf_data_room_size(mp); + uint32_t max_rx_pkt_len = dev->data->dev_conf.rxmode.max_rx_pkt_len; int ret, tc, inq; uint64_t offloads; @@ -1568,15 +1605,16 @@ mrvl_rx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, return -EFAULT; } - min_size = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM - - MRVL_PKT_EFFEC_OFFS; - if (min_size < max_rx_pkt_len) { - MRVL_LOG(ERR, - "Mbuf size must be increased to %u bytes to hold up to %u bytes of data.", - max_rx_pkt_len + RTE_PKTMBUF_HEADROOM + - MRVL_PKT_EFFEC_OFFS, + frame_size = buf_size - RTE_PKTMBUF_HEADROOM - MRVL_PKT_EFFEC_OFFS; + if (frame_size < max_rx_pkt_len) { + MRVL_LOG(WARNING, + "Mbuf size must be increased to %u bytes to hold up " + "to %u bytes of data.", + buf_size + max_rx_pkt_len - frame_size, max_rx_pkt_len); - return -EINVAL; + dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size; + MRVL_LOG(INFO, "Setting max rx pkt len to %u", + dev->data->dev_conf.rxmode.max_rx_pkt_len); } if (dev->data->rx_queues[idx]) { diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index 984f31e..f0ae983 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.h +++ b/drivers/net/mvpp2/mrvl_ethdev.h @@ -72,6 +72,13 @@ /** Minimum number of sent buffers to release from shadow queue to BM */ #define MRVL_PP2_BUF_RELEASE_BURST_SIZE 64 +#define MRVL_PP2_VLAN_TAG_LEN 4 +#define MRVL_PP2_ETH_HDRS_LEN (ETHER_HDR_LEN + ETHER_CRC_LEN + \ + (2 * MRVL_PP2_VLAN_TAG_LEN)) +#define MRVL_PP2_HDRS_LEN (MV_MH_SIZE + MRVL_PP2_ETH_HDRS_LEN) +#define MRVL_PP2_MTU_TO_MRU(mtu) ((mtu) + MRVL_PP2_HDRS_LEN) +#define MRVL_PP2_MRU_TO_MTU(mru) ((mru) - MRVL_PP2_HDRS_LEN) + /** Maximum length of a match string */ #define MRVL_MATCH_LEN 16