get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 66582,
    "url": "http://patches.dpdk.org/api/patches/66582/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200312111907.31555-8-ndabilpuram@marvell.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": "<20200312111907.31555-8-ndabilpuram@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200312111907.31555-8-ndabilpuram@marvell.com",
    "date": "2020-03-12T11:19:03",
    "name": "[07/11] net/octeontx2: add tm stats and shaper profile cbs",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "2810e30903d811d62a923196499d23470fe710ba",
    "submitter": {
        "id": 1202,
        "url": "http://patches.dpdk.org/api/people/1202/?format=api",
        "name": "Nithin Dabilpuram",
        "email": "ndabilpuram@marvell.com"
    },
    "delegate": {
        "id": 310,
        "url": "http://patches.dpdk.org/api/users/310/?format=api",
        "username": "jerin",
        "first_name": "Jerin",
        "last_name": "Jacob",
        "email": "jerinj@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200312111907.31555-8-ndabilpuram@marvell.com/mbox/",
    "series": [
        {
            "id": 8894,
            "url": "http://patches.dpdk.org/api/series/8894/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8894",
            "date": "2020-03-12T11:18:56",
            "name": "net/octeontx2: add traffic manager support",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8894/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/66582/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/66582/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 7B41CA056B;\n\tThu, 12 Mar 2020 12:21:11 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id DDBB11C0AB;\n\tThu, 12 Mar 2020 12:19:35 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 947A11C067\n for <dev@dpdk.org>; Thu, 12 Mar 2020 12:19:34 +0100 (CET)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n 02CBFWvm017671 for <dev@dpdk.org>; Thu, 12 Mar 2020 04:19:34 -0700",
            "from sc-exch01.marvell.com ([199.233.58.181])\n by mx0b-0016f401.pphosted.com with ESMTP id 2yqfggs6fa-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT)\n for <dev@dpdk.org>; Thu, 12 Mar 2020 04:19:33 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Thu, 12 Mar 2020 04:19:32 -0700",
            "from SC-EXCH04.marvell.com (10.93.176.84) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Thu, 12 Mar 2020 04:19:31 -0700",
            "from maili.marvell.com (10.93.176.43) by SC-EXCH04.marvell.com\n (10.93.176.84) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Thu, 12 Mar 2020 04:19:30 -0700",
            "from hyd1588t430.marvell.com (unknown [10.29.52.204])\n by maili.marvell.com (Postfix) with ESMTP id 553D93F7041;\n Thu, 12 Mar 2020 04:19:29 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-type; s=pfpt0818; bh=Jz+UUSxGiEWOoi+PeYPFUgAN8j0Zdk/qIjo68zb9eh4=;\n b=kAyDEcXwkEUiP6K+lqdsVzsDCHP+EJCdPYqzNnGPOUDIFO/oUHVncN6zUK3wk9DL7HxA\n 2mbD8Fs20fmK5020TzG7bNzTTl90p32sgM7OUOwh1DAwmyBBgkNf1//dOxbqFlleZQon\n YHi3JjTihyo9UnlfkVFluRdqvEbR1Us4Q3iyyK6mECxKMh0y+LJcIOU9YCXtSe1v9wTx\n 0w1IWmYS2ZghIZg+D0Rh0zrVbIcGbLvu1Uj9yGeffRjKqqZWp1U+7Hmx2bTujcDU7s3p\n fpGrzX39GoTq0vOMmSknNXEp+YJOwN3fLcHd1eYaTkG5fxTSfvvB3NUm2O7ED8+gVeBV Iw==",
        "From": "Nithin Dabilpuram <ndabilpuram@marvell.com>",
        "To": "Jerin Jacob <jerinj@marvell.com>, Nithin Dabilpuram\n <ndabilpuram@marvell.com>, Kiran Kumar K <kirankumark@marvell.com>",
        "CC": "Krzysztof Kanas <kkanas@marvell.com>, <dev@dpdk.org>",
        "Date": "Thu, 12 Mar 2020 16:49:03 +0530",
        "Message-ID": "<20200312111907.31555-8-ndabilpuram@marvell.com>",
        "X-Mailer": "git-send-email 2.8.4",
        "In-Reply-To": "<20200312111907.31555-1-ndabilpuram@marvell.com>",
        "References": "<20200312111907.31555-1-ndabilpuram@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572\n definitions=2020-03-12_03:2020-03-11,\n 2020-03-12 signatures=0",
        "Subject": "[dpdk-dev] [PATCH 07/11] net/octeontx2: add tm stats and shaper\n\tprofile cbs",
        "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://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add TM support for stats read and private shaper\nprofile addition or deletion.\n\nSigned-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>\nSigned-off-by: Krzysztof Kanas <kkanas@marvell.com>\n---\n drivers/net/octeontx2/otx2_tm.c | 271 ++++++++++++++++++++++++++++++++++++++++\n drivers/net/octeontx2/otx2_tm.h |   4 +\n 2 files changed, 275 insertions(+)",
    "diff": "diff --git a/drivers/net/octeontx2/otx2_tm.c b/drivers/net/octeontx2/otx2_tm.c\nindex ae779a5..6cc07fc 100644\n--- a/drivers/net/octeontx2/otx2_tm.c\n+++ b/drivers/net/octeontx2/otx2_tm.c\n@@ -1668,6 +1668,47 @@ validate_prio(struct otx2_eth_dev *dev, uint32_t lvl,\n }\n \n static int\n+read_tm_reg(struct otx2_mbox *mbox, uint64_t reg,\n+\t    uint64_t *regval, uint32_t hw_lvl)\n+{\n+\tvolatile struct nix_txschq_config *req;\n+\tstruct nix_txschq_config *rsp;\n+\tint rc;\n+\n+\treq = otx2_mbox_alloc_msg_nix_txschq_cfg(mbox);\n+\treq->read = 1;\n+\treq->lvl = hw_lvl;\n+\treq->reg[0] = reg;\n+\treq->num_regs = 1;\n+\n+\trc = otx2_mbox_process_msg(mbox, (void **)&rsp);\n+\tif (rc)\n+\t\treturn rc;\n+\t*regval = rsp->regval[0];\n+\treturn 0;\n+}\n+\n+/* Search for min rate in topology */\n+static void\n+nix_tm_shaper_profile_update_min(struct otx2_eth_dev *dev)\n+{\n+\tstruct otx2_nix_tm_shaper_profile *profile;\n+\tuint64_t rate_min = 1E9; /* 1 Gbps */\n+\n+\tTAILQ_FOREACH(profile, &dev->shaper_profile_list, shaper) {\n+\t\tif (profile->params.peak.rate &&\n+\t\t    profile->params.peak.rate < rate_min)\n+\t\t\trate_min = profile->params.peak.rate;\n+\n+\t\tif (profile->params.committed.rate &&\n+\t\t    profile->params.committed.rate < rate_min)\n+\t\t\trate_min = profile->params.committed.rate;\n+\t}\n+\n+\tdev->tm_rate_min = rate_min;\n+}\n+\n+static int\n nix_xmit_disable(struct rte_eth_dev *eth_dev)\n {\n \tstruct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);\n@@ -1763,6 +1804,145 @@ nix_xmit_disable(struct rte_eth_dev *eth_dev)\n }\n \n static int\n+nix_tm_node_type_get(struct rte_eth_dev *eth_dev, uint32_t node_id,\n+\t\t     int *is_leaf, struct rte_tm_error *error)\n+{\n+\tstruct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);\n+\tstruct otx2_nix_tm_node *tm_node;\n+\n+\tif (is_leaf == NULL) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;\n+\t\treturn -EINVAL;\n+\t}\n+\n+\ttm_node = nix_tm_node_search(dev, node_id, true);\n+\tif (node_id == RTE_TM_NODE_ID_NULL || !tm_node) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_NODE_ID;\n+\t\treturn -EINVAL;\n+\t}\n+\tif (nix_tm_is_leaf(dev, tm_node->lvl))\n+\t\t*is_leaf = true;\n+\telse\n+\t\t*is_leaf = false;\n+\n+\treturn 0;\n+}\n+\n+static int\n+nix_tm_shaper_profile_add(struct rte_eth_dev *eth_dev,\n+\t\t\t  uint32_t profile_id,\n+\t\t\t  struct rte_tm_shaper_params *params,\n+\t\t\t  struct rte_tm_error *error)\n+{\n+\tstruct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);\n+\tstruct otx2_nix_tm_shaper_profile *profile;\n+\n+\tprofile = nix_tm_shaper_profile_search(dev, profile_id);\n+\tif (profile) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;\n+\t\terror->message = \"shaper profile ID exist\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Committed rate and burst size can be enabled/disabled */\n+\tif (params->committed.size || params->committed.rate) {\n+\t\tif (params->committed.size < MIN_SHAPER_BURST ||\n+\t\t    params->committed.size > MAX_SHAPER_BURST) {\n+\t\t\terror->type =\n+\t\t\t\tRTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_SIZE;\n+\t\t\treturn -EINVAL;\n+\t\t} else if (!shaper_rate_to_nix(params->committed.rate * 8,\n+\t\t\t\t\t       NULL, NULL, NULL)) {\n+\t\t\terror->type =\n+\t\t\t\tRTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE;\n+\t\t\terror->message = \"shaper committed rate invalid\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\t/* Peak rate and burst size can be enabled/disabled */\n+\tif (params->peak.size || params->peak.rate) {\n+\t\tif (params->peak.size < MIN_SHAPER_BURST ||\n+\t\t    params->peak.size > MAX_SHAPER_BURST) {\n+\t\t\terror->type =\n+\t\t\t\tRTE_TM_ERROR_TYPE_SHAPER_PROFILE_PEAK_SIZE;\n+\t\t\treturn -EINVAL;\n+\t\t} else if (!shaper_rate_to_nix(params->peak.rate * 8,\n+\t\t\t\t\t       NULL, NULL, NULL)) {\n+\t\t\terror->type =\n+\t\t\t\tRTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE;\n+\t\t\terror->message = \"shaper peak rate invalid\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tprofile = rte_zmalloc(\"otx2_nix_tm_shaper_profile\",\n+\t\t\t      sizeof(struct otx2_nix_tm_shaper_profile), 0);\n+\tif (!profile)\n+\t\treturn -ENOMEM;\n+\n+\tprofile->shaper_profile_id = profile_id;\n+\trte_memcpy(&profile->params, params,\n+\t\t   sizeof(struct rte_tm_shaper_params));\n+\tTAILQ_INSERT_TAIL(&dev->shaper_profile_list, profile, shaper);\n+\n+\totx2_tm_dbg(\"Added TM shaper profile %u, \"\n+\t\t    \" pir %\" PRIu64 \" , pbs %\" PRIu64 \", cir %\" PRIu64\n+\t\t    \", cbs %\" PRIu64 \" , adj %u\",\n+\t\t    profile_id,\n+\t\t    params->peak.rate * 8,\n+\t\t    params->peak.size,\n+\t\t    params->committed.rate * 8,\n+\t\t    params->committed.size,\n+\t\t    params->pkt_length_adjust);\n+\n+\t/* Translate rate as bits per second */\n+\tprofile->params.peak.rate = profile->params.peak.rate * 8;\n+\tprofile->params.committed.rate = profile->params.committed.rate * 8;\n+\t/* Always use PIR for single rate shaping */\n+\tif (!params->peak.rate && params->committed.rate) {\n+\t\tprofile->params.peak = profile->params.committed;\n+\t\tmemset(&profile->params.committed, 0,\n+\t\t       sizeof(profile->params.committed));\n+\t}\n+\n+\t/* update min rate */\n+\tnix_tm_shaper_profile_update_min(dev);\n+\treturn 0;\n+}\n+\n+static int\n+nix_tm_shaper_profile_delete(struct rte_eth_dev *eth_dev,\n+\t\t\t     uint32_t profile_id,\n+\t\t\t     struct rte_tm_error *error)\n+{\n+\tstruct otx2_nix_tm_shaper_profile *profile;\n+\tstruct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);\n+\n+\tprofile = nix_tm_shaper_profile_search(dev, profile_id);\n+\n+\tif (!profile) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE_ID;\n+\t\terror->message = \"shaper profile ID not exist\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (profile->reference_count) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_SHAPER_PROFILE;\n+\t\terror->message = \"shaper profile in use\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\totx2_tm_dbg(\"Removing TM shaper profile %u\", profile_id);\n+\tTAILQ_REMOVE(&dev->shaper_profile_list, profile, shaper);\n+\trte_free(profile);\n+\n+\t/* update min rate */\n+\tnix_tm_shaper_profile_update_min(dev);\n+\treturn 0;\n+}\n+\n+static int\n nix_tm_node_add(struct rte_eth_dev *eth_dev, uint32_t node_id,\n \t\tuint32_t parent_node_id, uint32_t priority,\n \t\tuint32_t weight, uint32_t lvl,\n@@ -2048,12 +2228,103 @@ nix_tm_hierarchy_commit(struct rte_eth_dev *eth_dev,\n \treturn 0;\n }\n \n+static int\n+nix_tm_node_stats_read(struct rte_eth_dev *eth_dev, uint32_t node_id,\n+\t\t       struct rte_tm_node_stats *stats, uint64_t *stats_mask,\n+\t\t       int clear, struct rte_tm_error *error)\n+{\n+\tstruct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);\n+\tstruct otx2_nix_tm_node *tm_node;\n+\tuint64_t reg, val;\n+\tint64_t *addr;\n+\tint rc = 0;\n+\n+\ttm_node = nix_tm_node_search(dev, node_id, true);\n+\tif (!tm_node) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_NODE_ID;\n+\t\terror->message = \"no such node\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\t/* Stats support only for leaf node or TL1 root */\n+\tif (nix_tm_is_leaf(dev, tm_node->lvl)) {\n+\t\treg = (((uint64_t)tm_node->id) << 32);\n+\n+\t\t/* Packets */\n+\t\taddr = (int64_t *)(dev->base + NIX_LF_SQ_OP_PKTS);\n+\t\tval = otx2_atomic64_add_nosync(reg, addr);\n+\t\tif (val & OP_ERR)\n+\t\t\tval = 0;\n+\t\tstats->n_pkts = val - tm_node->last_pkts;\n+\n+\t\t/* Bytes */\n+\t\taddr = (int64_t *)(dev->base + NIX_LF_SQ_OP_OCTS);\n+\t\tval = otx2_atomic64_add_nosync(reg, addr);\n+\t\tif (val & OP_ERR)\n+\t\t\tval = 0;\n+\t\tstats->n_bytes = val - tm_node->last_bytes;\n+\n+\t\tif (clear) {\n+\t\t\ttm_node->last_pkts = stats->n_pkts;\n+\t\t\ttm_node->last_bytes = stats->n_bytes;\n+\t\t}\n+\n+\t\t*stats_mask = RTE_TM_STATS_N_PKTS | RTE_TM_STATS_N_BYTES;\n+\n+\t} else if (tm_node->hw_lvl == NIX_TXSCH_LVL_TL1) {\n+\t\terror->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;\n+\t\terror->message = \"stats read error\";\n+\n+\t\t/* RED Drop packets */\n+\t\treg = NIX_AF_TL1X_DROPPED_PACKETS(tm_node->hw_id);\n+\t\trc = read_tm_reg(dev->mbox, reg, &val, NIX_TXSCH_LVL_TL1);\n+\t\tif (rc)\n+\t\t\tgoto exit;\n+\t\tstats->leaf.n_pkts_dropped[RTE_COLOR_RED] =\n+\t\t\t\t\t\tval - tm_node->last_pkts;\n+\n+\t\t/* RED Drop bytes */\n+\t\treg = NIX_AF_TL1X_DROPPED_BYTES(tm_node->hw_id);\n+\t\trc = read_tm_reg(dev->mbox, reg, &val, NIX_TXSCH_LVL_TL1);\n+\t\tif (rc)\n+\t\t\tgoto exit;\n+\t\tstats->leaf.n_bytes_dropped[RTE_COLOR_RED] =\n+\t\t\t\t\t\tval - tm_node->last_bytes;\n+\n+\t\t/* Clear stats */\n+\t\tif (clear) {\n+\t\t\ttm_node->last_pkts =\n+\t\t\t\tstats->leaf.n_pkts_dropped[RTE_COLOR_RED];\n+\t\t\ttm_node->last_bytes =\n+\t\t\t\tstats->leaf.n_bytes_dropped[RTE_COLOR_RED];\n+\t\t}\n+\n+\t\t*stats_mask = RTE_TM_STATS_N_PKTS_RED_DROPPED |\n+\t\t\tRTE_TM_STATS_N_BYTES_RED_DROPPED;\n+\n+\t} else {\n+\t\terror->type = RTE_TM_ERROR_TYPE_NODE_ID;\n+\t\terror->message = \"unsupported node\";\n+\t\trc = -EINVAL;\n+\t}\n+\n+exit:\n+\treturn rc;\n+}\n+\n const struct rte_tm_ops otx2_tm_ops = {\n+\t.node_type_get = nix_tm_node_type_get,\n+\n+\t.shaper_profile_add = nix_tm_shaper_profile_add,\n+\t.shaper_profile_delete = nix_tm_shaper_profile_delete,\n+\n \t.node_add = nix_tm_node_add,\n \t.node_delete = nix_tm_node_delete,\n \t.node_suspend = nix_tm_node_suspend,\n \t.node_resume = nix_tm_node_resume,\n \t.hierarchy_commit = nix_tm_hierarchy_commit,\n+\n+\t.node_stats_read = nix_tm_node_stats_read,\n };\n \n static int\ndiff --git a/drivers/net/octeontx2/otx2_tm.h b/drivers/net/octeontx2/otx2_tm.h\nindex ebb4e90..20e2069 100644\n--- a/drivers/net/octeontx2/otx2_tm.h\n+++ b/drivers/net/octeontx2/otx2_tm.h\n@@ -46,6 +46,10 @@ struct otx2_nix_tm_node {\n \n \tstruct otx2_nix_tm_node *parent;\n \tstruct rte_tm_node_params params;\n+\n+\t/* Last stats */\n+\tuint64_t last_pkts;\n+\tuint64_t last_bytes;\n };\n \n struct otx2_nix_tm_shaper_profile {\n",
    "prefixes": [
        "07/11"
    ]
}