xref: /freebsd/sys/net/ifdi_if.m (revision 4c7070db)
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 void
64	null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused)
65	{
66	}
67
68	static void
69	null_led_func(if_ctx_t _ctx __unused, int _onoff __unused)
70	{
71	}
72
73	static void
74	null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused)
75	{
76	}
77
78	static int
79	null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused)
80	{
81		return (0);
82	}
83
84	static int
85	null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused)
86	{
87		return (ENOTSUP);
88	}
89
90	static int
91	null_sysctl_int_delay(if_ctx_t _sctx __unused, if_int_delay_info_t _iidi __unused)
92	{
93		return (0);
94	}
95
96	static int
97	null_iov_init(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
98	{
99		return (ENOTSUP);
100	}
101
102	static int
103	null_vf_add(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
104	{
105		return (ENOTSUP);
106	}
107
108	static int
109	null_priv_ioctl(if_ctx_t _ctx __unused, u_long command, caddr_t *data __unused)
110	{
111		return (ENOTSUP);
112	}
113};
114
115#
116# bus interfaces
117#
118
119METHOD int attach_pre {
120	if_ctx_t _ctx;
121};
122
123METHOD int attach_post {
124	if_ctx_t _ctx;
125};
126
127METHOD int detach {
128	if_ctx_t _ctx;
129};
130
131METHOD int suspend {
132	if_ctx_t _ctx;
133} DEFAULT null_int_op;
134
135METHOD int shutdown {
136	if_ctx_t _ctx;
137} DEFAULT null_int_op;
138
139METHOD int resume {
140	if_ctx_t _ctx;
141} DEFAULT null_int_op;
142
143#
144# downcall to driver to allocate its
145# own queue state and tie it to the parent
146#
147
148METHOD int tx_queues_alloc {
149	if_ctx_t _ctx;
150	caddr_t *_vaddrs;
151	uint64_t *_paddrs;
152	int ntxqs;
153	int ntxqsets;
154};
155
156METHOD int rx_queues_alloc {
157	if_ctx_t _ctx;
158	caddr_t *_vaddrs;
159	uint64_t *_paddrs;
160	int nrxqs;
161	int nrxqsets;
162};
163
164METHOD void queues_free {
165	if_ctx_t _ctx;
166};
167
168#
169# interface reset / stop
170#
171
172METHOD void init {
173	if_ctx_t _ctx;
174};
175
176METHOD void stop {
177	if_ctx_t _ctx;
178};
179
180#
181# interrupt setup and manipulation
182#
183
184METHOD int msix_intr_assign {
185	if_ctx_t _sctx;
186	int msix;
187};
188
189METHOD void intr_enable {
190	if_ctx_t _ctx;
191};
192
193METHOD void intr_disable {
194	if_ctx_t _ctx;
195};
196
197METHOD void queue_intr_enable {
198	if_ctx_t _ctx;
199	uint16_t _qid;
200} DEFAULT null_queue_intr_enable;
201
202METHOD void link_intr_enable {
203	if_ctx_t _ctx;
204} DEFAULT null_void_op;
205
206#
207# interface configuration
208#
209
210METHOD void multi_set {
211	if_ctx_t _ctx;
212};
213
214METHOD int mtu_set {
215	if_ctx_t _ctx;
216	uint32_t _mtu;
217};
218
219METHOD void media_set{
220	if_ctx_t _ctx;
221} DEFAULT null_void_op;
222
223METHOD int promisc_set {
224	if_ctx_t _ctx;
225	int _flags;
226};
227
228METHOD void crcstrip_set {
229	if_ctx_t _ctx;
230	int _onoff;
231};
232
233#
234# IOV handling
235#
236
237METHOD void vflr_handle {
238	if_ctx_t _ctx;
239} DEFAULT null_void_op;
240
241METHOD int iov_init {
242	if_ctx_t _ctx;
243	uint16_t num_vfs;
244	const nvlist_t * params;
245} DEFAULT null_iov_init;
246
247METHOD void iov_uninit {
248	if_ctx_t _ctx;
249} DEFAULT null_void_op;
250
251METHOD int iov_vf_add {
252	if_ctx_t _ctx;
253	uint16_t num_vfs;
254	const nvlist_t * params;
255} DEFAULT null_vf_add;
256
257
258#
259# Device status
260#
261
262METHOD void update_admin_status {
263	if_ctx_t _ctx;
264};
265
266METHOD void media_status {
267	if_ctx_t _ctx;
268	struct ifmediareq *_ifm;
269};
270
271METHOD int media_change {
272	if_ctx_t _ctx;
273};
274
275METHOD uint64_t get_counter {
276	if_ctx_t _ctx;
277	ift_counter cnt;
278};
279
280METHOD int priv_ioctl {
281	if_ctx_t _ctx;
282	u_long   _cmd;
283	caddr_t _data;
284} DEFAULT null_priv_ioctl;
285
286#
287# optional methods
288#
289
290METHOD int i2c_req {
291	if_ctx_t _ctx;
292	struct ifi2creq *_req;
293} DEFAULT null_i2c_req;
294
295METHOD int txq_setup {
296	if_ctx_t _ctx;
297	uint32_t _txqid;
298} DEFAULT null_q_setup;
299
300METHOD int rxq_setup {
301	if_ctx_t _ctx;
302	uint32_t _txqid;
303} DEFAULT null_q_setup;
304
305METHOD void timer {
306	if_ctx_t _ctx;
307	uint16_t _txqid;
308} DEFAULT null_timer_op;
309
310METHOD void watchdog_reset {
311	if_ctx_t _ctx;
312} DEFAULT null_void_op;
313
314METHOD void led_func {
315	if_ctx_t _ctx;
316	int _onoff;
317} DEFAULT null_led_func;
318
319METHOD void vlan_register {
320	if_ctx_t _ctx;
321	uint16_t _vtag;
322} DEFAULT null_vlan_register_op;
323
324METHOD void vlan_unregister {
325	if_ctx_t _ctx;
326	uint16_t _vtag;
327} DEFAULT null_vlan_register_op;
328
329METHOD int sysctl_int_delay {
330	if_ctx_t _sctx;
331	if_int_delay_info_t _iidi;
332} DEFAULT null_sysctl_int_delay;
333
334
335