2 * Copyright (c) 2013 Qualcomm Atheros, Inc.
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:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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
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.
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.
36 * FreeBSD specific prototypes
38 #ifndef _ADF_NBUF_PVT_H
39 #define _ADF_NBUF_PVT_H
42 //#include <Magpie_api.h>
44 //#include <adf_nbuf_api.h>
46 #define __ADF_NBUF_NULL NULL
47 #define __ADF_NBUF_CTX_BUF
49 typedef VBUF * __adf_nbuf_t;
54 typedef struct __adf_nbuf_qhead {
60 typedef __adf_nbuf_qhead_t __adf_nbuf_queue_t;
63 __adf_nbuf_alloc(adf_os_size_t size,
64 a_uint32_t reserve, a_uint32_t align);
67 __adf_nbuf_free(__adf_nbuf_t buf);
70 __adf_nbuf_push_head(__adf_nbuf_t buf, adf_os_size_t size);
73 __adf_nbuf_pull_head(__adf_nbuf_t buf, adf_os_size_t size);
76 __adf_nbuf_put_tail(__adf_nbuf_t buf, adf_os_size_t size);
79 __adf_nbuf_trim_tail(__adf_nbuf_t buf, adf_os_size_t size);
82 __adf_nbuf_realloc_headroom(__adf_nbuf_t buf,
86 __adf_nbuf_realloc_tailroom(__adf_nbuf_t buf,
90 __adf_nbuf_expand(__adf_nbuf_t buf,
91 a_uint32_t headroom, a_uint32_t tailroom);
94 __adf_nbuf_copy(__adf_nbuf_t src);
97 __adf_nbuf_unshare(__adf_nbuf_t src);
100 __adf_nbuf_frag_info(__adf_nbuf_t buf, adf_os_sglist_t *sg);
103 __adf_nbuf_get_priv(__adf_nbuf_t buf);
105 __adf_nbuf_queue_add(__adf_nbuf_qhead_t *qhead,
109 __adf_nbuf_queue_remove(__adf_nbuf_qhead_t *qhead);
112 __adf_nbuf_tx_cksum_info(__adf_nbuf_t buf,
117 __adf_nbuf_set_rx_cksum(__adf_nbuf_t buf, adf_nbuf_rx_cksum_t *cksum);
119 __adf_nbuf_get_tso_info(__adf_nbuf_t buf, adf_nbuf_tso_t *tso);
122 __adf_nbuf_get_vlan_info(adf_net_handle_t hdl,
124 adf_net_vlanhdr_t *vlan);
127 __adf_nbuf_dmamap_info(__adf_os_dma_map_t bmap, adf_os_dmamap_info_t *sg);
130 * @brief return the last mbuf
134 * @return struct mbuf*
137 __adf_nbuf_last(VBUF *buf);
140 * @brief num bytes in the head
144 * @return num of bytes available
147 __adf_nbuf_headroom(__adf_nbuf_t buf);
150 * @brief num of bytes available in the tail excluding the priv
155 * @return num of bytes
159 __adf_nbuf_tailroom(__adf_nbuf_t buf);
162 * @brief get the entire packet length
166 * @return total length of packet (sum of all frag lengths)
169 __adf_nbuf_len(__adf_nbuf_t buf);
172 * @brief Clone the nbuf (will not create writeable copies)
176 * @return Read-only copy of the nbuf (including clusters)
179 __adf_nbuf_clone(__adf_nbuf_t src);
182 __adf_nbuf_cat(__adf_nbuf_t dst, __adf_nbuf_t src);
186 * @brief check if the mbuf is cloned or not
193 __adf_nbuf_is_cloned(__adf_nbuf_t buf);
196 * @brief This will return the header's addr & m_len
199 __adf_nbuf_peek_header(__adf_nbuf_t buf, a_uint8_t **addr,
203 * @brief init the queue
207 __adf_nbuf_queue_init(__adf_nbuf_qhead_t *qhead);
210 * @brief return the length of queue
217 __adf_nbuf_queue_len(__adf_nbuf_qhead_t *qhead);
220 * @brief returns the first guy in the Q
223 * @return (NULL if the Q is empty)
226 __adf_nbuf_queue_first(__adf_nbuf_queue_t *qhead);
229 * @brief return the next packet from packet chain
231 * @param buf (packet)
233 * @return (NULL if no packets are there)
236 __adf_nbuf_queue_next(__adf_nbuf_t buf);
239 * @brief check if the queue is empty or not
246 __adf_nbuf_is_queue_empty(__adf_nbuf_qhead_t *qhead);
249 __adf_nbuf_create_frm_frag(__adf_nbuf_queue_t *head);
251 __adf_nbuf_split_to_frag(__adf_nbuf_t buf, __adf_nbuf_queue_t *qhead);
253 a_status_t __adf_nbuf_dmamap_create(__adf_os_device_t osdev,
254 __adf_os_dma_map_t *dmap);
256 void __adf_nbuf_dmamap_destroy(__adf_os_device_t osdev,
257 __adf_os_dma_map_t dmap);
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);