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# $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 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 116# 117# bus interfaces 118# 119 120METHOD int attach_pre { 121 if_ctx_t _ctx; 122}; 123 124METHOD int attach_post { 125 if_ctx_t _ctx; 126}; 127 128METHOD int detach { 129 if_ctx_t _ctx; 130}; 131 132METHOD int suspend { 133 if_ctx_t _ctx; 134} DEFAULT null_int_op; 135 136METHOD int shutdown { 137 if_ctx_t _ctx; 138} DEFAULT null_int_op; 139 140METHOD int resume { 141 if_ctx_t _ctx; 142} DEFAULT null_int_op; 143 144# 145# downcall to driver to allocate its 146# own queue state and tie it to the parent 147# 148 149METHOD int tx_queues_alloc { 150 if_ctx_t _ctx; 151 caddr_t *_vaddrs; 152 uint64_t *_paddrs; 153 int ntxqs; 154 int ntxqsets; 155}; 156 157METHOD int rx_queues_alloc { 158 if_ctx_t _ctx; 159 caddr_t *_vaddrs; 160 uint64_t *_paddrs; 161 int nrxqs; 162 int nrxqsets; 163}; 164 165METHOD void queues_free { 166 if_ctx_t _ctx; 167}; 168 169# 170# interface reset / stop 171# 172 173METHOD void init { 174 if_ctx_t _ctx; 175}; 176 177METHOD void stop { 178 if_ctx_t _ctx; 179}; 180 181# 182# interrupt setup and manipulation 183# 184 185METHOD int msix_intr_assign { 186 if_ctx_t _sctx; 187 int msix; 188}; 189 190METHOD void intr_enable { 191 if_ctx_t _ctx; 192}; 193 194METHOD void intr_disable { 195 if_ctx_t _ctx; 196}; 197 198METHOD int queue_intr_enable { 199 if_ctx_t _ctx; 200 uint16_t _qid; 201} DEFAULT null_queue_intr_enable; 202 203METHOD void link_intr_enable { 204 if_ctx_t _ctx; 205} DEFAULT null_void_op; 206 207# 208# interface configuration 209# 210 211METHOD void multi_set { 212 if_ctx_t _ctx; 213}; 214 215METHOD int mtu_set { 216 if_ctx_t _ctx; 217 uint32_t _mtu; 218}; 219 220METHOD void media_set{ 221 if_ctx_t _ctx; 222} DEFAULT null_void_op; 223 224METHOD int promisc_set { 225 if_ctx_t _ctx; 226 int _flags; 227}; 228 229METHOD void crcstrip_set { 230 if_ctx_t _ctx; 231 int _onoff; 232 int _strip; 233}; 234 235# 236# IOV handling 237# 238 239METHOD void vflr_handle { 240 if_ctx_t _ctx; 241} DEFAULT null_void_op; 242 243METHOD int iov_init { 244 if_ctx_t _ctx; 245 uint16_t num_vfs; 246 const nvlist_t * params; 247} DEFAULT null_iov_init; 248 249METHOD void iov_uninit { 250 if_ctx_t _ctx; 251} DEFAULT null_void_op; 252 253METHOD int iov_vf_add { 254 if_ctx_t _ctx; 255 uint16_t num_vfs; 256 const nvlist_t * params; 257} DEFAULT null_vf_add; 258 259 260# 261# Device status 262# 263 264METHOD void update_admin_status { 265 if_ctx_t _ctx; 266}; 267 268METHOD void media_status { 269 if_ctx_t _ctx; 270 struct ifmediareq *_ifm; 271}; 272 273METHOD int media_change { 274 if_ctx_t _ctx; 275}; 276 277METHOD uint64_t get_counter { 278 if_ctx_t _ctx; 279 ift_counter cnt; 280}; 281 282METHOD int priv_ioctl { 283 if_ctx_t _ctx; 284 u_long _cmd; 285 caddr_t _data; 286} DEFAULT null_priv_ioctl; 287 288# 289# optional methods 290# 291 292METHOD int i2c_req { 293 if_ctx_t _ctx; 294 struct ifi2creq *_req; 295} DEFAULT null_i2c_req; 296 297METHOD int txq_setup { 298 if_ctx_t _ctx; 299 uint32_t _txqid; 300} DEFAULT null_q_setup; 301 302METHOD int rxq_setup { 303 if_ctx_t _ctx; 304 uint32_t _txqid; 305} DEFAULT null_q_setup; 306 307METHOD void timer { 308 if_ctx_t _ctx; 309 uint16_t _txqid; 310} DEFAULT null_timer_op; 311 312METHOD void watchdog_reset { 313 if_ctx_t _ctx; 314} DEFAULT null_void_op; 315 316METHOD void led_func { 317 if_ctx_t _ctx; 318 int _onoff; 319} DEFAULT null_led_func; 320 321METHOD void vlan_register { 322 if_ctx_t _ctx; 323 uint16_t _vtag; 324} DEFAULT null_vlan_register_op; 325 326METHOD void vlan_unregister { 327 if_ctx_t _ctx; 328 uint16_t _vtag; 329} DEFAULT null_vlan_register_op; 330 331METHOD int sysctl_int_delay { 332 if_ctx_t _sctx; 333 if_int_delay_info_t _iidi; 334} DEFAULT null_sysctl_int_delay; 335 336 337