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#include <sys/types.h> 28#include <sys/systm.h> 29#include <sys/socket.h> 30 31#include <machine/bus.h> 32#include <sys/bus.h> 33 34#include <net/ethernet.h> 35#include <net/if.h> 36#include <net/if_var.h> 37#include <net/if_media.h> 38#include <net/iflib.h> 39 40INTERFACE ifdi; 41 42CODE { 43 44 static void 45 null_void_op(if_ctx_t _ctx __unused) 46 { 47 } 48 49 static void 50 null_timer_op(if_ctx_t _ctx __unused, uint16_t _qsidx __unused) 51 { 52 } 53 54 static int 55 null_int_op(if_ctx_t _ctx __unused) 56 { 57 return (0); 58 } 59 60 static void 61 null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused) 62 { 63 } 64 65 static void 66 null_led_func(if_ctx_t _ctx __unused, int _onoff __unused) 67 { 68 } 69 70 static void 71 null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused) 72 { 73 } 74 75 static int 76 null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused) 77 { 78 return (0); 79 } 80 81 static int 82 null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused) 83 { 84 return (ENOTSUP); 85 } 86 87 static int 88 null_sysctl_int_delay(if_ctx_t _sctx __unused, if_int_delay_info_t _iidi __unused) 89 { 90 return (0); 91 } 92 93 static int 94 null_iov_init(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused) 95 { 96 return (ENOTSUP); 97 } 98 99 static int 100 null_vf_add(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused) 101 { 102 return (ENOTSUP); 103 } 104 105}; 106 107# 108# bus interfaces 109# 110 111METHOD int attach_pre { 112 if_ctx_t _ctx; 113}; 114 115METHOD int attach_post { 116 if_ctx_t _ctx; 117}; 118 119METHOD int detach { 120 if_ctx_t _ctx; 121}; 122 123METHOD int suspend { 124 if_ctx_t _ctx; 125} DEFAULT null_int_op; 126 127METHOD int shutdown { 128 if_ctx_t _ctx; 129} DEFAULT null_int_op; 130 131METHOD int resume { 132 if_ctx_t _ctx; 133} DEFAULT null_int_op; 134 135# 136# downcall to driver to allocate its 137# own queue state and tie it to the parent 138# 139 140METHOD int queues_alloc { 141 if_ctx_t _ctx; 142 caddr_t *_vaddrs; 143 uint64_t *_paddrs; 144 int nqs; 145}; 146 147METHOD void queues_free { 148 if_ctx_t _ctx; 149}; 150 151# 152# interface reset / stop 153# 154 155METHOD void init { 156 if_ctx_t _ctx; 157}; 158 159METHOD void stop { 160 if_ctx_t _ctx; 161}; 162 163# 164# interrupt setup and manipulation 165# 166 167METHOD int msix_intr_assign { 168 if_ctx_t _sctx; 169 int msix; 170}; 171 172METHOD void intr_enable { 173 if_ctx_t _ctx; 174}; 175 176METHOD void intr_disable { 177 if_ctx_t _ctx; 178}; 179 180METHOD void queue_intr_enable { 181 if_ctx_t _ctx; 182 uint16_t _qid; 183} DEFAULT null_queue_intr_enable; 184 185METHOD void link_intr_enable { 186 if_ctx_t _ctx; 187} DEFAULT null_void_op; 188 189# 190# interface configuration 191# 192 193METHOD void multi_set { 194 if_ctx_t _ctx; 195}; 196 197METHOD int mtu_set { 198 if_ctx_t _ctx; 199 uint32_t _mtu; 200}; 201 202METHOD void media_set{ 203 if_ctx_t _ctx; 204} DEFAULT null_void_op; 205 206METHOD int promisc_set { 207 if_ctx_t _ctx; 208 int _flags; 209}; 210 211# 212# IOV handling 213# 214 215METHOD void vflr_handle { 216 if_ctx_t _ctx; 217} DEFAULT null_void_op; 218 219METHOD int iov_init { 220 if_ctx_t _ctx; 221 uint16_t num_vfs; 222 const nvlist_t * params; 223} DEFAULT null_iov_init; 224 225METHOD void iov_uninit { 226 if_ctx_t _ctx; 227} DEFAULT null_void_op; 228 229METHOD int iov_vf_add { 230 if_ctx_t _ctx; 231 uint16_t num_vfs; 232 const nvlist_t * params; 233} DEFAULT null_vf_add; 234 235 236# 237# Device status 238# 239 240METHOD void update_admin_status { 241 if_ctx_t _ctx; 242}; 243 244METHOD void media_status { 245 if_ctx_t _ctx; 246 struct ifmediareq *_ifm; 247}; 248 249METHOD int media_change { 250 if_ctx_t _ctx; 251}; 252 253METHOD uint64_t get_counter { 254 if_ctx_t _sctx; 255 ift_counter cnt; 256}; 257 258# 259# optional methods 260# 261 262METHOD int i2c_req { 263 if_ctx_t _ctx; 264 struct ifi2creq *_req; 265} DEFAULT null_i2c_req; 266 267METHOD int txq_setup { 268 if_ctx_t _ctx; 269 uint32_t _txqid; 270} DEFAULT null_q_setup; 271 272METHOD int rxq_setup { 273 if_ctx_t _ctx; 274 uint32_t _txqid; 275} DEFAULT null_q_setup; 276 277METHOD void timer { 278 if_ctx_t _ctx; 279 uint16_t _txqid; 280} DEFAULT null_timer_op; 281 282METHOD void watchdog_reset { 283 if_ctx_t _ctx; 284} DEFAULT null_void_op; 285 286METHOD void led_func { 287 if_ctx_t _ctx; 288 int _onoff; 289} DEFAULT null_led_func; 290 291METHOD void vlan_register { 292 if_ctx_t _ctx; 293 uint16_t _vtag; 294} DEFAULT null_vlan_register_op; 295 296METHOD void vlan_unregister { 297 if_ctx_t _ctx; 298 uint16_t _vtag; 299} DEFAULT null_vlan_register_op; 300 301METHOD int sysctl_int_delay { 302 if_ctx_t _sctx; 303 if_int_delay_info_t _iidi; 304} DEFAULT null_sysctl_int_delay; 305 306 307