From owner-svn-src-all@FreeBSD.ORG Sat Mar 7 10:21:37 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B465D106566C; Sat, 7 Mar 2009 10:21:37 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A1DD88FC14; Sat, 7 Mar 2009 10:21:37 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n27ALbLn045504; Sat, 7 Mar 2009 10:21:37 GMT (envelope-from rwatson@svn.freebsd.org) Received: (from rwatson@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n27ALbRj045503; Sat, 7 Mar 2009 10:21:37 GMT (envelope-from rwatson@svn.freebsd.org) Message-Id: <200903071021.n27ALbRj045503@svn.freebsd.org> From: Robert Watson Date: Sat, 7 Mar 2009 10:21:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189489 - head/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Mar 2009 10:21:38 -0000 Author: rwatson Date: Sat Mar 7 10:21:37 2009 New Revision: 189489 URL: http://svn.freebsd.org/changeset/base/189489 Log: Clarify some comments, fix some types, and rename ZBUF_FLAG_IMMUTABLE to ZBUF_FLAG_ASSIGNED to make it clear why the buffer can't be written to: it is assigned to userspace. Modified: head/sys/net/bpf_zerocopy.c Modified: head/sys/net/bpf_zerocopy.c ============================================================================== --- head/sys/net/bpf_zerocopy.c Sat Mar 7 07:26:22 2009 (r189488) +++ head/sys/net/bpf_zerocopy.c Sat Mar 7 10:21:37 2009 (r189489) @@ -91,7 +91,7 @@ __FBSDID("$FreeBSD$"); * knows that the space is not available. */ struct zbuf { - vm_offset_t zb_uaddr; /* User address, may be stale. */ + vm_offset_t zb_uaddr; /* User address at time of setup. */ size_t zb_size; /* Size of buffer, incl. header. */ u_int zb_numpages; /* Number of pages. */ int zb_flags; /* Flags on zbuf. */ @@ -104,7 +104,7 @@ struct zbuf { * buffer may remain in the store position as a result of the user process * not yet having acknowledged the buffer in the hold position yet. */ -#define ZBUF_FLAG_IMMUTABLE 0x00000001 /* Set when owned by user. */ +#define ZBUF_FLAG_ASSIGNED 0x00000001 /* Set when owned by user. */ /* * Release a page we've previously wired. @@ -262,8 +262,8 @@ bpf_zerocopy_append_bytes(struct bpf_d * src_bytes = (u_char *)src; zb = (struct zbuf *)buf; - KASSERT((zb->zb_flags & ZBUF_FLAG_IMMUTABLE) == 0, - ("bpf_zerocopy_append_bytes: ZBUF_FLAG_IMMUTABLE")); + KASSERT((zb->zb_flags & ZBUF_FLAG_ASSIGNED) == 0, + ("bpf_zerocopy_append_bytes: ZBUF_FLAG_ASSIGNED")); /* * Scatter-gather copy to user pages mapped into kernel address space @@ -314,8 +314,8 @@ bpf_zerocopy_append_mbuf(struct bpf_d *d m = (struct mbuf *)src; zb = (struct zbuf *)buf; - KASSERT((zb->zb_flags & ZBUF_FLAG_IMMUTABLE) == 0, - ("bpf_zerocopy_append_mbuf: ZBUF_FLAG_IMMUTABLE")); + KASSERT((zb->zb_flags & ZBUF_FLAG_ASSIGNED) == 0, + ("bpf_zerocopy_append_mbuf: ZBUF_FLAG_ASSIGNED")); /* * Scatter gather both from an mbuf chain and to a user page set @@ -374,8 +374,8 @@ bpf_zerocopy_buffull(struct bpf_d *d) zb = (struct zbuf *)d->bd_sbuf; KASSERT(zb != NULL, ("bpf_zerocopy_buffull: zb == NULL")); - if ((zb->zb_flags & ZBUF_FLAG_IMMUTABLE) == 0) { - zb->zb_flags |= ZBUF_FLAG_IMMUTABLE; + if ((zb->zb_flags & ZBUF_FLAG_ASSIGNED) == 0) { + zb->zb_flags |= ZBUF_FLAG_ASSIGNED; zb->zb_header->bzh_kernel_len = d->bd_slen; atomic_add_rel_int(&zb->zb_header->bzh_kernel_gen, 1); } @@ -384,9 +384,8 @@ bpf_zerocopy_buffull(struct bpf_d *d) /* * Notification from the BPF framework that a buffer has moved into the held * slot on a descriptor. Zero-copy BPF will update the shared page to let - * the user process know and flag the buffer as immutable if it hasn't - * already been marked immutable due to filling while it was in the store - * position. + * the user process know and flag the buffer as assigned if it hasn't already + * been marked assigned due to filling while it was in the store position. * * Note: identical logic as in bpf_zerocopy_buffull(), except that we operate * on bd_hbuf and bd_hlen. @@ -402,8 +401,8 @@ bpf_zerocopy_bufheld(struct bpf_d *d) zb = (struct zbuf *)d->bd_hbuf; KASSERT(zb != NULL, ("bpf_zerocopy_bufheld: zb == NULL")); - if ((zb->zb_flags & ZBUF_FLAG_IMMUTABLE) == 0) { - zb->zb_flags |= ZBUF_FLAG_IMMUTABLE; + if ((zb->zb_flags & ZBUF_FLAG_ASSIGNED) == 0) { + zb->zb_flags |= ZBUF_FLAG_ASSIGNED; zb->zb_header->bzh_kernel_len = d->bd_hlen; atomic_add_rel_int(&zb->zb_header->bzh_kernel_gen, 1); } @@ -411,7 +410,8 @@ bpf_zerocopy_bufheld(struct bpf_d *d) /* * Notification from the BPF framework that the free buffer has been been - * re-assigned. This happens when the user ackknowledges the buffer. + * rotated out of the held position to the free position. This happens when + * the user acknowledges the held buffer. */ void bpf_zerocopy_buf_reclaimed(struct bpf_d *d) @@ -422,9 +422,9 @@ bpf_zerocopy_buf_reclaimed(struct bpf_d ("bpf_zerocopy_reclaim_buf: not in zbuf mode")); KASSERT(d->bd_fbuf != NULL, - ("bpf_zerocopy_buf_reclaimed: NULL free buff")); + ("bpf_zerocopy_buf_reclaimed: NULL free buf")); zb = (struct zbuf *)d->bd_fbuf; - zb->zb_flags &= ~ZBUF_FLAG_IMMUTABLE; + zb->zb_flags &= ~ZBUF_FLAG_ASSIGNED; } /* @@ -467,7 +467,7 @@ bpf_zerocopy_canwritebuf(struct bpf_d *d zb = (struct zbuf *)d->bd_sbuf; KASSERT(zb != NULL, ("bpf_zerocopy_canwritebuf: bd_sbuf NULL")); - if (zb->zb_flags & ZBUF_FLAG_IMMUTABLE) + if (zb->zb_flags & ZBUF_FLAG_ASSIGNED) return (0); return (1); } @@ -510,7 +510,7 @@ bpf_zerocopy_ioctl_getzmax(struct thread /* * Ioctl to force rotation of the two buffers, if there's any data available. - * This can be used by user space to implement time outs when waiting for a + * This can be used by user space to implement timeouts when waiting for a * buffer to fill. */ int