Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Ryan Hsu | ceb390c | 2016-01-21 23:00:43 -0800 | [diff] [blame] | 2 | * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: cdf_nbuf_public network buffer API |
| 30 | * This file defines the network buffer abstraction. |
| 31 | */ |
| 32 | |
| 33 | #ifndef _CDF_NBUF_H |
| 34 | #define _CDF_NBUF_H |
| 35 | #include <cdf_util.h> |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 36 | #include <qdf_types.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 37 | #include <cdf_net_types.h> |
| 38 | #include <cdf_lock.h> |
| 39 | #include <i_cdf_nbuf.h> |
| 40 | #include <asm/cacheflush.h> |
| 41 | |
| 42 | #define IPA_NBUF_OWNER_ID 0xaa55aa55 |
| 43 | #define NBUF_PKT_TRAC_TYPE_EAPOL 0x02 |
| 44 | #define NBUF_PKT_TRAC_TYPE_DHCP 0x04 |
| 45 | #define NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08 |
| 46 | #define NBUF_PKT_TRAC_MAX_STRING 12 |
| 47 | #define NBUF_PKT_TRAC_PROTO_STRING 4 |
| 48 | #define NBUF_PKT_ERROR 1 |
| 49 | |
| 50 | /* Tracked Packet types */ |
| 51 | #define NBUF_TX_PKT_INVALID 0 |
| 52 | #define NBUF_TX_PKT_DATA_TRACK 1 |
| 53 | #define NBUF_TX_PKT_MGMT_TRACK 2 |
| 54 | |
| 55 | /* Different Packet states */ |
| 56 | #define NBUF_TX_PKT_HDD 1 |
| 57 | #define NBUF_TX_PKT_TXRX_ENQUEUE 2 |
| 58 | #define NBUF_TX_PKT_TXRX_DEQUEUE 3 |
| 59 | #define NBUF_TX_PKT_TXRX 4 |
| 60 | #define NBUF_TX_PKT_HTT 5 |
| 61 | #define NBUF_TX_PKT_HTC 6 |
| 62 | #define NBUF_TX_PKT_HIF 7 |
| 63 | #define NBUF_TX_PKT_CE 8 |
| 64 | #define NBUF_TX_PKT_FREE 9 |
| 65 | #define NBUF_TX_PKT_STATE_MAX 10 |
| 66 | |
| 67 | |
| 68 | /** |
| 69 | * @cdf_nbuf_t - Platform indepedent packet abstraction |
| 70 | */ |
| 71 | typedef __cdf_nbuf_t cdf_nbuf_t; |
| 72 | |
| 73 | /** |
| 74 | * @cdf_dma_map_cb_t - Dma map callback prototype |
| 75 | */ |
| 76 | typedef void (*cdf_dma_map_cb_t)(void *arg, cdf_nbuf_t buf, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 77 | qdf_dma_map_t dmap); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * @__CDF_NBUF_NULL - invalid handle |
| 81 | */ |
| 82 | #define CDF_NBUF_NULL __CDF_NBUF_NULL |
| 83 | /** |
| 84 | * @cdf_nbuf_queue_t - Platform independent packet queue abstraction |
| 85 | */ |
| 86 | typedef __cdf_nbuf_queue_t cdf_nbuf_queue_t; |
| 87 | |
| 88 | /* BUS/DMA mapping routines */ |
| 89 | |
| 90 | /** |
| 91 | * cdf_nbuf_map() - map a buffer to local bus address space |
| 92 | * @osdev: OS device |
| 93 | * @buf: Buf to be mapped (mapping info is stored in the buf's meta-data area) |
| 94 | * @dir: DMA direction |
| 95 | * |
| 96 | * Return: Status of the operation |
| 97 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 98 | static inline QDF_STATUS |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 99 | cdf_nbuf_map(qdf_device_t osdev, cdf_nbuf_t buf, qdf_dma_dir_t dir) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 100 | { |
| 101 | return __cdf_nbuf_map(osdev, buf, dir); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * cdf_nbuf_unmap() - unmap a previously mapped buf |
| 106 | * @osdev: OS device |
| 107 | * @buf: Buf to be unmapped (mapping info is stored in the buf's meta-data area) |
| 108 | * @dir: DMA direction |
| 109 | * |
| 110 | * Return: none |
| 111 | */ |
| 112 | static inline void |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 113 | cdf_nbuf_unmap(qdf_device_t osdev, cdf_nbuf_t buf, qdf_dma_dir_t dir) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 114 | { |
| 115 | __cdf_nbuf_unmap(osdev, buf, dir); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * cdf_nbuf_map_single() - map a single buffer to local bus address space |
| 120 | * @osdev: OS device |
| 121 | * @buf: Buf to be mapped (mapping info is stored in the buf's meta-data area) |
| 122 | * @dir: DMA direction |
| 123 | * |
| 124 | * Return: Status of the operation |
| 125 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 126 | static inline QDF_STATUS |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 127 | cdf_nbuf_map_single(qdf_device_t osdev, cdf_nbuf_t buf, qdf_dma_dir_t dir) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 128 | { |
| 129 | return __cdf_nbuf_map_single(osdev, buf, dir); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * cdf_nbuf_unmap_single() - unmap a previously mapped buf |
| 134 | * @osdev: OS device |
| 135 | * @buf: Buf to be unmapped (mapping info is stored in the buf's meta-data area) |
| 136 | * @dir: DMA direction |
| 137 | * |
| 138 | * Return: none |
| 139 | */ |
| 140 | static inline void |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 141 | cdf_nbuf_unmap_single(qdf_device_t osdev, cdf_nbuf_t buf, qdf_dma_dir_t dir) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 142 | { |
| 143 | __cdf_nbuf_unmap_single(osdev, buf, dir); |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * cdf_nbuf_get_num_frags() - get number of fragments |
| 148 | * @buf: Network buffer |
| 149 | * |
| 150 | * Return: Number of fragments |
| 151 | */ |
| 152 | static inline int cdf_nbuf_get_num_frags(cdf_nbuf_t buf) |
| 153 | { |
| 154 | return __cdf_nbuf_get_num_frags(buf); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * cdf_nbuf_get_frag_len() - get fragment length |
| 159 | * @buf: Network buffer |
| 160 | * @frag_num: Fragment number |
| 161 | * |
| 162 | * Return: Fragment length |
| 163 | */ |
| 164 | static inline int cdf_nbuf_get_frag_len(cdf_nbuf_t buf, int frag_num) |
| 165 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 166 | BUG_ON(frag_num >= NBUF_CB_TX_MAX_EXTRA_FRAGS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 167 | return __cdf_nbuf_get_frag_len(buf, frag_num); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * cdf_nbuf_get_frag_vaddr() - get fragment virtual address |
| 172 | * @buf: Network buffer |
| 173 | * @frag_num: Fragment number |
| 174 | * |
| 175 | * Return: Fragment virtual address |
| 176 | */ |
| 177 | static inline unsigned char *cdf_nbuf_get_frag_vaddr(cdf_nbuf_t buf, |
| 178 | int frag_num) |
| 179 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 180 | BUG_ON(frag_num >= NBUF_CB_TX_MAX_EXTRA_FRAGS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 181 | return __cdf_nbuf_get_frag_vaddr(buf, frag_num); |
| 182 | } |
| 183 | |
| 184 | /** |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 185 | * cdf_nbuf_get_frag_paddr() - get fragment physical address |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 186 | * @buf: Network buffer |
| 187 | * @frag_num: Fragment number |
| 188 | * |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 189 | * Return: Fragment physical address |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 190 | */ |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 191 | static inline cdf_dma_addr_t cdf_nbuf_get_frag_paddr(cdf_nbuf_t buf, int frag_num) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 192 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 193 | BUG_ON(frag_num >= NBUF_CB_TX_MAX_EXTRA_FRAGS); |
| 194 | return __cdf_nbuf_get_frag_paddr(buf, frag_num); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
| 198 | * cdf_nbuf_get_frag_is_wordstream() - is fragment wordstream |
| 199 | * @buf: Network buffer |
| 200 | * @frag_num: Fragment number |
| 201 | * |
| 202 | * Return: Fragment wordstream or not |
| 203 | */ |
| 204 | static inline int cdf_nbuf_get_frag_is_wordstream(cdf_nbuf_t buf, int frag_num) |
| 205 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 206 | BUG_ON(frag_num >= NBUF_CB_TX_MAX_EXTRA_FRAGS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 207 | return __cdf_nbuf_get_frag_is_wordstream(buf, frag_num); |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * cdf_nbuf_set_frag_is_wordstream() - set fragment wordstream |
| 212 | * @buf: Network buffer |
| 213 | * @frag_num: Fragment number |
| 214 | * @is_wordstream: Wordstream |
| 215 | * |
| 216 | * Return: none |
| 217 | */ |
| 218 | static inline void |
| 219 | cdf_nbuf_set_frag_is_wordstream(cdf_nbuf_t buf, int frag_num, int is_wordstream) |
| 220 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 221 | BUG_ON(frag_num >= NBUF_CB_TX_MAX_EXTRA_FRAGS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 222 | __cdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream); |
| 223 | } |
| 224 | |
| 225 | /** |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 226 | * cdf_nbuf_ipa_owned_get - gets the ipa_owned flag |
| 227 | * @buf: Network buffer |
| 228 | * |
| 229 | * Return: none |
| 230 | */ |
| 231 | static inline int cdf_nbuf_ipa_owned_get(cdf_nbuf_t buf) |
| 232 | { |
| 233 | return __cdf_nbuf_ipa_owned_get(buf); |
| 234 | } |
| 235 | |
| 236 | /** |
| 237 | * cdf_nbuf_ipa_owned_set - sets the ipa_owned flag |
| 238 | * @buf: Network buffer |
| 239 | * |
| 240 | * Return: none |
| 241 | */ |
| 242 | static inline void cdf_nbuf_ipa_owned_set(cdf_nbuf_t buf) |
| 243 | { |
| 244 | __cdf_nbuf_ipa_owned_set(buf); |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * cdf_nbuf_ipa_priv_get - gets the ipa_priv field |
| 249 | * @buf: Network buffer |
| 250 | * |
| 251 | * Return: none |
| 252 | */ |
| 253 | static inline int cdf_nbuf_ipa_priv_get(cdf_nbuf_t buf) |
| 254 | { |
| 255 | return __cdf_nbuf_ipa_priv_get(buf); |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * cdf_nbuf_ipa_priv_set - sets the ipa_priv field |
| 260 | * @buf: Network buffer |
| 261 | * |
| 262 | * Return: none |
| 263 | */ |
| 264 | static inline void cdf_nbuf_ipa_priv_set(cdf_nbuf_t buf, uint32_t priv) |
| 265 | { |
| 266 | BUG_ON(priv & 0x80000000); /* priv is 31 bits only */ |
| 267 | __cdf_nbuf_ipa_priv_set(buf, priv); |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * cdf_nbuf_mapped_paddr_get - gets the paddr of nbuf->data |
| 272 | * @buf: Network buffer |
| 273 | * |
| 274 | * Return: none |
| 275 | */ |
| 276 | static inline cdf_dma_addr_t |
| 277 | cdf_nbuf_mapped_paddr_get(cdf_nbuf_t buf) |
| 278 | { |
| 279 | return __cdf_nbuf_mapped_paddr_get(buf); |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * cdf_nbuf_mapped_paddr_set - sets the paddr of nbuf->data |
| 284 | * @buf: Network buffer |
| 285 | * |
| 286 | * Return: none |
| 287 | */ |
| 288 | static inline void |
| 289 | cdf_nbuf_mapped_paddr_set(cdf_nbuf_t buf, cdf_dma_addr_t paddr) |
| 290 | { |
| 291 | __cdf_nbuf_mapped_paddr_set(buf, paddr); |
| 292 | } |
| 293 | |
| 294 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 295 | * cdf_nbuf_frag_push_head() - push fragment head |
| 296 | * @buf: Network buffer |
| 297 | * @frag_len: Fragment length |
| 298 | * @frag_vaddr: Fragment virtual address |
| 299 | * @frag_paddr_lo: Fragment physical address lo |
| 300 | * @frag_paddr_hi: Fragment physical address hi |
| 301 | * |
| 302 | * Return: none |
| 303 | */ |
| 304 | static inline void |
| 305 | cdf_nbuf_frag_push_head(cdf_nbuf_t buf, |
| 306 | int frag_len, |
| 307 | char *frag_vaddr, |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 308 | cdf_dma_addr_t frag_paddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 309 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 310 | __cdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | #ifdef MEMORY_DEBUG |
| 314 | void cdf_net_buf_debug_init(void); |
| 315 | void cdf_net_buf_debug_exit(void); |
| 316 | void cdf_net_buf_debug_clean(void); |
| 317 | void cdf_net_buf_debug_add_node(cdf_nbuf_t net_buf, size_t size, |
| 318 | uint8_t *file_name, uint32_t line_num); |
| 319 | void cdf_net_buf_debug_delete_node(cdf_nbuf_t net_buf); |
| 320 | void cdf_net_buf_debug_release_skb(cdf_nbuf_t net_buf); |
| 321 | |
| 322 | /* nbuf allocation rouines */ |
| 323 | |
| 324 | /** |
| 325 | * cdf_nbuf_alloc() - Allocate cdf_nbuf |
| 326 | * @hdl: Platform device object |
| 327 | * @size: Data buffer size for this cdf_nbuf including max header |
| 328 | * size |
| 329 | * @reserve: Headroom to start with. |
| 330 | * @align: Alignment for the start buffer. |
| 331 | * @prio: Indicate if the nbuf is high priority (some OSes e.g darwin |
| 332 | * polls few times if allocation fails and priority is true) |
| 333 | * |
| 334 | * The nbuf created is guarenteed to have only 1 physical segment |
| 335 | * |
| 336 | * Return: The new cdf_nbuf instance or NULL if there's not enough memory. |
| 337 | */ |
| 338 | |
| 339 | #define cdf_nbuf_alloc(d, s, r, a, p) \ |
| 340 | cdf_nbuf_alloc_debug(d, s, r, a, p, __FILE__, __LINE__) |
| 341 | static inline cdf_nbuf_t |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 342 | cdf_nbuf_alloc_debug(qdf_device_t osdev, qdf_size_t size, int reserve, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | int align, int prio, uint8_t *file_name, |
| 344 | uint32_t line_num) |
| 345 | { |
| 346 | cdf_nbuf_t net_buf; |
| 347 | net_buf = __cdf_nbuf_alloc(osdev, size, reserve, align, prio); |
| 348 | |
| 349 | /* Store SKB in internal CDF tracking table */ |
| 350 | if (cdf_likely(net_buf)) |
| 351 | cdf_net_buf_debug_add_node(net_buf, size, file_name, line_num); |
| 352 | |
| 353 | return net_buf; |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * cdf_nbuf_free() - free cdf_nbuf |
| 358 | * @net_buf: Network buffer to free |
| 359 | * |
| 360 | * Return: none |
| 361 | */ |
| 362 | static inline void cdf_nbuf_free(cdf_nbuf_t net_buf) |
| 363 | { |
| 364 | /* Remove SKB from internal CDF tracking table */ |
| 365 | if (cdf_likely(net_buf)) |
| 366 | cdf_net_buf_debug_delete_node(net_buf); |
| 367 | |
| 368 | __cdf_nbuf_free(net_buf); |
| 369 | } |
| 370 | |
| 371 | #else |
| 372 | |
| 373 | static inline void cdf_net_buf_debug_release_skb(cdf_nbuf_t net_buf) |
| 374 | { |
| 375 | return; |
| 376 | } |
| 377 | |
| 378 | /* Nbuf allocation rouines */ |
| 379 | |
| 380 | /** |
| 381 | * cdf_nbuf_alloc() - allocate cdf_nbuf |
| 382 | * @hdl: Platform device object |
| 383 | * @size: Data buffer size for this cdf_nbuf including max header |
| 384 | * size |
| 385 | * @reserve: Headroom to start with. |
| 386 | * @align: Alignment for the start buffer. |
| 387 | * @prio: Indicate if the nbuf is high priority (some OSes e.g darwin |
| 388 | * polls few times if allocation fails and priority is true) |
| 389 | * |
| 390 | * The nbuf created is guarenteed to have only 1 physical segment |
| 391 | * |
| 392 | * Return: new cdf_nbuf instance or NULL if there's not enough memory. |
| 393 | */ |
| 394 | static inline cdf_nbuf_t |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 395 | cdf_nbuf_alloc(qdf_device_t osdev, |
| 396 | qdf_size_t size, int reserve, int align, int prio) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 397 | { |
| 398 | return __cdf_nbuf_alloc(osdev, size, reserve, align, prio); |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * cdf_nbuf_free() - free cdf_nbuf |
| 403 | * @buf: Network buffer to free |
| 404 | * |
| 405 | * Return: none |
| 406 | */ |
| 407 | static inline void cdf_nbuf_free(cdf_nbuf_t buf) |
| 408 | { |
| 409 | __cdf_nbuf_free(buf); |
| 410 | } |
| 411 | |
| 412 | #endif |
| 413 | |
| 414 | /** |
| 415 | * cdf_nbuf_tx_free() - free a list of cdf_nbufs and tell the OS their tx |
| 416 | * status (if req'd) |
| 417 | * @bufs: List of netbufs to free |
| 418 | * @tx_err: Whether the tx frames were transmitted successfully |
| 419 | * |
| 420 | * Return: none |
| 421 | */ |
| 422 | static inline void cdf_nbuf_tx_free(cdf_nbuf_t buf_list, int tx_err) |
| 423 | { |
| 424 | __cdf_nbuf_tx_free(buf_list, tx_err); |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * cdf_nbuf_copy() - copy src buffer into dst. |
| 429 | * @buf: source nbuf to copy from |
| 430 | * |
| 431 | * This API is useful, for example, because most native buffer provide a way to |
| 432 | * copy a chain into a single buffer. Therefore as a side effect, it also |
| 433 | * "linearizes" a buffer (which is perhaps why you'll use it mostly). It |
| 434 | * creates a writeable copy. |
| 435 | * |
| 436 | * |
| 437 | * Return: new nbuf |
| 438 | */ |
| 439 | static inline cdf_nbuf_t cdf_nbuf_copy(cdf_nbuf_t buf) |
| 440 | { |
| 441 | return __cdf_nbuf_copy(buf); |
| 442 | } |
| 443 | |
| 444 | /** |
| 445 | * cdf_nbuf_cat() - link two nbufs, the new buf is piggybacked into older one |
| 446 | * @dst: Buffer to piggyback into |
| 447 | * @src: Buffer to put |
| 448 | * |
| 449 | * Return: Status of the call - 0 successful |
| 450 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 451 | static inline QDF_STATUS cdf_nbuf_cat(cdf_nbuf_t dst, cdf_nbuf_t src) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 452 | { |
| 453 | return __cdf_nbuf_cat(dst, src); |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * @cdf_nbuf_copy_bits() - return the length of the copy bits for skb |
| 458 | * @skb: SKB pointer |
| 459 | * @offset: offset |
| 460 | * @len: Length |
| 461 | * @to: To |
| 462 | * |
| 463 | * Return: int32_t |
| 464 | */ |
| 465 | static inline int32_t |
| 466 | cdf_nbuf_copy_bits(cdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to) |
| 467 | { |
| 468 | return __cdf_nbuf_copy_bits(nbuf, offset, len, to); |
| 469 | } |
| 470 | |
| 471 | /** |
| 472 | * cdf_nbuf_clone() - clone the nbuf (copy is readonly) |
| 473 | * @buf: nbuf to clone from |
| 474 | * |
| 475 | * Return: cloned buffer |
| 476 | */ |
| 477 | static inline cdf_nbuf_t cdf_nbuf_clone(cdf_nbuf_t buf) |
| 478 | { |
| 479 | return __cdf_nbuf_clone(buf); |
| 480 | } |
| 481 | |
| 482 | /* nbuf manipulation routines */ |
| 483 | |
| 484 | /** |
| 485 | * @cdf_nbuf_head() - return the address of an nbuf's buffer |
| 486 | * @buf: netbuf |
| 487 | * |
| 488 | * Return: head address |
| 489 | */ |
| 490 | static inline uint8_t *cdf_nbuf_head(cdf_nbuf_t buf) |
| 491 | { |
| 492 | return __cdf_nbuf_head(buf); |
| 493 | } |
| 494 | |
| 495 | /** |
| 496 | * cdf_nbuf_data() - Return the address of the start of data within an nbuf |
| 497 | * @buf: Network buffer |
| 498 | * |
| 499 | * Return: Data address |
| 500 | */ |
| 501 | static inline uint8_t *cdf_nbuf_data(cdf_nbuf_t buf) |
| 502 | { |
| 503 | return __cdf_nbuf_data(buf); |
| 504 | } |
| 505 | |
| 506 | /** |
| 507 | * cdf_nbuf_headroom() - amount of headroom int the current nbuf |
| 508 | * @buf: Network buffer |
| 509 | * |
| 510 | * Return: Amount of head room |
| 511 | */ |
| 512 | static inline uint32_t cdf_nbuf_headroom(cdf_nbuf_t buf) |
| 513 | { |
| 514 | return __cdf_nbuf_headroom(buf); |
| 515 | } |
| 516 | |
| 517 | /** |
| 518 | * cdf_nbuf_tailroom() - amount of tail space available |
| 519 | * @buf: Network buffer |
| 520 | * |
| 521 | * Return: amount of tail room |
| 522 | */ |
| 523 | static inline uint32_t cdf_nbuf_tailroom(cdf_nbuf_t buf) |
| 524 | { |
| 525 | return __cdf_nbuf_tailroom(buf); |
| 526 | } |
| 527 | |
| 528 | /** |
| 529 | * cdf_nbuf_push_head() - push data in the front |
| 530 | * @buf: Network buf instance |
| 531 | * @size: Size to be pushed |
| 532 | * |
| 533 | * Return: New data pointer of this buf after data has been pushed, |
| 534 | * or NULL if there is not enough room in this buf. |
| 535 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 536 | static inline uint8_t *cdf_nbuf_push_head(cdf_nbuf_t buf, qdf_size_t size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 537 | { |
| 538 | return __cdf_nbuf_push_head(buf, size); |
| 539 | } |
| 540 | |
| 541 | /** |
| 542 | * cdf_nbuf_put_tail() - puts data in the end |
| 543 | * @buf: Network buf instance |
| 544 | * @size: Size to be pushed |
| 545 | * |
| 546 | * Return: Data pointer of this buf where new data has to be |
| 547 | * put, or NULL if there is not enough room in this buf. |
| 548 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 549 | static inline uint8_t *cdf_nbuf_put_tail(cdf_nbuf_t buf, qdf_size_t size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 550 | { |
| 551 | return __cdf_nbuf_put_tail(buf, size); |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * cdf_nbuf_pull_head() - pull data out from the front |
| 556 | * @buf: Network buf instance |
| 557 | * @size: Size to be popped |
| 558 | * |
| 559 | * Return: New data pointer of this buf after data has been popped, |
| 560 | * or NULL if there is not sufficient data to pull. |
| 561 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 562 | static inline uint8_t *cdf_nbuf_pull_head(cdf_nbuf_t buf, qdf_size_t size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | { |
| 564 | return __cdf_nbuf_pull_head(buf, size); |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * cdf_nbuf_trim_tail() - trim data out from the end |
| 569 | * @buf: Network buf instance |
| 570 | * @size: Size to be popped |
| 571 | * |
| 572 | * Return: none |
| 573 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 574 | static inline void cdf_nbuf_trim_tail(cdf_nbuf_t buf, qdf_size_t size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 575 | { |
| 576 | __cdf_nbuf_trim_tail(buf, size); |
| 577 | } |
| 578 | |
| 579 | /** |
| 580 | * cdf_nbuf_len() - get the length of the buf |
| 581 | * @buf: Network buf instance |
| 582 | * |
| 583 | * Return: total length of this buf. |
| 584 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 585 | static inline qdf_size_t cdf_nbuf_len(cdf_nbuf_t buf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 586 | { |
| 587 | return __cdf_nbuf_len(buf); |
| 588 | } |
| 589 | |
| 590 | /** |
| 591 | * cdf_nbuf_set_pktlen() - set the length of the buf |
| 592 | * @buf: Network buf instance |
| 593 | * @size: Size to be set |
| 594 | * |
| 595 | * Return: none |
| 596 | */ |
| 597 | static inline void cdf_nbuf_set_pktlen(cdf_nbuf_t buf, uint32_t len) |
| 598 | { |
| 599 | __cdf_nbuf_set_pktlen(buf, len); |
| 600 | } |
| 601 | |
| 602 | /** |
| 603 | * cdf_nbuf_reserve() - trim data out from the end |
| 604 | * @buf: Network buf instance |
| 605 | * @size: Size to be popped |
| 606 | * |
| 607 | * Return: none |
| 608 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 609 | static inline void cdf_nbuf_reserve(cdf_nbuf_t buf, qdf_size_t size) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 610 | { |
| 611 | __cdf_nbuf_reserve(buf, size); |
| 612 | } |
| 613 | |
| 614 | /** |
| 615 | * cdf_nbuf_peek_header() - return the data pointer & length of the header |
| 616 | * @buf: Network nbuf |
| 617 | * @addr: Data pointer |
| 618 | * @len: Length of the data |
| 619 | * |
| 620 | * Return: none |
| 621 | */ |
| 622 | static inline void |
| 623 | cdf_nbuf_peek_header(cdf_nbuf_t buf, uint8_t **addr, uint32_t *len) |
| 624 | { |
| 625 | __cdf_nbuf_peek_header(buf, addr, len); |
| 626 | } |
| 627 | |
| 628 | /* nbuf private context routines */ |
| 629 | |
| 630 | /* nbuf queue routines */ |
| 631 | |
| 632 | /** |
| 633 | * cdf_nbuf_queue_init() - initialize buf queue |
| 634 | * @head: Network buf queue head |
| 635 | * |
| 636 | * Return: none |
| 637 | */ |
| 638 | static inline void cdf_nbuf_queue_init(cdf_nbuf_queue_t *head) |
| 639 | { |
| 640 | __cdf_nbuf_queue_init(head); |
| 641 | } |
| 642 | |
| 643 | /** |
| 644 | * cdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue |
| 645 | * @head: Network buf queue head |
| 646 | * @buf: Network buf |
| 647 | * |
| 648 | * Return: none |
| 649 | */ |
| 650 | static inline void cdf_nbuf_queue_add(cdf_nbuf_queue_t *head, cdf_nbuf_t buf) |
| 651 | { |
| 652 | __cdf_nbuf_queue_add(head, buf); |
| 653 | } |
| 654 | |
| 655 | /** |
| 656 | * cdf_nbuf_queue_insert_head() - insert nbuf at the head of queue |
| 657 | * @head: Network buf queue head |
| 658 | * @buf: Network buf |
| 659 | * |
| 660 | * Return: none |
| 661 | */ |
| 662 | static inline void |
| 663 | cdf_nbuf_queue_insert_head(cdf_nbuf_queue_t *head, cdf_nbuf_t buf) |
| 664 | { |
| 665 | __cdf_nbuf_queue_insert_head(head, buf); |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * cdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue |
| 670 | * @head: Network buf queue head |
| 671 | * |
| 672 | * Return: The head buf in the buf queue. |
| 673 | */ |
| 674 | static inline cdf_nbuf_t cdf_nbuf_queue_remove(cdf_nbuf_queue_t *head) |
| 675 | { |
| 676 | return __cdf_nbuf_queue_remove(head); |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * cdf_nbuf_queue_len() - get the length of the queue |
| 681 | * @head: Network buf queue head |
| 682 | * |
| 683 | * Return: length of the queue |
| 684 | */ |
| 685 | static inline uint32_t cdf_nbuf_queue_len(cdf_nbuf_queue_t *head) |
| 686 | { |
| 687 | return __cdf_nbuf_queue_len(head); |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * cdf_nbuf_queue_next() - get the next guy/packet of the given buffer |
| 692 | * @buf: Network buffer |
| 693 | * |
| 694 | * Return: next buffer/packet |
| 695 | */ |
| 696 | static inline cdf_nbuf_t cdf_nbuf_queue_next(cdf_nbuf_t buf) |
| 697 | { |
| 698 | return __cdf_nbuf_queue_next(buf); |
| 699 | } |
| 700 | |
| 701 | /** |
| 702 | * @cdf_nbuf_is_queue_empty() - check if the buf queue is empty |
| 703 | * @nbq: Network buf queue handle |
| 704 | * |
| 705 | * Return: true if queue is empty |
| 706 | * false if queue is not emty |
| 707 | */ |
| 708 | static inline bool cdf_nbuf_is_queue_empty(cdf_nbuf_queue_t *nbq) |
| 709 | { |
| 710 | return __cdf_nbuf_is_queue_empty(nbq); |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * cdf_nbuf_next() - get the next packet in the linked list |
| 715 | * @buf: Network buffer |
| 716 | * |
| 717 | * This function can be used when nbufs are directly linked into a list, |
| 718 | * rather than using a separate network buffer queue object. |
| 719 | * |
| 720 | * Return: next network buffer in the linked list |
| 721 | */ |
| 722 | static inline cdf_nbuf_t cdf_nbuf_next(cdf_nbuf_t buf) |
| 723 | { |
| 724 | return __cdf_nbuf_next(buf); |
| 725 | } |
| 726 | |
| 727 | /** |
| 728 | * cdf_nbuf_get_protocol() - return the protocol value of the skb |
| 729 | * @skb: Pointer to network buffer |
| 730 | * |
| 731 | * Return: skb protocol |
| 732 | */ |
| 733 | static inline uint16_t cdf_nbuf_get_protocol(struct sk_buff *skb) |
| 734 | { |
| 735 | return __cdf_nbuf_get_protocol(skb); |
| 736 | } |
| 737 | |
| 738 | /** |
| 739 | * cdf_nbuf_get_ip_summed() - return the ip checksum value of the skb |
| 740 | * @skb: Pointer to network buffer |
| 741 | * |
| 742 | * Return: skb ip_summed |
| 743 | */ |
| 744 | static inline uint8_t cdf_nbuf_get_ip_summed(struct sk_buff *skb) |
| 745 | { |
| 746 | return __cdf_nbuf_get_ip_summed(skb); |
| 747 | } |
| 748 | |
| 749 | /** |
| 750 | * cdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb |
| 751 | * @skb: Pointer to network buffer |
| 752 | * @ip_summed: ip checksum |
| 753 | * |
| 754 | * Return: none |
| 755 | */ |
| 756 | static inline void cdf_nbuf_set_ip_summed(struct sk_buff *skb, uint8_t ip_summed) |
| 757 | { |
| 758 | __cdf_nbuf_set_ip_summed(skb, ip_summed); |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * cdf_nbuf_set_next() - add a packet to a linked list |
| 763 | * @this_buf: Predecessor buffer |
| 764 | * @next_buf: Successor buffer |
| 765 | * |
| 766 | * This function can be used to directly link nbufs, rather than using |
| 767 | * a separate network buffer queue object. |
| 768 | * |
| 769 | * Return: none |
| 770 | */ |
| 771 | static inline void cdf_nbuf_set_next(cdf_nbuf_t this_buf, cdf_nbuf_t next_buf) |
| 772 | { |
| 773 | __cdf_nbuf_set_next(this_buf, next_buf); |
| 774 | } |
| 775 | |
| 776 | /* nbuf extension routines */ |
| 777 | |
| 778 | /** |
| 779 | * cdf_nbuf_set_next_ext() - link extension of this packet contained in a new |
| 780 | * nbuf |
| 781 | * @this_buf: predecessor buffer |
| 782 | * @next_buf: successor buffer |
| 783 | * |
| 784 | * This function is used to link up many nbufs containing a single logical |
| 785 | * packet - not a collection of packets. Do not use for linking the first |
| 786 | * extension to the head |
| 787 | * |
| 788 | * Return: none |
| 789 | */ |
| 790 | static inline void |
| 791 | cdf_nbuf_set_next_ext(cdf_nbuf_t this_buf, cdf_nbuf_t next_buf) |
| 792 | { |
| 793 | __cdf_nbuf_set_next_ext(this_buf, next_buf); |
| 794 | } |
| 795 | |
| 796 | /** |
| 797 | * cdf_nbuf_next_ext() - get the next packet extension in the linked list |
| 798 | * @buf: Network buffer |
| 799 | * |
| 800 | * Return: Next network buffer in the linked list |
| 801 | */ |
| 802 | static inline cdf_nbuf_t cdf_nbuf_next_ext(cdf_nbuf_t buf) |
| 803 | { |
| 804 | return __cdf_nbuf_next_ext(buf); |
| 805 | } |
| 806 | |
| 807 | /** |
| 808 | * cdf_nbuf_append_ext_list() - link list of packet extensions to the head |
| 809 | * segment |
| 810 | * @head_buf: Network buf holding head segment (single) |
| 811 | * @ext_list: Network buf list holding linked extensions to the head |
| 812 | * @ext_len: Total length of all buffers in the extension list |
| 813 | * |
| 814 | * This function is used to link up a list of packet extensions (seg1, 2, |
| 815 | * ...) to the nbuf holding the head segment (seg0) |
| 816 | * |
| 817 | * Return: none |
| 818 | */ |
| 819 | static inline void |
| 820 | cdf_nbuf_append_ext_list(cdf_nbuf_t head_buf, cdf_nbuf_t ext_list, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 821 | qdf_size_t ext_len) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | { |
| 823 | __cdf_nbuf_append_ext_list(head_buf, ext_list, ext_len); |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * cdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand |
| 828 | * @buf: Network buffer |
| 829 | * |
| 830 | * Return: cdf_nbuf_tx_cksum_t checksum offload demand for the frame |
| 831 | */ |
| 832 | static inline cdf_nbuf_tx_cksum_t cdf_nbuf_get_tx_cksum(cdf_nbuf_t buf) |
| 833 | { |
| 834 | return __cdf_nbuf_get_tx_cksum(buf); |
| 835 | } |
| 836 | |
| 837 | /** |
| 838 | * cdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to |
| 839 | * indicate checksum info to the stack. |
| 840 | * @buf: Network buffer |
| 841 | * @cksum: Checksum |
| 842 | * |
| 843 | * Return: none |
| 844 | */ |
| 845 | static inline void |
| 846 | cdf_nbuf_set_rx_cksum(cdf_nbuf_t buf, cdf_nbuf_rx_cksum_t *cksum) |
| 847 | { |
| 848 | __cdf_nbuf_set_rx_cksum(buf, cksum); |
| 849 | } |
| 850 | |
| 851 | /** |
| 852 | * cdf_nbuf_get_tid() - this function extracts the TID value from nbuf |
| 853 | * @buf: Network buffer |
| 854 | * |
| 855 | * Return: TID value |
| 856 | */ |
| 857 | static inline uint8_t cdf_nbuf_get_tid(cdf_nbuf_t buf) |
| 858 | { |
| 859 | return __cdf_nbuf_get_tid(buf); |
| 860 | } |
| 861 | |
| 862 | /** |
| 863 | * cdf_nbuf_set_tid() - this function sets the TID value in nbuf |
| 864 | * @buf: Network buffer |
| 865 | * @tid: TID value |
| 866 | * |
| 867 | * Return: none |
| 868 | */ |
| 869 | static inline void cdf_nbuf_set_tid(cdf_nbuf_t buf, uint8_t tid) |
| 870 | { |
| 871 | __cdf_nbuf_set_tid(buf, tid); |
| 872 | } |
| 873 | |
| 874 | /** |
| 875 | * cdf_nbuf_get_exemption_type() - this function extracts the exemption type |
| 876 | * from nbuf |
| 877 | * @buf: Network buffer |
| 878 | * |
| 879 | * Return: Exemption type |
| 880 | */ |
| 881 | static inline uint8_t cdf_nbuf_get_exemption_type(cdf_nbuf_t buf) |
| 882 | { |
| 883 | return __cdf_nbuf_get_exemption_type(buf); |
| 884 | } |
| 885 | |
| 886 | /** |
| 887 | * cdf_nbuf_set_protocol() - this function peeks data into the buffer at given |
| 888 | * offset |
| 889 | * @buf: Network buffer |
| 890 | * @proto: Protocol |
| 891 | * |
| 892 | * Return: none |
| 893 | */ |
| 894 | static inline void cdf_nbuf_set_protocol(cdf_nbuf_t buf, uint16_t proto) |
| 895 | { |
| 896 | __cdf_nbuf_set_protocol(buf, proto); |
| 897 | } |
| 898 | |
| 899 | /** |
| 900 | * cdf_nbuf_trace_get_proto_type() - this function return packet proto type |
| 901 | * @buf: Network buffer |
| 902 | * |
| 903 | * Return: Packet protocol type |
| 904 | */ |
| 905 | static inline uint8_t cdf_nbuf_trace_get_proto_type(cdf_nbuf_t buf) |
| 906 | { |
| 907 | return __cdf_nbuf_trace_get_proto_type(buf); |
| 908 | } |
| 909 | |
| 910 | #ifdef QCA_PKT_PROTO_TRACE |
| 911 | /** |
| 912 | * cdf_nbuf_trace_set_proto_type() - this function updates packet proto type |
| 913 | * @buf: Network buffer |
| 914 | * @proto_type: Protocol type |
| 915 | * |
| 916 | * Return: none |
| 917 | */ |
| 918 | static inline void |
| 919 | cdf_nbuf_trace_set_proto_type(cdf_nbuf_t buf, uint8_t proto_type) |
| 920 | { |
| 921 | __cdf_nbuf_trace_set_proto_type(buf, proto_type); |
| 922 | } |
| 923 | #else |
| 924 | #define cdf_nbuf_trace_set_proto_type(buf, proto_type) /*NO OP*/ |
| 925 | #endif |
| 926 | |
| 927 | /** |
| 928 | * cdf_nbuf_reg_trace_cb() - this function registers protocol trace callback |
| 929 | * @cb_func_ptr: Callback pointer |
| 930 | * |
| 931 | * Return: none |
| 932 | */ |
| 933 | static inline void cdf_nbuf_reg_trace_cb(cdf_nbuf_trace_update_t cb_func_ptr) |
| 934 | { |
| 935 | __cdf_nbuf_reg_trace_cb(cb_func_ptr); |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | * cdf_nbuf_trace_update() - this function updates protocol event |
| 940 | * @buf: Network buffer |
| 941 | * @event_string: Event string pointer |
| 942 | * |
| 943 | * Return: none |
| 944 | */ |
| 945 | static inline void cdf_nbuf_trace_update(cdf_nbuf_t buf, char *event_string) |
| 946 | { |
| 947 | __cdf_nbuf_trace_update(buf, event_string); |
| 948 | } |
| 949 | |
| 950 | /** |
| 951 | * cdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download |
| 952 | * @buf: Network buffer |
| 953 | * @candi: Candidate of parallel download frame |
| 954 | * |
| 955 | * This function stores a flag specifying this TX frame is suitable for |
| 956 | * downloading though a 2nd TX data pipe that is used for short frames for |
| 957 | * protocols that can accept out-of-order delivery. |
| 958 | * |
| 959 | * Return: none |
| 960 | */ |
| 961 | static inline void |
| 962 | cdf_nbuf_set_tx_parallel_dnload_frm(cdf_nbuf_t buf, uint8_t candi) |
| 963 | { |
| 964 | __cdf_nbuf_set_tx_htt2_frm(buf, candi); |
| 965 | } |
| 966 | |
| 967 | /** |
| 968 | * cdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download |
| 969 | * @buf: Network buffer |
| 970 | * |
| 971 | * This function return whether this TX frame is allow to download though a 2nd |
| 972 | * TX data pipe or not. |
| 973 | * |
| 974 | * Return: none |
| 975 | */ |
| 976 | static inline uint8_t cdf_nbuf_get_tx_parallel_dnload_frm(cdf_nbuf_t buf) |
| 977 | { |
| 978 | return __cdf_nbuf_get_tx_htt2_frm(buf); |
| 979 | } |
| 980 | |
| 981 | /** |
| 982 | * cdf_invalidate_range() - invalidate the virtual address range specified by |
| 983 | * start and end addresses. |
| 984 | * Note: This does not write back the cache entries. |
| 985 | * |
| 986 | * Return: none |
| 987 | */ |
Ryan Hsu | ceb390c | 2016-01-21 23:00:43 -0800 | [diff] [blame] | 988 | |
| 989 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | static inline void cdf_invalidate_range(void *start, void *end) |
| 991 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 992 | dmac_inv_range(start, end); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | } |
Ryan Hsu | ceb390c | 2016-01-21 23:00:43 -0800 | [diff] [blame] | 994 | #else |
| 995 | static inline void cdf_invalidate_range(void *start, void *end) |
| 996 | { |
| 997 | } |
| 998 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | |
| 1000 | #if defined(FEATURE_TSO) |
| 1001 | /** |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1002 | * cdf_nbuf_reset_num_frags() - resets the number of frags to 0 (valid range: 0..1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1003 | * @buf: Network buffer |
| 1004 | * |
| 1005 | * Return: Number of fragments |
| 1006 | */ |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1007 | static inline int cdf_nbuf_reset_num_frags(cdf_nbuf_t buf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | { |
Houston Hoffman | 43d47fa | 2016-02-24 16:34:30 -0800 | [diff] [blame] | 1009 | return __cdf_nbuf_reset_num_frags(buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | /** |
| 1013 | * cdf_nbuf_is_tso() - is the network buffer a jumbo packet? |
| 1014 | * @buf: Network buffer |
| 1015 | * |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 1016 | * Return: true - jumbo packet false - not a jumbo packet |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1017 | */ |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 1018 | static inline bool cdf_nbuf_is_tso(cdf_nbuf_t nbuf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1019 | { |
| 1020 | return __cdf_nbuf_is_tso(nbuf); |
| 1021 | } |
| 1022 | |
| 1023 | /** |
| 1024 | * cdf_nbuf_get_tso_info() - function to divide a jumbo TSO |
| 1025 | * network buffer into segments |
| 1026 | * @nbuf: network buffer to be segmented |
| 1027 | * @tso_info: This is the output. The information about the |
| 1028 | * TSO segments will be populated within this. |
| 1029 | * |
| 1030 | * This function fragments a TCP jumbo packet into smaller |
| 1031 | * segments to be transmitted by the driver. It chains the TSO |
| 1032 | * segments created into a list. |
| 1033 | * |
| 1034 | * Return: number of TSO segments |
| 1035 | */ |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame^] | 1036 | static inline uint32_t cdf_nbuf_get_tso_info(qdf_device_t osdev, |
| 1037 | cdf_nbuf_t nbuf, struct qdf_tso_info_t *tso_info) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | { |
| 1039 | return __cdf_nbuf_get_tso_info(osdev, nbuf, tso_info); |
| 1040 | } |
| 1041 | |
| 1042 | /** |
| 1043 | * cdf_nbuf_get_tso_num_seg() - function to calculate the number |
| 1044 | * of TCP segments within the TSO jumbo packet |
| 1045 | * @nbuf: TSO jumbo network buffer to be segmented |
| 1046 | * |
| 1047 | * This function calculates the number of TCP segments that the |
| 1048 | network buffer can be divided into. |
| 1049 | * |
| 1050 | * Return: number of TCP segments |
| 1051 | */ |
| 1052 | static inline uint32_t cdf_nbuf_get_tso_num_seg(cdf_nbuf_t nbuf) |
| 1053 | { |
| 1054 | return __cdf_nbuf_get_tso_num_seg(nbuf); |
| 1055 | } |
| 1056 | |
| 1057 | /** |
| 1058 | * cdf_nbuf_inc_users() - function to increment the number of |
| 1059 | * users referencing this network buffer |
| 1060 | * |
| 1061 | * @nbuf: network buffer |
| 1062 | * |
| 1063 | * This function increments the number of users referencing this |
| 1064 | * network buffer |
| 1065 | * |
| 1066 | * Return: the network buffer |
| 1067 | */ |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 1068 | static inline void cdf_nbuf_inc_users(cdf_nbuf_t nbuf) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1069 | { |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 1070 | __cdf_nbuf_inc_users(nbuf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1071 | } |
| 1072 | #endif /*TSO*/ |
| 1073 | |
| 1074 | /** |
| 1075 | * cdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb |
| 1076 | * |
| 1077 | * @nbuf: Network buffer (skb on linux) |
| 1078 | * |
| 1079 | * This function returns the values of data_attr field |
| 1080 | * in struct cvg_nbuf_cb{}, to which skb->cb is typecast. |
| 1081 | * This value is actually the value programmed in CE descriptor. |
| 1082 | * |
| 1083 | * Return: Value of data_attr |
| 1084 | */ |
| 1085 | static inline |
| 1086 | uint32_t cdf_nbuf_data_attr_get(cdf_nbuf_t buf) |
| 1087 | { |
| 1088 | return __cdf_nbuf_data_attr_get(buf); |
| 1089 | } |
| 1090 | |
| 1091 | /** |
| 1092 | * cdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb |
| 1093 | * |
| 1094 | * @nbuf: Network buffer (skb on linux) |
| 1095 | * @data_attr: Value to be stored cvg_nbuf_cb->data_attr |
| 1096 | * |
| 1097 | * This function stores the value to be programmed in CE |
| 1098 | * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{} |
| 1099 | * |
| 1100 | * Return: void |
| 1101 | */ |
| 1102 | static inline |
| 1103 | void cdf_nbuf_data_attr_set(cdf_nbuf_t buf, uint32_t data_attr) |
| 1104 | { |
| 1105 | __cdf_nbuf_data_attr_set(buf, data_attr); |
| 1106 | } |
| 1107 | |
| 1108 | /** |
| 1109 | * cdf_nbuf_tx_info_get() - Parse skb and get Tx metadata |
| 1110 | * |
| 1111 | * @nbuf: Network buffer (skb on linux) |
| 1112 | * |
| 1113 | * This function parses the payload to figure out relevant |
| 1114 | * Tx meta-data e.g. whether to enable tx_classify bit |
| 1115 | * in CE. |
| 1116 | * |
| 1117 | * Return: void |
| 1118 | */ |
| 1119 | #define cdf_nbuf_tx_info_get __cdf_nbuf_tx_info_get |
| 1120 | |
| 1121 | void cdf_nbuf_set_state(cdf_nbuf_t nbuf, uint8_t current_state); |
| 1122 | void cdf_nbuf_tx_desc_count_display(void); |
| 1123 | void cdf_nbuf_tx_desc_count_clear(void); |
| 1124 | |
| 1125 | #endif |