summaryrefslogtreecommitdiffstats
path: root/netlink/extapi.h
blob: e2d6b71f55b0280bd7e215e3b8a873ac8e1a67f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
 * extapi.h - external interface of netlink code
 *
 * Declarations needed by non-netlink code (mostly ethtool.c).
 */

#ifndef ETHTOOL_EXTAPI_H__
#define ETHTOOL_EXTAPI_H__

struct cmd_context;
struct nl_context;

typedef int (*nl_func_t)(struct cmd_context *);
typedef bool (*nl_chk_t)(struct cmd_context *);

#ifdef ETHTOOL_ENABLE_NETLINK

void netlink_run_handler(struct cmd_context *ctx, nl_chk_t nlchk,
			 nl_func_t nlfunc, bool no_fallback);

int nl_gset(struct cmd_context *ctx);
int nl_sset(struct cmd_context *ctx);
int nl_permaddr(struct cmd_context *ctx);
int nl_gfeatures(struct cmd_context *ctx);
int nl_sfeatures(struct cmd_context *ctx);
int nl_gprivflags(struct cmd_context *ctx);
int nl_sprivflags(struct cmd_context *ctx);
int nl_gring(struct cmd_context *ctx);
int nl_sring(struct cmd_context *ctx);
int nl_gchannels(struct cmd_context *ctx);
int nl_schannels(struct cmd_context *ctx);
int nl_gcoalesce(struct cmd_context *ctx);
int nl_scoalesce(struct cmd_context *ctx);
int nl_gpause(struct cmd_context *ctx);
int nl_spause(struct cmd_context *ctx);
int nl_geee(struct cmd_context *ctx);
int nl_seee(struct cmd_context *ctx);
int nl_tsinfo(struct cmd_context *ctx);
int nl_cable_test(struct cmd_context *ctx);
int nl_cable_test_tdr(struct cmd_context *ctx);
int nl_gtunnels(struct cmd_context *ctx);
int nl_gfec(struct cmd_context *ctx);
int nl_sfec(struct cmd_context *ctx);
bool nl_gstats_chk(struct cmd_context *ctx);
int nl_gstats(struct cmd_context *ctx);
int nl_gmodule(struct cmd_context *ctx);
int nl_smodule(struct cmd_context *ctx);
int nl_monitor(struct cmd_context *ctx);
int nl_getmodule(struct cmd_context *ctx);
int nl_grss(struct cmd_context *ctx);
int nl_plca_get_cfg(struct cmd_context *ctx);
int nl_plca_set_cfg(struct cmd_context *ctx);
int nl_plca_get_status(struct cmd_context *ctx);
int nl_get_mm(struct cmd_context *ctx);
int nl_set_mm(struct cmd_context *ctx);
int nl_gpse(struct cmd_context *ctx);
int nl_spse(struct cmd_context *ctx);

void nl_monitor_usage(void);

int nl_get_eeprom_page(struct cmd_context *ctx,
		       struct ethtool_module_eeprom *request);

#else /* ETHTOOL_ENABLE_NETLINK */

static inline void netlink_run_handler(struct cmd_context *ctx __maybe_unused,
				       nl_chk_t nlchk __maybe_unused,
				       nl_func_t nlfunc __maybe_unused,
				       bool no_fallback)
{
	if (no_fallback) {
		fprintf(stderr,
			"Command requires kernel netlink support which is not "
			"enabled in this ethtool binary\n");
		exit(1);
	}
}

static inline int nl_monitor(struct cmd_context *ctx __maybe_unused)
{
	fprintf(stderr, "Netlink not supported by ethtool, option --monitor unsupported.\n");
	return -EOPNOTSUPP;
}

static inline void nl_monitor_usage(void)
{
}

static inline int
nl_get_eeprom_page(struct cmd_context *ctx __maybe_unused,
		   struct ethtool_module_eeprom *request __maybe_unused)
{
	fprintf(stderr, "Netlink not supported by ethtool.\n");
	return -EOPNOTSUPP;
}

#define nl_gset			NULL
#define nl_sset			NULL
#define nl_permaddr		NULL
#define nl_gfeatures		NULL
#define nl_sfeatures		NULL
#define nl_gprivflags		NULL
#define nl_sprivflags		NULL
#define nl_gring		NULL
#define nl_sring		NULL
#define nl_gchannels		NULL
#define nl_schannels		NULL
#define nl_gcoalesce		NULL
#define nl_scoalesce		NULL
#define nl_gpause		NULL
#define nl_spause		NULL
#define nl_geee			NULL
#define nl_seee			NULL
#define nl_tsinfo		NULL
#define nl_cable_test		NULL
#define nl_cable_test_tdr	NULL
#define nl_gtunnels		NULL
#define nl_gfec			NULL
#define nl_sfec			NULL
#define nl_gstats_chk		NULL
#define nl_gstats		NULL
#define nl_getmodule		NULL
#define nl_gmodule		NULL
#define nl_smodule		NULL
#define nl_grss			NULL
#define nl_plca_get_cfg		NULL
#define nl_plca_set_cfg		NULL
#define nl_plca_get_status	NULL
#define nl_get_mm		NULL
#define nl_set_mm		NULL
#define nl_gpse			NULL
#define nl_spse			NULL

#endif /* ETHTOOL_ENABLE_NETLINK */

#endif /* ETHTOOL_EXTAPI_H__ */