PERFORCE change 134217 for review

Christian S.J. Peron csjp at FreeBSD.org
Sun Jan 27 10:11:26 PST 2008


http://perforce.freebsd.org/chv.cgi?CH=134217

Change 134217 by csjp at csjp_xor on 2008/01/27 18:11:13

	Clean up BIOCACKZBUF, BIOCGETZBUF, and BIOCGETZNEXT.  When zerocopy
	bpf was early in development, we buffer management system was driven
	by system calls.  Now, the buffer management occurs using the zero
	copy buffers and a memory barrier on integer arithemetic.
	
	- Clean up ioctl commands
	- Re-number the ioctl commands
	- Garbage collect any KPIs that faciliated the old buffer management
	  systems
	
	Discussed with:	rwatson

Affected files ...

.. //depot/projects/zcopybpf/src/sys/net/bpf.c#41 edit
.. //depot/projects/zcopybpf/src/sys/net/bpf.h#20 edit
.. //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.c#28 edit
.. //depot/projects/zcopybpf/src/sys/net/bpf_zerocopy.h#11 edit

Differences ...

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

@@ -272,33 +272,6 @@
 }
 
 static int
-bpf_ioctl_ackzbuf(struct thread *td, struct bpf_d *d, struct bpf_zbuf *bz)
-{
-
-	if (d->bd_bufmode != BPF_BUFMODE_ZBUF)
-		return (EOPNOTSUPP);
-	return (bpf_zerocopy_ioctl_ackzbuf(td, d, bz));
-}
-
-static int
-bpf_ioctl_getzbuf(struct thread *td, struct bpf_d *d, struct bpf_zbuf *bz)
-{
-
-	if (d->bd_bufmode != BPF_BUFMODE_ZBUF)
-		return (EOPNOTSUPP);
-	return (bpf_zerocopy_ioctl_getzbuf(td, d, bz));
-}
-
-static int
-bpf_ioctl_getznext(struct thread *td, struct bpf_d *d, struct bpf_zbuf *bz)
-{
-
-	if (d->bd_bufmode != BPF_BUFMODE_ZBUF)
-		return (EOPNOTSUPP);
-	return (bpf_zerocopy_ioctl_getznext(td, d, bz));
-}
-
-static int
 bpf_ioctl_getzmax(struct thread *td, struct bpf_d *d, size_t *i)
 {
 
@@ -919,11 +892,8 @@
  *  BIOCSDIRECTION	Set packet direction flag
  *  BIOCLOCK		Set "locked" flag
  *  BIOCFEEDBACK	Set packet feedback mode.
- *  BIOCGETZBUF		Query current zero-copy buffer locations.
  *  BIOCSETZBUF		Set current zero-copy buffer locations.
- *  BIOCACKZBUF		Acknowledge reading zero-copy buffers.
  *  BIOCGETZMAX		Get maximum zero-copy buffer size.
- *  BIOCGETZNEXT	Get next ready zero-copy buffer location
  *  BIOCROTZBUF		Force rotation of zero-copy buffer
  */
 /* ARGSUSED */
@@ -962,8 +932,6 @@
 		case BIOCSRTIMEOUT:
 		case BIOCIMMEDIATE:
 		case TIOCGPGRP:
-		case BIOCACKZBUF:
-		case BIOCGETZBUF:
 		case BIOCROTZBUF:
 			break;
 		default:
@@ -1291,18 +1259,9 @@
 		BPFD_UNLOCK(d);
 		break;
 
-	case BIOCACKZBUF:
-		return (bpf_ioctl_ackzbuf(td, d, (struct bpf_zbuf *)addr));
-
-	case BIOCGETZBUF:
-		return (bpf_ioctl_getzbuf(td, d, (struct bpf_zbuf *)addr));
-
 	case BIOCGETZMAX:
 		return (bpf_ioctl_getzmax(td, d, (size_t *)addr));
 
-	case BIOCGETZNEXT:
-		return (bpf_ioctl_getznext(td, d, (struct bpf_zbuf *)addr));
-
 	case BIOCSETZBUF:
 		return (bpf_ioctl_setzbuf(td, d, (struct bpf_zbuf *)addr));
 

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

@@ -106,13 +106,11 @@
 #define	BPF_BUFMODE_DEFAULT	BPF_BUFMODE_BUFFER	/* Default. */
 
 /*
- * Struct used by BIOCACKZBUF, BIOCGETZNEXT, BIOCGETZBUF, BIOCSETZBUF:
+ * Struct used by BIOCSETZBUF, BIOCROTZBUF:
  * describes up to two zero-copy buffer as used by BPF.
  *
- * BIOCACKZBUF      Acknowledge read of stored zero-copy buffer (rotate).
- * BIOCGETZBUF      Query current zero-copy buffer locations.
- * BIOCGETZNEXT     Query next stored buffer, if available.
  * BIOCSETZBUF      Set current zero-copy buffer locations (once only).
+ * BIOCROTZBUF      Force rotation of zero-copy buffer(s)
  *
  * Pointers may be set to NULL to indicate a buffer is not configure, should
  * be freed, or is not being acknowledged.
@@ -152,13 +150,10 @@
 
 #define	BIOCGETBUFMODE	_IOR('B', 124, u_int)
 #define	BIOCSETBUFMODE	_IOW('B', 125, u_int)
-#define	BIOCACKZBUF	_IOW('B', 126, struct bpf_zbuf)
-#define	BIOCGETZBUF	_IOR('B', 127, struct bpf_zbuf)
-#define	BIOCGETZMAX	_IOR('B', 128, size_t)
-#define	BIOCGETZNEXT	_IOR('B', 129, struct bpf_zbuf)
-#define	BIOCROTZBUF	_IOR('B', 130, struct bpf_zbuf)
-#define	BIOCSETZBUF	_IOW('B', 131, struct bpf_zbuf)
-#define	BIOCFEEDBACK	_IOW('B', 132, u_int)
+#define	BIOCGETZMAX	_IOR('B', 126, size_t)
+#define	BIOCROTZBUF	_IOR('B', 127, struct bpf_zbuf)
+#define	BIOCSETZBUF	_IOW('B', 128, struct bpf_zbuf)
+#define	BIOCFEEDBACK	_IOW('B', 129, u_int)
 
 /* Packet directions */
 enum bpf_direction {

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

@@ -397,79 +397,6 @@
 }
 
 /*
- * Acknowledge reading the buffer without performing read().  We accept an
- * argument primarily so that we can validate that user space has the right
- * idea, helping to catch application bugs faster if the application's sense
- * of buffer rotation differs from the kernel's (or for that matter, kernel
- * bugs).
- */
-int
-bpf_zerocopy_ioctl_ackzbuf(struct thread *td, struct bpf_d *d,
-    struct bpf_zbuf *bz)
-{
-	struct zbuf *zb;
-
-	KASSERT(d->bd_bufmode == BPF_BUFMODE_ZBUF,
-	    ("bpf_zerocopy_ioctl_ackzbuf: not in zbuf mode"));
-
-	BPFD_LOCK(d);
-	if (d->bd_hbuf == NULL) {
-		BPFD_UNLOCK(d);
-		return (EINVAL);
-	}
-	zb = (struct zbuf *)d->bd_hbuf;
-	if (bz->bz_bufa != (void *)zb->zb_uaddr) {
-		BPFD_UNLOCK(d);
-		return (EINVAL);
-	}
-	zb->zb_header->bzh_user_gen = zb->zb_header->bzh_kernel_gen;
-	d->bd_fbuf = d->bd_hbuf;
-	d->bd_hbuf = NULL;
-	d->bd_hlen = 0;
-	BPFD_UNLOCK(d);
-	return (0);
-}
-
-/*
- * Ioctl to retrieve zbuf settings.  Note that the user address pointers are
- * copied versions of those originally submitted via the setzbuf ioctl--if
- * user space has remapped the buffers, then they may be inconsistent.  User
- * applications must be aware that these are in effect buffer names, not
- * pointers, if they play such games with their address space.  Pointers are
- * returned in arbitrary order, which may vary by ioctl.
- */
-int
-bpf_zerocopy_ioctl_getzbuf(struct thread *td, struct bpf_d *d,
-    struct bpf_zbuf *bz)
-{
-	struct zbuf *zb;
-
-	KASSERT(d->bd_bufmode == BPF_BUFMODE_ZBUF,
-	    ("bpf_zerocopy_ioctl_getzbuf: not in zbuf mode"));
-
-	bzero(bz, sizeof(*bz));
-	BPFD_LOCK(d);
-	if (d->bd_hbuf != NULL) {
-		zb = (struct zbuf *)d->bd_hbuf;
-		bz->bz_bufa = (void *)zb->zb_uaddr;
-		bz->bz_buflen = zb->zb_size;
-		zb = (struct zbuf *)d->bd_sbuf;
-		bz->bz_bufb = (void *)zb->zb_uaddr;
-	} else if (d->bd_sbuf != NULL) {
-		zb = (struct zbuf *)d->bd_sbuf;
-		bz->bz_bufa = (void *)zb->zb_uaddr;
-		bz->bz_buflen = zb->zb_size;
-		zb = (struct zbuf *)d->bd_fbuf;
-		bz->bz_bufb = (void *)zb->zb_uaddr;
-	} else {
-		bz->bz_bufa = bz->bz_bufb = NULL;
-		bz->bz_buflen = 0;
-	}
-	BPFD_UNLOCK(d);
-	return (0);
-}
-
-/*
  * Ioctl to return the maximum buffer size.
  */
 int
@@ -483,39 +410,6 @@
 	return (0);
 }
 
