-/* (c) Copyright 2002 - 2008 Atheros Communications Inc. */
-
+/*
+ * Copyright (c) 2013 Qualcomm Atheros, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * Neither the name of Qualcomm Atheros nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
/**
* @defgroup adf_nbuf_public network buffer API
- */
+ */
/**
* @ingroup adf_nbuf_public
* @file adf_nbuf.h
* This file defines the network buffer abstraction.
- */
+ */
#ifndef _ADF_NBUF_H
#define _ADF_NBUF_H
* - need space in adf_drv's software descriptor
* - are typically created during adf_drv_create
* - need to be created before any API(adf_nbuf_map) that uses them
- *
+ *
* @param[in] osdev os device
* @param[out] dmap map handle
- *
+ *
* @return status of the operation
*/
static inline a_status_t
/**
* @brief Delete a dmap map
- *
+ *
* @param[in] osdev os device
* @param[in] dmap
*/
* @return status of the operation
*/
static inline a_status_t
-adf_nbuf_map(adf_os_device_t osdev,
- adf_os_dma_map_t bmap,
- adf_nbuf_t buf,
+adf_nbuf_map(adf_os_device_t osdev,
+ adf_os_dma_map_t bmap,
+ adf_nbuf_t buf,
adf_os_dma_dir_t dir)
{
return __adf_nbuf_map(osdev, bmap, buf, dir);
* @param[in] dir DMA direction
*/
static inline void
-adf_nbuf_unmap(adf_os_device_t osdev,
- adf_os_dma_map_t bmap,
+adf_nbuf_unmap(adf_os_device_t osdev,
+ adf_os_dma_map_t bmap,
adf_os_dma_dir_t dir)
{
__adf_nbuf_unmap(osdev, bmap, dir);
/**
* @brief returns information about the mapped buf
- *
+ *
* @param[in] bmap map handle
* @param[out] sg map info
*/
* The nbuf created is guarenteed to have only 1 physical segment
*
* @param[in] hdl platform device object
- * @param[in] size data buffer size for this adf_nbuf including max header
+ * @param[in] size data buffer size for this adf_nbuf including max header
* size
* @param[in] reserve headroom to start with.
* @param[in] align alignment for the start buffer.
*
* @return The new adf_nbuf instance or NULL if there's not enough memory.
*/
-static inline adf_nbuf_t
+static inline adf_nbuf_t
adf_nbuf_alloc(adf_os_size_t size,
int reserve,
int align)
* buf. Note that this can allocate a new buffer, or
* change geometry of the orignial buffer. The new buffer
* is returned in the (new_buf).
- *
+ *
* @param[in] buf (older buffer)
* @param[in] headroom
- *
+ *
* @return newly allocated buffer
*/
static inline adf_nbuf_t
/**
* @brief expand the tailroom to the new tailroom, but the buffer
* remains the same
- *
+ *
* @param[in] buf buffer
* @param[in] tailroom new tailroom
- *
+ *
* @return expanded buffer or NULL on failure
*/
static inline adf_nbuf_t
* having an extra API is that some OS do this in more
* optimized way, rather than calling realloc (head/tail)
* back to back.
- *
+ *
* @param[in] buf buffer
- * @param[in] headroom new headroom
+ * @param[in] headroom new headroom
* @param[in] tailroom new tailroom
- *
+ *
* @return expanded buffer
*/
static inline adf_nbuf_t
* effect, it also "linearizes" a buffer (which is
* perhaps why you'll use it mostly). It creates a
* writeable copy.
- *
+ *
* @param[in] buf source nbuf to copy from
- *
+ *
* @return the new nbuf
*/
static inline adf_nbuf_t
/**
* @brief link two nbufs, the new buf is piggybacked into the
* older one.
- *
+ *
* @param[in] dst buffer to piggyback into
* @param[in] src buffer to put
- *
+ *
* @return status of the call
*/
static inline void
/**
* @brief clone the nbuf (copy is readonly)
- *
+ *
* @param[in] buf nbuf to clone from
- *
+ *
* @return cloned buffer
*/
-static inline adf_nbuf_t
+static inline adf_nbuf_t
adf_nbuf_clone(adf_nbuf_t buf)
{
return(__adf_nbuf_clone(buf));
* other users.If the nbuf is a clone then this function
* creates a new copy of the data. If the buffer is not
* a clone the original buffer is returned.
- *
+ *
* @param[in] buf source nbuf to create a writable copy from
- *
+ *
* @return new buffer which is writeable
*/
-static inline adf_nbuf_t
+static inline adf_nbuf_t
adf_nbuf_unshare(adf_nbuf_t buf)
{
return(__adf_nbuf_unshare(buf));
/**
* @brief return the amount of headroom int the current nbuf
- *
+ *
* @param[in] buf buffer
- *
+ *
* @return amount of head room
*/
static inline a_uint32_t
/**
* @brief return the amount of tail space available
- *
+ *
* @param[in] buf buffer
- *
- * @return amount of tail room
+ *
+ * @return amount of tail room
*/
static inline a_uint32_t
adf_nbuf_tailroom(adf_nbuf_t buf)
/**
- *
+ *
* @brief trim data out from the end
*
* @param[in] buf buf instance
/**
* @brief test whether the nbuf is cloned or not
- *
+ *
* @param[in] buf buffer
- *
+ *
* @return TRUE if it is cloned, else FALSE
*/
static inline a_bool_t
/**
* @brief return the frag pointer & length of the frag
- *
+ *
* @param[in] buf buffer
* @param[out] sg this will return all the frags of the nbuf
- *
+ *
*/
-static inline void
-adf_nbuf_frag_info(adf_nbuf_t buf, adf_os_sglist_t *sg)
+static inline void
+adf_nbuf_frag_info(adf_nbuf_t buf, adf_os_sglist_t *sg)
{
__adf_nbuf_frag_info(buf, sg);
}
/**
* @brief return the data pointer & length of the header
- *
+ *
* @param[in] buf nbuf
* @param[out] addr data pointer
* @param[out] len length of the data
/**
* @brief get the priv pointer from the nbuf'f private space
- *
+ *
* @param[in] buf
- *
+ *
* @return data pointer to typecast into your priv structure
*/
static inline a_uint8_t *
/**
* @brief get the length of the queue
- *
+ *
* @param[in] head buf queue head
- *
+ *
* @return length of the queue
*/
static inline a_uint32_t
/**
* @brief get the first guy/packet in the queue
- *
+ *
* @param[in] head buf queue head
- *
+ *
* @return first buffer in queue
*/
-static inline adf_nbuf_t
+static inline adf_nbuf_t
adf_nbuf_queue_first(adf_nbuf_queue_t *head)
{
return (__adf_nbuf_queue_first(head));
/**
* @brief get the next guy/packet of the given buffer (or
* packet)
- *
+ *
* @param[in] buf buffer
- *
+ *
* @return next buffer/packet
*/
static inline adf_nbuf_t
/**
* @brief Check if the buf queue is empty
- *
+ *
* @param[in] nbq buf queue handle
*
* @return TRUE if queue is empty
/**
* @brief Gets the tx checksumming to be performed on this buf
- *
+ *
* @param[in] buf buffer
* @param[out] hdr_off the (tcp) header start
* @param[out] where the checksum offset
/**
* @brief Drivers that support hw checksumming use this to
* indicate checksum info to the stack.
- *
+ *
* @param[in] buf buffer
* @param[in] cksum checksum
*/
/**
* @brief Drivers that are capable of TCP Large segment offload
* use this to get the offload info out of an buf.
- *
+ *
* @param[in] buf buffer
* @param[out] tso offload info
*/
/**
* @brief This function extracts the vid & priority from an
* nbuf
- *
- *
+ *
+ *
* @param[in] hdl net handle
* @param[in] buf buffer
* @param[in] vlan vlan header
- *
+ *
* @return status of the operation
*/
static inline a_status_t
-adf_nbuf_get_vlan_info(adf_net_handle_t hdl, adf_nbuf_t buf,
+adf_nbuf_get_vlan_info(adf_net_handle_t hdl, adf_nbuf_t buf,
adf_net_vlanhdr_t *vlan)
{
return __adf_nbuf_get_vlan_info(hdl, buf, vlan);