Date: Thu, 6 Nov 2008 23:02:42 GMT From: Hans Petter Selasky <hselasky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 152597 for review Message-ID: <200811062302.mA6N2g3H036233@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811062302.mA6N2g3H036233>