2 # Copyright (c) 2014-2018, Matthew Macy (mmacy@mattmacy.io)
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.
30 #include <sys/types.h>
31 #include <sys/systm.h>
32 #include <sys/socket.h>
34 #include <machine/bus.h>
37 #include <net/ethernet.h>
39 #include <net/if_var.h>
40 #include <net/if_media.h>
41 #include <net/iflib.h>
42 #include <net/if_clone.h>
43 #include <net/if_dl.h>
44 #include <net/if_types.h>
51 null_void_op(if_ctx_t _ctx __unused)
56 null_knlist_add(if_ctx_t _ctx __unused, struct knote *_kn)
62 null_knote_event(if_ctx_t _ctx __unused, struct knote *_kn, int _hint)
68 null_timer_op(if_ctx_t _ctx __unused, uint16_t _qsidx __unused)
73 null_int_op(if_ctx_t _ctx __unused)
79 null_int_int_op(if_ctx_t _ctx __unused, int arg0 __unused)
85 null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused)
91 null_led_func(if_ctx_t _ctx __unused, int _onoff __unused)
96 null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused)
101 null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused)
107 null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused)
113 null_sysctl_int_delay(if_ctx_t _sctx __unused, if_int_delay_info_t _iidi __unused)
119 null_iov_init(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
125 null_vf_add(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
131 null_priv_ioctl(if_ctx_t _ctx __unused, u_long command, caddr_t *data __unused)
137 null_media_status(if_ctx_t ctx __unused, struct ifmediareq *ifmr)
139 ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE;
140 ifmr->ifm_active = IFM_ETHER | IFM_25G_ACC | IFM_FDX;
144 null_cloneattach(if_ctx_t ctx __unused, struct if_clone *ifc __unused,
145 const char *name __unused, caddr_t params __unused)
151 null_rx_clset(if_ctx_t _ctx __unused, uint16_t _flid __unused,
152 uint16_t _qid __unused, caddr_t *_sdcl __unused)
156 null_object_info_get(if_ctx_t ctx __unused, void *data __unused, int size __unused)
160 default_mac_set(if_ctx_t ctx, const uint8_t *mac)
162 struct ifnet *ifp = iflib_get_ifp(ctx);
163 struct sockaddr_dl *sdl;
165 if (ifp && ifp->if_addr) {
166 sdl = (struct sockaddr_dl *)ifp->if_addr->ifa_addr;
167 MPASS(sdl->sdl_type == IFT_ETHER);
168 memcpy(LLADDR(sdl), mac, ETHER_ADDR_LEN);
178 METHOD int knlist_add {
181 } DEFAULT null_knlist_add;
183 METHOD int knote_event {
187 } DEFAULT null_knote_event;
194 METHOD int object_info_get {
198 } DEFAULT null_object_info_get;
204 METHOD int attach_pre {
206 } DEFAULT null_int_op;
208 METHOD int attach_post {
210 } DEFAULT null_int_op;
212 METHOD int reinit_pre {
214 } DEFAULT null_int_op;
216 METHOD int reinit_post {
218 } DEFAULT null_int_op;
220 METHOD int cloneattach {
222 struct if_clone *_ifc;
225 } DEFAULT null_cloneattach;
233 } DEFAULT null_int_op;
235 METHOD int shutdown {
237 } DEFAULT null_int_op;
241 } DEFAULT null_int_op;
244 # downcall to driver to allocate its
245 # own queue state and tie it to the parent
248 METHOD int tx_queues_alloc {
256 METHOD int rx_queues_alloc {
264 METHOD void queues_free {
266 } DEFAULT null_void_op;
268 METHOD void rx_clset {
273 } DEFAULT null_rx_clset;
276 # interface reset / stop
288 # interrupt setup and manipulation
291 METHOD int msix_intr_assign {
294 } DEFAULT null_int_int_op;
296 METHOD void intr_enable {
300 METHOD void intr_disable {
304 METHOD int rx_queue_intr_enable {
307 } DEFAULT null_queue_intr_enable;
309 METHOD int tx_queue_intr_enable {
312 } DEFAULT null_queue_intr_enable;
314 METHOD void link_intr_enable {
316 } DEFAULT null_void_op;
319 # interface configuration
322 METHOD void multi_set {
333 } DEFAULT default_mac_set;
335 METHOD void media_set{
337 } DEFAULT null_void_op;
339 METHOD int promisc_set {
344 METHOD void crcstrip_set {
354 METHOD void vflr_handle {
356 } DEFAULT null_void_op;
358 METHOD int iov_init {
361 const nvlist_t * params;
362 } DEFAULT null_iov_init;
364 METHOD void iov_uninit {
366 } DEFAULT null_void_op;
368 METHOD int iov_vf_add {
371 const nvlist_t * params;
372 } DEFAULT null_vf_add;
379 METHOD void update_admin_status {
383 METHOD void media_status {
385 struct ifmediareq *_ifm;
386 } DEFAULT null_media_status;
388 METHOD int media_change {
390 } DEFAULT null_int_op;
392 METHOD uint64_t get_counter {
397 METHOD int priv_ioctl {
401 } DEFAULT null_priv_ioctl;
409 struct ifi2creq *_req;
410 } DEFAULT null_i2c_req;
412 METHOD int txq_setup {
415 } DEFAULT null_q_setup;
417 METHOD int rxq_setup {
420 } DEFAULT null_q_setup;
425 } DEFAULT null_timer_op;
427 METHOD void watchdog_reset {
429 } DEFAULT null_void_op;
431 METHOD void watchdog_reset_queue {
434 } DEFAULT null_timer_op;
436 METHOD void led_func {
439 } DEFAULT null_led_func;
441 METHOD void vlan_register {
444 } DEFAULT null_vlan_register_op;
446 METHOD void vlan_unregister {
449 } DEFAULT null_vlan_register_op;
451 METHOD int sysctl_int_delay {
453 if_int_delay_info_t _iidi;
454 } DEFAULT null_sysctl_int_delay;
458 } DEFAULT null_void_op;