From owner-freebsd-current@FreeBSD.ORG Thu Feb 27 07:04:05 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 09585DA3 for ; Thu, 27 Feb 2014 07:04:05 +0000 (UTC) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by mx1.freebsd.org (Postfix) with ESMTP id 01B8F1F9F for ; Thu, 27 Feb 2014 07:03:59 +0000 (UTC) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile14) with ESMTP id s1R73vdo011874; Thu, 27 Feb 2014 16:03:57 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili11) with ESMTP id s1R73vR14350; Thu, 27 Feb 2014 16:03:57 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi11) id s1R73vK4009152; Thu, 27 Feb 2014 16:03:57 +0900 Received: from localhost by lomi11.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id s1R73vql009100; Thu, 27 Feb 2014 16:03:57 +0900 Date: Thu, 27 Feb 2014 16:03:54 +0900 (JST) Message-Id: <20140227.160354.2283977188535912888.okuno.kohji@jp.panasonic.com> To: jmg@funkthat.com Subject: Re: kqueue for usb_dev From: Kohji Okuno In-Reply-To: <20140227062118.GC47921@funkthat.com> References: <20140227.142615.924807465819500067.okuno.kohji@jp.panasonic.com> <20140227062118.GC47921@funkthat.com> Organization: Panasonic Corporation X-Mailer: Mew version 6.5 on Emacs 24.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Thu_Feb_27_16_03_54_2014_940)--" Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org, okuno.kohji@jp.panasonic.com X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Feb 2014 07:04:05 -0000 ----Next_Part(Thu_Feb_27_16_03_54_2014_940)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi John-Mark, I tested the attached sample source with USB mouse. Thanks, Kohji Okuno From: John-Mark Gurney > Kohji Okuno wrote this message on Thu, Feb 27, 2014 at 14:26 +0900: >> I tried add kqueue I/F to usb_dev.c. I attached my patch. >> What do you think about my patch? > > Do you have test cases for these patches? > > -- > John-Mark Gurney Voice: +1 415 225 5579 > > "All that I will do, has been done, All that I have, has not." ----Next_Part(Thu_Feb_27_16_03_54_2014_940)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ums.c" #include #include #include #include #include #include #include #include #include #include #define DEV "/dev/ums0" #if 0 int main() { int i; ssize_t ret; uint8_t buf[128]; int fd = open(DEV, O_RDONLY); fd_set readfds; for (i = 0; i < 10; i++) { FD_ZERO(&readfds); FD_SET(fd, &readfds); ret = select(fd+1, &readfds, NULL, NULL, NULL); printf("select=%d\n", ret); ret = read(fd, buf, sizeof(buf)); printf("%d:%02x %02x %02x\n", ret, buf[0], buf[1], buf[2]); } close(fd); exit(0); } #else int main() { int i; int err; ssize_t ret; uint8_t buf[128]; int fd = open(DEV, O_RDONLY); int kqfd = kqueue(); struct kevent evlist[1]; EV_SET(&evlist[0], fd, EVFILT_READ, EV_ADD, 0, 0, 0); err = kevent(kqfd, evlist, 1, 0, 0, 0); if (err) { perror("kevent"); close(fd); close(kqfd); exit(1); } for (i = 0; i < 10; i++) { ret = kevent(kqfd, 0, 0, evlist, 1, 0); printf("kev=%d\n", ret); ret = read(fd, buf, sizeof(buf)); printf("%d:%02x %02x %02x\n", ret, buf[0], buf[1], buf[2]); } close(fd); exit(0); } #endif ----Next_Part(Thu_Feb_27_16_03_54_2014_940)----