1 /*
2 * extapi.h - external interface of netlink code
3 *
4 * Declarations needed by non-netlink code (mostly ethtool.c).
5 */
6
7 #ifndef ETHTOOL_EXTAPI_H__
8 #define ETHTOOL_EXTAPI_H__
9
10 struct cmd_context;
11 struct nl_context;
12
13 typedef int (*nl_func_t)(struct cmd_context *);
14 typedef bool (*nl_chk_t)(struct cmd_context *);
15
16 #ifdef ETHTOOL_ENABLE_NETLINK
17
18 void netlink_run_handler(struct cmd_context *ctx, nl_chk_t nlchk,
19 nl_func_t nlfunc, bool no_fallback);
20
21 int nl_gset(struct cmd_context *ctx);
22 int nl_sset(struct cmd_context *ctx);
23 int nl_permaddr(struct cmd_context *ctx);
24 int nl_gfeatures(struct cmd_context *ctx);
25 int nl_sfeatures(struct cmd_context *ctx);
26 int nl_gprivflags(struct cmd_context *ctx);
27 int nl_sprivflags(struct cmd_context *ctx);
28 int nl_gring(struct cmd_context *ctx);
29 int nl_sring(struct cmd_context *ctx);
30 int nl_gchannels(struct cmd_context *ctx);
31 int nl_schannels(struct cmd_context *ctx);
32 int nl_gcoalesce(struct cmd_context *ctx);
33 int nl_scoalesce(struct cmd_context *ctx);
34 int nl_gpause(struct cmd_context *ctx);
35 int nl_spause(struct cmd_context *ctx);
36 int nl_geee(struct cmd_context *ctx);
37 int nl_seee(struct cmd_context *ctx);
38 int nl_tsinfo(struct cmd_context *ctx);
39 int nl_cable_test(struct cmd_context *ctx);
40 int nl_cable_test_tdr(struct cmd_context *ctx);
41 int nl_gtunnels(struct cmd_context *ctx);
42 int nl_gfec(struct cmd_context *ctx);
43 int nl_sfec(struct cmd_context *ctx);
44 bool nl_gstats_chk(struct cmd_context *ctx);
45 int nl_gstats(struct cmd_context *ctx);
46 int nl_gmodule(struct cmd_context *ctx);
47 int nl_smodule(struct cmd_context *ctx);
48 int nl_monitor(struct cmd_context *ctx);
49 int nl_getmodule(struct cmd_context *ctx);
50 int nl_grss(struct cmd_context *ctx);
51 int nl_plca_get_cfg(struct cmd_context *ctx);
52 int nl_plca_set_cfg(struct cmd_context *ctx);
53 int nl_plca_get_status(struct cmd_context *ctx);
54 int nl_get_mm(struct cmd_context *ctx);
55 int nl_set_mm(struct cmd_context *ctx);
56 int nl_gpse(struct cmd_context *ctx);
57 int nl_spse(struct cmd_context *ctx);
58 int nl_flash_module_fw(struct cmd_context *ctx);
59 int nl_get_phy(struct cmd_context *ctx);
60
61 void nl_monitor_usage(void);
62
63 int nl_get_eeprom_page(struct cmd_context *ctx,
64 struct ethtool_module_eeprom *request);
65
66 #else /* ETHTOOL_ENABLE_NETLINK */
67
netlink_run_handler(struct cmd_context * ctx __maybe_unused,nl_chk_t nlchk __maybe_unused,nl_func_t nlfunc __maybe_unused,bool no_fallback)68 static inline void netlink_run_handler(struct cmd_context *ctx __maybe_unused,
69 nl_chk_t nlchk __maybe_unused,
70 nl_func_t nlfunc __maybe_unused,
71 bool no_fallback)
72 {
73 if (no_fallback) {
74 fprintf(stderr,
75 "Command requires kernel netlink support which is not "
76 "enabled in this ethtool binary\n");
77 exit(1);
78 }
79 }
80
nl_monitor(struct cmd_context * ctx __maybe_unused)81 static inline int nl_monitor(struct cmd_context *ctx __maybe_unused)
82 {
83 fprintf(stderr, "Netlink not supported by ethtool, option --monitor unsupported.\n");
84 return -EOPNOTSUPP;
85 }
86
nl_monitor_usage(void)87 static inline void nl_monitor_usage(void)
88 {
89 }
90
91 static inline int
nl_get_eeprom_page(struct cmd_context * ctx __maybe_unused,struct ethtool_module_eeprom * request __maybe_unused)92 nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,
93 struct ethtool_module_eeprom *request __maybe_unused)
94 {
95 fprintf(stderr, "Netlink not supported by ethtool.\n");
96 return -EOPNOTSUPP;
97 }
98
99 #define nl_gset NULL
100 #define nl_sset NULL
101 #define nl_permaddr NULL
102 #define nl_gfeatures NULL
103 #define nl_sfeatures NULL
104 #define nl_gprivflags NULL
105 #define nl_sprivflags NULL
106 #define nl_gring NULL
107 #define nl_sring NULL
108 #define nl_gchannels NULL
109 #define nl_schannels NULL
110 #define nl_gcoalesce NULL
111 #define nl_scoalesce NULL
112 #define nl_gpause NULL
113 #define nl_spause NULL
114 #define nl_geee NULL
115 #define nl_seee NULL
116 #define nl_tsinfo NULL
117 #define nl_cable_test NULL
118 #define nl_cable_test_tdr NULL
119 #define nl_gtunnels NULL
120 #define nl_gfec NULL
121 #define nl_sfec NULL
122 #define nl_gstats_chk NULL
123 #define nl_gstats NULL
124 #define nl_getmodule NULL
125 #define nl_gmodule NULL
126 #define nl_smodule NULL
127 #define nl_grss NULL
128 #define nl_plca_get_cfg NULL
129 #define nl_plca_set_cfg NULL
130 #define nl_plca_get_status NULL
131 #define nl_get_mm NULL
132 #define nl_set_mm NULL
133 #define nl_gpse NULL
134 #define nl_spse NULL
135 #define nl_flash_module_fw NULL
136 #define nl_get_phy NULL
137
138 #endif /* ETHTOOL_ENABLE_NETLINK */
139
140 #endif /* ETHTOOL_EXTAPI_H__ */
141