-/*
- * Ioctl to return the next completed buffer to read, if any.  In immediate
- * mode, this may force a buffer rotation if there is stored data but no held
- * data, in similar style to calling bpfread() on an immediate mode
- * descriptor.
- */
-int
-bpf_zerocopy_ioctl_getznext(struct thread *td, struct bpf_d *d,
-    struct bpf_zbuf *bz)
-{
-	struct zbuf *zb;
-
-	KASSERT(d->bd_bufmode == BPF_BUFMODE_ZBUF,
-	    ("bpf_zerocopy_ioctl_getznext: not in zbuf mode"));
-
-	/*
-	 * If in immediate mode, there's no holder buffer, but there is
-	 * stored packet data, rotate so that the stored buffer is now the
-	 * held buffer.
-	 */
-	BPFD_LOCK(d);
-	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;
-		bz->bz_bufa = (void *)zb->zb_uaddr;
-		bz->bz_buflen = d->bd_hlen;
-	}
-	BPFD_UNLOCK(d);
-	return (0);
-}
-
 int
 bpf_zerocopy_ioctl_rotzbuf(struct thread *td, struct bpf_d *d,
     struct bpf_zbuf *bz)

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

@@ -43,14 +43,8 @@
 void	bpf_zerocopy_bufheld(struct bpf_d *);
 int	bpf_zerocopy_canfreebuf(struct bpf_d *);
 void	bpf_zerocopy_free(struct bpf_d *d);
-int	bpf_zerocopy_ioctl_ackzbuf(struct thread *td, struct bpf_d *d,
-	    struct bpf_zbuf *bz);
-int	bpf_zerocopy_ioctl_getzbuf(struct thread *td, struct bpf_d *d,
-	    struct bpf_zbuf *bz);
 int	bpf_zerocopy_ioctl_getzmax(struct thread *td, struct bpf_d *d,
 	    size_t *i);
-int	bpf_zerocopy_ioctl_getznext(struct thread *td, struct bpf_d *d,
-	    struct bpf_zbuf *bz);
 int	bpf_zerocopy_ioctl_rotzbuf(struct thread *td, struct bpf_d *d,
 	    struct bpf_zbuf *bz);
 int	bpf_zerocopy_ioctl_setzbuf(struct thread *td, struct bpf_d *d,


More information about the p4-projects mailing list