From patchwork Tue Sep 25 07:05:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Ostruszka X-Patchwork-Id: 45292 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 D99B6548B; Tue, 25 Sep 2018 09:05:26 +0200 (CEST) Received: from mail-lf1-f65.google.com (mail-lf1-f65.google.com [209.85.167.65]) by dpdk.org (Postfix) with ESMTP id 99F5D4CA5 for ; Tue, 25 Sep 2018 09:05:16 +0200 (CEST) Received: by mail-lf1-f65.google.com with SMTP id a82-v6so3619206lfa.4 for ; Tue, 25 Sep 2018 00:05:16 -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=VQ6BynRxjjN5oqK0wBGUmFaqigfXEHYiyw3U2xCX5Es=; b=xvkmLIbzjX8vPr+hfGynzpac+6Cr2zbzwD4GLeeYlixhRPpesNz8KGrhzLlMosaNTX f8SHPqQ8iayq5z3aRsg8F6OqEhBFwfPTCW7umZf1oOXMxdzOB/KUuFCbtiIvGZXIHmoP gwLAQMruypwZLOwQR20u1tY48/imDL+kbm4EgWKIJB0JRofrYLRrGhNkbAOHDNgHkM2X Lk/QgszUOMyUI0bYufbpTyX8IaWW66LDogW+FWxyxnPkR2v8Im2nA1XaUwUDIwXXNwfN /BcZe5UZ9QgtjJaPbEkNuy4uGkQedXA00Ve3Izt9zCPwVNQfmxjzTmxK2/Yzn8w/3WlG ckcA== 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=VQ6BynRxjjN5oqK0wBGUmFaqigfXEHYiyw3U2xCX5Es=; b=aelkgNlUUfd806UjnrDojfCdbIIFj4F3Q0oC832THMSA3e9RmmCRMnIV2POrO2rJiJ iWBrB7TRXofiDLjLxkagjcN2fZ1Fsdj8HTVFFGax+TVyLRBdaeNYGgkoH6vT5EpqwMat c2GhnS8elaXBq2wuIPu1sQuNLFeR2lsAPf/S+0MKvXQuonZjG342Y0/Bc9nGuSUMOCbt MHrGJg2pzn6CMEp6awSbbKJ9nTVrqluSG01qiYSzM7lugv6h8xslMMMFGRIvNOoUi3SN eOLjxHlEMtOPsH6p+KLZMiWpldEmLqoXgr2Ib10h9NS2ivaQ+x9Hq7ourht3FgcHMmkk +R1Q== X-Gm-Message-State: ABuFfojlx5RcMAFFPxDbLcgP6AyS6Ju4Cokr1XtvIVmp/CN61JTTzdYS HdF07s4VIN6Vv1Uzv7tcOezO3PMfu2mg6Q== X-Google-Smtp-Source: ACcGV632DLPdOvtGxgdNBveQre5F5ZiWp22aw4kLhIaz8nMeT6tKZ0cV9m8zWCt4+T2LnknzMnikWA== X-Received: by 2002:a19:109e:: with SMTP id 30-v6mr1430358lfq.96.1537859115831; Tue, 25 Sep 2018 00:05:15 -0700 (PDT) Received: from amok.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.googlemail.com with ESMTPSA id 24-v6sm238306ljb.76.2018.09.25.00.05.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Sep 2018 00:05:15 -0700 (PDT) From: Andrzej Ostruszka To: dev@dpdk.org Cc: mw@semihalf.com, nadavh@marvell.com, Tomasz Duszynski , Natalie Samsonov Date: Tue, 25 Sep 2018 09:05:00 +0200 Message-Id: <1537859109-25659-5-git-send-email-amo@semihalf.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537859109-25659-1-git-send-email-amo@semihalf.com> References: <1536068953-9352-1-git-send-email-tdu@semihalf.com> <1537859109-25659-1-git-send-email-amo@semihalf.com> Subject: [dpdk-dev] [PATCH v3 04/13] 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" From: Tomasz Duszynski 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 a6cc550..0571635 100644 --- a/drivers/net/mvpp2/mrvl_ethdev.c +++ b/drivers/net/mvpp2/mrvl_ethdev.c @@ -789,9 +789,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]; };