12b4a8990SMichal Kubecek /* SPDX-License-Identifier: GPL-2.0-only */
22b4a8990SMichal Kubecek 
32b4a8990SMichal Kubecek #ifndef _LINUX_ETHTOOL_NETLINK_H_
42b4a8990SMichal Kubecek #define _LINUX_ETHTOOL_NETLINK_H_
52b4a8990SMichal Kubecek 
62b4a8990SMichal Kubecek #include <uapi/linux/ethtool_netlink.h>
72b4a8990SMichal Kubecek #include <linux/ethtool.h>
86b08d6c1SMichal Kubecek #include <linux/netdevice.h>
96b08d6c1SMichal Kubecek 
10f625aa9bSMichal Kubecek #define __ETHTOOL_LINK_MODE_MASK_NWORDS \
11f625aa9bSMichal Kubecek 	DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32)
12f625aa9bSMichal Kubecek 
131aabe578SJakub Kicinski #define ETHTOOL_PAUSE_STAT_CNT	(__ETHTOOL_A_PAUSE_STAT_CNT -		\
141aabe578SJakub Kicinski 				 ETHTOOL_A_PAUSE_STAT_TX_FRAMES)
151aabe578SJakub Kicinski 
166b08d6c1SMichal Kubecek enum ethtool_multicast_groups {
176b08d6c1SMichal Kubecek 	ETHNL_MCGRP_MONITOR,
186b08d6c1SMichal Kubecek };
192b4a8990SMichal Kubecek 
201dd3f212SAndrew Lunn struct phy_device;
211dd3f212SAndrew Lunn 
221dd3f212SAndrew Lunn #if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
231a644de2SAndrew Lunn int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd);
241dd3f212SAndrew Lunn void ethnl_cable_test_free(struct phy_device *phydev);
251dd3f212SAndrew Lunn void ethnl_cable_test_finished(struct phy_device *phydev);
26*4715d87eSOleksij Rempel int ethnl_cable_test_result_with_src(struct phy_device *phydev, u8 pair,
27*4715d87eSOleksij Rempel 				     u8 result, u32 src);
28*4715d87eSOleksij Rempel int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev, u8 pair,
29*4715d87eSOleksij Rempel 					   u32 cm, u32 src);
306b4a0fc1SAndrew Lunn int ethnl_cable_test_amplitude(struct phy_device *phydev, u8 pair, s16 mV);
316b4a0fc1SAndrew Lunn int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV);
326b4a0fc1SAndrew Lunn int ethnl_cable_test_step(struct phy_device *phydev, u32 first, u32 last,
336b4a0fc1SAndrew Lunn 			  u32 step);
349179f5feSVladimir Oltean void ethtool_aggregate_mac_stats(struct net_device *dev,
359179f5feSVladimir Oltean 				 struct ethtool_eth_mac_stats *mac_stats);
369179f5feSVladimir Oltean void ethtool_aggregate_phy_stats(struct net_device *dev,
379179f5feSVladimir Oltean 				 struct ethtool_eth_phy_stats *phy_stats);
389179f5feSVladimir Oltean void ethtool_aggregate_ctrl_stats(struct net_device *dev,
399179f5feSVladimir Oltean 				  struct ethtool_eth_ctrl_stats *ctrl_stats);
409179f5feSVladimir Oltean void ethtool_aggregate_pause_stats(struct net_device *dev,
419179f5feSVladimir Oltean 				   struct ethtool_pause_stats *pause_stats);
429179f5feSVladimir Oltean void ethtool_aggregate_rmon_stats(struct net_device *dev,
439179f5feSVladimir Oltean 				  struct ethtool_rmon_stats *rmon_stats);
44d54151aaSVladimir Oltean bool ethtool_dev_mm_supported(struct net_device *dev);
459179f5feSVladimir Oltean 
461dd3f212SAndrew Lunn #else
ethnl_cable_test_alloc(struct phy_device * phydev,u8 cmd)471a644de2SAndrew Lunn static inline int ethnl_cable_test_alloc(struct phy_device *phydev, u8 cmd)
481dd3f212SAndrew Lunn {
491e2dc145SAndrew Lunn 	return -EOPNOTSUPP;
501dd3f212SAndrew Lunn }
511dd3f212SAndrew Lunn 
ethnl_cable_test_free(struct phy_device * phydev)521dd3f212SAndrew Lunn static inline void ethnl_cable_test_free(struct phy_device *phydev)
531dd3f212SAndrew Lunn {
541dd3f212SAndrew Lunn }
551dd3f212SAndrew Lunn 
ethnl_cable_test_finished(struct phy_device * phydev)561dd3f212SAndrew Lunn static inline void ethnl_cable_test_finished(struct phy_device *phydev)
571dd3f212SAndrew Lunn {
581dd3f212SAndrew Lunn }
ethnl_cable_test_result_with_src(struct phy_device * phydev,u8 pair,u8 result,u32 src)59*4715d87eSOleksij Rempel static inline int ethnl_cable_test_result_with_src(struct phy_device *phydev,
60*4715d87eSOleksij Rempel 						   u8 pair, u8 result, u32 src)
611e2dc145SAndrew Lunn {
621e2dc145SAndrew Lunn 	return -EOPNOTSUPP;
631e2dc145SAndrew Lunn }
641e2dc145SAndrew Lunn 
ethnl_cable_test_fault_length_with_src(struct phy_device * phydev,u8 pair,u32 cm,u32 src)65*4715d87eSOleksij Rempel static inline int ethnl_cable_test_fault_length_with_src(struct phy_device *phydev,
66*4715d87eSOleksij Rempel 							 u8 pair, u32 cm, u32 src)
671e2dc145SAndrew Lunn {
681e2dc145SAndrew Lunn 	return -EOPNOTSUPP;
691e2dc145SAndrew Lunn }
706b4a0fc1SAndrew Lunn 
ethnl_cable_test_amplitude(struct phy_device * phydev,u8 pair,s16 mV)716b4a0fc1SAndrew Lunn static inline int ethnl_cable_test_amplitude(struct phy_device *phydev,
726b4a0fc1SAndrew Lunn 					     u8 pair, s16 mV)
736b4a0fc1SAndrew Lunn {
746b4a0fc1SAndrew Lunn 	return -EOPNOTSUPP;
756b4a0fc1SAndrew Lunn }
766b4a0fc1SAndrew Lunn 
ethnl_cable_test_pulse(struct phy_device * phydev,u16 mV)776b4a0fc1SAndrew Lunn static inline int ethnl_cable_test_pulse(struct phy_device *phydev, u16 mV)
786b4a0fc1SAndrew Lunn {
796b4a0fc1SAndrew Lunn 	return -EOPNOTSUPP;
806b4a0fc1SAndrew Lunn }
816b4a0fc1SAndrew Lunn 
ethnl_cable_test_step(struct phy_device * phydev,u32 first,u32 last,u32 step)826b4a0fc1SAndrew Lunn static inline int ethnl_cable_test_step(struct phy_device *phydev, u32 first,
836b4a0fc1SAndrew Lunn 					u32 last, u32 step)
846b4a0fc1SAndrew Lunn {
856b4a0fc1SAndrew Lunn 	return -EOPNOTSUPP;
866b4a0fc1SAndrew Lunn }
879179f5feSVladimir Oltean 
889179f5feSVladimir Oltean static inline void
ethtool_aggregate_mac_stats(struct net_device * dev,struct ethtool_eth_mac_stats * mac_stats)899179f5feSVladimir Oltean ethtool_aggregate_mac_stats(struct net_device *dev,
909179f5feSVladimir Oltean 			    struct ethtool_eth_mac_stats *mac_stats)
919179f5feSVladimir Oltean {
929179f5feSVladimir Oltean }
939179f5feSVladimir Oltean 
949179f5feSVladimir Oltean static inline void
ethtool_aggregate_phy_stats(struct net_device * dev,struct ethtool_eth_phy_stats * phy_stats)959179f5feSVladimir Oltean ethtool_aggregate_phy_stats(struct net_device *dev,
969179f5feSVladimir Oltean 			    struct ethtool_eth_phy_stats *phy_stats)
979179f5feSVladimir Oltean {
989179f5feSVladimir Oltean }
999179f5feSVladimir Oltean 
1009179f5feSVladimir Oltean static inline void
ethtool_aggregate_ctrl_stats(struct net_device * dev,struct ethtool_eth_ctrl_stats * ctrl_stats)1019179f5feSVladimir Oltean ethtool_aggregate_ctrl_stats(struct net_device *dev,
1029179f5feSVladimir Oltean 			     struct ethtool_eth_ctrl_stats *ctrl_stats)
1039179f5feSVladimir Oltean {
1049179f5feSVladimir Oltean }
1059179f5feSVladimir Oltean 
1069179f5feSVladimir Oltean static inline void
ethtool_aggregate_pause_stats(struct net_device * dev,struct ethtool_pause_stats * pause_stats)1079179f5feSVladimir Oltean ethtool_aggregate_pause_stats(struct net_device *dev,
1089179f5feSVladimir Oltean 			      struct ethtool_pause_stats *pause_stats)
1099179f5feSVladimir Oltean {
1109179f5feSVladimir Oltean }
1119179f5feSVladimir Oltean 
1129179f5feSVladimir Oltean static inline void
ethtool_aggregate_rmon_stats(struct net_device * dev,struct ethtool_rmon_stats * rmon_stats)1139179f5feSVladimir Oltean ethtool_aggregate_rmon_stats(struct net_device *dev,
1149179f5feSVladimir Oltean 			     struct ethtool_rmon_stats *rmon_stats)
1159179f5feSVladimir Oltean {
1169179f5feSVladimir Oltean }
1179179f5feSVladimir Oltean 
ethtool_dev_mm_supported(struct net_device * dev)118d54151aaSVladimir Oltean static inline bool ethtool_dev_mm_supported(struct net_device *dev)
119d54151aaSVladimir Oltean {
120d54151aaSVladimir Oltean 	return false;
121d54151aaSVladimir Oltean }
122d54151aaSVladimir Oltean 
12390c56b38SKees Cook #endif /* IS_ENABLED(CONFIG_ETHTOOL_NETLINK) */
124*4715d87eSOleksij Rempel 
ethnl_cable_test_result(struct phy_device * phydev,u8 pair,u8 result)125*4715d87eSOleksij Rempel static inline int ethnl_cable_test_result(struct phy_device *phydev, u8 pair,
126*4715d87eSOleksij Rempel 					  u8 result)
127*4715d87eSOleksij Rempel {
128*4715d87eSOleksij Rempel 	return ethnl_cable_test_result_with_src(phydev, pair, result,
129*4715d87eSOleksij Rempel 						ETHTOOL_A_CABLE_INF_SRC_TDR);
130*4715d87eSOleksij Rempel }
131*4715d87eSOleksij Rempel 
ethnl_cable_test_fault_length(struct phy_device * phydev,u8 pair,u32 cm)132*4715d87eSOleksij Rempel static inline int ethnl_cable_test_fault_length(struct phy_device *phydev,
133*4715d87eSOleksij Rempel 						u8 pair, u32 cm)
134*4715d87eSOleksij Rempel {
135*4715d87eSOleksij Rempel 	return ethnl_cable_test_fault_length_with_src(phydev, pair, cm,
136*4715d87eSOleksij Rempel 						      ETHTOOL_A_CABLE_INF_SRC_TDR);
137*4715d87eSOleksij Rempel }
138*4715d87eSOleksij Rempel 
1392b4a8990SMichal Kubecek #endif /* _LINUX_ETHTOOL_NETLINK_H_ */
140