ed(1): simplify by using arc4random_buf().
[freebsd-src.git] / sys / net / ifdi_if.m
blob60629e46b6cd5c4cb851a2fd104f6518fead267f
2 # Copyright (c) 2014, Matthew Macy (kmacy@freebsd.org)
3 # All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
8 #  1. Redistributions of source code must retain the above copyright notice,
9 #     this list of conditions and the following disclaimer.
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.
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.
27 # $FreeBSD$
30 #include <sys/types.h>
31 #include <sys/systm.h>
32 #include <sys/socket.h>
34 #include <machine/bus.h>
35 #include <sys/bus.h>
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>
43 INTERFACE ifdi;
45 CODE {
47         static void
48         null_void_op(if_ctx_t _ctx __unused)
49         {
50         }
52         static void
53         null_timer_op(if_ctx_t _ctx __unused, uint16_t _qsidx __unused)
54         {
55         }
57         static int
58         null_int_op(if_ctx_t _ctx __unused)
59         {
60                 return (0);
61         }
63         static void
64         null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused)
65         {
66         }
68         static void
69         null_led_func(if_ctx_t _ctx __unused, int _onoff __unused)
70         {
71         }
73         static void
74         null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused)
75         {
76         }
78         static int
79         null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused)
80         {
81                 return (0);
82         }
84         static int
85         null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused)
86         {
87                 return (ENOTSUP);
88         }
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         }
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         }
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         }
108         static int
109         null_priv_ioctl(if_ctx_t _ctx __unused, u_long command, caddr_t *data __unused)
110         {
111                 return (ENOTSUP);
112         }
116 # bus interfaces
119 METHOD int attach_pre {
120         if_ctx_t _ctx;
123 METHOD int attach_post {
124         if_ctx_t _ctx;
127 METHOD int detach {
128         if_ctx_t _ctx;
131 METHOD int suspend {
132         if_ctx_t _ctx;
133 } DEFAULT null_int_op;
135 METHOD int shutdown {
136         if_ctx_t _ctx;
137 } DEFAULT null_int_op;
139 METHOD int resume {
140         if_ctx_t _ctx;
141 } DEFAULT null_int_op;
144 # downcall to driver to allocate its
145 # own queue state and tie it to the parent
148 METHOD int tx_queues_alloc {
149         if_ctx_t _ctx;
150         caddr_t *_vaddrs;
151         uint64_t *_paddrs;
152         int ntxqs;
153         int ntxqsets;
156 METHOD int rx_queues_alloc {
157         if_ctx_t _ctx;
158         caddr_t *_vaddrs;
159         uint64_t *_paddrs;
160         int nrxqs;
161         int nrxqsets;
164 METHOD void queues_free {
165         if_ctx_t _ctx;
169 # interface reset / stop
172 METHOD void init {
173         if_ctx_t _ctx;
176 METHOD void stop {
177         if_ctx_t _ctx;
181 # interrupt setup and manipulation
184 METHOD int msix_intr_assign {
185         if_ctx_t _sctx;
186         int msix;
189 METHOD void intr_enable {
190         if_ctx_t _ctx;
193 METHOD void intr_disable {
194         if_ctx_t _ctx;
197 METHOD void queue_intr_enable {
198         if_ctx_t _ctx;
199         uint16_t _qid;
200 } DEFAULT null_queue_intr_enable;
202 METHOD void link_intr_enable {
203         if_ctx_t _ctx;
204 } DEFAULT null_void_op;
207 # interface configuration
210 METHOD void multi_set {
211         if_ctx_t _ctx;
214 METHOD int mtu_set {
215         if_ctx_t _ctx;
216         uint32_t _mtu;
219 METHOD void media_set{
220         if_ctx_t _ctx;
221 } DEFAULT null_void_op;
223 METHOD int promisc_set {
224         if_ctx_t _ctx;
225         int _flags;
228 METHOD void crcstrip_set {
229         if_ctx_t _ctx;
230         int _onoff;
234 # IOV handling
237 METHOD void vflr_handle {
238         if_ctx_t _ctx;
239 } DEFAULT null_void_op;
241 METHOD int iov_init {
242         if_ctx_t _ctx;
243         uint16_t num_vfs;
244         const nvlist_t * params;
245 } DEFAULT null_iov_init;
247 METHOD void iov_uninit {
248         if_ctx_t _ctx;
249 } DEFAULT null_void_op;
251 METHOD int iov_vf_add {
252         if_ctx_t _ctx;
253         uint16_t num_vfs;
254         const nvlist_t * params;
255 } DEFAULT null_vf_add;
259 # Device status
262 METHOD void update_admin_status {
263         if_ctx_t _ctx;
266 METHOD void media_status {
267         if_ctx_t _ctx;
268         struct ifmediareq *_ifm;
271 METHOD int media_change {
272         if_ctx_t _ctx;
275 METHOD uint64_t get_counter {
276         if_ctx_t _ctx;
277         ift_counter cnt;
280 METHOD int priv_ioctl {
281         if_ctx_t _ctx;
282         u_long   _cmd;
283         caddr_t _data;
284 } DEFAULT null_priv_ioctl;
287 # optional methods
290 METHOD int i2c_req {
291         if_ctx_t _ctx;
292         struct ifi2creq *_req;
293 } DEFAULT null_i2c_req;
295 METHOD int txq_setup {
296         if_ctx_t _ctx;
297         uint32_t _txqid;
298 } DEFAULT null_q_setup;
300 METHOD int rxq_setup {
301         if_ctx_t _ctx;
302         uint32_t _txqid;
303 } DEFAULT null_q_setup;
305 METHOD void timer {
306         if_ctx_t _ctx;
307         uint16_t _txqid;
308 } DEFAULT null_timer_op;
310 METHOD void watchdog_reset {
311         if_ctx_t _ctx;
312 } DEFAULT null_void_op;
314 METHOD void led_func {
315         if_ctx_t _ctx;
316         int _onoff;
317 } DEFAULT null_led_func;
319 METHOD void vlan_register {
320         if_ctx_t _ctx;
321         uint16_t _vtag;
322 } DEFAULT null_vlan_register_op;
324 METHOD void vlan_unregister {
325         if_ctx_t _ctx;
326         uint16_t _vtag;
327 } DEFAULT null_vlan_register_op;
329 METHOD int sysctl_int_delay {
330         if_ctx_t _sctx;
331         if_int_delay_info_t _iidi;
332 } DEFAULT null_sysctl_int_delay;