Initial cut of the open ath9k htc firmware.
[open-ath9k-htc-firmware.git] / target_firmware / magpie_fw_dev / target / adf / adf_nbuf_pvt.h
1 /*
2  * (c) Copyright Atheros Communications
3  *  FreeBSD specific prototypes 
4  */
5 #ifndef _ADF_NBUF_PVT_H
6 #define _ADF_NBUF_PVT_H
7
8 #include <osapi.h>
9 //#include <Magpie_api.h>
10 #include <vbuf_api.h>
11 //#include <adf_nbuf_api.h>
12
13 #define __ADF_NBUF_NULL         NULL
14 #define __ADF_NBUF_CTX_BUF      
15
16 typedef VBUF *     __adf_nbuf_t;
17
18 /**
19  * queue head
20  */
21 typedef struct __adf_nbuf_qhead {
22     VBUF             *head;
23     VBUF             *tail;    
24     a_uint32_t        qlen;
25 }__adf_nbuf_qhead_t;
26
27 typedef __adf_nbuf_qhead_t         __adf_nbuf_queue_t;
28
29 __adf_nbuf_t 
30 __adf_nbuf_alloc(adf_os_size_t size, 
31                  a_uint32_t reserve, a_uint32_t align);                                
32
33 void 
34 __adf_nbuf_free(__adf_nbuf_t  buf);
35
36 a_uint8_t *   
37 __adf_nbuf_push_head(__adf_nbuf_t buf, adf_os_size_t size);
38  
39 a_uint8_t *    
40 __adf_nbuf_pull_head(__adf_nbuf_t buf, adf_os_size_t size);
41
42 a_uint8_t *    
43 __adf_nbuf_put_tail(__adf_nbuf_t buf, adf_os_size_t size);
44
45 void         
46 __adf_nbuf_trim_tail(__adf_nbuf_t buf, adf_os_size_t size);
47
48 __adf_nbuf_t 
49 __adf_nbuf_realloc_headroom(__adf_nbuf_t buf,
50                             a_uint32_t headroom);                           
51                             
52 __adf_nbuf_t 
53 __adf_nbuf_realloc_tailroom(__adf_nbuf_t buf, 
54                             a_uint32_t tailroom);
55                                                 
56 __adf_nbuf_t 
57 __adf_nbuf_expand(__adf_nbuf_t buf,
58                                a_uint32_t headroom, a_uint32_t tailroom);
59                                                                                
60 __adf_nbuf_t 
61 __adf_nbuf_copy(__adf_nbuf_t src);
62
63 __adf_nbuf_t 
64 __adf_nbuf_unshare(__adf_nbuf_t  src);
65
66 void         
67 __adf_nbuf_frag_info(__adf_nbuf_t buf, adf_os_sglist_t *sg);
68
69 a_uint8_t *    
70 __adf_nbuf_get_priv(__adf_nbuf_t buf);
71 void         
72 __adf_nbuf_queue_add(__adf_nbuf_qhead_t *qhead, 
73                      __adf_nbuf_t buf);
74                                   
75 __adf_nbuf_t 
76 __adf_nbuf_queue_remove(__adf_nbuf_qhead_t *qhead);
77
78 a_uint32_t     
79 __adf_nbuf_tx_cksum_info(__adf_nbuf_t buf, 
80                          a_uint8_t **hdr_off, 
81                          a_uint8_t **where);
82                                       
83 void         
84 __adf_nbuf_set_rx_cksum(__adf_nbuf_t buf, adf_nbuf_rx_cksum_t *cksum);
85 void         
86 __adf_nbuf_get_tso_info(__adf_nbuf_t buf, adf_nbuf_tso_t *tso);
87
88 a_status_t   
89 __adf_nbuf_get_vlan_info(adf_net_handle_t hdl, 
90                                       __adf_nbuf_t buf, 
91                                       adf_net_vlanhdr_t *vlan);                                                                                                
92                                        
93 void         
94 __adf_nbuf_dmamap_info(__adf_os_dma_map_t bmap, adf_os_dmamap_info_t *sg);
95
96 /**
97  * @brief return the last mbuf
98  * 
99  * @param m0
100  * 
101  * @return struct mbuf*
102  */
103 VDESC * 
104 __adf_nbuf_last(VBUF *buf);
105
106 /**
107  * @brief num bytes in the head
108  * 
109  * @param adf_nbuf
110  * 
111  * @return num of bytes available
112  */
113 a_uint32_t
114 __adf_nbuf_headroom(__adf_nbuf_t  buf);
115
116 /**
117  * @brief num of bytes available in the tail excluding the priv
118  *        portion
119  * 
120  * @param adf_nbuf
121  * 
122  * @return num of bytes
123  */
124
125 a_uint32_t 
126 __adf_nbuf_tailroom(__adf_nbuf_t  buf);
127
128 /**
129  * @brief get the entire packet length
130  * 
131  * @param adf_nbuf
132  * 
133  * @return total length of packet (sum of all frag lengths)
134  */ 
135 a_uint32_t
136 __adf_nbuf_len(__adf_nbuf_t  buf);
137
138 /**
139  * @brief Clone the nbuf (will not create writeable copies)
140  * 
141  * @param adf_nbuf
142  * 
143  * @return Read-only copy of the nbuf (including clusters)
144  */
145 __adf_nbuf_t 
146 __adf_nbuf_clone(__adf_nbuf_t  src);
147
148 void
149 __adf_nbuf_cat(__adf_nbuf_t dst, __adf_nbuf_t src);
150
151
152 /*
153  * @brief check if the mbuf is cloned or not
154  * 
155  * @param buf
156  * 
157  * @return a_bool_t
158  */
159 a_bool_t
160 __adf_nbuf_is_cloned(__adf_nbuf_t  buf);
161
162 /**
163  * @brief This will return the header's addr & m_len
164  */
165 void
166 __adf_nbuf_peek_header(__adf_nbuf_t buf, a_uint8_t   **addr, 
167                        a_uint32_t       *len);
168
169 /**
170  * @brief init the queue
171  * @param qhead
172  */
173 void 
174 __adf_nbuf_queue_init(__adf_nbuf_qhead_t *qhead);
175
176 /**
177  * @brief return the length of queue
178  * @param adf_qhead
179  * 
180  * @return length
181  * 
182  */
183 a_uint32_t  
184 __adf_nbuf_queue_len(__adf_nbuf_qhead_t *qhead);
185
186 /**
187  * @brief returns the first guy in the Q
188  * @param qhead
189  * 
190  * @return (NULL if the Q is empty)
191  */
192 __adf_nbuf_t   
193 __adf_nbuf_queue_first(__adf_nbuf_queue_t *qhead);
194
195 /**
196  * @brief return the next packet from packet chain
197  * 
198  * @param buf (packet)
199  * 
200  * @return (NULL if no packets are there)
201  */
202 __adf_nbuf_t   
203 __adf_nbuf_queue_next(__adf_nbuf_t  buf);
204
205 /**
206  * @brief check if the queue is empty or not
207  * 
208  * @param qhead
209  * 
210  * @return a_bool_t
211  */
212 a_bool_t  
213 __adf_nbuf_is_queue_empty(__adf_nbuf_qhead_t *qhead);
214
215 __adf_nbuf_t
216 __adf_nbuf_create_frm_frag(__adf_nbuf_queue_t *head);
217 void
218 __adf_nbuf_split_to_frag(__adf_nbuf_t buf, __adf_nbuf_queue_t *qhead);
219
220 a_status_t      __adf_nbuf_dmamap_create(__adf_os_device_t osdev, 
221                                          __adf_os_dma_map_t *dmap);
222
223 void            __adf_nbuf_dmamap_destroy(__adf_os_device_t osdev, 
224                                           __adf_os_dma_map_t dmap);
225
226 a_status_t      __adf_nbuf_map(__adf_os_device_t osdev, __adf_os_dma_map_t dmap,
227                                 __adf_nbuf_t buf, adf_os_dma_dir_t dir);
228 void            __adf_nbuf_unmap(__adf_os_device_t osdev, __adf_os_dma_map_t dmap,
229                                adf_os_dma_dir_t dir);
230
231 #endif
232