get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 810972,
    "url": "http://patchwork.ozlabs.org/api/patches/810972/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/150478203291.24662.3361290802097939640.stgit@anamdev.jf.intel.com/",
    "project": {
        "id": 46,
        "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api",
        "name": "Intel Wired Ethernet development",
        "link_name": "intel-wired-lan",
        "list_id": "intel-wired-lan.osuosl.org",
        "list_email": "intel-wired-lan@osuosl.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<150478203291.24662.3361290802097939640.stgit@anamdev.jf.intel.com>",
    "list_archive_url": null,
    "date": "2017-09-07T11:00:32",
    "name": "[RFC,v3,6/6] i40e: Add support setting TC max bandwidth rates",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "4ca8d1c3e12fe75e944759e2757d4f6e9b39b106",
    "submitter": {
        "id": 68504,
        "url": "http://patchwork.ozlabs.org/api/people/68504/?format=api",
        "name": "Nambiar, Amritha",
        "email": "amritha.nambiar@intel.com"
    },
    "delegate": {
        "id": 68,
        "url": "http://patchwork.ozlabs.org/api/users/68/?format=api",
        "username": "jtkirshe",
        "first_name": "Jeff",
        "last_name": "Kirsher",
        "email": "jeffrey.t.kirsher@intel.com"
    },
    "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/150478203291.24662.3361290802097939640.stgit@anamdev.jf.intel.com/mbox/",
    "series": [
        {
            "id": 1979,
            "url": "http://patchwork.ozlabs.org/api/series/1979/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=1979",
            "date": "2017-09-07T11:00:01",
            "name": "Configuring traffic classes via new hardware offload mechanism in tc/mqprio",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/1979/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/810972/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/810972/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@osuosl.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@bilbo.ozlabs.org",
            "intel-wired-lan@lists.osuosl.org"
        ],
        "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.133; helo=hemlock.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xnyFd0w0mz9s7C\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 21:01:57 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id ACDF389A61;\n\tThu,  7 Sep 2017 11:01:55 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id AvTfbIo8iozd; Thu,  7 Sep 2017 11:01:54 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id D41CF89BEA;\n\tThu,  7 Sep 2017 11:01:54 +0000 (UTC)",
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\tby ash.osuosl.org (Postfix) with ESMTP id C2CAB1C2121\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:52 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id BB3E889612\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:52 +0000 (UTC)",
            "from hemlock.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id x9t4N7zBQCUZ for <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:51 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby hemlock.osuosl.org (Postfix) with ESMTPS id 9455589514\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:51 +0000 (UTC)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Sep 2017 04:01:37 -0700",
            "from anamdev.jf.intel.com ([10.166.29.110])\n\tby orsmga004.jf.intel.com with ESMTP; 07 Sep 2017 04:01:37 -0700"
        ],
        "X-Virus-Scanned": [
            "amavisd-new at osuosl.org",
            "amavisd-new at osuosl.org"
        ],
        "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.42,357,1500966000\"; d=\"scan'208\";a=\"126453236\"",
        "From": "Amritha Nambiar <amritha.nambiar@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com",
        "Date": "Thu, 07 Sep 2017 04:00:32 -0700",
        "Message-ID": "<150478203291.24662.3361290802097939640.stgit@anamdev.jf.intel.com>",
        "In-Reply-To": "<150478158684.24662.17975701233699487888.stgit@anamdev.jf.intel.com>",
        "References": "<150478158684.24662.17975701233699487888.stgit@anamdev.jf.intel.com>",
        "User-Agent": "StGit/0.17.1-dirty",
        "MIME-Version": "1.0",
        "Cc": "netdev@vger.kernel.org",
        "Subject": "[Intel-wired-lan] [RFC PATCH v3 6/6] i40e: Add support setting TC\n\tmax bandwidth rates",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.18-1",
        "Precedence": "list",
        "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>",
        "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>",
        "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>"
    },
    "content": "This patch enables setting up maximum Tx rates for the traffic\nclasses in i40e. The maximum rate is offloaded to the hardware through\nthe mqprio framework by specifying the mode option as 'channel' and\nshaper option as 'bw_rlimit' and is configured for the VSI. Configuring\nminimum Tx rate limit is not supported in the device. The minimum\nusable value for Tx rate is 50Mbps.\n\nExample:\n# tc qdisc add dev eth0 root mqprio num_tc 2  map 0 0 0 0 1 1 1 1\\\n  queues 4@0 4@4 hw 1 mode channel shaper bw_rlimit\\\n  max_rate 4Gbit 5Gbit\n\nTo dump the bandwidth rates:\n# tc qdisc show dev eth0\n\nqdisc mqprio 804a: root  tc 2 map 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0\n             queues:(0:3) (4:7)\n             mode:channel\n             shaper:bw_rlimit   max_rate:4Gbit 5Gbit\n\nSigned-off-by: Amritha Nambiar <amritha.nambiar@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e.h      |    2 +\n drivers/net/ethernet/intel/i40e/i40e_main.c |  101 +++++++++++++++++++++++++--\n 2 files changed, 94 insertions(+), 9 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex 2ee0197..02cae34 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -359,6 +359,8 @@ struct i40e_channel {\n \tu8 enabled_tc;\n \tstruct i40e_aqc_vsi_properties_data info;\n \n+\tu64 max_tx_rate;\n+\n \t/* track this channel belongs to which VSI */\n \tstruct i40e_vsi *parent_vsi;\n };\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 7f13bc7..14a177b 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -5202,9 +5202,16 @@ static int i40e_vsi_configure_bw_alloc(struct i40e_vsi *vsi, u8 enabled_tc,\n \ti40e_status ret;\n \tint i;\n \n-\tif ((vsi->back->flags & I40E_FLAG_TC_MQPRIO) ||\n-\t    !vsi->mqprio_qopt.qopt.hw)\n+\tif (vsi->back->flags & I40E_FLAG_TC_MQPRIO)\n \t\treturn 0;\n+\tif (!vsi->mqprio_qopt.qopt.hw) {\n+\t\tret = i40e_set_bw_limit(vsi, vsi->seid, 0);\n+\t\tif (ret)\n+\t\t\tdev_info(&vsi->back->pdev->dev,\n+\t\t\t\t \"Failed to reset tx rate for vsi->seid %u\\n\",\n+\t\t\t\t vsi->seid);\n+\t\treturn ret;\n+\t}\n \tbw_data.tc_valid_bits = enabled_tc;\n \tfor (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++)\n \t\tbw_data.tc_bw_credits[i] = bw_share[i];\n@@ -5511,6 +5518,13 @@ static void i40e_remove_queue_channels(struct i40e_vsi *vsi)\n \t\t\trx_ring->ch = NULL;\n \t\t}\n \n+\t\t/* Reset BW configured for this VSI via mqprio */\n+\t\tret = i40e_set_bw_limit(vsi, ch->seid, 0);\n+\t\tif (ret)\n+\t\t\tdev_info(&vsi->back->pdev->dev,\n+\t\t\t\t \"Failed to reset tx rate for ch->seid %u\\n\",\n+\t\t\t\t ch->seid);\n+\n \t\t/* delete VSI from FW */\n \t\tret = i40e_aq_delete_element(&vsi->back->hw, ch->seid,\n \t\t\t\t\t     NULL);\n@@ -6053,6 +6067,17 @@ int i40e_create_queue_channel(struct i40e_vsi *vsi,\n \t\t \"Setup channel (id:%u) utilizing num_queues %d\\n\",\n \t\t ch->seid, ch->num_queue_pairs);\n \n+\t/* configure VSI for BW limit */\n+\tif (ch->max_tx_rate) {\n+\t\tif (i40e_set_bw_limit(vsi, ch->seid, ch->max_tx_rate))\n+\t\t\treturn -EINVAL;\n+\n+\t\tdev_dbg(&pf->pdev->dev,\n+\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\tch->max_tx_rate,\n+\t\t\tch->max_tx_rate / I40E_BW_CREDIT_DIVISOR, ch->seid);\n+\t}\n+\n \t/* in case of VF, this will be main SRIOV VSI */\n \tch->parent_vsi = vsi;\n \n@@ -6088,6 +6113,12 @@ static int i40e_configure_queue_channels(struct i40e_vsi *vsi)\n \t\t\tch->base_queue =\n \t\t\t\tvsi->tc_config.tc_info[i].qoffset;\n \n+\t\t\t/* Bandwidth limit through tc interface is in bytes/s,\n+\t\t\t * change to Mbit/s\n+\t\t\t */\n+\t\t\tch->max_tx_rate =\n+\t\t\t\tvsi->mqprio_qopt.max_rate[i] / (1000000 / 8);\n+\n \t\t\tlist_add_tail(&ch->list, &vsi->ch_list);\n \n \t\t\tret = i40e_create_queue_channel(vsi, ch);\n@@ -6514,6 +6545,7 @@ void i40e_down(struct i40e_vsi *vsi)\n static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,\n \t\t\t\t     struct tc_mqprio_qopt_offload *mqprio_qopt)\n {\n+\tu64 sum_max_rate = 0;\n \tint i;\n \n \tif ((mqprio_qopt->qopt.offset[0] != 0) ||\n@@ -6523,8 +6555,13 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,\n \tfor (i = 0; ; i++) {\n \t\tif (!mqprio_qopt->qopt.count[i])\n \t\t\treturn -EINVAL;\n-\t\tif (mqprio_qopt->min_rate[i] || mqprio_qopt->max_rate[i])\n+\t\tif (mqprio_qopt->min_rate[i]) {\n+\t\t\tdev_err(&vsi->back->pdev->dev,\n+\t\t\t\t\"Invalid min tx rate (greater than 0) specified\\n\");\n \t\t\treturn -EINVAL;\n+\t\t}\n+\t\tsum_max_rate += (mqprio_qopt->max_rate[i] / (1000000 / 8));\n+\n \t\tif (i >= mqprio_qopt->qopt.num_tc - 1)\n \t\t\tbreak;\n \t\tif (mqprio_qopt->qopt.offset[i + 1] !=\n@@ -6535,6 +6572,11 @@ static int i40e_validate_mqprio_qopt(struct i40e_vsi *vsi,\n \t    (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) {\n \t\treturn -EINVAL;\n \t}\n+\tif (sum_max_rate > i40e_get_link_speed(vsi)) {\n+\t\tdev_err(&vsi->back->pdev->dev,\n+\t\t\t\"Invalid max tx rate specified\\n\");\n+\t\treturn -EINVAL;\n+\t}\n \treturn 0;\n }\n \n@@ -6661,6 +6703,21 @@ static int i40e_setup_tc(struct net_device *netdev, void *type_data)\n \t}\n \n \tif (pf->flags & I40E_FLAG_TC_MQPRIO) {\n+\t\tif (vsi->mqprio_qopt.max_rate[0]) {\n+\t\t\tu64 max_tx_rate = vsi->mqprio_qopt.max_rate[0] /\n+\t\t\t\t\t\t\t\t(1000000 / 8);\n+\t\t\tret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);\n+\t\t\tif (!ret) {\n+\t\t\t\tdev_dbg(&vsi->back->pdev->dev,\n+\t\t\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\t\t\tmax_tx_rate,\n+\t\t\t\t\tmax_tx_rate / I40E_BW_CREDIT_DIVISOR,\n+\t\t\t\t\tvsi->seid);\n+\t\t\t} else {\n+\t\t\t\tneed_reset = true;\n+\t\t\t\tgoto exit;\n+\t\t\t}\n+\t\t}\n \t\tret = i40e_configure_queue_channels(vsi);\n \t\tif (ret) {\n \t\t\tnetdev_info(netdev,\n@@ -8114,6 +8171,18 @@ static int i40e_rebuild_channels(struct i40e_vsi *vsi)\n \t\t\t\t vsi->uplink_seid);\n \t\t\treturn ret;\n \t\t}\n+\t\tif (ch->max_tx_rate) {\n+\t\t\tif (i40e_set_bw_limit(vsi, ch->seid,\n+\t\t\t\t\t      ch->max_tx_rate))\n+\t\t\t\treturn -EINVAL;\n+\n+\t\t\tdev_dbg(&vsi->back->pdev->dev,\n+\t\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\t\tch->max_tx_rate,\n+\t\t\t\tch->max_tx_rate /\n+\t\t\t\t\t\tI40E_BW_CREDIT_DIVISOR,\n+\t\t\t\tch->seid);\n+\t\t}\n \t}\n \treturn 0;\n }\n@@ -8254,6 +8323,7 @@ static int i40e_reset(struct i40e_pf *pf)\n  **/\n static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)\n {\n+\tstruct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];\n \tstruct i40e_hw *hw = &pf->hw;\n \tu8 set_fc_aq_fail = 0;\n \ti40e_status ret;\n@@ -8336,7 +8406,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)\n \t * If there were VEBs but the reconstitution failed, we'll try\n \t * try to recover minimal use by getting the basic PF VSI working.\n \t */\n-\tif (pf->vsi[pf->lan_vsi]->uplink_seid != pf->mac_seid) {\n+\tif (vsi->uplink_seid != pf->mac_seid) {\n \t\tdev_dbg(&pf->pdev->dev, \"attempting to rebuild switch\\n\");\n \t\t/* find the one VEB connected to the MAC, and find orphans */\n \t\tfor (v = 0; v < I40E_MAX_VEB; v++) {\n@@ -8360,8 +8430,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)\n \t\t\t\t\tdev_info(&pf->pdev->dev,\n \t\t\t\t\t\t \"rebuild of switch failed: %d, will try to set up simple PF connection\\n\",\n \t\t\t\t\t\t ret);\n-\t\t\t\t\tpf->vsi[pf->lan_vsi]->uplink_seid\n-\t\t\t\t\t\t\t\t= pf->mac_seid;\n+\t\t\t\t\tvsi->uplink_seid = pf->mac_seid;\n \t\t\t\t\tbreak;\n \t\t\t\t} else if (pf->veb[v]->uplink_seid == 0) {\n \t\t\t\t\tdev_info(&pf->pdev->dev,\n@@ -8372,10 +8441,10 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)\n \t\t}\n \t}\n \n-\tif (pf->vsi[pf->lan_vsi]->uplink_seid == pf->mac_seid) {\n+\tif (vsi->uplink_seid == pf->mac_seid) {\n \t\tdev_dbg(&pf->pdev->dev, \"attempting to rebuild PF VSI\\n\");\n \t\t/* no VEB, so rebuild only the Main VSI */\n-\t\tret = i40e_add_vsi(pf->vsi[pf->lan_vsi]);\n+\t\tret = i40e_add_vsi(vsi);\n \t\tif (ret) {\n \t\t\tdev_info(&pf->pdev->dev,\n \t\t\t\t \"rebuild of Main VSI failed: %d\\n\", ret);\n@@ -8383,10 +8452,24 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)\n \t\t}\n \t}\n \n+\tif (vsi->mqprio_qopt.max_rate[0]) {\n+\t\tu64 max_tx_rate = vsi->mqprio_qopt.max_rate[0] / (1000000 / 8);\n+\n+\t\tret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);\n+\t\tif (!ret)\n+\t\t\tdev_dbg(&vsi->back->pdev->dev,\n+\t\t\t\t\"Set tx rate of %llu Mbps (count of 50Mbps %llu) for vsi->seid %u\\n\",\n+\t\t\t\tmax_tx_rate,\n+\t\t\t\tmax_tx_rate / I40E_BW_CREDIT_DIVISOR,\n+\t\t\t\tvsi->seid);\n+\t\telse\n+\t\t\tgoto end_unlock;\n+\t}\n+\n \t/* PF Main VSI is rebuild by now, go ahead and rebuild channel VSIs\n \t * for this main VSI if they exist\n \t */\n-\tret = i40e_rebuild_channels(pf->vsi[pf->lan_vsi]);\n+\tret = i40e_rebuild_channels(vsi);\n \tif (ret)\n \t\tgoto end_unlock;\n \n",
    "prefixes": [
        "RFC",
        "v3",
        "6/6"
    ]
}