xref: /illumos-gate/usr/src/uts/common/sys/usb/usba/hcdi.h (revision 993e3faf)
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
528cdc3d7Sszhou  * Common Development and Distribution License (the "License").
628cdc3d7Sszhou  * 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  */
217c478bd9Sstevel@tonic-gate /*
22269552cdSguoqing zhu - Sun Microsystems - Beijing China  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
24*993e3fafSRobert Mustacchi  *
25*993e3fafSRobert Mustacchi  * Copyright 2016 Joyent, Inc.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_USB_HCDI_H
297c478bd9Sstevel@tonic-gate #define	_SYS_USB_HCDI_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
337c478bd9Sstevel@tonic-gate extern "C" {
347c478bd9Sstevel@tonic-gate #endif
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #include <sys/usb/usba/genconsole.h>
377c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_types.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * HCD ops structure
417c478bd9Sstevel@tonic-gate  *
427c478bd9Sstevel@tonic-gate  * - this structure defines all entry points into HCD
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * - all client driver USBAI functions that require HCD
457c478bd9Sstevel@tonic-gate  *   involvement go through this ops table
467c478bd9Sstevel@tonic-gate  *
477c478bd9Sstevel@tonic-gate  * - at HCD attach time, the HCD ops are passed to
487c478bd9Sstevel@tonic-gate  *   to the USBA through usba_hcdi_attach()
497c478bd9Sstevel@tonic-gate  *
507c478bd9Sstevel@tonic-gate  * some of these ops implement the semantics of the corresponding
517c478bd9Sstevel@tonic-gate  * USBAI interfaces. Refer to usbai.h for detailed description
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate #define	HCDI_OPS_VERSION_0 0
5428cdc3d7Sszhou #define	HCDI_OPS_VERSION_1 1
55*993e3fafSRobert Mustacchi #define	HCDI_OPS_VERSION_2 2
56*993e3fafSRobert Mustacchi #define	HCDI_OPS_VERSION	HCDI_OPS_VERSION_2
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate typedef struct usba_hcdi_ops {
597c478bd9Sstevel@tonic-gate 	int	usba_hcdi_ops_version;	/* implementation version */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate 	dev_info_t	*usba_hcdi_dip;	/* HCD's devinfo ptr */
627c478bd9Sstevel@tonic-gate 
634610e4a0Sfrits 	/* can this hcd support pm? */
644610e4a0Sfrits 	int	(*usba_hcdi_pm_support)(dev_info_t *dip);
654610e4a0Sfrits 
667c478bd9Sstevel@tonic-gate 	/*
677c478bd9Sstevel@tonic-gate 	 * usba_hcdi_pipe_open:
687c478bd9Sstevel@tonic-gate 	 *	implements the semantics of usb_pipe_open()
697c478bd9Sstevel@tonic-gate 	 *	USBA allocate the pipe_handle which contains
707c478bd9Sstevel@tonic-gate 	 *	pipe_policy and endpoint pointers
717c478bd9Sstevel@tonic-gate 	 */
727c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_open)(
737c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
747c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate 	/*
777c478bd9Sstevel@tonic-gate 	 * close a pipe
787c478bd9Sstevel@tonic-gate 	 */
797c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_close)(
807c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
817c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	/*
847c478bd9Sstevel@tonic-gate 	 * pipe management
857c478bd9Sstevel@tonic-gate 	 */
867c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_reset)(
877c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
887c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
897c478bd9Sstevel@tonic-gate 
90269552cdSguoqing zhu - Sun Microsystems - Beijing China 	/*
91269552cdSguoqing zhu - Sun Microsystems - Beijing China 	 * pipe management
92269552cdSguoqing zhu - Sun Microsystems - Beijing China 	 */
93269552cdSguoqing zhu - Sun Microsystems - Beijing China 	void	(*usba_hcdi_pipe_reset_data_toggle)(
94269552cdSguoqing zhu - Sun Microsystems - Beijing China 		usba_pipe_handle_data_t	*pipe_handle);
95269552cdSguoqing zhu - Sun Microsystems - Beijing China 
967c478bd9Sstevel@tonic-gate 	/*
977c478bd9Sstevel@tonic-gate 	 * data transfer management
987c478bd9Sstevel@tonic-gate 	 */
997c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_ctrl_xfer)(
1007c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
1017c478bd9Sstevel@tonic-gate 		usb_ctrl_req_t		*usb_ctrl_req,
1027c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	/*
1057c478bd9Sstevel@tonic-gate 	 * get HCD limitation on bulk xfer at a time?
1067c478bd9Sstevel@tonic-gate 	 */
1077c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_bulk_transfer_size)(
1087c478bd9Sstevel@tonic-gate 		usba_device_t		*usba_device,
1097c478bd9Sstevel@tonic-gate 		size_t			*size);
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate 	/*
1127c478bd9Sstevel@tonic-gate 	 * do bulk read/write
1137c478bd9Sstevel@tonic-gate 	 */
1147c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_bulk_xfer)(
1157c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
1167c478bd9Sstevel@tonic-gate 		usb_bulk_req_t		*usb_bulk_req,
1177c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 	/*
1207c478bd9Sstevel@tonic-gate 	 * do interrupt pipe read/write
1217c478bd9Sstevel@tonic-gate 	 */
1227c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_intr_xfer)(
1237c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
1247c478bd9Sstevel@tonic-gate 		usb_intr_req_t		*usb_intr_req,
1257c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate 	/*
1287c478bd9Sstevel@tonic-gate 	 * stop interrupt pipe polling
1297c478bd9Sstevel@tonic-gate 	 */
1307c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_stop_intr_polling)(
1317c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
1327c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate 	/*
1357c478bd9Sstevel@tonic-gate 	 * do isoch pipe read/write
1367c478bd9Sstevel@tonic-gate 	 */
1377c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_isoc_xfer)(
1387c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
1397c478bd9Sstevel@tonic-gate 		usb_isoc_req_t		*usb_isoc_req,
1407c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate 	/*
1437c478bd9Sstevel@tonic-gate 	 * stop isoc pipe polling
1447c478bd9Sstevel@tonic-gate 	 */
1457c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_pipe_stop_isoc_polling)(
1467c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t	*pipe_handle,
1477c478bd9Sstevel@tonic-gate 		usb_flags_t		usb_flags);
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate 	/* utility isoc functions */
150fffe0b30Sqz 	int	(*usba_hcdi_get_current_frame_number)(
151fffe0b30Sqz 		usba_device_t		*usba_device,
152fffe0b30Sqz 		usb_frame_number_t	*frame_number);
1537c478bd9Sstevel@tonic-gate 
154fffe0b30Sqz 	int	(*usba_hcdi_get_max_isoc_pkts)(
155fffe0b30Sqz 		usba_device_t		*usba_device,
156fffe0b30Sqz 		uint_t			*max_isoc_pkts_per_request);
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate 	/*
1597c478bd9Sstevel@tonic-gate 	 * Initialize OBP support for input
1607c478bd9Sstevel@tonic-gate 	 */
1617c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_console_input_init)(
1627c478bd9Sstevel@tonic-gate 		usba_pipe_handle_data_t		*pipe_handle,
1637c478bd9Sstevel@tonic-gate 		uchar_t				**obp_buf,
1647c478bd9Sstevel@tonic-gate 		usb_console_info_impl_t		*console_input_info);
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate 	/*
1677c478bd9Sstevel@tonic-gate 	 * Free resources allocated by usba_hcdi_console_input_init
1687c478bd9Sstevel@tonic-gate 	 */
1697c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_console_input_fini)(
1707c478bd9Sstevel@tonic-gate 		usb_console_info_impl_t		*console_input_info);
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate 	/*
1737c478bd9Sstevel@tonic-gate 	 * Save controller state information
1747c478bd9Sstevel@tonic-gate 	 */
1757c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_console_input_enter)(
1767c478bd9Sstevel@tonic-gate 		usb_console_info_impl_t		*console_input_info);
1777c478bd9Sstevel@tonic-gate 
1787c478bd9Sstevel@tonic-gate 	/*
1797c478bd9Sstevel@tonic-gate 	 * Read character from controller
1807c478bd9Sstevel@tonic-gate 	 */
1817c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_console_read)(
1827c478bd9Sstevel@tonic-gate 		usb_console_info_impl_t		*console_input_info,
1837c478bd9Sstevel@tonic-gate 		uint_t				*num_characters);
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 	/*
1867c478bd9Sstevel@tonic-gate 	 * Restore controller state information
1877c478bd9Sstevel@tonic-gate 	 */
1887c478bd9Sstevel@tonic-gate 	int	(*usba_hcdi_console_input_exit)(
1897c478bd9Sstevel@tonic-gate 		usb_console_info_impl_t		*console_input_info);
19028cdc3d7Sszhou 
19128cdc3d7Sszhou 
19228cdc3d7Sszhou 	/*
19328cdc3d7Sszhou 	 * VERSION 1 ops: support for polled output
19428cdc3d7Sszhou 	 */
19528cdc3d7Sszhou 	int	(*usba_hcdi_console_output_init)(
19628cdc3d7Sszhou 		usba_pipe_handle_data_t		*pipe_handle,
19728cdc3d7Sszhou 		usb_console_info_impl_t		*console_output_info);
19828cdc3d7Sszhou 
19928cdc3d7Sszhou 	int	(*usba_hcdi_console_output_fini)(
20028cdc3d7Sszhou 		usb_console_info_impl_t		*console_output_info);
20128cdc3d7Sszhou 
20228cdc3d7Sszhou 	int	(*usba_hcdi_console_output_enter)(
20328cdc3d7Sszhou 		usb_console_info_impl_t		*console_output_info);
20428cdc3d7Sszhou 
20528cdc3d7Sszhou 	int	(*usba_hcdi_console_write)(
20628cdc3d7Sszhou 		usb_console_info_impl_t		*console_output_info,
20728cdc3d7Sszhou 		uchar_t				*buf,
20828cdc3d7Sszhou 		uint_t				num_characters,
20928cdc3d7Sszhou 		uint_t				*num_characters_written);
21028cdc3d7Sszhou 
21128cdc3d7Sszhou 	int	(*usba_hcdi_console_output_exit)(
21228cdc3d7Sszhou 		usb_console_info_impl_t		*console_output_info);
213*993e3fafSRobert Mustacchi 
214*993e3fafSRobert Mustacchi 	/*
215*993e3fafSRobert Mustacchi 	 * VERSION 2 ops: support for device initialization
216*993e3fafSRobert Mustacchi 	 */
217*993e3fafSRobert Mustacchi 	int	(*usba_hcdi_device_init)(
218*993e3fafSRobert Mustacchi 		usba_device_t			*usba_device,
219*993e3fafSRobert Mustacchi 		usb_port_t			port,
220*993e3fafSRobert Mustacchi 		void				**);
221*993e3fafSRobert Mustacchi 
222*993e3fafSRobert Mustacchi 	void	(*usba_hcdi_device_fini)(
223*993e3fafSRobert Mustacchi 		usba_device_t			*usba_device,
224*993e3fafSRobert Mustacchi 		void				*);
225*993e3fafSRobert Mustacchi 
226*993e3fafSRobert Mustacchi 	int	(*usba_hcdi_device_address)(
227*993e3fafSRobert Mustacchi 		usba_device_t			*usba_device);
228*993e3fafSRobert Mustacchi 
229*993e3fafSRobert Mustacchi 	int	(*usba_hcdi_hub_update)(
230*993e3fafSRobert Mustacchi 		usba_device_t			*usba_device,
231*993e3fafSRobert Mustacchi 		uint8_t				nports,
232*993e3fafSRobert Mustacchi 		uint8_t				think_time);
2337c478bd9Sstevel@tonic-gate } usba_hcdi_ops_t;
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate 
2367c478bd9Sstevel@tonic-gate /*
2377c478bd9Sstevel@tonic-gate  * callback support:
2387c478bd9Sstevel@tonic-gate  *	this function handles all HCD callbacks as follows:
2397c478bd9Sstevel@tonic-gate  *	- USB_FLAGS_SLEEP determines whether the client driver made
2407c478bd9Sstevel@tonic-gate  *	  a synchronous or asynchronous USBAI call
2417c478bd9Sstevel@tonic-gate  *	- for synchronous calls, the args are copied into the pipe handle
2427c478bd9Sstevel@tonic-gate  *		and the sync cv of the pipe handle is signalled
2437c478bd9Sstevel@tonic-gate  *	- for async calls and completion_reason = 0, the normal callback
2447c478bd9Sstevel@tonic-gate  *		is invoked
2457c478bd9Sstevel@tonic-gate  *	- for async calls and completion_reason != 0, the exception
2467c478bd9Sstevel@tonic-gate  *		callback is invoked
2477c478bd9Sstevel@tonic-gate  */
2487c478bd9Sstevel@tonic-gate void
2497c478bd9Sstevel@tonic-gate usba_hcdi_cb(usba_pipe_handle_data_t	*ph,
250*993e3fafSRobert Mustacchi     usb_opaque_t		req,
251*993e3fafSRobert Mustacchi     usb_cr_t		completion_reason);
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate /*
2547c478bd9Sstevel@tonic-gate  * function to duplicate a interrupt/isoc request (for HCD)
2557c478bd9Sstevel@tonic-gate  */
2567c478bd9Sstevel@tonic-gate usb_intr_req_t	*usba_hcdi_dup_intr_req(dev_info_t *,
2577c478bd9Sstevel@tonic-gate 			usb_intr_req_t *, size_t, usb_flags_t);
2587c478bd9Sstevel@tonic-gate usb_isoc_req_t	*usba_hcdi_dup_isoc_req(dev_info_t *,
2597c478bd9Sstevel@tonic-gate 			usb_isoc_req_t *, usb_flags_t);
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate /* access to private member of requests */
2627c478bd9Sstevel@tonic-gate usb_opaque_t	usba_hcdi_get_req_private(usb_opaque_t);
2637c478bd9Sstevel@tonic-gate void		usba_hcdi_set_req_private(usb_opaque_t, usb_opaque_t);
2647c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *
2657c478bd9Sstevel@tonic-gate 		usba_hcdi_get_ph_data(usba_device_t *, uint8_t);
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /* data toggle get and set */
2687c478bd9Sstevel@tonic-gate uchar_t		usba_hcdi_get_data_toggle(usba_device_t *, uint8_t);
2697c478bd9Sstevel@tonic-gate void 		usba_hcdi_set_data_toggle(usba_device_t *, uint8_t, uchar_t);
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate /*
2727c478bd9Sstevel@tonic-gate  * HCD Nexus driver support:
2737c478bd9Sstevel@tonic-gate  */
2747c478bd9Sstevel@tonic-gate 
2757c478bd9Sstevel@tonic-gate /*
2767c478bd9Sstevel@tonic-gate  * hcd_ops allocator/deallocator
2777c478bd9Sstevel@tonic-gate  *	USBA allocates the usba_hcdi_ops so we can easily handle
2787c478bd9Sstevel@tonic-gate  *	versioning
2797c478bd9Sstevel@tonic-gate  */
2807c478bd9Sstevel@tonic-gate usba_hcdi_ops_t	*usba_alloc_hcdi_ops();
2817c478bd9Sstevel@tonic-gate void		usba_free_hcdi_ops(usba_hcdi_ops_t *);
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate /*
2847c478bd9Sstevel@tonic-gate  * Argument structure for usba_hcdi_register
2857c478bd9Sstevel@tonic-gate  */
2867c478bd9Sstevel@tonic-gate typedef struct usba_hcdi_register_args {
2877c478bd9Sstevel@tonic-gate 	uint_t			usba_hcdi_register_version;
2887c478bd9Sstevel@tonic-gate 	dev_info_t		*usba_hcdi_register_dip;
2897c478bd9Sstevel@tonic-gate 	usba_hcdi_ops_t		*usba_hcdi_register_ops;
2907c478bd9Sstevel@tonic-gate 	ddi_dma_attr_t		*usba_hcdi_register_dma_attr;
2917c478bd9Sstevel@tonic-gate 	ddi_iblock_cookie_t	usba_hcdi_register_iblock_cookie;
2927c478bd9Sstevel@tonic-gate } usba_hcdi_register_args_t;
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate #define	HCDI_REGISTER_VERS_0		0
2957c478bd9Sstevel@tonic-gate #define	HCDI_REGISTER_VERSION		HCDI_REGISTER_VERS_0
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 
2987c478bd9Sstevel@tonic-gate /*
2997c478bd9Sstevel@tonic-gate  * make	this instance known to USBA
3007c478bd9Sstevel@tonic-gate  *
3017c478bd9Sstevel@tonic-gate  * the HCD must initialize the hcdi_ops before calling this function
3027c478bd9Sstevel@tonic-gate  */
3037c478bd9Sstevel@tonic-gate int	usba_hcdi_register(usba_hcdi_register_args_t *, uint_t);
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate /*
3067c478bd9Sstevel@tonic-gate  * detach support
3077c478bd9Sstevel@tonic-gate  */
3087c478bd9Sstevel@tonic-gate void	usba_hcdi_unregister(dev_info_t *);
3097c478bd9Sstevel@tonic-gate 
310*993e3fafSRobert Mustacchi /*
311*993e3fafSRobert Mustacchi  * HCD device private storage
312*993e3fafSRobert Mustacchi  */
313*993e3fafSRobert Mustacchi void	*usba_hcdi_get_device_private(usba_device_t *);
314*993e3fafSRobert Mustacchi 
3157c478bd9Sstevel@tonic-gate /*
3167c478bd9Sstevel@tonic-gate  * Hotplug kstats named structure
3177c478bd9Sstevel@tonic-gate  *
3187c478bd9Sstevel@tonic-gate  * Number of types of USB transfers
3197c478bd9Sstevel@tonic-gate  */
3207c478bd9Sstevel@tonic-gate #define	USB_N_COUNT_KSTATS	4
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate typedef struct hcdi_hotplug_stats {
3237c478bd9Sstevel@tonic-gate 	struct kstat_named	hcdi_hotplug_total_success;
3247c478bd9Sstevel@tonic-gate 	struct kstat_named	hcdi_hotplug_success;
3257c478bd9Sstevel@tonic-gate 	struct kstat_named	hcdi_hotplug_total_failure;
3267c478bd9Sstevel@tonic-gate 	struct kstat_named	hcdi_hotplug_failure;
3277c478bd9Sstevel@tonic-gate 	struct kstat_named	hcdi_device_count;
3287c478bd9Sstevel@tonic-gate } hcdi_hotplug_stats_t;
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate /*
3317c478bd9Sstevel@tonic-gate  * USB error kstats named structure
3327c478bd9Sstevel@tonic-gate  */
3337c478bd9Sstevel@tonic-gate typedef struct hcdi_error_stats {
3347c478bd9Sstevel@tonic-gate 	/* transport completion codes */
3357c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_crc;
3367c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_bitstuffing;
3377c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_data_toggle_mm;
3387c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_stall;
3397c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_dev_not_resp;
3407c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_pid_checkfailure;
3417c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_unexp_pid;
3427c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_data_overrun;
3437c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_data_underrun;
3447c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_buffer_overrun;
3457c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_buffer_underrun;
3467c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_timeout;
3477c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_not_accessed;
3487c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_no_resources;
3497c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_unspecified_err;
3507c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_stopped_polling;
3517c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_pipe_closing;
3527c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_pipe_reset;
3537c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_not_supported;
3547c478bd9Sstevel@tonic-gate 	struct kstat_named	cc_flushed;
3557c478bd9Sstevel@tonic-gate } hcdi_error_stats_t;
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate /*
3587c478bd9Sstevel@tonic-gate  * hcdi kstat defines
3597c478bd9Sstevel@tonic-gate  * XXX this needs to be a function
3607c478bd9Sstevel@tonic-gate  */
3617c478bd9Sstevel@tonic-gate #define	HCDI_HOTPLUG_STATS(hcdi)	((hcdi)->hcdi_hotplug_stats)
3627c478bd9Sstevel@tonic-gate #define	HCDI_HOTPLUG_STATS_DATA(hcdi)	\
3637c478bd9Sstevel@tonic-gate 	((hcdi_hotplug_stats_t *)HCDI_HOTPLUG_STATS((hcdi))->ks_data)
3647c478bd9Sstevel@tonic-gate 
3657c478bd9Sstevel@tonic-gate #define	HCDI_ERROR_STATS(hcdi)		((hcdi)->hcdi_error_stats)
3667c478bd9Sstevel@tonic-gate #define	HCDI_ERROR_STATS_DATA(hcdi)	\
3677c478bd9Sstevel@tonic-gate 	((hcdi_error_stats_t *)HCDI_ERROR_STATS((hcdi))->ks_data)
3687c478bd9Sstevel@tonic-gate 
3697c478bd9Sstevel@tonic-gate 
370*993e3fafSRobert Mustacchi /*
371*993e3fafSRobert Mustacchi  * The default timeout that should occur for non-periodic transfers if a timeout
372*993e3fafSRobert Mustacchi  * is not requested by a client driver. This is a time in seconds.
373*993e3fafSRobert Mustacchi  */
374*993e3fafSRobert Mustacchi #define	HCDI_DEFAULT_TIMEOUT	5
375*993e3fafSRobert Mustacchi 
3767c478bd9Sstevel@tonic-gate #ifdef __cplusplus
3777c478bd9Sstevel@tonic-gate }
3787c478bd9Sstevel@tonic-gate #endif
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate #endif	/* _SYS_USB_HCDI_H */
381