Re: [PATCH net v2] net: phy: aquantia: Introduce custom get_features

From: Abhishek Chauhan (ABC)
Date: Tue Sep 24 2024 - 11:19:34 EST




On 9/24/2024 1:46 AM, Przemek Kitszel wrote:
> On 9/24/24 07:52, Abhishek Chauhan wrote:
>> Remove the use of phy_set_max_speed in phy driver as the
>> function is mainly used in MAC driver to set the max
>> speed.
>>
>> Introduce custom get_features for AQR family of chipsets
>>
>> 1. such as AQR111/B0/114c which supports speeds up to 5Gbps
>> 2. such as AQR115c/AQCS109 which supports speeds up to 2.5Gbps
>>
>> Fixes: 038ba1dc4e54 ("net: phy: aquantia: add AQR111 and AQR111B0 PHY ID")
>> Fixes: 0974f1f03b07 ("net: phy: aquantia: remove false 5G and 10G speed ability for AQCS109")
>> Fixes: c278ec644377 ("net: phy: aquantia: add support for AQR114C PHY ID")
>> Fixes: 0ebc581f8a4b ("net: phy: aquantia: add support for aqr115c")
>> Link: https://lore.kernel.org/all/20240913011635.1286027-1-quic_abchauha@xxxxxxxxxxx/T/
>> Signed-off-by: Abhishek Chauhan <quic_abchauha@xxxxxxxxxxx>
>
> I'm not sure if this patch is -net material
>
>> +static void aqr_supported_speed(struct phy_device *phydev, u32 max_speed)
>> +{
>> +    __ETHTOOL_DECLARE_LINK_MODE_MASK(supported) = { 0, };
>> +
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_Pause_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_Asym_Pause_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_TP_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Half_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_10baseT_Full_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Half_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Half_BIT, supported);
>> +    linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, supported);
>> +
>> +    if (max_speed == SPEED_2500) {
>> +        linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, supported);
>> +        linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, supported);
>> +    } else if (max_speed == SPEED_5000) {
>> +        linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, supported);
>> +        linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, supported);
>> +        linkmode_set_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, supported);
>> +    }
>
> instead of duplicating, just make the lists incremental:
>
>     if (max_speed >= SPEED_2500) {
>         linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseX_Full_BIT, supported);
>         linkmode_set_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, supported);
>     }
>     if (max_speed >= SPEED_5000)
>         linkmode_set_bit(ETHTOOL_LINK_MODE_5000baseT_Full_BIT, supported);
>
I will try to optimize this in the upcoming patches based on your suggestion.
>> +
>> +    linkmode_copy(phydev->supported, supported);
>> +}