All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shannon Nelson <shannon.nelson@oracle.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 13/13 net-next] i40e: convert i40e_set_link_ksettings to new API
Date: Wed, 4 Oct 2017 16:47:18 -0700	[thread overview]
Message-ID: <513e49e8-d03d-0385-5123-cc8adfcfb829@oracle.com> (raw)
In-Reply-To: <20171004175839.28364-14-alan.brady@intel.com>

On 10/4/2017 10:58 AM, Alan Brady wrote:
> This finishes off the conversion to the new ethtool API by removing the
> old macros being used in i40e_set_link_ksettings and replacing them with
> shiny new ones.
> 
> This conversion also allows us to provide link speed support for new 25G
> and 10G macros which is included here as well.
> 
> Signed-off-by: Alan Brady <alan.brady@intel.com>
> ---
>   drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 94 ++++++++++++++++----------
>   1 file changed, 58 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> index f25cdd4cb860..489aecd3f5dc 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
> @@ -855,9 +855,7 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
>   	i40e_status status = 0;
>   	int timeout = 50;
>   	int err = 0;
> -	u32 autoneg;
> -	u32 advertise;
> -	u32 tmp;
> +	u8 autoneg;
>   
>   	/* Changing port settings is not supported if this isn't the
>   	 * port's controlling PF
> @@ -885,28 +883,35 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
>   	/* copy the ksettings to copy_ks to avoid modifying the origin */
>   	memcpy(&copy_ks, ks, sizeof(struct ethtool_link_ksettings));
>   
> +	/* save autoneg out of ksettings */
> +	autoneg = copy_ks.base.autoneg;
> +
> +	memset(&safe_ks, 0, sizeof(safe_ks));
> +	/* Get link modes supported by hardware... */
> +	i40e_phy_type_to_ethtool(pf, &safe_ks);
> +	/* ...and check against modes requested by user.
> +	 * Return an error if unsupported mode was set.
> +	 */

Please don't split this comment, it makes things harder to read.

sln

