From owner-p4-projects@FreeBSD.ORG Thu Nov 6 23:02:43 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1EA4E106567B; Thu, 6 Nov 2008 23:02:43 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2C941065672 for ; Thu, 6 Nov 2008 23:02:42 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C191A8FC2F for ; Thu, 6 Nov 2008 23:02:42 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id mA6N2g57036235 for ; Thu, 6 Nov 2008 23:02:42 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id mA6N2g3H036233 for perforce@freebsd.org; Thu, 6 Nov 2008 23:02:42 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 6 Nov 2008 23:02:42 GMT Message-Id: <200811062302.mA6N2g3H036233@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 152597 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: Thu, 06 Nov 2008 23:02:43 -0000 http://perforce.freebsd.org/chv.cgi?CH=152597 Change 152597 by hselasky@hselasky_laptop001 on 2008/11/06 23:02:19 Sometimes it is convenient to process data at the expense of a userland process instead of a kernel process or thread. Add support for data filters. Affected files ... .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#39 edit .. //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.h#14 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.c#39 (text+ko) ==== @@ -1777,9 +1777,16 @@ break; } continue; - } else { - tr_data = 1; + } + if (f->methods->f_filter_read) { + /* + * Sometimes it is convenient to process data at the + * expense of a userland process instead of a kernel + * process. + */ + (f->methods->f_filter_read) (f, m); } + tr_data = 1; io_len = MIN(m->cur_data_len, uio->uio_resid); @@ -1914,9 +1921,8 @@ break; } continue; - } else { - tr_data = 1; } + tr_data = 1; USB_MBUF_RESET(m); @@ -1933,10 +1939,19 @@ if (err) { USB_IF_ENQUEUE(&f->free_q, m); break; - } else { - USB_IF_ENQUEUE(&f->used_q, m); - (f->methods->f_start_write) (f); + } + if (f->methods->f_filter_write) { + /* + * Sometimes it is convenient to process data at the + * expense of a userland process instead of a kernel + * process. + */ + (f->methods->f_filter_write) (f, m); } + USB_IF_ENQUEUE(&f->used_q, m); + + (f->methods->f_start_write) (f); + } while (uio->uio_resid > 0); done: mtx_unlock(f->priv_mtx); @@ -2561,33 +2576,18 @@ { struct usb2_mbuf *m; - USB_IF_DEQUEUE(&f->used_q, m); + USB_IF_POLL(&f->used_q, m); if (m) { *plen = m->cur_data_len; *pptr = m->cur_data_ptr; - USB_IF_PREPEND(&f->used_q, m); return (1); } return (0); } void -usb2_fifo_get_data_next(struct usb2_fifo *f) -{ - struct usb2_mbuf *m; - - USB_IF_DEQUEUE(&f->used_q, m); - - if (m) { - USB_IF_ENQUEUE(&f->free_q, m); - usb2_fifo_wakeup(f); - } - return; -} - -void usb2_fifo_get_data_error(struct usb2_fifo *f) { f->flag_iserror = 1; ==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_dev.h#14 (text+ko) ==== @@ -39,11 +39,13 @@ #define USB_FIFO_RX 1 struct usb2_fifo; +struct usb2_mbuf; typedef int (usb2_fifo_open_t)(struct usb2_fifo *fifo, int fflags, struct thread *td); typedef void (usb2_fifo_close_t)(struct usb2_fifo *fifo, int fflags, struct thread *td); typedef int (usb2_fifo_ioctl_t)(struct usb2_fifo *fifo, u_long cmd, void *addr, int fflags, struct thread *td); typedef void (usb2_fifo_cmd_t)(struct usb2_fifo *fifo); +typedef void (usb2_fifo_filter_t)(struct usb2_fifo *fifo, struct usb2_mbuf *m); struct usb2_symlink { TAILQ_ENTRY(usb2_symlink) sym_entry; @@ -57,8 +59,8 @@ /* * Locking note for the following functions. All the - * "usb2_fifo_cmd_t" functions are called locked. The others are - * called unlocked. + * "usb2_fifo_cmd_t" and "usb2_fifo_filter_t" functions are called + * locked. The others are called unlocked. */ struct usb2_fifo_methods { usb2_fifo_open_t *f_open; @@ -68,6 +70,8 @@ usb2_fifo_cmd_t *f_stop_read; usb2_fifo_cmd_t *f_start_write; usb2_fifo_cmd_t *f_stop_write; + usb2_fifo_filter_t *f_filter_read; + usb2_fifo_filter_t *f_filter_write; const char *basename[4]; const char *postfix[4]; }; @@ -134,7 +138,6 @@ uint8_t usb2_fifo_get_data(struct usb2_fifo *fifo, struct usb2_page_cache *pc, uint32_t offset, uint32_t len, uint32_t *actlen, uint8_t what); uint8_t usb2_fifo_get_data_linear(struct usb2_fifo *fifo, void *ptr, uint32_t len, uint32_t *actlen, uint8_t what); uint8_t usb2_fifo_get_data_buffer(struct usb2_fifo *f, void **pptr, uint32_t *plen); -void usb2_fifo_get_data_next(struct usb2_fifo *f); void usb2_fifo_get_data_error(struct usb2_fifo *fifo); uint8_t usb2_fifo_opened(struct usb2_fifo *fifo); void usb2_fifo_free(struct usb2_fifo *f);