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