freebsd_network: Additions and modifications for FreeBSD 14.x drivers.
* Add more if_{get|set}* routines, and move all copied directly from
FreeBSD into a fbsd_if.c file. Also clean up the header.
* DRIVER_MODULE macros dropped the "devclass" parameter.
In order to not break all existing drivers, use FreeBSD's
interim solution of compatibility macros.
This commit is contained in:
@@ -11,6 +11,7 @@ SubDirC++Flags [ FDefines _KERNEL=1 ] ;
|
||||
|
||||
KernelStaticLibrary libfreebsd_network.a :
|
||||
fbsd_ether.c
|
||||
fbsd_if.c
|
||||
fbsd_if_media.c
|
||||
fbsd_kern_mbuf.c
|
||||
fbsd_uipc_mbuf.c
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$FreeBSD: stable/11/sys/dev/mii/miidevs 337755 2018-08-14 14:17:20Z markj $
|
||||
$FreeBSD$
|
||||
/*$NetBSD: miidevs,v 1.105 2011/11/25 23:28:14 jakllsch Exp $*/
|
||||
|
||||
/*-
|
||||
@@ -33,7 +33,7 @@ $FreeBSD: stable/11/sys/dev/mii/miidevs 337755 2018-08-14 14:17:20Z markj $
|
||||
|
||||
/*
|
||||
* List of known MII OUIs.
|
||||
* For a complete list see http://standards.ieee.org/regauth/oui/
|
||||
* For a complete list see http://standards-oui.ieee.org/
|
||||
*
|
||||
* XXX Vendors do obviously not agree how OUIs (24 bit) are mapped
|
||||
* to the 22 bits available in the id registers.
|
||||
@@ -63,6 +63,7 @@ oui JMICRON 0x00d831 JMicron Technologies
|
||||
oui LEVEL1 0x00207b Level 1
|
||||
oui MARVELL 0x005043 Marvell Semiconductor
|
||||
oui MICREL 0x0010a1 Micrel
|
||||
oui MOTORCOMM 0x000000 Motorcomm
|
||||
oui MYSON 0x00c0b4 Myson Technology
|
||||
oui NATSEMI 0x080017 National Semiconductor
|
||||
oui PMCSIERRA 0x00e004 PMC-Sierra
|
||||
@@ -110,6 +111,7 @@ oui xxPMCSIERRA 0x0009c0 PMC-Sierra
|
||||
oui xxPMCSIERRA2 0x009057 PMC-Sierra
|
||||
oui xxREALTEK 0x000732 RealTek Semicondctor
|
||||
oui yyREALTEK 0x000004 RealTek Semicondctor
|
||||
oui xxTI 0x100014 Texas Instruments
|
||||
|
||||
/*
|
||||
* List of known models. Grouped by oui.
|
||||
@@ -190,11 +192,14 @@ model BROADCOM2 BCM5784 0x003a BCM5784 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5709C 0x003c BCM5709 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5761 0x003d BCM5761 10/100/1000baseT PHY
|
||||
model BROADCOM2 BCM5709S 0x003f BCM5709S/5720S 1000/2500baseSX PHY
|
||||
model BROADCOM3 BCM54618SE 0x000d BCM54618SE 10/100/1000BASE-T PHY
|
||||
model BROADCOM3 BCM54616S 0x0011 BCM54616S 10/100/1000BASE-T PHY
|
||||
model BROADCOM3 BCM57780 0x0019 BCM57780 1000BASE-T media interface
|
||||
model BROADCOM3 BCM5717C 0x0020 BCM5717C 1000BASE-T media interface
|
||||
model BROADCOM3 BCM5719C 0x0022 BCM5719C 1000BASE-T media interface
|
||||
model BROADCOM3 BCM57765 0x0024 BCM57765 1000BASE-T media interface
|
||||
model BROADCOM3 BCM5720C 0x0036 BCM5720C 1000BASE-T media interface
|
||||
model BROADCOM4 BCM54213PE 0x000a BCM54213PE 1000BASE-T media interface
|
||||
model BROADCOM4 BCM5725C 0x0038 BCM5725C 1000BASE-T media interface
|
||||
model xxBROADCOM_ALT1 BCM5906 0x0004 BCM5906 10/100baseTX media interface
|
||||
|
||||
@@ -207,6 +212,7 @@ model xxCICADA CS8201A 0x0020 Cicada CS8201 10/100/1000TX PHY
|
||||
model xxCICADA CS8201B 0x0021 Cicada CS8201 10/100/1000TX PHY
|
||||
model xxCICADA CS8244 0x002c Cicada CS8244 10/100/1000TX PHY
|
||||
model xxVITESSE VSC8601 0x0002 Vitesse VSC8601 10/100/1000TX PHY
|
||||
model xxVITESSE VSC8641 0x0003 Vitesse VSC8641 10/100/1000TX PHY
|
||||
|
||||
/* Davicom Semiconductor PHYs */
|
||||
/* AMD Am79C873 seems to be a relabeled DM9101 */
|
||||
@@ -269,6 +275,7 @@ model xxMARVELL E1112 0x0009 Marvell 88E1112 Gigabit PHY
|
||||
model xxMARVELL E1149 0x000b Marvell 88E1149 Gigabit PHY
|
||||
model xxMARVELL E1111 0x000c Marvell 88E1111 Gigabit PHY
|
||||
model xxMARVELL E1145 0x000d Marvell 88E1145 Quad Gigabit PHY
|
||||
model xxMARVELL E1512 0x001d Marvell 88E1512 Gigabit PHY
|
||||
model xxMARVELL E1116 0x0021 Marvell 88E1116 Gigabit PHY
|
||||
model xxMARVELL E1116R 0x0024 Marvell 88E1116R Gigabit PHY
|
||||
model xxMARVELL E1118 0x0022 Marvell 88E1118 Gigabit PHY
|
||||
@@ -287,6 +294,9 @@ model MICREL KSZ8081 0x0016 Micrel KSZ8081 10/100 PHY
|
||||
model MICREL KSZ9021 0x0021 Micrel KSZ9021 10/100/1000 PHY
|
||||
model MICREL KSZ9031 0x0022 Micrel KSZ9031 10/100/1000 PHY
|
||||
|
||||
/* Motorcomm PHYs */
|
||||
model MOTORCOMM YT8511 0x010a Motorcomm YT8511 10/100/1000 PHY
|
||||
|
||||
/* Myson Technology PHYs */
|
||||
model xxMYSON MTD972 0x0000 MTD972 10/100 media interface
|
||||
model MYSON MTD803 0x0000 MTD803 3-in-1 media interface
|
||||
@@ -312,14 +322,16 @@ model xxQUALSEMI QS6612 0x0000 QS6612 10/100 media interface
|
||||
|
||||
/* RDC Semiconductor PHYs */
|
||||
model RDC R6040 0x0003 R6040 10/100 media interface
|
||||
model RDC R6040_2 0x0005 R6040 10/100 media interface
|
||||
|
||||
/* RealTek Semicondctor PHYs */
|
||||
model yyREALTEK RTL8201L 0x0020 RTL8201L 10/100 media interface
|
||||
model xxREALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media interface
|
||||
model REALTEK RTL8305SC 0x0005 RTL8305SC 10/100 802.1q switch
|
||||
model REALTEK RTL8201E 0x0008 RTL8201E 10/100 media interface
|
||||
model REALTEK RTL8251 0x0000 RTL8251 1000BASE-T media interface
|
||||
model REALTEK RTL8251 0x0000 RTL8251/8153 1000BASE-T media interface
|
||||
model REALTEK RTL8169S 0x0011 RTL8169S/8110S/8211 1000BASE-T media interface
|
||||
model REALTEK RTL8211FVD 0x0007 RTL8211F-VD 1000BASE-T media interface
|
||||
|
||||
/* Seeq Seeq PHYs */
|
||||
model SEEQ 80220 0x0003 Seeq 80220 10/100 media interface
|
||||
@@ -333,6 +345,8 @@ model SIS 900 0x0000 SiS 900 10/100 media interface
|
||||
model TI TLAN10T 0x0001 ThunderLAN 10BASE-T media interface
|
||||
model TI 100VGPMI 0x0002 ThunderLAN 100VG-AnyLan media interface
|
||||
model TI TNETE2101 0x0003 TNETE2101 media interface
|
||||
model xxTI DP83867 0x0023 High Immunity 10/100/1000 PHY
|
||||
model xxTI DP83822 0x0024 High Immunity 10/100 PHY
|
||||
|
||||
/* TDK Semiconductor PHYs */
|
||||
model xxTSC 78Q2120 0x0014 78Q2120 10/100 media interface
|
||||
@@ -340,7 +354,8 @@ model xxTSC 78Q2121 0x0015 78Q2121 100BASE-TX media interface
|
||||
|
||||
/* Vitesse Semiconductor (now Microsemi) */
|
||||
model xxVITESSE VSC8501 0x0013 Vitesse VSC8501 10/100/1000TX PHY
|
||||
model xxVITESSE VSC8641 0x0003 Vitesse VSC8641 10/100/1000TX PHY
|
||||
model xxVITESSE VSC8504 0x000c Vitesse VSC8504 10/100/1000TX PHY
|
||||
model xxVITESSE VSC8514 0x0027 Vitesse VSC8514 10/100/1000TX PHY
|
||||
|
||||
/* XaQti Corp. PHYs */
|
||||
model xxXAQTI XMACII 0x0000 XaQti Corp. XMAC II gigabit interface
|
||||
|
||||
@@ -132,6 +132,8 @@ typedef struct mii_softc mii_softc_t;
|
||||
#define MIIF_DOPAUSE 0x00000100 /* advertise PAUSE capability */
|
||||
#define MIIF_IS_HPNA 0x00000200 /* is a HomePNA device */
|
||||
#define MIIF_FORCEANEG 0x00000400 /* force auto-negotiation */
|
||||
#define MIIF_RX_DELAY 0x00000800 /* add RX delay */
|
||||
#define MIIF_TX_DELAY 0x00001000 /* add TX delay */
|
||||
#define MIIF_NOMANPAUSE 0x00100000 /* no manual PAUSE selection */
|
||||
#define MIIF_FORCEPAUSE 0x00200000 /* force PAUSE advertisement */
|
||||
#define MIIF_MACPRIV0 0x01000000 /* private to the MAC driver */
|
||||
|
||||
@@ -79,9 +79,14 @@ CTASSERT(sizeof (struct ether_addr) == ETHER_ADDR_LEN);
|
||||
#endif
|
||||
|
||||
#define ETHER_IS_MULTICAST(addr) (*(addr) & 0x01) /* is address mcast/bcast? */
|
||||
#define ETHER_IS_IPV6_MULTICAST(addr) \
|
||||
(((addr)[0] == 0x33) && ((addr)[1] == 0x33))
|
||||
#define ETHER_IS_BROADCAST(addr) \
|
||||
(((addr)[0] & (addr)[1] & (addr)[2] & \
|
||||
(addr)[3] & (addr)[4] & (addr)[5]) == 0xff)
|
||||
#define ETHER_IS_ZERO(addr) \
|
||||
(((addr)[0] | (addr)[1] | (addr)[2] | \
|
||||
(addr)[3] | (addr)[4] | (addr)[5]) == 0x00)
|
||||
|
||||
/*
|
||||
* NOTE: 0x0000-0x05DC (0..1500) are generally IEEE 802.3 length fields.
|
||||
|
||||
@@ -656,7 +656,6 @@ struct ifaddr {
|
||||
int ifa_metric; /* cost of going out this interface */
|
||||
int (*ifa_claim_addr) /* check if an addr goes to this if */
|
||||
(struct ifaddr *, struct sockaddr *);
|
||||
struct mtx ifa_mtx;
|
||||
};
|
||||
#define IFA_ROUTE RTF_UP /* route installed */
|
||||
|
||||
@@ -668,13 +667,6 @@ struct ifaddr * ifa_alloc(size_t size, int flags);
|
||||
void ifa_free(struct ifaddr *ifa);
|
||||
void ifa_ref(struct ifaddr *ifa);
|
||||
|
||||
|
||||
#define IFA_LOCK_INIT(ifa) \
|
||||
mtx_init(&(ifa)->ifa_mtx, "ifaddr", NULL, MTX_DEF)
|
||||
#define IFA_LOCK(ifa) mtx_lock(&(ifa)->ifa_mtx)
|
||||
#define IFA_UNLOCK(ifa) mtx_unlock(&(ifa)->ifa_mtx)
|
||||
#define IFA_DESTROY(ifa) mtx_destroy(&(ifa)->ifa_mtx)
|
||||
|
||||
/*
|
||||
* The prefix structure contains information about one prefix
|
||||
* of an interface. They are maintained by the different address families,
|
||||
@@ -708,9 +700,6 @@ struct ifmultiaddr {
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define IFA_LOCK(ifa) mtx_lock(&(ifa)->ifa_mtx)
|
||||
#define IFA_UNLOCK(ifa) mtx_unlock(&(ifa)->ifa_mtx)
|
||||
|
||||
extern struct rw_lock ifnet_rwlock;
|
||||
#define IFNET_LOCK_INIT() rw_lock_init(&ifnet_rwlock, "ifnet rwlock")
|
||||
#define IFNET_WLOCK() rw_lock_write_lock(&ifnet_rwlock)
|
||||
@@ -720,8 +709,7 @@ extern struct rw_lock ifnet_rwlock;
|
||||
#define IFNET_RUNLOCK() rw_lock_read_unlock(&ifnet_rwlock)
|
||||
#define IFNET_RUNLOCK_NOSLEEP() rw_lock_read_unlock(&ifnet_rwlock)
|
||||
|
||||
struct ifnet *ifnet_byindex(u_short idx);
|
||||
struct ifnet *ifnet_byindex_locked(u_short idx);
|
||||
if_t ifnet_byindex(u_int);
|
||||
|
||||
extern struct ifnethead ifnet;
|
||||
extern int ifqmaxlen;
|
||||
@@ -754,70 +742,107 @@ struct ifnet *ifunit(const char *);
|
||||
int if_alloc_inplace(struct ifnet *ifp, u_char type);
|
||||
void if_free_inplace(struct ifnet *ifp);
|
||||
|
||||
struct ifaddr *ifa_ifwithaddr(struct sockaddr *);
|
||||
struct ifaddr *ifa_ifwithbroadaddr(struct sockaddr *);
|
||||
struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *);
|
||||
struct ifaddr *ifa_ifwithnet(struct sockaddr *);
|
||||
struct ifaddr *ifa_ifwithroute(int, struct sockaddr *, struct sockaddr *);
|
||||
struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *);
|
||||
|
||||
int if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen);
|
||||
|
||||
typedef void *if_com_alloc_t(u_char type, struct ifnet *ifp);
|
||||
typedef void if_com_free_t(void *com, u_char type);
|
||||
void if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f);
|
||||
void if_deregister_com_alloc(u_char type);
|
||||
void if_data_copy(struct ifnet *, struct if_data *);
|
||||
uint64_t if_get_counter_default(struct ifnet *, ift_counter);
|
||||
void if_inc_counter(struct ifnet *, ift_counter, int64_t);
|
||||
|
||||
#define IF_LLADDR(ifp) \
|
||||
LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
|
||||
LLADDR((struct sockaddr_dl *)((ifp)->if_addr->ifa_addr))
|
||||
|
||||
uint64_t if_setbaudrate(if_t ifp, uint64_t baudrate);
|
||||
uint64_t if_getbaudrate(if_t ifp);
|
||||
uint64_t if_getbaudrate(const if_t ifp);
|
||||
int if_setcapabilities(if_t ifp, int capabilities);
|
||||
int if_setcapabilitiesbit(if_t ifp, int setbit, int clearbit);
|
||||
int if_getcapabilities(if_t ifp);
|
||||
int if_getcapabilities(const if_t ifp);
|
||||
int if_togglecapenable(if_t ifp, int togglecap);
|
||||
int if_setcapenable(if_t ifp, int capenable);
|
||||
int if_setcapenablebit(if_t ifp, int setcap, int clearcap);
|
||||
int if_getcapenable(if_t ifp);
|
||||
const char *if_getdname(if_t ifp);
|
||||
int if_getcapenable(const if_t ifp);
|
||||
int if_setcapabilities2(if_t ifp, int capabilities);
|
||||
int if_setcapabilities2bit(if_t ifp, int setbit, int clearbit);
|
||||
int if_getcapabilities2(const if_t ifp);
|
||||
int if_togglecapenable2(if_t ifp, int togglecap);
|
||||
int if_setcapenable2(if_t ifp, int capenable);
|
||||
int if_setcapenable2bit(if_t ifp, int setcap, int clearcap);
|
||||
int if_getcapenable2(const if_t ifp);
|
||||
int if_getdunit(const if_t ifp);
|
||||
int if_getindex(const if_t ifp);
|
||||
int if_getidxgen(const if_t ifp);
|
||||
const char *if_getdname(const if_t ifp);
|
||||
void if_setdname(if_t ifp, const char *name);
|
||||
const char *if_name(if_t ifp);
|
||||
int if_setname(if_t ifp, const char *name);
|
||||
int if_rename(if_t ifp, char *new_name);
|
||||
const char *if_getdescr(if_t ifp);
|
||||
void if_setdescr(if_t ifp, char *descrbuf);
|
||||
char *if_allocdescr(size_t sz, int malloc_flag);
|
||||
void if_freedescr(char *descrbuf);
|
||||
void if_setlastchange(if_t ifp);
|
||||
int if_getalloctype(const if_t ifp);
|
||||
int if_gettype(const if_t ifp);
|
||||
int if_setdev(if_t ifp, void *dev);
|
||||
int if_setdrvflagbits(if_t ifp, int if_setflags, int clear_flags);
|
||||
int if_getdrvflags(if_t ifp);
|
||||
int if_getdrvflags(const if_t ifp);
|
||||
int if_setdrvflags(if_t ifp, int flags);
|
||||
int if_getlinkstate(if_t ifp);
|
||||
int if_clearhwassist(if_t ifp);
|
||||
int if_sethwassistbits(if_t ifp, int toset, int toclear);
|
||||
int if_sethwassist(if_t ifp, int hwassist_bit);
|
||||
int if_gethwassist(if_t ifp);
|
||||
int if_gethwassist(const if_t ifp);
|
||||
int if_togglehwassist(if_t ifp, int toggle_bits);
|
||||
int if_setsoftc(if_t ifp, void *softc);
|
||||
void *if_getsoftc(if_t ifp);
|
||||
int if_setflags(if_t ifp, int flags);
|
||||
int if_gethwaddr(if_t ifp, struct ifreq *);
|
||||
void if_setllsoftc(if_t ifp, void *softc);
|
||||
void *if_getllsoftc(if_t ifp);
|
||||
u_int if_getfib(if_t ifp);
|
||||
uint8_t if_getaddrlen(if_t ifp);
|
||||
int if_gethwaddr(const if_t ifp, struct ifreq *);
|
||||
const uint8_t *if_getbroadcastaddr(const if_t ifp);
|
||||
void if_setbroadcastaddr(if_t ifp, const uint8_t *);
|
||||
int if_setmtu(if_t ifp, int mtu);
|
||||
int if_getmtu(if_t ifp);
|
||||
int if_getmtu_family(if_t ifp, int family);
|
||||
int if_getmtu(const if_t ifp);
|
||||
int if_getmtu_family(const if_t ifp, int family);
|
||||
void if_notifymtu(if_t ifp);
|
||||
int if_setflagbits(if_t ifp, int set, int clear);
|
||||
int if_getflags(if_t ifp);
|
||||
int if_setflags(if_t ifp, int flags);
|
||||
int if_getflags(const if_t ifp);
|
||||
int if_getnumadomain(if_t ifp);
|
||||
int if_sendq_empty(if_t ifp);
|
||||
int if_setsendqready(if_t ifp);
|
||||
int if_setsendqlen(if_t ifp, int tx_desc_count);
|
||||
int if_input(if_t ifp, struct mbuf* sendmp);
|
||||
int if_sethwtsomax(if_t ifp, u_int if_hw_tsomax);
|
||||
int if_sethwtsomaxsegcount(if_t ifp, u_int if_hw_tsomaxsegcount);
|
||||
int if_sethwtsomaxsegsize(if_t ifp, u_int if_hw_tsomaxsegsize);
|
||||
u_int if_gethwtsomax(const if_t ifp);
|
||||
u_int if_gethwtsomaxsegcount(const if_t ifp);
|
||||
u_int if_gethwtsomaxsegsize(const if_t ifp);
|
||||
void if_input(if_t ifp, struct mbuf* sendmp);
|
||||
int if_sendq_prepend(if_t ifp, struct mbuf *m);
|
||||
struct mbuf *if_dequeue(if_t ifp);
|
||||
int if_setifheaderlen(if_t ifp, int len);
|
||||
void if_setrcvif(struct mbuf *m, if_t ifp);
|
||||
|
||||
void if_setvtag(struct mbuf *m, u_int16_t tag);
|
||||
u_int16_t if_getvtag(struct mbuf *m);
|
||||
int if_vlantrunkinuse(if_t ifp);
|
||||
caddr_t if_getlladdr(if_t ifp);
|
||||
caddr_t if_getlladdr(const if_t ifp);
|
||||
struct vnet *if_getvnet(const if_t ifp);
|
||||
void *if_gethandle(u_char);
|
||||
void if_vlancap(if_t ifp);
|
||||
int if_transmit(if_t ifp, struct mbuf *m);
|
||||
void if_init(if_t ifp, void *ctx);
|
||||
int if_ioctl(if_t ifp, u_long cmd, void *data);
|
||||
int if_resolvemulti(if_t ifp, struct sockaddr **, struct sockaddr *);
|
||||
uint64_t if_getcounter(if_t ifp, ift_counter counter);
|
||||
struct label *if_getmaclabel(if_t ifp);
|
||||
void if_setmaclabel(if_t ifp, struct label *label);
|
||||
struct bpf_if *if_getbpf(if_t ifp);
|
||||
uint8_t if_getpcp(if_t ifp);
|
||||
void *if_getl2com(if_t ifp);
|
||||
struct ifvlantrunk *if_getvlantrunk(if_t ifp);
|
||||
bool if_altq_is_enabled(if_t ifp);
|
||||
|
||||
void if_bpfmtap(if_t ifp, struct mbuf *m);
|
||||
void if_etherbpfmtap(if_t ifp, struct mbuf *m);
|
||||
void if_vlancap(if_t ifp);
|
||||
|
||||
int if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max);
|
||||
int if_multiaddr_array(if_t ifp, void *mta, int *cnt, int max);
|
||||
|
||||
@@ -12,6 +12,7 @@ struct epoch_tracker {
|
||||
|
||||
#define NET_EPOCH_ENTER(et)
|
||||
#define NET_EPOCH_EXIT(et)
|
||||
#define NET_EPOCH_ASSERT()
|
||||
|
||||
|
||||
#endif /* _FBSD_COMPAT_SYS_EPOCH_H_ */
|
||||
|
||||
@@ -69,12 +69,25 @@ typedef struct {
|
||||
#define DEFINE_CLASS_0(name, driver, methods, size) \
|
||||
driver_t driver = { #name, methods, size }
|
||||
|
||||
#define DRIVER_MODULE(name, busname, driver, devclass, evh, arg) \
|
||||
driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver); \
|
||||
devclass_t *__class_ ## name ## _ ## busname ## _ ## devclass = &(devclass)
|
||||
#define DRIVER_MODULE5(name, busname, driver, evh, arg) \
|
||||
driver_t *DRIVER_MODULE_NAME(name, busname) = &(driver)
|
||||
|
||||
#define DRIVER_MODULE_ORDERED(name, busname, driver, devclass, evh, arg, order) \
|
||||
DRIVER_MODULE(name, busname, driver, devclass, evh, arg)
|
||||
#define DRIVER_MODULE_ORDERED6(name, busname, driver, evh, arg, order) \
|
||||
DRIVER_MODULE(name, busname, driver, evh, arg)
|
||||
|
||||
/* backwards compatibility */
|
||||
#define _DRIVER_MODULE_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) \
|
||||
NAME
|
||||
#define DRIVER_MODULE_ORDERED7(name, busname, driver, devclass, evh, arg, order) \
|
||||
DRIVER_MODULE_ORDERED6(name, busname, driver,, evh, arg, order)
|
||||
#define DRIVER_MODULE_ORDERED(...) \
|
||||
_DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, \
|
||||
DRIVER_MODULE_ORDERED7, DRIVER_MODULE_ORDERED6)(__VA_ARGS__)
|
||||
#define DRIVER_MODULE6(name, busname, driver, devclass, evh, arg) \
|
||||
DRIVER_MODULE5(name, busname, driver, evh, arg)
|
||||
#define DRIVER_MODULE(...) \
|
||||
_DRIVER_MODULE_MACRO(__VA_ARGS__, INVALID, INVALID, \
|
||||
DRIVER_MODULE6, DRIVER_MODULE5)(__VA_ARGS__)
|
||||
|
||||
#define DRIVER_MODULE_NAME(name, busname) \
|
||||
__fbsd_ ## name ## _ ## busname
|
||||
|
||||
@@ -191,6 +191,7 @@ SYSCTL_CHILDREN(void *ptr)
|
||||
#define SYSCTL_NODE(...)
|
||||
#define SYSCTL_INT(...)
|
||||
#define SYSCTL_UINT(...)
|
||||
#define SYSCTL_BOOL(...)
|
||||
#define SYSCTL_PROC(...)
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -80,8 +80,19 @@ remove_from_device_name_list(struct ifnet * ifp)
|
||||
}
|
||||
|
||||
|
||||
struct ifnet *
|
||||
ifnet_byindex(u_short idx)
|
||||
static struct ifnet *
|
||||
ifnet_byindex_locked(u_int idx)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
ifp = gDevices[idx];
|
||||
|
||||
return (ifp);
|
||||
}
|
||||
|
||||
|
||||
if_t
|
||||
ifnet_byindex(u_int idx)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
@@ -93,17 +104,6 @@ ifnet_byindex(u_short idx)
|
||||
}
|
||||
|
||||
|
||||
struct ifnet *
|
||||
ifnet_byindex_locked(u_short idx)
|
||||
{
|
||||
struct ifnet *ifp;
|
||||
|
||||
ifp = gDevices[idx];
|
||||
|
||||
return (ifp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ifnet_setbyindex_locked(u_short idx, struct ifnet *ifp)
|
||||
{
|
||||
@@ -281,7 +281,7 @@ ifq_uninit(struct ifqueue *ifq)
|
||||
|
||||
|
||||
static int
|
||||
if_transmit(struct ifnet *ifp, struct mbuf *m)
|
||||
if_transmit_default(struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
int error;
|
||||
|
||||
@@ -344,7 +344,7 @@ if_attach(struct ifnet *ifp)
|
||||
ifq_init((struct ifqueue *) &ifp->if_snd, ifp->if_xname);
|
||||
|
||||
if (ifp->if_transmit == NULL) {
|
||||
ifp->if_transmit = if_transmit;
|
||||
ifp->if_transmit = if_transmit_default;
|
||||
ifp->if_qflush = if_qflush;
|
||||
}
|
||||
if (ifp->if_input == NULL)
|
||||
@@ -893,21 +893,6 @@ fail:
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void
|
||||
ifa_ref(struct ifaddr *ifa)
|
||||
{
|
||||
//refcount_acquire(&ifa->ifa_refcnt);
|
||||
}
|
||||
|
||||
void
|
||||
ifa_free(struct ifaddr *ifa)
|
||||
{
|
||||
|
||||
//if (refcount_release(&ifa->ifa_refcnt)) {
|
||||
// free(ifa);
|
||||
//}
|
||||
}
|
||||
|
||||
void
|
||||
if_inc_counter(struct ifnet *ifp, ift_counter cnt, int64_t inc)
|
||||
{
|
||||
@@ -953,260 +938,6 @@ if_inc_counter(struct ifnet *ifp, ift_counter cnt, int64_t inc)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* API for driver access to network stack owned ifnet.*/
|
||||
uint64_t
|
||||
if_setbaudrate(struct ifnet *ifp, uint64_t baudrate)
|
||||
{
|
||||
uint64_t oldbrate;
|
||||
|
||||
oldbrate = ifp->if_baudrate;
|
||||
ifp->if_baudrate = baudrate;
|
||||
return (oldbrate);
|
||||
}
|
||||
|
||||
uint64_t
|
||||
if_getbaudrate(if_t ifp)
|
||||
{
|
||||
|
||||
return (((struct ifnet *)ifp)->if_baudrate);
|
||||
}
|
||||
|
||||
int
|
||||
if_setcapabilities(if_t ifp, int capabilities)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_capabilities = capabilities;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_setcapabilitiesbit(if_t ifp, int setbit, int clearbit)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_capabilities |= setbit;
|
||||
((struct ifnet *)ifp)->if_capabilities &= ~clearbit;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_getcapabilities(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_capabilities;
|
||||
}
|
||||
|
||||
int
|
||||
if_setcapenable(if_t ifp, int capabilities)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_capenable = capabilities;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_setcapenablebit(if_t ifp, int setcap, int clearcap)
|
||||
{
|
||||
if(setcap)
|
||||
((struct ifnet *)ifp)->if_capenable |= setcap;
|
||||
if(clearcap)
|
||||
((struct ifnet *)ifp)->if_capenable &= ~clearcap;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
if_getdname(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_dname;
|
||||
}
|
||||
|
||||
int
|
||||
if_togglecapenable(if_t ifp, int togglecap)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_capenable ^= togglecap;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_getcapenable(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_capenable;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is largely undesirable because it ties ifnet to a device, but does
|
||||
* provide flexiblity for an embedded product vendor. Should be used with
|
||||
* the understanding that it violates the interface boundaries, and should be
|
||||
* a last resort only.
|
||||
*/
|
||||
int
|
||||
if_setdev(if_t ifp, void *dev)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_setdrvflagbits(if_t ifp, int set_flags, int clear_flags)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_drv_flags |= set_flags;
|
||||
((struct ifnet *)ifp)->if_drv_flags &= ~clear_flags;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_getdrvflags(if_t ifp)
|
||||
{
|
||||
if ((struct ifnet *)ifp == NULL)
|
||||
return 0;
|
||||
return ((struct ifnet *)ifp)->if_drv_flags;
|
||||
}
|
||||
|
||||
int
|
||||
if_setdrvflags(if_t ifp, int flags)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_drv_flags = flags;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
if_setflags(if_t ifp, int flags)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_flags = flags;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_setflagbits(if_t ifp, int set, int clear)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_flags |= set;
|
||||
((struct ifnet *)ifp)->if_flags &= ~clear;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_getflags(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_flags;
|
||||
}
|
||||
|
||||
int
|
||||
if_clearhwassist(if_t ifp)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_hwassist = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_sethwassistbits(if_t ifp, int toset, int toclear)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_hwassist |= toset;
|
||||
((struct ifnet *)ifp)->if_hwassist &= ~toclear;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_sethwassist(if_t ifp, int hwassist_bit)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_hwassist = hwassist_bit;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_gethwassist(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_hwassist;
|
||||
}
|
||||
|
||||
int
|
||||
if_setmtu(if_t ifp, int mtu)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_mtu = mtu;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_getmtu(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_mtu;
|
||||
}
|
||||
|
||||
int
|
||||
if_setsoftc(if_t ifp, void *softc)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_softc = softc;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void *
|
||||
if_getsoftc(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_softc;
|
||||
}
|
||||
|
||||
void
|
||||
if_setrcvif(struct mbuf *m, if_t ifp)
|
||||
{
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)ifp;
|
||||
}
|
||||
|
||||
void
|
||||
if_setvtag(struct mbuf *m, uint16_t tag)
|
||||
{
|
||||
m->m_pkthdr.ether_vtag = tag;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
if_getvtag(struct mbuf *m)
|
||||
{
|
||||
|
||||
return (m->m_pkthdr.ether_vtag);
|
||||
}
|
||||
|
||||
int
|
||||
if_sendq_empty(if_t ifp)
|
||||
{
|
||||
return IFQ_DRV_IS_EMPTY(&((struct ifnet *)ifp)->if_snd);
|
||||
}
|
||||
|
||||
int
|
||||
if_getamcount(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_amcount;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
if_setsendqready(if_t ifp)
|
||||
{
|
||||
IFQ_SET_READY(&((struct ifnet *)ifp)->if_snd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_setsendqlen(if_t ifp, int tx_desc_count)
|
||||
{
|
||||
IFQ_SET_MAXLEN(&((struct ifnet *)ifp)->if_snd, tx_desc_count);
|
||||
((struct ifnet *)ifp)->if_snd.ifq_drv_maxlen = tx_desc_count;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_vlantrunkinuse(if_t ifp)
|
||||
{
|
||||
return ((struct ifnet *)ifp)->if_vlantrunk != NULL?1:0;
|
||||
}
|
||||
|
||||
int
|
||||
if_input(if_t ifp, struct mbuf* sendmp)
|
||||
{
|
||||
(*((struct ifnet *)ifp)->if_input)((struct ifnet *)ifp, sendmp);
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
/* XXX */
|
||||
#ifndef ETH_ADDR_LEN
|
||||
#define ETH_ADDR_LEN 6
|
||||
@@ -1265,73 +996,6 @@ if_multiaddr_count(if_t ifp, int max)
|
||||
return (count);
|
||||
}
|
||||
|
||||
u_int
|
||||
if_llmaddr_count(if_t ifp)
|
||||
{
|
||||
struct ifmultiaddr *ifma;
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
||||
if (ifma->ifma_addr->sa_family == AF_LINK)
|
||||
count++;
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
u_int
|
||||
if_foreach_llmaddr(if_t ifp, iflladdr_cb_t cb, void *cb_arg)
|
||||
{
|
||||
struct ifmultiaddr *ifma;
|
||||
u_int count;
|
||||
|
||||
count = 0;
|
||||
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
||||
if (ifma->ifma_addr->sa_family != AF_LINK)
|
||||
continue;
|
||||
count += (*cb)(cb_arg, (struct sockaddr_dl *)ifma->ifma_addr,
|
||||
count);
|
||||
}
|
||||
|
||||
return (count);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
if_dequeue(if_t ifp)
|
||||
{
|
||||
struct mbuf *m;
|
||||
IFQ_DRV_DEQUEUE(&((struct ifnet *)ifp)->if_snd, m);
|
||||
|
||||
return (m);
|
||||
}
|
||||
|
||||
int
|
||||
if_sendq_prepend(if_t ifp, struct mbuf *m)
|
||||
{
|
||||
IFQ_DRV_PREPEND(&((struct ifnet *)ifp)->if_snd, m);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
if_setifheaderlen(if_t ifp, int len)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_hdrlen = len;
|
||||
return (0);
|
||||
}
|
||||
|
||||
caddr_t
|
||||
if_getlladdr(if_t ifp)
|
||||
{
|
||||
return (IF_LLADDR((struct ifnet *)ifp));
|
||||
}
|
||||
|
||||
void *
|
||||
if_gethandle(u_char type)
|
||||
{
|
||||
return (if_alloc(type));
|
||||
}
|
||||
|
||||
void
|
||||
if_bpfmtap(if_t ifh, struct mbuf *m)
|
||||
{
|
||||
@@ -1347,47 +1011,3 @@ if_etherbpfmtap(if_t ifh, struct mbuf *m)
|
||||
|
||||
ETHER_BPF_MTAP(ifp, m);
|
||||
}
|
||||
|
||||
void
|
||||
if_vlancap(if_t ifh)
|
||||
{
|
||||
struct ifnet *ifp = (struct ifnet *)ifh;
|
||||
VLAN_CAPABILITIES(ifp);
|
||||
}
|
||||
|
||||
void
|
||||
if_setinitfn(if_t ifp, void (*init_fn)(void *))
|
||||
{
|
||||
((struct ifnet *)ifp)->if_init = init_fn;
|
||||
}
|
||||
|
||||
void
|
||||
if_setioctlfn(if_t ifp, int (*ioctl_fn)(if_t, u_long, caddr_t))
|
||||
{
|
||||
((struct ifnet *)ifp)->if_ioctl = (void *)ioctl_fn;
|
||||
}
|
||||
|
||||
void
|
||||
if_setstartfn(if_t ifp, void (*start_fn)(if_t))
|
||||
{
|
||||
((struct ifnet *)ifp)->if_start = (void *)start_fn;
|
||||
}
|
||||
|
||||
void
|
||||
if_settransmitfn(if_t ifp, if_transmit_fn_t start_fn)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_transmit = start_fn;
|
||||
}
|
||||
|
||||
void if_setqflushfn(if_t ifp, if_qflush_fn_t flush_fn)
|
||||
{
|
||||
((struct ifnet *)ifp)->if_qflush = flush_fn;
|
||||
}
|
||||
|
||||
void
|
||||
if_setgetcounterfn(if_t ifp, if_get_counter_t fn)
|
||||
{
|
||||
|
||||
ifp->if_get_counter = fn;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,14 +13,11 @@ static inline int
|
||||
if_input_openbsd(if_t ifp, struct mbuf_list* ml)
|
||||
{
|
||||
struct mbuf* m;
|
||||
int status = 0;
|
||||
while ((m = ml_dequeue(ml)) != NULL) {
|
||||
status = if_input(ifp, m);
|
||||
if (status != 0)
|
||||
break;
|
||||
if_input(ifp, m);
|
||||
}
|
||||
|
||||
return status;
|
||||
return 0;
|
||||
}
|
||||
#define if_input if_input_openbsd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user