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