• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Dongle BUS interface Abstraction layer
4  *   target serial buses like USB, SDIO, SPI, etc.
5  *
6  * Copyright (C) 1999-2019, Broadcom.
7  *
8  *      Unless you and Broadcom execute a separate written software license
9  * agreement governing use of this software, this software is licensed to you
10  * under the terms of the GNU General Public License version 2 (the "GPL"),
11  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
12  * following added to such license:
13  *
14  *      As a special exception, the copyright holders of this software give you
15  * permission to link this software with independent modules, and to copy and
16  * distribute the resulting executable under terms of your choice, provided that
17  * you also meet, for each linked independent module, the terms and conditions of
18  * the license of that module.  An independent module is a module which is not
19  * derived from this software.  The special exception does not apply to any
20  * modifications of the software.
21  *
22  *      Notwithstanding the above, under no circumstances may you combine this
23  * software in any way with any other Broadcom software provided under a license
24  * other than the GPL, without Broadcom's express prior written consent.
25  *
26  *
27  * <<Broadcom-WL-IPTag/Open:>>
28  *
29  * $Id: dbus.h 686618 2017-02-23 07:20:43Z $
30  */
31 
32 #ifndef __DBUS_H__
33 #define __DBUS_H__
34 
35 #include "typedefs.h"
36 #include <dhd_linux.h>
37 
38 extern uint dbus_msglevel;
39 #define DBUS_ERROR_VAL	0x0001
40 #define DBUS_TRACE_VAL	0x0002
41 #define DBUS_INFO_VAL	0x0004
42 
43 #if defined(DHD_DEBUG)
44 #define DBUSERR(args)		do {if (dbus_msglevel & DBUS_ERROR_VAL) printf args;} while (0)
45 #define DBUSTRACE(args)		do {if (dbus_msglevel & DBUS_TRACE_VAL) printf args;} while (0)
46 #define DBUSINFO(args)		do {if (dbus_msglevel & DBUS_INFO_VAL) printf args;} while (0)
47 #else /* defined(DHD_DEBUG) */
48 #define DBUSERR(args)
49 #define DBUSTRACE(args)
50 #define DBUSINFO(args)
51 #endif
52 
53 enum {
54 	DBUS_OK = 0,
55 	DBUS_ERR = -200,
56 	DBUS_ERR_TIMEOUT,
57 	DBUS_ERR_DISCONNECT,
58 	DBUS_ERR_NODEVICE,
59 	DBUS_ERR_UNSUPPORTED,
60 	DBUS_ERR_PENDING,
61 	DBUS_ERR_NOMEM,
62 	DBUS_ERR_TXFAIL,
63 	DBUS_ERR_TXTIMEOUT,
64 	DBUS_ERR_TXDROP,
65 	DBUS_ERR_RXFAIL,
66 	DBUS_ERR_RXDROP,
67 	DBUS_ERR_TXCTLFAIL,
68 	DBUS_ERR_RXCTLFAIL,
69 	DBUS_ERR_REG_PARAM,
70 	DBUS_STATUS_CANCELLED,
71 	DBUS_ERR_NVRAM,
72 	DBUS_JUMBO_NOMATCH,
73 	DBUS_JUMBO_BAD_FORMAT,
74 	DBUS_NVRAM_NONTXT,
75 	DBUS_ERR_RXZLP
76 };
77 
78 #define BCM_OTP_SIZE_43236  84	/* number of 16 bit values */
79 #define BCM_OTP_SW_RGN_43236	24  /* start offset of SW config region */
80 #define BCM_OTP_ADDR_43236 0x18000800 /* address of otp base */
81 
82 #define ERR_CBMASK_TXFAIL		0x00000001
83 #define ERR_CBMASK_RXFAIL		0x00000002
84 #define ERR_CBMASK_ALL			0xFFFFFFFF
85 
86 #define DBUS_CBCTL_WRITE			0
87 #define DBUS_CBCTL_READ				1
88 #if defined(INTR_EP_ENABLE)
89 #define DBUS_CBINTR_POLL			2
90 #endif /* defined(INTR_EP_ENABLE) */
91 
92 #define DBUS_TX_RETRY_LIMIT		3		/* retries for failed txirb */
93 #define DBUS_TX_TIMEOUT_INTERVAL	250		/* timeout for txirb complete, in ms */
94 
95 #define DBUS_BUFFER_SIZE_TX	32000
96 #define DBUS_BUFFER_SIZE_RX	24000
97 
98 #define DBUS_BUFFER_SIZE_TX_NOAGG	2048
99 #define DBUS_BUFFER_SIZE_RX_NOAGG	2048
100 
101 /** DBUS types */
102 enum {
103 	DBUS_USB,
104 	DBUS_SDIO,
105 	DBUS_SPI,
106 	DBUS_UNKNOWN
107 };
108 
109 enum dbus_state {
110 	DBUS_STATE_DL_PENDING,
111 	DBUS_STATE_DL_DONE,
112 	DBUS_STATE_UP,
113 	DBUS_STATE_DOWN,
114 	DBUS_STATE_PNP_FWDL,
115 	DBUS_STATE_DISCONNECT,
116 	DBUS_STATE_SLEEP,
117 	DBUS_STATE_DL_NEEDED
118 };
119 
120 enum dbus_pnp_state {
121 	DBUS_PNP_DISCONNECT,
122 	DBUS_PNP_SLEEP,
123 	DBUS_PNP_RESUME
124 };
125 
126 enum dbus_file {
127     DBUS_FIRMWARE,
128     DBUS_NVFILE
129 };
130 
131 typedef enum _DEVICE_SPEED {
132 	INVALID_SPEED = -1,
133 	LOW_SPEED     =  1,	/**< USB 1.1: 1.5 Mbps */
134 	FULL_SPEED,     	/**< USB 1.1: 12  Mbps */
135 	HIGH_SPEED,		/**< USB 2.0: 480 Mbps */
136 	SUPER_SPEED,		/**< USB 3.0: 4.8 Gbps */
137 } DEVICE_SPEED;
138 
139 typedef struct {
140 	int bustype;
141 	int vid;
142 	int pid;
143 	int devid;
144 	int chiprev; /**< chip revsion number */
145 	int mtu;
146 	int nchan; /**< Data Channels */
147 	int has_2nd_bulk_in_ep;
148 } dbus_attrib_t;
149 
150 /* FIX: Account for errors related to DBUS;
151  * Let upper layer account for packets/bytes
152  */
153 typedef struct {
154 	uint32 rx_errors;
155 	uint32 tx_errors;
156 	uint32 rx_dropped;
157 	uint32 tx_dropped;
158 } dbus_stats_t;
159 
160 /**
161  * Configurable BUS parameters
162  */
163 enum {
164 	DBUS_CONFIG_ID_RXCTL_DEFERRES = 1,
165 	DBUS_CONFIG_ID_AGGR_LIMIT,
166 	DBUS_CONFIG_ID_KEEPIF_ON_DEVRESET
167 };
168 
169 typedef struct {
170 	uint32 config_id;
171 	union {
172 		uint32 general_param;
173 		bool rxctl_deferrespok;
174 		struct {
175 			int maxrxsf;
176 			int maxrxsize;
177 			int maxtxsf;
178 			int maxtxsize;
179 		} aggr_param;
180 	};
181 } dbus_config_t;
182 
183 /**
184  * External Download Info
185  */
186 typedef struct dbus_extdl {
187 	uint8 *fw;
188 	int fwlen;
189 	uint8 *vars;
190 	int varslen;
191 } dbus_extdl_t;
192 
193 struct dbus_callbacks;
194 struct exec_parms;
195 
196 typedef void *(*probe_cb_t)(void *arg, const char *desc, uint32 bustype,
197 	uint16 bus_no, uint16 slot, uint32 hdrlen);
198 typedef void (*disconnect_cb_t)(void *arg);
199 typedef void *(*exec_cb_t)(struct exec_parms *args);
200 
201 /** Client callbacks registered during dbus_attach() */
202 typedef struct dbus_callbacks {
203 	void (*send_complete)(void *cbarg, void *info, int status);
204 	void (*recv_buf)(void *cbarg, uint8 *buf, int len);
205 	void (*recv_pkt)(void *cbarg, void *pkt);
206 	void (*txflowcontrol)(void *cbarg, bool onoff);
207 	void (*errhandler)(void *cbarg, int err);
208 	void (*ctl_complete)(void *cbarg, int type, int status);
209 	void (*state_change)(void *cbarg, int state);
210 	void *(*pktget)(void *cbarg, uint len, bool send);
211 	void (*pktfree)(void *cbarg, void *p, bool send);
212 } dbus_callbacks_t;
213 
214 struct dbus_pub;
215 struct bcmstrbuf;
216 struct dbus_irb;
217 struct dbus_irb_rx;
218 struct dbus_irb_tx;
219 struct dbus_intf_callbacks;
220 
221 typedef struct {
222 	void* (*attach)(struct dbus_pub *pub, void *cbarg, struct dbus_intf_callbacks *cbs);
223 	void (*detach)(struct dbus_pub *pub, void *bus);
224 
225 	int (*up)(void *bus);
226 	int (*down)(void *bus);
227 	int (*send_irb)(void *bus, struct dbus_irb_tx *txirb);
228 	int (*recv_irb)(void *bus, struct dbus_irb_rx *rxirb);
229 	int (*cancel_irb)(void *bus, struct dbus_irb_tx *txirb);
230 	int (*send_ctl)(void *bus, uint8 *buf, int len);
231 	int (*recv_ctl)(void *bus, uint8 *buf, int len);
232 	int (*get_stats)(void *bus, dbus_stats_t *stats);
233 	int (*get_attrib)(void *bus, dbus_attrib_t *attrib);
234 
235 	int (*pnp)(void *bus, int evnt);
236 	int (*remove)(void *bus);
237 	int (*resume)(void *bus);
238 	int (*suspend)(void *bus);
239 	int (*stop)(void *bus);
240 	int (*reset)(void *bus);
241 
242 	/* Access to bus buffers directly */
243 	void *(*pktget)(void *bus, int len);
244 	void (*pktfree)(void *bus, void *pkt);
245 
246 	int  (*iovar_op)(void *bus, const char *name, void *params, int plen, void *arg, int len,
247 		bool set);
248 	void (*dump)(void *bus, struct bcmstrbuf *strbuf);
249 	int  (*set_config)(void *bus, dbus_config_t *config);
250 	int  (*get_config)(void *bus, dbus_config_t *config);
251 
252 	bool (*device_exists)(void *bus);
253 	int (*dlneeded)(void *bus);
254 	int  (*dlstart)(void *bus, uint8 *fw, int len);
255 	int  (*dlrun)(void *bus);
256 	bool (*recv_needed)(void *bus);
257 
258 	void *(*exec_rxlock)(void *bus, exec_cb_t func, struct exec_parms *args);
259 	void *(*exec_txlock)(void *bus, exec_cb_t func, struct exec_parms *args);
260 
261 	int (*tx_timer_init)(void *bus);
262 	int (*tx_timer_start)(void *bus, uint timeout);
263 	int (*tx_timer_stop)(void *bus);
264 
265 	int (*sched_dpc)(void *bus);
266 	int (*lock)(void *bus);
267 	int (*unlock)(void *bus);
268 	int (*sched_probe_cb)(void *bus);
269 
270 	int (*shutdown)(void *bus);
271 
272 	int (*recv_stop)(void *bus);
273 	int (*recv_resume)(void *bus);
274 
275 	int (*recv_irb_from_ep)(void *bus, struct dbus_irb_rx *rxirb, uint ep_idx);
276 
277 	int (*readreg)(void *bus, uint32 regaddr, int datalen, uint32 *value);
278 
279 	/* Add from the bottom */
280 } dbus_intf_t;
281 
282 typedef struct dbus_pub {
283 	struct osl_info *osh;
284 	dbus_stats_t stats;
285 	dbus_attrib_t attrib;
286 	enum dbus_state busstate;
287 	DEVICE_SPEED device_speed;
288 	int ntxq, nrxq, rxsize;
289 	void *bus;
290 	struct shared_info *sh;
291 	void *dev_info;
292 } dbus_pub_t;
293 
294 #define BUS_INFO(bus, type) (((type *) bus)->pub->bus)
295 
296 #define	ALIGNED_LOCAL_VARIABLE(var, align)					\
297 	uint8	buffer[SDALIGN+64];						\
298 	uint8	*var = (uint8 *)(((uintptr)&buffer[0]) & ~(align-1)) + align;
299 
300 /*
301  * Public Bus Function Interface
302  */
303 
304 /*
305  * FIX: Is there better way to pass OS/Host handles to DBUS but still
306  *      maintain common interface for all OS??
307  * Under NDIS, param1 needs to be MiniportHandle
308  *  For NDIS60, param2 is WdfDevice
309  * Under Linux, param1 and param2 are NULL;
310  */
311 extern int dbus_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb, void *prarg,
312 	void *param1, void *param2);
313 extern int dbus_deregister(void);
314 
315 //extern int dbus_download_firmware(dbus_pub_t *pub);
316 //extern int dbus_up(struct dhd_bus *pub);
317 extern int dbus_down(dbus_pub_t *pub);
318 //extern int dbus_stop(struct dhd_bus *pub);
319 extern int dbus_shutdown(dbus_pub_t *pub);
320 extern void dbus_flowctrl_rx(dbus_pub_t *pub, bool on);
321 
322 extern int dbus_send_txdata(dbus_pub_t *dbus, void *pktbuf);
323 extern int dbus_send_buf(dbus_pub_t *pub, uint8 *buf, int len, void *info);
324 extern int dbus_send_pkt(dbus_pub_t *pub, void *pkt, void *info);
325 //extern int dbus_send_ctl(struct dhd_bus *pub, uint8 *buf, int len);
326 //extern int dbus_recv_ctl(struct dhd_bus *pub, uint8 *buf, int len);
327 extern int dbus_recv_bulk(dbus_pub_t *pub, uint32 ep_idx);
328 extern int dbus_poll_intr(dbus_pub_t *pub);
329 extern int dbus_get_stats(dbus_pub_t *pub, dbus_stats_t *stats);
330 extern int dbus_get_device_speed(dbus_pub_t *pub);
331 extern int dbus_set_config(dbus_pub_t *pub, dbus_config_t *config);
332 extern int dbus_get_config(dbus_pub_t *pub, dbus_config_t *config);
333 extern void * dbus_get_devinfo(dbus_pub_t *pub);
334 
335 extern void *dbus_pktget(dbus_pub_t *pub, int len);
336 extern void dbus_pktfree(dbus_pub_t *pub, void* pkt);
337 
338 extern int dbus_set_errmask(dbus_pub_t *pub, uint32 mask);
339 extern int dbus_pnp_sleep(dbus_pub_t *pub);
340 extern int dbus_pnp_resume(dbus_pub_t *pub, int *fw_reload);
341 extern int dbus_pnp_disconnect(dbus_pub_t *pub);
342 
343 //extern int dhd_bus_iovar_op(dhd_pub_t *dhdp, const char *name,
344 //	void *params, int plen, void *arg, int len, bool set);
345 
346 extern void *dhd_dbus_txq(const dbus_pub_t *pub);
347 extern uint dhd_dbus_hdrlen(const dbus_pub_t *pub);
348 
349 /*
350  * Private Common Bus Interface
351  */
352 
353 /** IO Request Block (IRB) */
354 typedef struct dbus_irb {
355 	struct dbus_irb *next;	/**< it's casted from dbus_irb_tx or dbus_irb_rx struct */
356 } dbus_irb_t;
357 
358 typedef struct dbus_irb_rx {
359 	struct dbus_irb irb; /* Must be first */
360 	uint8 *buf;
361 	int buf_len;
362 	int actual_len;
363 	void *pkt;
364 	void *info;
365 	void *arg;
366 } dbus_irb_rx_t;
367 
368 typedef struct dbus_irb_tx {
369 	struct dbus_irb irb; 	/** Must be first */
370 	uint8 *buf;		/** mutually exclusive with struct member 'pkt' */
371 	int len;		/** length of field 'buf' */
372 	void *pkt;		/** mutually exclusive with struct member 'buf' */
373 	int retry_count;
374 	void *info;
375 	void *arg;
376 	void *send_buf;		/**< linear  bufffer for LINUX when aggreagtion is enabled */
377 } dbus_irb_tx_t;
378 
379 /**
380  * DBUS interface callbacks are different from user callbacks
381  * so, internally, different info can be passed to upper layer
382  */
383 typedef struct dbus_intf_callbacks {
384 	void (*send_irb_timeout)(void *cbarg, dbus_irb_tx_t *txirb);
385 	void (*send_irb_complete)(void *cbarg, dbus_irb_tx_t *txirb, int status);
386 	void (*recv_irb_complete)(void *cbarg, dbus_irb_rx_t *rxirb, int status);
387 	void (*errhandler)(void *cbarg, int err);
388 	void (*ctl_complete)(void *cbarg, int type, int status);
389 	void (*state_change)(void *cbarg, int state);
390 	bool (*isr)(void *cbarg, bool *wantdpc);
391 	bool (*dpc)(void *cbarg, bool bounded);
392 	void (*watchdog)(void *cbarg);
393 	void *(*pktget)(void *cbarg, uint len, bool send);
394 	void (*pktfree)(void *cbarg, void *p, bool send);
395 	struct dbus_irb* (*getirb)(void *cbarg, bool send);
396 	void (*rxerr_indicate)(void *cbarg, bool on);
397 } dbus_intf_callbacks_t;
398 
399 /*
400  * Porting: To support new bus, port these functions below
401  */
402 
403 /*
404  * Bus specific Interface
405  * Implemented by dbus_usb.c/dbus_sdio.c
406  */
407 extern int dbus_bus_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb, void *prarg,
408 	dbus_intf_t **intf, void *param1, void *param2);
409 extern int dbus_bus_deregister(void);
410 extern void dbus_bus_fw_get(void *bus, uint8 **fw, int *fwlen, int *decomp);
411 
412 /*
413  * Bus-specific and OS-specific Interface
414  * Implemented by dbus_usb_[linux/ndis].c/dbus_sdio_[linux/ndis].c
415  */
416 extern int dbus_bus_osl_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb,
417 	void *prarg, dbus_intf_t **intf, void *param1, void *param2);
418 extern int dbus_bus_osl_deregister(void);
419 
420 /*
421  * Bus-specific, OS-specific, HW-specific Interface
422  * Mainly for SDIO Host HW controller
423  */
424 extern int dbus_bus_osl_hw_register(int vid, int pid, probe_cb_t prcb, disconnect_cb_t discb,
425 	void *prarg, dbus_intf_t **intf);
426 extern int dbus_bus_osl_hw_deregister(void);
427 
428 extern uint usbdev_bulkin_eps(void);
429 #if defined(BCM_REQUEST_FW)
430 extern void *dbus_get_fw_nvfile(int devid, int chiprev, uint8 **fw, int *fwlen, int type,
431   uint16 boardtype, uint16 boardrev);
432 extern void dbus_release_fw_nvfile(void *firmware);
433 #endif  /* #if defined(BCM_REQUEST_FW) */
434 
435 #if defined(EHCI_FASTPATH_TX) || defined(EHCI_FASTPATH_RX)
436 
437 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
438 	/* Backward compatibility */
439 	typedef unsigned int gfp_t;
440 
441 	#define dma_pool pci_pool
442 	#define dma_pool_create(name, dev, size, align, alloc) \
443 		pci_pool_create(name, dev, size, align, alloc, GFP_DMA | GFP_ATOMIC)
444 	#define dma_pool_destroy(pool) pci_pool_destroy(pool)
445 	#define dma_pool_alloc(pool, flags, handle) pci_pool_alloc(pool, flags, handle)
446 	#define dma_pool_free(pool, vaddr, addr) pci_pool_free(pool, vaddr, addr)
447 
448 	#define dma_map_single(dev, addr, size, dir)	pci_map_single(dev, addr, size, dir)
449 	#define dma_unmap_single(dev, hnd, size, dir)	pci_unmap_single(dev, hnd, size, dir)
450 	#define DMA_FROM_DEVICE PCI_DMA_FROMDEVICE
451 	#define DMA_TO_DEVICE PCI_DMA_TODEVICE
452 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)) */
453 
454 /* Availability of these functions varies (when present, they have two arguments) */
455 #ifndef hc32_to_cpu
456 	#define hc32_to_cpu(x)	le32_to_cpu(x)
457 	#define cpu_to_hc32(x)	cpu_to_le32(x)
458 	typedef unsigned int __hc32;
459 #else
460 	#error Two-argument functions needed
461 #endif // endif
462 
463 /* Private USB opcode base */
464 #define EHCI_FASTPATH		0x31
465 #define	EHCI_SET_EP_BYPASS	EHCI_FASTPATH
466 #define	EHCI_SET_BYPASS_CB	(EHCI_FASTPATH + 1)
467 #define	EHCI_SET_BYPASS_DEV	(EHCI_FASTPATH + 2)
468 #define	EHCI_DUMP_STATE		(EHCI_FASTPATH + 3)
469 #define	EHCI_SET_BYPASS_POOL	(EHCI_FASTPATH + 4)
470 #define	EHCI_CLR_EP_BYPASS	(EHCI_FASTPATH + 5)
471 
472 /*
473  * EHCI QTD structure (hardware and extension)
474  * NOTE that is does not need to (and does not) match its kernel counterpart
475  */
476 #define EHCI_QTD_NBUFFERS       5
477 #define EHCI_QTD_ALIGN  	32
478 #define EHCI_BULK_PACKET_SIZE	512
479 #define EHCI_QTD_XACTERR_MAX	32
480 
481 struct ehci_qtd {
482 	/* Hardware map */
483 	volatile uint32_t	qtd_next;
484 	volatile uint32_t	qtd_altnext;
485 	volatile uint32_t	qtd_status;
486 #define	EHCI_QTD_GET_BYTES(x)	(((x)>>16) & 0x7fff)
487 #define	EHCI_QTD_IOC            0x00008000
488 #define	EHCI_QTD_GET_CERR(x)	(((x)>>10) & 0x3)
489 #define EHCI_QTD_SET_CERR(x)    ((x) << 10)
490 #define	EHCI_QTD_GET_PID(x)	(((x)>>8) & 0x3)
491 #define EHCI_QTD_SET_PID(x)     ((x) <<  8)
492 #define EHCI_QTD_ACTIVE         0x80
493 #define EHCI_QTD_HALTED         0x40
494 #define EHCI_QTD_BUFERR         0x20
495 #define EHCI_QTD_BABBLE         0x10
496 #define EHCI_QTD_XACTERR        0x08
497 #define EHCI_QTD_MISSEDMICRO    0x04
498 	volatile uint32_t 	qtd_buffer[EHCI_QTD_NBUFFERS];
499 	volatile uint32_t 	qtd_buffer_hi[EHCI_QTD_NBUFFERS];
500 
501 	/* Implementation extension */
502 	dma_addr_t		qtd_self;		/**< own hardware address */
503 	struct ehci_qtd		*obj_next;		/**< software link to the next QTD */
504 	void			*rpc;			/**< pointer to the rpc buffer */
505 	size_t			length;			/**< length of the data in the buffer */
506 	void			*buff;			/**< pointer to the reassembly buffer */
507 	int			xacterrs;		/**< retry counter for qtd xact error */
508 } __attribute__ ((aligned(EHCI_QTD_ALIGN)));
509 
510 #define	EHCI_NULL	__constant_cpu_to_le32(1) /* HW null pointer shall be odd */
511 
512 #define SHORT_READ_Q(token) (EHCI_QTD_GET_BYTES(token) != 0 && EHCI_QTD_GET_PID(token) == 1)
513 
514 /**
515  * Queue Head
516  * NOTE This structure is slightly different from the one in the kernel; but needs to stay
517  * compatible.
518  */
519 struct ehci_qh {
520 	/* Hardware map */
521 	volatile uint32_t 	qh_link;
522 	volatile uint32_t 	qh_endp;
523 	volatile uint32_t 	qh_endphub;
524 	volatile uint32_t 	qh_curqtd;
525 
526 	/* QTD overlay */
527 	volatile uint32_t	ow_next;
528 	volatile uint32_t	ow_altnext;
529 	volatile uint32_t	ow_status;
530 	volatile uint32_t	ow_buffer [EHCI_QTD_NBUFFERS];
531 	volatile uint32_t	ow_buffer_hi [EHCI_QTD_NBUFFERS];
532 
533 	/* Extension (should match the kernel layout) */
534 	dma_addr_t		unused0;
535 	void 			*unused1;
536 	struct list_head	unused2;
537 	struct ehci_qtd		*dummy;
538 	struct ehci_qh		*unused3;
539 
540 	struct ehci_hcd		*unused4;
541 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
542 	struct kref		unused5;
543 	unsigned		unused6;
544 
545 	uint8_t			unused7;
546 
547 	/* periodic schedule info */
548 	uint8_t			unused8;
549 	uint8_t			unused9;
550 	uint8_t			unused10;
551 	uint16_t		unused11;
552 	uint16_t		unused12;
553 	uint16_t		unused13;
554 	struct usb_device	*unused14;
555 #else
556 	unsigned		unused5;
557 
558 	u8			unused6;
559 
560 	/* periodic schedule info */
561 	u8			unused7;
562 	u8			unused8;
563 	u8			unused9;
564 	unsigned short		unused10;
565 	unsigned short		unused11;
566 #define NO_FRAME ((unsigned short)~0)
567 #ifdef EHCI_QUIRK_FIX
568 	struct usb_device	*unused12;
569 #endif /* EHCI_QUIRK_FIX */
570 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) */
571 	struct ehci_qtd		*first_qtd;
572 		/* Link to the first QTD; this is an optimized equivalent of the qtd_list field */
573 		/* NOTE that ehci_qh in ehci.h shall reserve this word */
574 } __attribute__ ((aligned(EHCI_QTD_ALIGN)));
575 
576 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
577 /** The corresponding structure in the kernel is used to get the QH */
578 struct hcd_dev {	/* usb_device.hcpriv points to this */
579 	struct list_head	unused0;
580 	struct list_head	unused1;
581 
582 	/* array of QH pointers */
583 	void			*ep[32];
584 };
585 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0)) */
586 
587 int optimize_qtd_fill_with_rpc(const dbus_pub_t *pub,  int epn, struct ehci_qtd *qtd, void *rpc,
588 	int token, int len);
589 int optimize_qtd_fill_with_data(const dbus_pub_t *pub, int epn, struct ehci_qtd *qtd, void *data,
590 	int token, int len);
591 int optimize_submit_async(struct ehci_qtd *qtd, int epn);
592 void inline optimize_ehci_qtd_init(struct ehci_qtd *qtd, dma_addr_t dma);
593 struct ehci_qtd *optimize_ehci_qtd_alloc(gfp_t flags);
594 void optimize_ehci_qtd_free(struct ehci_qtd *qtd);
595 void optimize_submit_rx_request(const dbus_pub_t *pub, int epn, struct ehci_qtd *qtd_in, void *buf);
596 #endif /* EHCI_FASTPATH_TX || EHCI_FASTPATH_RX */
597 
598 void  dbus_flowctrl_tx(void *dbi, bool on);
599 #endif /* __DBUS_H__ */
600