get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 810971,
    "url": "http://patchwork.ozlabs.org/api/patches/810971/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/150478202784.24662.17062791162973773248.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": "<150478202784.24662.17062791162973773248.stgit@anamdev.jf.intel.com>",
    "list_archive_url": null,
    "date": "2017-09-07T11:00:27",
    "name": "[RFC,v3,5/6] i40e: Refactor VF BW rate limiting",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "2016bae7389d0a3ec6d3cc0a612eba9e9cb21057",
    "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/150478202784.24662.17062791162973773248.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/810971/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/810971/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.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 3xnyFZ6brrz9s9Y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu,  7 Sep 2017 21:01:54 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 730322F91C;\n\tThu,  7 Sep 2017 11:01:53 +0000 (UTC)",
            "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 6CpzJGYLbJS1; Thu,  7 Sep 2017 11:01:52 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 6C2DF2F807;\n\tThu,  7 Sep 2017 11:01:52 +0000 (UTC)",
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n\tby ash.osuosl.org (Postfix) with ESMTP id 6C4A11C2121\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:51 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 65E8C8893C\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:51 +0000 (UTC)",
            "from whitealder.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id IObaEREMVZGs for <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:50 +0000 (UTC)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby whitealder.osuosl.org (Postfix) with ESMTPS id B61D38854F\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu,  7 Sep 2017 11:01:50 +0000 (UTC)",
            "from orsmga005.jf.intel.com ([10.7.209.41])\n\tby orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t07 Sep 2017 04:01:32 -0700",
            "from anamdev.jf.intel.com ([10.166.29.110])\n\tby orsmga005.jf.intel.com with ESMTP; 07 Sep 2017 04:01:32 -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=\"146520891\"",
        "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:27 -0700",
        "Message-ID": "<150478202784.24662.17062791162973773248.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 5/6] i40e: Refactor VF BW rate\n\tlimiting",
        "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 refactors the BW rate limiting for Tx traffic\non the VF to be reused in the next patch for rate limiting Tx\ntraffic for the VSIs on the PF as well.\n\nv3: Minor fixes, clean up log messages based on Shannon's comments.\n\nSigned-off-by: Amritha Nambiar <amritha.nambiar@intel.com>\n---\n drivers/net/ethernet/intel/i40e/i40e.h             |    5 ++\n drivers/net/ethernet/intel/i40e/i40e_main.c        |   64 ++++++++++++++++++++\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |   45 +-------------\n 3 files changed, 71 insertions(+), 43 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex ddb7292..2ee0197 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -128,6 +128,10 @@\n /* default to trying for four seconds */\n #define I40E_TRY_LINK_TIMEOUT\t(4 * HZ)\n \n+/* BW rate limiting */\n+#define I40E_BW_CREDIT_DIVISOR\t\t50 /* 50Mbps per BW credit */\n+#define I40E_MAX_BW_INACTIVE_ACCUM\t4  /* accumulate 4 credits max */\n+\n /* driver state flags */\n enum i40e_state_t {\n \t__I40E_TESTING,\n@@ -1042,4 +1046,5 @@ static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)\n }\n \n int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch);\n+int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate);\n #endif /* _I40E_H_ */\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex a953c2e..7f13bc7 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -5406,6 +5406,70 @@ static int i40e_vsi_config_tc(struct i40e_vsi *vsi, u8 enabled_tc)\n }\n \n /**\n+ * i40e_get_link_speed - Returns link speed for the interface\n+ * @vsi: VSI to be configured\n+ *\n+ **/\n+int i40e_get_link_speed(struct i40e_vsi *vsi)\n+{\n+\tstruct i40e_pf *pf = vsi->back;\n+\n+\tswitch (pf->hw.phy.link_info.link_speed) {\n+\tcase I40E_LINK_SPEED_40GB:\n+\t\treturn 40000;\n+\tcase I40E_LINK_SPEED_25GB:\n+\t\treturn 25000;\n+\tcase I40E_LINK_SPEED_20GB:\n+\t\treturn 20000;\n+\tcase I40E_LINK_SPEED_10GB:\n+\t\treturn 10000;\n+\tcase I40E_LINK_SPEED_1GB:\n+\t\treturn 1000;\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n+}\n+\n+/**\n+ * i40e_set_bw_limit - setup BW limit for Tx traffic based on max_tx_rate\n+ * @vsi: VSI to be configured\n+ * @seid: seid of the channel/VSI\n+ * @max_tx_rate: max TX rate to be configured as BW limit\n+ *\n+ * Helper function to set BW limit for a given VSI\n+ **/\n+int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)\n+{\n+\tstruct i40e_pf *pf = vsi->back;\n+\tint speed = 0;\n+\tint ret = 0;\n+\n+\tspeed = i40e_get_link_speed(vsi);\n+\tif (max_tx_rate > speed) {\n+\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\"Invalid max tx rate %llu specified for VSI seid %d.\",\n+\t\t\tmax_tx_rate, seid);\n+\t\treturn -EINVAL;\n+\t}\n+\tif (max_tx_rate && max_tx_rate < 50) {\n+\t\tdev_warn(&pf->pdev->dev,\n+\t\t\t \"Setting max tx rate to minimum usable value of 50Mbps.\\n\");\n+\t\tmax_tx_rate = 50;\n+\t}\n+\n+\t/* Tx rate credits are in values of 50Mbps, 0 is disabled */\n+\tret = i40e_aq_config_vsi_bw_limit(&pf->hw, seid,\n+\t\t\t\t\t  max_tx_rate / I40E_BW_CREDIT_DIVISOR,\n+\t\t\t\t\t  I40E_MAX_BW_INACTIVE_ACCUM, NULL);\n+\tif (ret)\n+\t\tdev_err(&pf->pdev->dev,\n+\t\t\t\"Failed set tx rate (%llu Mbps) for vsi->seid %u, err %s aq_err %s\\n\",\n+\t\t\tmax_tx_rate, seid, i40e_stat_str(&pf->hw, ret),\n+\t\t\ti40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));\n+\treturn ret;\n+}\n+\n+/**\n  * i40e_remove_queue_channels - Remove queue channels for the TCs\n  * @vsi: VSI to be configured\n  *\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex ac88d96..06b2548 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -3115,8 +3115,6 @@ int i40e_ndo_set_vf_port_vlan(struct net_device *netdev, int vf_id,\n \treturn ret;\n }\n \n-#define I40E_BW_CREDIT_DIVISOR 50     /* 50Mbps per BW credit */\n-#define I40E_MAX_BW_INACTIVE_ACCUM 4  /* device can accumulate 4 credits max */\n /**\n  * i40e_ndo_set_vf_bw\n  * @netdev: network interface device structure\n@@ -3132,7 +3130,6 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,\n \tstruct i40e_pf *pf = np->vsi->back;\n \tstruct i40e_vsi *vsi;\n \tstruct i40e_vf *vf;\n-\tint speed = 0;\n \tint ret = 0;\n \n \t/* validate the request */\n@@ -3157,48 +3154,10 @@ int i40e_ndo_set_vf_bw(struct net_device *netdev, int vf_id, int min_tx_rate,\n \t\tgoto error;\n \t}\n \n-\tswitch (pf->hw.phy.link_info.link_speed) {\n-\tcase I40E_LINK_SPEED_40GB:\n-\t\tspeed = 40000;\n-\t\tbreak;\n-\tcase I40E_LINK_SPEED_25GB:\n-\t\tspeed = 25000;\n-\t\tbreak;\n-\tcase I40E_LINK_SPEED_20GB:\n-\t\tspeed = 20000;\n-\t\tbreak;\n-\tcase I40E_LINK_SPEED_10GB:\n-\t\tspeed = 10000;\n-\t\tbreak;\n-\tcase I40E_LINK_SPEED_1GB:\n-\t\tspeed = 1000;\n-\t\tbreak;\n-\tdefault:\n-\t\tbreak;\n-\t}\n-\n-\tif (max_tx_rate > speed) {\n-\t\tdev_err(&pf->pdev->dev, \"Invalid max tx rate %d specified for VF %d.\\n\",\n-\t\t\tmax_tx_rate, vf->vf_id);\n-\t\tret = -EINVAL;\n+\tret = i40e_set_bw_limit(vsi, vsi->seid, max_tx_rate);\n+\tif (ret)\n \t\tgoto error;\n-\t}\n \n-\tif ((max_tx_rate < 50) && (max_tx_rate > 0)) {\n-\t\tdev_warn(&pf->pdev->dev, \"Setting max Tx rate to minimum usable value of 50Mbps.\\n\");\n-\t\tmax_tx_rate = 50;\n-\t}\n-\n-\t/* Tx rate credits are in values of 50Mbps, 0 is disabled*/\n-\tret = i40e_aq_config_vsi_bw_limit(&pf->hw, vsi->seid,\n-\t\t\t\t\t  max_tx_rate / I40E_BW_CREDIT_DIVISOR,\n-\t\t\t\t\t  I40E_MAX_BW_INACTIVE_ACCUM, NULL);\n-\tif (ret) {\n-\t\tdev_err(&pf->pdev->dev, \"Unable to set max tx rate, error code %d.\\n\",\n-\t\t\tret);\n-\t\tret = -EIO;\n-\t\tgoto error;\n-\t}\n \tvf->tx_rate = max_tx_rate;\n error:\n \treturn ret;\n",
    "prefixes": [
        "RFC",
        "v3",
        "5/6"
    ]
}