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
59 void nl_monitor_usage(void);
60
61 int nl_get_eeprom_page(struct cmd_context *ctx,
62 struct ethtool_module_eeprom *request);
63
64 #else /* ETHTOOL_ENABLE_NETLINK */
65
netlink_run_handler(struct cmd_context * ctx __maybe_unused,nl_chk_t nlchk __maybe_unused,nl_func_t nlfunc __maybe_unused,bool no_fallback)66 static inline void netlink_run_handler(struct cmd_context *ctx __maybe_unused,
67 nl_chk_t nlchk __maybe_unused,
68 nl_func_t nlfunc __maybe_unused,
69 bool no_fallback)
70 {
71 if (no_fallback) {
72 fprintf(stderr,
73 "Command requires kernel netlink support which is not "
74 "enabled in this ethtool binary\n");
75 exit(1);
76 }
77 }
78
nl_monitor(struct cmd_context * ctx __maybe_unused)79 static inline int nl_monitor(struct cmd_context *ctx __maybe_unused)
80 {
81 fprintf(stderr, "Netlink not supported by ethtool, option --monitor unsupported.\n");
82 return -EOPNOTSUPP;
83 }
84
nl_monitor_usage(void)85 static inline void nl_monitor_usage(void)
86 {
87 }
88
89 static inline int
nl_get_eeprom_page(struct cmd_context * ctx __maybe_unused,struct ethtool_module_eeprom * request __maybe_unused)90 nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,
91 struct ethtool_module_eeprom *request __maybe_unused)
92 {
93 fprintf(stderr, "Netlink not supported by ethtool.\n");
94 return -EOPNOTSUPP;
95 }
96
97 #define nl_gset NULL
98 #define nl_sset NULL
99 #define nl_permaddr NULL
100 #define nl_gfeatures NULL
101 #define nl_sfeatures NULL
102 #define nl_gprivflags NULL
103 #define nl_sprivflags NULL
104 #define nl_gring NULL
105 #define nl_sring NULL
106 #define nl_gchannels NULL
107 #define nl_schannels NULL
108 #define nl_gcoalesce NULL
109 #define nl_scoalesce NULL
110 #define nl_gpause NULL
111 #define nl_spause NULL
112 #define nl_geee NULL
113 #define nl_seee NULL
114 #define nl_tsinfo NULL
115 #define nl_cable_test NULL
116 #define nl_cable_test_tdr NULL
117 #define nl_gtunnels NULL
118 #define nl_gfec NULL
119 #define nl_sfec NULL
120 #define nl_gstats_chk NULL
121 #define nl_gstats NULL
122 #define nl_getmodule NULL
123 #define nl_gmodule NULL
124 #define nl_smodule NULL
125 #define nl_grss NULL
126 #define nl_plca_get_cfg NULL
127 #define nl_plca_set_cfg NULL
128 #define nl_plca_get_status NULL
129 #define nl_get_mm NULL
130 #define nl_set_mm NULL
131 #define nl_gpse NULL
132 #define nl_spse NULL
133
134 #endif /* ETHTOOL_ENABLE_NETLINK */
135
136 #endif /* ETHTOOL_EXTAPI_H__ */
137