xref: /linux/drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c (revision 0e2b2a76278153d1ac312b0691cb65dabb9aef3e)
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2015 - 2023 Beijing WangXun Technology Co., Ltd. */
3 
4 #include <linux/pci.h>
5 #include <linux/phylink.h>
6 #include <linux/netdevice.h>
7 
8 #include "../libwx/wx_ethtool.h"
9 #include "../libwx/wx_type.h"
10 #include "txgbe_type.h"
11 #include "txgbe_ethtool.h"
12 
13 static int txgbe_nway_reset(struct net_device *netdev)
14 {
15 	struct txgbe *txgbe = netdev_to_txgbe(netdev);
16 
17 	return phylink_ethtool_nway_reset(txgbe->phylink);
18 }
19 
20 static int txgbe_get_link_ksettings(struct net_device *netdev,
21 				    struct ethtool_link_ksettings *cmd)
22 {
23 	struct txgbe *txgbe = netdev_to_txgbe(netdev);
24 
25 	return phylink_ethtool_ksettings_get(txgbe->phylink, cmd);
26 }
27 
28 static int txgbe_set_link_ksettings(struct net_device *netdev,
29 				    const struct ethtool_link_ksettings *cmd)
30 {
31 	struct txgbe *txgbe = netdev_to_txgbe(netdev);
32 
33 	return phylink_ethtool_ksettings_set(txgbe->phylink, cmd);
34 }
35 
36 static const struct ethtool_ops txgbe_ethtool_ops = {
37 	.get_drvinfo		= wx_get_drvinfo,
38 	.nway_reset		= txgbe_nway_reset,
39 	.get_link		= ethtool_op_get_link,
40 	.get_link_ksettings	= txgbe_get_link_ksettings,
41 	.set_link_ksettings	= txgbe_set_link_ksettings,
42 };
43 
44 void txgbe_set_ethtool_ops(struct net_device *netdev)
45 {
46 	netdev->ethtool_ops = &txgbe_ethtool_ops;
47 }
48