summaryrefslogtreecommitdiffstats
path: root/sys/dev/etherswitch/etherswitch_if.m
blob: b684027062f419f6050eaa6395076793e3008d99 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# $FreeBSD$

#include <sys/bus.h>

# Needed for ifreq/ifmediareq
#include <sys/socket.h>
#include <net/if.h>

#include <dev/etherswitch/etherswitch.h>

INTERFACE etherswitch;

#
# Default implementation
#
CODE {
	static void
	null_etherswitch_lock(device_t dev)
	{
	}

	static void
	null_etherswitch_unlock(device_t dev)
	{
	}

	static int
	null_etherswitch_getlaggroup(device_t dev, etherswitch_laggroup_t *conf)
	{
		return (EINVAL);
	}

	static int
	null_etherswitch_setlaggroup(device_t dev, etherswitch_laggroup_t *conf)
	{
		return (EINVAL);
	}

	static int
	null_etherswitch_getconf(device_t dev, etherswitch_conf_t *conf)
	{
		return (0);
	}

	static int
	null_etherswitch_setconf(device_t dev, etherswitch_conf_t *conf)
	{
		return (0);
	}

	static ssize_t
	null_etherswitch_getioblksize(device_t dev)
	{
		return (-1);
	}

	static ssize_t
	null_etherswitch_getiosize(device_t dev)
	{
		return (-1);
	}

	static void *
	null_etherswitch_getiobuf(device_t dev)
	{
		return (NULL);
	}

	static int
	null_etherswitch_ioread(device_t dev, off_t off, ssize_t len)
	{
		return (EIO);
	}

	static int
	null_etherswitch_iowrite(device_t dev, off_t off, ssize_t len)
	{
		return (EIO);
	}
};

#
# Return device info
#
METHOD etherswitch_info_t* getinfo {
	device_t	dev;
}

#
# Lock access to switch registers
#
METHOD void lock {
	device_t	dev;
} DEFAULT null_etherswitch_lock;

#
# Unlock access to switch registers
#
METHOD void unlock {
	device_t	dev;
} DEFAULT null_etherswitch_unlock;

#
# Read switch register
#
METHOD int readreg {
	device_t	dev;
	int		reg;
};

#
# Write switch register
#
METHOD int writereg {
	device_t	dev;
	int		reg;
	int		value;
};

#
# Read PHY register
#
METHOD int readphyreg {
	device_t	dev;
	int		phy;
	int		reg;
};

#
# Write PHY register
#
METHOD int writephyreg {
	device_t	dev;
	int		phy;
	int		reg;
	int		value;
};

#
# Get port configuration
#
METHOD int getport {
	device_t	dev;
	etherswitch_port_t *vg;
}

#
# Set port configuration
#
METHOD int setport {
	device_t	dev;
	etherswitch_port_t *vg;
}

#
# Get VLAN group configuration
#
METHOD int getvgroup {
	device_t	dev;
	etherswitch_vlangroup_t *vg;
}

#
# Set VLAN group configuration
#
METHOD int setvgroup {
	device_t	dev;
	etherswitch_vlangroup_t *vg;
}

#
# Get LAGG configuration
#
METHOD int getlaggroup {
	device_t	dev;
	etherswitch_laggroup_t *vg;
} DEFAULT null_etherswitch_getlaggroup;

#
# Set LAGG configuration
#
METHOD int setlaggroup {
	device_t	dev;
	etherswitch_laggroup_t *vg;
} DEFAULT null_etherswitch_setlaggroup;

#
# Get the Switch configuration
#
METHOD int getconf {
	device_t	dev;
	etherswitch_conf_t	*conf;
} DEFAULT null_etherswitch_getconf;

#
# Set the Switch configuration
#
METHOD int setconf {
	device_t	dev;
	etherswitch_conf_t	*conf;
} DEFAULT null_etherswitch_setconf;

#
# Get the IO buffer block size
#
METHOD ssize_t getioblksize {
	device_t	dev;
} DEFAULT null_etherswitch_getioblksize;

#
# Get the IO buffer size
#
METHOD ssize_t getiosize {
	device_t	dev;
} DEFAULT null_etherswitch_getiosize;

#
# Get the IO buffer
#
METHOD void * getiobuf {
	device_t	dev;
} DEFAULT null_etherswitch_getiobuf;

#
# Perform a read operation and save data into IO buffer
#
METHOD int ioread {
	device_t	dev;
	off_t		off;
	ssize_t		len;
} DEFAULT null_etherswitch_ioread;

#
# Perform a write operation (write the data in the IO buffer)
#
METHOD int iowrite {
	device_t	dev;
	off_t		off;
	ssize_t		len;
} DEFAULT null_etherswitch_iowrite;
OpenPOWER on IntegriCloud