1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #ifndef _LINUX_ETHTOOL_NETLINK_H_
4 #define _LINUX_ETHTOOL_NETLINK_H_
5 
6 #include <uapi/linux/ethtool_netlink.h>
7 #include <linux/ethtool.h>
8 #include <linux/netdevice.h>
9 
10 #define __ETHTOOL_LINK_MODE_MASK_NWORDS \
11 	DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)
12 
13 #define ETHTOOL_PAUSE_STAT_CNT	(__ETHTOOL_A_PAUSE_STAT_CNT -		\
14 				 ETHTOOL_A_PAUSE_STAT_TX_FRAMES)
15 
16 enum ethtool_multicast_groups {
17 	ETHNL_MCGRP_MONITOR,
18 };
19 
20 struct phy_device;
21 
22 #if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
23 int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd);
24 void ethnl_cable_test_free(struct phy_device *phydev);
25 void ethnl_cable_test_finished(struct phy_device *phydev);
26 int ethnl_cable_test_result(struct phy_device *phydev, u8 pair, u8 result);
27 int ethnl_cable_test_fault_length(struct phy_device *phydev, u8 pair, u32 cm);
28 int ethnl_cable_test_amplitude(struct phy_device *phydev, u8 pair, s16 mV);
29 int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV);
30 int ethnl_cable_test_step(struct phy_device *phydev, u32 first, u32 last,
31 			  u32 step);
32 void ethtool_aggregate_mac_stats(struct net_device *dev,
33 				 struct ethtool_eth_mac_stats *mac_stats);
34 void ethtool_aggregate_phy_stats(struct net_device *dev,
35 				 struct ethtool_eth_phy_stats *phy_stats);
36 void ethtool_aggregate_ctrl_stats(struct net_device *dev,
37 				  struct ethtool_eth_ctrl_stats *ctrl_stats);
38 void ethtool_aggregate_pause_stats(struct net_device *dev,
39 				   struct ethtool_pause_stats *pause_stats);
40 void ethtool_aggregate_rmon_stats(struct net_device *dev,
41 				  struct ethtool_rmon_stats *rmon_stats);
42 
43 #else
ethnl_cable_test_alloc(struct phy_device * phydev,u8 cmd)44 static inline int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd)
45 {
46 	return -EOPNOTSUPP;
47 }
48 
ethnl_cable_test_free(struct phy_device * phydev)49 static inline void ethnl_cable_test_free(struct phy_device *phydev)
50 {
51 }
52 
ethnl_cable_test_finished(struct phy_device * phydev)53 static inline void ethnl_cable_test_finished(struct phy_device *phydev)
54 {
55 }
ethnl_cable_test_result(struct phy_device * phydev,u8 pair,u8 result)56 static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
57 					  u8 result)
58 {
59 	return -EOPNOTSUPP;
60 }
61 
ethnl_cable_test_fault_length(struct phy_device * phydev,u8 pair,u32 cm)62 static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
63 						u8 pair, u32 cm)
64 {
65 	return -EOPNOTSUPP;
66 }
67 
ethnl_cable_test_amplitude(struct phy_device * phydev,u8 pair,s16 mV)68 static inline int ethnl_cable_test_amplitude(struct phy_device *phydev,
69 					     u8 pair, s16 mV)
70 {
71 	return -EOPNOTSUPP;
72 }
73 
ethnl_cable_test_pulse(struct phy_device * phydev,u16 mV)74 static inline int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV)
75 {
76 	return -EOPNOTSUPP;
77 }
78 
ethnl_cable_test_step(struct phy_device * phydev,u32 first,u32 last,u32 step)79 static inline int ethnl_cable_test_step(struct phy_device *phydev, u32 first,
80 					u32 last, u32 step)
81 {
82 	return -EOPNOTSUPP;
83 }
84 
85 static inline void
ethtool_aggregate_mac_stats(struct net_device * dev,struct ethtool_eth_mac_stats * mac_stats)86 ethtool_aggregate_mac_stats(struct net_device *dev,
87 			    struct ethtool_eth_mac_stats *mac_stats)
88 {
89 }
90 
91 static inline void
ethtool_aggregate_phy_stats(struct net_device * dev,struct ethtool_eth_phy_stats * phy_stats)92 ethtool_aggregate_phy_stats(struct net_device *dev,
93 			    struct ethtool_eth_phy_stats *phy_stats)
94 {
95 }
96 
97 static inline void
ethtool_aggregate_ctrl_stats(struct net_device * dev,struct ethtool_eth_ctrl_stats * ctrl_stats)98 ethtool_aggregate_ctrl_stats(struct net_device *dev,
99 			     struct ethtool_eth_ctrl_stats *ctrl_stats)
100 {
101 }
102 
103 static inline void
ethtool_aggregate_pause_stats(struct net_device * dev,struct ethtool_pause_stats * pause_stats)104 ethtool_aggregate_pause_stats(struct net_device *dev,
105 			      struct ethtool_pause_stats *pause_stats)
106 {
107 }
108 
109 static inline void
ethtool_aggregate_rmon_stats(struct net_device * dev,struct ethtool_rmon_stats * rmon_stats)110 ethtool_aggregate_rmon_stats(struct net_device *dev,
111 			     struct ethtool_rmon_stats *rmon_stats)
112 {
113 }
114 
115 #endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */
116 #endif /* _LINUX_ETHTOOL_NETLINK_H_ */
117