From patchwork Tue Sep 4 13:49:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44239 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 315D1231E; Tue, 4 Sep 2018 15:49:25 +0200 (CEST) Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id A82CA1BE0 for ; Tue, 4 Sep 2018 15:49:23 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id m26-v6so3037708lfb.0 for ; Tue, 04 Sep 2018 06:49:23 -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=jqiD4oTvNWQ5qwY+rPbcj3EFsPzhBD4O+LrJ5yPbu7I5p/uJpT3gsBXgMFZBcB80f7 FwwJvcoMJ88lu2pUXEmbaT7hceTpiSs4WoezELG3YoKYC/pDHUIlON5gM3oLapKHu3ty qDA092Mi528pXXYaqBNJtoZE5I8wcQDWEe4agkgRJAvfvuHUKEC/W5zkN2I5xwtP56Aq uncJCvcppJd6AzPYrf4JNB//HhwUb773hNPhyYDnM1yI1PBj3fvt/w6dnxams8po3u3a BcniKTysqo2YnPLCYWulY1mmlwY9x9QfgkjmJbYUt2Vk8t2dHW207/uzJcDMa8eKtUTx 5cHw== 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=pQ7jXW3+k9UayYUr/x1DUiVO9O1m6+rGJqLtJWGrfAoRq8CMJNO9v1BIghNvp33NYj SrGHiGMTMfSHUo4jSOo8q0ejic55tNQChcqDYJjk6/K5fDFCu8xLXGSA6k1jant9g+MK FKAl0gGtXHPDeO+ok1/mFSAJ8uql5wTJoouaKbNZ90I+K5KWUmZZ/KPQsudStoxhgMyl K2KdqVnddNo2RCpe7TMwLoBK9/hedkRtpFRDB7kdBNbJ/Wy1eJncEJNZQZt0Oc6+WRhs lnHHvXM89niWLDxdrg8pn1H6S9EXWT9W4iudv+W9xYZarAlAqFI46jX6rY5nxjI4JKQH /UtQ== X-Gm-Message-State: APzg51AynR+Kj9nTI2U9qthhdjgrSh8E4WJ9ZrGQtamqPE062wLgbCTw oEsor00pqyA37OumFMHaXVw2vSARwSaqwQ== X-Google-Smtp-Source: ANB0VdYqSzD6WDnVwUGvBQDDwLRN2ZRcmCgVkRFEWlFzJaf2TGAGCXmTeh8PUSB7l0VZbK3DQs8+GA== X-Received: by 2002:a19:1a52:: with SMTP id a79-v6mr9261997lfa.139.1536068963134; Tue, 04 Sep 2018 06:49:23 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:22 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com Date: Tue, 4 Sep 2018 15:49:02 +0200 Message-Id: <1536068953-9352-2-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 01/12] 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 13:49:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44241 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 0F437326D; Tue, 4 Sep 2018 15:49:29 +0200 (CEST) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 57E492B92 for ; Tue, 4 Sep 2018 15:49:25 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id j19-v6so3205712ljc.7 for ; Tue, 04 Sep 2018 06:49:25 -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=PSldXz1mrnCt+mRStXi4nXqqRTlQSkw5wa0W2EcA4OxcuK+3rT6MtxCJR6ZrRK9FPt zcU68BJlobjyZl9jp5iQUY0PSsMjKoVBZ766duFPNn+oVOHUPuWtcLRKXGwxM5Om0Jg0 ZGhFySYhwIpebsCpEY4Qt5goBbE1GcISwMePIF7VSy2uLDjIwJM2sVl1JQ2TsxP81Dpy XFJ2JHFqpct68FNousQ8I98Nb5GxjOQnAsX1MSZudVqMjlv9dXfyvSF1bgYpV4uhmxP8 /0jisesZbZwENWEGsp+0c2nZyrVAsJSvNbOK2h7z1MPwARjdbM7dgo8s/Bx8keO4vxsL AhaA== 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=GhY/d/GpmRFfgPl4+8/1oxEPR/qTQc3ek7yBDPi4kDoDq5G3N8Vy5H0i//evX+M73c RBCXGPy/jSHGwAyhp6+zatE2shelAKkM+GUsUgeSchrXAqGWbP1f4inQNYxVqHgHsTab ZHzQ27ggvclMJdduJHxKo8l8nMFXVrFJrtT67QB0elabLqyOC2aRms3rWHIKWGwHIEO3 aYSfSJ6TKcdcnIVs8Dfd6q5qqdz35I0tw+SLYnhGg7J+yA2ohrT0SYTuLpFijPiCHm0k 6XrgWTGnb8XcP8xDvYl/KsujDfQm8k5SdmcNc+LTxQgwsZjgHsYi3/3iSDinMobb67KM BW8g== X-Gm-Message-State: APzg51C6fgYmgPLQDKxiVOxyRvKEoTxBO8RtPLeSYywne2I629gmOtom uvvUbMAaq3VahK1uyEZahjVZaibEATWgyw== X-Google-Smtp-Source: ANB0VdYtvYK+mGdOT/Sc6KqGSjcUqpvCW4iLHAiIIOohIB1dzMaYRDo3E2oNiAiSKfBcRi8ab/3+KQ== X-Received: by 2002:a2e:498:: with SMTP id a24-v6mr21477591ljf.27.1536068964676; Tue, 04 Sep 2018 06:49:24 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:23 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 15:49:03 +0200 Message-Id: <1536068953-9352-3-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 02/12] 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 13:49:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44242 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 709284C9D; Tue, 4 Sep 2018 15:49:30 +0200 (CEST) Received: from mail-lf1-f68.google.com (mail-lf1-f68.google.com [209.85.167.68]) by dpdk.org (Postfix) with ESMTP id CB2FE2BF3 for ; Tue, 4 Sep 2018 15:49:26 +0200 (CEST) Received: by mail-lf1-f68.google.com with SMTP id m26-v6so3037873lfb.0 for ; Tue, 04 Sep 2018 06:49:26 -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=sr0fyacMstJGzNJ6GJeahZUIa0/A2z2tOE6lOXfa315lRWkCn6KvOE5sMINzEqtkoG /GECkW7MOzfUs2CDrgV9WU7sp8JG9EItU9XSHKgyXZZsnNjLLnRxjwFEYaamWmldvE47 CO5k4NOiVnw0fuX5ktA1NTxv02mO0BL+zvC3ysfonid1n3gC7kUQ1YbKHrv5M5bD8Pwz rW60p/+N8wx+c3QWopfBaHV4xg8X5p20xTd5rm4YfIatchtRmhwZq110CNUR5lL5TiMc rGItX74vtwNKa4++DU6CI8TYonpdKtpaUfxST4y8HgwdotOFSZ28uMp5ztWwy6GRn4HJ HaXg== 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=Q5Dd7CDlAKhWQiS38IjLE+v/qF0bIXgSi6f64RW2Iyz6jpGBDdhL/6tfnqOLCjQUTi 6o6g59ViXwg98L68btS4j0DFq8oFejrLE/c9hEM0mIBc4FTOsiv9BUuU2YfwTey/V7Oy Xjl0JlUaQCIkLPWZD1oghPbFnLs+xjyCZlFhGQAcnJyglLlmk/Z0sPEmUZyL32PH6/eJ h6mUlDYKIDXl1dbQdZEw1r33Fbl8av0hQ2mP6nK2LztisTN+0GcGYI95L9Gbpld5iuUt bJDJQg2RRNjZO3o8tjE9hhcZjfaRxVWNX/XXKymZ9XZ7jSG3ePmka4t3CCSkMSN4J/4x k7iQ== X-Gm-Message-State: APzg51C5qJUsCaIZFLqqHst980aKcz7z5qtgTOkcvKsG0JyA7Dgv7HRF AiqY9OMR9iVcAODh2a5TvBELcSX+RwSB5A== X-Google-Smtp-Source: ANB0VdYB52jgl8YoD+v2Ym3yBy2UI4SHlpmvKLo5QwL69URk3wg33nFPoO6ZX1gb7lfjXXtAcmfYqQ== X-Received: by 2002:a19:4803:: with SMTP id v3-v6mr16769383lfa.46.1536068965881; Tue, 04 Sep 2018 06:49:25 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:25 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 15:49:04 +0200 Message-Id: <1536068953-9352-4-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 03/12] 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 13:49:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44243 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 472E24F91; Tue, 4 Sep 2018 15:49:32 +0200 (CEST) Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by dpdk.org (Postfix) with ESMTP id 928882BF3 for ; Tue, 4 Sep 2018 15:49:27 +0200 (CEST) Received: by mail-lj1-f195.google.com with SMTP id l15-v6so3210821lji.6 for ; Tue, 04 Sep 2018 06:49:27 -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=Dz/Ow6L/j1uP7C5D0xAun2exBL9OWUGS777f6ccwanajDIJW6oBwQ1Ni2JD2M4sMnx NuzL9RKAT1xNdXIi5Zy0U3VrI9Cht/9aC5Qo+JVhBLeiTVIFVbr7sghRSuW/rlY2W7St pvbkPu+JdwJNxfMuGzidSHUbV4CLN63tOzJFQqv15ToTbIUTGV9DmV/+BzhkJnzR3R6l pX5y3ee1+dxJ4iCFxsGxHgbbrGBc+1MC9a/pfq3ZhzW7IYCHJkN+dIw6qleMQjTAmdaX V+q79nD8mVSznkuk7zVuKxh+GePV1BrmwJUAv8NtzE0Kfu/jKxlzBw1IWqF5xPo/LWPI r26Q== 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=HgtBuhnWdP2sp6LWyS62s2pkFeshdtmQNnkBIw/MBNh/yscgxq0KUd98e8JrtXzLPB qZ8naa0z2uFGk3XG87XawIQiwFRrV8ZLhwm9t2qn4Vmk4bRGGPSF31JYIdkhtyE1GC6k Ny/qyGIqDl1o3QW9QvZxfhL1kAyIiuBA3CSlpYHbyJQ28278+Lb09JW722HvaugT4jyD 7mZE2DX2UXgU9Ntl5vzbcQsH/fUxkg6U8+k2uX8/A0EFqDDmcCSqyALWlrH1ma1uQ8Kd DPRKxCQMxDkcB1ozW/HL/jUsOTwHDKdTXblCMHAHEqkQeU+m7MLAXhbHBM9V6y4Y8Mcq 3Szw== X-Gm-Message-State: APzg51DAxOSCpfHQHhzqnmPXda/zY30q679TjEVle22ny86zDaCaMTgU +FcHPlyHAbx6hGMBT+owLuVfGp8b5lY0BA== X-Google-Smtp-Source: ANB0VdZxfPUB/wvZMsZyCIi1HbtdRC8X6xWp1NrPn5llvGyo4p9hREciIFD33myczCRIMNPjlGkmDA== X-Received: by 2002:a2e:9a93:: with SMTP id p19-v6mr16764903lji.108.1536068966884; Tue, 04 Sep 2018 06:49:26 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:26 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 15:49:05 +0200 Message-Id: <1536068953-9352-5-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 04/12] 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 13:49:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44244 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 BB45E4F9B; Tue, 4 Sep 2018 15:49:33 +0200 (CEST) Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 945DC2D13 for ; Tue, 4 Sep 2018 15:49:28 +0200 (CEST) Received: by mail-lj1-f193.google.com with SMTP id f1-v6so3193107ljc.9 for ; Tue, 04 Sep 2018 06:49:28 -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=Y+y6Xh0XVy2xjEiAORkksYlXLVQfhYerLMdjmO8w1zFxZPNVipG4/C36TCyrxNq9tz QibtEWIlj23PXAiMu4NQbqgVf8nHpqO0+wDzyjhbrC4qH012D2LDDw6cUvIAVx3v1sOm +z7CB4CIljif8RNIYJzRHoRkIvt9pGfeIQP2or4BjTKU11Fu0ZKUlqxyw+MzpWW9+Nau zNntIe3uOG8dOo7MPXvF3c4FBv8AQnnELgwzCGDOP1YyKBznfVkX2I4b+pDS0/N6dQ70 cb/mfFFPYTphpiJ5jHKN7ZKIpfyLnX+AxTfyCoKa5zE/GPXHfV7aU9LAkL1iHykB0VXk AZgw== 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=FSKM9ML6lUcleCDFyMnKdu9p7BTBsKuCd2Lz84nFR2jszRzq4/OwuvYsWy0RMNPHhD HECrTJcX0w11139VwMUJsiMElT0CeBR3++MGHP585Xkw53WTGQEHL/ROFfAXdsz+J8Ms Ss0iJlUS6r40c1kGo2VmlyAmVS3RUq/PBWG0KYkvFZgTMiQQGyycLa9KZnKSTefUluhh b5zQkVTq8LEtoI8zv/Loz5q+eaCUQ1fenFvQR05hRF9rnchEfJflPlPPWmRc5y4fpbuX visMiG7YsI7XEyrBJAqq8mdUR0ZS+tIffbpw3lObvPFmXTuc8PzvdmqM00XHWU52jey8 /8vg== X-Gm-Message-State: APzg51Dj/ndPwB1c23ceGv6+QpUlZTbKW1DUyvtaQcP5B/UB4Jutiexp xU8sRJGm0S1vSeM+cHGmKLQHiauBV5MrnQ== X-Google-Smtp-Source: ANB0VdZVU96pIP6ASG4h/DHEPKobr3B9maMKSYiS83E0isN3mErriepx1sb4vOnizvWd7yOTXSEN6g== X-Received: by 2002:a2e:429c:: with SMTP id h28-v6mr20277573ljf.67.1536068968005; Tue, 04 Sep 2018 06:49:28 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:27 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 15:49:06 +0200 Message-Id: <1536068953-9352-6-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 05/12] 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 13:49:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44245 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 200AF5592; Tue, 4 Sep 2018 15:49:35 +0200 (CEST) Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) by dpdk.org (Postfix) with ESMTP id A515C2F4F for ; Tue, 4 Sep 2018 15:49:30 +0200 (CEST) Received: by mail-lj1-f196.google.com with SMTP id m84-v6so3193692lje.10 for ; Tue, 04 Sep 2018 06:49:30 -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=UR/7k5na20YF/7up7UnroRlPdBVxH89hsNf535L5MZ151RFXWiu5XmWRzsEBNB+9Bq nBGqBISIRBN9qNQgOj46w8RYmaSooeGzId8kjDZGHBlmAC1+oj/nxSDM8Rsxd8YqnmJj Nkl4PXL1ixnEcyX1fxswwo7Q5I+0FCJ7BPJonXGq5Rld6lHu07co+dMhucH8IPVPLh2o 3Q+fX0aZsvVE3OZ+uXnimoOdkiIejhlvbqybS4LLddT5g9dAEzEgS37Jj++Fwz//8s7B /bXco21Xx+rdhMFry1NP/a4BieRW0SyPwfIC4dAJpR4uOnec/Pm3IHAKUF4fwSQBXIT7 blTQ== 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=FT25cGqCUwrELqaKnMxHKj/9T4Sv5G0nc7e/d9E+B/xIhqAYFe4BQW0RFsjtHhOn6k UDIVEByH7+hjsRDvVIopejMLiYWeafQV9rDB6m4eU9RzIkapZloQaSwaaYe5YESxdFQ3 uLxX9G2MSpaQES01+RzDVna8D7ZyB5FkWQnsnd8oS3o6DJsHT9LvBpgZ/mxlcjkD0wCZ DdhaPARKKucGkASK1O3GDDKoqZCJUE1nAEZtT7jX6fWayvJHPhhXvj6Y6pH6YFbyaEvx 9elKVsJukcKwWfWk8siDFIYWGKMesnc0macyLt9f7BzZXAl03FIZe9V5noPcDT5olgHr KdXg== X-Gm-Message-State: APzg51BqwLcYzZedtPS3TlL+N1kld04NpQAJiB/DpbOWpROrEmnMyooQ e0+cLn90D+OC39ex5xXuD4hTmHM+68qC2g== X-Google-Smtp-Source: ANB0VdY1jnJXQ1g7YpS6zsFVOouqftk0ggyaF6x88uYXRLjBjoEcbZgowGWB8UdeLURKLPt13qy2Og== X-Received: by 2002:a2e:888d:: with SMTP id k13-v6mr20576883lji.38.1536068969520; Tue, 04 Sep 2018 06:49:29 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:28 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski Date: Tue, 4 Sep 2018 15:49:07 +0200 Message-Id: <1536068953-9352-7-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 06/12] 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 13:49:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Duszynski X-Patchwork-Id: 44246 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 8545158FA; Tue, 4 Sep 2018 15:49:36 +0200 (CEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by dpdk.org (Postfix) with ESMTP id 23B3B2F4F for ; Tue, 4 Sep 2018 15:49:31 +0200 (CEST) Received: by mail-lj1-f174.google.com with SMTP id j19-v6so3206035ljc.7 for ; Tue, 04 Sep 2018 06:49:31 -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=wOWtIt8B3+69tGWGzL5gnyddKFlJ16dKw+5GCWTsrVfMnX87VLwE+IZzxkDPDAWHWJ dzKyQ8loO+eilXbbbQXqot+fZqxoVTnoZtio5t8I/o7TftWvKaGqJJ7eZigxpqIwLGkC wKVy4DL2GRa2jL0OzUbJiVwpvVqk3i4YhbZKQaSX9wgxr7GqNIdBrN7IeIQuwgF+MKxB V4XEUfLe+6zsCnj+RUjwCbpi8rHrEAA7LwR2zPzYhl2FSjq7PEd3Zjwv2kbSWyZktYMv WdKt3chHJs8fvqoe4rPwL46O+0hH8mNY5Cm31IpG3EF5OvtXgspcFb24/wLRImac4ZSC +NQg== 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=bYRVTuyKJA2PWB8meexr0a8zW8YQ2378cKGUfrmQ8MTJIYgWKpeq5gzKZbyWuqUQYA UQjfl08sljShpu98wkwE/qBJUic1ABCkXqlTFd9moQMpakxJMEz0OPRATfuYAf/XFfy5 GYTRCWWF/jg3dru/KwL5arOoVuzr9aavPK7+ccJugRAfe2dozt5GqTkhA+qOz9yxXYwh iXCcCGe0IdgtffDwLVsg0RhibWDzCjFZXSscgaXOtkwOMZDz5Nc+b3D7IhQeDx0vIsQd 147c4PVaA3fWUQK2sosDY26e2MkmJ6jWOv5iv/6KJaRbkR9qbkTdLdVXvxhVeOvP7S7L 3Hdg== X-Gm-Message-State: APzg51BvxgnrdRRwLyCDJzT5AtjXOsPAPGPUHt7XHaB58y8Jl7bgPoNr xs4Wk4aRAlPu7yMTkNMAlNa5a6wUN/gdGA== X-Google-Smtp-Source: ANB0VdZlEZ6lZabel4fj2daqIYQg1Us7gUf5yDQ3LTXll0EB9O/nAepS+erGlRD3suj2dH4SnYQpkA== X-Received: by 2002:a2e:8e81:: with SMTP id z1-v6mr3156797ljk.156.1536068970611; Tue, 04 Sep 2018 06:49:30 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:29 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Yuval Caduri Date: Tue, 4 Sep 2018 15:49:08 +0200 Message-Id: <1536068953-9352-8-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 07/12] 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 13:49: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: 44247 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 851615B1C; Tue, 4 Sep 2018 15:49:38 +0200 (CEST) Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id 27B2D4CE4 for ; Tue, 4 Sep 2018 15:49:32 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id j8-v6so3013446lfb.4 for ; Tue, 04 Sep 2018 06:49:32 -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=lHraRfmUG6ochloeafzQ+KH70ByHj2XRDDWP75kEckMwsP7Z5o90+ovoFszZVccCNE DDzxTpX0+TNGQei9IAq5q8R/P3sC0phBzUkOGNldKPCKDpIChKaWfa9opSSWZG+F3Gzi y3WNthGtHUdLhkhk0WSvfyx53eUJQbgvotKxJkhqNZU21Gr3yb5xXj86yHt4Noqd67D0 oBOG2ZHFmjbqrbTqGp9saRAF5bDeKgzQ0GYGffD32SHVh7Bi9U0C4oVtyiNvV1qPoxg/ zw2BjbUEGze6H8vtQrgLLprf+x3/5OaeVINsoTghcCkzsdcJU5Xa/aewzhOl/KRFTix1 2aJg== 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=M2PfMhjfohGy0rLp0kgdMxqGQcrpy6gGRbpyRThnJ7cfWPw6VXfTvGhHi8GJyYw2o/ 03r6kLXpPvirS86r8cEpqmDCBt4Ekfk9BY06DuV897HbPSqMJ73+yfln260lC0/jSJ97 e96EdnLm/1/odNIn2LT/JlpxlwCqytGApMfpXdzOGEDEVvL6Wb80zJZpCc22XLz94SJs BC7Ey4wezq9z+tHRMPjh5Z/j3UrOFcLeDP/YlLbLF+XyCllikHGcT5YZqhdStJPps/kw KffOiHTtyvg1NfAtD2jQ2i/oYDRf5KCKIu6aMuy3KBAa4ZlDY+xa1ToO80u0I/cWXd4b ci5Q== X-Gm-Message-State: APzg51CaG4ALJKU7x2qj7ww5Y7TdV5cUY4FUz7kCqM3Tvx5WO0ZIsi6W 39LswlaD5u6RperTkKElJ69UXL5EHUrySA== X-Google-Smtp-Source: ANB0VdbfoJ5E647RNr2jsuYBh7lk0xB+yC0BvDRTX9rztrsYPJW0V/T6RkbKv+fqfTcECcgxfCVZjw== X-Received: by 2002:a19:7118:: with SMTP id m24-v6mr19128428lfc.6.1536068971628; Tue, 04 Sep 2018 06:49:31 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:30 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com Date: Tue, 4 Sep 2018 15:49:09 +0200 Message-Id: <1536068953-9352-9-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 08/12] 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 From patchwork Tue Sep 4 13:49: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: 44248 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 D67735B2C; Tue, 4 Sep 2018 15:49:39 +0200 (CEST) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by dpdk.org (Postfix) with ESMTP id 464014CE4 for ; Tue, 4 Sep 2018 15:49:33 +0200 (CEST) Received: by mail-lj1-f175.google.com with SMTP id 203-v6so3176721ljj.13 for ; Tue, 04 Sep 2018 06:49: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=CPjJASlmUae/BLLUq79eSahykDXpDSlinpenn79x2aY=; b=lN+DZovHyEBE3fDpP0/8QP6Z2JZP+unXxX8iwl8YBAlBr/wr58PmCyXpPHv9ntNQIT 5aUCBsWhBm7Ui2PvnPW2Fw5o1vjF+YbouHz7uTpCJkhtAsrNEMzSWsA2nkQ0lyeYpYJM C3N8XPD3GAdOBS8QNQ+wIGE2/tMRm7jRHuITm9yJJRrzhO0s7u9EOVwcrA1QTxl5Lj6/ 2meEa9FMQyYLUl1d2HdGSEPvmny7mbIDjO/wtAcOjjqq1wOB8WPMBIIxOIwwvRCbPrHM Ud+n8Y3XdiBgeaI7FDAmXlobP2hqktOzOlm5Nr8CcXTMDARW0Z2MrC9HNd4IC8hA+GQ+ irkw== 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=CPjJASlmUae/BLLUq79eSahykDXpDSlinpenn79x2aY=; b=b/zTsQWpR/N2sXCBbc8A7oRINqBlqJD5YYDMyWljjQ4iZhkx+F8BDwzcx6uB954XCM Y9nHBvl/6+3hzjodysL+qM9a6U7YkgpFfOIbD7kIJP/QA+VO0eMT5bclgV3MOUAwsf32 znbMpouJAooo7zofOjm8LYcACfhxjoBNP8QHDxSGJEQo+oNoOm/F/O/UZnLPDpfTy2fr N8Tjh2XbxEr6fBD0Gg8SQoTVVNDL//GO42ZcwtNeEF4e3FbmgtA4m9b8J6lnVmZRLhlA n3/PElkrzf8tWKeRGqZbTS/ziltCZHzdTg+LeAKoMi5hfhJlG7aVzqXShB34hgOvFhBH BI0w== X-Gm-Message-State: APzg51A/fHfaOEa+EX2f1BkqxPJ1GMBPfQkphUga7KyAp5GFZllXEcWb Z80uVnB+T1uL6c9JwIUvYqlXdxpVpca7Yg== X-Google-Smtp-Source: ANB0Vdbps6NvJqUaflPlgQM5HBvKd5saHHdGExZ9LDEsFPr3IngqAKRWpDrLyNV2zkz9zv889e2hEg== X-Received: by 2002:a2e:360c:: with SMTP id d12-v6mr3421832lja.88.1536068972784; Tue, 04 Sep 2018 06:49: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 q22-v6sm4057225lff.10.2018.09.04.06.49.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:32 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Tomasz Duszynski , Yuval Caduri Date: Tue, 4 Sep 2018 15:49:10 +0200 Message-Id: <1536068953-9352-10-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 09/12] net/mvpp2: align with MUSDK 18.09 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" This patch introduces necessary changes required by MUSDK 18.09 library. * As of MUSDK 18.09, pp2_cookie_t is no longer available. Now RX descriptor cookie is defined as plain u64 so existing cast is no longer valid. * MUSDK 18.09 increased number of available bpools (buffer hw pools) by introducing dma regions support. Update mvpp2 driver accordingly. * replace MV_NET_IP4_F_TOS with MV_NET_IP4_F_DSCP Before this patch, API allowed to configure a classification rule according to IPv4 TOS, which was not supported in classifier. This patch fixes this by using proper field. * use 48 bit address mask We cannot get pointers exceeding 48 bits thus using 48 bit mask for extracting higher IOVA address bits is enough. Signed-off-by: Natalie Samsonov Signed-off-by: Yuval Caduri Signed-off-by: Tomasz Duszynski Reviewed-by: Shlomi Gridish Reviewed-by: Alan Winkowski Reviewed-by: Liron Himi --- drivers/net/mvpp2/mrvl_ethdev.c | 10 ++++------ drivers/net/mvpp2/mrvl_flow.c | 3 ++- drivers/net/mvpp2/mrvl_qos.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 035ee81..899a9e4 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -54,9 +54,7 @@ #define MRVL_ARP_LENGTH 28 #define MRVL_COOKIE_ADDR_INVALID ~0ULL - -#define MRVL_COOKIE_HIGH_ADDR_SHIFT (sizeof(pp2_cookie_t) * 8) -#define MRVL_COOKIE_HIGH_ADDR_MASK (~0ULL << MRVL_COOKIE_HIGH_ADDR_SHIFT) +#define MRVL_COOKIE_HIGH_ADDR_MASK 0xffffff0000000000 /** Port Rx offload capabilities */ #define MRVL_RX_OFFLOADS (DEV_RX_OFFLOAD_VLAN_FILTER | \ @@ -1544,7 +1542,7 @@ mrvl_fill_bpool(struct mrvl_rxq *rxq, int num) entries[i].buff.addr = rte_mbuf_data_iova_default(mbufs[i]); - entries[i].buff.cookie = (pp2_cookie_t)(uint64_t)mbufs[i]; + entries[i].buff.cookie = (uint64_t)mbufs[i]; entries[i].bpool = bpool; } @@ -2180,7 +2178,7 @@ mrvl_rx_pkt_burst(void *rxq, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) if (unlikely(status != PP2_DESC_ERR_OK)) { struct pp2_buff_inf binf = { .addr = rte_mbuf_data_iova_default(mbuf), - .cookie = (pp2_cookie_t)(uint64_t)mbuf, + .cookie = (uint64_t)mbuf, }; pp2_bpool_put_buff(hif, bpool, &binf); @@ -2441,7 +2439,7 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) rte_mbuf_prefetch_part2(pref_pkt_hdr); } - sq->ent[sq->head].buff.cookie = (pp2_cookie_t)(uint64_t)mbuf; + sq->ent[sq->head].buff.cookie = (uint64_t)mbuf; sq->ent[sq->head].buff.addr = rte_mbuf_data_iova_default(mbuf); sq->ent[sq->head].bpool = diff --git a/drivers/net/mvpp2/mrvl_flow.c b/drivers/net/mvpp2/mrvl_flow.c index 065b1aa..ffd1dab 100644 --- a/drivers/net/mvpp2/mrvl_flow.c +++ b/drivers/net/mvpp2/mrvl_flow.c @@ -2437,7 +2437,8 @@ mrvl_create_cls_table(struct rte_eth_dev *dev, struct rte_flow *first_flow) if (first_flow->pattern & F_IP4_TOS) { key->proto_field[key->num_fields].proto = MV_NET_PROTO_IP4; - key->proto_field[key->num_fields].field.ipv4 = MV_NET_IP4_F_TOS; + key->proto_field[key->num_fields].field.ipv4 = + MV_NET_IP4_F_DSCP; key->key_size += 1; key->num_fields += 1; } diff --git a/drivers/net/mvpp2/mrvl_qos.c b/drivers/net/mvpp2/mrvl_qos.c index 5d80c3e..7fd9703 100644 --- a/drivers/net/mvpp2/mrvl_qos.c +++ b/drivers/net/mvpp2/mrvl_qos.c @@ -654,7 +654,7 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs, struct pp2_ppio_inq_params *inq_params; param->pkt_offset = MRVL_PKT_OFFS; - param->pools[0] = bpool; + param->pools[0][0] = bpool; param->default_color = color; inq_params = rte_zmalloc_socket("inq_params", From patchwork Tue Sep 4 13:49: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: 44249 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 300465B36; Tue, 4 Sep 2018 15:49:41 +0200 (CEST) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by dpdk.org (Postfix) with ESMTP id 757F15592 for ; Tue, 4 Sep 2018 15:49:34 +0200 (CEST) Received: by mail-lj1-f175.google.com with SMTP id q127-v6so3195872ljq.11 for ; Tue, 04 Sep 2018 06:49:34 -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=Pb1QM3WoKO0XDxYYp3UuHsmAdN8YjUREMaw6CI+dY7c=; b=Q7v/0SXQg+QfzK2uYQN0+uuadSUV5qcKCHv7rPSGNHJZNhjIdZJW+ULAb7eLqBiabW yllJicro5RRSOXuQdRqgkoKmWYGqNi0crFgLolWmKnJN18/wqhgdzodnQXuzlng9dTMC CfmCe8hvOc57hhwYwrVuKH30PknhU4KdBjhKNKIcLycTgYcWBvfLm++Ze0E9xUjWu5BY stC1EGAQex34+dCfkobxgkey2Jt/JsKjQIm/Hlabt6I36C9NWBWlTg5azL/THGABKd37 7FzWPlhzKbXsXHd6kPfctgHgbPjCmwVqJ7FuDrkkmGKLG2vzb6v6qggHGmUWY9ZNOG6L ZKjQ== 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=Pb1QM3WoKO0XDxYYp3UuHsmAdN8YjUREMaw6CI+dY7c=; b=GD7Ga/Dl0qM7UY4lxa5cBFtQNvKukR8f43FYVVlVMa2O28nshqQJouCcohPn6lP+/D vpio/hAVSfpL+YlbKJr1TBopahK1v3MA1aCUQ6ye9HNOY516YiImyuhzEXrvuctHTzX9 L21+Gc46DimB7uKNNpzs/sBe4Sa6HG3f50CbFUuhCYYsQ8o0w+asYNgDm8xbB20z8oiv 3wpLoytOUtirKaiEpW9yQAh44Q0idBfjnhGvy0wKywT0C3ed8TqUD2SdzJUZ0+WAjmP0 Cogx2+gP4QVmuxAykOFfMTKJydJ9FV+kQnTynaMAzAXMrug3ecFlvyXCy2CjQ9v0Kr7F 6okA== X-Gm-Message-State: APzg51COtMR6BbyJ3AxnUvOMQmLGDxSCKGcYp5I8Ty6te2RezJcd9V25 VBhZQWpJmi/dGn5r6ePU97gfbJTMeJQ2zg== X-Google-Smtp-Source: ANB0VdZkjrUvqfv95fttom2Tf5FdNgisqlNZt+tWbwzaJVR90MP55EDXL+lgx3rqnavY2XbGBNAJhA== X-Received: by 2002:a2e:259:: with SMTP id 86-v6mr21532590ljc.107.1536068973882; Tue, 04 Sep 2018 06:49:33 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:33 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com Date: Tue, 4 Sep 2018 15:49:11 +0200 Message-Id: <1536068953-9352-11-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 10/12] net/mvpp2: align documentation with MUSDK 18.09 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 Update documentation to align with MUSDK 18.09. Signed-off-by: Natalie Samsonov --- doc/guides/nics/mvpp2.rst | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/doc/guides/nics/mvpp2.rst b/doc/guides/nics/mvpp2.rst index a452c8a..3b3f8c6 100644 --- a/doc/guides/nics/mvpp2.rst +++ b/doc/guides/nics/mvpp2.rst @@ -74,6 +74,7 @@ Features of the MVPP2 PMD are: - QoS - RX flow control - TX queue start/stop +- Scattered TX frames Limitations @@ -96,19 +97,19 @@ Prerequisites .. code-block:: console - git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.52-armada-17.10 + git clone https://github.com/MarvellEmbeddedProcessors/linux-marvell.git -b linux-4.4.120-armada-18.09 - Out of tree `mvpp2x_sysfs` kernel module sources .. code-block:: console - git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-17.10 + git clone https://github.com/MarvellEmbeddedProcessors/mvpp2x-marvell.git -b mvpp2x-armada-18.09 - MUSDK (Marvell User-Space SDK) sources .. code-block:: console - git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-17.10 + git clone https://github.com/MarvellEmbeddedProcessors/musdk-marvell.git -b musdk-armada-18.09 MUSDK is a light-weight library that provides direct access to Marvell's PPv2 (Packet Processor v2). Alternatively prebuilt MUSDK library can be @@ -119,12 +120,6 @@ Prerequisites To get better understanding of the library one can consult documentation available in the ``doc`` top level directory of the MUSDK sources. - MUSDK must be configured with the following features: - - .. code-block:: console - - --enable-bpool-dma=64 - - DPDK environment Follow the DPDK :ref:`Getting Started Guide for Linux ` to setup @@ -140,6 +135,9 @@ The following options can be modified in the ``config`` file. Toggle compilation of the librte mvpp2 driver. + .. Note:: + + When MVPP2 PMD is enabled ``CONFIG_RTE_LIBRTE_MVNETA_PMD`` must be disabled QoS Configuration ----------------- @@ -314,7 +312,7 @@ Driver needs precompiled MUSDK library during compilation. export CROSS_COMPILE=/bin/aarch64-linux-gnu- ./bootstrap - ./configure --host=aarch64-linux-gnu --enable-bpool-dma=64 + ./configure --host=aarch64-linux-gnu make install MUSDK will be installed to `usr/local` under current directory. @@ -328,7 +326,8 @@ the path to the MUSDK installation directory needs to be exported. export LIBMUSDK_PATH=/usr/local export CROSS=aarch64-linux-gnu- make config T=arm64-armv8a-linuxapp-gcc - sed -ri 's,(MVPP2_PMD=)n,\1y,' build/.config + sed -i "s/MVNETA_PMD=y/MVNETA_PMD=n/" build/.config + sed -i "s/MVPP2_PMD=n/MVPP2_PMD=y/" build/.config make Flow API @@ -500,15 +499,14 @@ Usage Example ------------- MVPP2 PMD requires extra out of tree kernel modules to function properly. -`musdk_uio` and `mv_pp_uio` sources are part of the MUSDK. Please consult +`musdk_cma` sources are part of the MUSDK. Please consult ``doc/musdk_get_started.txt`` for the detailed build instructions. For `mvpp2x_sysfs` please consult ``Documentation/pp22_sysfs.txt`` for the detailed build instructions. .. code-block:: console - insmod musdk_uio.ko - insmod mv_pp_uio.ko + insmod musdk_cma.ko insmod mvpp2x_sysfs.ko Additionally interfaces used by DPDK application need to be put up: From patchwork Tue Sep 4 13:49: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: 44250 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 7C17A5F0D; Tue, 4 Sep 2018 15:49:42 +0200 (CEST) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by dpdk.org (Postfix) with ESMTP id F24CB58CB for ; Tue, 4 Sep 2018 15:49:35 +0200 (CEST) Received: by mail-lj1-f177.google.com with SMTP id l15-v6so3211189lji.6 for ; Tue, 04 Sep 2018 06:49: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=gXu7oWUNC8RzkdIcHwLyaka0ZDKRmxy258w/vT6PZRU=; b=fM76xGmZveJUxdw5FoE4MXuqAcDf6LqzyB7pE8UB6SsYb0Fuyla/HpZvz9d1VyFHxS t28S7RKHBr1xORw6UcmixnJt0frIEKtB5CEG2k68TWlYaUqcF6og9OTR/jcM0+00LRkn NIYcnYslV/DbZuUTmOdIlVRXFB8Yits3rLFjfUXnzTY+Nj2wTcv1mX6ksX6JQ0zUEIRC tWiOFyZ82ZEkOKRrRJOiMFEQ/xSKOOX6X8bSKaWhSD75wRJCDsVGySP0Qqkuk74V21m1 v+crEHl2mQDEKaBQwC4rtX9uXWklIEsdkQCX5Hrz8kDKh4cx0xkbpjx41I8+mcIJeIxP JONQ== 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=gXu7oWUNC8RzkdIcHwLyaka0ZDKRmxy258w/vT6PZRU=; b=QYZgEA6RsRf7ugsqSwh209epfX0rkqDhE6x3Ru2phUAxvVK6PY0akz+jHOGY5vzd2x FXBOwga19bEcjGrruQzaf2Mym1ebZ68WbCtj7Y8z0ZTVdq/zCXl26BLSSXPWOw4xS4C3 hwvb6KHlvwM821l1FZ5/mSLK34ThIecIWPFlrXPukcF879xY9NvKWnFXCYXCfcasvlI8 YHY5ckiHt3TWjPuke5mcmip8vLoTKIzFl5EtDMSVJDd8T9z7bE7gKdZdMldUIiF66jmF f7zIMGGHs1E/zkbqAHrJTNcoPEFuo5rGOWoGJw0DSOevtP0BVBm+c7UNKWPgkKqxOn0R tY8g== X-Gm-Message-State: APzg51Dnk95kq2HaaQ08i1c+MzOTEKMXfZ8k8ClklDuKSKY0KzOsarzA Gx3Ciupfd0HIpT999pf9II0W/cRr4PND/A== X-Google-Smtp-Source: ANB0VdZsYjRh10nMPbqg5Qzx6a0sRdx2gKZkfssipqz3nmzNgX0PKgXbsxpz5W/hTVZ+OhSSC39smA== X-Received: by 2002:a2e:9599:: with SMTP id w25-v6mr10866637ljh.6.1536068974906; Tue, 04 Sep 2018 06:49: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 q22-v6sm4057225lff.10.2018.09.04.06.49.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:34 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com Date: Tue, 4 Sep 2018 15:49:12 +0200 Message-Id: <1536068953-9352-12-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 11/12] net/mvpp2: document MTR and TM usage 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 Document MTR (metering) and TM (traffic management) usage plus do some small updates here and there. Signed-off-by: Natalie Samsonov --- doc/guides/nics/img/mvpp2_tm.png | Bin 0 -> 5355 bytes doc/guides/nics/mvpp2.rst | 386 +++++++++++++++++++++++++++++++++------ 2 files changed, 335 insertions(+), 51 deletions(-) create mode 100644 doc/guides/nics/img/mvpp2_tm.png diff --git a/doc/guides/nics/img/mvpp2_tm.png b/doc/guides/nics/img/mvpp2_tm.png new file mode 100644 index 0000000000000000000000000000000000000000..3c709bab43950c39578a6726ab570008bc722e2f GIT binary patch literal 5355 zcmeHL=U-FX(%vBudXXkgk$yk~Q3z53C{4tG2UHXUA}B>dITY!TXatcaBA^CDq^Ssr zCm^CUrK6#X3B82Sh0sfYyYXJ{?|ttda6jD-N!EJy+B5T;HS^3&;x1U3^KwaW0RX^j zan{5J03dj9oy`FQzty7x?ZF>NfQ|VXprlP|8r-nDpGKYrfOpB<%Y8zcaP zDFOfn2LM|jgqZ?>pyL2Ag8~5ECjfBJFZ1J{`T!v8X<>5uVu;gxmWHpCwopu(RsOlO zTRdWBT=}-w#kM&8XB8m>H1-e8(tgE_MyK7NFETZ_#dTX7dceJvyv!n4WfgP@VK0ZDLsi{Kr==N21k2U?z zh;Odm{jBgv8E*7eTXazv8@$#ngcrb9yRn0SArZn-XZ+&Qf!{!Mk#1cFrf*RKfJc(~ zC@WdfC@5=8tWlBdZ(#3oP)rV_Y*Y(CZ#_FioYvc`g>mrkV=tTj8z`RPF^1l%^8zR< zT6(DN;9V@QfY@P{;s^f*9KMUkzA^7TLel(_bQNZI8>u+HAP1|wJ z7w}3L2I)+K!Xqc8DFAjYN{<@(BvW>q6N*HmjqQ`NEc zh1S`Rut$KW-A~TUfg;xlU)L~+hKQd<=76v+epG8j1n#0MBfx6HA{5$e@O8GU`0RSF z<3ppHe5d-TI08h{s9O+SCyD&p;^trw-!FuAstODG;oWSUUe7AnmB``YR2>n@E*5%> z8Of38ot0Q==k#Mj6E$v|ygegS8`B2fZpa;ENVQq*i%AqK=1Ba0U@0$dqG=_t7o zn+p(0)PE>A;qKw^7R>FD#yx*o}`^4G8lk9kP z=W6D#DN7d_r>Mx_=#uH^KsJfY4clk`rLa1AuA z(yEfCIPOB3@|Up7Eq1Q)V!Y6!H23*N@J1!`A2GjSqaR@IHoAK@XDY1BDXrTzno5rn zeshqL@J6ZHog^Jpnm4RRnL5~<4s)ncGrwwCT;-ILyRACDs&Z&{M{YMtl#Muzx7!aj zht0kjl-xtkQQ2V)fsu~U1eq)GU%=QcgM#5+V~Qjrh9);4`67gt>Vdy3K8)_$0nPE{F|CO z*+SVp=^T<0#-TqiNmM*T$9pgGo(Rv-}&^;F(HNv^JAsx?r7m-F-zisCuB$Z zH#Ugt{j!TR%LOpgR`wYZr%B1r$CKgj<##Y z1fK6hPFJ@YFskqxtk-e{!0aprZ(!LuH^#yGRu%k+DNMl;W_O-`;hnzZ z9xy!P{2<5f!?8hv@=)@I^=Q|0g3ORGwlDz#8o;t|^|{0zvD8R8D{PA(Px|e*W;|DI z`hyJ9*HV8p{Q>fbcKbg)Qh}zF_G!F783Q0_;^1{i>|aOmEs$W>RsU-o#R@k!H}Bru ztY|T=#xZx+hw=64k?)iC=BT9UmQ*FT?daRL;aQoP5zCbt=YxCNbt*d(o`o2!8@mdP zTtTR*s~2{6cYklJ`S|f!QgSkR&6&QlwIxBB(?Mg&&y~bptr*(BcPbzywV$wy=AAb_ z1eHYHg(YaAc%ic!wJ=H#=8%~yT2t$hNkY)UPg*>0$D#P3+4lHo;6Kg*qW?Sh-}DRZ zSmWyIsywVo&YN%lmY0{8eLYJxj(JfAhK8(SV`GD}u}xc(BV%JOTU)C|PY-KPOHstc zF=_8Y?#DA|l1V_5N^mbRWoLJTA;*3&+#eGZ5utBUek?o&W{FO92qcgo0)df0N5zs#%HZ0pROPe-^d99RuSCitaEr_-%D=LMwW)(&-HyBtrA3uK~iA35S-dXGSMV5~B zjvN;^H1{emFHZ&Bx{aNboV}M7FvE|N$H!flARa%fc4mJNg4yNpD@(gO+lpZj`27LWoTEGoL{N1HEa9J_ObFQ4^*mw6VJymlyo8#O^Jd_5)IC;TjMpLG2BrH9m5|F$&1x-U82A9-4 z&O!Z`SYF9r?qYW->LD&<3q_TLcx zGX0>>3=0pcI|Y8_EN@h1A2i%!cI*2hX4dKSf`~_zqD+o$g%@!P_e6$@(Aj(H>p@GD zOOB3?gFy$Y=(|*s`{4UyI^sD$RSm`)8XDx+-_PdbMf=mXiHIns8088_vo5_kcym6e zsV_gXmCQ3S(9-oGG9v2}CS&{6lbz~puhbH=8F)B3N;>|gcQz+w;KRuv)ZL878yv)| zjEaOuIKn&vEQKLms#!=K4=gY7uR#XrLMXbGcc^>d*DCWCCIG&BKE16#U#Yh7b!UjK z>~w{CAUqI`SUu<~2|CR?jK+c$fr?N-!n5^Rd`?elb89f0vp9Qsn+1(YOnZNBtc&{i zEG}+Ma*q1idrYTx~7f)7h(r4?OLSoEHS`!P9P*mVE{%9qr&32U5Z@ zG_`y7OGEa=PAi*bf?>8{bT!9z{!Y~D%y;>}^0u!@;Fq_mosS&pOIns`_bS$}jNFEY zP8`uvuPs2JRRdo}9eGzb5WUOP@oG@+CEs13=6x~4sla5%8_ripZ2H&Of-}?es&G%{ zwzr0ju4J6j3r;1yT|fMqLRm;rH;&*Wk`-dA#ND7dw@p0?V>BEuRdC;Bd^Y?W*^UJaqu?bHqo}}vA zjWo~xl_8@j=ZZ`CTgXzw1|=jqsCc#&ep5Pt%MI!3^~KDv{M*e_?k?xA+sP6vN+x9X zGGb}6u(-o)p4URF%nI`uYlq-De6GhI(@k6+T%W?q5|v|(y|Z8a)uz}RN3)N#nfX&s zWHYO$SU=+<51tLNc+vV&d;0L~!nvSSHc6_6j00NrdN{%Lj2I3$7nj0W zCb74mw@BY^zIks|)8y@4zk9|Ig@yjrBMRK`kAeB~Rl7Y_rlzm5tT(QuLujGrcu=W| zeWJvaOpBji;*Y!d-9IwUcj7P<-Q}rDVs6T4<^dg)$Kf$6CMb@}XOws91GSPcXl!e3 zZ<5-~9M(@!|E^;wJl)c>K!+qLDZq#fs3ams^-HS0%8iSdzJ@l(`!X;2PK!K850qUn zk0Gn+Ts?`dw@oj3X$i4ted4(KbUTWh;xRwH^fatgt;iy>&CyY`{w9Zl^D0Y0|PmYU$EytdRRNX>>$|6wx(stD*RB3ZO}74JU< z@DC)2A66WFTDK~4_H{TXGNVpLAQCRDH8U&B` z?Y4Cq5nae9fn8?2ltcXuaq?9e2l-I426&8-=d6qO?_iNcjc-N3_FKk+fe{4x(Eh6N zHSB`~IlBcU*-2K)DJ=sy1&Rwq^bb3}{%8arj}KXy#o ti<%uDA3wda5=aON0EaxVnuTof6LM+ivt4^5!G9wG3sWnTk~63~{{Y^!D~|vG literal 0 HcmV?d00001 diff --git a/doc/guides/nics/mvpp2.rst b/doc/guides/nics/mvpp2.rst index 3b3f8c6..e7f45c3 100644 --- a/doc/guides/nics/mvpp2.rst +++ b/doc/guides/nics/mvpp2.rst @@ -56,7 +56,7 @@ Features of the MVPP2 PMD are: - Speed capabilities - Link status -- Queue start/stop +- Tx Queue start/stop - MTU update - Jumbo frame - Promiscuous mode @@ -70,12 +70,13 @@ Features of the MVPP2 PMD are: - L4 checksum offload - Packet type parsing - Basic stats -- Extended stats -- QoS +- :ref:`Extended stats ` - RX flow control -- TX queue start/stop - Scattered TX frames - +- :ref:`QoS ` +- :ref:`Flow API ` +- :ref:`Traffic metering and policing ` +- :ref:`Traffic Management API ` Limitations ----------- @@ -89,6 +90,20 @@ Limitations functionality. Current workaround is to reset board so that PPv2 has a chance to start in a sane state. +- MUSDK architecture does not support changing configuration in run time. + All nessesary configurations should be done before first dev_start(). + +- RX queue start/stop is not supported. + +- Current implementation does not support replacement of buffers in the HW buffer pool + at run time, so it is responsibility of the application to ensure that MTU does not exceed the configured buffer size. + +- Configuring TX flow control currently is not supported. + +- In current implementation, mechanism for acknowledging transmitted packets (``tx_done_cleanup``) is not supported. + +- Running more than one DPDK-MUSDK application simultaneously is not supported. + Prerequisites ------------- @@ -139,6 +154,92 @@ The following options can be modified in the ``config`` file. When MVPP2 PMD is enabled ``CONFIG_RTE_LIBRTE_MVNETA_PMD`` must be disabled + +Building DPDK +------------- + +Driver needs precompiled MUSDK library during compilation. + +.. code-block:: console + + export CROSS_COMPILE=/bin/aarch64-linux-gnu- + ./bootstrap + ./configure --host=aarch64-linux-gnu + make install + +MUSDK will be installed to `usr/local` under current directory. +For the detailed build instructions please consult ``doc/musdk_get_started.txt``. + +Before the DPDK build process the environmental variable ``LIBMUSDK_PATH`` with +the path to the MUSDK installation directory needs to be exported. + +For additional instructions regarding DPDK cross compilation please refer to :doc:`Cross compile DPDK for ARM64 <../linux_gsg/cross_build_dpdk_for_arm64>`. + +.. code-block:: console + + export LIBMUSDK_PATH=/usr/local + export CROSS=/bin/aarch64-linux-gnu- + export RTE_KERNELDIR= + export RTE_TARGET=arm64-armv8a-linuxapp-gcc + + make config T=arm64-armv8a-linuxapp-gcc + sed -i "s/MVNETA_PMD=y/MVNETA_PMD=n/" build/.config + sed -i "s/MVPP2_PMD=n/MVPP2_PMD=y/" build/.config + make + +Usage Example +------------- + +MVPP2 PMD requires extra out of tree kernel modules to function properly. +`musdk_cma` sources are part of the MUSDK. Please consult +``doc/musdk_get_started.txt`` for the detailed build instructions. +For `mvpp2x_sysfs` please consult ``Documentation/pp22_sysfs.txt`` for the +detailed build instructions. + +.. code-block:: console + + insmod musdk_cma.ko + insmod mvpp2x_sysfs.ko + +Additionally interfaces used by DPDK application need to be put up: + +.. code-block:: console + + ip link set eth0 up + ip link set eth2 up + +In order to run testpmd example application following command can be used: + +.. code-block:: console + + ./testpmd --vdev=eth_mvpp2,iface=eth0,iface=eth2 -c 7 -- \ + --burst=128 --txd=2048 --rxd=1024 --rxq=2 --txq=2 --nb-cores=2 \ + -i -a --rss-udp + +.. _extstats: + +Extended stats +-------------- + +MVPP2 PMD supports the following extended statistics: + + - ``rx_bytes``: number of RX bytes + - ``rx_packets``: number of RX packets + - ``rx_unicast_packets``: number of RX unicast packets + - ``rx_errors``: number of RX MAC errors + - ``rx_fullq_dropped``: number of RX packets dropped due to full RX queue + - ``rx_bm_dropped``: number of RX packets dropped due to no available buffers in the HW pool + - ``rx_early_dropped``: number of RX packets that were early dropped + - ``rx_fifo_dropped``: number of RX packets dropped due to RX fifo overrun + - ``rx_cls_dropped``: number of RX packets dropped by classifier + - ``tx_bytes``: number of TX bytes + - ``tx_packets``: number of TX packets + - ``tx_unicast_packets``: number of TX unicast packets + - ``tx_errors``: number of TX MAC errors + + +.. _qossupport: + QoS Configuration ----------------- @@ -302,39 +403,14 @@ Usage example ./testpmd --vdev=eth_mvpp2,iface=eth0,iface=eth2,cfg=/home/user/mrvl.conf \ -c 7 -- -i -a --disable-hw-vlan-strip --rxq=3 --txq=3 - -Building DPDK -------------- - -Driver needs precompiled MUSDK library during compilation. - -.. code-block:: console - - export CROSS_COMPILE=/bin/aarch64-linux-gnu- - ./bootstrap - ./configure --host=aarch64-linux-gnu - make install - -MUSDK will be installed to `usr/local` under current directory. -For the detailed build instructions please consult ``doc/musdk_get_started.txt``. - -Before the DPDK build process the environmental variable ``LIBMUSDK_PATH`` with -the path to the MUSDK installation directory needs to be exported. - -.. code-block:: console - - export LIBMUSDK_PATH=/usr/local - export CROSS=aarch64-linux-gnu- - make config T=arm64-armv8a-linuxapp-gcc - sed -i "s/MVNETA_PMD=y/MVNETA_PMD=n/" build/.config - sed -i "s/MVPP2_PMD=n/MVPP2_PMD=y/" build/.config - make +.. _flowapi: Flow API -------- PPv2 offers packet classification capabilities via classifier engine which can be configured via generic flow API offered by DPDK. +For an additional description please refer to DPDK :ref:`Generic flow API `. Supported flow actions ~~~~~~~~~~~~~~~~~~~~~~ @@ -495,31 +571,239 @@ Following limitations need to be taken into account while creating flow rules: For additional information about classifier please consult ``doc/musdk_cls_user_guide.txt``. -Usage Example -------------- +.. _mtrapi: -MVPP2 PMD requires extra out of tree kernel modules to function properly. -`musdk_cma` sources are part of the MUSDK. Please consult -``doc/musdk_get_started.txt`` for the detailed build instructions. -For `mvpp2x_sysfs` please consult ``Documentation/pp22_sysfs.txt`` for the -detailed build instructions. +Traffic metering and policing +----------------------------- -.. code-block:: console +MVPP2 PMD supports DPDK traffic metering and policing that allows the following: - insmod musdk_cma.ko - insmod mvpp2x_sysfs.ko +1. Meter ingress traffic. +2. Do policing. +3. Gather statistics. -Additionally interfaces used by DPDK application need to be put up: +For an additional description please refer to DPDK :doc:`Traffic Metering and Policing API <../prog_guide/traffic_metering_and_policing>`. -.. code-block:: console +The policer objects defined by this feature can work with the default policer defined via config file as discribed in :ref:`QoS Support `. - ip link set eth0 up - ip link set eth2 up +Limitations +~~~~~~~~~~~ -In order to run testpmd example application following command can be used: +The following capabilities are not supported: -.. code-block:: console +- MTR object meter DSCP table update +- MTR object policer action update +- MTR object enabled statistics - ./testpmd --vdev=eth_mvpp2,iface=eth0,iface=eth2 -c 7 -- \ - --burst=128 --txd=2048 --rxd=1024 --rxq=2 --txq=2 --nb-cores=2 \ - -i -a --rss-udp +Usage example +~~~~~~~~~~~~~ + +1. Run testpmd user app: + + .. code-block:: console + + ./testpmd --vdev=eth_mvpp2,iface=eth0,iface=eth2 -c 6 -- -i -p 3 -a --txd 1024 --rxd 1024 + +2. Create meter profile: + + .. code-block:: console + + testpmd> add port meter profile 0 0 srtcm_rfc2697 2000 256 256 + +3. Create meter: + + .. code-block:: console + + testpmd> create port meter 0 0 0 yes d d d 0 1 0 + +4. Create flow rule witch meter attached: + + .. code-block:: console + + testpmd> flow create 0 ingress pattern ipv4 src is 10.10.10.1 / end actions meter mtr_id 0 / end + +For a detailed usage description please refer to "Traffic Metering and Policing" section in DPDK :doc:`Testpmd Runtime Functions <../testpmd_app_ug/testpmd_funcs>`. + + + +.. _tmapi: + +Traffic Management API +---------------------- + +MVPP2 PMD supports generic DPDK Traffic Management API which allows to +configure the following features: + +1. Hierarchical scheduling +2. Traffic shaping +3. Congestion management +4. Packet marking + +Internally TM is represented by a hierarchy (tree) of nodes. +Node which has a parent is called a leaf whereas node without +parent is called a non-leaf (root). +MVPP2 PMD supports two level hierarchy where level 0 represents ports and level 1 represents tx queues of a given port. + +.. figure:: img/mvpp2_tm.png + +Nodes hold following types of settings: + +- for egress scheduler configuration: weight +- for egress rate limiter: private shaper +- bitmask indicating which statistics counters will be read + +Hierarchy is always constructed from the top, i.e first a root node is added +then some number of leaf nodes. Number of leaf nodes cannot exceed number +of configured tx queues. + +After hierarchy is complete it can be committed. + + +For an additional description please refer to DPDK :doc:`Traffic Management API <../prog_guide/traffic_management>`. + +Limitations +~~~~~~~~~~~ + +The following capabilities are not supported: + +- Traffic manager WRED profile and WRED context +- Traffic manager shared shaper update +- Traffic manager packet marking +- Maximum number of levels in hierarchy is 2 +- Currently dynamic change of a hierarchy is not supported + +Usage example +~~~~~~~~~~~~~ + +For a detailed usage description please refer to "Traffic Management" section in DPDK :doc:`Testpmd Runtime Functions <../testpmd_app_ug/testpmd_funcs>`. + +1. Run testpmd as follows: + + .. code-block:: console + + ./testpmd --vdev=net_mrvl,iface=eth0,iface=eth2,cfg=./qos_config -c 7 -- \ + -i -p 3 --disable-hw-vlan-strip --rxq 3 --txq 3 --txd 1024 --rxd 1024 + +2. Stop all ports: + + .. code-block:: console + + testpmd> port stop all + +3. Add shaper profile: + + .. code-block:: console + + testpmd> add port tm node shaper profile 0 0 900000 70000 0 + + Parameters have following meaning:: + + 0 - Id of a port. + 0 - Id of a new shaper profile. + 900000 - Shaper rate in bytes/s. + 70000 - Bucket size in bytes. + 0 - Packet length adjustment - ignored. + +4. Add non-leaf node for port 0: + + .. code-block:: console + + testpmd> add port tm nonleaf node 0 3 -1 0 0 0 0 0 1 3 0 + + Parameters have following meaning:: + + 0 - Id of a port + 3 - Id of a new node. + -1 - Indicate that root does not have a parent. + 0 - Priority of the node. + 0 - Weight of the node. + 0 - Id of a level. Since this is a root 0 is passed. + 0 - Id of the shaper profile. + 0 - Number of SP priorities. + 3 - Enable statistics for both number of transmitted packets and bytes. + 0 - Number of shared shapers. + +5. Add leaf node for tx queue 0: + + .. code-block:: console + + testpmd> add port tm leaf node 0 0 3 0 30 1 -1 0 0 1 0 + + Parameters have following meaning:: + + 0 - Id of a port. + 0 - Id of a new node. + 3 - Id of the parent node. + 0 - Priority of a node. + 30 - WRR weight. + 1 - Id of a level. Since this is a leaf node 1 is passed. + -1 - Id of a shaper. -1 indicates that shaper is not attached. + 0 - Congestion management is not supported. + 0 - Congestion management is not supported. + 1 - Enable statistics counter for number of transmitted packets. + 0 - Number of shared shapers. + +6. Add leaf node for tx queue 1: + + .. code-block:: console + + testpmd> add port tm leaf node 0 1 3 0 60 1 -1 0 0 1 0 + + Parameters have following meaning:: + + 0 - Id of a port. + 1 - Id of a new node. + 3 - Id of the parent node. + 0 - Priority of a node. + 60 - WRR weight. + 1 - Id of a level. Since this is a leaf node 1 is passed. + -1 - Id of a shaper. -1 indicates that shaper is not attached. + 0 - Congestion management is not supported. + 0 - Congestion management is not supported. + 1 - Enable statistics counter for number of transmitted packets. + 0 - Number of shared shapers. + +7. Add leaf node for tx queue 2: + + .. code-block:: console + + testpmd> add port tm leaf node 0 2 3 0 99 1 -1 0 0 1 0 + + Parameters have following meaning:: + + 0 - Id of a port. + 2 - Id of a new node. + 3 - Id of the parent node. + 0 - Priority of a node. + 99 - WRR weight. + 1 - Id of a level. Since this is a leaf node 1 is passed. + -1 - Id of a shaper. -1 indicates that shaper is not attached. + 0 - Congestion management is not supported. + 0 - Congestion management is not supported. + 1 - Enable statistics counter for number of transmitted packets. + 0 - Number of shared shapers. + +8. Commit hierarchy: + + .. code-block:: console + + testpmd> port tm hierarchy commit 0 no + + Parameters have following meaning:: + + 0 - Id of a port. + no - Do not flush TM hierarchy if commit fails. + +9. Start all ports + + .. code-block:: console + + testpmd> port start all + + + +10. Enable forwarding + + .. code-block:: console + + testpmd> start From patchwork Tue Sep 4 13:49: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: 44251 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 9F27D5F16; Tue, 4 Sep 2018 15:49:43 +0200 (CEST) Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id 977F05911 for ; Tue, 4 Sep 2018 15:49:36 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id x26-v6so3005553lfi.7 for ; Tue, 04 Sep 2018 06:49:36 -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=tNZa2oSbsKwpl9GgkorPacuDkjmiSsbldKd7jjcZlnM=; b=kOguogTwTtdA1NFW7s9IRSEa0CCYLTdzFGho7AW7mHASDR5heygjQSQsQT9WonC0f7 FvZ3e88oGq/wIW8YpqR1Nqa+SjYhrPf1I2BfgX6HuZgqnmkLnycpPCBuXkzDO7WRXwOy uHdbnEUDjOFUQNA9lKOW4jqrX6I4SFcnTAIf0RgK90wcE+XPULD3yV6kXHg9P+4Jl/AI JxtlZqIKqgoBo1QHiJEAfAKXM9tYy+yRfQBcnMe6Ds5s4CLaQUDetBVjStuujqmkxikF 155HdWzk+GepI6+WOxdlOdj52LT2tt5gv/9vdyBur2NDdxdWFizz8bVUUVd2HkB4RebU QKuA== 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=tNZa2oSbsKwpl9GgkorPacuDkjmiSsbldKd7jjcZlnM=; b=GAAbpsTdtQXMoXuL5r4gzxJkWNh5vWlXjSlyOpff8ESDDj1vASGD64LidUSA9Ou3Qp jwEcUsPOI9MjxAHRIpYWkeBVcmsXXbQMzQVgjrAmovzdacyMCh+ZO4ikq0vl6A0ifE/U CDK6kusJn291YM/GpZWC76Qlsxif+O+zlEBK3NbTWd7piVTzrN18NRKbU6f+sadqv/wh szrIT3mScL6MO6znKUtp7gyRAadMXwQIsXDlTxgK1pQK5gV+KFvcCAdKGjbovNhgkmdj z8CEw/rY+Butn8y2/PktX3Aboh/KovnoBL53q/sCXpRXcA7DHIjdqnyXZNhQYCN290Ss pknw== X-Gm-Message-State: APzg51Dm43cPZ0C1wlpS69ZDxrkiXeXpHibXnORqOdAK2Xs/SzEMHKl4 KQaA936NJe1A+2YV3krVKPyVj0IGMybsBw== X-Google-Smtp-Source: ANB0VdY+2KFslk5GJQ2NkGXePGni+NPG8eTmBIE3Xs5AAb4A36/gCiCST+HvdHMPqPaVAXMKZ4ojJA== X-Received: by 2002:a19:2a91:: with SMTP id q17-v6mr21567934lfq.74.1536068976024; Tue, 04 Sep 2018 06:49:36 -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 q22-v6sm4057225lff.10.2018.09.04.06.49.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Sep 2018 06:49:35 -0700 (PDT) From: Tomasz Duszynski To: dev@dpdk.org Cc: nsamsono@marvell.com, mw@semihalf.com, Zyta Szpak Date: Tue, 4 Sep 2018 15:49:13 +0200 Message-Id: <1536068953-9352-13-git-send-email-tdu@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536068953-9352-1-git-send-email-tdu@semihalf.com> References: <1536045016-32008-1-git-send-email-tdu@semihalf.com> <1536068953-9352-1-git-send-email-tdu@semihalf.com> Subject: [dpdk-dev] [PATCH v2 12/12] net/mvpp2: add Tx S/G 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" From: Zyta Szpak The patch introduces scatter/gather support on transmit path. A separate Tx callback is added and set if the application requests multisegment Tx offload. Multiple descriptors are sent per one packet. Signed-off-by: Zyta Szpak Signed-off-by: Natalie Samsonov Reviewed-by: Yelena Krivosheev --- drivers/net/mvpp2/mrvl_ethdev.c | 231 ++++++++++++++++++++++++++++++++++++---- drivers/net/mvpp2/mrvl_ethdev.h | 1 + 2 files changed, 212 insertions(+), 20 deletions(-) diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c index 899a9e4..56b190e 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -65,7 +65,8 @@ /** Port Tx offloads capabilities */ #define MRVL_TX_OFFLOADS (DEV_TX_OFFLOAD_IPV4_CKSUM | \ DEV_TX_OFFLOAD_UDP_CKSUM | \ - DEV_TX_OFFLOAD_TCP_CKSUM) + DEV_TX_OFFLOAD_TCP_CKSUM | \ + DEV_TX_OFFLOAD_MULTI_SEGS) static const char * const valid_args[] = { MRVL_IFACE_NAME_ARG, @@ -105,7 +106,9 @@ struct mrvl_shadow_txq { int head; /* write index - used when sending buffers */ int tail; /* read index - used when releasing buffers */ u16 size; /* queue occupied size */ - u16 num_to_release; /* number of buffers sent, that can be released */ + u16 num_to_release; /* number of descriptors sent, that can be + * released + */ struct buff_release_entry ent[MRVL_PP2_TX_SHADOWQ_SIZE]; /* q entries */ }; @@ -137,6 +140,12 @@ static inline void mrvl_free_sent_buffers(struct pp2_ppio *ppio, struct pp2_hif *hif, unsigned int core_id, struct mrvl_shadow_txq *sq, int qid, int force); +static uint16_t mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); +static uint16_t mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts); + + #define MRVL_XSTATS_TBL_ENTRY(name) { \ #name, offsetof(struct pp2_ppio_statistics, name), \ sizeof(((struct pp2_ppio_statistics *)0)->name) \ @@ -163,6 +172,31 @@ static struct { MRVL_XSTATS_TBL_ENTRY(tx_errors) }; +static inline void +mrvl_fill_shadowq(struct mrvl_shadow_txq *sq, struct rte_mbuf *buf) +{ + sq->ent[sq->head].buff.cookie = (uint64_t)buf; + sq->ent[sq->head].buff.addr = buf ? + rte_mbuf_data_iova_default(buf) : 0; + + sq->ent[sq->head].bpool = + (unlikely(!buf || buf->port >= RTE_MAX_ETHPORTS || + buf->refcnt > 1)) ? NULL : + mrvl_port_to_bpool_lookup[buf->port]; + + sq->head = (sq->head + 1) & MRVL_PP2_TX_SHADOWQ_MASK; + sq->size++; +} + +static inline void +mrvl_fill_desc(struct pp2_ppio_desc *desc, struct rte_mbuf *buf) +{ + pp2_ppio_outq_desc_reset(desc); + pp2_ppio_outq_desc_set_phys_addr(desc, rte_pktmbuf_iova(buf)); + pp2_ppio_outq_desc_set_pkt_offset(desc, 0); + pp2_ppio_outq_desc_set_pkt_len(desc, rte_pktmbuf_data_len(buf)); +} + static inline int mrvl_get_bpool_size(int pp2_id, int pool_id) { @@ -242,6 +276,27 @@ mrvl_get_hif(struct mrvl_priv *priv, int core_id) } /** + * Set tx burst function according to offload flag + * + * @param dev + * Pointer to Ethernet device structure. + */ +static void +mrvl_set_tx_function(struct rte_eth_dev *dev) +{ + struct mrvl_priv *priv = dev->data->dev_private; + + /* Use a simple Tx queue (no offloads, no multi segs) if possible */ + if (priv->multiseg) { + RTE_LOG(INFO, PMD, "Using multi-segment tx callback\n"); + dev->tx_pkt_burst = mrvl_tx_sg_pkt_burst; + } else { + RTE_LOG(INFO, PMD, "Using single-segment tx callback\n"); + dev->tx_pkt_burst = mrvl_tx_pkt_burst; + } +} + +/** * Configure rss based on dpdk rss configuration. * * @param priv @@ -325,6 +380,9 @@ mrvl_dev_configure(struct rte_eth_dev *dev) dev->data->mtu = dev->data->dev_conf.rxmode.max_rx_pkt_len - MRVL_PP2_ETH_HDRS_LEN; + if (dev->data->dev_conf.txmode.offloads & DEV_TX_OFFLOAD_MULTI_SEGS) + priv->multiseg = 1; + ret = mrvl_configure_rxqs(priv, dev->data->port_id, dev->data->nb_rx_queues); if (ret < 0) @@ -672,6 +730,7 @@ mrvl_dev_start(struct rte_eth_dev *dev) mrvl_flow_init(dev); mrvl_mtr_init(dev); + mrvl_set_tx_function(dev); return 0; out: @@ -2439,22 +2498,8 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) rte_mbuf_prefetch_part2(pref_pkt_hdr); } - sq->ent[sq->head].buff.cookie = (uint64_t)mbuf; - sq->ent[sq->head].buff.addr = - rte_mbuf_data_iova_default(mbuf); - sq->ent[sq->head].bpool = - (unlikely(mbuf->port >= RTE_MAX_ETHPORTS || - mbuf->refcnt > 1)) ? NULL : - mrvl_port_to_bpool_lookup[mbuf->port]; - sq->head = (sq->head + 1) & MRVL_PP2_TX_SHADOWQ_MASK; - sq->size++; - - pp2_ppio_outq_desc_reset(&descs[i]); - pp2_ppio_outq_desc_set_phys_addr(&descs[i], - rte_pktmbuf_iova(mbuf)); - pp2_ppio_outq_desc_set_pkt_offset(&descs[i], 0); - pp2_ppio_outq_desc_set_pkt_len(&descs[i], - rte_pktmbuf_pkt_len(mbuf)); + mrvl_fill_shadowq(sq, mbuf); + mrvl_fill_desc(&descs[i], mbuf); bytes_sent += rte_pktmbuf_pkt_len(mbuf); /* @@ -2492,6 +2537,152 @@ mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) return nb_pkts; } +/** DPDK callback for S/G transmit. + * + * @param txq + * Generic pointer transmit queue. + * @param tx_pkts + * Packets to transmit. + * @param nb_pkts + * Number of packets in array. + * + * @return + * Number of packets successfully transmitted. + */ +static uint16_t +mrvl_tx_sg_pkt_burst(void *txq, struct rte_mbuf **tx_pkts, + uint16_t nb_pkts) +{ + struct mrvl_txq *q = txq; + struct mrvl_shadow_txq *sq; + struct pp2_hif *hif; + struct pp2_ppio_desc descs[nb_pkts * PP2_PPIO_DESC_NUM_FRAGS]; + struct pp2_ppio_sg_pkts pkts; + uint8_t frags[nb_pkts]; + unsigned int core_id = rte_lcore_id(); + int i, j, ret, bytes_sent = 0; + int tail, tail_first; + uint16_t num, sq_free_size; + uint16_t nb_segs, total_descs = 0; + uint64_t addr; + + hif = mrvl_get_hif(q->priv, core_id); + sq = &q->shadow_txqs[core_id]; + pkts.frags = frags; + pkts.num = 0; + + if (unlikely(!q->priv->ppio || !hif)) + return 0; + + if (sq->size) + mrvl_free_sent_buffers(q->priv->ppio, hif, core_id, + sq, q->queue_id, 0); + + /* Save shadow queue free size */ + sq_free_size = MRVL_PP2_TX_SHADOWQ_SIZE - sq->size - 1; + + tail = 0; + for (i = 0; i < nb_pkts; i++) { + struct rte_mbuf *mbuf = tx_pkts[i]; + struct rte_mbuf *seg = NULL; + int gen_l3_cksum, gen_l4_cksum; + enum pp2_outq_l3_type l3_type; + enum pp2_outq_l4_type l4_type; + + nb_segs = mbuf->nb_segs; + tail_first = tail; + total_descs += nb_segs; + + /* + * Check if total_descs does not exceed + * shadow queue free size + */ + if (unlikely(total_descs > sq_free_size)) { + total_descs -= nb_segs; + RTE_LOG(DEBUG, PMD, + "No room in shadow queue for %d packets! " + "%d packets will be sent.\n", + nb_pkts, i); + break; + } + + /* Check if nb_segs does not exceed the max nb of desc per + * fragmented packet + */ + if (nb_segs > PP2_PPIO_DESC_NUM_FRAGS) { + total_descs -= nb_segs; + RTE_LOG(ERR, PMD, + "Too many segments. Packet won't be sent.\n"); + break; + } + + if (likely(nb_pkts - i > MRVL_MUSDK_PREFETCH_SHIFT)) { + struct rte_mbuf *pref_pkt_hdr; + + pref_pkt_hdr = tx_pkts[i + MRVL_MUSDK_PREFETCH_SHIFT]; + rte_mbuf_prefetch_part1(pref_pkt_hdr); + rte_mbuf_prefetch_part2(pref_pkt_hdr); + } + + pkts.frags[pkts.num] = nb_segs; + pkts.num++; + + seg = mbuf; + for (j = 0; j < nb_segs - 1; j++) { + /* For the subsequent segments, set shadow queue + * buffer to NULL + */ + mrvl_fill_shadowq(sq, NULL); + mrvl_fill_desc(&descs[tail], seg); + + tail++; + seg = seg->next; + } + /* Put first mbuf info in last shadow queue entry */ + mrvl_fill_shadowq(sq, mbuf); + /* Update descriptor with last segment */ + mrvl_fill_desc(&descs[tail++], seg); + + bytes_sent += rte_pktmbuf_pkt_len(mbuf); + /* In case unsupported ol_flags were passed + * do not update descriptor offload information + */ + ret = mrvl_prepare_proto_info(mbuf->ol_flags, mbuf->packet_type, + &l3_type, &l4_type, &gen_l3_cksum, + &gen_l4_cksum); + if (unlikely(ret)) + continue; + + pp2_ppio_outq_desc_set_proto_info(&descs[tail_first], l3_type, + l4_type, mbuf->l2_len, + mbuf->l2_len + mbuf->l3_len, + gen_l3_cksum, gen_l4_cksum); + } + + num = total_descs; + pp2_ppio_send_sg(q->priv->ppio, hif, q->queue_id, descs, + &total_descs, &pkts); + /* number of packets that were not sent */ + if (unlikely(num > total_descs)) { + for (i = total_descs; i < num; i++) { + sq->head = (MRVL_PP2_TX_SHADOWQ_SIZE + sq->head - 1) & + MRVL_PP2_TX_SHADOWQ_MASK; + + addr = sq->ent[sq->head].buff.cookie; + if (addr) + bytes_sent -= + rte_pktmbuf_pkt_len((struct rte_mbuf *) + (cookie_addr_high | addr)); + } + sq->size -= num - total_descs; + nb_pkts = pkts.num; + } + + q->bytes_sent += bytes_sent; + + return nb_pkts; +} + /** * Initialize packet processor. * @@ -2620,11 +2811,11 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name) memcpy(eth_dev->data->mac_addrs[0].addr_bytes, req.ifr_addr.sa_data, ETHER_ADDR_LEN); - eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst; - eth_dev->tx_pkt_burst = mrvl_tx_pkt_burst; eth_dev->data->kdrv = RTE_KDRV_NONE; eth_dev->data->dev_private = priv; eth_dev->device = &vdev->device; + eth_dev->rx_pkt_burst = mrvl_rx_pkt_burst; + mrvl_set_tx_function(eth_dev); eth_dev->dev_ops = &mrvl_ops; rte_eth_dev_probing_finish(eth_dev); diff --git a/drivers/net/mvpp2/mrvl_ethdev.h b/drivers/net/mvpp2/mrvl_ethdev.h index f0ae983..0120b9e 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.h +++ b/drivers/net/mvpp2/mrvl_ethdev.h @@ -188,6 +188,7 @@ struct mrvl_priv { uint8_t uc_mc_flushed; uint8_t vlan_flushed; uint8_t isolated; + uint8_t multiseg; struct pp2_ppio_params ppio_params; struct pp2_cls_qos_tbl_params qos_tbl_params;