17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5d29f5a71Szhigang lu - Sun Microsystems - Beijing China  * Common Development and Distribution License (the "License").
6d29f5a71Szhigang lu - Sun Microsystems - Beijing China  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  *
21ff0e937bSRaymond Chen  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
227c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
23e2c88f0cSGarrett D'Amore  *
24e2c88f0cSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
25*0d2006e4SRobert Mustacchi  * Copyright 2019, Joyent, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_USB_USBA_USBA_TYPES_H
297c478bd9Sstevel@tonic-gate #define	_SYS_USB_USBA_USBA_TYPES_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/taskq.h>
337c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_private.h>
347c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usbai_private.h>
35*0d2006e4SRobert Mustacchi #include <sys/usb/usba/bos.h>
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
387c478bd9Sstevel@tonic-gate extern "C" {
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate 
417c478bd9Sstevel@tonic-gate /* backup structure for opaque usb_pipe_handle_t */
427c478bd9Sstevel@tonic-gate typedef struct usba_ph_impl {
437c478bd9Sstevel@tonic-gate 	kmutex_t			usba_ph_mutex;
447c478bd9Sstevel@tonic-gate 	struct usba_pipe_handle_data	*usba_ph_data;	/* actual pipe handle */
457c478bd9Sstevel@tonic-gate 	dev_info_t			*usba_ph_dip;	/* owner dip */
467c478bd9Sstevel@tonic-gate 	usb_ep_descr_t			usba_ph_ep;	/* save ep descr */
477c478bd9Sstevel@tonic-gate 	usb_pipe_policy_t		usba_ph_policy; /* saved pipe policy */
487c478bd9Sstevel@tonic-gate 	uint_t				usba_ph_flags;
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate 	/*
517c478bd9Sstevel@tonic-gate 	 * usba_ph_ref_count is a count of the number of
527c478bd9Sstevel@tonic-gate 	 * concurrent activities on this pipe
537c478bd9Sstevel@tonic-gate 	 */
547c478bd9Sstevel@tonic-gate 	int				usba_ph_ref_count;
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 	/* pipe state management */
577c478bd9Sstevel@tonic-gate 	usb_pipe_state_t		usba_ph_state;
587c478bd9Sstevel@tonic-gate 	int				usba_ph_state_changing;
597c478bd9Sstevel@tonic-gate } usba_ph_impl_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_ph_impl::usba_ph_mutex, usba_ph_impl))
627c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_data))
637c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_dip))
647c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_ep))
657c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_ph_impl::usba_ph_policy))
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /* for usba_ph_flags */
687c478bd9Sstevel@tonic-gate #define	USBA_PH_DATA_TOGGLE		0x01	/* mask for data toggle */
697c478bd9Sstevel@tonic-gate #define	USBA_PH_DATA_PERSISTENT 	0x02	/* persistent pipe */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * usba_pipe_handle_data
747c478bd9Sstevel@tonic-gate  *	allocated by USBA and used by USBA and HCD but opaque to
757c478bd9Sstevel@tonic-gate  *	client driver
767c478bd9Sstevel@tonic-gate  *
777c478bd9Sstevel@tonic-gate  *	pipes can be shared but pipe_handles are unique
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  * p_hcd_private is a pointer to private data for HCD. This space
807c478bd9Sstevel@tonic-gate  * is allocated and maintained by HCD
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate typedef struct	usba_pipe_handle_data {
837c478bd9Sstevel@tonic-gate 	struct usba_ph_impl	*p_ph_impl;	/* backpointer to ph_impl */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 	/* For linking pipe requests on the pipe */
867c478bd9Sstevel@tonic-gate 	usba_list_entry_t	p_queue;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate 	/* shared usba_device structure */
897c478bd9Sstevel@tonic-gate 	struct usba_device	*p_usba_device;	/* set on pipe open */
907c478bd9Sstevel@tonic-gate 
91993e3fafSRobert Mustacchi 	/*
92993e3fafSRobert Mustacchi 	 * Pipe policy and endpoint descriptor for this pipe
93993e3fafSRobert Mustacchi 	 *
94993e3fafSRobert Mustacchi 	 * Both the basic and extended endpoints are kept around even though
95993e3fafSRobert Mustacchi 	 * we're duplicating data as most of the HCI drivers are relying on the
96993e3fafSRobert Mustacchi 	 * presence of p_ep.
97993e3fafSRobert Mustacchi 	 */
987c478bd9Sstevel@tonic-gate 	usb_pipe_policy_t	p_policy;	/* maintained by USBA */
997c478bd9Sstevel@tonic-gate 	usb_ep_descr_t		p_ep;
100993e3fafSRobert Mustacchi 	usb_ep_xdescr_t		p_xep;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate 	/* passed during open. needed for reset etc. */
1037c478bd9Sstevel@tonic-gate 	dev_info_t		*p_dip;
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate 	/* access control */
1067c478bd9Sstevel@tonic-gate 	kmutex_t		p_mutex;   /* mutex protecting pipe handle */
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate 	/* per-pipe private data for HCD */
1097c478bd9Sstevel@tonic-gate 	usb_opaque_t		p_hcd_private;
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 	/* per-pipe private data for client */
1127c478bd9Sstevel@tonic-gate 	usb_opaque_t		p_client_private;
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate 	/*
1157c478bd9Sstevel@tonic-gate 	 * p_req_count is the count of number requests active
1167c478bd9Sstevel@tonic-gate 	 * on this pipe
1177c478bd9Sstevel@tonic-gate 	 */
1187c478bd9Sstevel@tonic-gate 	int			p_req_count;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 	/* private use by USBA */
1217c478bd9Sstevel@tonic-gate 	usb_opaque_t		p_usba_private;
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate 	/*
1247c478bd9Sstevel@tonic-gate 	 * each pipe handle has its own taskq for callbacks and async reqs
1257c478bd9Sstevel@tonic-gate 	 * Note that this will not be used for normal callbacks if
1267c478bd9Sstevel@tonic-gate 	 * USB_FLAGS_SERIALIZED_CB is passed to usb_pipe_open().
1277c478bd9Sstevel@tonic-gate 	 */
1287c478bd9Sstevel@tonic-gate 	taskq_t			*p_taskq;
1297c478bd9Sstevel@tonic-gate 
1307c478bd9Sstevel@tonic-gate 	/* thread currently serving the queue */
1317c478bd9Sstevel@tonic-gate 	kthread_t		*p_thread_id;
1327c478bd9Sstevel@tonic-gate 
1337c478bd9Sstevel@tonic-gate 	/* cb queue serviced by taskq thread */
1347c478bd9Sstevel@tonic-gate 	usba_list_entry_t	p_cb_queue;
1357c478bd9Sstevel@tonic-gate 
1367c478bd9Sstevel@tonic-gate 	/* count for soft interrupts */
1377c478bd9Sstevel@tonic-gate 	uint_t			p_soft_intr;
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate 	/* flag for special things */
1407c478bd9Sstevel@tonic-gate 	uint_t			p_spec_flag;
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate } usba_pipe_handle_data_t;
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate #define	USBA_PH_FLAG_USE_SOFT_INTR	0x1
1457c478bd9Sstevel@tonic-gate #define	USBA_PH_FLAG_TQ_SHARE		0x2	/* Shared TaskQ for callbacks */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /* macro to get the endpoint descriptor */
1507c478bd9Sstevel@tonic-gate #define	USBA_DEFAULT_PIPE_EP	0	/* ep 0 is default pipe */
1517c478bd9Sstevel@tonic-gate #define	USBA_PH2ENDPOINT(ph)  (((usba_pipe_handle_data_t *)(ph))->p_ep)
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #define	USBA_PIPE_CLOSING(state) \
1547c478bd9Sstevel@tonic-gate 		(((state) == USB_PIPE_STATE_CLOSING) || \
1557c478bd9Sstevel@tonic-gate 		((state) == USB_PIPE_STATE_CLOSED))
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate #define	USBA_IS_DEFAULT_PIPE(ph)  ((ph) == \
1587c478bd9Sstevel@tonic-gate 	(ph)->p_usba_device->usb_ph_list[USBA_DEFAULT_PIPE_EP].usba_ph_data)
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_pipe_handle_data::p_mutex, \
1617c478bd9Sstevel@tonic-gate 	usba_pipe_handle_data))
1627c478bd9Sstevel@tonic-gate 
1637c478bd9Sstevel@tonic-gate /* these should be really stable data */
1647c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_ph_impl))
1657c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_usba_device))
1667c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_hcd_private))
1677c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_client_private))
1687c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_ep))
1697c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_dip))
1707c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_pipe_handle_data::p_taskq))
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate 
1737c478bd9Sstevel@tonic-gate /*
1747c478bd9Sstevel@tonic-gate  * usb_addr:
1757c478bd9Sstevel@tonic-gate  *	This is	the USB	address	of a device
1767c478bd9Sstevel@tonic-gate  */
1777c478bd9Sstevel@tonic-gate typedef	uchar_t usb_addr_t;
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #define	USBA_DEFAULT_ADDR	0
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate /*
1827c478bd9Sstevel@tonic-gate  * number of endpoint per device, 16 IN and 16 OUT.
1837c478bd9Sstevel@tonic-gate  * this define is used for pipehandle list, pipe reserved list
1847c478bd9Sstevel@tonic-gate  * and pipe open count array.
1857c478bd9Sstevel@tonic-gate  * these lists are indexed by endpoint number * ((address & direction)? 2 : 1)
1867c478bd9Sstevel@tonic-gate  *
1877c478bd9Sstevel@tonic-gate  * We use a bit mask for exclusive open tracking and therefore
1887c478bd9Sstevel@tonic-gate  * USB_N_ENDPOINTS must be equal to the bit size of int.
1897c478bd9Sstevel@tonic-gate  *
1907c478bd9Sstevel@tonic-gate  */
1917c478bd9Sstevel@tonic-gate #define	USBA_N_ENDPOINTS		32
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * USB spec defines 4 different power states of any usb device.
1957c478bd9Sstevel@tonic-gate  * They are D0, D1, D2 & D3. So, we need a total of 5 pm-components
1967c478bd9Sstevel@tonic-gate  * 4 for power and 1 for name.
1977c478bd9Sstevel@tonic-gate  */
1987c478bd9Sstevel@tonic-gate #define	USBA_N_PMCOMP		5
1997c478bd9Sstevel@tonic-gate 
2007c478bd9Sstevel@tonic-gate /*
2017c478bd9Sstevel@tonic-gate  * usb port status
2027c478bd9Sstevel@tonic-gate  */
2037c478bd9Sstevel@tonic-gate typedef uint8_t usb_port_status_t;
2047c478bd9Sstevel@tonic-gate typedef uint16_t usb_port_t;
2057c478bd9Sstevel@tonic-gate typedef uint32_t usb_port_mask_t;
2067c478bd9Sstevel@tonic-gate 
207993e3fafSRobert Mustacchi /*
208993e3fafSRobert Mustacchi  * Note, faster speeds should always be in increasing values. Various parts of
209993e3fafSRobert Mustacchi  * the stack use >= comparisons for things which are true for say anything equal
210993e3fafSRobert Mustacchi  * to or greater than USB 2.0.
211993e3fafSRobert Mustacchi  */
2127c478bd9Sstevel@tonic-gate #define	USBA_LOW_SPEED_DEV	0x1
2137c478bd9Sstevel@tonic-gate #define	USBA_FULL_SPEED_DEV	0x2
2147c478bd9Sstevel@tonic-gate #define	USBA_HIGH_SPEED_DEV	0x3
215993e3fafSRobert Mustacchi #define	USBA_SUPER_SPEED_DEV	0x4
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * NDI event is registered on a per-dip basis. usba_device can be
2197c478bd9Sstevel@tonic-gate  * shared by multiple dips, hence the following structure is
2207c478bd9Sstevel@tonic-gate  * need to keep per-dip event info.
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate typedef struct usba_evdata {
2237c478bd9Sstevel@tonic-gate 	struct usba_evdata	*ev_next;
2247c478bd9Sstevel@tonic-gate 	dev_info_t		*ev_dip;
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 	/* NDI evetn service callback ids */
2277c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_rm_cb_id;
2287c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_ins_cb_id;
2297c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_suspend_cb_id;
2307c478bd9Sstevel@tonic-gate 	ddi_callback_id_t	ev_resume_cb_id;
2317c478bd9Sstevel@tonic-gate } usba_evdata_t;
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate /*
2347c478bd9Sstevel@tonic-gate  * a client may request dev_data multiple times (eg. for
2357c478bd9Sstevel@tonic-gate  * ugen support) so we need a linked list
2367c478bd9Sstevel@tonic-gate  */
2377c478bd9Sstevel@tonic-gate typedef struct usb_client_dev_data_list {
2387c478bd9Sstevel@tonic-gate 	struct usb_client_dev_data_list *cddl_next;
2397c478bd9Sstevel@tonic-gate 	struct usb_client_dev_data_list *cddl_prev;
2407c478bd9Sstevel@tonic-gate 	dev_info_t			*cddl_dip;
2417c478bd9Sstevel@tonic-gate 	usb_client_dev_data_t		*cddl_dev_data;
2427c478bd9Sstevel@tonic-gate 	uint_t				cddl_ifno;
2437c478bd9Sstevel@tonic-gate } usb_client_dev_data_list_t;
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate /*
246*0d2006e4SRobert Mustacchi  * This structure uniquely identifies a USB device
2477c478bd9Sstevel@tonic-gate  * with all interfaces,	or just one interface of a USB device.
2487c478bd9Sstevel@tonic-gate  * usba_device is associated with a devinfo node
2497c478bd9Sstevel@tonic-gate  *
2507c478bd9Sstevel@tonic-gate  * This	structure is allocated and maintained by USBA and
2517c478bd9Sstevel@tonic-gate  * read-only for HCD
2527c478bd9Sstevel@tonic-gate  *
2537c478bd9Sstevel@tonic-gate  * There can be	multiple clients per device (multi-class
2547c478bd9Sstevel@tonic-gate  * device) in which case this structure is shared.
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate typedef struct usba_device {
2577c478bd9Sstevel@tonic-gate 	/* for linking all usba_devices on this bus */
2587c478bd9Sstevel@tonic-gate 	usba_list_entry_t	usb_device_list;
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	/* linked list of all pipe handles on this device per endpoint */
2617c478bd9Sstevel@tonic-gate 	struct usba_ph_impl	usb_ph_list[USBA_N_ENDPOINTS];
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 	kmutex_t		usb_mutex;   /* protecting usba_device */
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	dev_info_t		*usb_dip;
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate 	struct usba_hcdi_ops	*usb_hcdi_ops;	/* ptr to HCD ops */
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	struct usba_hubdi	*usb_hubdi;
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate 	usb_addr_t		usb_addr;	/* usb address */
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate 	uchar_t			usb_no_cpr;	/* CPR? */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate 	dev_info_t		*usb_root_hub_dip;
276ff0e937bSRaymond Chen 	struct hubd		*usb_root_hubd;	/* for HC or WA */
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate 	usb_dev_descr_t		*usb_dev_descr;	/* device descriptor */
2797c478bd9Sstevel@tonic-gate 
2807c478bd9Sstevel@tonic-gate 	uchar_t			*usb_cfg;	/* raw config descriptor */
2817c478bd9Sstevel@tonic-gate 	size_t			usb_cfg_length; /* length of raw descr */
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	char			*usb_mfg_str;	/* manufacturer string */
2847c478bd9Sstevel@tonic-gate 	char			*usb_product_str;	/* product string */
2857c478bd9Sstevel@tonic-gate 	char			*usb_serialno_str; /* serial number string */
2867c478bd9Sstevel@tonic-gate 	char			*usb_preferred_driver; /* user's choice */
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 	usb_port_status_t	usb_port_status; /* usb hub port status */
2897c478bd9Sstevel@tonic-gate 	usb_port_t		usb_port;
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 	/* To support split transactions */
2927c478bd9Sstevel@tonic-gate 	struct usba_device	*usb_hs_hub_usba_dev; /* HS hub usba device */
2937c478bd9Sstevel@tonic-gate 	usb_addr_t		usb_hs_hub_addr; /* High speed hub address */
2947c478bd9Sstevel@tonic-gate 	usb_port_t		usb_hs_hub_port; /* High speed hub port */
2957c478bd9Sstevel@tonic-gate 
2967c478bd9Sstevel@tonic-gate 	/* For high speed hub bandwidth allocation scheme */
2977c478bd9Sstevel@tonic-gate 	uint_t			usb_hs_hub_min_bandwidth;
2987c478bd9Sstevel@tonic-gate 	uint_t			usb_hs_hub_bandwidth[32];
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate 	/* store all config cloud here */
3017c478bd9Sstevel@tonic-gate 	uchar_t			**usb_cfg_array;
3027c478bd9Sstevel@tonic-gate 	uint_t			usb_cfg_array_length;
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 	uint16_t		*usb_cfg_array_len;
3057c478bd9Sstevel@tonic-gate 	uint_t			usb_cfg_array_len_length;
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate 	uint_t			usb_cfg_value;
3087c478bd9Sstevel@tonic-gate 	uint_t			usb_active_cfg_ndx;
3097c478bd9Sstevel@tonic-gate 	char			**usb_cfg_str_descr;
3107c478bd9Sstevel@tonic-gate 	uchar_t			usb_n_cfgs;
3117c478bd9Sstevel@tonic-gate 	uchar_t			usb_n_ifs;
3127c478bd9Sstevel@tonic-gate 
31335f36846Ssl 	/*
31435f36846Ssl 	 * power drawn from hub, if > 0, the power has been
31535f36846Ssl 	 * subtracted from the parent hub's power budget
31635f36846Ssl 	 */
31735f36846Ssl 	uint16_t		usb_pwr_from_hub;
31835f36846Ssl 
3197c478bd9Sstevel@tonic-gate 	/* ref count, if > 0, this structure is in use */
3207c478bd9Sstevel@tonic-gate 	int			usb_ref_count;
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate 	/* list of requests allocated for this device, detects leaks */
3237c478bd9Sstevel@tonic-gate 	usba_list_entry_t	usb_allocated;		/* alloc'ed reqs list */
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 	/* NDI event service cookies */
3267c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	rm_cookie;
3277c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	ins_cookie;
3287c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	suspend_cookie;
3297c478bd9Sstevel@tonic-gate 	ddi_eventcookie_t	resume_cookie;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate 	/* linked list of callid (per-devinfo) */
3327c478bd9Sstevel@tonic-gate 	usba_evdata_t		*usb_evdata;
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate 	/* client cleanup checks */
3357c478bd9Sstevel@tonic-gate 	uchar_t			*usb_client_flags;
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate 	struct {
3387c478bd9Sstevel@tonic-gate 		dev_info_t *dip;
3397c478bd9Sstevel@tonic-gate 	}			*usb_client_attach_list;
3407c478bd9Sstevel@tonic-gate 
3417c478bd9Sstevel@tonic-gate 	usb_client_dev_data_list_t usb_client_dev_data_list;
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate 	struct {
3447c478bd9Sstevel@tonic-gate 		dev_info_t *dip;
3457c478bd9Sstevel@tonic-gate 		usb_event_t *ev_data;
3467c478bd9Sstevel@tonic-gate 	}			*usb_client_ev_cb_list;
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate 	/* Shared task queue implementation. */
3497c478bd9Sstevel@tonic-gate 	taskq_t			*usb_shared_taskq[USBA_N_ENDPOINTS];
3507c478bd9Sstevel@tonic-gate 	uchar_t			usb_shared_taskq_ref_count
3517c478bd9Sstevel@tonic-gate 						[USBA_N_ENDPOINTS];
352993e3fafSRobert Mustacchi 
353993e3fafSRobert Mustacchi 	/*
354993e3fafSRobert Mustacchi 	 * Pointer to hub this is under. This is required for some HCDs to
355993e3fafSRobert Mustacchi 	 * accurately set up the device. Note that some usba_device_t's are
356993e3fafSRobert Mustacchi 	 * shared by multiple entries, so this is not strictly the parent
357993e3fafSRobert Mustacchi 	 * device. This would come up if the usb_mid driver was on the scene.
358993e3fafSRobert Mustacchi 	 * Importantly, this field is always read-only. While this is similar to
359993e3fafSRobert Mustacchi 	 * the usb_hs_hub_usba_dev, it's always set, regardless if it's a high
360993e3fafSRobert Mustacchi 	 * speed device or not.
361993e3fafSRobert Mustacchi 	 */
362993e3fafSRobert Mustacchi 	struct usba_device	*usb_parent_hub;
363993e3fafSRobert Mustacchi 
364993e3fafSRobert Mustacchi 	/*
365993e3fafSRobert Mustacchi 	 * Private data for HCD drivers
366993e3fafSRobert Mustacchi 	 */
367993e3fafSRobert Mustacchi 	void			*usb_hcd_private;
368*0d2006e4SRobert Mustacchi 
369*0d2006e4SRobert Mustacchi 	/*
370*0d2006e4SRobert Mustacchi 	 * Binary Object Store data
371*0d2006e4SRobert Mustacchi 	 */
372*0d2006e4SRobert Mustacchi 	mblk_t			*usb_bos_mp;
373*0d2006e4SRobert Mustacchi 	uint_t			usb_bos_nalloc;
374*0d2006e4SRobert Mustacchi 	uint_t			usb_bos_nents;
375*0d2006e4SRobert Mustacchi 	usb_bos_t		*usb_bos;
3767c478bd9Sstevel@tonic-gate } usba_device_t;
3777c478bd9Sstevel@tonic-gate 
3787c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_SIZE		1
3797c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_ATTACH		0x01
3807c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_EV_CBS		0x02
3817c478bd9Sstevel@tonic-gate #define	USBA_CLIENT_FLAG_DEV_DATA	0x04
3827c478bd9Sstevel@tonic-gate 
3837c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_device))
3847c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usba_device::usb_mutex, usba_evdata))
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3877c478bd9Sstevel@tonic-gate 				usba_evdata::ev_rm_cb_id))
3887c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3897c478bd9Sstevel@tonic-gate 				usba_evdata::ev_ins_cb_id))
3907c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3917c478bd9Sstevel@tonic-gate 				usba_evdata::ev_suspend_cb_id))
3927c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("chg at attach only",
3937c478bd9Sstevel@tonic-gate 				usba_evdata::ev_resume_cb_id))
3947c478bd9Sstevel@tonic-gate 
3957c478bd9Sstevel@tonic-gate /* this should be really stable data */
3967c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_serialno_str))
3977c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_root_hub_dip))
3987c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_root_hubd))
3997c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_product_str))
4007c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_preferred_driver))
4017c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_port))
4027c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_n_ifs))
4037c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_n_cfgs))
4047c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_mfg_str))
4057c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_dev_descr))
4067c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_ph_list))
4077c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_value))
4087c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_str_descr))
4097c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_length))
4107c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array))
4117c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_len))
4127c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_length))
4137c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg_array_len_length))
4147c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_cfg))
4157c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_hcdi_ops))
4167c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_addr))
4177c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_port_status))
4187c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::rm_cookie))
4197c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::ins_cookie))
4207c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::suspend_cookie))
4217c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::resume_cookie))
4227c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_flags))
4237c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_attach_list))
4247c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_client_ev_cb_list))
4257c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usba_device::usb_dip))
4267c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("set at device creation",
4277c478bd9Sstevel@tonic-gate 					usba_device::usb_shared_taskq))
4287c478bd9Sstevel@tonic-gate 
429489b7c4aSRaymond Chen _NOTE(SCHEME_PROTECTS_DATA("local use only",
430489b7c4aSRaymond Chen 				usb_key_descr::bDescriptorType))
431489b7c4aSRaymond Chen _NOTE(SCHEME_PROTECTS_DATA("local use only",
432489b7c4aSRaymond Chen 				usb_key_descr::bLength))
4337c478bd9Sstevel@tonic-gate /*
4347c478bd9Sstevel@tonic-gate  * serialization in drivers
4357c478bd9Sstevel@tonic-gate  */
4367c478bd9Sstevel@tonic-gate typedef struct usba_serialization_impl {
4377c478bd9Sstevel@tonic-gate 	dev_info_t	*s_dip;
4387c478bd9Sstevel@tonic-gate 	kcondvar_t	s_cv;
4397c478bd9Sstevel@tonic-gate 	kmutex_t	s_mutex;
4407c478bd9Sstevel@tonic-gate 	kthread_t	*s_thread;
4417c478bd9Sstevel@tonic-gate 	int		s_count;
4427c478bd9Sstevel@tonic-gate 	uint_t		s_flag;
4437c478bd9Sstevel@tonic-gate } usba_serialization_impl_t;
4447c478bd9Sstevel@tonic-gate 
4457c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared private data",
4467c478bd9Sstevel@tonic-gate 				usba_serialization_impl))
4477c478bd9Sstevel@tonic-gate 
4487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
4497c478bd9Sstevel@tonic-gate }
4507c478bd9Sstevel@tonic-gate #endif
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate #endif	/* _SYS_USB_USBA_USBA_TYPES_H */
453