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);
174 null_needs_restart(if_ctx_t _ctx __unused, enum iflib_restart_event _event __unused)
184 METHOD int knlist_add {
187 } DEFAULT null_knlist_add;
189 METHOD int knote_event {
193 } DEFAULT null_knote_event;
200 METHOD int object_info_get {
204 } DEFAULT null_object_info_get;
210 METHOD int attach_pre {
212 } DEFAULT null_int_op;
214 METHOD int attach_post {
216 } DEFAULT null_int_op;
218 METHOD int reinit_pre {
220 } DEFAULT null_int_op;
222 METHOD int reinit_post {
224 } DEFAULT null_int_op;
226 METHOD int cloneattach {
228 struct if_clone *_ifc;
231 } DEFAULT null_cloneattach;
239 } DEFAULT null_int_op;
241 METHOD int shutdown {
243 } DEFAULT null_int_op;
247 } DEFAULT null_int_op;
250 # downcall to driver to allocate its
251 # own queue state and tie it to the parent
254 METHOD int tx_queues_alloc {
262 METHOD int rx_queues_alloc {
270 METHOD void queues_free {
272 } DEFAULT null_void_op;
274 METHOD void rx_clset {
279 } DEFAULT null_rx_clset;
282 # interface reset / stop
294 # interrupt setup and manipulation
297 METHOD int msix_intr_assign {
300 } DEFAULT null_int_int_op;
302 METHOD void intr_enable {
306 METHOD void intr_disable {
310 METHOD int rx_queue_intr_enable {
313 } DEFAULT null_queue_intr_enable;
315 METHOD int tx_queue_intr_enable {
318 } DEFAULT null_queue_intr_enable;
320 METHOD void link_intr_enable {
322 } DEFAULT null_void_op;
325 # interface configuration
328 METHOD void multi_set {
339 } DEFAULT default_mac_set;
341 METHOD void media_set{
343 } DEFAULT null_void_op;
345 METHOD int promisc_set {
350 METHOD void crcstrip_set {
360 METHOD void vflr_handle {
362 } DEFAULT null_void_op;
364 METHOD int iov_init {
367 const nvlist_t * params;
368 } DEFAULT null_iov_init;
370 METHOD void iov_uninit {
372 } DEFAULT null_void_op;
374 METHOD int iov_vf_add {
377 const nvlist_t * params;
378 } DEFAULT null_vf_add;
385 METHOD void update_admin_status {
389 METHOD void media_status {
391 struct ifmediareq *_ifm;
392 } DEFAULT null_media_status;
394 METHOD int media_change {
396 } DEFAULT null_int_op;
398 METHOD uint64_t get_counter {
403 METHOD int priv_ioctl {
407 } DEFAULT null_priv_ioctl;
415 struct ifi2creq *_req;
416 } DEFAULT null_i2c_req;
418 METHOD int txq_setup {
421 } DEFAULT null_q_setup;
423 METHOD int rxq_setup {
426 } DEFAULT null_q_setup;
431 } DEFAULT null_timer_op;
433 METHOD void watchdog_reset {
435 } DEFAULT null_void_op;
437 METHOD void watchdog_reset_queue {
440 } DEFAULT null_timer_op;
442 METHOD void led_func {
445 } DEFAULT null_led_func;
447 METHOD void vlan_register {
450 } DEFAULT null_vlan_register_op;
452 METHOD void vlan_unregister {
455 } DEFAULT null_vlan_register_op;
457 METHOD int sysctl_int_delay {
459 if_int_delay_info_t _iidi;
460 } DEFAULT null_sysctl_int_delay;
464 } DEFAULT null_void_op;
466 METHOD bool needs_restart {
468 enum iflib_restart_event _event;
469 } DEFAULT null_needs_restart;