get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 77217,
    "url": "http://patches.dpdk.org/api/patches/77217/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1599763717-135002-9-git-send-email-savinay.dharmappa@intel.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": "<1599763717-135002-9-git-send-email-savinay.dharmappa@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1599763717-135002-9-git-send-email-savinay.dharmappa@intel.com",
    "date": "2020-09-10T18:48:35",
    "name": "[v2,08/10] drivers/softnic: add dynamic config of subport",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5918a5d3b19f6810f6c8152a72cb828c0704aaca",
    "submitter": {
        "id": 1535,
        "url": "http://patches.dpdk.org/api/people/1535/?format=api",
        "name": "Savinay Dharmappa",
        "email": "savinay.dharmappa@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1599763717-135002-9-git-send-email-savinay.dharmappa@intel.com/mbox/",
    "series": [
        {
            "id": 12110,
            "url": "http://patches.dpdk.org/api/series/12110/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=12110",
            "date": "2020-09-10T18:48:27",
            "name": "Enable dynamic config of subport bandwidth",
            "version": 2,
            "mbox": "http://patches.dpdk.org/series/12110/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/77217/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/77217/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 772D4A04B5;\n\tThu, 10 Sep 2020 20:50:08 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id BF5551C10A;\n\tThu, 10 Sep 2020 20:49:08 +0200 (CEST)",
            "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n by dpdk.org (Postfix) with ESMTP id D74A01C116\n for <dev@dpdk.org>; Thu, 10 Sep 2020 20:48:57 +0200 (CEST)",
            "from orsmga007.jf.intel.com ([10.7.209.58])\n by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 10 Sep 2020 11:48:56 -0700",
            "from silpixa00400629.ir.intel.com ([10.237.214.135])\n by orsmga007.jf.intel.com with ESMTP; 10 Sep 2020 11:48:55 -0700"
        ],
        "IronPort-SDR": [
            "\n kCXbO/FDQC1R5Ka7boLkIJhwHb2pAHnu6MsAnuGhV+iUV8Vn2vIMO3BBhyO1ccfuJmT4qqrEb0\n fHFCpPTegI6A==",
            "\n O3wilAu3noYegaipLOLfOy0zs0DhgRmnE++ilr7zBHKHpVDPW+rTqOgfqYXrsniUzCk6vweHDE\n MHL/++b+DSYQ=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6000,8403,9740\"; a=\"138130682\"",
            "E=Sophos;i=\"5.76,413,1592895600\"; d=\"scan'208\";a=\"138130682\"",
            "E=Sophos;i=\"5.76,413,1592895600\"; d=\"scan'208\";a=\"344371132\""
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "From": "Savinay Dharmappa <savinay.dharmappa@intel.com>",
        "To": "jasvinder.singh@intel.com,\n\tcristian.dumitrescu@intel.com,\n\tdev@dpdk.org",
        "Cc": "savinay.dharmappa@intel.com",
        "Date": "Thu, 10 Sep 2020 19:48:35 +0100",
        "Message-Id": "<1599763717-135002-9-git-send-email-savinay.dharmappa@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1599763717-135002-1-git-send-email-savinay.dharmappa@intel.com>",
        "References": "<1599037006-3931-1-git-send-email-savinay.dharmappa@intel.com>\n <1599763717-135002-1-git-send-email-savinay.dharmappa@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v2 08/10] drivers/softnic: add dynamic config of\n\tsubport",
        "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": "Modify the softnic drivers to build the hierarchical scheduler\nwith default subport bandwidth profile. It also allows to configure\na subport with different subport bandwidth profile dynamically.\n\nSigned-off-by: Savinay Dharmappa <savinay.dharmappa@intel.com>\n---\n drivers/net/softnic/rte_eth_softnic_internals.h |   9 +\n drivers/net/softnic/rte_eth_softnic_tm.c        | 223 +++++++++++++++++++-----\n 2 files changed, 187 insertions(+), 45 deletions(-)",
    "diff": "diff --git a/drivers/net/softnic/rte_eth_softnic_internals.h b/drivers/net/softnic/rte_eth_softnic_internals.h\nindex 6eec43b..cc50037 100644\n--- a/drivers/net/softnic/rte_eth_softnic_internals.h\n+++ b/drivers/net/softnic/rte_eth_softnic_internals.h\n@@ -164,10 +164,19 @@ TAILQ_HEAD(softnic_link_list, softnic_link);\n #ifndef TM_MAX_PIPE_PROFILE\n #define TM_MAX_PIPE_PROFILE\t\t\t\t256\n #endif\n+\n+#ifndef TM_MAX_SUBPORT_PROFILE\n+#define TM_MAX_SUBPORT_PROFILE\t\t\t\t256\n+#endif\n+\n struct tm_params {\n \tstruct rte_sched_port_params port_params;\n \n \tstruct rte_sched_subport_params subport_params[TM_MAX_SUBPORTS];\n+\tstruct rte_sched_subport_profile_params\n+\t\t\t\tsubport_profiles[TM_MAX_SUBPORT_PROFILE];\n+\tuint32_t n_subport_profiles;\n+\tuint32_t subport_to_profile[TM_MAX_SUBPORT_PROFILE];\n \n \tstruct rte_sched_pipe_params pipe_profiles[TM_MAX_PIPE_PROFILE];\n \tuint32_t n_pipe_profiles;\ndiff --git a/drivers/net/softnic/rte_eth_softnic_tm.c b/drivers/net/softnic/rte_eth_softnic_tm.c\nindex 80a470c..a223655 100644\n--- a/drivers/net/softnic/rte_eth_softnic_tm.c\n+++ b/drivers/net/softnic/rte_eth_softnic_tm.c\n@@ -98,6 +98,13 @@ softnic_tmgr_port_create(struct pmd_internals *p,\n \t\t\treturn NULL;\n \t\t}\n \n+\t\tstatus = rte_sched_subport_profile_config(sched,\n+\t\t\tsubport_id, t->subport_to_profile[subport_id]);\n+\t\tif (status) {\n+\t\t\trte_sched_port_free(sched);\n+\t\t\treturn NULL;\n+\t\t}\n+\n \t\t/* Pipe */\n \t\tfor (pipe_id = 0; pipe_id < n_pipes_per_subport; pipe_id++) {\n \t\t\tint pos = subport_id * TM_MAX_PIPES_PER_SUBPORT + pipe_id;\n@@ -1043,6 +1050,25 @@ tm_shared_shaper_get_tc(struct rte_eth_dev *dev,\n }\n \n static int\n+subport_profile_exists(struct rte_eth_dev *dev,\n+\tstruct rte_sched_subport_profile_params *sp,\n+\tuint32_t *subport_profile_id)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct tm_params *t = &p->soft.tm.params;\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < t->n_subport_profiles; i++)\n+\t\tif (memcmp(&t->subport_profiles[i], sp, sizeof(*sp)) == 0) {\n+\t\t\tif (subport_profile_id)\n+\t\t\t\t*subport_profile_id = i;\n+\t\t\treturn 1;\n+\t\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n update_subport_tc_rate(struct rte_eth_dev *dev,\n \tstruct tm_node *nt,\n \tstruct tm_shared_shaper *ss,\n@@ -1050,26 +1076,27 @@ update_subport_tc_rate(struct rte_eth_dev *dev,\n {\n \tstruct pmd_internals *p = dev->data->dev_private;\n \tuint32_t tc_id = tm_node_tc_id(dev, nt);\n-\n \tstruct tm_node *np = nt->parent_node;\n-\n \tstruct tm_node *ns = np->parent_node;\n \tuint32_t subport_id = tm_node_subport_id(dev, ns);\n-\n-\tstruct rte_sched_subport_params subport_params;\n-\n+\tstruct rte_sched_subport_profile_params subport_profile;\n \tstruct tm_shaper_profile *sp_old = tm_shaper_profile_search(dev,\n \t\tss->shaper_profile_id);\n+\tuint32_t subport_profile_id;\n \n \t/* Derive new subport configuration. */\n-\tmemcpy(&subport_params,\n-\t\t&p->soft.tm.params.subport_params[subport_id],\n-\t\tsizeof(subport_params));\n-\tsubport_params.tc_rate[tc_id] = sp_new->params.peak.rate;\n+\tmemcpy(&subport_profile,\n+\t\t&p->soft.tm.params.subport_profiles[subport_id],\n+\t\tsizeof(subport_profile));\n+\tsubport_profile.tc_rate[tc_id] = sp_new->params.peak.rate;\n+\n+\tif (subport_profile_exists(dev, &subport_profile,\n+\t\t\t\t  &subport_profile_id) == 0)\n+\t\treturn -1;\n \n \t/* Update the subport configuration. */\n-\tif (rte_sched_subport_config(SCHED(p),\n-\t\tsubport_id, &subport_params))\n+\tif (rte_sched_subport_profile_config(SCHED(p),\n+\t\tsubport_id, subport_profile_id))\n \t\treturn -1;\n \n \t/* Commit changes. */\n@@ -1078,9 +1105,9 @@ update_subport_tc_rate(struct rte_eth_dev *dev,\n \tss->shaper_profile_id = sp_new->shaper_profile_id;\n \tsp_new->n_users++;\n \n-\tmemcpy(&p->soft.tm.params.subport_params[subport_id],\n-\t\t&subport_params,\n-\t\tsizeof(subport_params));\n+\tmemcpy(&p->soft.tm.params.subport_profiles[subport_id],\n+\t\t&subport_profile,\n+\t\tsizeof(subport_profile));\n \n \treturn 0;\n }\n@@ -2190,6 +2217,108 @@ pipe_profiles_generate(struct rte_eth_dev *dev)\n \treturn 0;\n }\n \n+static struct rte_sched_subport_profile_params *\n+subport_profile_get(struct rte_eth_dev *dev, struct tm_node *np)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct tm_params *t = &p->soft.tm.params;\n+\tuint32_t subport_id = tm_node_subport_id(dev, np->parent_node);\n+\n+\treturn &t->subport_profiles[subport_id];\n+}\n+\n+static void\n+subport_profile_mark(struct rte_eth_dev *dev,\n+\tuint32_t subport_id,\n+\tuint32_t subport_profile_id)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct tm_params *t = &p->soft.tm.params;\n+\n+\tt->subport_to_profile[subport_id] = subport_profile_id;\n+}\n+\n+static void\n+subport_profile_install(struct rte_eth_dev *dev,\n+\tstruct rte_sched_subport_profile_params *sp,\n+\tuint32_t subport_profile_id)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct tm_params *t = &p->soft.tm.params;\n+\n+\tmemcpy(&t->subport_profiles[subport_profile_id], sp, sizeof(*sp));\n+\tt->n_subport_profiles++;\n+}\n+\n+static int\n+subport_profile_free_exists(struct rte_eth_dev *dev,\n+\tuint32_t *subport_profile_id)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct tm_params *t = &p->soft.tm.params;\n+\n+\tif (t->n_subport_profiles < TM_MAX_SUBPORT_PROFILE) {\n+\t\t*subport_profile_id = t->n_subport_profiles;\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+subport_profile_build(struct tm_node *np,\n+\tstruct rte_sched_subport_profile_params *sp)\n+{\n+\tmemset(sp, 0, sizeof(*sp));\n+\n+\t/* Pipe */\n+\tsp->tb_rate = np->shaper_profile->params.peak.rate;\n+\tsp->tb_size = np->shaper_profile->params.peak.size;\n+\n+\t/* Traffic Class (TC) */\n+\tsp->tc_period = SUBPORT_TC_PERIOD;\n+}\n+\n+static int\n+subport_profiles_generate(struct rte_eth_dev *dev)\n+{\n+\tstruct pmd_internals *p = dev->data->dev_private;\n+\tstruct tm_hierarchy *h = &p->soft.tm.h;\n+\tstruct tm_node_list *nl = &h->nodes;\n+\tstruct tm_node *ns;\n+\tuint32_t subport_id;\n+\n+\t/* Objective: Fill in the following fields in struct tm_params:\n+\t *    - subport_profiles\n+\t *    - n_subport_profiles\n+\t *    - subport_to_profile\n+\t */\n+\n+\tsubport_id = 0;\n+\tTAILQ_FOREACH(ns, nl, node) {\n+\t\tif (ns->level != TM_NODE_LEVEL_SUBPORT)\n+\t\t\tcontinue;\n+\n+\t\tstruct rte_sched_subport_profile_params sp;\n+\t\tuint32_t pos;\n+\n+\t\tsubport_profile_build(ns, &sp);\n+\n+\t\tif (!subport_profile_exists(dev, &sp, &pos)) {\n+\t\t\tif (!subport_profile_free_exists(dev, &pos))\n+\t\t\t\treturn -1;\n+\n+\t\t\tsubport_profile_install(dev, &sp, pos);\n+\t\t}\n+\n+\t\tsubport_profile_mark(dev, subport_id, pos);\n+\n+\t\tsubport_id++;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static struct tm_wred_profile *\n tm_tc_wred_profile_get(struct rte_eth_dev *dev, uint32_t tc_id)\n {\n@@ -2447,6 +2576,15 @@ hierarchy_commit_check(struct rte_eth_dev *dev, struct rte_tm_error *error)\n \t\t\t\trte_strerror(EINVAL));\n \t}\n \n+\t/* Not too many subport profiles. */\n+\tif (subport_profiles_generate(dev))\n+\t\treturn -rte_tm_error_set(error,\n+\t\t\tEINVAL,\n+\t\t\tRTE_TM_ERROR_TYPE_UNSPECIFIED,\n+\t\t\tNULL,\n+\t\t\trte_strerror(EINVAL));\n+\n+\n \t/* Not too many pipe profiles. */\n \tif (pipe_profiles_generate(dev))\n \t\treturn -rte_tm_error_set(error,\n@@ -2528,6 +2666,9 @@ hierarchy_blueprints_create(struct rte_eth_dev *dev)\n \t\t.frame_overhead =\n \t\t\troot->shaper_profile->params.pkt_length_adjust,\n \t\t.n_subports_per_port = root->n_children,\n+\t\t.n_subport_profiles = t->n_subport_profiles,\n+\t\t.subport_profiles = t->subport_profiles,\n+\t\t.n_max_subport_profiles = TM_MAX_SUBPORT_PROFILE,\n \t\t.n_pipes_per_subport = TM_MAX_PIPES_PER_SUBPORT,\n \t};\n \n@@ -2548,28 +2689,11 @@ hierarchy_blueprints_create(struct rte_eth_dev *dev)\n \t\t\t\tss->shaper_profile_id) :\n \t\t\t\tn->shaper_profile;\n \t\t\ttc_rate[i] = sp->params.peak.rate;\n+\t\t\tt->subport_profiles[subport_id].tc_rate[i] = tc_rate[i];\n \t\t}\n \n \t\tt->subport_params[subport_id] =\n \t\t\t(struct rte_sched_subport_params) {\n-\t\t\t\t.tb_rate = n->shaper_profile->params.peak.rate,\n-\t\t\t\t.tb_size = n->shaper_profile->params.peak.size,\n-\n-\t\t\t\t.tc_rate = {tc_rate[0],\n-\t\t\t\t\ttc_rate[1],\n-\t\t\t\t\ttc_rate[2],\n-\t\t\t\t\ttc_rate[3],\n-\t\t\t\t\ttc_rate[4],\n-\t\t\t\t\ttc_rate[5],\n-\t\t\t\t\ttc_rate[6],\n-\t\t\t\t\ttc_rate[7],\n-\t\t\t\t\ttc_rate[8],\n-\t\t\t\t\ttc_rate[9],\n-\t\t\t\t\ttc_rate[10],\n-\t\t\t\t\ttc_rate[11],\n-\t\t\t\t\ttc_rate[12],\n-\t\t\t\t},\n-\t\t\t\t.tc_period = SUBPORT_TC_PERIOD,\n \t\t\t\t.n_pipes_per_subport_enabled =\n \t\t\t\t\th->n_tm_nodes[TM_NODE_LEVEL_PIPE] /\n \t\t\t\t\th->n_tm_nodes[TM_NODE_LEVEL_SUBPORT],\n@@ -2829,30 +2953,39 @@ update_subport_rate(struct rte_eth_dev *dev,\n \tstruct pmd_internals *p = dev->data->dev_private;\n \tuint32_t subport_id = tm_node_subport_id(dev, ns);\n \n-\tstruct rte_sched_subport_params subport_params;\n+\tstruct rte_sched_subport_profile_params *profile0 =\n+\t\t\t\t\tsubport_profile_get(dev, ns);\n+\tstruct rte_sched_subport_profile_params profile1;\n+\tuint32_t subport_profile_id;\n \n-\t/* Derive new subport configuration. */\n-\tmemcpy(&subport_params,\n-\t\t&p->soft.tm.params.subport_params[subport_id],\n-\t\tsizeof(subport_params));\n-\tsubport_params.tb_rate = sp->params.peak.rate;\n-\tsubport_params.tb_size = sp->params.peak.size;\n+\t/* Derive new pipe profile. */\n+\tmemcpy(&profile1, profile0, sizeof(profile1));\n+\tprofile1.tb_rate = sp->params.peak.rate;\n+\tprofile1.tb_size = sp->params.peak.size;\n+\n+\t/* Since implementation does not allow adding more subport profiles\n+\t * after port configuration, the pipe configuration can be successfully\n+\t * updated only if the new profile is also part of the existing set of\n+\t * pipe profiles.\n+\t */\n+\tif (subport_profile_exists(dev, &profile1, &subport_profile_id) == 0)\n+\t\treturn -1;\n \n \t/* Update the subport configuration. */\n-\tif (rte_sched_subport_config(SCHED(p), subport_id,\n-\t\t&subport_params))\n+\tif (rte_sched_subport_profile_config(SCHED(p), subport_id,\n+\t\tsubport_profile_id))\n \t\treturn -1;\n \n+\tsubport_profile_mark(dev, subport_id, subport_profile_id);\n \t/* Commit changes. */\n \tns->shaper_profile->n_users--;\n-\n \tns->shaper_profile = sp;\n \tns->params.shaper_profile_id = sp->shaper_profile_id;\n \tsp->n_users++;\n \n-\tmemcpy(&p->soft.tm.params.subport_params[subport_id],\n-\t\t&subport_params,\n-\t\tsizeof(subport_params));\n+\tmemcpy(&p->soft.tm.params.subport_profiles[subport_id],\n+\t\t&profile1,\n+\t\tsizeof(profile1));\n \n \treturn 0;\n }\n",
    "prefixes": [
        "v2",
        "08/10"
    ]
}