From owner-svn-src-stable-8@FreeBSD.ORG Thu Apr 29 22:40:12 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AABC5106566B; Thu, 29 Apr 2010 22:40:12 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 970DE8FC08; Thu, 29 Apr 2010 22:40:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3TMeCQM080031; Thu, 29 Apr 2010 22:40:12 GMT (envelope-from thompsa@svn.freebsd.org) Received: (from thompsa@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3TMeCSe080026; Thu, 29 Apr 2010 22:40:12 GMT (envelope-from thompsa@svn.freebsd.org) Message-Id: <201004292240.o3TMeCSe080026@svn.freebsd.org> From: Andrew Thompson Date: Thu, 29 Apr 2010 22:40:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207397 - in stable/8: etc etc/devd sbin/devd sys/dev/usb X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Apr 2010 22:40:12 -0000 Author: thompsa Date: Thu Apr 29 22:40:12 2010 New Revision: 207397 URL: http://svn.freebsd.org/changeset/base/207397 Log: MFC r207020, r207027, r207072. Change usb devd events from fake attach to a notify. The ugen device is not a proper device_t so it faked the devctl event to appear like one, this is now a notify which allows more information to be passed. We notify for both the device attach/detach and for each usb interface. A devd rule can now match on the interface properties, including composite devices which may have a uvideo interface and also usound and possibly uhid too. An example to match a umass device with a scsi subclass and BBB protocol would be notify 100 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "ATTACH"; match "intclass" "0x08"; match "intsubclass" "0x06"; match "intprotocol" "0x50"; action ... }; The old attach devctl event has been retained for the moment to make merging to 8.1 easier. This was never compatible with 7.x or earlier due to the ugen regex change needed. Document the new USB notification types. Modified: stable/8/etc/devd.conf stable/8/etc/devd/uath.conf stable/8/sbin/devd/devd.conf.5 stable/8/sys/dev/usb/usb_device.c Directory Properties: stable/8/etc/ (props changed) stable/8/sbin/devd/ (props changed) stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/etc/devd.conf ============================================================================== --- stable/8/etc/devd.conf Thu Apr 29 22:30:59 2010 (r207396) +++ stable/8/etc/devd.conf Thu Apr 29 22:40:12 2010 (r207397) @@ -138,12 +138,14 @@ attach 100 { # This entry starts the ColdSync tool in daemon mode. Make sure you have an up # to date /usr/local/etc/palms. We override the 'listen' settings for port and # type in /usr/local/etc/coldsync.conf. -attach 100 { - device-name "ugen[0-9]+"; - match "vendor" "0x082d"; - match "product" "0x0100"; - match "release" "0x0100"; - action "/usr/local/bin/coldsync -md -p /dev/$device-name -t usb"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x082d"; + match "product" "0x0100"; + match "release" "0x0100"; + action "/usr/local/bin/coldsync -md -p /dev/$cdev -t usb"; }; # Modified: stable/8/etc/devd/uath.conf ============================================================================== --- stable/8/etc/devd/uath.conf Thu Apr 29 22:30:59 2010 (r207396) +++ stable/8/etc/devd/uath.conf Thu Apr 29 22:40:12 2010 (r207397) @@ -4,117 +4,143 @@ # Accton # SMCWUSB-G and SMCWUSBT-G2 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x083a"; - match "product" "(0x4505|0x4507)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x083a"; + match "product" "(0x4505|0x4507)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Atheros Communications # AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x168c"; - match "product" "0x0002"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x168c"; + match "product" "0x0002"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Atheros Communications # AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x0cf3"; - match "product" "(0x0002|0x0004|0x0006)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x0cf3"; + match "product" "(0x0002|0x0004|0x0006)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Conceptronic # AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x0d8e"; - match "product" "(0x7802|0x7812)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x0d8e"; + match "product" "(0x7802|0x7812)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # D-Link # DWL-AG132, DWL-G132 and DWL-AG122 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x2001"; - match "product" "(0x3a01|0x3a03|0x3a05)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x2001"; + match "product" "(0x3a01|0x3a03|0x3a05)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # D-Link # DWA-120 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x07d1"; - match "product" "0x3a0c"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x07d1"; + match "product" "0x3a0c"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Gigaset # SMCWUSBT-G -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x1690"; - match "product" "(0x0711|0x0713)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1690"; + match "product" "(0x0711|0x0713)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Global Sun Technology # AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x16ab"; - match "product" "(0x7802|0x7812)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x16ab"; + match "product" "(0x7802|0x7812)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # BayNETGEAR # WG111U -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x0846"; - match "product" "0x4301"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x0846"; + match "product" "0x4301"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Netgear # WG111T and WPN111 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x1385"; - match "product" "(0x4251|0x5f01)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1385"; + match "product" "(0x4251|0x5f01)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # U-MEDIA Communications # TEW-444UB and AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x157e"; - match "product" "(0x3007|0x3206)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x157e"; + match "product" "(0x3007|0x3206)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Wistron NeWeb # AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x1435"; - match "product" "(0x0827|0x0829)"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x1435"; + match "product" "(0x0827|0x0829)"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; # Z-Com # AR5523 -attach 100 { - device-name "ugen[0-9.]+"; - match "vendor" "0x0cde"; - match "product" "0x0013"; - action "/usr/sbin/uathload -d /dev/$device-name"; +notify 100 { + match "system" "USB"; + match "subsystem" "DEVICE"; + match "type" "ATTACH"; + match "vendor" "0x0cde"; + match "product" "0x0013"; + action "/usr/sbin/uathload -d /dev/$cdev"; }; Modified: stable/8/sbin/devd/devd.conf.5 ============================================================================== --- stable/8/sbin/devd/devd.conf.5 Thu Apr 29 22:30:59 2010 (r207396) +++ stable/8/sbin/devd/devd.conf.5 Thu Apr 29 22:40:12 2010 (r207397) @@ -250,18 +250,40 @@ CIS-vendor. Device class. .It Li device Device ID. +.It Li devclass +Device Class (USB) +.It Li devsubclass +Device Sub-class (USB) .It Li device-name Name of attached/detached device. +.It Li endpoints +Endpoint count (USB) .It Li function Card functions. +.It Li interface +Interface ID (USB) +.It Li intclass +Interface Class (USB) +.It Li intprotocol +Interface Protocol (USB) +.It Li intsubclass +Interface Sub-class (USB) .It Li manufacturer Manufacturer ID (pccard). +.It Li mode +Peripheral mode (USB) .It Li notify Match the value of the .Dq Li notify variable. +.It Li parent +Parent device +.It Li port +Hub port number (USB) .It Li product -Product ID (pccard). +Product ID (pccard/USB). +.It Li release +Hardware revision (USB) .It Li serial Serial Number (USB). .It Li slot @@ -342,6 +364,27 @@ The node is destroyed. .El .El +.It Li USB +Events related to the USB subsystem. +.Bl -tag -width ".Sy Subsystem" -compact +.It Sy Subsystem +.It Li DEVICE +.Bl -tag -width ".Li DETACH" -compact +.It Sy Type +.It Li ATTACH +USB device is attached to the system. +.It Li DETACH +USB device is detached from the system. +.El +.It Li INTERFACE +.Bl -tag -width ".Li DETACH" -compact +.It Sy Type +.It Li ATTACH +USB interface is attached from a device. +.It Li DETACH +USB interface is detached from a device. +.El +.El .It Li coretemp Events related to the .Xr coretemp 4 @@ -461,6 +504,17 @@ notify 0 { }; # +# Match a USB device type +# +notify 0 { + match "system" "USB"; + match "subsystem" "INTERFACE"; + match "type" "ATTACH"; + match "intclass" "0x0e"; + action "logger USB video device attached"; +}; + +# # Try to configure ath and wi devices with pccard_ether # as they are attached. # Modified: stable/8/sys/dev/usb/usb_device.c ============================================================================== --- stable/8/sys/dev/usb/usb_device.c Thu Apr 29 22:30:59 2010 (r207396) +++ stable/8/sys/dev/usb/usb_device.c Thu Apr 29 22:40:12 2010 (r207397) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -1834,7 +1835,7 @@ config_done: printf("%s: <%s> at %s\n", udev->ugen_name, udev->manufacturer, device_get_nameunit(udev->bus->bdev)); - usb_notify_addq("+", udev); + usb_notify_addq("ATTACH", udev); #endif done: if (err) { @@ -1980,7 +1981,7 @@ usb_free_device(struct usb_device *udev, usb_set_device_state(udev, USB_STATE_DETACHED); #if USB_HAVE_UGEN - usb_notify_addq("-", udev); + usb_notify_addq("DETACH", udev); printf("%s: <%s> at %s (disconnected)\n", udev->ugen_name, udev->manufacturer, device_get_nameunit(bus->bdev)); @@ -2347,13 +2348,23 @@ usbd_get_device_index(struct usb_device * * This function will generate events for dev. *------------------------------------------------------------------------*/ +#ifndef BURN_BRIDGES static void -usb_notify_addq(const char *type, struct usb_device *udev) +usb_notify_addq_compat(const char *type, struct usb_device *udev) { char *data = NULL; + const char *ntype; struct malloc_type *mt; const size_t buf_size = 512; + /* Convert notify type */ + if (strcmp(type, "ATTACH") == 0) + ntype = "+"; + else if (strcmp(type, "DETACH") == 0) + ntype = "-"; + else + return; + mtx_lock(&malloc_mtx); mt = malloc_desc2type("bus"); /* XXX M_BUS */ mtx_unlock(&malloc_mtx); @@ -2378,7 +2389,7 @@ usb_notify_addq(const char *type, struct "port=%u " "on " "%s\n", - type, + ntype, udev->ugen_name, UGETW(udev->ddesc.idVendor), UGETW(udev->ddesc.idProduct), @@ -2393,6 +2404,89 @@ usb_notify_addq(const char *type, struct devctl_queue_data(data); } +#endif + +static void +usb_notify_addq(const char *type, struct usb_device *udev) +{ + struct usb_interface *iface; + struct sbuf *sb; + int i; + +#ifndef BURN_BRIDGES + usb_notify_addq_compat(type, udev); +#endif + + /* announce the device */ + sb = sbuf_new_auto(); + sbuf_printf(sb, + "cdev=%s " + "vendor=0x%04x " + "product=0x%04x " + "devclass=0x%02x " + "devsubclass=0x%02x " + "sernum=\"%s\" " + "release=0x%04x " + "mode=%s " + "port=%u " + "parent=%s\n", + udev->ugen_name, + UGETW(udev->ddesc.idVendor), + UGETW(udev->ddesc.idProduct), + udev->ddesc.bDeviceClass, + udev->ddesc.bDeviceSubClass, + udev->serial, + UGETW(udev->ddesc.bcdDevice), + (udev->flags.usb_mode == USB_MODE_HOST) ? "host" : "device", + udev->port_no, + udev->parent_hub != NULL ? + udev->parent_hub->ugen_name : + device_get_nameunit(device_get_parent(udev->bus->bdev))); + sbuf_finish(sb); + devctl_notify("USB", "DEVICE", type, sbuf_data(sb)); + sbuf_delete(sb); + + /* announce each interface */ + for (i = 0; i < USB_IFACE_MAX; i++) { + iface = usbd_get_iface(udev, i); + if (iface == NULL) + break; /* end of interfaces */ + if (iface->idesc == NULL) + continue; /* no interface descriptor */ + + sb = sbuf_new_auto(); + sbuf_printf(sb, + "cdev=%s " + "vendor=0x%04x " + "product=0x%04x " + "devclass=0x%02x " + "devsubclass=0x%02x " + "sernum=\"%s\" " + "release=0x%04x " + "mode=%s " + "interface=%d " + "endpoints=%d " + "intclass=0x%02x " + "intsubclass=0x%02x " + "intprotocol=0x%02x\n", + udev->ugen_name, + UGETW(udev->ddesc.idVendor), + UGETW(udev->ddesc.idProduct), + udev->ddesc.bDeviceClass, + udev->ddesc.bDeviceSubClass, + udev->serial, + UGETW(udev->ddesc.bcdDevice), + (udev->flags.usb_mode == USB_MODE_HOST) ? "host" : "device", + iface->idesc->bInterfaceNumber, + iface->idesc->bNumEndpoints, + iface->idesc->bInterfaceClass, + iface->idesc->bInterfaceSubClass, + iface->idesc->bInterfaceProtocol); + sbuf_finish(sb); + devctl_notify("USB", "INTERFACE", type, sbuf_data(sb)); + sbuf_delete(sb); + } +} /*------------------------------------------------------------------------* * usb_fifo_free_wrap