From owner-p4-projects@FreeBSD.ORG Wed Jan 31 01:51:43 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 C758816A40D; Wed, 31 Jan 2007 01:51:42 +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 71BB316A40A for ; Wed, 31 Jan 2007 01:51:42 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 5C35E13C48E for ; Wed, 31 Jan 2007 01:51:42 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id l0V1pgko034266 for ; Wed, 31 Jan 2007 01:51:42 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id l0V1pfTF034263 for perforce@freebsd.org; Wed, 31 Jan 2007 01:51:41 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 31 Jan 2007 01:51:41 GMT Message-Id: <200701310151.l0V1pfTF034263@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 113744 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: Wed, 31 Jan 2007 01:51:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=113744 Change 113744 by rwatson@rwatson_cinnamon on 2007/01/31 01:50:59 Disable bpfread() for BPF devices in anything but buffered mode until such time as we implement proper support methods for other buffer modes. I.e., a uiomove able to scatter-gather from the zbuf buffer layout. Move bpf_ready() from a macro inbpfdesc.h to bpf.c as a function. Add locking assertion to it. We will be reformulating this to take into account "ready to read" differences between buffer modes. Affected files ... .. //depot/projects/zcopybpf/src/sys/net/bpf.c#5 edit .. //depot/projects/zcopybpf/src/sys/net/bpfdesc.h#4 edit Differences ... ==== //depot/projects/zcopybpf/src/sys/net/bpf.c#5 (text+ko) ==== @@ -641,6 +641,15 @@ return (EINVAL); BPFD_LOCK(d); + if (d->bd_bufmode != BPF_BUFMODE_BUFFER) { + /* + * XXXRW: For now, we don't implement a uiomove for the + * scatter-gather buffers associated with BPF_BUFMODE_ZBUF, + * so simply disallow read(). + */ + BPFD_UNLOCK(d); + return (EOPNOTSUPP); + } if (d->bd_state == BPF_WAITING) callout_stop(&d->bd_callout); timed_out = (d->bd_state == BPF_TIMED_OUT); @@ -764,6 +773,20 @@ } static int +bpf_ready(struct bpf_d *d) +{ + + BPFD_LOCK_ASSERT(d); + + if (d->bd_hlen != 0) + return (1); + if ((d->bd_immediate || d->bd_state == BPF_TIMED_OUT) && + d->bd_slen != 0) + return (1); + return (0); +} + +static int bpfwrite(struct cdev *dev, struct uio *uio, int ioflag) { struct bpf_d *d = dev->si_drv1; ==== //depot/projects/zcopybpf/src/sys/net/bpfdesc.h#4 (text+ko) ==== @@ -108,12 +108,6 @@ NET_ASSERT_GIANT(); \ } while (0) -/* Test whether a BPF is ready for read(). */ -#define bpf_ready(bd) \ - ((bd)->bd_hlen != 0 || \ - (((bd)->bd_immediate || (bd)->bd_state == BPF_TIMED_OUT) && \ - (bd)->bd_slen != 0)) - /* * External representation of the bpf descriptor */