xref: /freebsd/sys/dev/etherswitch/etherswitch_if.m (revision e6bfd18d21b225af6a0ed67ceeaf1293b7b9eba5)
1# $FreeBSD$
2
3#include <sys/bus.h>
4
5# Needed for ifreq/ifmediareq
6#include <sys/socket.h>
7#include <net/if.h>
8
9#include <dev/etherswitch/etherswitch.h>
10
11INTERFACE etherswitch;
12
13#
14# Default implementation
15#
16CODE {
17	static void
18	null_etherswitch_lock(device_t dev)
19	{
20	}
21
22	static void
23	null_etherswitch_unlock(device_t dev)
24	{
25	}
26
27	static int
28	null_etherswitch_getconf(device_t dev, etherswitch_conf_t *conf)
29	{
30		return (0);
31	}
32
33	static int
34	null_etherswitch_setconf(device_t dev, etherswitch_conf_t *conf)
35	{
36		return (0);
37	}
38
39	static int
40	null_etherswitch_flush_all(device_t dev)
41	{
42
43		return (ENXIO);
44	}
45
46	static int
47	null_etherswitch_flush_port(device_t dev, int port)
48	{
49
50		return (ENXIO);
51	}
52
53	static int
54	null_etherswitch_flush_mac(device_t dev,
55	    etherswitch_atu_flush_macentry_t *e)
56	{
57
58		return (ENXIO);
59	}
60
61	static int
62	null_etherswitch_fetch_table(device_t dev,
63	    etherswitch_atu_table_t *table)
64	{
65
66		table->es_nitems = 0;
67		return (ENXIO);
68	}
69
70	static int
71	null_etherswitch_fetch_entry(device_t dev,
72	    etherswitch_atu_entry_t *e)
73	{
74
75		return (ENXIO);
76	}
77};
78
79#
80# Return device info
81#
82METHOD etherswitch_info_t* getinfo {
83	device_t	dev;
84}
85
86#
87# Lock access to switch registers
88#
89METHOD void lock {
90	device_t	dev;
91} DEFAULT null_etherswitch_lock;
92
93#
94# Unlock access to switch registers
95#
96METHOD void unlock {
97	device_t	dev;
98} DEFAULT null_etherswitch_unlock;
99
100#
101# Read switch register
102#
103METHOD int readreg {
104	device_t	dev;
105	int		reg;
106};
107
108#
109# Write switch register
110#
111METHOD int writereg {
112	device_t	dev;
113	int		reg;
114	int		value;
115};
116
117#
118# Read PHY register
119#
120METHOD int readphyreg {
121	device_t	dev;
122	int		phy;
123	int		reg;
124};
125
126#
127# Write PHY register
128#
129METHOD int writephyreg {
130	device_t	dev;
131	int		phy;
132	int		reg;
133	int		value;
134};
135
136#
137# Get port configuration
138#
139METHOD int getport {
140	device_t	dev;
141	etherswitch_port_t *vg;
142}
143
144#
145# Set port configuration
146#
147METHOD int setport {
148	device_t	dev;
149	etherswitch_port_t *vg;
150}
151
152#
153# Get VLAN group configuration
154#
155METHOD int getvgroup {
156	device_t	dev;
157	etherswitch_vlangroup_t *vg;
158}
159
160#
161# Set VLAN group configuration
162#
163METHOD int setvgroup {
164	device_t	dev;
165	etherswitch_vlangroup_t *vg;
166}
167
168#
169# Get the Switch configuration
170#
171METHOD int getconf {
172	device_t	dev;
173	etherswitch_conf_t	*conf;
174} DEFAULT null_etherswitch_getconf;
175
176#
177# Set the Switch configuration
178#
179METHOD int setconf {
180	device_t	dev;
181	etherswitch_conf_t	*conf;
182} DEFAULT null_etherswitch_setconf;
183
184#
185# Flush all of the programmed/learnt MAC addresses
186#
187METHOD int flush_all {
188	device_t dev;
189} DEFAULT null_etherswitch_flush_all;
190
191#
192# Flush a single MAC address entry
193#
194METHOD int flush_mac {
195	device_t dev;
196	etherswitch_atu_flush_macentry_t *entry;
197} DEFAULT null_etherswitch_flush_mac;
198
199#
200# Flush all of the dynamic MAC addresses on a given port
201#
202METHOD int flush_port {
203	device_t dev;
204	int port;
205} DEFAULT null_etherswitch_flush_port;
206
207#
208# Fetch the address table from the ethernet switch.
209#
210METHOD int fetch_table {
211	device_t dev;
212	etherswitch_atu_table_t *table;
213} DEFAULT null_etherswitch_fetch_table;
214
215#
216# Fetch a single entry from the ethernet switch table.
217#
218METHOD int fetch_table_entry {
219	device_t dev;
220	etherswitch_atu_entry_t *entry;
221} DEFAULT null_etherswitch_fetch_entry;
222