Date: Tue, 25 Dec 2007 11:44:13 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 131578 for review Message-ID: <200712251144.lBPBiDuK015166@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=131578 Change 131578 by rwatson@rwatson_cinnamon on 2007/12/25 11:44:08 Minor style tweaks. Affected files ... .. //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#27 edit Differences ... ==== //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#27 (text+ko) ==== @@ -140,8 +140,8 @@ /* * Given a user pointer to a page of user memory, return an sf_buf for the - * page. Because we may be requesting quite a few sf_bufs, prefer failure - * to deadlock and use SFB_NOWAIT. + * page. Because we may be requesting quite a few sf_bufs, prefer failure to + * deadlock and use SFB_NOWAIT. */ static struct sf_buf * zbuf_sfbuf_get(struct vm_map *map, vm_offset_t uaddr) @@ -149,20 +149,17 @@ struct sf_buf *sf; vm_page_t pp; - if (vm_fault_quick((caddr_t) uaddr, VM_PROT_READ | VM_PROT_WRITE) - < 0) + if (vm_fault_quick((caddr_t) uaddr, VM_PROT_READ | VM_PROT_WRITE) < + 0) return (NULL); - - pp = pmap_extract_and_hold(map->pmap, uaddr, - VM_PROT_READ | VM_PROT_WRITE); + pp = pmap_extract_and_hold(map->pmap, uaddr, VM_PROT_READ | + VM_PROT_WRITE); if (pp == NULL) return (NULL); - vm_page_lock_queues(); vm_page_wire(pp); vm_page_unhold(pp); vm_page_unlock_queues(); - sf = sf_buf_alloc(pp, SFB_NOWAIT); if (sf == NULL) { zbuf_page_free(pp); @@ -197,6 +194,9 @@ if ((len / PAGE_SIZE) > BPF_MAX_PAGES) return (EINVAL); + /* + * Allocate the buffer and set up each page with is own sf_buf. + */ error = 0; zb = malloc(sizeof(*zb), M_BPF, M_ZERO | M_WAITOK); zb->zb_uaddr = uaddr; @@ -240,7 +240,6 @@ ("bpf_zerocopy_append_bytes: not in zbuf mode")); KASSERT(buf != NULL, ("bpf_zerocopy_append_bytes: NULL buf")); - src_bytes = (u_char *)src; zb = (struct zbuf *)buf; @@ -258,7 +257,6 @@ count = min(len, PAGE_SIZE - poffset); bcopy(src_bytes, ((u_char *)sf_buf_kva(zb->zb_pages[page])) + poffset, count); - poffset += count; if (poffset == PAGE_SIZE) { poffset = 0; @@ -317,7 +315,6 @@ bcopy(mtod(m, u_char *) + moffset, ((u_char *)sf_buf_kva(zb->zb_pages[page])) + poffset, count); - poffset += count; if (poffset == PAGE_SIZE) { poffset = 0; @@ -507,10 +504,8 @@ * held buffer. */ BPFD_LOCK(d); - if (d->bd_immediate && d->bd_hbuf == NULL - && d->bd_slen != 0) { + if (d->bd_immediate && d->bd_hbuf == NULL && d->bd_slen != 0) ROTATE_BUFFERS(d); - } bzero(bz, sizeof(*bz)); if (d->bd_hbuf != NULL) { zb = (struct zbuf *)d->bd_hbuf; @@ -538,6 +533,7 @@ BPFD_UNLOCK(d); return (0); } + /* * Ioctl to configure zero-copy buffers -- may be done only once. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200712251144.lBPBiDuK015166>