From owner-p4-projects@FreeBSD.ORG Sun Feb 4 01:02:13 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 18F3A16A406; Sun, 4 Feb 2007 01:02:13 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E75F016A403 for ; Sun, 4 Feb 2007 01:02:12 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id D8F5E13C481 for ; Sun, 4 Feb 2007 01:02:12 +0000 (UTC) (envelope-from csjp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l1412CdX029123 for ; Sun, 4 Feb 2007 01:02:12 GMT (envelope-from csjp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l1412CK2029120 for perforce@freebsd.org; Sun, 4 Feb 2007 01:02:12 GMT (envelope-from csjp@freebsd.org) Date: Sun, 4 Feb 2007 01:02:12 GMT Message-Id: <200702040102.l1412CK2029120@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to csjp@freebsd.org using -f From: "Christian S.J. Peron" To: Perforce Change Reviews Cc: Subject: PERFORCE change 113971 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Feb 2007 01:02:13 -0000 http://perforce.freebsd.org/chv.cgi?CH=113971 Change 113971 by csjp@csjp_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,