Subject: Re: [PATCH net-next 18/19] net: usb: aqc111: Implement get/set_link_ksettings callbacks

From: Andrew Lunn <[email-masked]>
Date: Sat, 6 Oct 2018 19:38:47 +0200

> +static int aqc111_set_link_ksettings(struct net_device *net,
> +				     const struct ethtool_link_ksettings *elk)
> +{
> +	struct usbnet *dev = netdev_priv(net);
> +	enum usb_device_speed usb_speed = dev->udev->speed;
> +	struct aqc111_data *aqc111_data = (struct aqc111_data *)dev->data[0];
> +	u32 speed = elk->base.speed;
> +	u8 autoneg = elk->base.autoneg;
> +
> +	if (autoneg == AUTONEG_ENABLE) {
> +		if (aqc111_data->autoneg != AUTONEG_ENABLE) {
> +			aqc111_data->autoneg = AUTONEG_ENABLE;
> +			aqc111_data->advertised_speed =
> +					(usb_speed == USB_SPEED_SUPER) ?
> +					 SPEED_5000 : SPEED_1000;
> +			aqc111_set_phy_speed(dev, aqc111_data->autoneg,
> +					     aqc111_data->advertised_speed);
> +		}
> +	} else {
> +		if (speed != SPEED_100 &&
> +		    speed != SPEED_1000 &&
> +		    speed != SPEED_2500 &&
> +		    speed != SPEED_5000 &&
> +		    speed != SPEED_UNKNOWN)
> +			return -EINVAL;
> +
> +		if (usb_speed != USB_SPEED_SUPER && speed > SPEED_1000)
> +			return -EINVAL;
> +

Hi Igor

Maybe you are missing a check for duplex here?

> +		aqc111_data->autoneg = AUTONEG_DISABLE;
> +		if (speed != SPEED_UNKNOWN)
> +			aqc111_data->advertised_speed = speed;
> +
> +		aqc111_set_phy_speed(dev, aqc111_data->autoneg,
> +				     aqc111_data->advertised_speed);
> +	}
> +
> +	return 0;
> +}
> +