diff options
Diffstat (limited to 'drivers/net/ethernet/intel/i40e/i40e_common.c')
| -rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_common.c | 111 | 
1 files changed, 63 insertions, 48 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c index 906cf68d3453..d37c6e0e5f08 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_common.c +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c @@ -1,6 +1,7 @@  // SPDX-License-Identifier: GPL-2.0  /* Copyright(c) 2013 - 2018 Intel Corporation. */ +#include "i40e.h"  #include "i40e_type.h"  #include "i40e_adminq.h"  #include "i40e_prototype.h" @@ -13,7 +14,7 @@   * This function sets the mac type of the adapter based on the   * vendor ID and device ID stored in the hw structure.   **/ -static i40e_status i40e_set_mac_type(struct i40e_hw *hw) +i40e_status i40e_set_mac_type(struct i40e_hw *hw)  {  	i40e_status status = 0; @@ -1577,19 +1578,22 @@ i40e_status i40e_aq_get_phy_capabilities(struct i40e_hw *hw,  		status = i40e_asq_send_command(hw, &desc, abilities,  					       abilities_size, cmd_details); -		if (status) -			break; - -		if (hw->aq.asq_last_status == I40E_AQ_RC_EIO) { +		switch (hw->aq.asq_last_status) { +		case I40E_AQ_RC_EIO:  			status = I40E_ERR_UNKNOWN_PHY;  			break; -		} else if (hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN) { +		case I40E_AQ_RC_EAGAIN:  			usleep_range(1000, 2000);  			total_delay++;  			status = I40E_ERR_TIMEOUT; +			break; +		/* also covers I40E_AQ_RC_OK */ +		default: +			break;  		} -	} while ((hw->aq.asq_last_status != I40E_AQ_RC_OK) && -		 (total_delay < max_delay)); + +	} while ((hw->aq.asq_last_status == I40E_AQ_RC_EAGAIN) && +		(total_delay < max_delay));  	if (status)  		return status; @@ -1643,25 +1647,15 @@ enum i40e_status_code i40e_aq_set_phy_config(struct i40e_hw *hw,  	return status;  } -/** - * i40e_set_fc - * @hw: pointer to the hw struct - * @aq_failures: buffer to return AdminQ failure information - * @atomic_restart: whether to enable atomic link restart - * - * Set the requested flow control mode using set_phy_config. - **/ -enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures, -				  bool atomic_restart) +static noinline_for_stack enum i40e_status_code +i40e_set_fc_status(struct i40e_hw *hw, +		   struct i40e_aq_get_phy_abilities_resp *abilities, +		   bool atomic_restart)  { -	enum i40e_fc_mode fc_mode = hw->fc.requested_mode; -	struct i40e_aq_get_phy_abilities_resp abilities;  	struct i40e_aq_set_phy_config config; -	enum i40e_status_code status; +	enum i40e_fc_mode fc_mode = hw->fc.requested_mode;  	u8 pause_mask = 0x0; -	*aq_failures = 0x0; -  	switch (fc_mode) {  	case I40E_FC_FULL:  		pause_mask |= I40E_AQ_PHY_FLAG_PAUSE_TX; @@ -1677,6 +1671,48 @@ enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,  		break;  	} +	memset(&config, 0, sizeof(struct i40e_aq_set_phy_config)); +	/* clear the old pause settings */ +	config.abilities = abilities->abilities & ~(I40E_AQ_PHY_FLAG_PAUSE_TX) & +			   ~(I40E_AQ_PHY_FLAG_PAUSE_RX); +	/* set the new abilities */ +	config.abilities |= pause_mask; +	/* If the abilities have changed, then set the new config */ +	if (config.abilities == abilities->abilities) +		return 0; + +	/* Auto restart link so settings take effect */ +	if (atomic_restart) +		config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK; +	/* Copy over all the old settings */ +	config.phy_type = abilities->phy_type; +	config.phy_type_ext = abilities->phy_type_ext; +	config.link_speed = abilities->link_speed; +	config.eee_capability = abilities->eee_capability; +	config.eeer = abilities->eeer_val; +	config.low_power_ctrl = abilities->d3_lpan; +	config.fec_config = abilities->fec_cfg_curr_mod_ext_info & +			    I40E_AQ_PHY_FEC_CONFIG_MASK; + +	return i40e_aq_set_phy_config(hw, &config, NULL); +} + +/** + * i40e_set_fc + * @hw: pointer to the hw struct + * @aq_failures: buffer to return AdminQ failure information + * @atomic_restart: whether to enable atomic link restart + * + * Set the requested flow control mode using set_phy_config. + **/ +enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures, +				  bool atomic_restart) +{ +	struct i40e_aq_get_phy_abilities_resp abilities; +	enum i40e_status_code status; + +	*aq_failures = 0x0; +  	/* Get the current phy config */  	status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities,  					      NULL); @@ -1685,31 +1721,10 @@ enum i40e_status_code i40e_set_fc(struct i40e_hw *hw, u8 *aq_failures,  		return status;  	} -	memset(&config, 0, sizeof(struct i40e_aq_set_phy_config)); -	/* clear the old pause settings */ -	config.abilities = abilities.abilities & ~(I40E_AQ_PHY_FLAG_PAUSE_TX) & -			   ~(I40E_AQ_PHY_FLAG_PAUSE_RX); -	/* set the new abilities */ -	config.abilities |= pause_mask; -	/* If the abilities have changed, then set the new config */ -	if (config.abilities != abilities.abilities) { -		/* Auto restart link so settings take effect */ -		if (atomic_restart) -			config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK; -		/* Copy over all the old settings */ -		config.phy_type = abilities.phy_type; -		config.phy_type_ext = abilities.phy_type_ext; -		config.link_speed = abilities.link_speed; -		config.eee_capability = abilities.eee_capability; -		config.eeer = abilities.eeer_val; -		config.low_power_ctrl = abilities.d3_lpan; -		config.fec_config = abilities.fec_cfg_curr_mod_ext_info & -				    I40E_AQ_PHY_FEC_CONFIG_MASK; -		status = i40e_aq_set_phy_config(hw, &config, NULL); +	status = i40e_set_fc_status(hw, &abilities, atomic_restart); +	if (status) +		*aq_failures |= I40E_SET_FC_AQ_FAIL_SET; -		if (status) -			*aq_failures |= I40E_SET_FC_AQ_FAIL_SET; -	}  	/* Update the link info */  	status = i40e_update_link_info(hw);  	if (status) { @@ -2537,7 +2552,7 @@ i40e_status i40e_get_link_status(struct i40e_hw *hw, bool *link_up)   * i40e_updatelink_status - update status of the HW network link   * @hw: pointer to the hw struct   **/ -i40e_status i40e_update_link_info(struct i40e_hw *hw) +noinline_for_stack i40e_status i40e_update_link_info(struct i40e_hw *hw)  {  	struct i40e_aq_get_phy_abilities_resp abilities;  	i40e_status status = 0;  |