Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/kqueue]: src/sys/netisdn Add kqueue support (someone who understands the...



details:   https://anonhg.NetBSD.org/src/rev/848b43db316f
branches:  kqueue
changeset: 512412:848b43db316f
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Sat Sep 08 23:26:02 2001 +0000

description:
Add kqueue support (someone who understands the i4b code should
make sure I got this right).

diffstat:

 sys/netisdn/i4b_i4bdrv.c |   67 ++++++++++++++++++++++++-
 sys/netisdn/i4b_rbch.c   |   93 +++++++++++++++++++++++++++++++++-
 sys/netisdn/i4b_tel.c    |  124 ++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 271 insertions(+), 13 deletions(-)

diffs (truncated from 426 to 300 lines):

diff -r fd0c5dfcb9a6 -r 848b43db316f sys/netisdn/i4b_i4bdrv.c
--- a/sys/netisdn/i4b_i4bdrv.c  Sat Sep 08 21:49:16 2001 +0000
+++ b/sys/netisdn/i4b_i4bdrv.c  Sat Sep 08 23:26:02 2001 +0000
@@ -27,7 +27,7 @@
  *     i4b_i4bdrv.c - i4b userland interface driver
  *     --------------------------------------------
  *
- *     $Id: i4b_i4bdrv.c,v 1.4.2.1 2001/08/25 06:17:07 thorpej Exp $ 
+ *     $Id: i4b_i4bdrv.c,v 1.4.2.2 2001/09/08 23:26:02 thorpej Exp $ 
  *
  * $FreeBSD$
  *
@@ -140,6 +140,7 @@
 
 #ifdef OS_USES_POLL
 PDEVSTATIC int i4bpoll __P((dev_t dev, int events, struct proc *p));
+PDEVSTATIC int i4bkqfilter __P((dev_t dev, struct knote *kn));
 #else
 PDEVSTATIC int i4bselect __P((dev_t dev, int rw, struct proc *p));
 #endif
@@ -953,6 +954,66 @@
        return(0);
 }
 
