[email protected]
[Top] [All Lists]

PERFORCE change 113971 for review

Subject: PERFORCE change 113971 for review
From: "Christian S.J. Peron"
Date: Sun, 4 Feb 2007 01:02:12 GMT
http://perforce.freebsd.org/chv.cgi?CH=113971

Change 113971 by [email protected]_rnd01 on 2007/02/04 01:01:29

        Add a timed_out argument to bpf_ioctl_getznext(). We will use this
        argument to trigger the rotation of buffers in the event there was
        a read timeout.  We need to do the initialization of this variable
        in bpfioctl() as we will clobber the descriptor state and set it to
        BPF_IDLE.
        
        This implements the buffer rotation in the event of a read timeout.

Affected files ...

.. //depot/projects/zcopybpf/src/sys/net/bpf.c#11 edit
.. //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#11 edit
.. //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.h#3 edit

Differences ...

==== //depot/projects/zcopybpf/src/sys/net/bpf.c#11 (text+ko) ====

@@ -310,13 +310,14 @@
 }
 
 static int
-bpf_ioctl_getznext(struct thread *td, struct bpf_d *d, struct bpf_zbuf *bz)
+bpf_ioctl_getznext(struct thread *td, struct bpf_d *d, struct bpf_zbuf *bz,
+    int timed_out)
 {
 
        if (d->bd_bufmode != BPF_BUFMODE_ZBUF)
                return (EOPNOTSUPP);
 #ifdef BPF_ZEROCOPY
-       return (bpf_zerocopy_ioctl_getznext(td, d, bz));
+       return (bpf_zerocopy_ioctl_getznext(td, d, bz, timed_out));
 #else
        panic("bpf_ioctl_getznext");
 #endif
@@ -920,6 +921,7 @@
  *  BIOCSETZBUF                Set current zero-copy buffer locations.
  *  BIOCSETZBUF                Acknowledge reading zero-copy buffers.
  *  BIOCGETZMAX                Get maximum zero-copy buffer size.
+ *  BIOCGETZNEXT       Get next ready zero-copy buffer location
  */
 /* ARGSUSED */
 static int
@@ -927,8 +929,8 @@
     struct thread *td)
 {
        struct bpf_d *d = dev->si_drv1;
-       int error = 0;
-
+       int timed_out, error = 0;
+       
        /* 
         * Refresh PID associated with this descriptor.
         */
@@ -936,6 +938,13 @@
        d->bd_pid = td->td_proc->p_pid;
        if (d->bd_state == BPF_WAITING)
                callout_stop(&d->bd_callout);
+       /*
+        * Before we clobber the BPF state, check to see if this descriptor
+        * was timed out.  If so, we capture that bit of information so we
+        * can pass it to bpf_ioctl_getznext() so that it knows to rotate
+        * the buffers.
+        */
+       timed_out = (d->bd_state == BPF_TIMED_OUT) ? 1 : 0;
        d->bd_state = BPF_IDLE;
        BPFD_UNLOCK(d);
 
@@ -1278,7 +1287,8 @@
                return (bpf_ioctl_getzmax(td, d, (u_int *)addr));
 
        case BIOCGETZNEXT:
-               return (bpf_ioctl_getznext(td, d, (struct bpf_zbuf *)addr));
+               return (bpf_ioctl_getznext(td, d, (struct bpf_zbuf *)addr,
+                   timed_out));
 
        case BIOCSETZBUF:
                return (bpf_ioctl_setzbuf(td, d, (struct bpf_zbuf *)addr));

==== //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#11 (text+ko) ====

@@ -548,7 +548,7 @@
  */
 int
 bpf_zerocopy_ioctl_getznext(struct thread *td, struct bpf_d *d,
-    struct bpf_zbuf *bz)
+    struct bpf_zbuf *bz, int timed_out)
 {
        struct zbuf *zb;
 
@@ -564,7 +564,8 @@
         * held buffer.
         */
        BPFD_LOCK(d);
-       if (d->bd_immediate && d->bd_hbuf == NULL && d->bd_slen != 0)
+       if ((timed_out || d->bd_immediate) && d->bd_hbuf == NULL
+           && d->bd_slen != 0)
                ROTATE_BUFFERS(d);
        bzero(bz, sizeof(*bz));
        if (d->bd_hbuf != NULL) {

==== //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.h#3 (text+ko) ====

@@ -50,7 +50,7 @@
 int    bpf_zerocopy_ioctl_getzmax(struct thread *td, struct bpf_d *d,
            u_int *i);
 int    bpf_zerocopy_ioctl_getznext(struct thread *td, struct bpf_d *d,
-           struct bpf_zbuf *bz);
+           struct bpf_zbuf *bz, int timed_out);
 int    bpf_zerocopy_ioctl_setzbuf(struct thread *td, struct bpf_d *d,
            struct bpf_zbuf *bz);
 int    bpf_zerocopy_uiomove(struct bpf_d *d, caddr_t buf, u_int len,
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/p4-projects
To unsubscribe, send any mail to "[email protected]"

<Prev in Thread] Current Thread [Next in Thread>
  • PERFORCE change 113971 for review, Christian S.J. Peron <=