/****************************************************************************** * FILE PURPOSE: Top level interface file for NWAL Module ****************************************************************************** * FILE NAME: pktio.h * * DESCRIPTION: netapi PKTIO module header file * * REVISION HISTORY: * * Copyright (c) Texas Instruments Incorporated 2010-2011 * * Redistribution and use in source and binary forms, with or without * modification, are permitted 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 Texas Instruments Incorporated nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * 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. * */ /* ============================================================= */ /** * @file pktio.h * @brief pktio module main header file for user space transport library */ #ifndef __PKTIO__H #define __PKTIO__H #include "netapi.h" #include "ti/runtime/pktlib/pktlib.h" #include "ti/drv/nwal/nwal.h" #include "ti/drv/nwal/nwal_util.h" #include "netapi_err.h" /*--------------------defines-----------------------*/ #define PKTIO_NOMEM NETAPI_ERR_NOMEM //default pktio channels #define NETCP_TX "NETCP_TX" #define NETCP_RX "NETCP_RX" #define NETCP_SB_RX "NETCP_SB_RX" #define NETCP_SB_TX "NETCP_SB_TX" #define PKTIO_MAX_NAME 19 /*--------------------data structures----------------*/ /** * @ingroup netapi_structures * @brief PKTIO meta data information . * * @details PKTIO meta data information TBD */ typedef struct PKTIO_METADATA_Tag { int flags1; #define PKTIO_META_RX 0x01 #define PKTIO_META_TX 0x02 #define PKTIO_META_SB_RX 0x4 /**< SB crypto rx */ #define PKTIO_META_SB_TX 0x8 /** _send((struct PKTIO_HANDLE_tag *)channel, pkt, m, err); } /** * @ingroup netapi_pktio_functions * @brief API sends data to a NETAPI PKTIO channel * * @details This sends an array of @ref Ti_Pkt and associated meta data, * @ref PKTIO_METADATA_T to a channel. The channel * must have already been created via @ref pktio_create or opened * via @ref pktio_open. It may have * been created internally during the netapi intialization. * @param[in] @ref PKTIO_HANDLE_T: handle to the channel * @param[in] @ref Ti_Pkt*: pointer to the packet to send * @param[in] @ref PKTIO_METADATA_T: pointer to meta data associated with packet * @oaran[in[ int np: the number of packets in list to send * @param[out] int * err: pointer to error return * @retval int npkts: number of packets sent, 0 if error * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open */ int pktio_sendMulti(PKTIO_HANDLE_T *channel, /* the channel handle */ Ti_Pkt * pkt[], /* array of packets to send */ PKTIO_METADATA_T * m[], /* meta data array */ int np, /* number of packets to send */ int * err); /***********************************/ /************* polling **************/ /***********************************/ /** * @ingroup netapi_pktio_functions * @brief API polls a NETAPI PKTIO channel for received packets * * @details This api polls a pktio channel. Any pending data in the channel is * passed to the @ref PKTIO_CB registered when the channel was * created or opened. The channel must * have already been created via @ref pktio_create or opened * via @ref pktio_open. It may have * been created internally during the netapi intialization. * @param[in] @ref PKTIO_HANDLE_T: handle to the channel * @param[in] @ref PKTIO_POLL_T *: pointer to pktio poll configuration * @param[out] int * err: pointer to error return * @retval int npkts: number of packets received by poll * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open */ static inline int pktio_poll(PKTIO_HANDLE_T * handle, //handle to pktio PKTIO_POLL_T * p_poll_cfg, //polling configuration int * err) { return handle->_poll((struct PKTIO_HANDLE_tag *) handle, p_poll_cfg, err); } /** * @ingroup netapi_pktio_functions * @brief API polls all NETAPI PKTIO channels associarted with @ref NETAPI_T instance * for received packets * * @details This api polls all pktio channels attached to an instance. * Any pending data in these channels are * passed to the @ref PKTIO_CB registered when the channel was * created or opened. The channels must * have already been created via @ref pktio_create or opened * via @ref pktio_open. They may have * been created internally during the netapi intialization. * @param[in] @ref NETAPI_T: handle of the NETAPI instance * @param[in] @ref PKTIO_POLL_T *: pointer to pktio poll configuration * @param[out] int * err: pointer to error return * @retval int npkts: number of packets received by poll * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open */ int pktio_pollAll(NETAPI_T handle, PKTIO_POLL_T * p_poll_cfg, int *err); /*----------------- utilities------------------ */ /* update max_n for poll */ #define pktio_set_max_n(handle,max_n) (handle)->max_n=max_n; #define pktio_get_netapi_handle(handle) (handle)->back #define pktio_set_cookie(handle, cookie) (handle)->cookie = cookie #define pktio_get_cookie(handle) (handle)->cookie #define pktio_get_q(handle) (handle)->q /*-----------------Extra Fast Path pkt meta data macros--------------------*/ #include "cppi_desc.h" #include "ti/drv/pa/pa.h" #include "ti/drv/pa/pasahost.h" /** * @ingroup netapi_pktio_functions * @brief API returns default packet queue to poll for netcp RX * @note: these are expensive calls, so call once and save */ static inline Qmss_QueueHnd PKTIO_GET_DEFAULT_NETCP_Q(PKTIO_HANDLE_T *h) { nwalGlobCxtInfo_t Info; nwal_getGlobCxtInfo(h->nwalInstanceHandle,&Info); return Info.rxDefPktQ; } /** * @ingroup netapi_pktio_functions * @brief API returns L4Queue to poll for netcp RX (L4 classifier queue). * @note: these are expensive calls, so call once and save */ static inline Qmss_QueueHnd PKTIO_GET_DEFAULT_NETCP_L4Q(PKTIO_HANDLE_T *h) { nwalLocCxtInfo_t Info; nwal_getLocCxtInfo(h->nwalInstanceHandle,&Info); return Info.rxL4PktQ; } /** * @ingroup netapi_pktio_functions * @brief API to perform descriptor push to QMSS Queue */ static inline void PKTIO_QMSS_QUEUE_PUSH_DESC_SIZE_RAW(Qmss_QueueHnd hnd, void *descAddr, uint32_t descSize) { return(Qmss_queuePushDescSizeRaw(hnd,descAddr,descSize)); } /** * @ingroup netapi_pktio_functions * @brief API to perform descriptor pop from QMSS Queue */ static inline void* PKTIO_QMSS_QUEUE_POP_RAW(Qmss_QueueHnd hnd) { return(Qmss_queuePopRaw(hnd)); } /** * @ingroup netapi_pktio_functions * @brief API to retrieve NWAL global instance handle. */ static inline nwal_Inst PKTIO_GET_NWAL_INSTANCE(PKTIO_HANDLE_T *h) { return h->nwalInstanceHandle; } #endif