xref: /illumos-gate/usr/src/uts/common/sys/usb/usba/whcdi.h (revision 489b7c4a)
1ff0e937bSRaymond Chen /*
2ff0e937bSRaymond Chen  * CDDL HEADER START
3ff0e937bSRaymond Chen  *
4ff0e937bSRaymond Chen  * The contents of this file are subject to the terms of the
5ff0e937bSRaymond Chen  * Common Development and Distribution License (the "License").
6ff0e937bSRaymond Chen  * You may not use this file except in compliance with the License.
7ff0e937bSRaymond Chen  *
8ff0e937bSRaymond Chen  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9ff0e937bSRaymond Chen  * or http://www.opensolaris.org/os/licensing.
10ff0e937bSRaymond Chen  * See the License for the specific language governing permissions
11ff0e937bSRaymond Chen  * and limitations under the License.
12ff0e937bSRaymond Chen  *
13ff0e937bSRaymond Chen  * When distributing Covered Code, include this CDDL HEADER in each
14ff0e937bSRaymond Chen  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15ff0e937bSRaymond Chen  * If applicable, add the following below this CDDL HEADER, with the
16ff0e937bSRaymond Chen  * fields enclosed by brackets "[]" replaced with your own identifying
17ff0e937bSRaymond Chen  * information: Portions Copyright [yyyy] [name of copyright owner]
18ff0e937bSRaymond Chen  *
19ff0e937bSRaymond Chen  * CDDL HEADER END
20ff0e937bSRaymond Chen  */
21ff0e937bSRaymond Chen /*
22ff0e937bSRaymond Chen  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23ff0e937bSRaymond Chen  * Use is subject to license terms.
24ff0e937bSRaymond Chen  */
25ff0e937bSRaymond Chen 
26ff0e937bSRaymond Chen #ifndef	_SYS_USB_WHCDI_H
27ff0e937bSRaymond Chen #define	_SYS_USB_WHCDI_H
28ff0e937bSRaymond Chen 
29ff0e937bSRaymond Chen #ifdef	__cplusplus
30ff0e937bSRaymond Chen extern "C" {
31ff0e937bSRaymond Chen #endif
32ff0e937bSRaymond Chen 
33ff0e937bSRaymond Chen #include <sys/usb/usba/usba_types.h>
34ff0e937bSRaymond Chen #include <sys/usb/usba/wusba.h>
35ff0e937bSRaymond Chen #include <sys/usb/usba/wusba_io.h>
36ff0e937bSRaymond Chen #include <sys/usb/usba/wa.h>	/* for wusb_secrt_data_t */
37ff0e937bSRaymond Chen 
38ff0e937bSRaymond Chen 
39ff0e937bSRaymond Chen /*
40ff0e937bSRaymond Chen  * This file contains data structures and functions that might be
41ff0e937bSRaymond Chen  * shared by HWA and WHCI drivers.
42ff0e937bSRaymond Chen  */
43ff0e937bSRaymond Chen 
44ff0e937bSRaymond Chen typedef struct wusb_hc_cc_list {
45ff0e937bSRaymond Chen 	wusb_cc_t		cc;
46ff0e937bSRaymond Chen 	struct wusb_hc_cc_list	*next;
47ff0e937bSRaymond Chen } wusb_hc_cc_list_t;
48ff0e937bSRaymond Chen 
49ff0e937bSRaymond Chen struct wusb_hc_data;
50ff0e937bSRaymond Chen 
51ff0e937bSRaymond Chen typedef struct wusb_dev_info {
52ff0e937bSRaymond Chen 	struct wusb_hc_data	*wdev_hc; /* the HC this device attaches */
53ff0e937bSRaymond Chen 	uint8_t			wdev_cdid[16];
54ff0e937bSRaymond Chen 	uint16_t		wdev_addr;
55ff0e937bSRaymond Chen 	uint16_t		wdev_state;
56ff0e937bSRaymond Chen 	uint8_t			wdev_is_newconn;
57ff0e937bSRaymond Chen 	uint8_t			wdev_beacon_attr;
58ff0e937bSRaymond Chen 	usb_pipe_handle_t	wdev_ph;	/* used before authenticated */
59ff0e937bSRaymond Chen 	wusb_secrt_data_t	wdev_secrt_data;
60ff0e937bSRaymond Chen 	usb_uwb_cap_descr_t	*wdev_uwb_descr;
61ff0e937bSRaymond Chen 	wusb_cc_t		*wdev_cc;
62ff0e937bSRaymond Chen 	uint8_t			wdev_ptk[16];
63ff0e937bSRaymond Chen 	uint8_t			wdev_tkid[3];
64ff0e937bSRaymond Chen 	timeout_id_t		wdev_trust_timer; /* TrustTimeout timer */
65ff0e937bSRaymond Chen 	uint8_t			wdev_active;
66ff0e937bSRaymond Chen } wusb_dev_info_t;
67ff0e937bSRaymond Chen 
68ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_dev_info::wdev_addr))
69ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_dev_info::wdev_uwb_descr))
70ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_dev_info::wdev_hc))
71*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_dev_info::wdev_secrt_data))
72ff0e937bSRaymond Chen 
73ff0e937bSRaymond Chen /*
74ff0e937bSRaymond Chen  * According to WUSB 1.0 spec, WUSB hosts can support up to 127 devices.
75ff0e937bSRaymond Chen  * To comply with USB bus convention that bus address 1 is assigned
76ff0e937bSRaymond Chen  * to the host controller device, the addresses assigned to WUSB devices
77ff0e937bSRaymond Chen  * would start from 2. So the max device number is reduced to 126.
78ff0e937bSRaymond Chen  */
79ff0e937bSRaymond Chen #define	WUSB_MAX_PORTS		126
80ff0e937bSRaymond Chen 
81ff0e937bSRaymond Chen #define	WUSB_CHILD_ZAP		0x1
82ff0e937bSRaymond Chen 
83ff0e937bSRaymond Chen typedef struct wusb_hc_data {
84ff0e937bSRaymond Chen 	dev_info_t		*hc_dip;
85ff0e937bSRaymond Chen 	void			*hc_private_data;
86ff0e937bSRaymond Chen 	uint8_t			hc_chid[16];
87ff0e937bSRaymond Chen 	uint8_t			hc_cluster_id;
88ff0e937bSRaymond Chen 	uint8_t			hc_num_mmcies;
89ff0e937bSRaymond Chen 	kmutex_t		hc_mutex;
90ff0e937bSRaymond Chen 	wusb_ie_header_t	**hc_mmcie_list;
91ff0e937bSRaymond Chen 
92ff0e937bSRaymond Chen 	boolean_t		hc_newcon_enabled;
93ff0e937bSRaymond Chen 
94ff0e937bSRaymond Chen 	/* save the often used IEs so as not to allocate them each time */
95ff0e937bSRaymond Chen 	wusb_ie_keepalive_t		hc_alive_ie;
96ff0e937bSRaymond Chen 
97ff0e937bSRaymond Chen 	/* children info structures */
98ff0e937bSRaymond Chen 	uint8_t			hc_num_ports;
99ff0e937bSRaymond Chen 	wusb_dev_info_t		**hc_dev_infos;
100ff0e937bSRaymond Chen 	dev_info_t		**hc_children_dips;
101ff0e937bSRaymond Chen 	size_t			hc_cd_list_length;
102ff0e937bSRaymond Chen 	usba_device_t		**hc_usba_devices;
103ff0e937bSRaymond Chen 
104ff0e937bSRaymond Chen 	/* for bus unconfig */
105ff0e937bSRaymond Chen 	uint8_t			hc_children_state[WUSB_MAX_PORTS + 1];
106ff0e937bSRaymond Chen 
107ff0e937bSRaymond Chen 	/* child connection functions */
108ff0e937bSRaymond Chen 	void	(*disconnect_dev)(dev_info_t *, usb_port_t);
109ff0e937bSRaymond Chen 	void	(*reconnect_dev)(dev_info_t *, usb_port_t);
110ff0e937bSRaymond Chen 	int	(*create_child)(dev_info_t *, usb_port_t);
111ff0e937bSRaymond Chen 	int	(*destroy_child)(dev_info_t *, usb_port_t);
112ff0e937bSRaymond Chen 
113ff0e937bSRaymond Chen 	/*
114ff0e937bSRaymond Chen 	 * some necessary host functions:
115ff0e937bSRaymond Chen 	 * Both HWA and HCI must implement these entries to support basic
116ff0e937bSRaymond Chen 	 * host controller operations.
117ff0e937bSRaymond Chen 	 */
118ff0e937bSRaymond Chen 	int	(*set_encrypt)(dev_info_t *, usb_port_t, uint8_t);
119ff0e937bSRaymond Chen 	int	(*set_ptk)(dev_info_t *, usb_key_descr_t *, size_t, usb_port_t);
120ff0e937bSRaymond Chen 	int	(*set_gtk)(dev_info_t *, usb_key_descr_t *, size_t);
121ff0e937bSRaymond Chen 	int	(*set_device_info)(dev_info_t *, wusb_dev_info_t *, usb_port_t);
122ff0e937bSRaymond Chen 	int	(*set_cluster_id) (dev_info_t *, uint8_t id);
123ff0e937bSRaymond Chen 	int	(*set_stream_idx) (dev_info_t *, uint8_t idx);
124ff0e937bSRaymond Chen 	int	(*set_wusb_mas)	(dev_info_t *, uint8_t *data);
125ff0e937bSRaymond Chen 	int	(*add_mmc_ie)	(dev_info_t *, uint8_t interval, uint8_t rcnt,
126ff0e937bSRaymond Chen 				uint8_t iehdl, uint16_t len, uint8_t *data);
127ff0e937bSRaymond Chen 	int	(*rem_mmc_ie)	(dev_info_t *, uint8_t iehdl);
128ff0e937bSRaymond Chen 	int	(*stop_ch)	(dev_info_t *, uint32_t time);
129ff0e937bSRaymond Chen 	int	(*set_num_dnts)	(dev_info_t *, uint8_t interval, uint8_t nslot);
130ff0e937bSRaymond Chen 	int	(*get_time)	(dev_info_t *, uint8_t timetype,
131ff0e937bSRaymond Chen 				uint16_t timelen, uint32_t *time);
132ff0e937bSRaymond Chen 
133ff0e937bSRaymond Chen 	/* host addr in MAC layer */
134ff0e937bSRaymond Chen 	uint16_t		hc_addr;
135ff0e937bSRaymond Chen 
136ff0e937bSRaymond Chen 	/* beaconing channel */
137ff0e937bSRaymond Chen 	uint8_t			hc_channel;
138ff0e937bSRaymond Chen 
139ff0e937bSRaymond Chen 	/* reserved MASes. bitmaps */
140ff0e937bSRaymond Chen 	uint8_t			hc_mas[WUSB_SET_WUSB_MAS_LEN];
141ff0e937bSRaymond Chen 
142ff0e937bSRaymond Chen 	/* connection context list for the host */
143ff0e937bSRaymond Chen 	wusb_hc_cc_list_t	*hc_cc_list;
144ff0e937bSRaymond Chen 
145ff0e937bSRaymond Chen 	/* group temporal key */
146ff0e937bSRaymond Chen 	usb_key_descr_t		hc_gtk;
147ff0e937bSRaymond Chen 	uint8_t			hc_gtk_padding[15];
148ff0e937bSRaymond Chen } wusb_hc_data_t;
149ff0e937bSRaymond Chen 
150ff0e937bSRaymond Chen _NOTE(MUTEX_PROTECTS_DATA(wusb_hc_data_t::hc_mutex, wusb_dev_info_t))
151ff0e937bSRaymond Chen _NOTE(MUTEX_PROTECTS_DATA(wusb_hc_data_t::hc_mutex, wusb_hc_data_t))
152ff0e937bSRaymond Chen 
153ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::hc_num_ports))
154*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::hc_num_mmcies))
155ff0e937bSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::hc_dip))
156*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::hc_gtk))
157*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::add_mmc_ie))
158*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::rem_mmc_ie))
159*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_cluster_id))
160*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_encrypt))
161*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_gtk))
162*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_ptk))
163*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_num_dnts))
164*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_stream_idx))
165*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::set_wusb_mas))
166*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::stop_ch))
167*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::create_child))
168*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::destroy_child))
169*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::disconnect_dev))
170*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::reconnect_dev))
171*489b7c4aSRaymond Chen _NOTE(DATA_READABLE_WITHOUT_LOCK(wusb_hc_data_t::get_time))
172*489b7c4aSRaymond Chen 
173*489b7c4aSRaymond Chen _NOTE(SCHEME_PROTECTS_DATA("local use only",
174*489b7c4aSRaymond Chen 				wusb_ie_host_disconnect::bLength))
175*489b7c4aSRaymond Chen _NOTE(SCHEME_PROTECTS_DATA("local use only",
176*489b7c4aSRaymond Chen 				wusb_ie_host_disconnect::bIEIdentifier))
177*489b7c4aSRaymond Chen _NOTE(SCHEME_PROTECTS_DATA("local use only",
178*489b7c4aSRaymond Chen 				wusb_ccm_nonce::sfn))
179ff0e937bSRaymond Chen /*
180ff0e937bSRaymond Chen  * WUSB 1.0 4.3.8.5 says the range of cluster id is in 0x80-0xfe,
181ff0e937bSRaymond Chen  * we limit the maximum WUSB host controller numbers to 31 now,
182ff0e937bSRaymond Chen  * and take the upper portion of this range as the broadcast
183ff0e937bSRaymond Chen  * cluster id
184ff0e937bSRaymond Chen  */
185ff0e937bSRaymond Chen #define	WUSB_CLUSTER_ID_COUNT		31
186ff0e937bSRaymond Chen #define	WUSB_MIN_CLUSTER_ID		0xe0
187ff0e937bSRaymond Chen 
188ff0e937bSRaymond Chen #define	WUSB_TRUST_TIMEOUT	4 /* WUSB 4.15.1 TrustTimeout = 4s */
189ff0e937bSRaymond Chen #define	WUSB_TRUST_TIMEOUT_US	WUSB_TRUST_TIMEOUT * MICROSEC
190ff0e937bSRaymond Chen 
191ff0e937bSRaymond Chen #define	WUSB_PERIODIC_ENDPOINT(endpoint) (((endpoint->bmAttributes & \
192ff0e937bSRaymond Chen 	USB_EP_ATTR_MASK) == USB_EP_ATTR_INTR) ||\
193ff0e937bSRaymond Chen 	((endpoint->bmAttributes &\
194ff0e937bSRaymond Chen 	USB_EP_ATTR_MASK) == USB_EP_ATTR_ISOCH))
195ff0e937bSRaymond Chen 
196ff0e937bSRaymond Chen #define	WUSB_ISOC_ENDPOINT(endpoint) (((endpoint->bmAttributes &\
197ff0e937bSRaymond Chen 	USB_EP_ATTR_MASK) == USB_EP_ATTR_ISOCH))
198ff0e937bSRaymond Chen 
199ff0e937bSRaymond Chen #define	WUSB_INTR_ENDPOINT(endpoint) (((endpoint->bmAttributes &\
200ff0e937bSRaymond Chen 	USB_EP_ATTR_MASK) == USB_EP_ATTR_INTR))
201ff0e937bSRaymond Chen 
202ff0e937bSRaymond Chen /* helper functions */
203ff0e937bSRaymond Chen uint8_t	wusb_hc_get_cluster_id();
204ff0e937bSRaymond Chen void	wusb_hc_free_cluster_id(uint8_t id);
205ff0e937bSRaymond Chen int	wusb_hc_get_iehdl(wusb_hc_data_t *hc_data, wusb_ie_header_t *hdr,
206ff0e937bSRaymond Chen 	uint8_t *iehdl);
207ff0e937bSRaymond Chen void	wusb_hc_free_iehdl(wusb_hc_data_t *hc_data, uint8_t iehdl);
208ff0e937bSRaymond Chen 
209ff0e937bSRaymond Chen uint_t	wusb_hc_is_dev_connected(wusb_hc_data_t *hc_data, uint8_t *cdid,
210ff0e937bSRaymond Chen 	usb_port_t *port);
211ff0e937bSRaymond Chen uint_t	wusb_hc_is_addr_valid(wusb_hc_data_t *hc_data, uint8_t addr,
212ff0e937bSRaymond Chen 	usb_port_t *port);
213ff0e937bSRaymond Chen usb_port_t	wusb_hc_get_free_port(wusb_hc_data_t *hc_data);
214ff0e937bSRaymond Chen 
215ff0e937bSRaymond Chen /* device notification support */
216ff0e937bSRaymond Chen int	wusb_hc_ack_conn(wusb_hc_data_t *hc_data, usb_port_t port);
217ff0e937bSRaymond Chen int	wusb_hc_ack_disconn(wusb_hc_data_t *hc_data, uint8_t addr);
218ff0e937bSRaymond Chen void	wusb_hc_rm_ack(wusb_hc_data_t *hc_data);
219ff0e937bSRaymond Chen int	wusb_hc_send_keepalive_ie(wusb_hc_data_t *hc_data, uint8_t addr);
220ff0e937bSRaymond Chen int	wusb_hc_auth_dev(wusb_hc_data_t *hc_data, usb_port_t port,
221ff0e937bSRaymond Chen 	usb_pipe_handle_t ph, uint8_t ifc, wusb_secrt_data_t *secrt_data);
222ff0e937bSRaymond Chen int	wusb_hc_handle_port_connect(wusb_hc_data_t *hc_data, usb_port_t port,
223ff0e937bSRaymond Chen 	usb_pipe_handle_t ph, uint8_t ifc, wusb_secrt_data_t *secrt_data);
224ff0e937bSRaymond Chen void	wusb_hc_handle_dn_connect(wusb_hc_data_t *hc_data,
225ff0e937bSRaymond Chen 	usb_pipe_handle_t ph, uint8_t ifc, uint8_t *data, size_t len,
226ff0e937bSRaymond Chen 	wusb_secrt_data_t *secrt_data);
227ff0e937bSRaymond Chen void	wusb_hc_handle_dn_disconnect(wusb_hc_data_t *hc_data, uint8_t addr,
228ff0e937bSRaymond Chen 	uint8_t *data, size_t len);
229ff0e937bSRaymond Chen 
230ff0e937bSRaymond Chen /* wusb common device function */
231ff0e937bSRaymond Chen int	wusb_create_child_devi(dev_info_t *dip, char *node_name,
232ff0e937bSRaymond Chen 	usba_hcdi_ops_t *usba_hcdi_ops, dev_info_t *usb_root_hub_dip,
233ff0e937bSRaymond Chen 	usb_port_status_t port_status, usba_device_t *usba_device,
234ff0e937bSRaymond Chen 	dev_info_t **child_dip);
235ff0e937bSRaymond Chen int	wusb_get_dev_security_descr(usb_pipe_handle_t ph,
236ff0e937bSRaymond Chen 	wusb_secrt_data_t *secrt_data);
237ff0e937bSRaymond Chen int	wusb_get_bos_cloud(dev_info_t *child_dip, usba_device_t *child_ud);
238ff0e937bSRaymond Chen int	wusb_get_rc_dev_by_hc(dev_info_t *dip, dev_t *dev);
239ff0e937bSRaymond Chen 
240ff0e937bSRaymond Chen int16_t	wusb_get_ccm_encryption_value(wusb_secrt_data_t *secrt_data);
241ff0e937bSRaymond Chen 
242ff0e937bSRaymond Chen /* device dynamical configuration functions */
243ff0e937bSRaymond Chen void	wusb_hc_disconnect_dev(wusb_hc_data_t *hc_data, usb_port_t port);
244ff0e937bSRaymond Chen void	wusb_hc_reconnect_dev(wusb_hc_data_t *hc_data, usb_port_t port);
245ff0e937bSRaymond Chen int	wusb_hc_create_child(wusb_hc_data_t *hc_data, usb_port_t port);
246ff0e937bSRaymond Chen int	wusb_hc_destroy_child(wusb_hc_data_t *hc_data, usb_port_t port);
247ff0e937bSRaymond Chen 
248ff0e937bSRaymond Chen /* WUSB HC common requests */
249ff0e937bSRaymond Chen int	wusb_hc_set_cluster_id(wusb_hc_data_t *hc_data, uint8_t cluster_id);
250ff0e937bSRaymond Chen 
251ff0e937bSRaymond Chen int	wusb_hc_set_stream_idx(wusb_hc_data_t *hc_data, uint8_t stream_idx);
252ff0e937bSRaymond Chen 
253ff0e937bSRaymond Chen int	wusb_hc_set_wusb_mas(wusb_hc_data_t *hc_data, uint8_t *data);
254ff0e937bSRaymond Chen 
255ff0e937bSRaymond Chen int	wusb_hc_add_mmc_ie(wusb_hc_data_t *hc_data, uint8_t interval,
256ff0e937bSRaymond Chen 	uint8_t rcnt, uint8_t iehdl, uint16_t len, uint8_t *data);
257ff0e937bSRaymond Chen 
258ff0e937bSRaymond Chen int	wusb_hc_remove_mmc_ie(wusb_hc_data_t *hc_data, uint8_t iehdl);
259ff0e937bSRaymond Chen void	wusb_hc_rem_ie(wusb_hc_data_t *hc_data, wusb_ie_header_t *ieh);
260ff0e937bSRaymond Chen 
261ff0e937bSRaymond Chen int	wusb_hc_stop_ch(wusb_hc_data_t *hc_data, uint32_t timeoff);
262ff0e937bSRaymond Chen 
263ff0e937bSRaymond Chen int	wusb_hc_set_num_dnts(wusb_hc_data_t *hc_data, uint8_t interval,
264ff0e937bSRaymond Chen 	uint8_t nslots);
265ff0e937bSRaymond Chen 
266ff0e937bSRaymond Chen int	wusb_hc_get_time(wusb_hc_data_t *hc_data, uint8_t time_type,
267ff0e937bSRaymond Chen 	uint16_t len, uint32_t *time);
268ff0e937bSRaymond Chen 
269ff0e937bSRaymond Chen int	wusb_hc_add_host_info(wusb_hc_data_t *hc_data, uint8_t stream_idx);
270ff0e937bSRaymond Chen 
271ff0e937bSRaymond Chen void	wusb_hc_rem_host_info(wusb_hc_data_t *hc_data);
272ff0e937bSRaymond Chen 
273ff0e937bSRaymond Chen int	wusb_hc_send_host_disconnect(wusb_hc_data_t *hc_data);
274ff0e937bSRaymond Chen 
275ff0e937bSRaymond Chen int	wusb_hc_set_device_info(wusb_hc_data_t *hc_data, usb_port_t port);
276ff0e937bSRaymond Chen 
277ff0e937bSRaymond Chen /* WUSB HC connection context list operations */
278ff0e937bSRaymond Chen void	wusb_hc_add_cc(wusb_hc_cc_list_t **cc_list, wusb_hc_cc_list_t *new_cc);
279ff0e937bSRaymond Chen void	wusb_hc_rem_cc(wusb_hc_cc_list_t **cc_list, wusb_cc_t *old_cc);
280ff0e937bSRaymond Chen void	wusb_hc_free_cc_list(wusb_hc_cc_list_t *cc_list);
281ff0e937bSRaymond Chen wusb_cc_t *wusb_hc_cc_matched(wusb_hc_cc_list_t *cc_list, uint8_t *cdid);
282ff0e937bSRaymond Chen 
283ff0e937bSRaymond Chen /* security functions */
284ff0e937bSRaymond Chen int	wusb_dev_set_encrypt(usb_pipe_handle_t ph, uint8_t value);
285*489b7c4aSRaymond Chen int	wusb_enable_dev_encrypt(wusb_hc_data_t *hc, wusb_dev_info_t *dev_info);
286ff0e937bSRaymond Chen int	wusb_dev_set_key(usb_pipe_handle_t ph, uint8_t key_index,
287ff0e937bSRaymond Chen 	usb_key_descr_t *key, size_t klen);
288ff0e937bSRaymond Chen int	wusb_hc_set_encrypt(wusb_hc_data_t *hc_data, usb_port_t port,
289ff0e937bSRaymond Chen 	uint8_t type);
290ff0e937bSRaymond Chen int	wusb_hc_set_ptk(wusb_hc_data_t *hc_data, uint8_t *key_data,
291ff0e937bSRaymond Chen 	usb_port_t port);
292ff0e937bSRaymond Chen int	wusb_hc_set_gtk(wusb_hc_data_t *hc_data, uint8_t *key_data,
293ff0e937bSRaymond Chen 	uint8_t *tkid);
294ff0e937bSRaymond Chen 
295ff0e937bSRaymond Chen /* crypto functions */
296ff0e937bSRaymond Chen int	PRF(const uchar_t *key, size_t klen, wusb_ccm_nonce_t *nonce,
297ff0e937bSRaymond Chen 	const uchar_t *adata, size_t alen,
298ff0e937bSRaymond Chen 	const uchar_t *bdata, size_t blen,
299ff0e937bSRaymond Chen 	uchar_t *out, size_t bitlen);
300ff0e937bSRaymond Chen 
301ff0e937bSRaymond Chen #define	PRF_64(key, klen, nonce, adata, alen, bdata, blen, out)	\
302ff0e937bSRaymond Chen 	PRF(key, klen, nonce, adata, alen, bdata, blen, out, 64)
303ff0e937bSRaymond Chen 
304ff0e937bSRaymond Chen #define	PRF_128(key, klen, nonce, adata, alen, bdata, blen, out)	\
305ff0e937bSRaymond Chen 	PRF(key, klen, nonce, adata, alen, bdata, blen, out, 128)
306ff0e937bSRaymond Chen 
307ff0e937bSRaymond Chen #define	PRF_256(key, klen, nonce, adata, alen, bdata, blen, out)	\
308ff0e937bSRaymond Chen 	PRF(key, klen, nonce, adata, alen, bdata, blen, out, 256)
309ff0e937bSRaymond Chen 
310ff0e937bSRaymond Chen int	wusb_gen_random_nonce(wusb_hc_data_t *hc_data,
311ff0e937bSRaymond Chen 	wusb_dev_info_t *dev_info, uchar_t *rbuf);
312ff0e937bSRaymond Chen 
313ff0e937bSRaymond Chen int	wusb_4way_handshake(wusb_hc_data_t *hc_data, usb_port_t port,
314ff0e937bSRaymond Chen 	usb_pipe_handle_t ph, uint8_t ifc);
315ff0e937bSRaymond Chen 
316ff0e937bSRaymond Chen #ifdef __cplusplus
317ff0e937bSRaymond Chen }
318ff0e937bSRaymond Chen #endif
319ff0e937bSRaymond Chen 
320ff0e937bSRaymond Chen #endif	/* _SYS_USB_WHCDI_H */
321