* [v2,net-next,18/21] net: usb: aqc111: Implement get/set_link_ksettings callbacks
@ 2018-11-13 14:45 Igor Russkikh
0 siblings, 0 replies; 3+ messages in thread
From: Igor Russkikh @ 2018-11-13 14:45 UTC (permalink / raw)
To: David S . Miller
Cc: linux-usb@vger.kernel.org, netdev@vger.kernel.org,
Dmitry Bezrukov, Igor Russkikh
From: Dmitry Bezrukov <dmitry.bezrukov@aquantia.com>
Signed-off-by: Dmitry Bezrukov <dmitry.bezrukov@aquantia.com>
Signed-off-by: Igor Russkikh <igor.russkikh@aquantia.com>
---
drivers/net/usb/aqc111.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
diff --git a/drivers/net/usb/aqc111.c b/drivers/net/usb/aqc111.c
index b3160b0320eb..80fedf2ab2dd 100644
--- a/drivers/net/usb/aqc111.c
+++ b/drivers/net/usb/aqc111.c
@@ -209,6 +209,85 @@ static void aqc111_get_drvinfo(struct net_device *net,
info->regdump_len = 0x00;
}
+static void aqc111_speed_to_link_mode(u32 speed,
+ struct ethtool_link_ksettings *elk)
+{
+ switch (speed) {
+ case SPEED_5000:
+ ethtool_link_ksettings_add_link_mode(elk, advertising,
+ 5000baseT_Full);
+ break;
+ case SPEED_2500:
+ ethtool_link_ksettings_add_link_mode(elk, advertising,
+ 2500baseT_Full);
+ break;
+ case SPEED_1000:
+ ethtool_link_ksettings_add_link_mode(elk, advertising,
+ 1000baseT_Full);
+ break;
+ case SPEED_100:
+ ethtool_link_ksettings_add_link_mode(elk, advertising,
+ 100baseT_Full);
+ break;
+ }
+}
+
+static int aqc111_get_link_ksettings(struct net_device *net,
+ struct ethtool_link_ksettings *elk)
+{
+ struct usbnet *dev = netdev_priv(net);
+ struct aqc111_data *aqc111_data = dev->driver_priv;
+ enum usb_device_speed usb_speed = dev->udev->speed;
+ u32 speed = SPEED_UNKNOWN;
+
+ ethtool_link_ksettings_zero_link_mode(elk, supported);
+ ethtool_link_ksettings_add_link_mode(elk, supported,
+ 100baseT_Full);
+ ethtool_link_ksettings_add_link_mode(elk, supported,
+ 1000baseT_Full);
+ if (usb_speed == USB_SPEED_SUPER) {
+ ethtool_link_ksettings_add_link_mode(elk, supported,
+ 2500baseT_Full);
+ ethtool_link_ksettings_add_link_mode(elk, supported,
+ 5000baseT_Full);
+ }
+ ethtool_link_ksettings_add_link_mode(elk, supported, TP);
+ ethtool_link_ksettings_add_link_mode(elk, supported, Autoneg);
+
+ elk->base.port = PORT_TP;
+ elk->base.transceiver = XCVR_INTERNAL;
+
+ elk->base.mdio_support = 0x00; /*Not supported*/
+
+ if (aqc111_data->autoneg)
+ bitmap_copy(elk->link_modes.advertising,
+ elk->link_modes.supported,
+ __ETHTOOL_LINK_MODE_MASK_NBITS);
+ else
+ aqc111_speed_to_link_mode(aqc111_data->advertised_speed, elk);
+
+ elk->base.autoneg = aqc111_data->autoneg;
+
+ switch (aqc111_data->link_speed) {
+ case AQ_INT_SPEED_5G:
+ speed = SPEED_5000;
+ break;
+ case AQ_INT_SPEED_2_5G:
+ speed = SPEED_2500;
+ break;
+ case AQ_INT_SPEED_1G:
+ speed = SPEED_1000;
+ break;
+ case AQ_INT_SPEED_100M:
+ speed = SPEED_100;
+ break;
+ }
+ elk->base.duplex = DUPLEX_FULL;
+ elk->base.speed = speed;
+
+ return 0;
+}
+
static void aqc111_set_phy_speed_fw_iface(struct usbnet *dev,
struct aqc111_data *aqc111_data)
{
@@ -325,11 +404,56 @@ static void aqc111_set_phy_speed(struct usbnet *dev, u8 autoneg, u16 speed)
aqc111_set_phy_speed_fw_iface(dev, aqc111_data);
}
+static int aqc111_set_link_ksettings(struct net_device *net,
+ const struct ethtool_link_ksettings *elk)
+{
+ struct usbnet *dev = netdev_priv(net);
+ struct aqc111_data *aqc111_data = dev->driver_priv;
+ enum usb_device_speed usb_speed = dev->udev->speed;
+ u8 autoneg = elk->base.autoneg;
+ u32 speed = elk->base.speed;
+
+ 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 (elk->base.duplex != DUPLEX_FULL)
+ return -EINVAL;
+
+ if (usb_speed != USB_SPEED_SUPER && speed > SPEED_1000)
+ return -EINVAL;
+
+ 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;
+}
+
static const struct ethtool_ops aqc111_ethtool_ops = {
.get_drvinfo = aqc111_get_drvinfo,
.get_msglevel = usbnet_get_msglevel,
.set_msglevel = usbnet_set_msglevel,
.get_link = ethtool_op_get_link,
+ .get_link_ksettings = aqc111_get_link_ksettings,
+ .set_link_ksettings = aqc111_set_link_ksettings
};
static int aqc111_change_mtu(struct net_device *net, int new_mtu)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [v2,net-next,18/21] net: usb: aqc111: Implement get/set_link_ksettings callbacks
@ 2018-11-13 20:50 Andrew Lunn
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2018-11-13 20:50 UTC (permalink / raw)
To: Igor Russkikh
Cc: David S . Miller, linux-usb@vger.kernel.org,
netdev@vger.kernel.org, Dmitry Bezrukov
On Tue, Nov 13, 2018 at 02:45:13PM +0000, Igor Russkikh wrote:
> +static int aqc111_get_link_ksettings(struct net_device *net,
> + struct ethtool_link_ksettings *elk)
> +{
> + struct usbnet *dev = netdev_priv(net);
> + struct aqc111_data *aqc111_data = dev->driver_priv;
> + enum usb_device_speed usb_speed = dev->udev->speed;
> + u32 speed = SPEED_UNKNOWN;
> +
> + ethtool_link_ksettings_zero_link_mode(elk, supported);
> + ethtool_link_ksettings_add_link_mode(elk, supported,
> + 100baseT_Full);
> + ethtool_link_ksettings_add_link_mode(elk, supported,
> + 1000baseT_Full);
> + if (usb_speed == USB_SPEED_SUPER) {
> + ethtool_link_ksettings_add_link_mode(elk, supported,
> + 2500baseT_Full);
> + ethtool_link_ksettings_add_link_mode(elk, supported,
> + 5000baseT_Full);
> + }
Hi Igor
We discussed this with the first version of the patches. I think you
should add a comment explaining why 2.5G and 5G is disabled unless
Super speed is available.
> + if (aqc111_data->autoneg)
> + bitmap_copy(elk->link_modes.advertising,
> + elk->link_modes.supported,
> + __ETHTOOL_LINK_MODE_MASK_NBITS);
linkmode_copy(). It is quite new, so you probably don't know about it.
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* [v2,net-next,18/21] net: usb: aqc111: Implement get/set_link_ksettings callbacks
@ 2018-11-14 7:46 Igor Russkikh
0 siblings, 0 replies; 3+ messages in thread
From: Igor Russkikh @ 2018-11-14 7:46 UTC (permalink / raw)
To: Andrew Lunn
Cc: David S . Miller, linux-usb@vger.kernel.org,
netdev@vger.kernel.org, Dmitry Bezrukov
>> + if (usb_speed == USB_SPEED_SUPER) {
>> + ethtool_link_ksettings_add_link_mode(elk, supported,
>> + 2500baseT_Full);
>> + ethtool_link_ksettings_add_link_mode(elk, supported,
>> + 5000baseT_Full);
>> + }
>
> Hi Igor
>
> We discussed this with the first version of the patches. I think you
> should add a comment explaining why 2.5G and 5G is disabled unless
> Super speed is available.
Right, I've explained that to you but forgot to add a comment here.
>> + if (aqc111_data->autoneg)
>> + bitmap_copy(elk->link_modes.advertising,
>> + elk->link_modes.supported,
>> + __ETHTOOL_LINK_MODE_MASK_NBITS);
>
> linkmode_copy(). It is quite new, so you probably don't know about it.
Ok,
Regards,
Igor
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-14 7:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-13 20:50 [v2,net-next,18/21] net: usb: aqc111: Implement get/set_link_ksettings callbacks Andrew Lunn
-- strict thread matches above, loose matches on Subject: below --
2018-11-14 7:46 Igor Russkikh
2018-11-13 14:45 Igor Russkikh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).