usb_bus.h revision 330897
1/* $FreeBSD: stable/11/sys/dev/usb/usb_bus.h 330897 2018-03-14 03:19:51Z eadler $ */ 2/*- 3 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 4 * 5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29#ifndef _USB_BUS_H_ 30#define _USB_BUS_H_ 31 32struct usb_fs_privdata; 33 34/* 35 * The following structure defines the USB explore message sent to the USB 36 * explore process. 37 */ 38 39struct usb_bus_msg { 40 struct usb_proc_msg hdr; 41 struct usb_bus *bus; 42}; 43 44/* 45 * The following structure defines the USB statistics structure. 46 */ 47struct usb_bus_stat { 48 uint32_t uds_requests[4]; 49}; 50 51/* 52 * The following structure defines an USB BUS. There is one USB BUS 53 * for every Host or Device controller. 54 */ 55struct usb_bus { 56 struct usb_bus_stat stats_err; 57 struct usb_bus_stat stats_ok; 58#if USB_HAVE_ROOT_MOUNT_HOLD 59 struct root_hold_token *bus_roothold; 60#endif 61 62/* convenience macros */ 63#define USB_BUS_TT_PROC(bus) USB_BUS_NON_GIANT_ISOC_PROC(bus) 64#define USB_BUS_CS_PROC(bus) USB_BUS_NON_GIANT_ISOC_PROC(bus) 65 66#if USB_HAVE_PER_BUS_PROCESS 67#define USB_BUS_GIANT_PROC(bus) (&(bus)->giant_callback_proc) 68#define USB_BUS_NON_GIANT_ISOC_PROC(bus) (&(bus)->non_giant_isoc_callback_proc) 69#define USB_BUS_NON_GIANT_BULK_PROC(bus) (&(bus)->non_giant_bulk_callback_proc) 70#define USB_BUS_EXPLORE_PROC(bus) (&(bus)->explore_proc) 71#define USB_BUS_CONTROL_XFER_PROC(bus) (&(bus)->control_xfer_proc) 72 /* 73 * There are three callback processes. One for Giant locked 74 * callbacks. One for non-Giant locked non-periodic callbacks 75 * and one for non-Giant locked periodic callbacks. This 76 * should avoid congestion and reduce response time in most 77 * cases. 78 */ 79 struct usb_process giant_callback_proc; 80 struct usb_process non_giant_isoc_callback_proc; 81 struct usb_process non_giant_bulk_callback_proc; 82 83 /* Explore process */ 84 struct usb_process explore_proc; 85 86 /* Control request process */ 87 struct usb_process control_xfer_proc; 88#endif 89 90 struct usb_bus_msg explore_msg[2]; 91 struct usb_bus_msg detach_msg[2]; 92 struct usb_bus_msg attach_msg[2]; 93 struct usb_bus_msg suspend_msg[2]; 94 struct usb_bus_msg resume_msg[2]; 95 struct usb_bus_msg reset_msg[2]; 96 struct usb_bus_msg shutdown_msg[2]; 97#if USB_HAVE_UGEN 98 struct usb_bus_msg cleanup_msg[2]; 99 LIST_HEAD(,usb_fs_privdata) pd_cleanup_list; 100#endif 101 /* 102 * This mutex protects the USB hardware: 103 */ 104 struct mtx bus_mtx; 105 struct mtx bus_spin_lock; 106 struct usb_xfer_queue intr_q; 107 struct usb_callout power_wdog; /* power management */ 108 109 device_t parent; 110 device_t bdev; /* filled by HC driver */ 111 112#if USB_HAVE_BUSDMA 113 struct usb_dma_parent_tag dma_parent_tag[1]; 114 struct usb_dma_tag dma_tags[USB_BUS_DMA_TAG_MAX]; 115#endif 116 const struct usb_bus_methods *methods; /* filled by HC driver */ 117 struct usb_device **devices; 118 119 struct ifnet *ifp; /* only for USB Packet Filter */ 120 121 usb_power_mask_t hw_power_state; /* see USB_HW_POWER_XXX */ 122 usb_size_t uframe_usage[USB_HS_MICRO_FRAMES_MAX]; 123 124 uint16_t isoc_time_last; /* in milliseconds */ 125 126 uint8_t alloc_failed; /* Set if memory allocation failed. */ 127 uint8_t driver_added_refcount; /* Current driver generation count */ 128 enum usb_revision usbrev; /* USB revision. See "USB_REV_XXX". */ 129 130 uint8_t devices_max; /* maximum number of USB devices */ 131 uint8_t do_probe; /* set if USB should be re-probed */ 132 uint8_t no_explore; /* don't explore USB ports */ 133 uint8_t dma_bits; /* number of DMA address lines */ 134}; 135 136#endif /* _USB_BUS_H_ */ 137