> +	if (!bitmap_subset(copy_ks.link_modes.advertising,
> +			   safe_ks.link_modes.supported,
> +			   __ETHTOOL_LINK_MODE_MASK_NBITS))
> +		return -EINVAL;
> +
>   	/* get our own copy of the bits to check against */
>   	memset(&safe_ks, 0, sizeof(struct ethtool_link_ksettings));
> +	safe_ks.base.cmd = copy_ks.base.cmd;
> +	safe_ks.base.link_mode_masks_nwords =
> +		copy_ks.base.link_mode_masks_nwords;
>   	i40e_get_link_ksettings(netdev, &safe_ks);
>   
> -	/* save autoneg and speed out of ksettings */
> -	autoneg = ks->base.autoneg;
> -	ethtool_convert_link_mode_to_legacy_u32(&advertise,
> -						ks->link_modes.advertising);
> -
> -	/* set autoneg and speed back to what they currently are */
> +	/* set autoneg back to what it currently is */
>   	copy_ks.base.autoneg = safe_ks.base.autoneg;
> -	ethtool_convert_link_mode_to_legacy_u32(
> -		&tmp, safe_ks.link_modes.advertising);
> -	ethtool_convert_legacy_u32_to_link_mode(
> -		copy_ks.link_modes.advertising, tmp);
>   
> -	copy_ks.base.cmd = safe_ks.base.cmd;
> -
> -	/* If copy_ks and safe_ks are not the same now, then they are
> -	 * trying to set something that we do not support
> +	/* If copy_ks.base and safe_ks.base are not the same now, then they are
> +	 * trying to set something that we do not support.
>   	 */
> -	if (memcmp(&copy_ks, &safe_ks, sizeof(struct ethtool_link_ksettings)))
> +	if (memcmp(&copy_ks.base, &safe_ks.base,
> +		   sizeof(struct ethtool_link_settings)))
>   		return -EOPNOTSUPP;
>   
>   	while (test_and_set_bit(__I40E_CONFIG_BUSY, pf->state)) {
> @@ -967,28 +972,45 @@ static int i40e_set_link_ksettings(struct net_device *netdev,
>   		}
>   	}
>   
> -	ethtool_convert_link_mode_to_legacy_u32(&tmp,
> -						safe_ks.link_modes.supported);
> -	if (advertise & ~tmp) {
> -		err = -EINVAL;
> -		goto done;
> -	}
> -
> -	if (advertise & ADVERTISED_100baseT_Full)
> +	if (ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  100baseT_Full))
>   		config.link_speed |= I40E_LINK_SPEED_100MB;
> -	if (advertise & ADVERTISED_1000baseT_Full ||
> -	    advertise & ADVERTISED_1000baseKX_Full)
> +	if (ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  1000baseT_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  1000baseX_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  1000baseKX_Full))
>   		config.link_speed |= I40E_LINK_SPEED_1GB;
> -	if (advertise & ADVERTISED_10000baseT_Full ||
> -	    advertise & ADVERTISED_10000baseKX4_Full ||
> -	    advertise & ADVERTISED_10000baseKR_Full)
> +	if (ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  10000baseT_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  10000baseKX4_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  10000baseKR_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  10000baseCR_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  10000baseSR_Full))
>   		config.link_speed |= I40E_LINK_SPEED_10GB;
> -	if (advertise & ADVERTISED_20000baseKR2_Full)
> +	if (ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  20000baseKR2_Full))
>   		config.link_speed |= I40E_LINK_SPEED_20GB;
> -	if (advertise & ADVERTISED_40000baseKR4_Full ||
> -	    advertise & ADVERTISED_40000baseCR4_Full ||
> -	    advertise & ADVERTISED_40000baseSR4_Full ||
> -	    advertise & ADVERTISED_40000baseLR4_Full)
> +	if (ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  25000baseCR_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  25000baseKR_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  25000baseSR_Full))
> +		config.link_speed |= I40E_LINK_SPEED_25GB;
> +	if (ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  40000baseKR4_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  40000baseCR4_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  40000baseSR4_Full) ||
> +	    ethtool_link_ksettings_test_link_mode(ks, advertising,
> +						  40000baseLR4_Full))
>   		config.link_speed |= I40E_LINK_SPEED_40GB;
>   
>   	/* If speed didn't get set, set it to what it currently is.
> 

      reply	other threads:[~2017-10-04 23:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 17:58 [Intel-wired-lan] [PATCH 00/13 net-next] i40e: refactor ethtool interface Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 01/13 net-next] i40e: rename 'cmd' variables in " Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 02/13 net-next] i40e: remove ifdef SPEED_25000 Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 03/13 net-next] i40e: add function header for i40e_get_rxfh Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 04/13 net-next] i40e: fix clearing link masks in i40e_get_link_ksettings Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 05/13 net-next] i40e: fix i40e_phy_type_to_ethtool function header Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 06/13 net-next] i40e: fix comment typo Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 07/13 net-next] i40e: fix whitespace issues in i40e_ethtool.c Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 08/13 net-next] i40e: group autoneg PHY types together Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 09/13 net-next] i40e: Add new phy types for 25G AOC and ACC support Alan Brady
2017-10-04 23:47   ` Shannon Nelson
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 10/13 net-next] i40e: convert i40e_phy_type_to_ethtool to new API Alan Brady
2017-10-04 23:47   ` Shannon Nelson
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 11/13 net-next] i40e: convert i40e_get_settings_link_up " Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 12/13 net-next] i40e: rename 'change' variable to 'autoneg_changed' Alan Brady
2017-10-04 17:58 ` [Intel-wired-lan] [PATCH 13/13 net-next] i40e: convert i40e_set_link_ksettings to new API Alan Brady
2017-10-04 23:47   ` Shannon Nelson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=513e49e8-d03d-0385-5123-cc8adfcfb829@oracle.com \
    --to=shannon.nelson@oracle.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.