get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/35325/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 35325,
    "url": "http://patches.dpdk.org/api/patches/35325/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1519222460-14605-3-git-send-email-tdu@semihalf.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<1519222460-14605-3-git-send-email-tdu@semihalf.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1519222460-14605-3-git-send-email-tdu@semihalf.com",
    "date": "2018-02-21T14:14:14",
    "name": "[dpdk-dev,2/8] net/mrvl: add ingress policer support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "1a505426d7c05273b113bb03a920ca0e22460599",
    "submitter": {
        "id": 846,
        "url": "http://patches.dpdk.org/api/people/846/?format=api",
        "name": "Tomasz Duszynski",
        "email": "tdu@semihalf.com"
    },
    "delegate": {
        "id": 319,
        "url": "http://patches.dpdk.org/api/users/319/?format=api",
        "username": "fyigit",
        "first_name": "Ferruh",
        "last_name": "Yigit",
        "email": "ferruh.yigit@amd.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1519222460-14605-3-git-send-email-tdu@semihalf.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/35325/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/35325/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id D2F581B22A;\n\tWed, 21 Feb 2018 15:14:35 +0100 (CET)",
            "from mail-lf0-f68.google.com (mail-lf0-f68.google.com\n\t[209.85.215.68]) by dpdk.org (Postfix) with ESMTP id BEE971B1D4\n\tfor <dev@dpdk.org>; Wed, 21 Feb 2018 15:14:34 +0100 (CET)",
            "by mail-lf0-f68.google.com with SMTP id 70so2562944lfw.2\n\tfor <dev@dpdk.org>; Wed, 21 Feb 2018 06:14:34 -0800 (PST)",
            "from sh.semihalf.local (31-172-191-173.noc.fibertech.net.pl.\n\t[31.172.191.173]) by smtp.gmail.com with ESMTPSA id\n\te27sm5038177lff.89.2018.02.21.06.14.33\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tWed, 21 Feb 2018 06:14:33 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=semihalf-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=IMRmcs2NYDeWlANfEieCH/QTiZEjYidy6GG1/yDAQEA=;\n\tb=ca1Mxu9vhlGOb+OmNahWU1B/Id9gCDQqSx2VY1ii0YVYHh3YxD6tdzEansEpSn7XgV\n\tX4FAzJdWWAqlV4FUzI2KS/vt2iu+2cSdCRE7HojSQwUlpZRaxVs9TMsr+j8IPJojXEgp\n\tSNaa2PG/CRc0KR+zCSm+uOdpXpxJee3y9tIHE1S83KkYmceQ/up9bgXy5xutuK2NnxTg\n\tstxh64BFpY1wsAwxMEHfclhQpGiv0NXXSzkyjAskxzaDA6CwdHK21HpWSgI6L25p+4kk\n\tZJagXdVZk6f75UHw0PBTPMFbtiapu0ilUaGZQ2V4kIji6q52dvECYaOe3Wn50vEAMScB\n\thQKw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=IMRmcs2NYDeWlANfEieCH/QTiZEjYidy6GG1/yDAQEA=;\n\tb=M5CFk7p+IZZohXDI0iQlczTywruFNMKGJPXOy2fKDFPCrm//zqYOOFieEW01FtgP6+\n\t5p+6YscYvImfTKvEDAE+vDdIxlAf5GsenQL7QQ+yZrfLYu47d1f5dMRC6eo+njzSoOtj\n\trZpQEaHg+EPEZncxi0wRyNTF+HykRM9N1ZoxpRrgWEAE6r7vqx0HRcHsx7AxDivOgKu1\n\tE8VcadbY0ZDxcolU9Tbz9UN1TQes+IcMc5Le+KARj3Tm1GE1b/o8EExytV0K2hn4PiJJ\n\tWKN2pNeMcDSpUu3mbTgUkFv/m3wesSwY/nN6kOGj6oVGJgoz6H6u+lNeUSFlJg4IdaQr\n\tEqcg==",
        "X-Gm-Message-State": "APf1xPABMf+MxiSISyNqNLwvqYPzJjKBZUAL2a7dyJOHT5nmUBDlaJgR\n\t2SHLjCMSWI6gYuDuiGSH8BW7+Pe5Go8=",
        "X-Google-Smtp-Source": "AH8x225PbAGRlXgNWTtZ+VlL007Oq7ZKe1Xq90nGdR+RTLRCJlSHpgAuFLP0eAHq1ozMuyK8KebauQ==",
        "X-Received": "by 10.25.26.130 with SMTP id a124mr2307453lfa.35.1519222474072; \n\tWed, 21 Feb 2018 06:14:34 -0800 (PST)",
        "From": "Tomasz Duszynski <tdu@semihalf.com>",
        "To": "dev@dpdk.org",
        "Cc": "mw@semihalf.com, dima@marvell.com, nsamsono@marvell.com, jck@semihalf.com,\n\tTomasz Duszynski <tdu@semihalf.com>",
        "Date": "Wed, 21 Feb 2018 15:14:14 +0100",
        "Message-Id": "<1519222460-14605-3-git-send-email-tdu@semihalf.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1519222460-14605-1-git-send-email-tdu@semihalf.com>",
        "References": "<1519222460-14605-1-git-send-email-tdu@semihalf.com>",
        "Subject": "[dpdk-dev] [PATCH 2/8] net/mrvl: add ingress policer support",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add ingress policer support.\n\nSigned-off-by: Natalie Samsonov <nsamsono@marvell.com>\nSigned-off-by: Tomasz Duszynski <tdu@semihalf.com>\n---\n drivers/net/mrvl/mrvl_ethdev.c |   6 ++\n drivers/net/mrvl/mrvl_ethdev.h |   1 +\n drivers/net/mrvl/mrvl_qos.c    | 160 +++++++++++++++++++++++++++++++++++++++--\n drivers/net/mrvl/mrvl_qos.h    |   3 +\n 4 files changed, 166 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/drivers/net/mrvl/mrvl_ethdev.c b/drivers/net/mrvl/mrvl_ethdev.c\nindex 3611a92..2d59fce 100644\n--- a/drivers/net/mrvl/mrvl_ethdev.c\n+++ b/drivers/net/mrvl/mrvl_ethdev.c\n@@ -689,6 +689,12 @@ mrvl_dev_stop(struct rte_eth_dev *dev)\n \tif (priv->ppio)\n \t\tpp2_ppio_deinit(priv->ppio);\n \tpriv->ppio = NULL;\n+\n+\t/* policer must be released after ppio deinitialization */\n+\tif (priv->policer) {\n+\t\tpp2_cls_plcr_deinit(priv->policer);\n+\t\tpriv->policer = NULL;\n+\t}\n }\n \n /**\ndiff --git a/drivers/net/mrvl/mrvl_ethdev.h b/drivers/net/mrvl/mrvl_ethdev.h\nindex f7afae5..0d152d6 100644\n--- a/drivers/net/mrvl/mrvl_ethdev.h\n+++ b/drivers/net/mrvl/mrvl_ethdev.h\n@@ -113,6 +113,7 @@ struct mrvl_priv {\n \tstruct pp2_cls_qos_tbl_params qos_tbl_params;\n \tstruct pp2_cls_tbl *qos_tbl;\n \tuint16_t nb_rx_queues;\n+\tstruct pp2_cls_plcr *policer;\n };\n \n #endif /* _MRVL_ETHDEV_H_ */\ndiff --git a/drivers/net/mrvl/mrvl_qos.c b/drivers/net/mrvl/mrvl_qos.c\nindex fbb3681..854eb4d 100644\n--- a/drivers/net/mrvl/mrvl_qos.c\n+++ b/drivers/net/mrvl/mrvl_qos.c\n@@ -71,6 +71,22 @@\n #define MRVL_TOK_VLAN_IP \"vlan/ip\"\n #define MRVL_TOK_WEIGHT \"weight\"\n \n+/* policer specific configuration tokens */\n+#define MRVL_TOK_PLCR_ENABLE \"policer_enable\"\n+#define MRVL_TOK_PLCR_UNIT \"token_unit\"\n+#define MRVL_TOK_PLCR_UNIT_BYTES \"bytes\"\n+#define MRVL_TOK_PLCR_UNIT_PACKETS \"packets\"\n+#define MRVL_TOK_PLCR_COLOR \"color_mode\"\n+#define MRVL_TOK_PLCR_COLOR_BLIND \"blind\"\n+#define MRVL_TOK_PLCR_COLOR_AWARE \"aware\"\n+#define MRVL_TOK_PLCR_CIR \"cir\"\n+#define MRVL_TOK_PLCR_CBS \"cbs\"\n+#define MRVL_TOK_PLCR_EBS \"ebs\"\n+#define MRVL_TOK_PLCR_DEFAULT_COLOR \"default_color\"\n+#define MRVL_TOK_PLCR_DEFAULT_COLOR_GREEN \"green\"\n+#define MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW \"yellow\"\n+#define MRVL_TOK_PLCR_DEFAULT_COLOR_RED \"red\"\n+\n /** Number of tokens in range a-b = 2. */\n #define MAX_RNG_TOKENS 2\n \n@@ -324,6 +340,25 @@ parse_tc_cfg(struct rte_cfgfile *file, int port, int tc,\n \t\t}\n \t\tcfg->port[port].tc[tc].dscps = n;\n \t}\n+\n+\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\tMRVL_TOK_PLCR_DEFAULT_COLOR);\n+\tif (entry) {\n+\t\tif (!strncmp(entry, MRVL_TOK_PLCR_DEFAULT_COLOR_GREEN,\n+\t\t\t\tsizeof(MRVL_TOK_PLCR_DEFAULT_COLOR_GREEN))) {\n+\t\t\tcfg->port[port].tc[tc].color = PP2_PPIO_COLOR_GREEN;\n+\t\t} else if (!strncmp(entry, MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW,\n+\t\t\t\tsizeof(MRVL_TOK_PLCR_DEFAULT_COLOR_YELLOW))) {\n+\t\t\tcfg->port[port].tc[tc].color = PP2_PPIO_COLOR_YELLOW;\n+\t\t} else if (!strncmp(entry, MRVL_TOK_PLCR_DEFAULT_COLOR_RED,\n+\t\t\t\tsizeof(MRVL_TOK_PLCR_DEFAULT_COLOR_RED))) {\n+\t\t\tcfg->port[port].tc[tc].color = PP2_PPIO_COLOR_RED;\n+\t\t} else {\n+\t\t\tRTE_LOG(ERR, PMD, \"Error while parsing: %s\\n\", entry);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n \treturn 0;\n }\n \n@@ -396,6 +431,88 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path,\n \t\t}\n \n \t\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\t\tMRVL_TOK_PLCR_ENABLE);\n+\t\tif (entry) {\n+\t\t\tif (get_val_securely(entry, &val) < 0)\n+\t\t\t\treturn -1;\n+\t\t\t(*cfg)->port[n].policer_enable = val;\n+\t\t}\n+\n+\t\tif ((*cfg)->port[n].policer_enable) {\n+\t\t\tenum pp2_cls_plcr_token_unit unit;\n+\n+\t\t\t/* Read policer token unit */\n+\t\t\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\t\t\tMRVL_TOK_PLCR_UNIT);\n+\t\t\tif (entry) {\n+\t\t\t\tif (!strncmp(entry, MRVL_TOK_PLCR_UNIT_BYTES,\n+\t\t\t\t\tsizeof(MRVL_TOK_PLCR_UNIT_BYTES))) {\n+\t\t\t\t\tunit = PP2_CLS_PLCR_BYTES_TOKEN_UNIT;\n+\t\t\t\t} else if (!strncmp(entry,\n+\t\t\t\t\t\tMRVL_TOK_PLCR_UNIT_PACKETS,\n+\t\t\t\t\tsizeof(MRVL_TOK_PLCR_UNIT_PACKETS))) {\n+\t\t\t\t\tunit = PP2_CLS_PLCR_PACKETS_TOKEN_UNIT;\n+\t\t\t\t} else {\n+\t\t\t\t\tRTE_LOG(ERR, PMD, \"Unknown token: %s\\n\",\n+\t\t\t\t\t\tentry);\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\t(*cfg)->port[n].policer_params.token_unit =\n+\t\t\t\t\tunit;\n+\t\t\t}\n+\n+\t\t\t/* Read policer color mode */\n+\t\t\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\t\t\tMRVL_TOK_PLCR_COLOR);\n+\t\t\tif (entry) {\n+\t\t\t\tenum pp2_cls_plcr_color_mode mode;\n+\n+\t\t\t\tif (!strncmp(entry, MRVL_TOK_PLCR_COLOR_BLIND,\n+\t\t\t\t\tsizeof(MRVL_TOK_PLCR_COLOR_BLIND))) {\n+\t\t\t\t\tmode = PP2_CLS_PLCR_COLOR_BLIND_MODE;\n+\t\t\t\t} else if (!strncmp(entry,\n+\t\t\t\t\t\tMRVL_TOK_PLCR_COLOR_AWARE,\n+\t\t\t\t\tsizeof(MRVL_TOK_PLCR_COLOR_AWARE))) {\n+\t\t\t\t\tmode = PP2_CLS_PLCR_COLOR_AWARE_MODE;\n+\t\t\t\t} else {\n+\t\t\t\t\tRTE_LOG(ERR, PMD,\n+\t\t\t\t\t\t\"Error in parsing: %s\\n\",\n+\t\t\t\t\t\tentry);\n+\t\t\t\t\treturn -1;\n+\t\t\t\t}\n+\t\t\t\t(*cfg)->port[n].policer_params.color_mode =\n+\t\t\t\t\tmode;\n+\t\t\t}\n+\n+\t\t\t/* Read policer cir */\n+\t\t\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\t\t\tMRVL_TOK_PLCR_CIR);\n+\t\t\tif (entry) {\n+\t\t\t\tif (get_val_securely(entry, &val) < 0)\n+\t\t\t\t\treturn -1;\n+\t\t\t\t(*cfg)->port[n].policer_params.cir = val;\n+\t\t\t}\n+\n+\t\t\t/* Read policer cbs */\n+\t\t\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\t\t\tMRVL_TOK_PLCR_CBS);\n+\t\t\tif (entry) {\n+\t\t\t\tif (get_val_securely(entry, &val) < 0)\n+\t\t\t\t\treturn -1;\n+\t\t\t\t(*cfg)->port[n].policer_params.cbs = val;\n+\t\t\t}\n+\n+\t\t\t/* Read policer ebs */\n+\t\t\tentry = rte_cfgfile_get_entry(file, sec_name,\n+\t\t\t\t\tMRVL_TOK_PLCR_EBS);\n+\t\t\tif (entry) {\n+\t\t\t\tif (get_val_securely(entry, &val) < 0)\n+\t\t\t\t\treturn -1;\n+\t\t\t\t(*cfg)->port[n].policer_params.ebs = val;\n+\t\t\t}\n+\t\t}\n+\n+\t\tentry = rte_cfgfile_get_entry(file, sec_name,\n \t\t\t\tMRVL_TOK_MAPPING_PRIORITY);\n \t\tif (entry) {\n \t\t\tif (!strncmp(entry, MRVL_TOK_VLAN_IP,\n@@ -450,16 +567,18 @@ mrvl_get_qoscfg(const char *key __rte_unused, const char *path,\n  * @param param TC parameters entry.\n  * @param inqs Number of MUSDK in-queues in this TC.\n  * @param bpool Bpool for this TC.\n+ * @param color Default color for this TC.\n  * @returns 0 in case of success, exits otherwise.\n  */\n static int\n setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,\n-\tstruct pp2_bpool *bpool)\n+\tstruct pp2_bpool *bpool, enum pp2_ppio_color color)\n {\n \tstruct pp2_ppio_inq_params *inq_params;\n \n \tparam->pkt_offset = MRVL_PKT_OFFS;\n \tparam->pools[0] = bpool;\n+\tparam->default_color = color;\n \n \tinq_params = rte_zmalloc_socket(\"inq_params\",\n \t\tinqs * sizeof(*inq_params),\n@@ -479,6 +598,33 @@ setup_tc(struct pp2_ppio_tc_params *param, uint8_t inqs,\n }\n \n /**\n+ * Setup ingress policer.\n+ *\n+ * @param priv Port's private data.\n+ * @param params Pointer to the policer's configuration.\n+ * @returns 0 in case of success, negative values otherwise.\n+ */\n+static int\n+setup_policer(struct mrvl_priv *priv, struct pp2_cls_plcr_params *params)\n+{\n+\tchar match[16];\n+\tint ret;\n+\n+\tsprintf(match, \"policer-%d:%d\\n\", priv->pp_id, priv->ppio_id);\n+\tparams->match = match;\n+\n+\tret = pp2_cls_plcr_init(params, &priv->policer);\n+\tif (ret) {\n+\t\tRTE_LOG(ERR, PMD, \"Failed to setup %s\\n\", match);\n+\t\treturn -1;\n+\t}\n+\n+\tpriv->ppio_params.inqs_params.plcr = priv->policer;\n+\n+\treturn 0;\n+}\n+\n+/**\n  * Configure RX Queues in a given port.\n  *\n  * Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.\n@@ -496,10 +642,13 @@ mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,\n \n \tif (mrvl_qos_cfg == NULL ||\n \t\tmrvl_qos_cfg->port[portid].use_global_defaults) {\n-\t\t/* No port configuration, use default: 1 TC, no QoS. */\n+\t\t/*\n+\t\t * No port configuration, use default: 1 TC, no QoS,\n+\t\t * TC color set to green.\n+\t\t */\n \t\tpriv->ppio_params.inqs_params.num_tcs = 1;\n \t\tsetup_tc(&priv->ppio_params.inqs_params.tcs_params[0],\n-\t\t\tmax_queues, priv->bpool);\n+\t\t\tmax_queues, priv->bpool, PP2_PPIO_COLOR_GREEN);\n \n \t\t/* Direct mapping of queues i.e. 0->0, 1->1 etc. */\n \t\tfor (i = 0; i < max_queues; ++i) {\n@@ -597,11 +746,14 @@ mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,\n \t\t\tbreak;\n \t\tsetup_tc(&priv->ppio_params.inqs_params.tcs_params[i],\n \t\t\t\tport_cfg->tc[i].inqs,\n-\t\t\t\tpriv->bpool);\n+\t\t\t\tpriv->bpool, port_cfg->tc[i].color);\n \t}\n \n \tpriv->ppio_params.inqs_params.num_tcs = i;\n \n+\tif (port_cfg->policer_enable)\n+\t\treturn setup_policer(priv, &port_cfg->policer_params);\n+\n \treturn 0;\n }\n \ndiff --git a/drivers/net/mrvl/mrvl_qos.h b/drivers/net/mrvl/mrvl_qos.h\nindex ae7508c..2ff50c1 100644\n--- a/drivers/net/mrvl/mrvl_qos.h\n+++ b/drivers/net/mrvl/mrvl_qos.h\n@@ -55,6 +55,7 @@ struct mrvl_qos_cfg {\n \t\t\tuint8_t inqs;\n \t\t\tuint8_t dscps;\n \t\t\tuint8_t pcps;\n+\t\t\tenum pp2_ppio_color color;\n \t\t} tc[MRVL_PP2_TC_MAX];\n \t\tstruct {\n \t\t\tuint8_t weight;\n@@ -64,6 +65,8 @@ struct mrvl_qos_cfg {\n \t\tuint16_t outqs;\n \t\tuint8_t default_tc;\n \t\tuint8_t use_global_defaults;\n+\t\tstruct pp2_cls_plcr_params policer_params;\n+\t\tuint8_t policer_enable;\n \t} port[RTE_MAX_ETHPORTS];\n };\n \n",
    "prefixes": [
        "dpdk-dev",
        "2/8"
    ]
}