From patchwork Fri Oct 13 11:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Loktionov X-Patchwork-Id: 13420800 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A818213FF6 for ; Fri, 13 Oct 2023 11:52:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DBUqKbSx" Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E6DCF3 for ; Fri, 13 Oct 2023 04:52:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697197968; x=1728733968; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=L2yLlOc8vB7BKM7ZbneI4WcA5LmAwEXyptbf0TpYHOg=; b=DBUqKbSxxJXKl+/arVKUMtqsjkTL/3RNRB7TbwjqTj/gKUywLvQKwKer BeCgYfq2IuUKY7fTAiqcdaSEpQ7bu3XNkZYb4vaTjteMBvE7bO8QeKBWW AI08vGtQQd3I2IwHDAbRHuHqJoUJOAPewT/kVZPDnthSwq8QUovh9y8OM ZlmZzL85g7BgxhypJA4Qn4R9uutcE8hBCLRiTSZssWRitnfRHb1cleTIG a3/ivkVPn1ooe2kzIVSDkf82rkwG8hB/qBNS6NE2xRiuRubVJe71B4nhS q9IR6VEcsr+mz/o80FvoS2j2Loj9EQ0TdmrmCvuDvDRLu3VWOBt3WDVAc Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="451636878" X-IronPort-AV: E=Sophos;i="6.03,222,1694761200"; d="scan'208";a="451636878" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2023 04:52:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10861"; a="845446270" X-IronPort-AV: E=Sophos;i="6.03,222,1694761200"; d="scan'208";a="845446270" Received: from unknown (HELO amlin-019-225.igk.intel.com) ([10.102.19.225]) by FMSMGA003.fm.intel.com with ESMTP; 13 Oct 2023 04:52:46 -0700 From: Aleksandr Loktionov To: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com, aleksandr.loktionov@intel.com, jedrzej.jagielski@intel.com Cc: netdev@vger.kernel.org Subject: [PATCH iwl-next v5] i40e: add restore default speed when changed PHY doesn't support it Date: Fri, 13 Oct 2023 13:52:45 +0200 Message-Id: <20231013115245.1517606-1-aleksandr.loktionov@intel.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Currently, there was no link after plugging a different type of PHY module if user forced previous PHY specific link type/speed before. Add reset link speed settings to the default values for PHY module, if different PHY module is inserted and currently defined user-specified speed is not compatible with this module. Co-developed-by: Radoslaw Tyl Signed-off-by: Radoslaw Tyl Reviewed-by: Jedrzej Jagielski Signed-off-by: Aleksandr Loktionov --- v1->v2 fixed Reviewed-by tags v2->v3 fixed commit messages and tags v3->v4 fixed commit message typo v4->v5 cc to netdev@vger.kernel.org --- --- drivers/net/ethernet/intel/i40e/i40e_main.c | 65 +++++++++++++++++++-- 1 file changed, 61 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index d0d0218..6829720 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -10076,6 +10076,55 @@ static void i40e_reset_subtask(struct i40e_pf *pf) rtnl_unlock(); } +/** + * i40e_restore_supported_phy_link_speed - Restore default PHY speed + * @pf: board private structure + * + * Set PHY module speeds according to values got from + * initial link speed abilites. + **/ +static int i40e_restore_supported_phy_link_speed(struct i40e_pf *pf) +{ + struct i40e_aq_get_phy_abilities_resp abilities; + struct i40e_aq_set_phy_config config = {0}; + struct i40e_hw *hw = &pf->hw; + int err; + + err = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, NULL); + if (err) { + dev_dbg(&pf->pdev->dev, "failed to get phy cap., ret = %i last_status = %s\n", + err, i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); + return err; + } + config.eee_capability = abilities.eee_capability; + config.phy_type_ext = abilities.phy_type_ext; + config.low_power_ctrl = abilities.d3_lpan; + config.abilities = abilities.abilities; + config.abilities |= I40E_AQ_PHY_ENABLE_AN; + config.phy_type = abilities.phy_type; + config.eeer = abilities.eeer_val; + config.fec_config = abilities.fec_cfg_curr_mod_ext_info & + I40E_AQ_PHY_FEC_CONFIG_MASK; + err = i40e_aq_get_phy_capabilities(hw, false, true, &abilities, NULL); + if (err) { + dev_dbg(&pf->pdev->dev, "get supported phy types ret = %i last_status = %s\n", + err, i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); + return err; + } + config.link_speed = abilities.link_speed; + + err = i40e_aq_set_phy_config(hw, &config, NULL); + if (err) + return err; + err = i40e_aq_set_link_restart_an(hw, true, NULL); + if (err) + return err; + + pf->hw.phy.link_info.requested_speeds = config.link_speed; + + return err; +} + /** * i40e_handle_link_event - Handle link event * @pf: board private structure @@ -10086,6 +10135,7 @@ static void i40e_handle_link_event(struct i40e_pf *pf, { struct i40e_aqc_get_link_status *status = (struct i40e_aqc_get_link_status *)&e->desc.params.raw; + int err; /* Do a new status request to re-enable LSE reporting * and load new status information into the hw struct @@ -10109,10 +10159,17 @@ static void i40e_handle_link_event(struct i40e_pf *pf, (!(status->an_info & I40E_AQ_QUALIFIED_MODULE)) && (!(status->link_info & I40E_AQ_LINK_UP)) && (!(pf->flags & I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED))) { - dev_err(&pf->pdev->dev, - "Rx/Tx is disabled on this device because an unsupported SFP module type was detected.\n"); - dev_err(&pf->pdev->dev, - "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for a list of supported modules.\n"); + err = i40e_restore_supported_phy_link_speed(pf); + if (err) { + dev_err(&pf->pdev->dev, + "Rx/Tx is disabled on this device because an unsupported SFP module type was detected.\n"); + dev_err(&pf->pdev->dev, + "Refer to the Intel(R) Ethernet Adapters and Devices User Guide for a list of supported modules.\n"); + + return; + } + + dev_info(&pf->pdev->dev, "The selected speed is incompatible with the connected media type. Resetting to the default speed setting for the media type."); } } }