get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1253344,
    "url": "http://patchwork.ozlabs.org/api/patches/1253344/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20200312015818.1007882-7-jacob.e.keller@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": "<20200312015818.1007882-7-jacob.e.keller@intel.com>",
    "list_archive_url": null,
    "date": "2020-03-12T01:58:15",
    "name": "[v3,6/9] ice: enable initial devlink support",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "44c5986aebe2bb7f86d6c3f6547d4d4927f8817c",
    "submitter": {
        "id": 9784,
        "url": "http://patchwork.ozlabs.org/api/people/9784/?format=api",
        "name": "Jacob Keller",
        "email": "jacob.e.keller@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/20200312015818.1007882-7-jacob.e.keller@intel.com/mbox/",
    "series": [
        {
            "id": 163869,
            "url": "http://patchwork.ozlabs.org/api/series/163869/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=163869",
            "date": "2020-03-12T01:58:10",
            "name": "ice devlink support",
            "version": 3,
            "mbox": "http://patchwork.ozlabs.org/series/163869/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1253344/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1253344/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; spf=pass (sender SPF authorized)\n\tsmtp.mailfrom=osuosl.org (client-ip=140.211.166.133;\n\thelo=hemlock.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 48dBnP0sVbz9sQx\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 12 Mar 2020 12:58:33 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id A4A6388F7E;\n\tThu, 12 Mar 2020 01:58:31 +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 MDuXTppp9cGB; Thu, 12 Mar 2020 01:58:30 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 2796B88550;\n\tThu, 12 Mar 2020 01:58:30 +0000 (UTC)",
            "from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])\n\tby ash.osuosl.org (Postfix) with ESMTP id E90111BF473\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:24 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby fraxinus.osuosl.org (Postfix) with ESMTP id E65C886193\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:24 +0000 (UTC)",
            "from fraxinus.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id RwE4XBxbIAYu for <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:24 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby fraxinus.osuosl.org (Postfix) with ESMTPS id CEFA18625E\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tThu, 12 Mar 2020 01:58:23 +0000 (UTC)",
            "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t11 Mar 2020 18:58:22 -0700",
            "from jekeller-desk.amr.corp.intel.com ([10.166.241.33])\n\tby orsmga008.jf.intel.com with ESMTP; 11 Mar 2020 18:58:21 -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-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.70,543,1574150400\"; d=\"scan'208\";a=\"236656316\"",
        "From": "Jacob Keller <jacob.e.keller@intel.com>",
        "To": "Intel Wired LAN <intel-wired-lan@lists.osuosl.org>",
        "Date": "Wed, 11 Mar 2020 18:58:15 -0700",
        "Message-Id": "<20200312015818.1007882-7-jacob.e.keller@intel.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200312015818.1007882-1-jacob.e.keller@intel.com>",
        "References": "<20200312015818.1007882-1-jacob.e.keller@intel.com>",
        "MIME-Version": "1.0",
        "Subject": "[Intel-wired-lan] [PATCH v3 6/9] ice: enable initial devlink support",
        "X-BeenThere": "intel-wired-lan@osuosl.org",
        "X-Mailman-Version": "2.1.29",
        "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>",
        "Cc": "Jakub Kicinski <kuba@kernel.org>",
        "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": "Begin implementing support for the devlink interface with the ice\ndriver.\n\nThe pf structure is currently memory managed through devres, via\na devm_alloc. To mimic this behavior, after allocating the devlink\npointer, use devm_add_action to add a teardown action for releasing the\ndevlink memory on exit.\n\nThe ice hardware is a multi-function PCIe device. Thus, each physical\nfunction will get its own devlink instance. This means that each\nfunction will be treated independently, with its own parameters and\nconfiguration. This is done because the ice driver loads a separate\ninstance for each function.\n\nDue to this, the implementation does not enable devlink to manage\ndevice-wide resources or configuration, as each physical function will\nbe treated independently. This is done for simplicity, as managing\na devlink instance across multiple driver instances would significantly\nincrease the complexity for minimal gain.\n\nSigned-off-by: Jacob Keller <jacob.e.keller@intel.com>\nReviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>\n---\n drivers/net/ethernet/intel/Kconfig           |   1 +\n drivers/net/ethernet/intel/ice/Makefile      |   1 +\n drivers/net/ethernet/intel/ice/ice.h         |   4 +\n drivers/net/ethernet/intel/ice/ice_devlink.c | 117 +++++++++++++++++++\n drivers/net/ethernet/intel/ice/ice_devlink.h |  14 +++\n drivers/net/ethernet/intel/ice/ice_main.c    |  33 +++++-\n 6 files changed, 166 insertions(+), 4 deletions(-)\n create mode 100644 drivers/net/ethernet/intel/ice/ice_devlink.c\n create mode 100644 drivers/net/ethernet/intel/ice/ice_devlink.h",
    "diff": "diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig\nindex ced9d2650da4..b421c0c5fc8b 100644\n--- a/drivers/net/ethernet/intel/Kconfig\n+++ b/drivers/net/ethernet/intel/Kconfig\n@@ -296,6 +296,7 @@ config ICE\n \tdefault n\n \tdepends on PCI_MSI\n \tselect VIRTUAL_BUS\n+\tselect NET_DEVLINK\n \t---help---\n \t  This driver supports Intel(R) Ethernet Connection E800 Series of\n \t  devices.  For more information on how to identify your adapter, go\ndiff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile\nindex 85e2ba18cec2..41bfd5f21679 100644\n--- a/drivers/net/ethernet/intel/ice/Makefile\n+++ b/drivers/net/ethernet/intel/ice/Makefile\n@@ -20,6 +20,7 @@ ice-y := ice_main.o\t\\\n \t ice_flex_pipe.o \\\n \t ice_flow.o\t\\\n \t ice_idc.o\t\\\n+\t ice_devlink.o\t\\\n \t ice_ethtool.o\n ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o\n ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_nl.o ice_dcb_lib.o\ndiff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h\nindex f237df923ea1..288b6d08eb3f 100644\n--- a/drivers/net/ethernet/intel/ice/ice.h\n+++ b/drivers/net/ethernet/intel/ice/ice.h\n@@ -35,6 +35,7 @@\n #include <linux/bpf.h>\n #include <linux/virtual_bus.h>\n #include <linux/avf/virtchnl.h>\n+#include <net/devlink.h>\n #include <net/ipv6.h>\n #include <net/xdp_sock.h>\n #include <net/geneve.h>\n@@ -358,6 +359,9 @@ enum ice_pf_flags {\n struct ice_pf {\n \tstruct pci_dev *pdev;\n \n+\t/* devlink port data */\n+\tstruct devlink_port devlink_port;\n+\n \t/* OS reserved IRQ details */\n \tstruct msix_entry *msix_entries;\n \tstruct ice_res_tracker *irq_tracker;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_devlink.c b/drivers/net/ethernet/intel/ice/ice_devlink.c\nnew file mode 100644\nindex 000000000000..cedd9d02299e\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_devlink.c\n@@ -0,0 +1,117 @@\n+// SPDX-License-Identifier: GPL-2.0\n+/* Copyright (c) 2020, Intel Corporation. */\n+\n+#include \"ice.h\"\n+#include \"ice_devlink.h\"\n+\n+static const struct devlink_ops ice_devlink_ops = {\n+};\n+\n+static void ice_devlink_free(void *devlink_ptr)\n+{\n+\tdevlink_free((struct devlink *)devlink_ptr);\n+}\n+\n+/**\n+ * ice_allocate_pf - Allocate devlink and return PF structure pointer\n+ * @dev: the device to allocate for\n+ *\n+ * Allocate a devlink instance for this device and return the private area as\n+ * the PF structure. The devlink memory is kept track of through devres by\n+ * adding an action to remove it when unwinding.\n+ */\n+struct ice_pf *ice_allocate_pf(struct device *dev)\n+{\n+\tstruct devlink *devlink;\n+\n+\tdevlink = devlink_alloc(&ice_devlink_ops, sizeof(struct ice_pf));\n+\tif (!devlink)\n+\t\treturn NULL;\n+\n+\t/* Add an action to teardown the devlink when unwinding the driver */\n+\tif (devm_add_action(dev, ice_devlink_free, devlink)) {\n+\t\tdevlink_free(devlink);\n+\t\treturn NULL;\n+\t}\n+\n+\treturn devlink_priv(devlink);\n+}\n+\n+/**\n+ * ice_devlink_register - Register devlink interface for this PF\n+ * @pf: the PF to register the devlink for.\n+ *\n+ * Register the devlink instance associated with this physical function.\n+ *\n+ * Return: zero on success or an error code on failure.\n+ */\n+int ice_devlink_register(struct ice_pf *pf)\n+{\n+\tstruct devlink *devlink = priv_to_devlink(pf);\n+\tstruct device *dev = ice_pf_to_dev(pf);\n+\tint err;\n+\n+\terr = devlink_register(devlink, dev);\n+\tif (err) {\n+\t\tdev_err(dev, \"devlink registration failed: %d\\n\", err);\n+\t\treturn err;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_devlink_unregister - Unregister devlink resources for this PF.\n+ * @pf: the PF structure to cleanup\n+ *\n+ * Releases resources used by devlink and cleans up associated memory.\n+ */\n+void ice_devlink_unregister(struct ice_pf *pf)\n+{\n+\tdevlink_unregister(priv_to_devlink(pf));\n+}\n+\n+/**\n+ * ice_devlink_create_port - Create a devlink port for this PF\n+ * @pf: the PF to create a port for\n+ *\n+ * Create and register a devlink_port for this PF. Note that although each\n+ * physical function is connected to a separate devlink instance, the port\n+ * will still be numbered according to the physical function id.\n+ *\n+ * Return: zero on success or an error code on failure.\n+ */\n+int ice_devlink_create_port(struct ice_pf *pf)\n+{\n+\tstruct devlink *devlink = priv_to_devlink(pf);\n+\tstruct ice_vsi *vsi = ice_get_main_vsi(pf);\n+\tstruct device *dev = ice_pf_to_dev(pf);\n+\tint err;\n+\n+\tif (!vsi) {\n+\t\tdev_err(dev, \"%s: unable to find main VSI\\n\", __func__);\n+\t\treturn -EIO;\n+\t}\n+\n+\tdevlink_port_attrs_set(&pf->devlink_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,\n+\t\t\t       pf->hw.pf_id, false, 0, NULL, 0);\n+\terr = devlink_port_register(devlink, &pf->devlink_port, pf->hw.pf_id);\n+\tif (err) {\n+\t\tdev_err(dev, \"devlink_port_register failed: %d\\n\", err);\n+\t\treturn err;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * ice_devlink_destroy_port - Destroy the devlink_port for this PF\n+ * @pf: the PF to cleanup\n+ *\n+ * Unregisters the devlink_port structure associated with this PF.\n+ */\n+void ice_devlink_destroy_port(struct ice_pf *pf)\n+{\n+\tdevlink_port_type_clear(&pf->devlink_port);\n+\tdevlink_port_unregister(&pf->devlink_port);\n+}\ndiff --git a/drivers/net/ethernet/intel/ice/ice_devlink.h b/drivers/net/ethernet/intel/ice/ice_devlink.h\nnew file mode 100644\nindex 000000000000..f94dc93c24c5\n--- /dev/null\n+++ b/drivers/net/ethernet/intel/ice/ice_devlink.h\n@@ -0,0 +1,14 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+/* Copyright (c) 2019, Intel Corporation. */\n+\n+#ifndef _ICE_DEVLINK_H_\n+#define _ICE_DEVLINK_H_\n+\n+struct ice_pf *ice_allocate_pf(struct device *dev);\n+\n+int ice_devlink_register(struct ice_pf *pf);\n+void ice_devlink_unregister(struct ice_pf *pf);\n+int ice_devlink_create_port(struct ice_pf *pf);\n+void ice_devlink_destroy_port(struct ice_pf *pf);\n+\n+#endif /* _ICE_DEVLINK_H_ */\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 5e99b100fcb3..9003801d6944 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -10,6 +10,7 @@\n #include \"ice_lib.h\"\n #include \"ice_dcb_lib.h\"\n #include \"ice_dcb_nl.h\"\n+#include \"ice_devlink.h\"\n \n #define DRV_VERSION_MAJOR 0\n #define DRV_VERSION_MINOR 8\n@@ -2391,10 +2392,16 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)\n \tu8 mac_addr[ETH_ALEN];\n \tint err;\n \n+\terr = ice_devlink_create_port(pf);\n+\tif (err)\n+\t\treturn err;\n+\n \tnetdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq,\n \t\t\t\t    vsi->alloc_rxq);\n-\tif (!netdev)\n-\t\treturn -ENOMEM;\n+\tif (!netdev) {\n+\t\terr = -ENOMEM;\n+\t\tgoto err_destroy_devlink_port;\n+\t}\n \n \tvsi->netdev = netdev;\n \tnp = netdev_priv(netdev);\n@@ -2424,7 +2431,9 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)\n \n \terr = register_netdev(vsi->netdev);\n \tif (err)\n-\t\treturn err;\n+\t\tgoto err_destroy_devlink_port;\n+\n+\tdevlink_port_type_eth_set(&pf->devlink_port, vsi->netdev);\n \n \tnetif_carrier_off(vsi->netdev);\n \n@@ -2432,6 +2441,11 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)\n \tnetif_tx_stop_all_queues(vsi->netdev);\n \n \treturn 0;\n+\n+err_destroy_devlink_port:\n+\tice_devlink_destroy_port(pf);\n+\n+\treturn err;\n }\n \n /**\n@@ -3224,7 +3238,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)\n \t\treturn err;\n \t}\n \n-\tpf = devm_kzalloc(dev, sizeof(*pf), GFP_KERNEL);\n+\tpf = ice_allocate_pf(dev);\n \tif (!pf)\n \t\treturn -ENOMEM;\n \n@@ -3262,6 +3276,12 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)\n \n \tpf->msg_enable = netif_msg_init(debug, ICE_DFLT_NETIF_M);\n \n+\terr = ice_devlink_register(pf);\n+\tif (err) {\n+\t\tdev_err(dev, \"ice_devlink_register failed: %d\\n\", err);\n+\t\tgoto err_exit_unroll;\n+\t}\n+\n #ifndef CONFIG_DYNAMIC_DEBUG\n \tif (debug < -1)\n \t\thw->debug_mask = debug;\n@@ -3422,6 +3442,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)\n \t\t}\n \t}\n err_alloc_sw_unroll:\n+\tice_devlink_destroy_port(pf);\n \tset_bit(__ICE_SERVICE_DIS, pf->state);\n \tset_bit(__ICE_DOWN, pf->state);\n \tdevm_kfree(dev, pf->first_sw);\n@@ -3434,6 +3455,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)\n \tice_deinit_pf(pf);\n \tice_deinit_hw(hw);\n err_exit_unroll:\n+\tice_devlink_unregister(pf);\n \tpci_disable_pcie_error_reporting(pdev);\n \treturn err;\n }\n@@ -3469,6 +3491,7 @@ static void ice_remove(struct pci_dev *pdev)\n \t}\n \tset_bit(__ICE_DOWN, pf->state);\n \n+\tice_devlink_destroy_port(pf);\n \tice_vsi_release_all(pf);\n \tif (ice_is_peer_ena(pf)) {\n \t\tice_for_each_peer(pf, NULL, ice_unreg_peer_device);\n@@ -3482,6 +3505,8 @@ static void ice_remove(struct pci_dev *pdev)\n \t}\n \tice_deinit_pf(pf);\n \tice_deinit_hw(&pf->hw);\n+\tice_devlink_unregister(pf);\n+\n \t/* Issue a PFR as part of the prescribed driver unload flow.  Do not\n \t * do it via ice_schedule_reset() since there is no need to rebuild\n \t * and the service task is already stopped.\n",
    "prefixes": [
        "v3",
        "6/9"
    ]
}