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