Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / inc / k2 / dma_engine_api.h
1 /*
2  * @File: dma_engine_api.h
3  * 
4  * @Abstract: DMA Engine api
5  * 
6  * @Notes:
7  * 
8  * Copyright (c) 2008 Atheros Communications Inc.
9  * All rights reserved.
10  *
11  */
12
13 #ifndef _DMA_ENGINE_API_H
14 #define _DMA_ENGINE_API_H
15
16 #include <vbuf_api.h>
17 #include <vdesc_api.h>
18
19 struct zsDmaDesc
20 {
21 #if 1   // BIG_ENDIAN
22         volatile u16_t      ctrl;       // Descriptor control
23         volatile u16_t      status;     // Descriptor status
24         volatile u16_t      totalLen;   // Total length
25         volatile u16_t      dataSize;   // Data size
26 #else
27         volatile u16_t      status;     // Descriptor status
28         volatile u16_t      ctrl;       // Descriptor control
29         volatile u16_t      dataSize;   // Data size
30         volatile u16_t      totalLen;   // Total length
31 #endif
32         struct zsDmaDesc*   lastAddr;   // Last address of this chain
33         volatile u32_t      dataAddr;   // Data buffer address
34         struct zsDmaDesc*   nextAddr;   // Next TD address
35 };
36
37 struct zsDmaQueue
38 {
39         struct zsDmaDesc* head;
40         struct zsDmaDesc* terminator;
41 };
42
43 // Subclass of zsDmaQueue for TX
44 struct zsTxDmaQueue
45 {
46         struct zsDmaDesc* head;
47         struct zsDmaDesc* terminator;
48     
49         /* Below are fields specific to TX */
50         VBUF *xmited_buf_head;
51         VBUF *xmited_buf_tail;        
52 };
53
54 /* hardware API table structure (API descriptions below) */
55 struct dma_engine_api 
56 {
57         void  (*_init)();
58
59         void  (*_init_rx_queue)(struct zsDmaQueue *q);
60     
61         void  (*_init_tx_queue)(struct zsTxDmaQueue *q);
62                     
63         void  (*_config_rx_queue)(struct zsDmaQueue *q, int num_desc, int buf_size);
64     
65         void  (*_xmit_buf)(struct zsTxDmaQueue *q, VBUF *buf);
66     
67         void  (*_flush_xmit)(struct zsDmaQueue *q);
68     
69         VBUF* (*_reap_recv_buf)(struct zsDmaQueue *q);
70     
71         void  (*_return_recv_buf)(struct zsDmaQueue *q, VBUF *buf);
72     
73         VBUF* (*_reap_xmited_buf)(struct zsTxDmaQueue *q);
74     
75         void  (*_swap_data)(struct zsDmaDesc* desc);
76     
77         int   (*_has_compl_packets)(struct zsDmaQueue *q);
78     
79         void  (*_desc_dump)(struct zsDmaQueue *q);
80     
81         /* The functions below are for patchable */
82         struct zsDmaDesc* (*_get_packet)(struct zsDmaQueue* q);
83         void  (*_reclaim_packet)(struct zsDmaQueue* q, struct zsDmaDesc* desc);
84         void (*_put_packet)(struct zsDmaQueue* q, struct zsDmaDesc* desc);
85     
86         /* room to expand this table by another table */
87         void *pReserved;
88 };
89
90 extern void dma_engine_module_install(struct dma_engine_api *apis);
91
92 #endif /* #ifndef _DMA_ENGINE_API_H */