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