summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2014-06-02 17:54:39 +0000
committermarcel <marcel@FreeBSD.org>2014-06-02 17:54:39 +0000
commit916c7006f53cf6a21d270b2c41727f786f65e066 (patch)
tree50b5505103db69da73caa7867a5a604a2f377b12 /sys/net
parentda8de155a096d247aff52acb7d8e06cbd3b87b3f (diff)
downloadFreeBSD-src-916c7006f53cf6a21d270b2c41727f786f65e066.zip
FreeBSD-src-916c7006f53cf6a21d270b2c41727f786f65e066.tar.gz
Introduce a procedural interface to the ifnet structure. The new
interface allows the ifnet structure to be defined as an opaque type in NIC drivers. This then allows the ifnet structure to be changed without a need to change or recompile NIC drivers. Put differently, NIC drivers can be written and compiled once and be used with different network stack implementations, provided of course that those network stack implementations have an API and ABI compatible interface. This commit introduces the 'if_t' type to replace 'struct ifnet *' as the type of a network interface. The 'if_t' type is defined as 'void *' to enable the compiler to perform type conversion to 'struct ifnet *' and vice versa where needed and without warnings. The functions that implement the API are the only functions that need to have an explicit cast. The MII code has been converted to use the driver API to avoid unnecessary code churn. Code churn comes from having to work with both converted and unconverted drivers in correlation with having callback functions that take an interface. By converting the MII code first, the callback functions can be defined so that the compiler will perform the typecasts automatically. As soon as all drivers have been converted, the if_t type can be redefined as needed and the API functions can be fix to not need an explicit cast. The immediate benefactors of this change are: 1. Juniper Networks - The network stack implementation in Junos is entirely different from FreeBSD's one and this change allows Juniper to build "stock" NIC drivers that can be used in combination with both the FreeBSD and Junos stacks. 2. FreeBSD - This change opens the door towards changing ifnet and implementing new features and optimizations in the network stack without it requiring a change in the many NIC drivers FreeBSD has. Submitted by: Anuranjan Shukla <anshukla@juniper.net> Reviewed by: glebius@ Obtained from: Juniper Networks, Inc.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c653
-rw-r--r--sys/net/if_media.h5
-rw-r--r--sys/net/if_var.h134
-rw-r--r--sys/net/ifq.h4
4 files changed, 778 insertions, 18 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 134a6d0..47b5b9d 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -63,12 +63,16 @@
#include <machine/stdarg.h>
#include <vm/uma.h>
+#include <net/bpf.h>
+#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_clone.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/if_var.h>
+#include <net/if_media.h>
+#include <net/if_vlan_var.h>
#include <net/radix.h>
#include <net/route.h>
#include <net/vnet.h>
@@ -1400,17 +1404,17 @@ if_addr_runlock(struct ifnet *ifp)
}
void
-if_maddr_rlock(struct ifnet *ifp)
+if_maddr_rlock(if_t ifp)
{
- IF_ADDR_RLOCK(ifp);
+ IF_ADDR_RLOCK((struct ifnet *)ifp);
}
void
-if_maddr_runlock(struct ifnet *ifp)
+if_maddr_runlock(if_t ifp)
{
- IF_ADDR_RUNLOCK(ifp);
+ IF_ADDR_RUNLOCK((struct ifnet *)ifp);
}
/*
@@ -3461,3 +3465,644 @@ if_deregister_com_alloc(u_char type)
if_com_alloc[type] = NULL;
if_com_free[type] = NULL;
}
+
+/* API for driver access to network stack owned ifnet.*/
+uint64_t
+if_setbaudrate(void *arg, uint64_t baudrate)
+{
+ struct ifnet *ifp = arg;
+ 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)
+{
+ 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);
+}
+
+/* Statistics */
+int
+if_incipackets(if_t ifp, int pkts)
+{
+ ((struct ifnet *)ifp)->if_ipackets += pkts;
+ return (0);
+}
+
+int
+if_incopackets(if_t ifp, int pkts)
+{
+ ((struct ifnet *)ifp)->if_opackets += pkts;
+ return (0);
+}
+
+int
+if_incierrors(if_t ifp, int ierrors)
+{
+ ((struct ifnet *)ifp)->if_ierrors += ierrors;
+ return (0);
+}
+
+
+int
+if_setierrors(if_t ifp, int ierrors)
+{
+ ((struct ifnet *)ifp)->if_ierrors = ierrors;
+ return (0);
+}
+
+int
+if_setoerrors(if_t ifp, int oerrors)
+{
+ ((struct ifnet *)ifp)->if_oerrors = oerrors;
+ return (0);
+}
+
+int if_incoerrors(if_t ifp, int oerrors)
+{
+ ((struct ifnet *)ifp)->if_oerrors += oerrors;
+ return (0);
+}
+
+int if_inciqdrops(if_t ifp, int val)
+{
+ ((struct ifnet *)ifp)->if_iqdrops += val;
+ return (0);
+}
+
+int
+if_setcollisions(if_t ifp, int collisions)
+{
+ ((struct ifnet *)ifp)->if_collisions = collisions;
+ return (0);
+}
+
+int
+if_inccollisions(if_t ifp, int collisions)
+{
+ ((struct ifnet *)ifp)->if_collisions += collisions;
+ return (0);
+}
+
+int
+if_setipackets(if_t ifp, int pkts)
+{
+ ((struct ifnet *)ifp)->if_ipackets = pkts;
+ return (0);
+}
+
+int
+if_setopackets(if_t ifp, int pkts)
+{
+ ((struct ifnet *)ifp)->if_opackets = pkts;
+ return (0);
+}
+
+int
+if_incobytes(if_t ifp, int bytes)
+{
+ ((struct ifnet *)ifp)->if_obytes += bytes;
+ return (0);
+}
+
+int
+if_setibytes(if_t ifp, int bytes)
+{
+ ((struct ifnet *)ifp)->if_ibytes = bytes;
+ return (0);
+}
+
+int
+if_setobytes(if_t ifp, int bytes)
+{
+ ((struct ifnet *)ifp)->if_obytes = bytes;
+ return (0);
+}
+
+
+int
+if_sendq_empty(if_t ifp)
+{
+ return IFQ_DRV_IS_EMPTY(&((struct ifnet *)ifp)->if_snd);
+}
+
+int if_getiqdrops(if_t ifp)
+{
+ return ((struct ifnet *)ifp)->if_iqdrops;
+}
+
+int
+if_incimcasts(if_t ifp, int mcast)
+{
+ ((struct ifnet *)ifp)->if_imcasts += mcast;
+ return (0);
+}
+
+
+int
+if_incomcasts(if_t ifp, int mcast)
+{
+ ((struct ifnet *)ifp)->if_omcasts += mcast;
+ return (0);
+}
+
+int
+if_setimcasts(if_t ifp, int mcast)
+{
+ ((struct ifnet *)ifp)->if_imcasts = mcast;
+ return (0);
+}
+
+
+struct ifaddr *
+if_getifaddr(if_t ifp)
+{
+ return ((struct ifnet *)ifp)->if_addr;
+}
+
+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
+#endif
+
+int
+if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max)
+{
+ struct ifmultiaddr *ifma;
+ uint8_t *lmta = (uint8_t *)mta;
+ int mcnt = 0;
+
+ TAILQ_FOREACH(ifma, &((struct ifnet *)ifp)->if_multiaddrs, ifma_link) {
+ if (ifma->ifma_addr->sa_family != AF_LINK)
+ continue;
+
+ if (mcnt == max)
+ break;
+
+ bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
+ &lmta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
+ mcnt++;
+ }
+ *cnt = mcnt;
+
+ return (0);
+}
+
+int
+if_multiaddr_array(if_t ifp, void *mta, int *cnt, int max)
+{
+ int error;
+
+ if_maddr_rlock(ifp);
+ error = if_setupmultiaddr(ifp, mta, cnt, max);
+ if_maddr_runlock(ifp);
+ return (error);
+}
+
+int
+if_multiaddr_count(if_t ifp, int max)
+{
+ struct ifmultiaddr *ifma;
+ int count;
+
+ count = 0;
+ if_maddr_rlock(ifp);
+ TAILQ_FOREACH(ifma, &((struct ifnet *)ifp)->if_multiaddrs, ifma_link) {
+ if (ifma->ifma_addr->sa_family != AF_LINK)
+ continue;
+ count++;
+ if (count == max)
+ break;
+ }
+ if_maddr_runlock(ifp);
+ 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_data.ifi_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)
+{
+ struct ifnet *ifp = (struct ifnet *)ifh;
+
+ BPF_MTAP(ifp, m);
+}
+
+void
+if_etherbpfmtap(if_t ifh, struct mbuf *m)
+{
+ struct ifnet *ifp = (struct ifnet *)ifh;
+
+ 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)(void *, u_long, caddr_t))
+{
+ ((struct ifnet *)ifp)->if_ioctl = (void *)ioctl_fn;
+}
+
+void
+if_setstartfn(if_t ifp, void (*start_fn)(void *))
+{
+ ((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;
+
+}
+
+/* These wrappers are hopefully temporary, till all drivers use drvapi */
+#ifdef INET
+void
+arp_ifinit_drv(if_t ifh, struct ifaddr *ifa)
+{
+ arp_ifinit((struct ifnet *)ifh, ifa);
+}
+#endif
+
+void
+ether_ifattach_drv(if_t ifh, const u_int8_t *lla)
+{
+ ether_ifattach((struct ifnet *)ifh, lla);
+}
+
+void
+ether_ifdetach_drv(if_t ifh)
+{
+ ether_ifdetach((struct ifnet *)ifh);
+}
+
+int
+ether_ioctl_drv(if_t ifh, u_long cmd, caddr_t data)
+{
+ struct ifnet *ifp = (struct ifnet *)ifh;
+
+ return (ether_ioctl(ifp, cmd, data));
+}
+
+int
+ifmedia_ioctl_drv(if_t ifh, struct ifreq *ifr, struct ifmedia *ifm,
+ u_long cmd)
+{
+ struct ifnet *ifp = (struct ifnet *)ifh;
+
+ return (ifmedia_ioctl(ifp, ifr, ifm, cmd));
+}
+
+void
+if_free_drv(if_t ifh)
+{
+ if_free((struct ifnet *)ifh);
+}
+
+void
+if_initname_drv(if_t ifh, const char *name, int unit)
+{
+ if_initname((struct ifnet *)ifh, name, unit);
+}
+
+void
+if_linkstate_change_drv(if_t ifh, int link_state)
+{
+ if_link_state_change((struct ifnet *)ifh, link_state);
+}
+
+void
+ifmedia_init_drv(struct ifmedia *ifm, int ncmask, int (*chg_cb)(void *),
+ void (*sts_cb)(void *, struct ifmediareq *))
+{
+ ifmedia_init(ifm, ncmask, (ifm_change_cb_t)chg_cb,
+ (ifm_stat_cb_t)sts_cb);
+}
+
+void
+if_addr_rlock_drv(if_t ifh)
+{
+
+ if_addr_runlock((struct ifnet *)ifh);
+}
+
+void
+if_addr_runlock_drv(if_t ifh)
+{
+ if_addr_runlock((struct ifnet *)ifh);
+}
+
+void
+if_qflush_drv(if_t ifh)
+{
+ if_qflush((struct ifnet *)ifh);
+
+}
+
+/* Revisit these - These are inline functions originally. */
+int
+drbr_inuse_drv(if_t ifh, struct buf_ring *br)
+{
+ return drbr_inuse_drv(ifh, br);
+}
+
+struct mbuf*
+drbr_dequeue_drv(if_t ifh, struct buf_ring *br)
+{
+ return drbr_dequeue(ifh, br);
+}
+
+int
+drbr_needs_enqueue_drv(if_t ifh, struct buf_ring *br)
+{
+ return drbr_needs_enqueue(ifh, br);
+}
+
+int
+drbr_enqueue_drv(if_t ifh, struct buf_ring *br, struct mbuf *m)
+{
+ return drbr_enqueue(ifh, br, m);
+
+}
diff --git a/sys/net/if_media.h b/sys/net/if_media.h
index a7a775b..88384f3 100644
--- a/sys/net/if_media.h
+++ b/sys/net/if_media.h
@@ -59,8 +59,8 @@ struct ifnet;
/*
* Driver callbacks for media status and change requests.
*/
-typedef int (*ifm_change_cb_t)(struct ifnet *ifp);
-typedef void (*ifm_stat_cb_t)(struct ifnet *ifp, struct ifmediareq *req);
+typedef int (*ifm_change_cb_t)(struct ifnet *);
+typedef void (*ifm_stat_cb_t)(struct ifnet *, struct ifmediareq *req);
/*
* In-kernel representation of a single supported media type.
@@ -106,6 +106,7 @@ void ifmedia_set(struct ifmedia *ifm, int mword);
int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr,
struct ifmedia *ifm, u_long cmd);
+
/* Compute baudrate for a given media. */
uint64_t ifmedia_baudrate(int);
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 0e3225c..0224e3a 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -66,6 +66,7 @@ struct carp_softc;
struct ifvlantrunk;
struct route; /* if_output */
struct vnet;
+struct ifmedia;
#ifdef _KERNEL
#include <sys/mbuf.h> /* ifqueue only? */
@@ -93,6 +94,15 @@ VNET_DECLARE(struct pfil_head, link_pfil_hook); /* packet filter hooks */
#define V_link_pfil_hook VNET(link_pfil_hook)
#endif /* _KERNEL */
+typedef void (*if_start_fn_t)(struct ifnet *);
+typedef int (*if_ioctl_fn_t)(struct ifnet *, u_long, caddr_t);
+typedef void (*if_init_fn_t)(void *);
+typedef void (*if_qflush_fn_t)(struct ifnet *);
+typedef int (*if_transmit_fn_t)(struct ifnet *, struct mbuf *);
+
+/* Opaque object pointing to interface structure (ifnet) */
+typedef void *if_t;
+
/*
* Structure defining a network interface.
*
@@ -170,18 +180,14 @@ struct ifnet {
struct route *);
void (*if_input) /* input routine (from h/w driver) */
(struct ifnet *, struct mbuf *);
- void (*if_start) /* initiate output routine */
- (struct ifnet *);
- int (*if_ioctl) /* ioctl routine */
- (struct ifnet *, u_long, caddr_t);
- void (*if_init) /* Init routine */
- (void *);
+ if_start_fn_t if_start; /* initiate output routine */
+ if_ioctl_fn_t if_ioctl; /* ioctl routine */
+ if_init_fn_t if_init; /* Init routine */
int (*if_resolvemulti) /* validate/resolve multicast */
(struct ifnet *, struct sockaddr **, struct sockaddr *);
- void (*if_qflush) /* flush any queues */
- (struct ifnet *);
- int (*if_transmit) /* initiate output routine */
- (struct ifnet *, struct mbuf *);
+ if_qflush_fn_t if_qflush; /* flush any queue */
+ if_transmit_fn_t if_transmit; /* initiate output routine */
+
void (*if_reassign) /* reassign to vnet routine */
(struct ifnet *, struct vnet *, char *);
@@ -254,8 +260,8 @@ struct ifnet {
*/
void if_addr_rlock(struct ifnet *ifp); /* if_addrhead */
void if_addr_runlock(struct ifnet *ifp); /* if_addrhead */
-void if_maddr_rlock(struct ifnet *ifp); /* if_multiaddrs */
-void if_maddr_runlock(struct ifnet *ifp); /* if_multiaddrs */
+void if_maddr_rlock(if_t ifp); /* if_multiaddrs */
+void if_maddr_runlock(if_t ifp); /* if_multiaddrs */
#ifdef _KERNEL
#ifdef _SYS_EVENTHANDLER_H_
@@ -514,5 +520,109 @@ void if_deregister_com_alloc(u_char type);
#define IF_LLADDR(ifp) \
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);
+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_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_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_setdrvflags(if_t ifp, int flags);
+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_setsoftc(if_t ifp, void *softc);
+void *if_getsoftc(if_t ifp);
+int if_setflags(if_t ifp, int flags);
+int if_setmtu(if_t ifp, int mtu);
+int if_getmtu(if_t ifp);
+int if_setflagbits(if_t ifp, int set, int clear);
+int if_getflags(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_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);
+void *if_gethandle(u_char);
+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);
+int if_multiaddr_count(if_t ifp, int max);
+
+int if_getamcount(if_t ifp);
+struct ifaddr * if_getifaddr(if_t ifp);
+/* Shim for drivers using drvapi */
+int ifmedia_ioctl_drv(if_t ifp, struct ifreq *ifr, struct ifmedia *ifm,
+ u_long cmd);
+
+/* Statistics */
+
+int if_incipackets(if_t ifp, int pkt);
+int if_incopackets(if_t ifp, int pkts);
+int if_incierrors(if_t ifp, int ierrors);
+int if_incoerrors(if_t ifp, int oerrors);
+int if_inciqdrops(if_t ifp, int val);
+int if_setierrors(if_t ifp, int ierrors);
+int if_setoerrors(if_t ifp, int oerrors);
+int if_setcollisions(if_t ifp, int collisions);
+int if_inccollisions(if_t ifp, int collisions);
+int if_incobytes(if_t ifp, int bytes);
+int if_getiqdrops(if_t ifp);
+int if_incimcasts(if_t ifp, int imcasts);
+int if_incomcasts(if_t ifp, int imcasts);
+int if_setipackets(if_t ifp, int pkts);
+int if_setopackets(if_t ifp, int pkts);
+int if_setibytes(if_t ifp, int bytes);
+int if_setobytes(if_t ifp, int bytes);
+int if_setimcasts(if_t ifp, int pkts);
+
+/* Functions */
+void if_setinitfn(if_t ifp, void (*)(void *));
+void if_setioctlfn(if_t ifp, int (*)(void *, u_long, caddr_t));
+void if_setstartfn(if_t ifp, void (*)(void *));
+void if_settransmitfn(if_t ifp, if_transmit_fn_t);
+void if_setqflushfn(if_t ifp, if_qflush_fn_t);
+
+
+/* Shim functions till all drivers use drvapi */
+void arp_ifinit_drv(if_t ifp, struct ifaddr *ifa);
+void ether_ifattach_drv(if_t ifp, const u_int8_t *lla);
+void ether_ifdetach_drv(if_t ifp);
+int ether_ioctl_drv(if_t ifp, u_long cmd, caddr_t data);
+void if_free_drv(if_t ifp);
+void if_initname_drv(if_t ifp, const char *name, int unit);
+void if_linkstate_change_drv(if_t ifp, int link_state);
+
+struct ifmedia;
+void ifmedia_init_drv(struct ifmedia *, int, int (*)(void *),
+ void (*)(void *, struct ifmediareq *));
+
+void if_addr_rlock_drv(if_t ifp);
+void if_addr_runlock_drv(if_t ifp);
+void if_qflush_drv(if_t ifp);
+
+/* Revisit the below. These are inline functions originally */
+int drbr_inuse_drv(if_t ifp, struct buf_ring *br);
+struct mbuf* drbr_dequeue_drv(if_t ifp, struct buf_ring *br);
+int drbr_needs_enqueue_drv(if_t ifp, struct buf_ring *br);
+int drbr_enqueue_drv(if_t ifp, struct buf_ring *br, struct mbuf *m);
+
#endif /* _KERNEL */
#endif /* !_NET_IF_VAR_H_ */
diff --git a/sys/net/ifq.h b/sys/net/ifq.h
index 18d61e2..cf0c506 100644
--- a/sys/net/ifq.h
+++ b/sys/net/ifq.h
@@ -484,6 +484,10 @@ enum poll_cmd { POLL_ONLY, POLL_AND_CHECK_STATUS };
typedef int poll_handler_t(struct ifnet *ifp, enum poll_cmd cmd, int count);
int ether_poll_register(poll_handler_t *h, struct ifnet *ifp);
int ether_poll_deregister(struct ifnet *ifp);
+/* The following should be temporary, till all drivers use the driver API */
+typedef int poll_handler_drv_t(if_t ifh, enum poll_cmd cmd, int count);
+int ether_poll_register_drv(poll_handler_drv_t *h, if_t ifh);
+int ether_poll_deregister_drv(if_t ifh);
#endif /* DEVICE_POLLING */
#endif /* _KERNEL */
OpenPOWER on IntegriCloud