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_private.h>
45 #include <net/if_types.h>
52 null_void_op(if_ctx_t _ctx __unused)
57 null_knlist_add(if_ctx_t _ctx __unused, struct knote *_kn)
63 null_knote_event(if_ctx_t _ctx __unused, struct knote *_kn, int _hint)
69 null_timer_op(if_ctx_t _ctx __unused, uint16_t _qsidx __unused)
74 null_int_op(if_ctx_t _ctx __unused)
80 null_int_int_op(if_ctx_t _ctx __unused, int arg0 __unused)
86 null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused)
92 null_led_func(if_ctx_t _ctx __unused, int _onoff __unused)
97 null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused)
102 null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused)
108 null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused)
114 null_sysctl_int_delay(if_ctx_t _sctx __unused, if_int_delay_info_t _iidi __unused)
120 null_iov_init(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
126 null_vf_add(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused)
132 null_priv_ioctl(if_ctx_t _ctx __unused, u_long command, caddr_t *data __unused)
138 null_media_status(if_ctx_t ctx __unused, struct ifmediareq *ifmr)
140 ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE;
141 ifmr->ifm_active = IFM_ETHER | IFM_25G_ACC | IFM_FDX;
145 null_cloneattach(if_ctx_t ctx __unused, struct if_clone *ifc __unused,
146 const char *name __unused, caddr_t params __unused)
152 null_rx_clset(if_ctx_t _ctx __unused, uint16_t _flid __unused,
153 uint16_t _qid __unused, caddr_t *_sdcl __unused)
157 null_object_info_get(if_ctx_t ctx __unused, void *data __unused, int size __unused)
161 default_mac_set(if_ctx_t ctx, const uint8_t *mac)
163 struct ifnet *ifp = iflib_get_ifp(ctx);
164 struct sockaddr_dl *sdl;
166 if (ifp && ifp->if_addr) {
167 sdl = (struct sockaddr_dl *)ifp->if_addr->ifa_addr;
168 MPASS(sdl->sdl_type == IFT_ETHER);
169 memcpy(LLADDR(sdl), mac, ETHER_ADDR_LEN);
175 null_needs_restart(if_ctx_t _ctx __unused, enum iflib_restart_event _event __unused)
185 METHOD int knlist_add {
188 } DEFAULT null_knlist_add;
190 METHOD int knote_event {
194 } DEFAULT null_knote_event;
201 METHOD int object_info_get {
205 } DEFAULT null_object_info_get;
211 METHOD int attach_pre {
213 } DEFAULT null_int_op;
215 METHOD int attach_post {
217 } DEFAULT null_int_op;
219 METHOD int reinit_pre {
221 } DEFAULT null_int_op;
223 METHOD int reinit_post {
225 } DEFAULT null_int_op;
227 METHOD int cloneattach {
229 struct if_clone *_ifc;
232 } DEFAULT null_cloneattach;
240 } DEFAULT null_int_op;
242 METHOD int shutdown {
244 } DEFAULT null_int_op;
248 } DEFAULT null_int_op;
251 # downcall to driver to allocate its
252 # own queue state and tie it to the parent
255 METHOD int tx_queues_alloc {
263 METHOD int rx_queues_alloc {
271 METHOD void queues_free {
273 } DEFAULT null_void_op;
275 METHOD void rx_clset {
280 } DEFAULT null_rx_clset;
283 # interface reset / stop
295 # interrupt setup and manipulation
298 METHOD int msix_intr_assign {
301 } DEFAULT null_int_int_op;
303 METHOD void intr_enable {
307 METHOD void intr_disable {
311 METHOD int rx_queue_intr_enable {
314 } DEFAULT null_queue_intr_enable;
316 METHOD int tx_queue_intr_enable {
319 } DEFAULT null_queue_intr_enable;
321 METHOD void link_intr_enable {
323 } DEFAULT null_void_op;
325 METHOD void admin_completion_handle {
327 } DEFAULT null_void_op;
330 # interface configuration
333 METHOD void multi_set {
344 } DEFAULT default_mac_set;
346 METHOD void media_set{
348 } DEFAULT null_void_op;
350 METHOD int promisc_set {
355 METHOD void crcstrip_set {
365 METHOD void vflr_handle {
367 } DEFAULT null_void_op;
369 METHOD int iov_init {
372 const nvlist_t * params;
373 } DEFAULT null_iov_init;
375 METHOD void iov_uninit {
377 } DEFAULT null_void_op;
379 METHOD int iov_vf_add {
382 const nvlist_t * params;
383 } DEFAULT null_vf_add;
390 METHOD void update_admin_status {
394 METHOD void media_status {
396 struct ifmediareq *_ifm;
397 } DEFAULT null_media_status;
399 METHOD int media_change {
401 } DEFAULT null_int_op;
403 METHOD uint64_t get_counter {
408 METHOD int priv_ioctl {
412 } DEFAULT null_priv_ioctl;
420 struct ifi2creq *_req;
421 } DEFAULT null_i2c_req;
423 METHOD int txq_setup {
426 } DEFAULT null_q_setup;
428 METHOD int rxq_setup {
431 } DEFAULT null_q_setup;
436 } DEFAULT null_timer_op;
438 METHOD void watchdog_reset {
440 } DEFAULT null_void_op;
442 METHOD void watchdog_reset_queue {
445 } DEFAULT null_timer_op;
447 METHOD void led_func {
450 } DEFAULT null_led_func;
452 METHOD void vlan_register {
455 } DEFAULT null_vlan_register_op;
457 METHOD void vlan_unregister {
460 } DEFAULT null_vlan_register_op;
462 METHOD int sysctl_int_delay {
464 if_int_delay_info_t _iidi;
465 } DEFAULT null_sysctl_int_delay;
469 } DEFAULT null_void_op;
471 METHOD bool needs_restart {
473 enum iflib_restart_event _event;
474 } DEFAULT null_needs_restart;