+static void
+filt_i4brdetach(struct knote *kn)
+{
+       int s;
+
+       s = splnet();
+       SLIST_REMOVE(&select_rd_info.si_klist, kn, knote, kn_selnext);
+       splx(s);
+}
+
+static int
+filt_i4bread(struct knote *kn, long hint)
+{
+       struct mbuf *m;
+
+       if (IF_QEMPTY(&i4b_rdqueue))
+               return (0);
+
+       IF_POLL(&i4b_rdqueue, m);
+
+       kn->kn_data = m->m_len;
+       return (1);
+}
+
+static const struct filterops i4bread_filtops =
+       { 1, NULL, filt_i4brdetach, filt_i4bread };
+
+static const struct filterops i4b_seltrue_filtops =
+       { 1, NULL, filt_i4brdetach, filt_seltrue };
+
+int
+i4bkqfilter(dev_t dev, struct knote *kn)
+{
+       struct klist *klist;
+       int s;
+
+       switch (kn->kn_filter) {
+       case EVFILT_READ:
+               klist = &select_rd_info.si_klist;
+               kn->kn_fop = &i4bread_filtops;
+               break;
+
+       case EVFILT_WRITE:
+               klist = &select_rd_info.si_klist;
+               kn->kn_fop = &i4b_seltrue_filtops;
+               break;
+
+       default:
+               return (1);
+       }
+
+       kn->kn_hook = NULL;
+
+       s = splnet();
+       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       splx(s);
+
+       return (0);
+}
+
 #endif /* OS_USES_SELECT */
 
 /*---------------------------------------------------------------------------*
@@ -992,7 +1053,7 @@
        if(selflag)
        {
                selflag = 0;
-               selwakeup(&select_rd_info);
+               selnotify(&select_rd_info, 0);
        }
 }
 
@@ -1033,7 +1094,7 @@
        if(selflag)
        {
                selflag = 0;
-               selwakeup(&select_rd_info);
+               selnotify(&select_rd_info, 0);
        }
 }
 
diff -r fd0c5dfcb9a6 -r 848b43db316f sys/netisdn/i4b_rbch.c
--- a/sys/netisdn/i4b_rbch.c    Sat Sep 08 21:49:16 2001 +0000
+++ b/sys/netisdn/i4b_rbch.c    Sat Sep 08 23:26:02 2001 +0000
@@ -27,7 +27,7 @@
  *     i4b_rbch.c - device driver for raw B channel data
  *     ---------------------------------------------------
  *
- *     $Id: i4b_rbch.c,v 1.3 2001/03/24 12:40:32 martin Exp $
+ *     $Id: i4b_rbch.c,v 1.3.2.1 2001/09/08 23:26:02 thorpej Exp $
  *
  * $FreeBSD$
  *
@@ -177,6 +177,7 @@
 int i4brbchioctl __P((dev_t dev, IOCTL_CMD_T cmd, caddr_t arg, int flag, struct proc* pr));
 #ifdef OS_USES_POLL
 int i4brbchpoll __P((dev_t dev, int events, struct proc *p));
+int i4brbchkqfilter __P((dev_t dev, struct knote *kn));
 #else
 PDEVSTATIC int i4brbchselect __P((dev_t dev, int rw, struct proc *p));
 #endif
@@ -762,6 +763,90 @@
        return(revents);
 }
 
+static void
+filt_i4brbchdetach(struct knote *kn)
+{
+       struct rbch_softc *sc = (void *) kn->kn_hook;
+       int s;
+
+       s = splhigh();
+       SLIST_REMOVE(&sc->selp.si_klist, kn, knote, kn_selnext);
+       splx(s);
+}
+
+static int
+filt_i4brbchread(struct knote *kn, long hint)
+{
+       struct rbch_softc *sc = (void *) kn->kn_hook;
+       struct ifqueue *iqp;
+
+       if ((sc->sc_devstate & ST_CONNECTED) == 0)
+               return (0);
+
+       if (sc->sc_bprot == BPROT_RHDLC)
+               iqp = &sc->sc_hdlcq;
+       else
+               iqp = isdn_linktab[sc->sc_unit]->rx_queue;      
+
+       if (IF_QEMPTY(iqp))
+               return (0);
+
+       kn->kn_data = 0;        /* XXXLUKEM (thorpej): what to put here? */
+       return (1);
+}
+
+static const struct filterops i4brbchread_filtops =
+       { 1, NULL, filt_i4brbchdetach, filt_i4brbchread };
+
+static int
+filt_i4brbchwrite(struct knote *kn, long hint)
+{
+       struct rbch_softc *sc = (void *) kn->kn_hook;
+
+       if ((sc->sc_devstate & ST_CONNECTED) == 0)
+               return (0);
+
+       if (IF_QFULL(isdn_linktab[sc->sc_unit]->tx_queue))
+               return (0);
+
+       kn->kn_data = 0;        /* XXXLUKEM (thorpej): what to put here? */
+       return (1);
+}
+
+static const struct filterops i4brbchwrite_filtops =
+       { 1, NULL, filt_i4brbchdetach, filt_i4brbchwrite };
+
+int
+i4brbchkqfilter(dev_t dev, struct knote *kn)
+{
+       struct rbch_softc *sc = &rbch_softc[minor(dev)];
+       struct klist *klist;
+       int s;
+
+       switch (kn->kn_filter) {
+       case EVFILT_READ:
+               klist = &sc->selp.si_klist;
+               kn->kn_fop = &i4brbchread_filtops;
+               break;
+
+       case EVFILT_WRITE:
+               klist = &sc->selp.si_klist;
+               kn->kn_fop = &i4brbchwrite_filtops;
+               break;
+
+       default:
+               return (1);
+       }
+
+       kn->kn_hook = (void *) sc;
+
+       s = splhigh();
+       SLIST_INSERT_HEAD(klist, kn, kn_selnext);
+       splx(s);
+
+       return (0);
+}
+
 #else /* OS_USES_POLL */
 
 /*---------------------------------------------------------------------------*
@@ -984,7 +1069,7 @@
        {
                NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit);
        }
-       selwakeup(&rbch_softc[unit].selp);
+       selnotify(&rbch_softc[unit].selp, 0);
 }
 
 /*---------------------------------------------------------------------------*
@@ -1005,7 +1090,7 @@
        {
                NDBGL4(L4_RBCHDBG, "unit %d, NO wakeup", unit);
        }
-       selwakeup(&rbch_softc[unit].selp);
+       selnotify(&rbch_softc[unit].selp, 0);
 }
 
 /*---------------------------------------------------------------------------*
@@ -1017,7 +1102,7 @@
 {
        if (rbch_softc[unit].sc_cd)
                rbch_softc[unit].sc_cd->last_active_time = SECOND;
-       selwakeup(&rbch_softc[unit].selp);
+       selnotify(&rbch_softc[unit].selp, 0);
 }
 
 /*---------------------------------------------------------------------------*
diff -r fd0c5dfcb9a6 -r 848b43db316f sys/netisdn/i4b_tel.c
--- a/sys/netisdn/i4b_tel.c     Sat Sep 08 21:49:16 2001 +0000
+++ b/sys/netisdn/i4b_tel.c     Sat Sep 08 23:26:02 2001 +0000
@@ -27,7 +27,7 @@
  *     i4b_tel.c - device driver for ISDN telephony
  *     --------------------------------------------
  *
- *     $Id: i4b_tel.c,v 1.4 2001/04/21 07:23:41 martin Exp $
+ *     $Id: i4b_tel.c,v 1.4.2.1 2001/09/08 23:26:02 thorpej Exp $
  *
  * $FreeBSD$
  *
@@ -179,6 +179,7 @@
 
 #ifdef OS_USES_POLL
 int i4btelpoll __P((dev_t dev, int events, struct proc *p));
+int i4btelkqfilter __P((dev_t dev, struct knote *kn));
 #else
 int i4btelsel __P((dev_t dev, int rw, struct proc *p));
 #endif
@@ -906,6 +907,117 @@
        return(revents);
 }
 
+static void
+filt_i4btel_detach(struct knote *kn)
+{
+       tel_sc_t *sc = (void *) kn->kn_hook;
+       int s;
+
+       s = splhigh();
+       SLIST_REMOVE(&sc->selp.si_klist, kn, knote, kn_selnext);
+       splx(s);
+}
+
+static int
+filt_i4btel_telread(struct knote *kn, long hint)
+{
+       tel_sc_t *sc = (void *) kn->kn_hook;
+
+       if ((sc->devstate & ST_CONNECTED) == 0)
+               return (0);
+       if (sc->isdn_linktab == NULL)
+               return (0);
+       if (IF_QEMPTY(sc->isdn_linktab->rx_queue))
+               return (0);
+
+       kn->kn_data = 0;        /* XXXLUKEM (thorpej): what to put here? */
+       return (1);
+}
+
+static const struct filterops i4btel_telread_filtops =
+       { 1, NULL, filt_i4btel_detach, filt_i4btel_telread };
+
+static int
+filt_i4btel_telwrite(struct knote *kn, long hint)
+{



Home | Main Index | Thread Index | Old Index