X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/blobdiff_plain/8a1056501895a800226ae76327de0c78e9add591..78195a764d5e70464a6d4f49bc08332a2a8bb4d0:/sys/net/i4b/driver/i4b_ipr.c diff --git a/sys/net/i4b/driver/i4b_ipr.c b/sys/net/i4b/driver/i4b_ipr.c index 3f5478648f..663686839d 100644 --- a/sys/net/i4b/driver/i4b_ipr.c +++ b/sys/net/i4b/driver/i4b_ipr.c @@ -28,7 +28,7 @@ * --------------------------------------------------------- * * $FreeBSD: src/sys/i4b/driver/i4b_ipr.c,v 1.8.2.3 2001/10/27 15:48:17 hm Exp $ - * $DragonFly: src/sys/net/i4b/driver/i4b_ipr.c,v 1.15 2005/02/10 00:20:09 joerg Exp $ + * $DragonFly: src/sys/net/i4b/driver/i4b_ipr.c,v 1.18 2005/11/28 17:13:45 dillon Exp $ * * last edit-date: [Fri Oct 26 19:32:38 2001] * @@ -61,9 +61,7 @@ #if NI4BIPR > 0 -#if defined(__DragonFly__) || defined(__FreeBSD__) #include "opt_i4b.h" -#endif #include #include @@ -71,21 +69,14 @@ #include #include -#if defined(__DragonFly__) || defined(__FreeBSD__) #include #include #ifdef IPR_VJ #include #endif -#else -#include -#endif - -#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000 -#include -#endif #include +#include #include #include @@ -115,47 +106,24 @@ /* undef to uncompress in the mbuf itself */ #endif /* IPR_VJ */ -#if defined(__DragonFly__) || (defined(__FreeBSD_version) && __FreeBSD_version >= 400008) #include "use_bpf.h" -#else -#include "bpfilter.h" -#endif #if NBPFILTER > 0 || NBPF > 0 #include #include #endif -#if defined(__DragonFly__) || defined(__FreeBSD__) #include #include -#else -#include -#include -#endif #include "../include/i4b_global.h" #include "../include/i4b_l3l4.h" #include "../layer4/i4b_l4.h" -#if !defined(__DragonFly__) || !defined(__FreeBSD__) -#include /* For softnet */ -#endif - -#if defined(__FreeBSD__) && !defined(__DragonFly__) -#define IPR_FMT "ipr%d: " -#define IPR_ARG(sc) ((sc)->sc_if.if_unit) -#define PDEVSTATIC static -#elif defined(__bsdi__) -#define IPR_FMT "ipr%d: " -#define IPR_ARG(sc) ((sc)->sc_if.if_unit) -#define PDEVSTATIC /* not static */ -#else #define IPR_FMT "%s: " #define IPR_ARG(sc) ((sc)->sc_if.if_xname) #define PDEVSTATIC /* not static */ -#endif #define I4BIPRMTU 1500 /* regular MTU */ #define I4BIPRMAXMTU 2000 /* max MTU */ @@ -175,11 +143,7 @@ static isdn_link_t *isdn_linktab[NI4BIPR]; struct ipr_softc { struct ifnet sc_if; /* network-visible interface */ int sc_state; /* state of the interface */ - -#if !defined(__FreeBSD__) || defined(__DragonFly__) - int sc_unit; /* unit number for Net/OpenBSD */ -#endif - + int sc_unit; /* unit number */ call_desc_t *sc_cdp; /* ptr to call descriptor */ int sc_updown; /* soft state of interface */ struct ifqueue sc_fastq; /* interactive traffic */ @@ -221,33 +185,15 @@ enum ipr_states { ST_CONNECTED_A, /* connected to remote */ }; -#if (defined(__FreeBSD__) && !defined(__DragonFly__)) || (defined(__bsdi__)) -#define THE_UNIT sc->sc_if.if_unit -#else #define THE_UNIT sc->sc_unit -#endif -#if defined(__DragonFly__) || defined __FreeBSD__ || defined __NetBSD__ # define IOCTL_CMD_T u_long -#else -# define IOCTL_CMD_T int -#endif -#if defined(__DragonFly__) || defined(__FreeBSD__) PDEVSTATIC void i4biprattach(void *); PSEUDO_SET(i4biprattach, i4b_ipr); static int i4biprioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data, struct ucred *cr); -#else -PDEVSTATIC void i4biprattach (void); -static int i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data); -#endif - -#ifdef __bsdi__ -static int iprwatchdog(int unit); -#else static void iprwatchdog(struct ifnet *ifp); -#endif static void ipr_init_linktab(int unit); static void ipr_tx_queue_empty(int unit); static int i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct rtentry *rtp); @@ -261,11 +207,7 @@ static void iprclearqueues(struct ipr_softc *sc); * interface attach routine at kernel boot time *---------------------------------------------------------------------------*/ PDEVSTATIC void -#if defined(__DragonFly__) || defined(__FreeBSD__) i4biprattach(void *dummy) -#else -i4biprattach() -#endif { struct ipr_softc *sc = ipr_softc; int i; @@ -284,19 +226,7 @@ i4biprattach() sc->sc_state = ST_IDLE; -#ifdef __DragonFly__ if_initname(&(sc->sc_if), "ipr", i); -#elif defined(__FreeBSD__) - sc->sc_if.if_name = "ipr"; - sc->sc_if.if_unit = i; -#elif defined(__bsdi__) - sc->sc_if.if_name = "ipr"; - sc->sc_if.if_unit = i; -#else - sprintf(sc->sc_if.if_xname, "ipr%d", i); - sc->sc_if.if_softc = sc; - sc->sc_unit = i; -#endif #ifdef IPR_VJ sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_SIMPLEX | IPR_AUTOCOMP; @@ -314,9 +244,6 @@ i4biprattach() sc->sc_if.if_snd.ifq_maxlen = I4BIPRMAXQLEN; sc->sc_fastq.ifq_maxlen = I4BIPRMAXQLEN; -#if defined (__FreeBSD__) && __FreeBSD__ > 4 - mtx_init(&sc->sc_fastq.ifq_mtx, "i4b_ipr_fastq", MTX_DEF); -#endif sc->sc_if.if_ipackets = 0; sc->sc_if.if_ierrors = 0; sc->sc_if.if_opackets = 0; @@ -345,11 +272,7 @@ i4biprattach() #endif #ifdef IPR_VJ -#if defined(__DragonFly__) || defined(__FreeBSD__) sl_compress_init(&sc->sc_compr, -1); -#else - sl_compress_init(&sc->sc_compr); -#endif #ifdef IPR_VJ_USEBUFFER if(!((sc->sc_cbuf = @@ -363,15 +286,8 @@ i4biprattach() sc->sc_dialresp = DSTAT_NONE; /* no response */ sc->sc_lastdialresp = DSTAT_NONE; - if_attach(&sc->sc_if); - -#if NBPFILTER > 0 || NBPF > 0 -#if defined(__DragonFly__) || defined(__FreeBSD__) + if_attach(&sc->sc_if, NULL); bpfattach(&sc->sc_if, DLT_NULL, sizeof(u_int)); -#else - bpfattach(&sc->sc_if.if_bpf, &sc->sc_if, DLT_NULL, sizeof(u_int)); -#endif -#endif } } @@ -384,18 +300,12 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, { struct ipr_softc *sc; int unit; - int s; struct ip *ip; - s = SPLI4B(); + crit_enter(); -#if (defined(__FreeBSD__) && !defined(__DragonFly__)) || (defined(__bsdi__)) - unit = ifp->if_unit; - sc = &ipr_softc[unit]; -#else sc = ifp->if_softc; unit = sc->sc_unit; -#endif /* check for IP */ @@ -403,7 +313,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, { printf(IPR_FMT "af%d not supported\n", IPR_ARG(sc), dst->sa_family); m_freem(m); - splx(s); + crit_exit(); sc->sc_if.if_noproto++; sc->sc_if.if_oerrors++; return(EAFNOSUPPORT); @@ -415,7 +325,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, { NDBGL4(L4_IPRDBG, "ipr%d: interface is DOWN!", unit); m_freem(m); - splx(s); + crit_exit(); sc->sc_if.if_oerrors++; return(ENETDOWN); } @@ -433,7 +343,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, m_freem(m); iprclearqueues(sc); sc->sc_dialresp = DSTAT_NONE; - splx(s); + crit_exit(); sc->sc_if.if_oerrors++; return(ENETUNREACH); break; @@ -443,7 +353,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, m_freem(m); iprclearqueues(sc); sc->sc_dialresp = DSTAT_NONE; - splx(s); + crit_exit(); sc->sc_if.if_oerrors++; return(EHOSTUNREACH); break; @@ -453,7 +363,7 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, m_freem(m); iprclearqueues(sc); sc->sc_dialresp = DSTAT_NONE; - splx(s); + crit_exit(); sc->sc_if.if_oerrors++; return(EHOSTUNREACH); break; @@ -488,21 +398,19 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, /* check for space in choosen send queue */ -#if defined(__DragonFly__) || defined (__FreeBSD__) if (netisr_queue(NETISR_IP, m)) { NDBGL4(L4_IPRDBG, "ipr%d: send queue full!", unit); - splx(s); + crit_exit(); sc->sc_if.if_oerrors++; return(ENOBUFS); } -#endif NDBGL4(L4_IPRDBG, "ipr%d: add packet to send queue!", unit); ipr_tx_queue_empty(unit); - splx(s); + crit_exit(); return (0); } @@ -510,26 +418,16 @@ i4biproutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, /*---------------------------------------------------------------------------* * process ioctl *---------------------------------------------------------------------------*/ -#if defined(__DragonFly__) || defined(__FreeBSD__) static int i4biprioctl(struct ifnet *ifp, IOCTL_CMD_T cmd, caddr_t data, struct ucred *cr) -#else -static int -i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) -#endif { -#if (defined(__FreeBSD__) && !defined(__DragonFly__)) || (defined(__bsdi__)) - struct ipr_softc *sc = &ipr_softc[ifp->if_unit]; -#else struct ipr_softc *sc = ifp->if_softc; -#endif struct ifreq *ifr = (struct ifreq *)data; struct ifaddr *ifa = (struct ifaddr *)data; - int s; int error = 0; - s = SPLI4B(); + crit_enter(); switch (cmd) { @@ -549,11 +447,7 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) if(sc->sc_if.if_flags & IFF_RUNNING) { /* disconnect ISDN line */ -#if (defined(__FreeBSD__) && !defined(__DragonFly__)) || (defined(__bsdi__)) - i4b_l4_drvrdisc(BDRV_IPR, ifp->if_unit); -#else i4b_l4_drvrdisc(BDRV_IPR, sc->sc_unit); -#endif sc->sc_if.if_flags &= ~IFF_RUNNING; } @@ -572,7 +466,6 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) microtime(&sc->sc_if.if_lastchange); break; -#if !defined(__OpenBSD__) case SIOCSIFMTU: /* set interface MTU */ if(ifr->ifr_mtu > I4BIPRMAXMTU) error = EINVAL; @@ -584,7 +477,6 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) microtime(&sc->sc_if.if_lastchange); } break; -#endif /* __OPENBSD__ */ #if 0 /* not needed for FreeBSD, done in sl_compress_init() (-hm) */ @@ -609,7 +501,7 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) break; } - splx(s); + crit_exit(); return(error); } @@ -620,21 +512,13 @@ i4biprioctl(struct ifnet *ifp, u_long cmd, caddr_t data) static void iprclearqueues(struct ipr_softc *sc) { - int x; - -#if defined (__FreeBSD__) && __FreeBSD__ > 4 - x = splimp(); - IF_DRAIN(&sc->sc_fastq); - IF_DRAIN(&sc->sc_if.if_snd); - splx(x); -#else struct mbuf *m; for(;;) { - x = splimp(); + crit_enter(); IF_DEQUEUE(&sc->sc_fastq, m); - splx(x); + crit_exit(); if(m) m_freem(m); else @@ -643,40 +527,25 @@ iprclearqueues(struct ipr_softc *sc) for(;;) { - x = splimp(); + crit_enter(); IF_DEQUEUE(&sc->sc_if.if_snd, m); - splx(x); + crit_exit(); if(m) m_freem(m); else break; } -#endif } #if I4BIPRACCT /*---------------------------------------------------------------------------* * watchdog routine *---------------------------------------------------------------------------*/ -#ifdef __bsdi__ -static int -iprwatchdog(int unit) -{ -#else static void iprwatchdog(struct ifnet *ifp) { -#endif -#if defined(__FreeBSD__) && !defined(__DragonFly__) - int unit = ifp->if_unit; - struct ipr_softc *sc = &ipr_softc[unit]; -#elif defined(__bsdi__) - struct ipr_softc *sc = &ipr_softc[unit]; - struct ifnet *ifp = &ipr_softc[unit].sc_if; -#else struct ipr_softc *sc = ifp->if_softc; int unit = sc->sc_unit; -#endif bchan_statistics_t bs; /* get # of bytes in and out from the HSCX driver */ @@ -704,9 +573,6 @@ iprwatchdog(struct ifnet *ifp) sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_outb, sc->sc_inb); } sc->sc_if.if_timer = I4BIPRACCTINTVL; -#ifdef __bsdi__ - return 0; -#endif } #endif /* I4BIPRACCT */ @@ -720,7 +586,7 @@ iprwatchdog(struct ifnet *ifp) static void i4bipr_connect_startio(struct ipr_softc *sc) { - int s = SPLI4B(); + crit_enter(); if(sc->sc_state == ST_CONNECTED_W) { @@ -728,7 +594,7 @@ i4bipr_connect_startio(struct ipr_softc *sc) ipr_tx_queue_empty(THE_UNIT); } - splx(s); + crit_exit(); } /*---------------------------------------------------------------------------* @@ -738,11 +604,10 @@ static void ipr_connect(int unit, void *cdp) { struct ipr_softc *sc = &ipr_softc[unit]; - int s; sc->sc_cdp = (call_desc_t *)cdp; - s = SPLI4B(); + crit_enter(); NDBGL4(L4_DIALST, "ipr%d: setting dial state to ST_CONNECTED", unit); @@ -797,7 +662,7 @@ ipr_connect(int unit, void *cdp) ipr_tx_queue_empty(unit); } - splx(s); + crit_exit(); /* we don't need any negotiation - pass event back right now */ i4b_l4_negcomplete(sc->sc_cdp); @@ -876,8 +741,8 @@ ipr_updown(int unit, int updown) /*---------------------------------------------------------------------------* * this routine is called from the HSCX interrupt handler * when a new frame (mbuf) has been received and was put on - * the rx queue. It is assumed that this routines runs at - * pri level splimp() ! Keep it short ! + * the rx queue. It is assumed that this routines runs in + * a critical section ! Keep it short ! *---------------------------------------------------------------------------*/ static void ipr_rx_data_rdy(int unit) @@ -1036,13 +901,11 @@ error: if (sc->sc_if.if_bpf) bpf_ptap(sc->sc_if.if_bpf, m, &af, sizeof(af)); -#if defined(__DragonFly__) || defined (__FreeBSD__) if (netisr_queue(NETISR_IP, m)) { NDBGL4(L4_IPRDBG, "ipr%d: ipintrq full!", unit); sc->sc_if.if_ierrors++; sc->sc_if.if_iqdrops++; } -#endif } /*---------------------------------------------------------------------------*