123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053 |
- /*
- * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
- *
- * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
- *
- *
- * Permission to use, copy, modify, and/or distribute this software for
- * any purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
- /*
- * This file was originally distributed by Qualcomm Atheros, Inc.
- * under proprietary terms before Copyright ownership was assigned
- * to the Linux Foundation.
- */
- /**
- * DOC: cdf_nbuf_public network buffer API
- * This file defines the network buffer abstraction.
- */
- #ifndef _CDF_NBUF_H
- #define _CDF_NBUF_H
- #include <cdf_util.h>
- #include <cdf_types.h>
- #include <cdf_net_types.h>
- #include <cdf_lock.h>
- #include <i_cdf_nbuf.h>
- #include <asm/cacheflush.h>
- #define IPA_NBUF_OWNER_ID 0xaa55aa55
- #define NBUF_PKT_TRAC_TYPE_EAPOL 0x02
- #define NBUF_PKT_TRAC_TYPE_DHCP 0x04
- #define NBUF_PKT_TRAC_TYPE_MGMT_ACTION 0x08
- #define NBUF_PKT_TRAC_MAX_STRING 12
- #define NBUF_PKT_TRAC_PROTO_STRING 4
- #define NBUF_PKT_ERROR 1
- /* Tracked Packet types */
- #define NBUF_TX_PKT_INVALID 0
- #define NBUF_TX_PKT_DATA_TRACK 1
- #define NBUF_TX_PKT_MGMT_TRACK 2
- /* Different Packet states */
- #define NBUF_TX_PKT_HDD 1
- #define NBUF_TX_PKT_TXRX_ENQUEUE 2
- #define NBUF_TX_PKT_TXRX_DEQUEUE 3
- #define NBUF_TX_PKT_TXRX 4
- #define NBUF_TX_PKT_HTT 5
- #define NBUF_TX_PKT_HTC 6
- #define NBUF_TX_PKT_HIF 7
- #define NBUF_TX_PKT_CE 8
- #define NBUF_TX_PKT_FREE 9
- #define NBUF_TX_PKT_STATE_MAX 10
- /**
- * @cdf_nbuf_t - Platform indepedent packet abstraction
- */
- typedef __cdf_nbuf_t cdf_nbuf_t;
- /**
- * @cdf_dma_map_cb_t - Dma map callback prototype
- */
- typedef void (*cdf_dma_map_cb_t)(void *arg, cdf_nbuf_t buf,
- cdf_dma_map_t dmap);
- /**
- * @__CDF_NBUF_NULL - invalid handle
- */
- #define CDF_NBUF_NULL __CDF_NBUF_NULL
- /**
- * @cdf_nbuf_queue_t - Platform independent packet queue abstraction
- */
- typedef __cdf_nbuf_queue_t cdf_nbuf_queue_t;
- /* BUS/DMA mapping routines */
- /**
- * cdf_nbuf_map() - map a buffer to local bus address space
- * @osdev: OS device
- * @buf: Buf to be mapped (mapping info is stored in the buf's meta-data area)
- * @dir: DMA direction
- *
- * Return: Status of the operation
- */
- static inline CDF_STATUS
- cdf_nbuf_map(cdf_device_t osdev, cdf_nbuf_t buf, cdf_dma_dir_t dir)
- {
- return __cdf_nbuf_map(osdev, buf, dir);
- }
- /**
- * cdf_nbuf_unmap() - unmap a previously mapped buf
- * @osdev: OS device
- * @buf: Buf to be unmapped (mapping info is stored in the buf's meta-data area)
- * @dir: DMA direction
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_unmap(cdf_device_t osdev, cdf_nbuf_t buf, cdf_dma_dir_t dir)
- {
- __cdf_nbuf_unmap(osdev, buf, dir);
- }
- /**
- * cdf_nbuf_map_single() - map a single buffer to local bus address space
- * @osdev: OS device
- * @buf: Buf to be mapped (mapping info is stored in the buf's meta-data area)
- * @dir: DMA direction
- *
- * Return: Status of the operation
- */
- static inline CDF_STATUS
- cdf_nbuf_map_single(cdf_device_t osdev, cdf_nbuf_t buf, cdf_dma_dir_t dir)
- {
- return __cdf_nbuf_map_single(osdev, buf, dir);
- }
- /**
- * cdf_nbuf_unmap_single() - unmap a previously mapped buf
- * @osdev: OS device
- * @buf: Buf to be unmapped (mapping info is stored in the buf's meta-data area)
- * @dir: DMA direction
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_unmap_single(cdf_device_t osdev, cdf_nbuf_t buf, cdf_dma_dir_t dir)
- {
- __cdf_nbuf_unmap_single(osdev, buf, dir);
- }
- /**
- * cdf_nbuf_get_num_frags() - get number of fragments
- * @buf: Network buffer
- *
- * Return: Number of fragments
- */
- static inline int cdf_nbuf_get_num_frags(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_get_num_frags(buf);
- }
- /**
- * cdf_nbuf_get_frag_len() - get fragment length
- * @buf: Network buffer
- * @frag_num: Fragment number
- *
- * Return: Fragment length
- */
- static inline int cdf_nbuf_get_frag_len(cdf_nbuf_t buf, int frag_num)
- {
- return __cdf_nbuf_get_frag_len(buf, frag_num);
- }
- /**
- * cdf_nbuf_get_frag_vaddr() - get fragment virtual address
- * @buf: Network buffer
- * @frag_num: Fragment number
- *
- * Return: Fragment virtual address
- */
- static inline unsigned char *cdf_nbuf_get_frag_vaddr(cdf_nbuf_t buf,
- int frag_num)
- {
- return __cdf_nbuf_get_frag_vaddr(buf, frag_num);
- }
- /**
- * cdf_nbuf_get_frag_paddr_lo() - get fragment physical address low order bytes
- * @buf: Network buffer
- * @frag_num: Fragment number
- *
- * Return: Fragment physical address lo
- */
- static inline uint32_t cdf_nbuf_get_frag_paddr_lo(cdf_nbuf_t buf, int frag_num)
- {
- return __cdf_nbuf_get_frag_paddr_lo(buf, frag_num);
- }
- /**
- * cdf_nbuf_get_frag_is_wordstream() - is fragment wordstream
- * @buf: Network buffer
- * @frag_num: Fragment number
- *
- * Return: Fragment wordstream or not
- */
- static inline int cdf_nbuf_get_frag_is_wordstream(cdf_nbuf_t buf, int frag_num)
- {
- return __cdf_nbuf_get_frag_is_wordstream(buf, frag_num);
- }
- /**
- * cdf_nbuf_set_frag_is_wordstream() - set fragment wordstream
- * @buf: Network buffer
- * @frag_num: Fragment number
- * @is_wordstream: Wordstream
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_set_frag_is_wordstream(cdf_nbuf_t buf, int frag_num, int is_wordstream)
- {
- __cdf_nbuf_set_frag_is_wordstream(buf, frag_num, is_wordstream);
- }
- /**
- * cdf_nbuf_frag_push_head() - push fragment head
- * @buf: Network buffer
- * @frag_len: Fragment length
- * @frag_vaddr: Fragment virtual address
- * @frag_paddr_lo: Fragment physical address lo
- * @frag_paddr_hi: Fragment physical address hi
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_frag_push_head(cdf_nbuf_t buf,
- int frag_len,
- char *frag_vaddr,
- uint32_t frag_paddr_lo, uint32_t frag_paddr_hi)
- {
- __cdf_nbuf_frag_push_head(buf, frag_len, frag_vaddr, frag_paddr_lo,
- frag_paddr_hi);
- }
- #ifdef MEMORY_DEBUG
- void cdf_net_buf_debug_init(void);
- void cdf_net_buf_debug_exit(void);
- void cdf_net_buf_debug_clean(void);
- void cdf_net_buf_debug_add_node(cdf_nbuf_t net_buf, size_t size,
- uint8_t *file_name, uint32_t line_num);
- void cdf_net_buf_debug_delete_node(cdf_nbuf_t net_buf);
- void cdf_net_buf_debug_release_skb(cdf_nbuf_t net_buf);
- /* nbuf allocation rouines */
- /**
- * cdf_nbuf_alloc() - Allocate cdf_nbuf
- * @hdl: Platform device object
- * @size: Data buffer size for this cdf_nbuf including max header
- * size
- * @reserve: Headroom to start with.
- * @align: Alignment for the start buffer.
- * @prio: Indicate if the nbuf is high priority (some OSes e.g darwin
- * polls few times if allocation fails and priority is true)
- *
- * The nbuf created is guarenteed to have only 1 physical segment
- *
- * Return: The new cdf_nbuf instance or NULL if there's not enough memory.
- */
- #define cdf_nbuf_alloc(d, s, r, a, p) \
- cdf_nbuf_alloc_debug(d, s, r, a, p, __FILE__, __LINE__)
- static inline cdf_nbuf_t
- cdf_nbuf_alloc_debug(cdf_device_t osdev, cdf_size_t size, int reserve,
- int align, int prio, uint8_t *file_name,
- uint32_t line_num)
- {
- cdf_nbuf_t net_buf;
- net_buf = __cdf_nbuf_alloc(osdev, size, reserve, align, prio);
- /* Store SKB in internal CDF tracking table */
- if (cdf_likely(net_buf))
- cdf_net_buf_debug_add_node(net_buf, size, file_name, line_num);
- return net_buf;
- }
- /**
- * cdf_nbuf_free() - free cdf_nbuf
- * @net_buf: Network buffer to free
- *
- * Return: none
- */
- static inline void cdf_nbuf_free(cdf_nbuf_t net_buf)
- {
- /* Remove SKB from internal CDF tracking table */
- if (cdf_likely(net_buf))
- cdf_net_buf_debug_delete_node(net_buf);
- __cdf_nbuf_free(net_buf);
- }
- #else
- static inline void cdf_net_buf_debug_release_skb(cdf_nbuf_t net_buf)
- {
- return;
- }
- /* Nbuf allocation rouines */
- /**
- * cdf_nbuf_alloc() - allocate cdf_nbuf
- * @hdl: Platform device object
- * @size: Data buffer size for this cdf_nbuf including max header
- * size
- * @reserve: Headroom to start with.
- * @align: Alignment for the start buffer.
- * @prio: Indicate if the nbuf is high priority (some OSes e.g darwin
- * polls few times if allocation fails and priority is true)
- *
- * The nbuf created is guarenteed to have only 1 physical segment
- *
- * Return: new cdf_nbuf instance or NULL if there's not enough memory.
- */
- static inline cdf_nbuf_t
- cdf_nbuf_alloc(cdf_device_t osdev,
- cdf_size_t size, int reserve, int align, int prio)
- {
- return __cdf_nbuf_alloc(osdev, size, reserve, align, prio);
- }
- /**
- * cdf_nbuf_free() - free cdf_nbuf
- * @buf: Network buffer to free
- *
- * Return: none
- */
- static inline void cdf_nbuf_free(cdf_nbuf_t buf)
- {
- __cdf_nbuf_free(buf);
- }
- #endif
- /**
- * cdf_nbuf_tx_free() - free a list of cdf_nbufs and tell the OS their tx
- * status (if req'd)
- * @bufs: List of netbufs to free
- * @tx_err: Whether the tx frames were transmitted successfully
- *
- * Return: none
- */
- static inline void cdf_nbuf_tx_free(cdf_nbuf_t buf_list, int tx_err)
- {
- __cdf_nbuf_tx_free(buf_list, tx_err);
- }
- /**
- * cdf_nbuf_copy() - copy src buffer into dst.
- * @buf: source nbuf to copy from
- *
- * This API is useful, for example, because most native buffer provide a way to
- * copy a chain into a single buffer. Therefore as a side effect, it also
- * "linearizes" a buffer (which is perhaps why you'll use it mostly). It
- * creates a writeable copy.
- *
- *
- * Return: new nbuf
- */
- static inline cdf_nbuf_t cdf_nbuf_copy(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_copy(buf);
- }
- /**
- * cdf_nbuf_cat() - link two nbufs, the new buf is piggybacked into older one
- * @dst: Buffer to piggyback into
- * @src: Buffer to put
- *
- * Return: Status of the call - 0 successful
- */
- static inline CDF_STATUS cdf_nbuf_cat(cdf_nbuf_t dst, cdf_nbuf_t src)
- {
- return __cdf_nbuf_cat(dst, src);
- }
- /**
- * @cdf_nbuf_copy_bits() - return the length of the copy bits for skb
- * @skb: SKB pointer
- * @offset: offset
- * @len: Length
- * @to: To
- *
- * Return: int32_t
- */
- static inline int32_t
- cdf_nbuf_copy_bits(cdf_nbuf_t nbuf, uint32_t offset, uint32_t len, void *to)
- {
- return __cdf_nbuf_copy_bits(nbuf, offset, len, to);
- }
- /**
- * cdf_nbuf_clone() - clone the nbuf (copy is readonly)
- * @buf: nbuf to clone from
- *
- * Return: cloned buffer
- */
- static inline cdf_nbuf_t cdf_nbuf_clone(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_clone(buf);
- }
- /* nbuf manipulation routines */
- /**
- * @cdf_nbuf_head() - return the address of an nbuf's buffer
- * @buf: netbuf
- *
- * Return: head address
- */
- static inline uint8_t *cdf_nbuf_head(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_head(buf);
- }
- /**
- * cdf_nbuf_data() - Return the address of the start of data within an nbuf
- * @buf: Network buffer
- *
- * Return: Data address
- */
- static inline uint8_t *cdf_nbuf_data(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_data(buf);
- }
- /**
- * cdf_nbuf_headroom() - amount of headroom int the current nbuf
- * @buf: Network buffer
- *
- * Return: Amount of head room
- */
- static inline uint32_t cdf_nbuf_headroom(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_headroom(buf);
- }
- /**
- * cdf_nbuf_tailroom() - amount of tail space available
- * @buf: Network buffer
- *
- * Return: amount of tail room
- */
- static inline uint32_t cdf_nbuf_tailroom(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_tailroom(buf);
- }
- /**
- * cdf_nbuf_push_head() - push data in the front
- * @buf: Network buf instance
- * @size: Size to be pushed
- *
- * Return: New data pointer of this buf after data has been pushed,
- * or NULL if there is not enough room in this buf.
- */
- static inline uint8_t *cdf_nbuf_push_head(cdf_nbuf_t buf, cdf_size_t size)
- {
- return __cdf_nbuf_push_head(buf, size);
- }
- /**
- * cdf_nbuf_put_tail() - puts data in the end
- * @buf: Network buf instance
- * @size: Size to be pushed
- *
- * Return: Data pointer of this buf where new data has to be
- * put, or NULL if there is not enough room in this buf.
- */
- static inline uint8_t *cdf_nbuf_put_tail(cdf_nbuf_t buf, cdf_size_t size)
- {
- return __cdf_nbuf_put_tail(buf, size);
- }
- /**
- * cdf_nbuf_pull_head() - pull data out from the front
- * @buf: Network buf instance
- * @size: Size to be popped
- *
- * Return: New data pointer of this buf after data has been popped,
- * or NULL if there is not sufficient data to pull.
- */
- static inline uint8_t *cdf_nbuf_pull_head(cdf_nbuf_t buf, cdf_size_t size)
- {
- return __cdf_nbuf_pull_head(buf, size);
- }
- /**
- * cdf_nbuf_trim_tail() - trim data out from the end
- * @buf: Network buf instance
- * @size: Size to be popped
- *
- * Return: none
- */
- static inline void cdf_nbuf_trim_tail(cdf_nbuf_t buf, cdf_size_t size)
- {
- __cdf_nbuf_trim_tail(buf, size);
- }
- /**
- * cdf_nbuf_len() - get the length of the buf
- * @buf: Network buf instance
- *
- * Return: total length of this buf.
- */
- static inline cdf_size_t cdf_nbuf_len(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_len(buf);
- }
- /**
- * cdf_nbuf_set_pktlen() - set the length of the buf
- * @buf: Network buf instance
- * @size: Size to be set
- *
- * Return: none
- */
- static inline void cdf_nbuf_set_pktlen(cdf_nbuf_t buf, uint32_t len)
- {
- __cdf_nbuf_set_pktlen(buf, len);
- }
- /**
- * cdf_nbuf_reserve() - trim data out from the end
- * @buf: Network buf instance
- * @size: Size to be popped
- *
- * Return: none
- */
- static inline void cdf_nbuf_reserve(cdf_nbuf_t buf, cdf_size_t size)
- {
- __cdf_nbuf_reserve(buf, size);
- }
- /**
- * cdf_nbuf_peek_header() - return the data pointer & length of the header
- * @buf: Network nbuf
- * @addr: Data pointer
- * @len: Length of the data
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_peek_header(cdf_nbuf_t buf, uint8_t **addr, uint32_t *len)
- {
- __cdf_nbuf_peek_header(buf, addr, len);
- }
- /* nbuf private context routines */
- /* nbuf queue routines */
- /**
- * cdf_nbuf_queue_init() - initialize buf queue
- * @head: Network buf queue head
- *
- * Return: none
- */
- static inline void cdf_nbuf_queue_init(cdf_nbuf_queue_t *head)
- {
- __cdf_nbuf_queue_init(head);
- }
- /**
- * cdf_nbuf_queue_add() - append a nbuf to the tail of the buf queue
- * @head: Network buf queue head
- * @buf: Network buf
- *
- * Return: none
- */
- static inline void cdf_nbuf_queue_add(cdf_nbuf_queue_t *head, cdf_nbuf_t buf)
- {
- __cdf_nbuf_queue_add(head, buf);
- }
- /**
- * cdf_nbuf_queue_insert_head() - insert nbuf at the head of queue
- * @head: Network buf queue head
- * @buf: Network buf
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_queue_insert_head(cdf_nbuf_queue_t *head, cdf_nbuf_t buf)
- {
- __cdf_nbuf_queue_insert_head(head, buf);
- }
- /**
- * cdf_nbuf_queue_remove() - retrieve a buf from the head of the buf queue
- * @head: Network buf queue head
- *
- * Return: The head buf in the buf queue.
- */
- static inline cdf_nbuf_t cdf_nbuf_queue_remove(cdf_nbuf_queue_t *head)
- {
- return __cdf_nbuf_queue_remove(head);
- }
- /**
- * cdf_nbuf_queue_len() - get the length of the queue
- * @head: Network buf queue head
- *
- * Return: length of the queue
- */
- static inline uint32_t cdf_nbuf_queue_len(cdf_nbuf_queue_t *head)
- {
- return __cdf_nbuf_queue_len(head);
- }
- /**
- * cdf_nbuf_queue_next() - get the next guy/packet of the given buffer
- * @buf: Network buffer
- *
- * Return: next buffer/packet
- */
- static inline cdf_nbuf_t cdf_nbuf_queue_next(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_queue_next(buf);
- }
- /**
- * @cdf_nbuf_is_queue_empty() - check if the buf queue is empty
- * @nbq: Network buf queue handle
- *
- * Return: true if queue is empty
- * false if queue is not emty
- */
- static inline bool cdf_nbuf_is_queue_empty(cdf_nbuf_queue_t *nbq)
- {
- return __cdf_nbuf_is_queue_empty(nbq);
- }
- /**
- * cdf_nbuf_next() - get the next packet in the linked list
- * @buf: Network buffer
- *
- * This function can be used when nbufs are directly linked into a list,
- * rather than using a separate network buffer queue object.
- *
- * Return: next network buffer in the linked list
- */
- static inline cdf_nbuf_t cdf_nbuf_next(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_next(buf);
- }
- /**
- * cdf_nbuf_get_protocol() - return the protocol value of the skb
- * @skb: Pointer to network buffer
- *
- * Return: skb protocol
- */
- static inline uint16_t cdf_nbuf_get_protocol(struct sk_buff *skb)
- {
- return __cdf_nbuf_get_protocol(skb);
- }
- /**
- * cdf_nbuf_get_ip_summed() - return the ip checksum value of the skb
- * @skb: Pointer to network buffer
- *
- * Return: skb ip_summed
- */
- static inline uint8_t cdf_nbuf_get_ip_summed(struct sk_buff *skb)
- {
- return __cdf_nbuf_get_ip_summed(skb);
- }
- /**
- * cdf_nbuf_set_ip_summed() - sets the ip_summed value of the skb
- * @skb: Pointer to network buffer
- * @ip_summed: ip checksum
- *
- * Return: none
- */
- static inline void cdf_nbuf_set_ip_summed(struct sk_buff *skb, uint8_t ip_summed)
- {
- __cdf_nbuf_set_ip_summed(skb, ip_summed);
- }
- /**
- * cdf_nbuf_set_next() - add a packet to a linked list
- * @this_buf: Predecessor buffer
- * @next_buf: Successor buffer
- *
- * This function can be used to directly link nbufs, rather than using
- * a separate network buffer queue object.
- *
- * Return: none
- */
- static inline void cdf_nbuf_set_next(cdf_nbuf_t this_buf, cdf_nbuf_t next_buf)
- {
- __cdf_nbuf_set_next(this_buf, next_buf);
- }
- /* nbuf extension routines */
- /**
- * cdf_nbuf_set_next_ext() - link extension of this packet contained in a new
- * nbuf
- * @this_buf: predecessor buffer
- * @next_buf: successor buffer
- *
- * This function is used to link up many nbufs containing a single logical
- * packet - not a collection of packets. Do not use for linking the first
- * extension to the head
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_set_next_ext(cdf_nbuf_t this_buf, cdf_nbuf_t next_buf)
- {
- __cdf_nbuf_set_next_ext(this_buf, next_buf);
- }
- /**
- * cdf_nbuf_next_ext() - get the next packet extension in the linked list
- * @buf: Network buffer
- *
- * Return: Next network buffer in the linked list
- */
- static inline cdf_nbuf_t cdf_nbuf_next_ext(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_next_ext(buf);
- }
- /**
- * cdf_nbuf_append_ext_list() - link list of packet extensions to the head
- * segment
- * @head_buf: Network buf holding head segment (single)
- * @ext_list: Network buf list holding linked extensions to the head
- * @ext_len: Total length of all buffers in the extension list
- *
- * This function is used to link up a list of packet extensions (seg1, 2,
- * ...) to the nbuf holding the head segment (seg0)
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_append_ext_list(cdf_nbuf_t head_buf, cdf_nbuf_t ext_list,
- cdf_size_t ext_len)
- {
- __cdf_nbuf_append_ext_list(head_buf, ext_list, ext_len);
- }
- /**
- * cdf_nbuf_get_tx_cksum() - gets the tx checksum offload demand
- * @buf: Network buffer
- *
- * Return: cdf_nbuf_tx_cksum_t checksum offload demand for the frame
- */
- static inline cdf_nbuf_tx_cksum_t cdf_nbuf_get_tx_cksum(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_get_tx_cksum(buf);
- }
- /**
- * cdf_nbuf_set_rx_cksum() - drivers that support hw checksumming use this to
- * indicate checksum info to the stack.
- * @buf: Network buffer
- * @cksum: Checksum
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_set_rx_cksum(cdf_nbuf_t buf, cdf_nbuf_rx_cksum_t *cksum)
- {
- __cdf_nbuf_set_rx_cksum(buf, cksum);
- }
- /**
- * cdf_nbuf_get_tid() - this function extracts the TID value from nbuf
- * @buf: Network buffer
- *
- * Return: TID value
- */
- static inline uint8_t cdf_nbuf_get_tid(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_get_tid(buf);
- }
- /**
- * cdf_nbuf_set_tid() - this function sets the TID value in nbuf
- * @buf: Network buffer
- * @tid: TID value
- *
- * Return: none
- */
- static inline void cdf_nbuf_set_tid(cdf_nbuf_t buf, uint8_t tid)
- {
- __cdf_nbuf_set_tid(buf, tid);
- }
- /**
- * cdf_nbuf_get_exemption_type() - this function extracts the exemption type
- * from nbuf
- * @buf: Network buffer
- *
- * Return: Exemption type
- */
- static inline uint8_t cdf_nbuf_get_exemption_type(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_get_exemption_type(buf);
- }
- /**
- * cdf_nbuf_set_protocol() - this function peeks data into the buffer at given
- * offset
- * @buf: Network buffer
- * @proto: Protocol
- *
- * Return: none
- */
- static inline void cdf_nbuf_set_protocol(cdf_nbuf_t buf, uint16_t proto)
- {
- __cdf_nbuf_set_protocol(buf, proto);
- }
- /**
- * cdf_nbuf_trace_get_proto_type() - this function return packet proto type
- * @buf: Network buffer
- *
- * Return: Packet protocol type
- */
- static inline uint8_t cdf_nbuf_trace_get_proto_type(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_trace_get_proto_type(buf);
- }
- #ifdef QCA_PKT_PROTO_TRACE
- /**
- * cdf_nbuf_trace_set_proto_type() - this function updates packet proto type
- * @buf: Network buffer
- * @proto_type: Protocol type
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_trace_set_proto_type(cdf_nbuf_t buf, uint8_t proto_type)
- {
- __cdf_nbuf_trace_set_proto_type(buf, proto_type);
- }
- #else
- #define cdf_nbuf_trace_set_proto_type(buf, proto_type) /*NO OP*/
- #endif
- /**
- * cdf_nbuf_reg_trace_cb() - this function registers protocol trace callback
- * @cb_func_ptr: Callback pointer
- *
- * Return: none
- */
- static inline void cdf_nbuf_reg_trace_cb(cdf_nbuf_trace_update_t cb_func_ptr)
- {
- __cdf_nbuf_reg_trace_cb(cb_func_ptr);
- }
- /**
- * cdf_nbuf_trace_update() - this function updates protocol event
- * @buf: Network buffer
- * @event_string: Event string pointer
- *
- * Return: none
- */
- static inline void cdf_nbuf_trace_update(cdf_nbuf_t buf, char *event_string)
- {
- __cdf_nbuf_trace_update(buf, event_string);
- }
- /**
- * cdf_nbuf_set_tx_parallel_dnload_frm() - set tx parallel download
- * @buf: Network buffer
- * @candi: Candidate of parallel download frame
- *
- * This function stores a flag specifying this TX frame is suitable for
- * downloading though a 2nd TX data pipe that is used for short frames for
- * protocols that can accept out-of-order delivery.
- *
- * Return: none
- */
- static inline void
- cdf_nbuf_set_tx_parallel_dnload_frm(cdf_nbuf_t buf, uint8_t candi)
- {
- __cdf_nbuf_set_tx_htt2_frm(buf, candi);
- }
- /**
- * cdf_nbuf_get_tx_parallel_dnload_frm() - get tx parallel download
- * @buf: Network buffer
- *
- * This function return whether this TX frame is allow to download though a 2nd
- * TX data pipe or not.
- *
- * Return: none
- */
- static inline uint8_t cdf_nbuf_get_tx_parallel_dnload_frm(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_get_tx_htt2_frm(buf);
- }
- /**
- * cdf_invalidate_range() - invalidate the virtual address range specified by
- * start and end addresses.
- * Note: This does not write back the cache entries.
- *
- * Return: none
- */
- static inline void cdf_invalidate_range(void *start, void *end)
- {
- #ifdef MSM_PLATFORM
- dmac_inv_range(start, end);
- #else
- /* TODO figure out how to invalidate cache on x86 and other
- non-MSM platform */
- CDF_TRACE(CDF_MODULE_ID_CDF, CDF_TRACE_LEVEL_FATAL,
- "Cache invalidate not yet implemneted for non-MSM platform");
- return;
- #endif
- }
- #if defined(FEATURE_TSO)
- /**
- * cdf_nbuf_dec_num_frags() - decrement the number of fragments
- * @buf: Network buffer
- *
- * Return: Number of fragments
- */
- static inline int cdf_nbuf_dec_num_frags(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_dec_num_frags(buf);
- }
- /**
- * cdf_nbuf_is_tso() - is the network buffer a jumbo packet?
- * @buf: Network buffer
- *
- * Return: 1 - this is a jumbo packet 0 - not a jumbo packet
- */
- static inline uint8_t cdf_nbuf_is_tso(cdf_nbuf_t nbuf)
- {
- return __cdf_nbuf_is_tso(nbuf);
- }
- /**
- * cdf_nbuf_get_tso_info() - function to divide a jumbo TSO
- * network buffer into segments
- * @nbuf: network buffer to be segmented
- * @tso_info: This is the output. The information about the
- * TSO segments will be populated within this.
- *
- * This function fragments a TCP jumbo packet into smaller
- * segments to be transmitted by the driver. It chains the TSO
- * segments created into a list.
- *
- * Return: number of TSO segments
- */
- static inline uint32_t cdf_nbuf_get_tso_info(cdf_device_t osdev,
- cdf_nbuf_t nbuf, struct cdf_tso_info_t *tso_info)
- {
- return __cdf_nbuf_get_tso_info(osdev, nbuf, tso_info);
- }
- /**
- * cdf_nbuf_get_tso_num_seg() - function to calculate the number
- * of TCP segments within the TSO jumbo packet
- * @nbuf: TSO jumbo network buffer to be segmented
- *
- * This function calculates the number of TCP segments that the
- network buffer can be divided into.
- *
- * Return: number of TCP segments
- */
- static inline uint32_t cdf_nbuf_get_tso_num_seg(cdf_nbuf_t nbuf)
- {
- return __cdf_nbuf_get_tso_num_seg(nbuf);
- }
- /**
- * cdf_nbuf_inc_users() - function to increment the number of
- * users referencing this network buffer
- *
- * @nbuf: network buffer
- *
- * This function increments the number of users referencing this
- * network buffer
- *
- * Return: the network buffer
- */
- static inline cdf_nbuf_t cdf_nbuf_inc_users(cdf_nbuf_t nbuf)
- {
- return __cdf_nbuf_inc_users(nbuf);
- }
- #endif /*TSO*/
- /**
- * cdf_nbuf_data_attr_get() - Get data_attr field from cvg_nbuf_cb
- *
- * @nbuf: Network buffer (skb on linux)
- *
- * This function returns the values of data_attr field
- * in struct cvg_nbuf_cb{}, to which skb->cb is typecast.
- * This value is actually the value programmed in CE descriptor.
- *
- * Return: Value of data_attr
- */
- static inline
- uint32_t cdf_nbuf_data_attr_get(cdf_nbuf_t buf)
- {
- return __cdf_nbuf_data_attr_get(buf);
- }
- /**
- * cdf_nbuf_data_attr_set() - Sets data_attr field in cvg_nbuf_cb
- *
- * @nbuf: Network buffer (skb on linux)
- * @data_attr: Value to be stored cvg_nbuf_cb->data_attr
- *
- * This function stores the value to be programmed in CE
- * descriptor as part skb->cb which is typecast to struct cvg_nbuf_cb{}
- *
- * Return: void
- */
- static inline
- void cdf_nbuf_data_attr_set(cdf_nbuf_t buf, uint32_t data_attr)
- {
- __cdf_nbuf_data_attr_set(buf, data_attr);
- }
- /**
- * cdf_nbuf_tx_info_get() - Parse skb and get Tx metadata
- *
- * @nbuf: Network buffer (skb on linux)
- *
- * This function parses the payload to figure out relevant
- * Tx meta-data e.g. whether to enable tx_classify bit
- * in CE.
- *
- * Return: void
- */
- #define cdf_nbuf_tx_info_get __cdf_nbuf_tx_info_get
- void cdf_nbuf_set_state(cdf_nbuf_t nbuf, uint8_t current_state);
- void cdf_nbuf_tx_desc_count_display(void);
- void cdf_nbuf_tx_desc_count_clear(void);
- #endif
|