get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 661666,
    "url": "http://patchwork.ozlabs.org/api/patches/661666/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/1471905790-4222-4-git-send-email-sridhar.samudrala@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": "<1471905790-4222-4-git-send-email-sridhar.samudrala@intel.com>",
    "list_archive_url": null,
    "date": "2016-08-22T22:43:10",
    "name": "[dev-queue,v3,3/3] i40e: Introduce devlink interface.",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": false,
    "hash": "9aedb305003fd587324129259155763f1693de1a",
    "submitter": {
        "id": 65219,
        "url": "http://patchwork.ozlabs.org/api/people/65219/?format=api",
        "name": "Samudrala, Sridhar",
        "email": "sridhar.samudrala@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/1471905790-4222-4-git-send-email-sridhar.samudrala@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/661666/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/661666/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<intel-wired-lan-bounces@lists.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"
        ],
        "Received": [
            "from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 3sJ9K85rR6z9s8x\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 23 Aug 2016 09:49:32 +1000 (AEST)",
            "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 6236B89C25;\n\tMon, 22 Aug 2016 23:49:31 +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 xRL3F8XwCDuz; Mon, 22 Aug 2016 23:49:28 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id C447089D2C;\n\tMon, 22 Aug 2016 23:49:24 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id DE5941C2BE5\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 22 Aug 2016 23:49:21 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id D82563141F\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 22 Aug 2016 23:49:21 +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 flEF+kM8J62v for <intel-wired-lan@lists.osuosl.org>;\n\tMon, 22 Aug 2016 23:49:20 +0000 (UTC)",
            "from mga06.intel.com (mga06.intel.com [134.134.136.31])\n\tby silver.osuosl.org (Postfix) with ESMTPS id 235B23142A\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tMon, 22 Aug 2016 23:49:20 +0000 (UTC)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby orsmga104.jf.intel.com with ESMTP; 22 Aug 2016 16:49:20 -0700",
            "from unknown (HELO sri-mi-02.jf.intel.com) ([10.166.31.66])\n\tby fmsmga004.fm.intel.com with ESMTP; 22 Aug 2016 16:49:20 -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.28,562,1464678000\"; d=\"scan'208\";a=\"159588718\"",
        "From": "Sridhar Samudrala <sridhar.samudrala@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org, anjali.singhai@intel.com,\n\tjohn.r.fastabend@intel.com, amritha.nambiar@intel.com,\n\talexander.h.duyck@intel.com",
        "Date": "Tue, 23 Aug 2016 00:43:10 +0200",
        "Message-Id": "<1471905790-4222-4-git-send-email-sridhar.samudrala@intel.com>",
        "X-Mailer": "git-send-email 2.5.5",
        "In-Reply-To": "<1471905790-4222-1-git-send-email-sridhar.samudrala@intel.com>",
        "References": "<1471905790-4222-1-git-send-email-sridhar.samudrala@intel.com>",
        "Subject": "[Intel-wired-lan] [dev-queue PATCH v3 3/3] i40e: Introduce devlink\n\tinterface.",
        "X-BeenThere": "intel-wired-lan@lists.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.lists.osuosl.org>",
        "List-Unsubscribe": "<http://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>",
        "List-Post": "<mailto:intel-wired-lan@lists.osuosl.org>",
        "List-Help": "<mailto:intel-wired-lan-request@lists.osuosl.org?subject=help>",
        "List-Subscribe": "<http://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@lists.osuosl.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "intel-wired-lan-bounces@lists.osuosl.org",
        "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@lists.osuosl.org>"
    },
    "content": "Add initial devlink support to set/get the mode of SRIOV switch.\nBy default the switch mode is set to 'switchdev' as VF Port representors\nare created by default.\nThis patch allows the mode to be set to 'legacy' to disable creation of\nVF Port representor netdevs.\n\nWith smode support in iproute2 'devlink' utility, switch mode can be set\nand get via following commands.\n\n    # devlink dev smode pci/0000:05:00.0\n    mode: switchdev\n    # devlink dev set pci/0000:05:00.0 smode legacy\n    # devlink dev smode pci/0000:05:00.0\n    mode: legacy\n\nSigned-off-by: Sridhar Samudrala <sridhar.samudrala@intel.com>\n---\n drivers/net/ethernet/intel/Kconfig                 |  1 +\n drivers/net/ethernet/intel/i40e/i40e.h             |  3 +\n drivers/net/ethernet/intel/i40e/i40e_main.c        | 91 ++++++++++++++++++++--\n drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c |  6 +-\n 4 files changed, 91 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig\nindex c0e1743..2ede229 100644\n--- a/drivers/net/ethernet/intel/Kconfig\n+++ b/drivers/net/ethernet/intel/Kconfig\n@@ -215,6 +215,7 @@ config I40E\n \ttristate \"Intel(R) Ethernet Controller XL710 Family support\"\n \tselect PTP_1588_CLOCK\n \tdepends on PCI\n+\tdepends on MAY_USE_DEVLINK\n \t---help---\n \t  This driver supports Intel(R) Ethernet Controller XL710 Family of\n \t  devices.  For more information on how to identify your adapter, go\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h\nindex 13b1f75..6e211f2 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e.h\n+++ b/drivers/net/ethernet/intel/i40e/i40e.h\n@@ -53,6 +53,8 @@\n #include <linux/clocksource.h>\n #include <linux/net_tstamp.h>\n #include <linux/ptp_clock_kernel.h>\n+#include <net/devlink.h>\n+\n #include \"i40e_type.h\"\n #include \"i40e_prototype.h\"\n #ifdef I40E_FCOE\n@@ -442,6 +444,7 @@ struct i40e_pf {\n \tu32 ioremap_len;\n \tu32 fd_inv;\n \tu16 phy_led_val;\n+\tenum devlink_eswitch_mode eswitch_mode;\n };\n \n enum i40e_filter_state {\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c\nindex 45a1165..3027bb6 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_main.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c\n@@ -10703,6 +10703,68 @@ static void i40e_get_platform_mac_addr(struct pci_dev *pdev, struct i40e_pf *pf)\n }\n \n /**\n+ * i40e_devlink_eswitch_mode_get\n+ *\n+ * @devlink: pointer to devlink struct\n+ * @mode: sr-iov switch mode pointer\n+ *\n+ * Returns the switch mode of the associated PF in the @mode pointer.\n+ */\n+static int i40e_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode)\n+{\n+\tstruct i40e_pf *pf = devlink_priv(devlink);\n+\n+\t*mode = pf->eswitch_mode;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * i40e_devlink_eswitch_mode_set\n+ *\n+ * @devlink: pointer to devlink struct\n+ * @mode: sr-iov switch mode\n+ *\n+ * Set the switch mode of the associated PF.\n+ * Returns 0 on success and -EOPNOTSUPP on error.\n+ */\n+static int i40e_devlink_eswitch_mode_set(struct devlink *devlink, u16 mode)\n+{\n+\tstruct i40e_pf *pf = devlink_priv(devlink);\n+\tstruct i40e_vf *vf;\n+\tint i, err = 0;\n+\n+\tif (mode == pf->eswitch_mode)\n+\t\tgoto done;\n+\n+\tswitch (mode) {\n+\tcase DEVLINK_ESWITCH_MODE_LEGACY:\n+\t\tfor (i = 0; i < pf->num_alloc_vfs; i++) {\n+\t\t\tvf = &(pf->vf[i]);\n+\t\t\ti40e_free_vf_netdev(vf);\n+\t\t}\n+\t\tpf->eswitch_mode = mode;\n+\t\tbreak;\n+\tcase DEVLINK_ESWITCH_MODE_SWITCHDEV:\n+\t\tpf->eswitch_mode = mode;\n+\t\tfor (i = 0; i < pf->num_alloc_vfs; i++) {\n+\t\t\tvf = &(pf->vf[i]);\n+\t\t\ti40e_alloc_vf_netdev(vf, i);\n+\t\t}\n+\t\tbreak;\n+\tdefault:\n+\t\terr = -EOPNOTSUPP;\n+\t}\n+done:\n+\treturn err;\n+}\n+\n+static const struct devlink_ops i40e_devlink_ops = {\n+\t.eswitch_mode_get = i40e_devlink_eswitch_mode_get,\n+\t.eswitch_mode_set = i40e_devlink_eswitch_mode_set,\n+};\n+\n+/**\n  * i40e_probe - Device initialization routine\n  * @pdev: PCI device information struct\n  * @ent: entry in i40e_pci_tbl\n@@ -10719,6 +10781,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \tstruct i40e_pf *pf;\n \tstruct i40e_hw *hw;\n \tstatic u16 pfs_found;\n+\tstruct devlink *devlink;\n \tu16 wol_nvm_bits;\n \tu16 link_status;\n \tint err;\n@@ -10752,20 +10815,28 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)\n \tpci_enable_pcie_error_reporting(pdev);\n \tpci_set_master(pdev);\n \n+\tdevlink = devlink_alloc(&i40e_devlink_ops, sizeof(*pf));\n+\tif (!devlink) {\n+\t\tdev_err(&pdev->dev, \"devlink_alloc failed\\n\");\n+\t\terr = -ENOMEM;\n+\t\tgoto err_devlink_alloc;\n+\t}\n+\n \t/* Now that we have a PCI connection, we need to do the\n \t * low level device setup.  This is primarily setting up\n \t * the Admin Queue structures and then querying for the\n \t * device's current profile information.\n \t */\n-\tpf = kzalloc(sizeof(*pf), GFP_KERNEL);\n-\tif (!pf) {\n-\t\terr = -ENOMEM;\n-\t\tgoto err_pf_alloc;\n-\t}\n+\tpf = devlink_priv(devlink);\n \tpf->next_vsi = 0;\n \tpf->pdev = pdev;\n \tset_bit(__I40E_DOWN, &pf->state);\n \n+\tpf->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV;\n+\terr = devlink_register(devlink, &pdev->dev);\n+\tif (err)\n+\t\tgoto err_devlink_register;\n+\n \thw = &pf->hw;\n \thw->back = pf;\n \n@@ -11236,8 +11307,10 @@ err_adminq_setup:\n err_pf_reset:\n \tiounmap(hw->hw_addr);\n err_ioremap:\n-\tkfree(pf);\n-err_pf_alloc:\n+\tdevlink_unregister(devlink);\n+err_devlink_register:\n+\tdevlink_free(devlink);\n+err_devlink_alloc:\n \tpci_disable_pcie_error_reporting(pdev);\n \tpci_release_mem_regions(pdev);\n err_pci_reg:\n@@ -11259,6 +11332,7 @@ static void i40e_remove(struct pci_dev *pdev)\n {\n \tstruct i40e_pf *pf = pci_get_drvdata(pdev);\n \tstruct i40e_hw *hw = &pf->hw;\n+\tstruct devlink *devlink = priv_to_devlink(pf);\n \ti40e_status ret_code;\n \tint i;\n \n@@ -11349,7 +11423,8 @@ static void i40e_remove(struct pci_dev *pdev)\n \tkfree(pf->vsi);\n \n \tiounmap(hw->hw_addr);\n-\tkfree(pf);\n+\tdevlink_unregister(devlink);\n+\tdevlink_free(devlink);\n \tpci_release_mem_regions(pdev);\n \n \tpci_disable_pcie_error_reporting(pdev);\ndiff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\nindex b5a716e..4551c84 100644\n--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c\n@@ -1131,7 +1131,8 @@ void i40e_free_vfs(struct i40e_pf *pf)\n \t\t/* disable qp mappings */\n \t\ti40e_disable_vf_mappings(&pf->vf[i]);\n \n-\t\ti40e_free_vf_netdev(&pf->vf[i]);\n+\t\tif (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV)\n+\t\t\ti40e_free_vf_netdev(&pf->vf[i]);\n \t}\n \n \tkfree(pf->vf);\n@@ -1199,7 +1200,8 @@ int i40e_alloc_vfs(struct i40e_pf *pf, u16 num_alloc_vfs)\n \t\t/* VF resources get allocated during reset */\n \t\ti40e_reset_vf(&vfs[i], false);\n \n-\t\ti40e_alloc_vf_netdev(&vfs[i], i);\n+\t\tif (pf->eswitch_mode == DEVLINK_ESWITCH_MODE_SWITCHDEV)\n+\t\t\ti40e_alloc_vf_netdev(&vfs[i], i);\n \n \t}\n \tpf->num_alloc_vfs = num_alloc_vfs;\n",
    "prefixes": [
        "dev-queue",
        "v3",
        "3/3"
    ]
}