xref: /freebsd/sys/net/ifdi_if.m (revision 3ac125068a211377f0b3817c37cf1db95a87e8fb)
1#
2# Copyright (c) 2014, Matthew Macy (kmacy@freebsd.org)
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are met:
7#
8#  1. Redistributions of source code must retain the above copyright notice,
9#     this list of conditions and the following disclaimer.
10#
11#  2. Neither the name of Matthew Macy nor the names of its
12#     contributors may be used to endorse or promote products derived from
13#     this software without specific prior written permission.
14#
15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25# POSSIBILITY OF SUCH DAMAGE.
26#
27# $FreeBSD$
28#
29
30#include <sys/types.h>
31#include <sys/systm.h>
32#include <sys/socket.h>
33
34#include <machine/bus.h>
35#include <sys/bus.h>
36
37#include <net/ethernet.h>
38#include <net/if.h>
39#include <net/if_var.h>
40#include <net/if_media.h>
41#include <net/iflib.h>
42
43INTERFACE ifdi;
44
45CODE {
46
47	static void
48	null_void_op(if_ctx_t _ctx __unused)
49	{
50	}
51
52	static void
53	null_timer_op(if_ctx_t _ctx __unused, uint16_t _qsidx __unused)
54	{
55	}
56
57	static int
58	null_int_op(if_ctx_t _ctx __unused)
59	{
60		return (0);
61	}
62
63	static int
64	null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused)
65	{
66		return (ENOTSUP);
67	}
68
69	static void
70	null_led_func(if_ctx_t _ctx __unused, int _onoff __unused)
71	{
72	}
73
74	static void
75	null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused)
76	{
77	}
78
79	static int
80	null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused)
81	{
82		return (0);
83	}
84
85	static int
86	null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused)
87	{
88		return (ENOTSUP);
89	}
90
91	static int
92	null_sysctl_int_delay(if_ctx_t _sctx __unused, if_int_delay_info_t _iidi __unused)
93	{
94		return (0);
95	}
96
97	static int
98	null_iov_init(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
99	{
100		return (ENOTSUP);
101	}
102
103	static int
104	null_vf_add(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
105	{
106		return (ENOTSUP);
107	}
108
109	static int
110	null_priv_ioctl(if_ctx_t _ctx __unused, u_long command, caddr_t *data __unused)
111	{
112		return (ENOTSUP);
113	}
114};
115
116#
117# bus interfaces
118#
119
120METHOD int attach_pre {
121	if_ctx_t _ctx;
122};
123
124METHOD int attach_post {
125	if_ctx_t _ctx;
126};
127
128METHOD int detach {
129	if_ctx_t _ctx;
130};
131
132METHOD int suspend {
133	if_ctx_t _ctx;
134} DEFAULT null_int_op;
135
136METHOD int shutdown {
137	if_ctx_t _ctx;
138} DEFAULT null_int_op;
139
140METHOD int resume {
141	if_ctx_t _ctx;
142} DEFAULT null_int_op;
143
144#
145# downcall to driver to allocate its
146# own queue state and tie it to the parent
147#
148
149METHOD int tx_queues_alloc {
150	if_ctx_t _ctx;
151	caddr_t *_vaddrs;
152	uint64_t *_paddrs;
153	int ntxqs;
154	int ntxqsets;
155};
156
157METHOD int rx_queues_alloc {
158	if_ctx_t _ctx;
159	caddr_t *_vaddrs;
160	uint64_t *_paddrs;
161	int nrxqs;
162	int nrxqsets;
163};
164
165METHOD void queues_free {
166	if_ctx_t _ctx;
167};
168
169#
170# interface reset / stop
171#
172
173METHOD void init {
174	if_ctx_t _ctx;
175};
176
177METHOD void stop {
178	if_ctx_t _ctx;
179};
180
181#
182# interrupt setup and manipulation
183#
184
185METHOD int msix_intr_assign {
186	if_ctx_t _sctx;
187	int msix;
188};
189
190METHOD void intr_enable {
191	if_ctx_t _ctx;
192};
193
194METHOD void intr_disable {
195	if_ctx_t _ctx;
196};
197
198METHOD int queue_intr_enable {
199	if_ctx_t _ctx;
200	uint16_t _qid;
201} DEFAULT null_queue_intr_enable;
202
203METHOD void link_intr_enable {
204	if_ctx_t _ctx;
205} DEFAULT null_void_op;
206
207#
208# interface configuration
209#
210
211METHOD void multi_set {
212	if_ctx_t _ctx;
213};
214
215METHOD int mtu_set {
216	if_ctx_t _ctx;
217	uint32_t _mtu;
218};
219
220METHOD void media_set{
221	if_ctx_t _ctx;
222} DEFAULT null_void_op;
223
224METHOD int promisc_set {
225	if_ctx_t _ctx;
226	int _flags;
227};
228
229METHOD void crcstrip_set {
230	if_ctx_t _ctx;
231	int _onoff;
232};
233
234#
235# IOV handling
236#
237
238METHOD void vflr_handle {
239	if_ctx_t _ctx;
240} DEFAULT null_void_op;
241
242METHOD int iov_init {
243	if_ctx_t _ctx;
244	uint16_t num_vfs;
245	const nvlist_t * params;
246} DEFAULT null_iov_init;
247
248METHOD void iov_uninit {
249	if_ctx_t _ctx;
250} DEFAULT null_void_op;
251
252METHOD int iov_vf_add {
253	if_ctx_t _ctx;
254	uint16_t num_vfs;
255	const nvlist_t * params;
256} DEFAULT null_vf_add;
257
258
259#
260# Device status
261#
262
263METHOD void update_admin_status {
264	if_ctx_t _ctx;
265};
266
267METHOD void media_status {
268	if_ctx_t _ctx;
269	struct ifmediareq *_ifm;
270};
271
272METHOD int media_change {
273	if_ctx_t _ctx;
274};
275
276METHOD uint64_t get_counter {
277	if_ctx_t _ctx;
278	ift_counter cnt;
279};
280
281METHOD int priv_ioctl {
282	if_ctx_t _ctx;
283	u_long   _cmd;
284	caddr_t _data;
285} DEFAULT null_priv_ioctl;
286
287#
288# optional methods
289#
290
291METHOD int i2c_req {
292	if_ctx_t _ctx;
293	struct ifi2creq *_req;
294} DEFAULT null_i2c_req;
295
296METHOD int txq_setup {
297	if_ctx_t _ctx;
298	uint32_t _txqid;
299} DEFAULT null_q_setup;
300
301METHOD int rxq_setup {
302	if_ctx_t _ctx;
303	uint32_t _txqid;
304} DEFAULT null_q_setup;
305
306METHOD void timer {
307	if_ctx_t _ctx;
308	uint16_t _txqid;
309} DEFAULT null_timer_op;
310
311METHOD void watchdog_reset {
312	if_ctx_t _ctx;
313} DEFAULT null_void_op;
314
315METHOD void led_func {
316	if_ctx_t _ctx;
317	int _onoff;
318} DEFAULT null_led_func;
319
320METHOD void vlan_register {
321	if_ctx_t _ctx;
322	uint16_t _vtag;
323} DEFAULT null_vlan_register_op;
324
325METHOD void vlan_unregister {
326	if_ctx_t _ctx;
327	uint16_t _vtag;
328} DEFAULT null_vlan_register_op;
329
330METHOD int sysctl_int_delay {
331	if_ctx_t _sctx;
332	if_int_delay_info_t _iidi;
333} DEFAULT null_sysctl_int_delay;
334
335
336