Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/951919/?format=api
{ "id": 951919, "url": "http://patchwork.ozlabs.org/api/patches/951919/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20180801040433.5865-8-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": "<20180801040433.5865-8-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2018-08-01T04:04:27", "name": "[v2,07/13] ice: Implement handlers for ethtool PHY/link operations", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "dc2e13b7390c84527a7387f74a2d5736f0d37fe1", "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/20180801040433.5865-8-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 58674, "url": "http://patchwork.ozlabs.org/api/series/58674/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=58674", "date": "2018-08-01T04:04:20", "name": "Feature updates for ice", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/58674/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/951919/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/951919/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>)", "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 AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 41gKTD1lTKz9rxx\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 1 Aug 2018 14:05:04 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id CA32787F2C;\n\tWed, 1 Aug 2018 04:05:02 +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 a8kSICzAm3u9; Wed, 1 Aug 2018 04:04:54 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby hemlock.osuosl.org (Postfix) with ESMTP id 3E39787F2B;\n\tWed, 1 Aug 2018 04:04:54 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 43B781C0BBC\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:52 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 36CF725BF8\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:52 +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 cO1fLstQWGd5 for <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:49 +0000 (UTC)", "from mga12.intel.com (mga12.intel.com [192.55.52.136])\n\tby silver.osuosl.org (Postfix) with ESMTPS id DAA2825636\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tWed, 1 Aug 2018 04:04:49 +0000 (UTC)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t31 Jul 2018 21:04:49 -0700", "from lnahar-mobl.amr.corp.intel.com (HELO\n\tavenkata-mobl4.localdomain) ([10.252.134.1])\n\tby FMSMGA003.fm.intel.com with ESMTP; 31 Jul 2018 21:04:48 -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.51,430,1526367600\"; d=\"scan'208\";a=\"69105111\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 31 Jul 2018 21:04:27 -0700", "Message-Id": "<20180801040433.5865-8-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.17.1", "In-Reply-To": "<20180801040433.5865-1-anirudh.venkataramanan@intel.com>", "References": "<20180801040433.5865-1-anirudh.venkataramanan@intel.com>", "Subject": "[Intel-wired-lan] [PATCH v2 07/13] ice: Implement handlers for\n\tethtool PHY/link operations", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.24", "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: Chinh Cao <chinh.t.cao@intel.com>\n\nThis patch implements handlers for ethtool get_link_ksettings and\nset_link_ksettings. Helper functions use by these handlers are also\nintroduced in this patch.\n\nSigned-off-by: Chinh Cao <chinh.t.cao@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> cleaned up commit message]\n---\n .../net/ethernet/intel/ice/ice_adminq_cmd.h | 8 +-\n drivers/net/ethernet/intel/ice/ice_common.c | 120 ++-\n drivers/net/ethernet/intel/ice/ice_common.h | 14 +-\n drivers/net/ethernet/intel/ice/ice_ethtool.c | 805 +++++++++++++++++-\n 4 files changed, 894 insertions(+), 53 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 a49b890941ec..ce3405f870d8 100644\n--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n@@ -921,9 +921,11 @@ struct ice_aqc_set_phy_cfg_data {\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)\n-#define ICE_AQ_PHY_ENA_LOW_POWER\t\tBIT(2)\n-#define ICE_AQ_PHY_ENA_LINK\t\t\tBIT(3)\n-#define ICE_AQ_PHY_ENA_ATOMIC_LINK\t\tBIT(5)\n+#define ICE_AQ_PHY_ENA_LOW_POWER\tBIT(2)\n+#define ICE_AQ_PHY_ENA_LINK\t\tBIT(3)\n+#define ICE_AQ_PHY_ENA_AUTO_LINK_UPDT\tBIT(5)\n+#define ICE_AQ_PHY_ENA_LESM\t\tBIT(6)\n+#define ICE_AQ_PHY_ENA_AUTO_FEC\t\tBIT(7)\n \tu8 low_power_ctrl;\n \t__le16 eee_cap; /* Value from ice_aqc_get_phy_caps */\n \t__le16 eeer_value;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c\nindex 303403f4ffc6..ad7f450ddf85 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.c\n+++ b/drivers/net/ethernet/intel/ice/ice_common.c\n@@ -122,7 +122,7 @@ ice_aq_manage_mac_read(struct ice_hw *hw, void *buf, u16 buf_size,\n *\n * Returns the various PHY capabilities supported on the Port (0x0600)\n */\n-static enum ice_status\n+enum ice_status\n ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,\n \t\t struct ice_aqc_get_phy_caps_data *pcaps,\n \t\t struct ice_sq_cd *cd)\n@@ -1318,6 +1318,109 @@ void ice_clear_pxe_mode(struct ice_hw *hw)\n \t\tice_aq_clear_pxe_mode(hw);\n }\n \n+/**\n+ * ice_get_link_speed_based_on_phy_type - returns link speed\n+ * @phy_type_low : lower part of phy_type\n+ * This helper function will convert a phy_type_low to its corresponding link\n+ * speed.\n+ * Note : In the structure of phy_type_low, there should be one bit set, as\n+ * this function will convert one phy type to its speed.\n+ * If no bit gets set, ICE_LINK_SPEED_UNKNOWN will be returned\n+ * If more than one bit gets set, ICE_LINK_SPEED_UNKNOWN will be returned\n+ */\n+static u16\n+ice_get_link_speed_based_on_phy_type(u64 phy_type_low)\n+{\n+\tu16 speed_phy_type_low = ICE_AQ_LINK_SPEED_UNKNOWN;\n+\n+\tswitch (phy_type_low) {\n+\tcase ICE_PHY_TYPE_LOW_100BASE_TX:\n+\tcase ICE_PHY_TYPE_LOW_100M_SGMII:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_100MB;\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_T:\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_SX:\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_LX:\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_KX:\n+\tcase ICE_PHY_TYPE_LOW_1G_SGMII:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_1000MB;\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_2500BASE_T:\n+\tcase ICE_PHY_TYPE_LOW_2500BASE_X:\n+\tcase ICE_PHY_TYPE_LOW_2500BASE_KX:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_2500MB;\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_5GBASE_T:\n+\tcase ICE_PHY_TYPE_LOW_5GBASE_KR:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_5GB;\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_T:\n+\tcase ICE_PHY_TYPE_LOW_10G_SFI_DA:\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_SR:\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_LR:\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_KR_CR1:\n+\tcase ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC:\n+\tcase ICE_PHY_TYPE_LOW_10G_SFI_C2C:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_10GB;\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_T:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_CR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_CR_S:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_CR1:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_SR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_LR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_KR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_KR_S:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_KR1:\n+\tcase ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC:\n+\tcase ICE_PHY_TYPE_LOW_25G_AUI_C2C:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_25GB;\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_CR4:\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_SR4:\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_LR4:\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_KR4:\n+\tcase ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC:\n+\tcase ICE_PHY_TYPE_LOW_40G_XLAUI:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_40GB;\n+\t\tbreak;\n+\tdefault:\n+\t\tspeed_phy_type_low = ICE_AQ_LINK_SPEED_UNKNOWN;\n+\t\tbreak;\n+\t}\n+\n+\treturn speed_phy_type_low;\n+}\n+\n+/**\n+ * ice_update_phy_type\n+ * @phy_type_low : pointer to the lower part of phy_type\n+ * @link_speeds_bitmap : targeted link speeds bitmap\n+ *\n+ * Note : For the link_speeds_bitmap structure, you can check it at\n+ * [ice_aqc_get_link_status->link_speed]. Caller can pass in\n+ * link_speeds_bitmap include multiple speeds.\n+ *\n+ * The value of phy_type_low will present a certain link speed. This helper\n+ * function will turn on bits in the phy_type_low based on the value of\n+ * link_speeds_bitmap input parameter.\n+ */\n+void ice_update_phy_type(u64 *phy_type_low, u16 link_speeds_bitmap)\n+{\n+\tu16 speed = ICE_AQ_LINK_SPEED_UNKNOWN;\n+\tu64 pt_low;\n+\tint index;\n+\n+\t/* We first check with low part of phy_type */\n+\tfor (index = 0; index <= ICE_PHY_TYPE_LOW_MAX_INDEX; index++) {\n+\t\tpt_low = BIT_ULL(index);\n+\t\tspeed = ice_get_link_speed_based_on_phy_type(pt_low);\n+\n+\t\tif (link_speeds_bitmap & speed)\n+\t\t\t*phy_type_low |= BIT_ULL(index);\n+\t}\n+}\n+\n /**\n * ice_aq_set_phy_cfg\n * @hw: pointer to the hw struct\n@@ -1330,19 +1433,18 @@ void ice_clear_pxe_mode(struct ice_hw *hw)\n * mode as the PF may not have the privilege to set some of the PHY Config\n * parameters. This status will be indicated by the command response (0x0601).\n */\n-static enum ice_status\n+enum ice_status\n ice_aq_set_phy_cfg(struct ice_hw *hw, u8 lport,\n \t\t struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd)\n {\n-\tstruct ice_aqc_set_phy_cfg *cmd;\n \tstruct ice_aq_desc desc;\n \n \tif (!cfg)\n \t\treturn ICE_ERR_PARAM;\n \n-\tcmd = &desc.params.set_phy;\n \tice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_set_phy_cfg);\n-\tcmd->lport_num = lport;\n+\tdesc.params.set_phy.lport_num = lport;\n+\tdesc.flags |= cpu_to_le16(ICE_AQ_FLAG_RD);\n \n \treturn ice_aq_send_cmd(hw, &desc, cfg, sizeof(*cfg), cd);\n }\n@@ -1391,12 +1493,12 @@ ice_update_link_info(struct ice_port_info *pi)\n * ice_set_fc\n * @pi: port information structure\n * @aq_failures: pointer to status code, specific to ice_set_fc routine\n- * @atomic_restart: enable automatic link update\n+ * @ena_auto_link_update: enable automatic link update\n *\n * Set the requested flow control mode.\n */\n enum ice_status\n-ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool atomic_restart)\n+ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)\n {\n \tstruct ice_aqc_set_phy_cfg_data cfg = { 0 };\n \tstruct ice_aqc_get_phy_caps_data *pcaps;\n@@ -1446,8 +1548,8 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool atomic_restart)\n \t\tint retry_count, retry_max = 10;\n \n \t\t/* Auto restart link so settings take effect */\n-\t\tif (atomic_restart)\n-\t\t\tcfg.caps |= ICE_AQ_PHY_ENA_ATOMIC_LINK;\n+\t\tif (ena_auto_link_update)\n+\t\t\tcfg.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n \t\t/* Copy over all the old settings */\n \t\tcfg.phy_type_low = pcaps->phy_type_low;\n \t\tcfg.low_power_ctrl = pcaps->low_power_ctrl;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex 9a5519130af1..34c468138a8a 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -58,12 +58,24 @@ enum ice_status\n ice_aq_send_cmd(struct ice_hw *hw, struct ice_aq_desc *desc,\n \t\tvoid *buf, u16 buf_size, struct ice_sq_cd *cd);\n enum ice_status ice_aq_get_fw_ver(struct ice_hw *hw, struct ice_sq_cd *cd);\n+\n+enum ice_status\n+ice_aq_get_phy_caps(struct ice_port_info *pi, bool qual_mods, u8 report_mode,\n+\t\t struct ice_aqc_get_phy_caps_data *caps,\n+\t\t struct ice_sq_cd *cd);\n+void\n+ice_update_phy_type(u64 *phy_type_low, u16 link_speeds_bitmap);\n enum ice_status\n ice_aq_manage_mac_write(struct ice_hw *hw, u8 *mac_addr, u8 flags,\n \t\t\tstruct ice_sq_cd *cd);\n enum ice_status ice_clear_pf_cfg(struct ice_hw *hw);\n enum ice_status\n-ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool atomic_restart);\n+ice_aq_set_phy_cfg(struct ice_hw *hw, u8 lport,\n+\t\t struct ice_aqc_set_phy_cfg_data *cfg, struct ice_sq_cd *cd);\n+enum ice_status\n+ice_set_fc(struct ice_port_info *pi, u8 *aq_failures,\n+\t bool ena_auto_link_update);\n+\n enum ice_status\n ice_aq_set_link_restart_an(struct ice_port_info *pi, bool ena_link,\n \t\t\t struct ice_sq_cd *cd);\ndiff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c\nindex 807b683a5707..21c3be1ed72c 100644\n--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c\n+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c\n@@ -332,58 +332,477 @@ ice_get_ethtool_stats(struct net_device *netdev,\n \t}\n }\n \n-static int\n-ice_get_link_ksettings(struct net_device *netdev,\n-\t\t struct ethtool_link_ksettings *ks)\n+/**\n+ * ice_phy_type_to_ethtool - convert the phy_types to ethtool link modes\n+ * @netdev: network interface device structure\n+ * @ks: ethtool link ksettings struct to fill out\n+ *\n+ */\n+static void ice_phy_type_to_ethtool(struct net_device *netdev,\n+\t\t\t\t struct ethtool_link_ksettings *ks)\n {\n \tstruct ice_netdev_priv *np = netdev_priv(netdev);\n \tstruct ice_link_status *hw_link_info;\n \tstruct ice_vsi *vsi = np->vsi;\n-\tbool link_up;\n+\tu64 phy_types_low;\n \n \thw_link_info = &vsi->port_info->phy.link_info;\n-\tlink_up = hw_link_info->link_info & ICE_AQ_LINK_UP;\n+\tphy_types_low = vsi->port_info->phy.phy_type_low;\n+\n+\tethtool_link_ksettings_zero_link_mode(ks, supported);\n+\tethtool_link_ksettings_zero_link_mode(ks, advertising);\n+\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_100BASE_TX ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_100M_SGMII) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 100baseT_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_100MB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 100baseT_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_1G_SGMII) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseT_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_1000MB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 1000baseT_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_KX) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseKX_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_1000MB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 1000baseKX_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_SX ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_LX) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseX_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_1000MB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 1000baseX_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_T) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 2500baseT_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_2500MB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 2500baseT_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_X ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_KX) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 2500baseX_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_2500MB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 2500baseX_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_KR) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 5000baseT_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_5GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 5000baseT_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_10G_SFI_DA ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_10G_SFI_C2C) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseT_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_10GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 10000baseT_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_KR_CR1) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseKR_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_10GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 10000baseKR_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_SR) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseSR_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_10GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 10000baseSR_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_LR) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseLR_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_10GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 10000baseLR_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR_S ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR1 ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25G_AUI_C2C) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseCR_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_25GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 25000baseCR_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_SR ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_LR) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseSR_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_25GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 25000baseSR_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR_S ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR1) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseKR_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_25GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 25000baseKR_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_KR4) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseKR4_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_40GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 40000baseKR4_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_CR4 ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_40G_XLAUI) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseCR4_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_40GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 40000baseCR4_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_SR4) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseSR4_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_40GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 40000baseSR4_Full);\n+\t}\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_LR4) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseLR4_Full);\n+\t\tif (hw_link_info->req_speeds & ICE_AQ_LINK_SPEED_40GB)\n+\t\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t\t 40000baseLR4_Full);\n+\t}\n \n-\tethtool_link_ksettings_add_link_mode(ks, supported,\n-\t\t\t\t\t 10000baseT_Full);\n-\tethtool_link_ksettings_add_link_mode(ks, advertising,\n-\t\t\t\t\t 10000baseT_Full);\n+\t/* Autoneg PHY types */\n+\tif (phy_types_low & ICE_PHY_TYPE_LOW_100BASE_TX ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_1000BASE_KX ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_2500BASE_KX ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_5GBASE_KR ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_10GBASE_KR_CR1 ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_T ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR_S ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_CR1 ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR_S ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_25GBASE_KR1 ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_CR4 ||\n+\t phy_types_low & ICE_PHY_TYPE_LOW_40GBASE_KR4) {\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t Autoneg);\n+\t}\n+}\n \n-\t/* set speed and duplex */\n-\tif (link_up) {\n-\t\tswitch (hw_link_info->link_speed) {\n-\t\tcase ICE_AQ_LINK_SPEED_100MB:\n-\t\t\tks->base.speed = SPEED_100;\n-\t\t\tbreak;\n-\t\tcase ICE_AQ_LINK_SPEED_2500MB:\n-\t\t\tks->base.speed = SPEED_2500;\n-\t\t\tbreak;\n-\t\tcase ICE_AQ_LINK_SPEED_5GB:\n-\t\t\tks->base.speed = SPEED_5000;\n-\t\t\tbreak;\n-\t\tcase ICE_AQ_LINK_SPEED_10GB:\n-\t\t\tks->base.speed = SPEED_10000;\n-\t\t\tbreak;\n-\t\tcase ICE_AQ_LINK_SPEED_25GB:\n-\t\t\tks->base.speed = SPEED_25000;\n-\t\t\tbreak;\n-\t\tcase ICE_AQ_LINK_SPEED_40GB:\n-\t\t\tks->base.speed = SPEED_40000;\n-\t\t\tbreak;\n-\t\tdefault:\n-\t\t\tks->base.speed = SPEED_UNKNOWN;\n-\t\t\tbreak;\n-\t\t}\n+#define TEST_SET_BITS_TIMEOUT\t50\n+#define TEST_SET_BITS_SLEEP_MAX\t2000\n+#define TEST_SET_BITS_SLEEP_MIN\t1000\n \n-\t\tks->base.duplex = DUPLEX_FULL;\n-\t} else {\n-\t\tks->base.speed = SPEED_UNKNOWN;\n-\t\tks->base.duplex = DUPLEX_UNKNOWN;\n+/**\n+ * ice_get_settings_link_up - Get Link settings for when link is up\n+ * @ks: ethtool ksettings to fill in\n+ * @netdev: network interface device structure\n+ */\n+static void ice_get_settings_link_up(struct ethtool_link_ksettings *ks,\n+\t\t\t\t struct net_device *netdev)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ethtool_link_ksettings cap_ksettings;\n+\tstruct ice_link_status *hw_link_info;\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tbool unrecog_phy = false;\n+\n+\thw_link_info = &vsi->port_info->phy.link_info;\n+\n+\t/* Initialize supported and advertised settings based on phy settings */\n+\tswitch (hw_link_info->phy_type_low) {\n+\tcase ICE_PHY_TYPE_LOW_100BASE_TX:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 100baseT_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 100baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_100M_SGMII:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 100baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_T:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseT_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 1000baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_1G_SGMII:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_SX:\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_LX:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseX_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_1000BASE_KX:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 1000baseKX_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 1000baseKX_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_2500BASE_T:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 2500baseT_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 2500baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_2500BASE_X:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 2500baseX_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_2500BASE_KX:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 2500baseX_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 2500baseX_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_5GBASE_T:\n+\tcase ICE_PHY_TYPE_LOW_5GBASE_KR:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 5000baseT_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 5000baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_T:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseT_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 10000baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_10G_SFI_DA:\n+\tcase ICE_PHY_TYPE_LOW_10G_SFI_AOC_ACC:\n+\tcase ICE_PHY_TYPE_LOW_10G_SFI_C2C:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseT_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_SR:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseSR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_LR:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseLR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_10GBASE_KR_CR1:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 10000baseKR_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 10000baseKR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_T:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_CR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_CR_S:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_CR1:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseCR_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 25000baseCR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_25G_AUI_AOC_ACC:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseCR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_SR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_LR:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseSR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_KR:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_KR1:\n+\tcase ICE_PHY_TYPE_LOW_25GBASE_KR_S:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 25000baseKR_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 25000baseKR_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_CR4:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseCR4_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 40000baseCR4_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_40G_XLAUI_AOC_ACC:\n+\tcase ICE_PHY_TYPE_LOW_40G_XLAUI:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseCR4_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_SR4:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseSR4_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_LR4:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseLR4_Full);\n+\t\tbreak;\n+\tcase ICE_PHY_TYPE_LOW_40GBASE_KR4:\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported,\n+\t\t\t\t\t\t 40000baseKR4_Full);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, Autoneg);\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t 40000baseKR4_Full);\n+\t\tbreak;\n+\tdefault:\n+\t\tunrecog_phy = true;\n+\t}\n+\n+\tif (unrecog_phy) {\n+\t\t/* if we got here and link is up something bad is afoot */\n+\t\tnetdev_info(netdev,\n+\t\t\t \"WARNING: Link up but PhyType isn't recognized.\\n\");\n+\t\tnetdev_info(netdev,\n+\t\t\t \"WARNING: Unrecognized PHY_Low (0x%llx).\\n\",\n+\t\t\t (unsigned long long)hw_link_info->phy_type_low);\n \t}\n \n+\t/* Now that we've worked out everything that could be supported by the\n+\t * current PHY type, get what is supported by the NVM and intersect\n+\t * them to get what is truly supported\n+\t */\n+\tmemset(&cap_ksettings, 0, sizeof(struct ethtool_link_ksettings));\n+\tice_phy_type_to_ethtool(netdev, &cap_ksettings);\n+\tethtool_intersect_link_masks(ks, &cap_ksettings);\n+\n+\tswitch (hw_link_info->link_speed) {\n+\tcase ICE_AQ_LINK_SPEED_40GB:\n+\t\tks->base.speed = SPEED_40000;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_25GB:\n+\t\tks->base.speed = SPEED_25000;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_20GB:\n+\t\tks->base.speed = SPEED_20000;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_10GB:\n+\t\tks->base.speed = SPEED_10000;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_5GB:\n+\t\tks->base.speed = SPEED_5000;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_2500MB:\n+\t\tks->base.speed = SPEED_2500;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_1000MB:\n+\t\tks->base.speed = SPEED_1000;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_SPEED_100MB:\n+\t\tks->base.speed = SPEED_100;\n+\t\tbreak;\n+\tdefault:\n+\t\tnetdev_info(netdev,\n+\t\t\t \"WARNING: Unrecognized link_speed (0x%x).\\n\",\n+\t\t\t hw_link_info->link_speed);\n+\t\tbreak;\n+\t}\n+\tks->base.duplex = DUPLEX_FULL;\n+}\n+\n+/**\n+ * ice_get_settings_link_down - Get the Link settings when link is down\n+ * @ks: ethtool ksettings to fill in\n+ * @netdev: network interface device structure\n+ *\n+ * Reports link settings that can be determined when link is down\n+ */\n+static void\n+ice_get_settings_link_down(struct ethtool_link_ksettings *ks,\n+\t\t\t struct net_device __always_unused *netdev)\n+{\n+\t/* link is down and the driver needs to fall back on\n+\t * supported phy types to figure out what info to display\n+\t */\n+\tice_phy_type_to_ethtool(netdev, ks);\n+\n+\t/* With no link, speed and duplex are unknown */\n+\tks->base.speed = SPEED_UNKNOWN;\n+\tks->base.duplex = DUPLEX_UNKNOWN;\n+}\n+\n+/**\n+ * ice_get_link_ksettings - Get Link Speed and Duplex settings\n+ * @netdev: network interface device structure\n+ * @ks: ethtool ksettings\n+ *\n+ * Reports speed/duplex settings based on media_type\n+ */\n+static int ice_get_link_ksettings(struct net_device *netdev,\n+\t\t\t\t struct ethtool_link_ksettings *ks)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_link_status *hw_link_info;\n+\tstruct ice_vsi *vsi = np->vsi;\n+\n+\tethtool_link_ksettings_zero_link_mode(ks, supported);\n+\tethtool_link_ksettings_zero_link_mode(ks, advertising);\n+\thw_link_info = &vsi->port_info->phy.link_info;\n+\n+\t/* set speed and duplex */\n+\tif (hw_link_info->link_info & ICE_AQ_LINK_UP)\n+\t\tice_get_settings_link_up(ks, netdev);\n+\telse\n+\t\tice_get_settings_link_down(ks, netdev);\n+\n \t/* set autoneg settings */\n-\tks->base.autoneg = ((hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ?\n-\t\t\t AUTONEG_ENABLE : AUTONEG_DISABLE);\n+\tks->base.autoneg = (hw_link_info->an_info & ICE_AQ_AN_COMPLETED) ?\n+\t\tAUTONEG_ENABLE : AUTONEG_DISABLE;\n \n \t/* set media type settings */\n \tswitch (vsi->port_info->phy.media_type) {\n@@ -441,6 +860,311 @@ ice_get_link_ksettings(struct net_device *netdev,\n \treturn 0;\n }\n \n+/**\n+ * ice_ksettings_find_adv_link_speed - Find advertising link speed\n+ * @ks: ethtool ksettings\n+ */\n+static u16\n+ice_ksettings_find_adv_link_speed(const struct ethtool_link_ksettings *ks)\n+{\n+\tu16 adv_link_speed = 0;\n+\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 100baseT_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_100MB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 1000baseX_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_1000MB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 1000baseT_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 1000baseKX_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_1000MB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 2500baseT_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_2500MB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 2500baseX_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_2500MB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 5000baseT_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_5GB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 10000baseT_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 10000baseKR_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_10GB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 10000baseSR_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 10000baseLR_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_10GB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 25000baseCR_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 25000baseSR_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 25000baseKR_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_25GB;\n+\tif (ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 40000baseCR4_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 40000baseSR4_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 40000baseLR4_Full) ||\n+\t ethtool_link_ksettings_test_link_mode(ks, advertising,\n+\t\t\t\t\t\t 40000baseKR4_Full))\n+\t\tadv_link_speed |= ICE_AQ_LINK_SPEED_40GB;\n+\n+\treturn adv_link_speed;\n+}\n+\n+/**\n+ * ice_setup_autoneg\n+ * @p: port info\n+ * @ks: ethtool_link_ksettings\n+ * @config: configuration that will be sent down to FW\n+ * @autoneg_enabled: autonegotiation is enabled or not\n+ * @autoneg_changed: will there a change in autonegotiation\n+ * @netdev: network interface device structure\n+ *\n+ * Setup PHY autonegotiation feature\n+ */\n+static int\n+ice_setup_autoneg(struct ice_port_info *p, struct ethtool_link_ksettings *ks,\n+\t\t struct ice_aqc_set_phy_cfg_data *config,\n+\t\t u8 autoneg_enabled, u8 *autoneg_changed,\n+\t\t struct net_device *netdev)\n+{\n+\tint err = 0;\n+\n+\t*autoneg_changed = 0;\n+\n+\t/* Check autoneg */\n+\tif (autoneg_enabled == AUTONEG_ENABLE) {\n+\t\t/* If autoneg was not already enabled */\n+\t\tif (!(p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED)) {\n+\t\t\t/* If autoneg is not supported, return error */\n+\t\t\tif (!ethtool_link_ksettings_test_link_mode(ks,\n+\t\t\t\t\t\t\t\t supported,\n+\t\t\t\t\t\t\t\t Autoneg)) {\n+\t\t\t\tnetdev_info(netdev, \"Autoneg not supported on this phy.\\n\");\n+\t\t\t\terr = -EINVAL;\n+\t\t\t} else {\n+\t\t\t\t/* Autoneg is allowed to change */\n+\t\t\t\tconfig->caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n+\t\t\t\t*autoneg_changed = 1;\n+\t\t\t}\n+\t\t}\n+\t} else {\n+\t\t/* If autoneg is currently enabled */\n+\t\tif (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) {\n+\t\t\t/* If autoneg is supported 10GBASE_T is the only phy\n+\t\t\t * that can disable it, so otherwise return error\n+\t\t\t */\n+\t\t\tif (ethtool_link_ksettings_test_link_mode(ks,\n+\t\t\t\t\t\t\t\t supported,\n+\t\t\t\t\t\t\t\t Autoneg)) {\n+\t\t\t\tnetdev_info(netdev, \"Autoneg cannot be disabled on this phy\\n\");\n+\t\t\t\terr = -EINVAL;\n+\t\t\t} else {\n+\t\t\t\t/* Autoneg is allowed to change */\n+\t\t\t\tconfig->caps &= ~ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n+\t\t\t\t*autoneg_changed = 1;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn err;\n+}\n+\n+/**\n+ * ice_set_link_ksettings - Set Speed and Duplex\n+ * @netdev: network interface device structure\n+ * @ks: ethtool ksettings\n+ *\n+ * Set speed/duplex per media_types advertised/forced\n+ */\n+static int ice_set_link_ksettings(struct net_device *netdev,\n+\t\t\t\t const struct ethtool_link_ksettings *ks)\n+{\n+\tu8 autoneg, timeout = TEST_SET_BITS_TIMEOUT, lport = 0;\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ethtool_link_ksettings safe_ks, copy_ks;\n+\tstruct ice_aqc_get_phy_caps_data *abilities;\n+\tu16 adv_link_speed, curr_link_speed, idx;\n+\tstruct ice_aqc_set_phy_cfg_data config;\n+\tstruct ice_pf *pf = np->vsi->back;\n+\tstruct ice_port_info *p;\n+\tu8 autoneg_changed = 0;\n+\tenum ice_status status;\n+\tu64 phy_type_low;\n+\tint err = 0;\n+\tbool linkup;\n+\n+\tp = np->vsi->port_info;\n+\n+\tif (!p)\n+\t\treturn -EOPNOTSUPP;\n+\n+\t/* Check if this is lan vsi */\n+\tfor (idx = 0 ; idx < pf->num_alloc_vsi ; idx++) {\n+\t\tif (pf->vsi[idx]->type == ICE_VSI_PF) {\n+\t\t\tif (np->vsi != pf->vsi[idx])\n+\t\t\t\treturn -EOPNOTSUPP;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tif (p->phy.media_type != ICE_MEDIA_BASET &&\n+\t p->phy.media_type != ICE_MEDIA_FIBER &&\n+\t p->phy.media_type != ICE_MEDIA_BACKPLANE &&\n+\t p->phy.media_type != ICE_MEDIA_DA &&\n+\t p->phy.link_info.link_info & ICE_AQ_LINK_UP)\n+\t\treturn -EOPNOTSUPP;\n+\n+\t/* copy the ksettings to copy_ks to avoid modifying the original */\n+\tmemcpy(©_ks, ks, sizeof(struct ethtool_link_ksettings));\n+\n+\t/* save autoneg out of ksettings */\n+\tautoneg = copy_ks.base.autoneg;\n+\n+\tmemset(&safe_ks, 0, sizeof(safe_ks));\n+\n+\t/* Get link modes supported by hardware.*/\n+\tice_phy_type_to_ethtool(netdev, &safe_ks);\n+\n+\t/* and check against modes requested by user.\n+\t * Return an error if unsupported mode was set.\n+\t */\n+\tif (!bitmap_subset(copy_ks.link_modes.advertising,\n+\t\t\t safe_ks.link_modes.supported,\n+\t\t\t __ETHTOOL_LINK_MODE_MASK_NBITS))\n+\t\treturn -EINVAL;\n+\n+\t/* get our own copy of the bits to check against */\n+\tmemset(&safe_ks, 0, sizeof(struct ethtool_link_ksettings));\n+\tsafe_ks.base.cmd = copy_ks.base.cmd;\n+\tsafe_ks.base.link_mode_masks_nwords =\n+\t\tcopy_ks.base.link_mode_masks_nwords;\n+\tice_get_link_ksettings(netdev, &safe_ks);\n+\n+\t/* set autoneg back to what it currently is */\n+\tcopy_ks.base.autoneg = safe_ks.base.autoneg;\n+\t/* we don't compare the speed */\n+\tcopy_ks.base.speed = safe_ks.base.speed;\n+\n+\t/* If copy_ks.base and safe_ks.base are not the same now, then they are\n+\t * trying to set something that we do not support.\n+\t */\n+\tif (memcmp(©_ks.base, &safe_ks.base,\n+\t\t sizeof(struct ethtool_link_settings)))\n+\t\treturn -EOPNOTSUPP;\n+\n+\twhile (test_and_set_bit(__ICE_CFG_BUSY, pf->state)) {\n+\t\ttimeout--;\n+\t\tif (!timeout)\n+\t\t\treturn -EBUSY;\n+\t\tusleep_range(TEST_SET_BITS_SLEEP_MIN, TEST_SET_BITS_SLEEP_MAX);\n+\t}\n+\n+\tabilities = devm_kzalloc(&pf->pdev->dev, sizeof(*abilities),\n+\t\t\t\t GFP_KERNEL);\n+\tif (!abilities)\n+\t\treturn -ENOMEM;\n+\n+\t/* Get the current phy config */\n+\tstatus = ice_aq_get_phy_caps(p, false, ICE_AQC_REPORT_SW_CFG, abilities,\n+\t\t\t\t NULL);\n+\tif (status) {\n+\t\terr = -EAGAIN;\n+\t\tgoto done;\n+\t}\n+\n+\t/* Copy abilities to config in case autoneg is not set below */\n+\tmemset(&config, 0, sizeof(struct ice_aqc_set_phy_cfg_data));\n+\tconfig.caps = abilities->caps & ~ICE_AQC_PHY_AN_MODE;\n+\tif (abilities->caps & ICE_AQC_PHY_AN_MODE)\n+\t\tconfig.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n+\n+\t/* Check autoneg */\n+\terr = ice_setup_autoneg(p, &safe_ks, &config, autoneg, &autoneg_changed,\n+\t\t\t\tnetdev);\n+\n+\tif (err)\n+\t\tgoto done;\n+\n+\t/* Call to get the current link speed */\n+\tp->phy.get_link_info = true;\n+\tstatus = ice_get_link_status(p, &linkup);\n+\tif (status) {\n+\t\terr = -EAGAIN;\n+\t\tgoto done;\n+\t}\n+\n+\tcurr_link_speed = p->phy.link_info.link_speed;\n+\tadv_link_speed = ice_ksettings_find_adv_link_speed(ks);\n+\n+\t/* If speed didn't get set, set it to what it currently is.\n+\t * This is needed because if advertise is 0 (as it is when autoneg\n+\t * is disabled) then speed won't get set.\n+\t */\n+\tif (!adv_link_speed)\n+\t\tadv_link_speed = curr_link_speed;\n+\n+\t/* Convert the advertise link speeds to their corresponded PHY_TYPE */\n+\tice_update_phy_type(&phy_type_low, adv_link_speed);\n+\n+\tif (!autoneg_changed && adv_link_speed == curr_link_speed) {\n+\t\tnetdev_info(netdev, \"Nothing changed, exiting without setting anything.\\n\");\n+\t\tgoto done;\n+\t}\n+\n+\t/* copy over the rest of the abilities */\n+\tconfig.low_power_ctrl = abilities->low_power_ctrl;\n+\tconfig.eee_cap = abilities->eee_cap;\n+\tconfig.eeer_value = abilities->eeer_value;\n+\tconfig.link_fec_opt = abilities->link_fec_options;\n+\n+\t/* save the requested speeds */\n+\tp->phy.link_info.req_speeds = adv_link_speed;\n+\n+\t/* set link and auto negotiation so changes take effect */\n+\tconfig.caps |= ICE_AQ_PHY_ENA_LINK;\n+\n+\tif (phy_type_low) {\n+\t\tconfig.phy_type_low = cpu_to_le64(phy_type_low) &\n+\t\t\tabilities->phy_type_low;\n+\t} else {\n+\t\terr = -EAGAIN;\n+\t\tnetdev_info(netdev, \"Nothing changed. No PHY_TYPE is corresponded to advertised link speed.\\n\");\n+\t\tgoto done;\n+\t}\n+\n+\t/* If link is up put link down */\n+\tif (p->phy.link_info.link_info & ICE_AQ_LINK_UP) {\n+\t\t/* Tell the OS link is going down, the link will go\n+\t\t * back up when fw says it is ready asynchronously\n+\t\t */\n+\t\tice_print_link_msg(np->vsi, false);\n+\t\tnetif_carrier_off(netdev);\n+\t\tnetif_tx_stop_all_queues(netdev);\n+\t}\n+\n+\t/* make the aq call */\n+\tstatus = ice_aq_set_phy_cfg(&pf->hw, lport, &config, NULL);\n+\tif (status) {\n+\t\tnetdev_info(netdev, \"Set phy config failed,\\n\");\n+\t\terr = -EAGAIN;\n+\t}\n+\n+done:\n+\tdevm_kfree(&pf->pdev->dev, abilities);\n+\tclear_bit(__ICE_CFG_BUSY, pf->state);\n+\n+\treturn err;\n+}\n+\n /**\n * ice_get_rxnfc - command to get RX flow classification rules\n * @netdev: network interface device structure\n@@ -933,6 +1657,7 @@ static int ice_set_rxfh(struct net_device *netdev, const u32 *indir,\n \n static const struct ethtool_ops ice_ethtool_ops = {\n \t.get_link_ksettings\t= ice_get_link_ksettings,\n+\t.set_link_ksettings\t= ice_set_link_ksettings,\n \t.get_drvinfo = ice_get_drvinfo,\n \t.get_regs_len = ice_get_regs_len,\n \t.get_regs = ice_get_regs,\n", "prefixes": [ "v2", "07/13" ] }