1 /* 2 * This file is produced automatically. 3 * Do not modify anything in here by hand. 4 * 5 * Created from source file 6 * sys/net/ifdi_if.m 7 # 8 # Copyright (c) 2014-2018, Matthew Macy (mmacy@mattmacy.io) 9 # All rights reserved. 10 # 11 # Redistribution and use in source and binary forms, with or without 12 # modification, are permitted provided that the following conditions are met: 13 # 14 # 1. Redistributions of source code must retain the above copyright notice, 15 # this list of conditions and the following disclaimer. 16 # 17 # 2. Neither the name of Matthew Macy nor the names of its 18 # contributors may be used to endorse or promote products derived from 19 # this software without specific prior written permission. 20 # 21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 25 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 # POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <sys/param.h> 35 #include <sys/queue.h> 36 #include <sys/kernel.h> 37 #include <sys/kobj.h> 38 #include <sys/types.h> 39 #include <sys/systm.h> 40 #include <sys/socket.h> 41 #include <machine/bus.h> 42 #include <sys/bus.h> 43 #include <net/ethernet.h> 44 #include <net/if.h> 45 #include <net/if_var.h> 46 #include <net/if_media.h> 47 #include <net/iflib.h> 48 #include <net/if_dl.h> 49 #include <net/if_types.h> 50 #include <ifdi_if.h> 51 52 53 54 static void 55 null_void_op(if_ctx_t _ctx __unused) 56 { 57 } 58 59 #ifndef __HAIKU__ 60 static int 61 null_knlist_add(if_ctx_t _ctx __unused, struct knote *_kn) 62 { 63 return (0); 64 } 65 66 static int 67 null_knote_event(if_ctx_t _ctx __unused, struct knote *_kn, int _hint) 68 { 69 return (0); 70 } 71 #endif 72 73 static void 74 null_timer_op(if_ctx_t _ctx __unused, uint16_t _qsidx __unused) 75 { 76 } 77 78 static int 79 null_int_op(if_ctx_t _ctx __unused) 80 { 81 return (0); 82 } 83 84 static int 85 null_int_int_op(if_ctx_t _ctx __unused, int arg0 __unused) 86 { 87 return (ENOTSUP); 88 } 89 90 static int 91 null_queue_intr_enable(if_ctx_t _ctx __unused, uint16_t _qid __unused) 92 { 93 return (ENOTSUP); 94 } 95 96 static void 97 null_led_func(if_ctx_t _ctx __unused, int _onoff __unused) 98 { 99 } 100 101 static void 102 null_vlan_register_op(if_ctx_t _ctx __unused, uint16_t vtag __unused) 103 { 104 } 105 106 static bool 107 null_needs_restart_op(if_ctx_t _ctx __unused, enum iflib_restart_event _event __unused) 108 { 109 } 110 111 static int 112 null_q_setup(if_ctx_t _ctx __unused, uint32_t _qid __unused) 113 { 114 return (0); 115 } 116 117 static int 118 null_i2c_req(if_ctx_t _sctx __unused, struct ifi2creq *_i2c __unused) 119 { 120 return (ENOTSUP); 121 } 122 123 static int 124 null_sysctl_int_delay(if_ctx_t _sctx __unused, if_int_delay_info_t _iidi __unused) 125 { 126 return (0); 127 } 128 129 static int 130 null_iov_init(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused) 131 { 132 return (ENOTSUP); 133 } 134 135 static int 136 null_vf_add(if_ctx_t _ctx __unused, uint16_t num_vfs __unused, const nvlist_t *params __unused) 137 { 138 return (ENOTSUP); 139 } 140 141 static int 142 null_priv_ioctl(if_ctx_t _ctx __unused, u_long command, caddr_t *data __unused) 143 { 144 return (ENOTSUP); 145 } 146 147 static void 148 null_media_status(if_ctx_t ctx __unused, struct ifmediareq *ifmr) 149 { 150 ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE; 151 ifmr->ifm_active = IFM_ETHER | IFM_FDX; 152 } 153 154 static int 155 null_cloneattach(if_ctx_t ctx __unused, struct if_clone *ifc __unused, 156 const char *name __unused, caddr_t params __unused) 157 { 158 return (0); 159 } 160 161 static void 162 null_rx_clset(if_ctx_t _ctx __unused, uint16_t _flid __unused, 163 uint16_t _qid __unused, caddr_t *_sdcl __unused) 164 { 165 } 166 static void 167 null_object_info_get(if_ctx_t ctx __unused, void *data __unused, int size __unused) 168 { 169 } 170 static int 171 default_mac_set(if_ctx_t ctx, const uint8_t *mac) 172 { 173 struct ifnet *ifp = iflib_get_ifp(ctx); 174 struct sockaddr_dl *sdl; 175 176 if (ifp && ifp->if_addr) { 177 sdl = (struct sockaddr_dl *)ifp->if_addr->ifa_addr; 178 MPASS(sdl->sdl_type == IFT_ETHER); 179 memcpy(LLADDR(sdl), mac, ETHER_ADDR_LEN); 180 } 181 return (0); 182 } 183 184 #ifndef __HAIKU__ 185 struct kobjop_desc ifdi_knlist_add_desc = { 186 0, { NULL, ID_ifdi_knlist_add, (kobjop_t)null_knlist_add } 187 }; 188 189 struct kobjop_desc ifdi_knote_event_desc = { 190 0, { NULL, ID_ifdi_knote_event, (kobjop_t)null_knote_event } 191 }; 192 #endif 193 194 struct kobjop_desc ifdi_object_info_get_desc = { 195 0, { NULL, ID_ifdi_object_info_get, (kobjop_t)null_object_info_get } 196 }; 197 198 struct kobjop_desc ifdi_attach_pre_desc = { 199 0, { NULL, ID_ifdi_attach_pre, (kobjop_t)null_int_op } 200 }; 201 202 struct kobjop_desc ifdi_attach_post_desc = { 203 0, { NULL, ID_ifdi_attach_post, (kobjop_t)null_int_op } 204 }; 205 206 struct kobjop_desc ifdi_reinit_pre_desc = { 207 0, { NULL, ID_ifdi_reinit_pre, (kobjop_t)null_int_op } 208 }; 209 210 struct kobjop_desc ifdi_reinit_post_desc = { 211 0, { NULL, ID_ifdi_reinit_post, (kobjop_t)null_int_op } 212 }; 213 214 struct kobjop_desc ifdi_cloneattach_desc = { 215 0, { NULL, ID_ifdi_cloneattach, (kobjop_t)null_cloneattach } 216 }; 217 218 struct kobjop_desc ifdi_detach_desc = { 219 0, { NULL, ID_ifdi_detach, (kobjop_t)kobj_error_method } 220 }; 221 222 struct kobjop_desc ifdi_suspend_desc = { 223 0, { NULL, ID_ifdi_suspend, (kobjop_t)null_int_op } 224 }; 225 226 struct kobjop_desc ifdi_shutdown_desc = { 227 0, { NULL, ID_ifdi_shutdown, (kobjop_t)null_int_op } 228 }; 229 230 struct kobjop_desc ifdi_resume_desc = { 231 0, { NULL, ID_ifdi_resume, (kobjop_t)null_int_op } 232 }; 233 234 struct kobjop_desc ifdi_tx_queues_alloc_desc = { 235 0, { NULL, ID_ifdi_tx_queues_alloc, (kobjop_t)kobj_error_method } 236 }; 237 238 struct kobjop_desc ifdi_rx_queues_alloc_desc = { 239 0, { NULL, ID_ifdi_rx_queues_alloc, (kobjop_t)kobj_error_method } 240 }; 241 242 struct kobjop_desc ifdi_queues_free_desc = { 243 0, { NULL, ID_ifdi_queues_free, (kobjop_t)null_void_op } 244 }; 245 246 struct kobjop_desc ifdi_rx_clset_desc = { 247 0, { NULL, ID_ifdi_rx_clset, (kobjop_t)null_rx_clset } 248 }; 249 250 struct kobjop_desc ifdi_init_desc = { 251 0, { NULL, ID_ifdi_init, (kobjop_t)kobj_error_method } 252 }; 253 254 struct kobjop_desc ifdi_stop_desc = { 255 0, { NULL, ID_ifdi_stop, (kobjop_t)kobj_error_method } 256 }; 257 258 struct kobjop_desc ifdi_msix_intr_assign_desc = { 259 0, { NULL, ID_ifdi_msix_intr_assign, (kobjop_t)null_int_int_op } 260 }; 261 262 struct kobjop_desc ifdi_intr_enable_desc = { 263 0, { NULL, ID_ifdi_intr_enable, (kobjop_t)kobj_error_method } 264 }; 265 266 struct kobjop_desc ifdi_intr_disable_desc = { 267 0, { NULL, ID_ifdi_intr_disable, (kobjop_t)kobj_error_method } 268 }; 269 270 struct kobjop_desc ifdi_rx_queue_intr_enable_desc = { 271 0, { NULL, ID_ifdi_rx_queue_intr_enable, (kobjop_t)null_queue_intr_enable } 272 }; 273 274 struct kobjop_desc ifdi_tx_queue_intr_enable_desc = { 275 0, { NULL, ID_ifdi_tx_queue_intr_enable, (kobjop_t)null_queue_intr_enable } 276 }; 277 278 struct kobjop_desc ifdi_link_intr_enable_desc = { 279 0, { NULL, ID_ifdi_link_intr_enable, (kobjop_t)null_void_op } 280 }; 281 282 struct kobjop_desc ifdi_multi_set_desc = { 283 0, { NULL, ID_ifdi_multi_set, (kobjop_t)kobj_error_method } 284 }; 285 286 struct kobjop_desc ifdi_mtu_set_desc = { 287 0, { NULL, ID_ifdi_mtu_set, (kobjop_t)kobj_error_method } 288 }; 289 290 struct kobjop_desc ifdi_mac_set_desc = { 291 0, { NULL, ID_ifdi_mac_set, (kobjop_t)default_mac_set } 292 }; 293 294 struct kobjop_desc ifdi_media_set_desc = { 295 0, { NULL, ID_ifdi_media_set, (kobjop_t)null_void_op } 296 }; 297 298 struct kobjop_desc ifdi_promisc_set_desc = { 299 0, { NULL, ID_ifdi_promisc_set, (kobjop_t)kobj_error_method } 300 }; 301 302 struct kobjop_desc ifdi_crcstrip_set_desc = { 303 0, { NULL, ID_ifdi_crcstrip_set, (kobjop_t)kobj_error_method } 304 }; 305 306 struct kobjop_desc ifdi_vflr_handle_desc = { 307 0, { NULL, ID_ifdi_vflr_handle, (kobjop_t)null_void_op } 308 }; 309 310 struct kobjop_desc ifdi_iov_init_desc = { 311 0, { NULL, ID_ifdi_iov_init, (kobjop_t)null_iov_init } 312 }; 313 314 struct kobjop_desc ifdi_iov_uninit_desc = { 315 0, { NULL, ID_ifdi_iov_uninit, (kobjop_t)null_void_op } 316 }; 317 318 struct kobjop_desc ifdi_iov_vf_add_desc = { 319 0, { NULL, ID_ifdi_iov_vf_add, (kobjop_t)null_vf_add } 320 }; 321 322 struct kobjop_desc ifdi_update_admin_status_desc = { 323 0, { NULL, ID_ifdi_update_admin_status, (kobjop_t)kobj_error_method } 324 }; 325 326 struct kobjop_desc ifdi_media_status_desc = { 327 0, { NULL, ID_ifdi_media_status, (kobjop_t)null_media_status } 328 }; 329 330 struct kobjop_desc ifdi_media_change_desc = { 331 0, { NULL, ID_ifdi_media_change, (kobjop_t)null_int_op } 332 }; 333 334 struct kobjop_desc ifdi_get_counter_desc = { 335 0, { NULL, ID_ifdi_get_counter, (kobjop_t)kobj_error_method } 336 }; 337 338 struct kobjop_desc ifdi_priv_ioctl_desc = { 339 0, { NULL, ID_ifdi_priv_ioctl, (kobjop_t)null_priv_ioctl } 340 }; 341 342 struct kobjop_desc ifdi_i2c_req_desc = { 343 0, { NULL, ID_ifdi_i2c_req, (kobjop_t)null_i2c_req } 344 }; 345 346 struct kobjop_desc ifdi_txq_setup_desc = { 347 0, { NULL, ID_ifdi_txq_setup, (kobjop_t)null_q_setup } 348 }; 349 350 struct kobjop_desc ifdi_rxq_setup_desc = { 351 0, { NULL, ID_ifdi_rxq_setup, (kobjop_t)null_q_setup } 352 }; 353 354 struct kobjop_desc ifdi_timer_desc = { 355 0, { NULL, ID_ifdi_timer, (kobjop_t)null_timer_op } 356 }; 357 358 struct kobjop_desc ifdi_watchdog_reset_desc = { 359 0, { NULL, ID_ifdi_watchdog_reset, (kobjop_t)null_void_op } 360 }; 361 362 struct kobjop_desc ifdi_watchdog_reset_queue_desc = { 363 0, { NULL, ID_ifdi_watchdog_reset_queue, (kobjop_t)null_timer_op } 364 }; 365 366 struct kobjop_desc ifdi_led_func_desc = { 367 0, { NULL, ID_ifdi_led_func, (kobjop_t)null_led_func } 368 }; 369 370 struct kobjop_desc ifdi_vlan_register_desc = { 371 0, { NULL, ID_ifdi_vlan_register, (kobjop_t)null_vlan_register_op } 372 }; 373 374 struct kobjop_desc ifdi_vlan_unregister_desc = { 375 0, { NULL, ID_ifdi_vlan_unregister, (kobjop_t)null_vlan_register_op } 376 }; 377 378 struct kobjop_desc ifdi_sysctl_int_delay_desc = { 379 0, { NULL, ID_ifdi_sysctl_int_delay, (kobjop_t)null_sysctl_int_delay } 380 }; 381 382 struct kobjop_desc ifdi_debug_desc = { 383 0, { NULL, ID_ifdi_debug, (kobjop_t)null_void_op } 384 }; 385 386 struct kobjop_desc ifdi_needs_restart_desc = { 387 0, { NULL, ID_ifdi_needs_restart, (kobjop_t)null_needs_restart_op } 388 }; 389