Setting up repository
[linux-libre-firmware.git] / ath9k_htc / target_firmware / magpie_fw_dev / target / adf / adf_nbuf_pvt.h
1 /*
2  * Copyright (c) 2013 Qualcomm Atheros, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted (subject to the limitations in the
7  * disclaimer below) provided that the following conditions are met:
8  *
9  *  * Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  *  * Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the
15  *    distribution.
16  *
17  *  * Neither the name of Qualcomm Atheros nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
22  * GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
23  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
24  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
32  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 /*
36  *  FreeBSD specific prototypes 
37  */
38 #ifndef _ADF_NBUF_PVT_H
39 #define _ADF_NBUF_PVT_H
40
41 #include <osapi.h>
42 //#include <Magpie_api.h>
43 #include <vbuf_api.h>
44 //#include <adf_nbuf_api.h>
45
46 #define __ADF_NBUF_NULL         NULL
47 #define __ADF_NBUF_CTX_BUF      
48
49 typedef VBUF *     __adf_nbuf_t;
50
51 /**
52  * queue head
53  */
54 typedef struct __adf_nbuf_qhead {
55     VBUF             *head;
56     VBUF             *tail;    
57     a_uint32_t        qlen;
58 }__adf_nbuf_qhead_t;
59
60 typedef __adf_nbuf_qhead_t         __adf_nbuf_queue_t;
61
62 __adf_nbuf_t 
63 __adf_nbuf_alloc(adf_os_size_t size, 
64                  a_uint32_t reserve, a_uint32_t align);                                
65
66 void 
67 __adf_nbuf_free(__adf_nbuf_t  buf);
68
69 a_uint8_t *   
70 __adf_nbuf_push_head(__adf_nbuf_t buf, adf_os_size_t size);
71  
72 a_uint8_t *    
73 __adf_nbuf_pull_head(__adf_nbuf_t buf, adf_os_size_t size);
74
75 a_uint8_t *    
76 __adf_nbuf_put_tail(__adf_nbuf_t buf, adf_os_size_t size);
77
78 void         
79 __adf_nbuf_trim_tail(__adf_nbuf_t buf, adf_os_size_t size);
80
81 __adf_nbuf_t 
82 __adf_nbuf_realloc_headroom(__adf_nbuf_t buf,
83                             a_uint32_t headroom);                           
84                             
85 __adf_nbuf_t 
86 __adf_nbuf_realloc_tailroom(__adf_nbuf_t buf, 
87                             a_uint32_t tailroom);
88                                                 
89 __adf_nbuf_t 
90 __adf_nbuf_expand(__adf_nbuf_t buf,
91                                a_uint32_t headroom, a_uint32_t tailroom);
92                                                                                
93 __adf_nbuf_t 
94 __adf_nbuf_copy(__adf_nbuf_t src);
95
96 __adf_nbuf_t 
97 __adf_nbuf_unshare(__adf_nbuf_t  src);
98
99 void         
100 __adf_nbuf_frag_info(__adf_nbuf_t buf, adf_os_sglist_t *sg);
101
102 a_uint8_t *    
103 __adf_nbuf_get_priv(__adf_nbuf_t buf);
104 void         
105 __adf_nbuf_queue_add(__adf_nbuf_qhead_t *qhead, 
106                      __adf_nbuf_t buf);
107                                   
108 __adf_nbuf_t 
109 __adf_nbuf_queue_remove(__adf_nbuf_qhead_t *qhead);
110
111 a_uint32_t     
112 __adf_nbuf_tx_cksum_info(__adf_nbuf_t buf, 
113                          a_uint8_t **hdr_off, 
114                          a_uint8_t **where);
115                                       
116 void         
117 __adf_nbuf_set_rx_cksum(__adf_nbuf_t buf, adf_nbuf_rx_cksum_t *cksum);
118 void         
119 __adf_nbuf_get_tso_info(__adf_nbuf_t buf, adf_nbuf_tso_t *tso);
120
121 a_status_t   
122 __adf_nbuf_get_vlan_info(adf_net_handle_t hdl, 
123                                       __adf_nbuf_t buf, 
124                                       adf_net_vlanhdr_t *vlan);                                                                                                
125                                        
126 void         
127 __adf_nbuf_dmamap_info(__adf_os_dma_map_t bmap, adf_os_dmamap_info_t *sg);
128
129 /**
130  * @brief return the last mbuf
131  * 
132  * @param m0
133  * 
134  * @return struct mbuf*
135  */
136 VDESC * 
137 __adf_nbuf_last(VBUF *buf);
138
139 /**
140  * @brief num bytes in the head
141  * 
142  * @param adf_nbuf
143  * 
144  * @return num of bytes available
145  */
146 a_uint32_t
147 __adf_nbuf_headroom(__adf_nbuf_t  buf);
148
149 /**
150  * @brief num of bytes available in the tail excluding the priv
151  *        portion
152  * 
153  * @param adf_nbuf
154  * 
155  * @return num of bytes
156  */
157
158 a_uint32_t 
159 __adf_nbuf_tailroom(__adf_nbuf_t  buf);
160
161 /**
162  * @brief get the entire packet length
163  * 
164  * @param adf_nbuf
165  * 
166  * @return total length of packet (sum of all frag lengths)
167  */ 
168 a_uint32_t
169 __adf_nbuf_len(__adf_nbuf_t  buf);
170
171 /**
172  * @brief Clone the nbuf (will not create writeable copies)
173  * 
174  * @param adf_nbuf
175  * 
176  * @return Read-only copy of the nbuf (including clusters)
177  */
178 __adf_nbuf_t 
179 __adf_nbuf_clone(__adf_nbuf_t  src);
180
181 void
182 __adf_nbuf_cat(__adf_nbuf_t dst, __adf_nbuf_t src);
183
184
185 /*
186  * @brief check if the mbuf is cloned or not
187  * 
188  * @param buf
189  * 
190  * @return a_bool_t
191  */
192 a_bool_t
193 __adf_nbuf_is_cloned(__adf_nbuf_t  buf);
194
195 /**
196  * @brief This will return the header's addr & m_len
197  */
198 void
199 __adf_nbuf_peek_header(__adf_nbuf_t buf, a_uint8_t   **addr, 
200                        a_uint32_t       *len);
201
202 /**
203  * @brief init the queue
204  * @param qhead
205  */
206 void 
207 __adf_nbuf_queue_init(__adf_nbuf_qhead_t *qhead);
208
209 /**
210  * @brief return the length of queue
211  * @param adf_qhead
212  * 
213  * @return length
214  * 
215  */
216 a_uint32_t  
217 __adf_nbuf_queue_len(__adf_nbuf_qhead_t *qhead);
218
219 /**
220  * @brief returns the first guy in the Q
221  * @param qhead
222  * 
223  * @return (NULL if the Q is empty)
224  */
225 __adf_nbuf_t   
226 __adf_nbuf_queue_first(__adf_nbuf_queue_t *qhead);
227
228 /**
229  * @brief return the next packet from packet chain
230  * 
231  * @param buf (packet)
232  * 
233  * @return (NULL if no packets are there)
234  */
235 __adf_nbuf_t   
236 __adf_nbuf_queue_next(__adf_nbuf_t  buf);
237
238 /**
239  * @brief check if the queue is empty or not
240  * 
241  * @param qhead
242  * 
243  * @return a_bool_t
244  */
245 a_bool_t  
246 __adf_nbuf_is_queue_empty(__adf_nbuf_qhead_t *qhead);
247
248 __adf_nbuf_t
249 __adf_nbuf_create_frm_frag(__adf_nbuf_queue_t *head);
250 void
251 __adf_nbuf_split_to_frag(__adf_nbuf_t buf, __adf_nbuf_queue_t *qhead);
252
253 a_status_t      __adf_nbuf_dmamap_create(__adf_os_device_t osdev, 
254                                          __adf_os_dma_map_t *dmap);
255
256 void            __adf_nbuf_dmamap_destroy(__adf_os_device_t osdev, 
257                                           __adf_os_dma_map_t dmap);
258
259 a_status_t      __adf_nbuf_map(__adf_os_device_t osdev, __adf_os_dma_map_t dmap,
260                                 __adf_nbuf_t buf, adf_os_dma_dir_t dir);
261 void            __adf_nbuf_unmap(__adf_os_device_t osdev, __adf_os_dma_map_t dmap,
262                                adf_os_dma_dir_t dir);
263
264 #endif
265