index 91eb045c06c6e6a6068007d9472f23d7f9fa0ade..0ddf435b40db006967b7649e4eaf8452cf7ffa13 100755 (executable)
-/*********************************\r
- *FILE: pktio.h\r
- *PURPOSE: pktio library header\r
- **************************************************************\r
- * @file pktio.h\r
- * \r
- * @bried DESCRIPTION: pktio module main header file for user space transport\r
- * library\r
- * \r
- * REVISION HISTORY: rev 0.0.1 \r
- *\r
- * Copyright (c) Texas Instruments Incorporated 2010-2011\r
- * \r
- * Redistribution and use in source and binary forms, with or without \r
- * modification, are permitted provided that the following conditions \r
- * are met:\r
- *\r
- * Redistributions of source code must retain the above copyright \r
- * notice, this list of conditions and the following disclaimer.\r
- *\r
- * Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the \r
- * documentation and/or other materials provided with the \r
- * distribution.\r
- *\r
- * Neither the name of Texas Instruments Incorporated nor the names of\r
- * its contributors may be used to endorse or promote products derived\r
- * from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
-\r
- ********************************/\r
-#ifndef __PKTIO__H\r
-#define __PKTIO__H\r
-#include "netapi.h"\r
-#include "ti/runtime/pktlib/pktlib.h"\r
-#include "ti/drv/nwal/nwal.h"\r
-#include "netapi_err.h"\r
-\r
-/*--------------------defines-----------------------*/\r
-#define PKTIO_NOMEM NETAPI_ERR_NOMEM\r
-//default pktio channels \r
-#define NETCP_TX "NETCP_TX"\r
-#define NETCP_RX "NETCP_RX"\r
-#define NETCP_SB_RX "NETCP_SB_RX"\r
-#define NETCP_SB_TX "NETCP_SB_TX"\r
-#define PKTIO_MAX_NAME 19 \r
-\r
-/*--------------------data structures----------------*/\r
-typedef struct PKTIO_METADATA_Tag\r
-{\r
- int flags1;\r
-#define PKTIO_META_RX 0x01\r
-#define PKTIO_META_TX 0x02\r
-#define PKTIO_META_SB_RX 0x4 //SB crypto rx \r
-#define PKTIO_META_SB_TX 0x8 //SB crypto tx\r
-#define PKTIO_META_APP_DEF 0x80000000\r
- union\r
- {\r
- nwalRxPktInfo_t * rx_meta;\r
- nwalTxPktInfo_t * tx_meta;\r
- nwalDmRxPayloadInfo_t * rx_sb_meta;\r
- nwalDmTxPayloadInfo_t * tx_sb_meta;\r
- } u;\r
- void * sa_handle; //valid for PKTIO_META_TX with IPSEC inflow or PKTIO_PKTIO_META_SB_TX . \r
- // MUST BE nwal_HANDLE_INVALID otherwise\r
-} PKTIO_METADATA_T;\r
-\r
-/* the callback function */\r
-struct PKTIO_HANDLE_tag;\r
-\r
-#define PKTIO_MAX_RECV (TUNE_NETAPI_MAX_BURST_RCV)\r
-typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel, Ti_Pkt* p_recv[],\r
- PKTIO_METADATA_T p_meta[], int n_pkts,\r
- uint64_t ts );\r
-\r
-/** channel configuration */\r
-#define PKTIO_NA 0\r
-typedef struct PKTIO_CFG_Tag\r
-{\r
-#define PKTIO_R 0x1\r
-#define PKTIO_W 0x2\r
-#define PKTIO_RW (PKTIO_R | PKTIO_W)\r
-int flags1;\r
-\r
-#define PKTIO_LOCAL 0x2 \r
-#define PKTIO_GLOBAL 0x1\r
-#define PKTIO_PKT 0x4 //define this if this channel is for NETCP \r
-#define PKTIO_SB 0x8 //define this if this channel is for sideband crypto \r
-int flags2;\r
-\r
-//for create\r
-#define PKTIO_Q_ANY -1\r
-int qnum;\r
-\r
-//for poll\r
-int max_n;\r
-}PKTIO_CFG_T;\r
-\r
-struct NETAPI_tag;\r
-\r
-/* a pktio channel .. */\r
-\r
-typedef struct PKTIO_HANDLE_Tag\r
-{\r
-#define PKTIO_INUSE 0xfeedfeed\r
- int inuse;\r
- int use_nwal; /* true if this is managed by nwal */\r
-#define PKTIO_4_IPC 0 //For IPC\r
-#define PKTIO_4_ADJ_NWAL 1 //(RX)app queues managed by NWAL\r
-#define PKTIO_DEF_NWAL 2 // default NWAL RX/TX queues\r
-#define PKTIO_4_ADJ_SB 3 //(RX) crypto side band app defined\r
-#define PKTIO_DEF_SB 4 //crypto side band default\r
- struct NETAPI_tag * back; /* back handle */\r
- void * nwalInstanceHandle; /* save here for conveninece */\r
- PKTIO_CB cb; /* callback for channel */\r
- PKTIO_CFG_T cfg; /* configuration */\r
- Qmss_QueueHnd q; /* the associated queue handle */\r
- Qmss_Queue qInfo; /* and its qm#/q# */\r
- int max_n; /* max # of pkts to read in one poll */\r
- void * cookie; /* app specific */\r
- char name[PKTIO_MAX_NAME+1];\r
-} PKTIO_HANDLE_T;\r
-\r
-\r
-\r
-typedef struct PKTIO_CONTROL_Tag\r
-{\r
-#define PKTIO_CLEAR 0x1 //clear out the channel\r
-#define PKTIO_DIVERT 0x2 //divert, (to dest channel)\r
- int op;\r
- PKTIO_HANDLE_T *dest;\r
-} PKTIO_CONTROL_T;\r
-\r
-\r
-//polling control\r
-typedef struct PKTIO_POLL_Tag\r
-{\r
-/* future */\r
-} PKTIO_POLL_T;\r
-\r
-/*---------------------------------------------------*/\r
-/*-------------------------API-----------------------*/\r
-/*---------------------------------------------------*/\r
-\r
-/*\r
-* @brief API creates a NETAPI channel \r
- *\r
- * @details This assigns global resources to a NETAPI pktio channel.\r
- * Once created, the channel can be used to send and/or receive\r
- * a TI @ref Ti_Pkt. This can be used for communication with the \r
- * the Network co-processor (NETCP) or for internal inter-processor\r
- * communication. The channel is saved under the assigned name \r
- * and can be opened by other netapi threads instances.\r
- * @param[in] @ref NETAPI_T: handle to the instance \r
- * @param[in] char * name: a pointer to the char string name for channel\r
- * @param[in] @ref PKTIO_CB : callback to be issued on packet receive\r
- * @param[in] @ref PKTIO_CFG_T: pointer to channel configuration\r
- * @param[out] int * err: pointer to error return \r
- * @retval @ref PKTIO_HANDLE_T: handle to the pktio instance or NULL on error\r
- * @pre @ref netapi_init \r
- */\r
-PKTIO_HANDLE_T * pktio_create(NETAPI_T netapi_handle, /* netapi instance */\r
- char * name, /* name of the channel */\r
- PKTIO_CB cb, /* receive callback */\r
- PKTIO_CFG_T * p_cfg, /* ptr to config*/\r
- int * err);\r
-\r
-/*\r
-* @brief API opens an existing NETAPI channel\r
- *\r
- * @details This opens an NETAPI pktio channel for use. The channel\r
- * must have already been created via @ref pktio_create or may have\r
- * been created internally during the netapi intialization.\r
- * Once opened, the channel can be used to send and/or receive\r
- * a TI @ref Ti_Pkt. This can be used for communication with the \r
- * the Network co-processor (NETCP) or for internal inter-processor\r
- * communication. \r
- *\r
- * @param[in] @ref NETAPI_T: handle to the instance \r
- * @param[in] char * name: a pointer to the char string name for channel\r
- * @param[in] @ref PKTIO_CB : callback to be issued on packet receive\r
- * @param[in] @ref PKTIO_CFG_T: pointer to channel configuration\r
- * @param[out] int * err: pointer to error return\r
- * @retval @ref PKTIO_HANDLE_T: handle to the pktio instance or NULL on error\r
- * @pre @ref netapi_init , @ref pktio_create\r
- */\r
-PKTIO_HANDLE_T * pktio_open(NETAPI_T netapi_handle, /* netapi instance */\r
- char *name, /* name of channel to open */\r
- PKTIO_CB cb, /* receive callback */\r
- PKTIO_CFG_T *p_cfg, /* channel configuration */\r
- int * err);\r
-\r
-/* future: control the channel */\r
-void pktio_control(PKTIO_HANDLE_T * channel, //handle from open or create\r
- PKTIO_CB cb, //change the callback\r
- PKTIO_CFG_T * p_cfg,//optional \r
- PKTIO_CONTROL_T *p_control,//optional\r
- int *err);\r
- \r
-/* future: close or delete a pktio channel */\r
-void pktio_close(PKTIO_HANDLE_T * channel, int * err);\r
-void pktio_delete(PKTIO_HANDLE_T * channel, int * err);\r
-\r
-/*\r
-* @brief API sends data to a pktio channel \r
- *\r
- * @details This sends a @ref Ti_Pkt and associated meta data, \r
- * @ref PKTIO_METADATA_T to a channel. The channel\r
- * must have already been created via @ref pktio_create or opened\r
- * via @ref pktio_open. It may have\r
- * been created internally during the netapi intialization.\r
- * @param[in] @ref PKTIO_HANDLE_T: handle to the channel\r
- * @param[in] @ref Ti_Pkt*: pointer to the packet to send\r
- * @param[in] @ref PKTIO_METADATA_T: pointer to meta data associated with packet \r
- * @param[out] int * err: pointer to error return\r
- * @retval int npkts: 1 if packet sent, 0 if error \r
- * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open\r
- */\r
-int pktio_send(PKTIO_HANDLE_T * channel, /* the channel */\r
- Ti_Pkt *pkt, /* pointer to packet */\r
- PKTIO_METADATA_T *m, /* pointer to meta data */\r
- int * err);\r
-\r
-/*\r
-* @brief API sends data to a pktio channel\r
- *\r
- * @details This sends an array of @ref Ti_Pkt and associated meta data,\r
- * @ref PKTIO_METADATA_T to a channel. The channel\r
- * must have already been created via @ref pktio_create or opened\r
- * via @ref pktio_open. It may have\r
- * been created internally during the netapi intialization.\r
- * @param[in] @ref PKTIO_HANDLE_T: handle to the channel\r
- * @param[in] @ref Ti_Pkt*: pointer to the packet to send\r
- * @param[in] @ref PKTIO_METADATA_T: pointer to meta data associated with packet\r
- * @oaran[in[ int np: the number of packets in list to send\r
- * @param[out] int * err: pointer to error return\r
- * @retval int npkts: number of packets sent, 0 if error\r
- * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open\r
- */\r
-int pktio_sendMulti(PKTIO_HANDLE_T *channel, /* the channel handle */\r
- Ti_Pkt * pkt[], /* array of packets to send */\r
- PKTIO_METADATA_T * m[], /* meta data array */\r
- int np, /* number of packets to send */\r
- int * err);\r
-\r
-/***********************************/\r
-/************* polling **************/\r
-/***********************************/\r
-\r
-/*\r
-* @brief API polls a pkto channel for received packets \r
- *\r
- * @details This api polls a pktio channel. Any pending data in the channel is\r
- * passed to the @ref PKTIO_CB registered when the channel was\r
- * created or opened. The channel must\r
- * have already been created via @ref pktio_create or opened\r
- * via @ref pktio_open. It may have\r
- * been created internally during the netapi intialization.\r
- * @param[in] @ref PKTIO_HANDLE_T: handle to the channel\r
- * @param[in] @ref PKTIO_POLL_T *: pointer to pktio poll configuration\r
- * @param[out] int * err: pointer to error return\r
- * @retval int npkts: number of packets received by poll \r
- * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open\r
- */\r
-int pktio_poll(PKTIO_HANDLE_T * handle, //handle to pktio\r
- PKTIO_POLL_T * p_poll_cfg, //polling configuration\r
- int * err);\r
-\r
-/*\r
-* @brief API polls all pkto channels associarted with @ref NETAPI_T instance\r
- * for received packets\r
- *\r
- * @details This api polls all pktio channels attached to an instance.\r
- * Any pending data in these channels are \r
- * passed to the @ref PKTIO_CB registered when the channel was\r
- * created or opened. The channels must\r
- * have already been created via @ref pktio_create or opened\r
- * via @ref pktio_open. They may have\r
- * been created internally during the netapi intialization.\r
- * @param[in] @ref NETAPI_T: handle of the NETAPI instance \r
- * @param[in] @ref PKTIO_POLL_T *: pointer to pktio poll configuration\r
- * @param[out] int * err: pointer to error return\r
- * @retval int npkts: number of packets received by poll\r
- * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open\r
- */\r
-int pktio_pollAll(NETAPI_T handle, PKTIO_POLL_T * p_poll_cfg, int *err);\r
-\r
-/*----------------- utilities------------------ */\r
-/* update max_n for poll */\r
-#define pktio_set_max_n(handle,max_n) (handle)->max_n=max_n;\r
-#define pktio_get_netapi_handle(handle) (handle)->back\r
-#define pktio_set_cookie(handle, cookie) (handle)->cookie = cookie\r
-#define pktio_get_cookie(handle) (handle)->cookie\r
-#define pktio_get_q(handle) (handle)->q\r
-#endif\r
+/******************************************************************************
+ * 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
+ * @details: pktio provides an abstraction to H/W queues that are used to transmit and receive packets, IPC messages, etc. Pktio channels can be created by user but there are also several canned channels available for NETCP transmit, receive, SA sideband crypto transmit and receive
+ */
+
+
+
+#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-----------------------*/
+
+/**
+ * @def PKTIO_NOMEM
+ * @ingroup pktio_constants
+ * This define is used to indicate out of memory to user space application
+ */
+#define PKTIO_NOMEM NETAPI_ERR_NOMEM
+
+/**
+ * @def NETCP_TX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP transmit channel name
+ */
+#define NETCP_TX "NETCP_TX"
+
+/**
+ * @def NETCP_RX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP receive channel name
+ */
+#define NETCP_RX "NETCP_RX"
+
+/**
+ * @def NETCP_SB_RX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP-SA receive SIDEBAND channel name
+ */
+#define NETCP_SB_RX "NETCP_SB_RX"
+
+/**
+ * @def NETCP_SB_TX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP-SA transmit SIDEBAND channel name
+ */
+#define NETCP_SB_TX "NETCP_SB_TX"
+
+/**
+ * @def PKTIO_MAX_NAME
+ * @ingroup pktio_constants
+ * This defines the maximum length of a pktio channel name
+ */
+#define PKTIO_MAX_NAME 19
+
+/**
+ * @ingroup pktio_structures
+ * @brief PKTIO meta data information .
+ *
+ * @details PKTIO meta data information TBD
+ */
+typedef struct PKTIO_METADATA_Tag
+{
+/**
+ * Flags for PKTIO Meta Data configuration
+ * <br>
+ * valid flag1 parameters are as follows:
+ * @ref PKTIO_META_RX , @ref PKTIO_META_TX, @ref PKTIO_META_SB_RX, @ref PKTIO_META_SB_TX
+ */
+ int flags1;
+
+/**
+ * @def PKTIO_META_RX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP receive INFLOW channel
+ */
+#define PKTIO_META_RX 0x01
+
+/**
+ * @def PKTIO_META_TX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP transmit INFLOW channel
+ */
+#define PKTIO_META_TX 0x02
+
+/**
+ * @def PKTIO_META_SB_RX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP SIDEBAND channel channel
+ */
+#define PKTIO_META_SB_RX 0x4 /**< SB crypto rx */
+
+/**
+ * @def PKTIO_META_SB_TX
+ * @ingroup pktio_constants
+ * This defines the pktio NETCP transmit SIDEBAND channel
+ */
+#define PKTIO_META_SB_TX 0x8 /** <SB crypto tx */
+
+/**
+ * @def PKTIO_META_APP_DEF
+ * @ingroup pktio_constants
+ * TBD- is this part of flags2?
+ */
+#define PKTIO_META_APP_DEF 0x80000000
+
+/**
+ * @brief NWAL Packet meta data information
+ */
+ union
+ {
+ nwalRxPktInfo_t * rx_meta; /**< NWAL Packet meta data information for incoming packet */
+ nwalTxPktInfo_t * tx_meta; /**< NWAL Packet meta data information for outgoing packet */
+ nwalDmRxPayloadInfo_t * rx_sb_meta; /**<NWAL Data mode meta data payload information from NetCP */
+ nwalDmTxPayloadInfo_t * tx_sb_meta; /**< NWAL Data Mode Payload information for packet to SA */
+ } u; /**< union NWAL Packet meta data information */
+
+/**
+ * @brief valid for PKTIO_META_TX with IPSEC inflow or PKTIO_PKTIO_META_SB_TX MUST BE nwal_HANDLE_INVALID otherwise
+ */
+ void * sa_handle;
+} PKTIO_METADATA_T;
+
+/* the callback function */
+struct PKTIO_HANDLE_tag;
+
+/**
+ * @ingroup pktio_structures
+ * @brief PKTIO polling control struct FUTURE- TBD
+ *
+ * @details PKTIO polling control struct FUTURE- TBD
+ */
+typedef struct PKTIO_POLL_Tag
+{
+/* future */
+} PKTIO_POLL_T;
+
+/**
+ * @def PKTIO_MAX_RECV
+ * @ingroup pktio_constants
+ * This defines the maximum number of packets to receive in one pktio poll, @ref TUNE_NETAPI_MAX_BURST_RCV
+ */
+#define PKTIO_MAX_RECV (TUNE_NETAPI_MAX_BURST_RCV)
+
+
+/**
+ * @ingroup netapi_cb_functions
+ * @brief PKTIO_CB Callback function to be issued on packet receive
+ *
+ * @details The application provides a callback function that gets invoked on packet receive
+ * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_recv Pointer to the packets received.
+ * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
+ * @param[in] n_pkts Number of packets received.
+ * @param[in] ts Timestamp associted with received packets.
+ * @retval none
+ * @pre @ref pktio_open
+ */
+typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel,
+ Ti_Pkt* p_recv[],
+ PKTIO_METADATA_T p_meta[],
+ int n_pkts,
+ uint64_t ts);
+
+/**
+ * @ingroup pktio_functions
+ * @brief PKTIO_SEND PKTIO specific send function
+ *
+ * @details The application calls this PKTIO specific send function to transmit packet
+ * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_send Pointer to the packet to send
+ * @param[in] p_meta Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
+ * @param[out] p_err Pointer to error code.
+ * @retval none
+ * @pre @ref pktio_open
+ */
+typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
+ Ti_Pkt* p_send,
+ PKTIO_METADATA_T *p_meta,
+ int * p_err);
+
+
+/**
+ * @ingroup pktio_functions
+ * @brief PKTIO_POLL PKTIO specific poll function
+ *
+ * @details The application calls this PKTIO specific POLL function
+ * @param[in] channel The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
+ * @param[out] p_err Pointer to error code.
+ * @retval none
+ * @pre @ref pktio_open
+ */
+typedef int (*PKTIO_POLL)(struct PKTIO_HANDLE_tag * channel,
+ PKTIO_POLL_T * p_poll_cfg,
+ int * p_err);
+
+/**
+ * @brief This defines TBD
+ */
+#define PKTIO_NA 0
+
+/**
+ * @ingroup pktio_structures
+ * @brief PKTIO configuration information
+ *
+ * @details PKTIO :q information
+ */
+typedef struct PKTIO_CFG_Tag
+{
+/**
+ * Flags for PKTIO channel configuration
+ * <br>
+ * The following are flags used to configure the pktio channel:
+ * @ref PKTIO_R , @ref PKTIO_W, @ref PKTIO_RW
+ */
+ int flags1;
+
+/**
+ * @def PKTIO_R
+ * @ingroup pktio_constants
+ * This defines the pktio channel as type read TBD
+ */
+#define PKTIO_R 0x1
+
+/**
+ * @def PKTIO_W
+ * @ingroup pktio_constants
+ * This defines the pktio channel as type write TBD
+ */
+#define PKTIO_W 0x2
+
+/**
+ * @def PKTIO_RW
+ * @ingroup pktio_constants
+ * This defines the pktio channel as type read/write TBD
+ */
+#define PKTIO_RW (PKTIO_R | PKTIO_W)
+
+
+
+/**
+ * Additional flags for PKTIO channel configuration
+ * <br>
+ * The following are flags used to configure the pktio channel:
+ * @ref PKTIO_LOCAL , @ref PKTIO_GLOBAL, @ref PKTIO_RW
+ */
+int flags2; /**< Flags for PKTIO channel configuration */
+
+/**
+ * @def PKTIO_GLOBAL
+ * @ingroup pktio_constants
+ * This defines the pktio channel as type global TBD
+ */
+#define PKTIO_GLOBAL 0x1
+
+/**
+ * @def PKTIO_LOCAL
+ * @ingroup pktio_constants
+ * This defines the pktio channel as type local TBD
+ */
+#define PKTIO_LOCAL 0x2
+
+/**
+ * @def PKTIO_PKT
+ * @ingroup pktio_constants
+ * This defines the pktio channel is for NETCP
+ */
+#define PKTIO_PKT 0x4
+
+/**
+ * @def PKTIO_SB
+ * @ingroup pktio_constants
+ * This defines the pktio channel is for sideband crypto
+ */
+#define PKTIO_SB 0x8
+
+/**
+ * @def PKTIO_Q_ANY
+ * @ingroup pktio_constants
+ * This defines the pktio IO queue number to be TBD
+ */
+#define PKTIO_Q_ANY -1
+
+int qnum; /**< PKTIO channel queue number */
+
+
+int max_n; /**< Maximum number of packets read in 1 poll */
+} PKTIO_CFG_T;
+
+struct NETAPI_tag;
+
+/* a pktio channel .. */
+
+
+
+/**
+ * @ingroup pktio_structures
+ * @brief PKTIO handle structure definition.
+ *
+ * @details PKTIO handle strucutre which is returned from call to @ref pktio_create
+ */
+typedef struct PKTIO_HANDLE_Tag
+{
+/**
+ * @def PKTIO_INUSE
+ * @ingroup pktio_constants
+ * This defines is used to TBD
+ */
+#define PKTIO_INUSE 0xfeedfeed
+
+ int inuse; /**<true is pktio channel is in use TBD */
+
+/**
+ * Set the "use_nwal" field to one of the defines listed below.
+ * <br>
+ * The following defines are used to populate the use_nwal field TBD:
+ * @ref PKTIO_4_IPC , @ref PKTIO_4_ADJ_NWAL, @ref PKTIO_DEF_NWAL. @ref PKTIO_4_ADJ_SB., @ref PKTIO_DEF_SB
+ */
+ int use_nwal;
+
+/**
+ * @def PKTIO_4_IPC
+ * @ingroup pktio_constants
+ * This define is for IPC TBD
+ */
+#define PKTIO_4_IPC 0
+
+/**
+ * @def PKTIO_4_ADJ_NWAL
+ * @ingroup pktio_constants
+ * This define is for (RX)app queues managed by NWAL
+ */
+#define PKTIO_4_ADJ_NWAL 1
+
+/**
+ * @def PKTIO_DEF_NWAL
+ * @ingroup pktio_constants
+ * This define is for default NWAL RX/TX queues
+ */
+#define PKTIO_DEF_NWAL 2
+
+/**
+ * @def PKTIO_4_ADJ_SB
+ * This define is for (RX) crypto side band app defined
+ * @ingroup pktio_constants
+ */
+#define PKTIO_4_ADJ_SB 3
+
+/**
+ * @def PKTIO_DEF_SB
+ * @ingroup pktio_constants
+ * This define is for crypto side band default
+ */
+#define PKTIO_DEF_SB 4
+
+ struct NETAPI_tag * back; /**< back handle */
+ void * nwalInstanceHandle; /**<save here for conveninece TBD*/
+ PKTIO_CB cb; /**< callback for channel */
+ PKTIO_CFG_T cfg; /**<configuration */
+ Qmss_QueueHnd q; /**<the associated queue handle */
+ Qmss_Queue qInfo; /**<and its qm#/q# */
+ int max_n; /**<max # of pkts to read in one poll */
+ void * cookie; /**<app specific */
+ PKTIO_SEND _send; /**<pktio type specific send function */
+ PKTIO_POLL _poll; /**<pktio type specific POLL function */
+ char name[PKTIO_MAX_NAME+1]; /**< Name of pktio channel */
+} PKTIO_HANDLE_T;
+
+
+/**
+ * @ingroup pktio_structures
+ * @brief PKTIO control TBD
+ *
+ * @details PKTIO control RBD
+ */
+typedef struct PKTIO_CONTROL_Tag
+{
+/**
+ * @def PKTIO_CLEAR
+ * This defines is used to clear out the PKTIO channel
+ */
+#define PKTIO_CLEAR 0x1
+
+/**
+ * @def PKTIO_DIVERT
+ * This defines is used to divert to dest channel TBD
+ */
+#define PKTIO_DIVERT 0x2
+
+ int op; /**< TBD */
+ PKTIO_HANDLE_T *dest; /**< Handle to PKTIO channel */
+} PKTIO_CONTROL_T;
+
+
+
+/**
+ * @ingroup pktio_functions
+ * @brief API creates a NETAPI PKTIO channel
+ *
+ * @details This assigns global resources to a NETAPI pktio channel.
+ * Once created, the channel can be used to send and/or receive
+ * a Ti_Pkt. This can be used for communication with the
+ * the Network co-processor (NETCP) or for internal inter-processor
+ * communication. The channel is saved under the assigned name
+ * and can be opened by other netapi threads instances.
+ * @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
+ * @param[in] name A pointer to the char string name for channel
+ * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
+ * @param[in] p_cfg Pointer to channel configuration, @ref PKTIO_CFG_T
+ * @param[out] err Pointer to error code.
+ * @retval Handle to the pktio instance or NULL on error, @ref PKTIO_HANDLE_T
+ * @pre @ref netapi_init
+ */
+PKTIO_HANDLE_T * pktio_create(NETAPI_T netapi_handle,
+ char * name,
+ PKTIO_CB cb,
+ PKTIO_CFG_T* p_cfg,
+ int * err);
+
+/**
+ * @ingroup pktio_functions
+ * @brief API opens an existing NETAPI PKTIO channel
+ *
+ * @details This opens an NETAPI pktio channel for use. The channel
+ * must have already been created via @ref pktio_create or may have
+ * been created internally during the netapi intialization.
+ * Once opened, the channel can be used to send and/or receive
+ * a Ti_Pkt. This can be used for communication with the
+ * the Network co-processor (NETCP) or for internal inter-processor
+ * communication.
+ *
+ * @param[in] netapi_handle The NETAPI handle, @ref NETAPI_T
+ * @param[in] name A pointer to the char string name for channel to open
+ * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
+ * @param[in] p_cfg Pointer to channel configuration, @ref PKTIO_CFG_T
+ * @param[out] err Pointer to error code.
+ * @retval Handle to the pktio instance or NULL on error, @ref PKTIO_HANDLE_T
+ * @pre @ref netapi_init, @ref pktio_create
+ */
+PKTIO_HANDLE_T * pktio_open(NETAPI_T netapi_handle,
+ char *name,
+ PKTIO_CB cb,
+ PKTIO_CFG_T *p_cfg,
+ int * err);
+
+/**
+ * @ingroup pktio_functions
+ * @brief API controls an existing NETAPI PKTIO channel
+ *
+ * @details This controls an opened pktio channel
+ *
+ * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] cb Callback to be issued on packet receive, @ref PKTIO_CB
+ * @param[in] p_cfg Pointer to channel configuration which (optional), @ref PKTIO_CFG_T
+ * @param[in] p_control Pointer to PKTIO control information (optional), @ref PKTIO_CONTROL_T
+ * @param[out] err Pointer to error code.
+ * @retval none
+ * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
+ */
+void pktio_control(PKTIO_HANDLE_T * handle,
+ PKTIO_CB cb,
+ PKTIO_CFG_T * p_cfg,
+ PKTIO_CONTROL_T *p_control,
+ int *err);
+
+/**
+ * @ingroup pktio_functions
+ * @brief API closes a PKTIO channel
+ *
+ * @details This closes a PKTIO channel
+ *
+ * @param[in] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[out] err Pointer to error code.
+ * @retval none
+ * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
+ */
+void pktio_close(PKTIO_HANDLE_T * handle,
+ int * err);
+
+/**
+ * @ingroup pktio_functions
+ * @brief API deletes a PKTIO channel
+ *
+ * @details This deletes a PKTIO channel
+ *
+ * @param[in] handle The PKTIO handle, @ref PKTIO_HANDLE_T
+ * @param[out] err Pointer to error code.
+ * @retval none
+ * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
+ */
+void pktio_delete(PKTIO_HANDLE_T * handle,
+ int * err);
+
+/**
+ * @ingroup pktio_functions
+ * @brief API sends data to a NETAPI PKTIO channel
+ *
+ * @details This sends a 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] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] pkt Pointer to the packet to send
+ * @param[in] m Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
+ * @param[out] err Pointer to error code.
+ * @retval 1 if packet sent, 0 if error
+ * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
+ */
+static inline int pktio_send(PKTIO_HANDLE_T * handle,
+ Ti_Pkt *pkt,
+ PKTIO_METADATA_T *m,
+ int * err)
+{
+ return handle->_send((struct PKTIO_HANDLE_tag *)handle, pkt, m, err);
+}
+
+/**
+ * @ingroup pktio_functions
+ * @brief API sends data to a NETAPI PKTIO channel
+ *
+ * @details This sends an array of 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] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] pkt Pointer to the packet to send
+ * @param[in] m Pointer to meta data associated with packet, @ref PKTIO_METADATA_T
+ * @param[in] np The number of packets in list to send
+ * @param[out] err Pointer to error code.
+ * @retval Number of packets sent, 0 if error
+ * @pre @ref netapi_init, @ref pktio_create, @ref pktio_open
+ */
+int pktio_sendMulti(PKTIO_HANDLE_T *handle,
+ Ti_Pkt * pkt[],
+ PKTIO_METADATA_T * m[],
+ int np,
+ int * err);
+
+/**
+ * @ingroup 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] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
+ * @param[out] err Pointer to error code.
+ * @retval 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,
+ PKTIO_POLL_T * p_poll_cfg,
+ int * err)
+{
+ return handle->_poll((struct PKTIO_HANDLE_tag *) handle, p_poll_cfg, err);
+}
+
+/**
+ * @ingroup 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] handle The PKTIO channel handle, @ref PKTIO_HANDLE_T
+ * @param[in] p_poll_cfg Pointer to pktio poll configuration. @ref PKTIO_POLL_T
+ * @param[out] err Pointer to error code.
+ * @retval 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);
+
+
+/* update max_n for poll */
+
+
+/**
+ * @brief This define sets the max number of pkts to read in one poll in the @ref PKTIO_HANDLE_T
+ */
+#define pktio_set_max_n(handle,max_n) (handle)->max_n=max_n;
+
+/**
+ * @brief This define returns NETAPI handle stored in the @ref PKTIO_HANDLE_T
+ */
+#define pktio_get_netapi_handle(handle) (handle)->back
+
+/**
+ * @brief This define sets a user space application cookie in the @ref PKTIO_HANDLE_T
+ */
+#define pktio_set_cookie(handle, cookie) (handle)->cookie = cookie
+
+/**
+ * @brief This define returns a previously set user space application cookie stored in the @ref PKTIO_HANDLE_T
+ */
+#define pktio_get_cookie(handle) (handle)->cookie
+
+
+/**
+ * @brief This define returns a associate queue handle stored in the @ref PKTIO_HANDLE_T
+ */
+
+#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 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 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 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 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 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