xref: /linux/include/linux/ethtool_netlink.h (revision 49bda4826843be0ef97a162009a29ea3a63f3935)
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_PAUSE_STAT_CNT	(__ETHTOOL_A_PAUSE_STAT_CNT -		\
11 				 ETHTOOL_A_PAUSE_STAT_TX_FRAMES)
12 
13 enum ethtool_multicast_groups {
14 	ETHNL_MCGRP_MONITOR,
15 };
16 
17 struct phy_device;
18 
19 #if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
20 int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd);
21 void ethnl_cable_test_free(struct phy_device *phydev);
22 void ethnl_cable_test_finished(struct phy_device *phydev);
23 int ethnl_cable_test_result_with_src(struct phy_device *phydev, u8 pair,
24 				     u8 result, u32 src);
25 int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev, u8 pair,
26 					   u32 cm, u32 src);
27 int ethnl_cable_test_amplitude(struct phy_device *phydev, u8 pair, s16 mV);
28 int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV);
29 int ethnl_cable_test_step(struct phy_device *phydev, u32 first, u32 last,
30 			  u32 step);
31 void ethtool_aggregate_mac_stats(struct net_device *dev,
32 				 struct ethtool_eth_mac_stats *mac_stats);
33 void ethtool_aggregate_phy_stats(struct net_device *dev,
34 				 struct ethtool_eth_phy_stats *phy_stats);
35 void ethtool_aggregate_ctrl_stats(struct net_device *dev,
36 				  struct ethtool_eth_ctrl_stats *ctrl_stats);
37 void ethtool_aggregate_pause_stats(struct net_device *dev,
38 				   struct ethtool_pause_stats *pause_stats);
39 void ethtool_aggregate_rmon_stats(struct net_device *dev,
40 				  struct ethtool_rmon_stats *rmon_stats);
41 bool ethtool_dev_mm_supported(struct net_device *dev);
42 
43 void ethnl_pse_send_ntf(struct net_device *netdev, unsigned long notif);
44 
45 #else
ethnl_cable_test_alloc(struct phy_device * phydev,u8 cmd)46 static inline int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd)
47 {
48 	return -EOPNOTSUPP;
49 }
50 
ethnl_cable_test_free(struct phy_device * phydev)51 static inline void ethnl_cable_test_free(struct phy_device *phydev)
52 {
53 }
54 
ethnl_cable_test_finished(struct phy_device * phydev)55 static inline void ethnl_cable_test_finished(struct phy_device *phydev)
56 {
57 }
ethnl_cable_test_result_with_src(struct phy_device * phydev,u8 pair,u8 result,u32 src)58 static inline int ethnl_cable_test_result_with_src(struct phy_device *phydev,
59 						   u8 pair, u8 result, u32 src)
60 {
61 	return -EOPNOTSUPP;
62 }
63 
ethnl_cable_test_fault_length_with_src(struct phy_device * phydev,u8 pair,u32 cm,u32 src)64 static inline int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev,
65 							 u8 pair, u32 cm, u32 src)
66 {
67 	return -EOPNOTSUPP;
68 }
69 
ethnl_cable_test_amplitude(struct phy_device * phydev,u8 pair,s16 mV)70 static inline int ethnl_cable_test_amplitude(struct phy_device *phydev,
71 					     u8 pair, s16 mV)
72 {
73 	return -EOPNOTSUPP;
74 }
75 
ethnl_cable_test_pulse(struct phy_device * phydev,u16 mV)76 static inline int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV)
77 {
78 	return -EOPNOTSUPP;
79 }
80 
ethnl_cable_test_step(struct phy_device * phydev,u32 first,u32 last,u32 step)81 static inline int ethnl_cable_test_step(struct phy_device *phydev, u32 first,
82 					u32 last, u32 step)
83 {
84 	return -EOPNOTSUPP;
85 }
86 
87 static inline void
ethtool_aggregate_mac_stats(struct net_device * dev,struct ethtool_eth_mac_stats * mac_stats)88 ethtool_aggregate_mac_stats(struct net_device *dev,
89 			    struct ethtool_eth_mac_stats *mac_stats)
90 {
91 }
92 
93 static inline void
ethtool_aggregate_phy_stats(struct net_device * dev,struct ethtool_eth_phy_stats * phy_stats)94 ethtool_aggregate_phy_stats(struct net_device *dev,
95 			    struct ethtool_eth_phy_stats *phy_stats)
96 {
97 }
98 
99 static inline void
ethtool_aggregate_ctrl_stats(struct net_device * dev,struct ethtool_eth_ctrl_stats * ctrl_stats)100 ethtool_aggregate_ctrl_stats(struct net_device *dev,
101 			     struct ethtool_eth_ctrl_stats *ctrl_stats)
102 {
103 }
104 
105 static inline void
ethtool_aggregate_pause_stats(struct net_device * dev,struct ethtool_pause_stats * pause_stats)106 ethtool_aggregate_pause_stats(struct net_device *dev,
107 			      struct ethtool_pause_stats *pause_stats)
108 {
109 }
110 
111 static inline void
ethtool_aggregate_rmon_stats(struct net_device * dev,struct ethtool_rmon_stats * rmon_stats)112 ethtool_aggregate_rmon_stats(struct net_device *dev,
113 			     struct ethtool_rmon_stats *rmon_stats)
114 {
115 }
116 
ethtool_dev_mm_supported(struct net_device * dev)117 static inline bool ethtool_dev_mm_supported(struct net_device *dev)
118 {
119 	return false;
120 }
121 
ethnl_pse_send_ntf(struct net_device * netdev,unsigned long notif)122 static inline void ethnl_pse_send_ntf(struct net_device *netdev,
123 				      unsigned long notif)
124 {
125 }
126 
127 #endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */
128 
ethnl_cable_test_result(struct phy_device * phydev,u8 pair,u8 result)129 static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
130 					  u8 result)
131 {
132 	return ethnl_cable_test_result_with_src(phydev, pair, result,
133 						ETHTOOL_A_CABLE_INF_SRC_TDR);
134 }
135 
ethnl_cable_test_fault_length(struct phy_device * phydev,u8 pair,u32 cm)136 static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
137 						u8 pair, u32 cm)
138 {
139 	return ethnl_cable_test_fault_length_with_src(phydev, pair, cm,
140 						      ETHTOOL_A_CABLE_INF_SRC_TDR);
141 }
142 
143 #endif /* _LINUX_ETHTOOL_NETLINK_H_ */
144