diff mbox series

[net-next,4/6] net: hns3: add support for set_link_ksettings

Message ID 1509682710-94908-5-git-send-email-lipeng321@huawei.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series net: hns3: support set_link_ksettings and for nway_reset ethtool command | expand

Commit Message

lipeng (Y) Nov. 3, 2017, 4:18 a.m. UTC
From: Fuyun Liang <liangfuyun1@huawei.com>

This patch adds set_link_ksettings support for ethtool cmd.

Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
Signed-off-by: Lipeng <lipeng321@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Florian Fainelli Nov. 3, 2017, 7:52 p.m. UTC | #1
On 11/02/2017 09:18 PM, Lipeng wrote:
> From: Fuyun Liang <liangfuyun1@huawei.com>
> 
> This patch adds set_link_ksettings support for ethtool cmd.
> 
> Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
> Signed-off-by: Lipeng <lipeng321@huawei.com>
> ---
>  drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
> index c7b8ebd..7fe193b 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
> @@ -653,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
>  	return 0;
>  }
>  
> +static int hns3_set_link_ksettings(struct net_device *netdev,
> +				   const struct ethtool_link_ksettings *cmd)
> +{
> +	/* Only support ksettings_set for netdev with phy attached for now */
> +	if (netdev->phydev)
> +		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
> +
> +	return -EOPNOTSUPP;

Consider using phy_ethtool_get_link_ksettings() which already checks for
netdev->phydev.
lipeng (Y) Nov. 6, 2017, 2:28 a.m. UTC | #2
On 2017/11/4 3:52, Florian Fainelli wrote:
> On 11/02/2017 09:18 PM, Lipeng wrote:
>> From: Fuyun Liang <liangfuyun1@huawei.com>
>>
>> This patch adds set_link_ksettings support for ethtool cmd.
>>
>> Signed-off-by: Fuyun Liang <liangfuyun1@huawei.com>
>> Signed-off-by: Lipeng <lipeng321@huawei.com>
>> ---
>>   drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
>> index c7b8ebd..7fe193b 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
>> @@ -653,6 +653,16 @@ static int hns3_get_link_ksettings(struct net_device *netdev,
>>   	return 0;
>>   }
>>   
>> +static int hns3_set_link_ksettings(struct net_device *netdev,
>> +				   const struct ethtool_link_ksettings *cmd)
>> +{
>> +	/* Only support ksettings_set for netdev with phy attached for now */
>> +	if (netdev->phydev)
>> +		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
>> +
>> +	return -EOPNOTSUPP;
> Consider using phy_ethtool_get_link_ksettings() which already checks for
> netdev->phydev.
agree, Thanks for your comment.

as this patch has been applied to  net-next, we will push another 
cleanup patch.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
index c7b8ebd..7fe193b 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_ethtool.c
@@ -653,6 +653,16 @@  static int hns3_get_link_ksettings(struct net_device *netdev,
 	return 0;
 }
 
+static int hns3_set_link_ksettings(struct net_device *netdev,
+				   const struct ethtool_link_ksettings *cmd)
+{
+	/* Only support ksettings_set for netdev with phy attached for now */
+	if (netdev->phydev)
+		return phy_ethtool_ksettings_set(netdev->phydev, cmd);
+
+	return -EOPNOTSUPP;
+}
+
 static u32 hns3_get_rss_key_size(struct net_device *netdev)
 {
 	struct hnae3_handle *h = hns3_get_handle(netdev);
@@ -839,6 +849,7 @@  static int hns3_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 	.get_rxfh = hns3_get_rss,
 	.set_rxfh = hns3_set_rss,
 	.get_link_ksettings = hns3_get_link_ksettings,
+	.set_link_ksettings = hns3_set_link_ksettings,
 };
 
 void hns3_ethtool_set_ops(struct net_device *netdev)