xref: /freebsd/sys/net/ifdi_if.m (revision 3416500aef140042c64bc149cb1ec6620483bc44)
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 rx_queue_intr_enable {
199	if_ctx_t _ctx;
200	uint16_t _qid;
201} DEFAULT null_queue_intr_enable;
202
203METHOD int tx_queue_intr_enable {
204	if_ctx_t _ctx;
205	uint16_t _qid;
206} DEFAULT null_queue_intr_enable;
207
208METHOD void link_intr_enable {
209	if_ctx_t _ctx;
210} DEFAULT null_void_op;
211
212#
213# interface configuration
214#
215
216METHOD void multi_set {
217	if_ctx_t _ctx;
218};
219
220METHOD int mtu_set {
221	if_ctx_t _ctx;
222	uint32_t _mtu;
223};
224
225METHOD void media_set{
226	if_ctx_t _ctx;
227} DEFAULT null_void_op;
228
229METHOD int promisc_set {
230	if_ctx_t _ctx;
231	int _flags;
232};
233
234METHOD void crcstrip_set {
235	if_ctx_t _ctx;
236	int _onoff;
237	int _strip;
238};
239
240#
241# IOV handling
242#
243
244METHOD void vflr_handle {
245	if_ctx_t _ctx;
246} DEFAULT null_void_op;
247
248METHOD int iov_init {
249	if_ctx_t _ctx;
250	uint16_t num_vfs;
251	const nvlist_t * params;
252} DEFAULT null_iov_init;
253
254METHOD void iov_uninit {
255	if_ctx_t _ctx;
256} DEFAULT null_void_op;
257
258METHOD int iov_vf_add {
259	if_ctx_t _ctx;
260	uint16_t num_vfs;
261	const nvlist_t * params;
262} DEFAULT null_vf_add;
263
264
265#
266# Device status
267#
268
269METHOD void update_admin_status {
270	if_ctx_t _ctx;
271};
272
273METHOD void media_status {
274	if_ctx_t _ctx;
275	struct ifmediareq *_ifm;
276};
277
278METHOD int media_change {
279	if_ctx_t _ctx;
280};
281
282METHOD uint64_t get_counter {
283	if_ctx_t _ctx;
284	ift_counter cnt;
285};
286
287METHOD int priv_ioctl {
288	if_ctx_t _ctx;
289	u_long   _cmd;
290	caddr_t _data;
291} DEFAULT null_priv_ioctl;
292
293#
294# optional methods
295#
296
297METHOD int i2c_req {
298	if_ctx_t _ctx;
299	struct ifi2creq *_req;
300} DEFAULT null_i2c_req;
301
302METHOD int txq_setup {
303	if_ctx_t _ctx;
304	uint32_t _txqid;
305} DEFAULT null_q_setup;
306
307METHOD int rxq_setup {
308	if_ctx_t _ctx;
309	uint32_t _txqid;
310} DEFAULT null_q_setup;
311
312METHOD void timer {
313	if_ctx_t _ctx;
314	uint16_t _txqid;
315} DEFAULT null_timer_op;
316
317METHOD void watchdog_reset {
318	if_ctx_t _ctx;
319} DEFAULT null_void_op;
320
321METHOD void led_func {
322	if_ctx_t _ctx;
323	int _onoff;
324} DEFAULT null_led_func;
325
326METHOD void vlan_register {
327	if_ctx_t _ctx;
328	uint16_t _vtag;
329} DEFAULT null_vlan_register_op;
330
331METHOD void vlan_unregister {
332	if_ctx_t _ctx;
333	uint16_t _vtag;
334} DEFAULT null_vlan_register_op;
335
336METHOD int sysctl_int_delay {
337	if_ctx_t _sctx;
338	if_int_delay_info_t _iidi;
339} DEFAULT null_sysctl_int_delay;
340
341METHOD void debug {
342	if_ctx_t _ctx;
343} DEFAULT null_void_op;
344