get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 1016226,
    "url": "http://patchwork.ozlabs.org/api/patches/1016226/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20181219180334.1104-7-anirudh.venkataramanan@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": "<20181219180334.1104-7-anirudh.venkataramanan@intel.com>",
    "list_archive_url": null,
    "date": "2018-12-19T18:03:25",
    "name": "[S10,06/15] ice: Set physical link up/down when an interface is set up/down",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "30e4363c94dabe111b7a1da5b908f64e7217c83c",
    "submitter": {
        "id": 73601,
        "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api",
        "name": "Anirudh Venkataramanan",
        "email": "anirudh.venkataramanan@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/20181219180334.1104-7-anirudh.venkataramanan@intel.com/mbox/",
    "series": [
        {
            "id": 82906,
            "url": "http://patchwork.ozlabs.org/api/series/82906/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=82906",
            "date": "2018-12-19T18:03:28",
            "name": "Feature updates for ice",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/82906/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1016226/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1016226/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>)",
            "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com"
        ],
        "Received": [
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\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 43KjSQ5NLbz9sCQ\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 20 Dec 2018 05:03:50 +1100 (AEDT)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 5739D22049;\n\tWed, 19 Dec 2018 18:03:49 +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 Ua6m+4sDpCAT; Wed, 19 Dec 2018 18:03:46 +0000 (UTC)",
            "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 3072423236;\n\tWed, 19 Dec 2018 18:03:46 +0000 (UTC)",
            "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 5D6EC1C2A9B\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:40 +0000 (UTC)",
            "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 5B30F22049\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:40 +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 dsGLbp0xUgPA for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:36 +0000 (UTC)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby silver.osuosl.org (Postfix) with ESMTPS id CB51D22E77\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 19 Dec 2018 18:03:36 +0000 (UTC)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t19 Dec 2018 10:03:35 -0800",
            "from shasta.jf.intel.com ([10.166.241.11])\n\tby fmsmga002.fm.intel.com with ESMTP; 19 Dec 2018 10:03:35 -0800"
        ],
        "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.56,373,1539673200\"; d=\"scan'208\";a=\"127400076\"",
        "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>",
        "To": "intel-wired-lan@lists.osuosl.org",
        "Date": "Wed, 19 Dec 2018 10:03:25 -0800",
        "Message-Id": "<20181219180334.1104-7-anirudh.venkataramanan@intel.com>",
        "X-Mailer": "git-send-email 2.14.5",
        "In-Reply-To": "<20181219180334.1104-1-anirudh.venkataramanan@intel.com>",
        "References": "<20181219180334.1104-1-anirudh.venkataramanan@intel.com>",
        "Subject": "[Intel-wired-lan] [PATCH S10 06/15] ice: Set physical link up/down\n\twhen an interface is set up/down",
        "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>",
        "MIME-Version": "1.0",
        "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": "From: Brett Creeley <brett.creeley@intel.com>\n\nWhen a netdev is set up/down we need to set the phsyical link state\naccordingly. This patch adds that functionality by calling\nice_force_phys_link_state(vsi, link_up) in both the ice_stop() and\nice_open() paths.\n\nIn order to force link, ice_force_phys_link_state(vsi, link_up) will\nfirst determine the current phy capabilities. If link has not changed\nthere is nothing to do. If link has changed, previous PHY capabilities\nare saved and the \"Enable Automatic Link Update\" and \"Link Establishment\nState Machine (LESM)\" enable bits are set. Then the new PHY config is\nsaved. The \"Enable Automatic Link Update\" will force the FW to execute\nSetup link and restart auto-negotiation. This *should* then result in a\n\"Link Status Event (LSE)\" which will cause the driver to get the current\nlink status.\n\nSigned-off-by: Brett Creeley <brett.creeley@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n drivers/net/ethernet/intel/ice/ice_adminq_cmd.h |  4 +-\n drivers/net/ethernet/intel/ice/ice_main.c       | 97 ++++++++++++++++++++++++-\n 2 files changed, 96 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\nindex 245068b21982..526224ede3fa 100644\n--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n@@ -851,7 +851,7 @@ struct ice_aqc_get_phy_caps {\n \n struct ice_aqc_get_phy_caps_data {\n \t__le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */\n-\t__le64 reserved;\n+\t__le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */\n \tu8 caps;\n #define ICE_AQC_PHY_EN_TX_LINK_PAUSE\t\t\tBIT(0)\n #define ICE_AQC_PHY_EN_RX_LINK_PAUSE\t\t\tBIT(1)\n@@ -916,7 +916,7 @@ struct ice_aqc_set_phy_cfg {\n /* Set PHY config command data structure */\n struct ice_aqc_set_phy_cfg_data {\n \t__le64 phy_type_low; /* Use values from ICE_PHY_TYPE_LOW_* */\n-\t__le64 rsvd0;\n+\t__le64 phy_type_high; /* Use values from ICE_PHY_TYPE_HIGH_* */\n \tu8 caps;\n #define ICE_AQ_PHY_ENA_TX_PAUSE_ABILITY\t\tBIT(0)\n #define ICE_AQ_PHY_ENA_RX_PAUSE_ABILITY\t\tBIT(1)\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 90773b477d19..6434deec359d 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -2944,13 +2944,92 @@ static void ice_napi_disable_all(struct ice_vsi *vsi)\n \t}\n }\n \n+/**\n+ * ice_force_phys_link_state - Force the physical link state\n+ * @vsi: vsi to force the physical link state to up/down\n+ * @link_up: true/false indicates to set the physical link to up/down\n+ *\n+ * Force the physical link state by getting the current phy capabilities from\n+ * hardware and setting the phy config based on the determined capabilities. If\n+ * link changes a link event will be triggered because both the Enable Automatic\n+ * Link Update and LESM Enable bits are set when setting the PHY capabilities.\n+ *\n+ * Returns 0 on succcess, negative on failure\n+ */\n+static int ice_force_phys_link_state(struct ice_vsi *vsi, bool link_up)\n+{\n+\tstruct ice_aqc_get_phy_caps_data *pcaps;\n+\tstruct ice_aqc_set_phy_cfg_data *cfg;\n+\tstruct ice_port_info *pi;\n+\tstruct device *dev;\n+\tint retcode;\n+\n+\tif (!vsi || !vsi->port_info || !vsi->back)\n+\t\treturn -EINVAL;\n+\tif (vsi->type != ICE_VSI_PF)\n+\t\treturn 0;\n+\n+\tdev = &vsi->back->pdev->dev;\n+\n+\tpi = vsi->port_info;\n+\n+\tpcaps = devm_kzalloc(dev, sizeof(*pcaps), GFP_KERNEL);\n+\tif (!pcaps)\n+\t\treturn -ENOMEM;\n+\n+\tretcode = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG, pcaps,\n+\t\t\t\t      NULL);\n+\tif (retcode) {\n+\t\tdev_err(dev,\n+\t\t\t\"Failed to get phy capabilities, VSI %d error %d\\n\",\n+\t\t\tvsi->vsi_num, retcode);\n+\t\tretcode = -EIO;\n+\t\tgoto out;\n+\t}\n+\n+\t/* No change in link */\n+\tif (link_up == !!(pcaps->caps & ICE_AQC_PHY_EN_LINK) &&\n+\t    link_up == !!(pi->phy.link_info.link_info & ICE_AQ_LINK_UP))\n+\t\tgoto out;\n+\n+\tcfg = devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL);\n+\tif (!cfg) {\n+\t\tretcode = -ENOMEM;\n+\t\tgoto out;\n+\t}\n+\n+\tcfg->phy_type_low = pcaps->phy_type_low;\n+\tcfg->phy_type_high = pcaps->phy_type_high;\n+\tcfg->caps = pcaps->caps | ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n+\tcfg->low_power_ctrl = pcaps->low_power_ctrl;\n+\tcfg->eee_cap = pcaps->eee_cap;\n+\tcfg->eeer_value = pcaps->eeer_value;\n+\tcfg->link_fec_opt = pcaps->link_fec_options;\n+\tif (link_up)\n+\t\tcfg->caps |= ICE_AQ_PHY_ENA_LINK;\n+\telse\n+\t\tcfg->caps &= ~ICE_AQ_PHY_ENA_LINK;\n+\n+\tretcode = ice_aq_set_phy_cfg(&vsi->back->hw, pi->lport, cfg, NULL);\n+\tif (retcode) {\n+\t\tdev_err(dev, \"Failed to set phy config, VSI %d error %d\\n\",\n+\t\t\tvsi->vsi_num, retcode);\n+\t\tretcode = -EIO;\n+\t}\n+\n+\tdevm_kfree(dev, cfg);\n+out:\n+\tdevm_kfree(dev, pcaps);\n+\treturn retcode;\n+}\n+\n /**\n  * ice_down - Shutdown the connection\n  * @vsi: The VSI being stopped\n  */\n int ice_down(struct ice_vsi *vsi)\n {\n-\tint i, tx_err, rx_err;\n+\tint i, tx_err, rx_err, link_err;\n \n \t/* Caller of this function is expected to set the\n \t * vsi->state __ICE_DOWN bit\n@@ -2975,13 +3054,19 @@ int ice_down(struct ice_vsi *vsi)\n \n \tice_napi_disable_all(vsi);\n \n+\tlink_err = ice_force_phys_link_state(vsi, false);\n+\tif (link_err)\n+\t\tnetdev_err(vsi->netdev,\n+\t\t\t   \"Failed to set physical link down, VSI %d error %d\\n\",\n+\t\t\t   vsi->vsi_num, link_err);\n+\n \tice_for_each_txq(vsi, i)\n \t\tice_clean_tx_ring(vsi->tx_rings[i]);\n \n \tice_for_each_rxq(vsi, i)\n \t\tice_clean_rx_ring(vsi->rx_rings[i]);\n \n-\tif (tx_err || rx_err) {\n+\tif (tx_err || rx_err || link_err) {\n \t\tnetdev_err(vsi->netdev,\n \t\t\t   \"Failed to close VSI 0x%04X on switch 0x%04X\\n\",\n \t\t\t   vsi->vsi_num, vsi->vsw->sw_id);\n@@ -3815,8 +3900,14 @@ static int ice_open(struct net_device *netdev)\n \n \tnetif_carrier_off(netdev);\n \n-\terr = ice_vsi_open(vsi);\n+\terr = ice_force_phys_link_state(vsi, true);\n+\tif (err) {\n+\t\tnetdev_err(netdev,\n+\t\t\t   \"Failed to set physical link up, error %d\\n\", err);\n+\t\treturn err;\n+\t}\n \n+\terr = ice_vsi_open(vsi);\n \tif (err)\n \t\tnetdev_err(netdev, \"Failed to open VSI 0x%04X on switch 0x%04X\\n\",\n \t\t\t   vsi->vsi_num, vsi->vsw->sw_id);\n",
    "prefixes": [
        "S10",
        "06/15"
    ]
}