Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1086504/?format=api
{ "id": 1086504, "url": "http://patchwork.ozlabs.org/api/patches/1086504/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190416173503.29847-4-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": "<20190416173503.29847-4-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2019-04-16T17:34:52", "name": "[S21,03/14] ice: Add support for Forward Error Correction (FEC)", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "38f2a0319070b3b95d843f67094378cf46f19b04", "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/20190416173503.29847-4-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 103110, "url": "http://patchwork.ozlabs.org/api/series/103110/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=103110", "date": "2019-04-16T17:34:49", "name": "Fixes and feature updates for ice", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/103110/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1086504/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1086504/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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])\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 44kCFk3gmnz9s55\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 17 Apr 2019 03:35:53 +1000 (AEST)", "from localhost (localhost [127.0.0.1])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id 329AF87055;\n\tTue, 16 Apr 2019 17:35:52 +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 XEs1czNLidI0; Tue, 16 Apr 2019 17:35:45 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby whitealder.osuosl.org (Postfix) with ESMTP id E3367870B2;\n\tTue, 16 Apr 2019 17:35:45 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 27C971C1647\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 16 Apr 2019 17:35:42 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 199CF23358\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 16 Apr 2019 17:35:42 +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 Xdm4QjcI64n2 for <intel-wired-lan@lists.osuosl.org>;\n\tTue, 16 Apr 2019 17:35:37 +0000 (UTC)", "from mga17.intel.com (mga17.intel.com [192.55.52.151])\n\tby silver.osuosl.org (Postfix) with ESMTPS id 2BE9E23600\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tTue, 16 Apr 2019 17:35:37 +0000 (UTC)", "from fmsmga001.fm.intel.com ([10.253.24.23])\n\tby fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t16 Apr 2019 10:35:36 -0700", "from shasta.jf.intel.com ([10.166.244.191])\n\tby fmsmga001.fm.intel.com with ESMTP; 16 Apr 2019 10:35:36 -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.60,358,1549958400\"; d=\"scan'208\";a=\"165278539\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Tue, 16 Apr 2019 10:34:52 -0700", "Message-Id": "<20190416173503.29847-4-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190416173503.29847-1-anirudh.venkataramanan@intel.com>", "References": "<20190416173503.29847-1-anirudh.venkataramanan@intel.com>", "MIME-Version": "1.0", "Subject": "[Intel-wired-lan] [PATCH S21 03/14] ice: Add support for Forward\n\tError Correction (FEC)", "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>", "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: Paul Greenwalt <paul.greenwalt@intel.com>\n\nThis patch adds driver support for Forward Error Correction (FEC)\nand ethtool handlers to set/get FEC params.\n\nSigned-off-by: Paul Greenwalt <paul.greenwalt@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n .../net/ethernet/intel/ice/ice_adminq_cmd.h | 4 +\n drivers/net/ethernet/intel/ice/ice_common.c | 70 ++++++\n drivers/net/ethernet/intel/ice/ice_common.h | 6 +-\n drivers/net/ethernet/intel/ice/ice_ethtool.c | 216 ++++++++++++++++++\n drivers/net/ethernet/intel/ice/ice_main.c | 47 +++-\n drivers/net/ethernet/intel/ice/ice_type.h | 9 +\n 6 files changed, 349 insertions(+), 3 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 8680ee2ffa1b..b233f6ca8f0f 100644\n--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h\n@@ -920,6 +920,8 @@ struct ice_aqc_get_phy_caps_data {\n #define ICE_AQC_PHY_EN_LINK\t\t\t\tBIT(3)\n #define ICE_AQC_PHY_AN_MODE\t\t\t\tBIT(4)\n #define ICE_AQC_GET_PHY_EN_MOD_QUAL\t\t\tBIT(5)\n+#define ICE_AQC_PHY_EN_AUTO_FEC\t\t\t\tBIT(7)\n+#define ICE_AQC_PHY_CAPS_MASK\t\t\t\tICE_M(0xff, 0)\n \tu8 low_power_ctrl;\n #define ICE_AQC_PHY_EN_D3COLD_LOW_POWER_AUTONEG\t\tBIT(0)\n \t__le16 eee_cap;\n@@ -940,6 +942,7 @@ struct ice_aqc_get_phy_caps_data {\n #define ICE_AQC_PHY_FEC_25G_RS_544_REQ\t\t\tBIT(4)\n #define ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN\t\tBIT(6)\n #define ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN\t\tBIT(7)\n+#define ICE_AQC_PHY_FEC_MASK\t\t\t\tICE_M(0xdf, 0)\n \tu8 extended_compliance_code;\n #define ICE_MODULE_TYPE_TOTAL_BYTE\t\t\t3\n \tu8 module_type[ICE_MODULE_TYPE_TOTAL_BYTE];\n@@ -1062,6 +1065,7 @@ struct ice_aqc_get_link_status_data {\n #define ICE_AQ_LINK_25G_KR_FEC_EN\tBIT(0)\n #define ICE_AQ_LINK_25G_RS_528_FEC_EN\tBIT(1)\n #define ICE_AQ_LINK_25G_RS_544_FEC_EN\tBIT(2)\n+#define ICE_AQ_FEC_MASK\t\t\tICE_M(0x7, 0)\n \t/* Pacing Config */\n #define ICE_AQ_CFG_PACING_S\t\t3\n #define ICE_AQ_CFG_PACING_M\t\t(0xF << ICE_AQ_CFG_PACING_S)\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c\nindex b870cc0a363b..9a402513613f 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.c\n+++ b/drivers/net/ethernet/intel/ice/ice_common.c\n@@ -304,6 +304,8 @@ ice_aq_get_link_info(struct ice_port_info *pi, bool ena_lse,\n \thw_link_info->an_info = link_data.an_info;\n \thw_link_info->ext_info = link_data.ext_info;\n \thw_link_info->max_frame_size = le16_to_cpu(link_data.max_frame_size);\n+\thw_link_info->fec_info = link_data.cfg & ICE_AQ_FEC_MASK;\n+\thw_link_info->topo_media_conflict = link_data.topo_media_conflict;\n \thw_link_info->pacing = link_data.cfg & ICE_AQ_CFG_PACING_M;\n \n \t/* update fc info */\n@@ -2129,6 +2131,74 @@ ice_set_fc(struct ice_port_info *pi, u8 *aq_failures, bool ena_auto_link_update)\n \treturn status;\n }\n \n+/**\n+ * ice_copy_phy_caps_to_cfg - Copy PHY ability data to configuration data\n+ * @caps: PHY ability structure to copy date from\n+ * @cfg: PHY configuration structure to copy data to\n+ *\n+ * Helper function to copy AQC PHY get ability data to PHY set configuration\n+ * data structure\n+ */\n+void\n+ice_copy_phy_caps_to_cfg(struct ice_aqc_get_phy_caps_data *caps,\n+\t\t\t struct ice_aqc_set_phy_cfg_data *cfg)\n+{\n+\tif (!caps || !cfg)\n+\t\treturn;\n+\n+\tcfg->phy_type_low = caps->phy_type_low;\n+\tcfg->phy_type_high = caps->phy_type_high;\n+\tcfg->caps = caps->caps;\n+\tcfg->low_power_ctrl = caps->low_power_ctrl;\n+\tcfg->eee_cap = caps->eee_cap;\n+\tcfg->eeer_value = caps->eeer_value;\n+\tcfg->link_fec_opt = caps->link_fec_options;\n+}\n+\n+/**\n+ * ice_cfg_phy_fec - Configure PHY FEC data based on FEC mode\n+ * @cfg: PHY configuration data to set FEC mode\n+ * @fec: FEC mode to configure\n+ *\n+ * Caller should copy ice_aqc_get_phy_caps_data.caps ICE_AQC_PHY_EN_AUTO_FEC\n+ * (bit 7) and ice_aqc_get_phy_caps_data.link_fec_options to cfg.caps\n+ * ICE_AQ_PHY_ENA_AUTO_FEC (bit 7) and cfg.link_fec_options before calling.\n+ */\n+void\n+ice_cfg_phy_fec(struct ice_aqc_set_phy_cfg_data *cfg, enum ice_fec_mode fec)\n+{\n+\tswitch (fec) {\n+\tcase ICE_FEC_BASER:\n+\t\t/* Clear auto FEC and RS bits, and AND BASE-R ability\n+\t\t * bits and OR request bits.\n+\t\t */\n+\t\tcfg->caps &= ~ICE_AQC_PHY_EN_AUTO_FEC;\n+\t\tcfg->link_fec_opt &= ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN |\n+\t\t\t\t ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN;\n+\t\tcfg->link_fec_opt |= ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ |\n+\t\t\t\t ICE_AQC_PHY_FEC_25G_KR_REQ;\n+\t\tbreak;\n+\tcase ICE_FEC_RS:\n+\t\t/* Clear auto FEC and BASE-R bits, and AND RS ability\n+\t\t * bits and OR request bits.\n+\t\t */\n+\t\tcfg->caps &= ~ICE_AQC_PHY_EN_AUTO_FEC;\n+\t\tcfg->link_fec_opt &= ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN;\n+\t\tcfg->link_fec_opt |= ICE_AQC_PHY_FEC_25G_RS_528_REQ |\n+\t\t\t\t ICE_AQC_PHY_FEC_25G_RS_544_REQ;\n+\t\tbreak;\n+\tcase ICE_FEC_NONE:\n+\t\t/* Clear auto FEC and all FEC option bits. */\n+\t\tcfg->caps &= ~ICE_AQC_PHY_EN_AUTO_FEC;\n+\t\tcfg->link_fec_opt &= ~ICE_AQC_PHY_FEC_MASK;\n+\t\tbreak;\n+\tcase ICE_FEC_AUTO:\n+\t\t/* AND auto FEC bit, and all caps bits. */\n+\t\tcfg->caps &= ICE_AQC_PHY_CAPS_MASK;\n+\t\tbreak;\n+\t}\n+}\n+\n /**\n * ice_get_link_status - get status of the HW network link\n * @pi: port information structure\ndiff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h\nindex 9773d7b2e9c9..d1f8353fe6bb 100644\n--- a/drivers/net/ethernet/intel/ice/ice_common.h\n+++ b/drivers/net/ethernet/intel/ice/ice_common.h\n@@ -86,7 +86,11 @@ ice_aq_set_phy_cfg(struct ice_hw *hw, u8 lport,\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+void\n+ice_cfg_phy_fec(struct ice_aqc_set_phy_cfg_data *cfg, enum ice_fec_mode fec);\n+void\n+ice_copy_phy_caps_to_cfg(struct ice_aqc_get_phy_caps_data *caps,\n+\t\t\t struct ice_aqc_set_phy_cfg_data *cfg);\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 9dde6dd78643..2da83847b9dc 100644\n--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c\n+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c\n@@ -959,6 +959,185 @@ ice_set_phys_id(struct net_device *netdev, enum ethtool_phys_id_state state)\n \treturn 0;\n }\n \n+/**\n+ * ice_set_fec_cfg - Set link FEC options\n+ * @netdev: network interface device structure\n+ * @req_fec: FEC mode to configure\n+ */\n+static int ice_set_fec_cfg(struct net_device *netdev, enum ice_fec_mode req_fec)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_aqc_set_phy_cfg_data config = { 0 };\n+\tstruct ice_aqc_get_phy_caps_data *caps;\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tu8 sw_cfg_caps, sw_cfg_fec;\n+\tstruct ice_port_info *pi;\n+\tenum ice_status status;\n+\tint err = 0;\n+\n+\tpi = vsi->port_info;\n+\tif (!pi)\n+\t\treturn -EOPNOTSUPP;\n+\n+\t/* Changing the FEC parameters is not supported if not the PF VSI */\n+\tif (vsi->type != ICE_VSI_PF) {\n+\t\tnetdev_info(netdev, \"Changing FEC parameters only supported for PF VSI\\n\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\t/* Get last SW configuration */\n+\tcaps = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*caps), GFP_KERNEL);\n+\tif (!caps)\n+\t\treturn -ENOMEM;\n+\n+\tstatus = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG,\n+\t\t\t\t caps, NULL);\n+\tif (status) {\n+\t\terr = -EAGAIN;\n+\t\tgoto done;\n+\t}\n+\n+\t/* Copy SW configuration returned from PHY caps to PHY config */\n+\tice_copy_phy_caps_to_cfg(caps, &config);\n+\tsw_cfg_caps = caps->caps;\n+\tsw_cfg_fec = caps->link_fec_options;\n+\n+\t/* Get toloplogy caps, then copy PHY FEC topoloy caps to PHY config */\n+\tmemset(caps, 0, sizeof(*caps));\n+\n+\tstatus = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP,\n+\t\t\t\t caps, NULL);\n+\tif (status) {\n+\t\terr = -EAGAIN;\n+\t\tgoto done;\n+\t}\n+\n+\tconfig.caps |= (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC);\n+\tconfig.link_fec_opt = caps->link_fec_options;\n+\n+\tice_cfg_phy_fec(&config, req_fec);\n+\n+\t/* If FEC mode has changed, then set PHY configuration and enable AN. */\n+\tif ((config.caps & ICE_AQ_PHY_ENA_AUTO_FEC) !=\n+\t (sw_cfg_caps & ICE_AQC_PHY_EN_AUTO_FEC) ||\n+\t config.link_fec_opt != sw_cfg_fec) {\n+\t\tif (caps->caps & ICE_AQC_PHY_AN_MODE)\n+\t\t\tconfig.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n+\n+\t\tstatus = ice_aq_set_phy_cfg(pi->hw, pi->lport, &config, NULL);\n+\n+\t\tif (status)\n+\t\t\terr = -EAGAIN;\n+\t}\n+\n+done:\n+\tdevm_kfree(&vsi->back->pdev->dev, caps);\n+\treturn err;\n+}\n+\n+/**\n+ * ice_set_fecparam - Set FEC link options\n+ * @netdev: network interface device structure\n+ * @fecparam: Ethtool structure to retrieve FEC parameters\n+ */\n+static int\n+ice_set_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tenum ice_fec_mode fec;\n+\n+\tswitch (fecparam->fec) {\n+\tcase ETHTOOL_FEC_AUTO:\n+\t\tfec = ICE_FEC_AUTO;\n+\t\tbreak;\n+\tcase ETHTOOL_FEC_RS:\n+\t\tfec = ICE_FEC_RS;\n+\t\tbreak;\n+\tcase ETHTOOL_FEC_BASER:\n+\t\tfec = ICE_FEC_BASER;\n+\t\tbreak;\n+\tcase ETHTOOL_FEC_OFF:\n+\tcase ETHTOOL_FEC_NONE:\n+\t\tfec = ICE_FEC_NONE;\n+\t\tbreak;\n+\tdefault:\n+\t\tdev_warn(&vsi->back->pdev->dev, \"Unsupported FEC mode: %d\\n\",\n+\t\t\t fecparam->fec);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn ice_set_fec_cfg(netdev, fec);\n+}\n+\n+/**\n+ * ice_get_fecparam - Get link FEC options\n+ * @netdev: network interface device structure\n+ * @fecparam: Ethtool structure to retrieve FEC parameters\n+ */\n+static int\n+ice_get_fecparam(struct net_device *netdev, struct ethtool_fecparam *fecparam)\n+{\n+\tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_aqc_get_phy_caps_data *caps;\n+\tstruct ice_link_status *link_info;\n+\tstruct ice_vsi *vsi = np->vsi;\n+\tstruct ice_port_info *pi;\n+\tenum ice_status status;\n+\tint err = 0;\n+\n+\tpi = vsi->port_info;\n+\n+\tif (!pi)\n+\t\treturn -EOPNOTSUPP;\n+\tlink_info = &pi->phy.link_info;\n+\n+\t/* Set FEC mode based on negotiated link info */\n+\tswitch (link_info->fec_info) {\n+\tcase ICE_AQ_LINK_25G_KR_FEC_EN:\n+\t\tfecparam->active_fec = ETHTOOL_FEC_BASER;\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_25G_RS_528_FEC_EN:\n+\t\t/* fall through */\n+\tcase ICE_AQ_LINK_25G_RS_544_FEC_EN:\n+\t\tfecparam->active_fec = ETHTOOL_FEC_RS;\n+\t\tbreak;\n+\tdefault:\n+\t\tfecparam->active_fec = ETHTOOL_FEC_OFF;\n+\t\tbreak;\n+\t}\n+\n+\tcaps = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*caps), GFP_KERNEL);\n+\tif (!caps)\n+\t\treturn -ENOMEM;\n+\n+\tstatus = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_TOPO_CAP,\n+\t\t\t\t caps, NULL);\n+\tif (status) {\n+\t\terr = -EAGAIN;\n+\t\tgoto done;\n+\t}\n+\n+\t/* Set supported/configured FEC modes based on PHY capability */\n+\tif (caps->caps & ICE_AQC_PHY_EN_AUTO_FEC)\n+\t\tfecparam->fec |= ETHTOOL_FEC_AUTO;\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)\n+\t\tfecparam->fec |= ETHTOOL_FEC_BASER;\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)\n+\t\tfecparam->fec |= ETHTOOL_FEC_RS;\n+\tif (caps->link_fec_options == 0)\n+\t\tfecparam->fec |= ETHTOOL_FEC_OFF;\n+\n+done:\n+\tdevm_kfree(&vsi->back->pdev->dev, caps);\n+\treturn err;\n+}\n+\n /**\n * ice_get_priv_flags - report device private flags\n * @netdev: network interface device structure\n@@ -1885,6 +2064,7 @@ ice_get_link_ksettings(struct net_device *netdev,\n \t\t struct ethtool_link_ksettings *ks)\n {\n \tstruct ice_netdev_priv *np = netdev_priv(netdev);\n+\tstruct ice_aqc_get_phy_caps_data *caps;\n \tstruct ice_link_status *hw_link_info;\n \tstruct ice_vsi *vsi = np->vsi;\n \n@@ -1955,6 +2135,40 @@ ice_get_link_ksettings(struct net_device *netdev,\n \t\tbreak;\n \t}\n \n+\tcaps = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*caps), GFP_KERNEL);\n+\tif (!caps)\n+\t\tgoto done;\n+\n+\tif (ice_aq_get_phy_caps(vsi->port_info, false, ICE_AQC_REPORT_TOPO_CAP,\n+\t\t\t\tcaps, NULL))\n+\t\tnetdev_info(netdev, \"Get phy capability failed.\\n\");\n+\n+\t/* Set supported FEC modes based on PHY capability */\n+\tethtool_link_ksettings_add_link_mode(ks, supported, FEC_NONE);\n+\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_EN ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_CLAUSE74_EN)\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, FEC_BASER);\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_CLAUSE91_EN)\n+\t\tethtool_link_ksettings_add_link_mode(ks, supported, FEC_RS);\n+\n+\tif (ice_aq_get_phy_caps(vsi->port_info, false, ICE_AQC_REPORT_SW_CFG,\n+\t\t\t\tcaps, NULL))\n+\t\tnetdev_info(netdev, \"Get phy capability failed.\\n\");\n+\n+\t/* Set advertised FEC modes based on PHY capability */\n+\tethtool_link_ksettings_add_link_mode(ks, advertising, FEC_NONE);\n+\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising,\n+\t\t\t\t\t\t FEC_BASER);\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ)\n+\t\tethtool_link_ksettings_add_link_mode(ks, advertising, FEC_RS);\n+\n+done:\n+\tdevm_kfree(&vsi->back->pdev->dev, caps);\n \treturn 0;\n }\n \n@@ -3167,6 +3381,8 @@ static const struct ethtool_ops ice_ethtool_ops = {\n \t.get_ts_info\t\t= ethtool_op_get_ts_info,\n \t.get_per_queue_coalesce = ice_get_per_q_coalesce,\n \t.set_per_queue_coalesce = ice_set_per_q_coalesce,\n+\t.get_fecparam\t\t= ice_get_fecparam,\n+\t.set_fecparam\t\t= ice_set_fecparam,\n };\n \n /**\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex da62a901b355..c8cf2c35ecbb 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -624,7 +624,11 @@ static void ice_reset_subtask(struct ice_pf *pf)\n */\n void ice_print_link_msg(struct ice_vsi *vsi, bool isup)\n {\n+\tstruct ice_aqc_get_phy_caps_data *caps;\n+\tenum ice_status status;\n+\tconst char *fec_req;\n \tconst char *speed;\n+\tconst char *fec;\n \tconst char *fc;\n \n \tif (!vsi)\n@@ -688,8 +692,47 @@ void ice_print_link_msg(struct ice_vsi *vsi, bool isup)\n \t\tbreak;\n \t}\n \n-\tnetdev_info(vsi->netdev, \"NIC Link is up %sbps, Flow Control: %s\\n\",\n-\t\t speed, fc);\n+\t/* Get FEC mode based on negotiated link info */\n+\tswitch (vsi->port_info->phy.link_info.fec_info) {\n+\tcase ICE_AQ_LINK_25G_RS_528_FEC_EN:\n+\t\t/* fall through */\n+\tcase ICE_AQ_LINK_25G_RS_544_FEC_EN:\n+\t\tfec = \"RS-FEC\";\n+\t\tbreak;\n+\tcase ICE_AQ_LINK_25G_KR_FEC_EN:\n+\t\tfec = \"FC-FEC/BASE-R\";\n+\t\tbreak;\n+\tdefault:\n+\t\tfec = \"NONE\";\n+\t\tbreak;\n+\t}\n+\n+\t/* Get FEC mode requested based on PHY caps last SW configuration */\n+\tcaps = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*caps), GFP_KERNEL);\n+\tif (!caps) {\n+\t\tfec_req = \"Unknown\";\n+\t\tgoto done;\n+\t}\n+\n+\tstatus = ice_aq_get_phy_caps(vsi->port_info, false,\n+\t\t\t\t ICE_AQC_REPORT_SW_CFG, caps, NULL);\n+\tif (status)\n+\t\tnetdev_info(vsi->netdev, \"Get phy capability failed.\\n\");\n+\n+\tif (caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_528_REQ ||\n+\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_RS_544_REQ)\n+\t\tfec_req = \"RS-FEC\";\n+\telse if (caps->link_fec_options & ICE_AQC_PHY_FEC_10G_KR_40G_KR4_REQ ||\n+\t\t caps->link_fec_options & ICE_AQC_PHY_FEC_25G_KR_REQ)\n+\t\tfec_req = \"FC-FEC/BASE-R\";\n+\telse\n+\t\tfec_req = \"NONE\";\n+\n+\tdevm_kfree(&vsi->back->pdev->dev, caps);\n+\n+done:\n+\tnetdev_info(vsi->netdev, \"NIC Link is up %sbps, Requested FEC: %s, FEC: %s, Flow Control: %s\\n\",\n+\t\t speed, fec_req, fec, fc);\n }\n \n /**\ndiff --git a/drivers/net/ethernet/intel/ice/ice_type.h b/drivers/net/ethernet/intel/ice/ice_type.h\nindex 0a0fa30a85bb..b6d0399f49b9 100644\n--- a/drivers/net/ethernet/intel/ice/ice_type.h\n+++ b/drivers/net/ethernet/intel/ice/ice_type.h\n@@ -61,6 +61,13 @@ enum ice_fc_mode {\n \tICE_FC_DFLT\n };\n \n+enum ice_fec_mode {\n+\tICE_FEC_NONE = 0,\n+\tICE_FEC_RS,\n+\tICE_FEC_BASER,\n+\tICE_FEC_AUTO\n+};\n+\n enum ice_set_fc_aq_failures {\n \tICE_SET_FC_AQ_FAIL_NONE = 0,\n \tICE_SET_FC_AQ_FAIL_GET,\n@@ -93,6 +100,7 @@ struct ice_link_status {\n \t/* Refer to ice_aq_phy_type for bits definition */\n \tu64 phy_type_low;\n \tu64 phy_type_high;\n+\tu8 topo_media_conflict;\n \tu16 max_frame_size;\n \tu16 link_speed;\n \tu16 req_speeds;\n@@ -100,6 +108,7 @@ struct ice_link_status {\n \tu8 link_info;\n \tu8 an_info;\n \tu8 ext_info;\n+\tu8 fec_info;\n \tu8 pacing;\n \t/* Refer to #define from module_type[ICE_MODULE_TYPE_TOTAL_BYTE] of\n \t * ice_aqc_get_phy_caps structure\n", "prefixes": [ "S21", "03/14" ] }