1 /* $NetBSD: netif.h,v 1.8 2024/02/27 16:09:19 christos Exp $ */ 2 3 /*- 4 * Copyright (c) 2024 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 #ifndef __SYS_LIBNETBOOT_NETIF_H 30 #define __SYS_LIBNETBOOT_NETIF_H 31 32 #include "iodesc.h" 33 34 struct netif; /* forward */ 35 36 struct netif_driver { 37 char *netif_bname; 38 int (*netif_match)(struct netif *, void *); 39 int (*netif_probe)(struct netif *, void *); 40 void (*netif_init)(struct iodesc *, void *); 41 int (*netif_get)(struct iodesc *, void *, size_t, saseconds_t); 42 int (*netif_put)(struct iodesc *, void *, size_t); 43 void (*netif_end)(struct netif *); 44 struct netif_dif *netif_ifs; 45 int netif_nifs; 46 }; 47 48 struct netif_dif { 49 int dif_unit; 50 int dif_nsel; 51 struct netif_stats *dif_stats; 52 void *dif_private; 53 /* the following fields are used internally by the netif layer */ 54 u_long dif_used; 55 }; 56 57 struct netif_stats { 58 int collisions; 59 int collision_error; 60 int missed; 61 int sent; 62 int received; 63 int deferred; 64 int overflow; 65 }; 66 67 struct netif { 68 struct netif_driver *nif_driver; 69 int nif_unit; 70 int nif_sel; 71 void *nif_devdata; 72 }; 73 74 extern struct netif_driver *netif_drivers[]; /* machdep */ 75 extern int n_netif_drivers; 76 77 extern int netif_debug; 78 79 void netif_init(void); 80 struct netif *netif_select(void *); 81 int netif_probe(struct netif *, void *); 82 void netif_attach(struct netif *, struct iodesc *, void *); 83 void netif_detach(struct netif *); 84 85 int netif_open(void *); 86 int netif_close(int); 87 88 #endif /* __SYS_LIBNETBOOT_NETIF_H */ 89