]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/commitdiff
This commit adds the following:
authorTinku Mannan <tmannan@ti.com>
Wed, 20 Feb 2013 13:52:04 +0000 (08:52 -0500)
committerTinku Mannan <tmannan@ti.com>
Wed, 20 Feb 2013 13:52:04 +0000 (08:52 -0500)
1. Added consistency in API and internal function naming conventions.
2. Incorporated code review comments.
3. General cleanup.

28 files changed:
ti/runtime/netapi/netapi.h
ti/runtime/netapi/netapi_sched.h
ti/runtime/netapi/netapi_sec.h
ti/runtime/netapi/netapi_util.h
ti/runtime/netapi/netapi_ver.h
ti/runtime/netapi/netcp_cfg.h
ti/runtime/netapi/netsync.h
ti/runtime/netapi/pktio.h
ti/runtime/netapi/src/netapi.c
ti/runtime/netapi/src/netapi_init.c
ti/runtime/netapi/src/netapi_loc.h
ti/runtime/netapi/src/netapi_sched.c
ti/runtime/netapi/src/netapi_sec.c
ti/runtime/netapi/src/netcp_cfg.c
ti/runtime/netapi/src/pdkv2/netapi_navig.c
ti/runtime/netapi/src/pdkv3/netapi_navig.c
ti/runtime/netapi/src/pktio.c
ti/runtime/netapi/test/addsa_test.c
ti/runtime/netapi/test/mt_test.c
ti/runtime/netapi/test/net_test.c
ti/runtime/netapi/test/net_test.h
ti/runtime/netapi/test/net_test_router.c
ti/runtime/netapi/test/net_test_sa_utils.c
ti/runtime/netapi/test/net_test_thread_utils.c
ti/runtime/netapi/test/net_test_utils.c
ti/runtime/netapi/test/net_test_utils.h
ti/runtime/netapi/test/trie.c
ti/runtime/netapi/tools/dumpdesc.c

index 09f8460da481afc928b6991b3031a786051da6b7..de1e815c7985c332f733c2f65b19066dbcc8fdd7 100755 (executable)
@@ -5,7 +5,7 @@
  *
  * DESCRIPTION: NETAPI definitions and data structures
  *
- * REVISION HISTORY: rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  *
index fd18617e7b0d690c6e17a3dccfb2b6ec6fbd174e..ab5d3b074f35a286eefd4c85da1e24266017c10d 100755 (executable)
@@ -115,16 +115,16 @@ typedef struct NETAPI_SCHED_CONFIG_Tag
  */
 #define NETAPI_SCHED_FOREVER 0L
 
-    int valid_flags;            /**< Flags used to configure the scheduler, @ref NETAPI_SCHED_DURATION,
-                                     @ref NETAPI_SCHED_CBV. */
-    uint64_t duration;          /**< Duration scheduler is configured to run, 0 == forever,
-                                     non-zero value is ticks for scheduler to run */
-    NETAPI_SCHED_CB house_cb;   /**< House keeping callback */
+    int             valid_flags;            /**< Flags used to configure the scheduler, @ref NETAPI_SCHED_DURATION,
+                                                 @ref NETAPI_SCHED_CBV. */
+    uint64_t        duration;               /**< Duration scheduler is configured to run, 0 == forever,
+                                                 non-zero value is ticks for scheduler to run */
+    NETAPI_SCHED_CB house_cb;               /**< House keeping callback */
 
-    uint32_t interval;          /**< How many poll loop intervals after which to call the house keeping
-                                     callback function*/
+    uint32_t        interval;               /**< How many poll loop intervals after which to call the house keeping
+                                                 callback function*/
 
-    int power_control;          /**< Currently NOT_IMPLEMENTED  */
+    int             power_control;          /**< Currently NOT_IMPLEMENTED  */
 
 
 /**
@@ -142,13 +142,13 @@ typedef struct NETAPI_SCHED_CONFIG_Tag
 #define NETAPI_SCHED_POWER_ALWAYS_ON 1
 
 
-    int idle_time;              /**< Currently NOT_IMPLEMENTED  */
-    Bool  yield;                /**< Option to yield in scheduling loop if no packets received
-                                     from any NETAPI PKTIO channel associated with NETAPI instance.*/
-    Bool pollCtrlQ;             /**< Option to poll the NETCP control queues associated with the NETAPI
-                                     intance in scheduling loop. */
-    Bool pollGarbageQ;          /**< Option to poll the internal heaps and any application heaps that have
-                                     been registerd with NETAPI instance. in scheduling loop. */
+    int             idle_time;              /**< Currently NOT_IMPLEMENTED  */
+    Bool            yield;                  /**< Option to yield in scheduling loop if no packets received
+                                                 from any NETAPI PKTIO channel associated with NETAPI instance.*/
+    Bool            pollCtrlQ;              /**< Option to poll the NETCP control queues associated with the NETAPI
+                                                 intance in scheduling loop. */
+    Bool            pollGarbageQ;           /**< Option to poll the internal heaps and any application heaps that have
+                                                 been registerd with NETAPI instance. in scheduling loop. */
 } NETAPI_SCHED_CONFIG_T;
 
 /**
@@ -194,15 +194,15 @@ typedef struct NETAPI_SCHED_HANDLE_Tag
 #define NETAPI_SCHED_STATE_OPEN 2
 
 
-    volatile int state;                /**< @ref NETAPI_SCHED_STATE_CLOSE ,
-                                            @ref NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS ,
-                                            @ref NETAPI_SCHED_STATE_OPEN */
-    void * back;                        /**< Pointer back to NETAPI handle */
-    NETAPI_SCHED_CONFIG_T config;       /**< NETAPI scheduler configuration */
-    uint64_t start;                     /**< Start time of NETAPI scheduler context */ 
-    volatile int shutdown_reason;       /**< Currently NOT_IMPLEMENTED  */
-    volatile uint64_t shutdown_time;    /**< Time till scheduler context will be shutdown/closed */
-    NETAPI_SCHED_STATS_T stats;         /**< Per scheduler satistics */
+    volatile int            state;              /**< @ref NETAPI_SCHED_STATE_CLOSE ,
+                                                     @ref NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS ,
+                                                     @ref NETAPI_SCHED_STATE_OPEN */
+    void*                   back;               /**< Pointer back to NETAPI handle */
+    NETAPI_SCHED_CONFIG_T   config;             /**< NETAPI scheduler configuration */
+    uint64_t                start;              /**< Start time of NETAPI scheduler context */ 
+    volatile int            shutdown_reason;    /**< Currently NOT_IMPLEMENTED  */
+    volatile uint64_t       shutdown_time;      /**< Time till scheduler context will be shutdown/closed */
+    NETAPI_SCHED_STATS_T    stats;              /**< Per scheduler satistics */
 } NETAPI_SCHED_HANDLE_T;
 
 
@@ -260,9 +260,9 @@ typedef struct NETAPI_SCHED_SHUTDOWN_Tag
  *  @retval     Handle associated with created scheduler context, @ref NETAPI_SCHED_HANDLE_T
  *  @pre        @ref netapi_init 
  */
-NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n,
-                                         NETAPI_SCHED_CONFIG_T * p_config,
-                                         int *p_err);
+NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T                   n,
+                                         NETAPI_SCHED_CONFIG_T*     p_config,
+                                         int*                       p_err);
 
 /// @cond NOT_IMPLEMENTED
 /**
@@ -276,9 +276,9 @@ NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n,
  *  @retval     Handle associated with created scheduler context, @ref NETAPI_SCHED_HANDLE_T
  *  @pre        @ref netapi_schedOpen 
  */
-int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s,
-                        NETAPI_SCHED_CONFIG_T *p_config,
-                        int *p_err);
+int netapi_schedControl(NETAPI_SCHED_HANDLE_T*  s,
+                        NETAPI_SCHED_CONFIG_T*  p_config,
+                        int*                    p_err);
 /// @endcond
 
 /**
@@ -291,8 +291,8 @@ int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s,
  *  @retval     always 1
  *  @pre        @ref netapi_schedOpen 
  */
-int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s,
-                              int * p_err);
+int netapi_schedRun(NETAPI_SCHED_HANDLE_T*  s,
+                    int*                    p_err);
 
 /**
  *  @ingroup sched_functions
@@ -305,9 +305,9 @@ int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s,
  *  @retval     NO USED, ALWAYS 1
  *  @pre        @ref netapi_schedOpen 
  */
-int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s, 
-                         NETAPI_SCHED_SHUTDOWN_T * p_close,
-                         int *p_err);
+int netapi_schedClose(NETAPI_SCHED_HANDLE_T*    s, 
+                      NETAPI_SCHED_SHUTDOWN_T*  p_close,
+                      int*                      p_err);
 
 /**
  *  @ingroup sched_functions
@@ -333,8 +333,8 @@ static NETAPI_T netapi_schedGetHandle(NETAPI_SCHED_HANDLE_T *s)
  *  @param[in]  p_ccycles  total number of cache control cycles taken by scheduler poll loop
  *  @retval     none
  */
-void netapi_schedGetStats(NETAPI_SCHED_HANDLE_T *s,
-                                                        unsigned long long * p_pkts, 
-                                                        unsigned long long * p_cycles,
-                                                        unsigned long long * p_ccycles);
+void netapi_schedGetStats(NETAPI_SCHED_HANDLE_T*    s,
+                          unsigned long long*       p_pkts, 
+                          unsigned long long*       p_cycles,
+                          unsigned long long*       p_ccycles);
 #endif
index 000cbded27a504e3559654ce5a118939bc8d8bab..b60543030a5b684deeb5fea4fc5810603b8da609 100755 (executable)
@@ -115,13 +115,18 @@ typedef struct NETAPI_SEC_SA_INFO_tag
 
 
 /**
- * @brief This defines the SA mode of operation to be INFLOW.  This means that IPSEC will be applied as the packet is being received or just before it is transmitted. This is a more efficient way to use SA and saves host cycles.
+ * @brief This defines the SA mode of operation to be INFLOW. This means that IPSEC will be applied 
+ *        as the packet is being received or just before it is transmitted. This is a more efficient 
+ *        way to use SA and saves host cycles.
  * @ingroup security_constants
  */
 #define NETAPI_SEC_SA_INFLOW   0x2
 
 /**
- * @brief This defines the SA mode of operation to be SIDEBAND.  This means that Security Acclerator is to be used a traditional accelerator where for RX, the packet will first be received on host and then sent back to SA for crypto.  For TX the packet will first be sent to SA for crypto, returned to host and then sent to NETCP for transmit.
+ * @brief This defines the SA mode of operation to be SIDEBAND. This means that Security Acclerator is
+ *        to be used a traditional accelerator where for RX, the packet will first be received on host 
+ *        and then sent back to SA for crypto.  For TX the packet will first be sent to SA for crypto,
+ *        returned to host and then sent to NETCP for transmit.
  * @ingroup security_constants
  */
 #define NETAPI_SEC_SA_SIDEBAND 0x1
@@ -150,16 +155,16 @@ typedef struct NETAPI_SEC_SA_INFO_tag
  *              (note: if a RX policy is matched also then the ID associated with the policy will be tagged instead).
  *  @pre        @ref netapi_init
  */
-NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
+NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T                     h,
                                 int iface_no,
-                                NETAPI_SEC_SA_INFO_T *sa_info,
-                                nwalSecKeyParams_t *key_params,
-                                int mode,
-                                NETCP_CFG_ROUTE_HANDLE_T  route,
-                                void ** data_mode_handle,
-                                void ** inflow_mode_handle,
-                                void * user_data,
-                                int * perr);
+                                NETAPI_SEC_SA_INFO_T*       sa_info,
+                                nwalSecKeyParams_t*         key_params,
+                                int                         mode,
+                                NETCP_CFG_ROUTE_HANDLE_T    route,
+                                void**                      data_mode_handle,
+                                void**                      inflow_mode_handle,
+                                void*                       user_data,
+                                int*                        perr);
 /**
  *  @ingroup cfg_security_functions
  *  @brief  netapi_secDelSA: API to delete an IPSEC SA. 
@@ -172,7 +177,10 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
  *  @retval     none
  *  @pre        @ref netapi_init @ref netapi_secAddSA
 */
-void netapi_secDelSA(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa_app_id,  int *perr);
+void netapi_secDelSA(NETAPI_T       h,
+                     int            iface_no, 
+                     NETCP_CFG_SA_T sa_app_id,
+                     int*           perr);
 
 /**
  *  @ingroup cfg_security_functions
@@ -192,15 +200,15 @@ void netapi_secDelSA(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa_app_id,  int *p
  *  @retval    Aplication id associated with created receive security policy @ref NETCP_CFG_IPSEC_POLICY_T.  This is used to refer to the policy in the @ref netapi_secDelRxPolicy call.  Also, packets that match this policy but do not pass any further lookups in NETCP will be tagged with this ID
  *  @pre        @ref netapi_init @ref netapi_secAddSA
 */
-NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h,
-                                NETCP_CFG_SA_T sa,
-                                nwal_IpType ipType,
-                                nwalIpAddr_t  * src_ip_addr,
-                                nwalIpAddr_t  * dst_ip_addr,
-                                nwalIpOpt_t * ip_qualifiers,
-                                NETCP_CFG_ROUTE_HANDLE_T  route,
-                                void * user_data,
-                                int * perr);
+NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T                     h,
+                                               NETCP_CFG_SA_T               sa,
+                                               nwal_IpType                  ipType,
+                                               nwalIpAddr_t*                src_ip_addr,
+                                               nwalIpAddr_t*                dst_ip_addr,
+                                               nwalIpOpt_t*                 ip_qualifiers,
+                                               NETCP_CFG_ROUTE_HANDLE_T     route,
+                                               void*                        user_data,
+                                               int*                         perr);
 
 /**
  *  @ingroup cfg_security_functions
@@ -213,9 +221,9 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h,
  *  @retval     none
  *  @pre        @ref netapi_init, @ref netapi_secAddRxPolicy
 */
-void netapi_secDelRxPolicy(NETAPI_T h,
+void netapi_secDelRxPolicy(NETAPI_T                 h,
                            NETCP_CFG_IPSEC_POLICY_T policy_app_id, 
-                           int *perr);
+                           int*                     perr);
 
 
 /**
index 724663d115f47afb5cf4b9180c6adda479c9e596..0ae5171a14f83a8215298a5e64b9159432a414d9 100755 (executable)
@@ -7,7 +7,7 @@
  * DESCRIPTION:  netapi utility header file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
@@ -49,9 +49,9 @@
 
 #define NETAPI_DEBUG */
 #ifdef NETAPI_DEBUG
-#define Debug_printf printf
+#define netapi_Log printf
 #else
-#define Debug_printf
+#define netapi_Log
 #endif
 
 
@@ -75,7 +75,8 @@ static hplib_spinLock_T netapi_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
  *  @retval     1 if OK, <0 on error
  *  @pre        @ref netapi_init
  */
-static inline int netapi_registerHeap(NETAPI_T p,  Pktlib_HeapHandle h)
+static inline int netapi_registerHeap(NETAPI_T p,
+                                      Pktlib_HeapHandle h)
 {
     NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
     int i;
@@ -106,7 +107,8 @@ static inline int netapi_registerHeap(NETAPI_T p,  Pktlib_HeapHandle h)
  *  @retval     <0 if err, 1 if OK
  *  @pre        @ref netapi_init
  */
-static inline int netapi_unregisterHeap(NETAPI_T p,  Pktlib_HeapHandle h)
+static inline int netapi_unregisterHeap(NETAPI_T p,
+                                        Pktlib_HeapHandle h)
 {
     NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
     int i;
@@ -135,14 +137,15 @@ static inline int netapi_unregisterHeap(NETAPI_T p,  Pktlib_HeapHandle h)
  *  @retval     <0 if err, 1 if OK
  *  @pre        @ref netapi_init  @ref netapi_registerHeap
  */
-static inline int netapi_closeHeap(NETAPI_T p, Pktlib_HeapHandle h)
+static inline int netapi_closeHeap(NETAPI_T p,
+                                   Pktlib_HeapHandle h)
 {
     Qmss_QueueHnd q;
     Pktlib_garbageCollection(p);
     q = Pktlib_getZeroHeapQueue(p);
-    netapi_zapQ(q);
+    netapip_zapQ(q);
     q= Pktlib_getInternalHeapQueue(p);
-    netapi_zapQ(q);
+    netapip_zapQ(q);
 }
 /**
  *  @ingroup netapi_gen_functions
@@ -173,7 +176,8 @@ static inline void * netapi_getCookie(NETAPI_T p)
  *  @retval     none
  *  @pre        @ref netapi_init
  */
-static inline void netapi_setCookie(NETAPI_T p, void * cookie)
+static inline void netapi_setCookie(NETAPI_T p,
+                                    void * cookie)
 {
     NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
     pp->cookie= cookie;
@@ -227,7 +231,7 @@ static inline NETCP_CFG_ROUTE_HANDLE_T netapi_getDefaultRoute(NETAPI_T p)
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgGetPolicyUserData    API to retrieve user mode data associated with Policy APPID.
+ *  @brief netapi_netcpCfgGetPolicyUserData    API to retrieve user mode data associated with Policy APPID.
  *
  *  @details This api is used to retrieve user mode data associated with an Policy APPID
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -235,11 +239,11 @@ static inline NETCP_CFG_ROUTE_HANDLE_T netapi_getDefaultRoute(NETAPI_T p)
  *  @retval void*   pointer to user mode data.
  *  @pre       @ref netapi_init 
  */
-static inline void*  netcp_cfgGetPolicyUserData(NETAPI_T h,
-                                          NETCP_CFG_SA_T    app_id)
+static inline void*  netapi_netcpCfgGetPolicyUserData(NETAPI_T h,
+                                                      NETCP_CFG_SA_T app_id)
 {
     NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
-    int slot = (app_id >>8) &0xffff;
+    int slot = netapi_cfgGetMatchId(app_id);
     if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_POLICY))
     {
         return NULL;
@@ -249,7 +253,7 @@ static inline void*  netcp_cfgGetPolicyUserData(NETAPI_T h,
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgGetIpSecUserData    API to retrieve user mode data associated with IPSEC APPID.
+ *  @brief netapi_netcpCfgGetIpSecUserData    API to retrieve user mode data associated with IPSEC APPID.
  *
  *  @details This api is used to retrieve user mode data associated with an IPSEC APPID
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -257,17 +261,17 @@ static inline void*  netcp_cfgGetPolicyUserData(NETAPI_T h,
  *  @retval void*   pointer to user mode data.
  *  @pre       @ref netapi_init 
  */
-static inline void*  netcp_cfgGetIpSecUserData(NETAPI_T h,
-                                          NETCP_CFG_SA_T    app_id)
+static inline void*  netapi_netcpCfgGetIpSecUserData(NETAPI_T h,
+                                                     NETCP_CFG_SA_T app_id)
 {
     NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
-    int slot = (app_id >>8) &0xffff;
-    Debug_printf("netcp_cfgGetIpSecUserData: slot found %d\n", slot);
+    int slot = netapi_cfgGetMatchId(app_id);
+    netapi_Log("netapi_netcpCfgGetIpSecUserData: slot found %d\n", slot);
     if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_SA))
     {
         return NULL;
     }
-    Debug_printf("netcp_cfgGetIpSecUserData: user data being returned %d\n",
+    netapi_Log("netapi_netcpCfgGetIpSecUserData: user data being returned %d\n",
         (uint32_t)(p->tunnel[slot].user_data));
     return (p->tunnel[slot].user_data);
 }
@@ -275,7 +279,7 @@ static inline void*  netcp_cfgGetIpSecUserData(NETAPI_T h,
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgGetIpUserData    API to retrieve user mode data associated with Generic IP APPID.
+ *  @brief netapi_netcpCfgGetIpUserData    API to retrieve user mode data associated with Generic IP APPID.
  *
  *  @details This api is used to retrieve user mode data associated with a Generic IP APPID
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -283,11 +287,11 @@ static inline void*  netcp_cfgGetIpSecUserData(NETAPI_T h,
  *  @retval void*   pointer to user mode data.
  *  @pre       @ref netapi_init 
  */
-static inline void*  netcp_cfgGetIpUserData(NETAPI_T h,
-                                          NETCP_CFG_SA_T    app_id)
+static inline void*  netapi_netcpCfgGetIpUserData(NETAPI_T h,
+                                                  NETCP_CFG_SA_T app_id)
 {
     NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
-    int slot = (app_id >>8) &0xffff;
+    int slot = netapi_cfgGetMatchId(app_id);
     if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_NUM_IP))
     {
         return NULL;
@@ -297,7 +301,7 @@ static inline void*  netcp_cfgGetIpUserData(NETAPI_T h,
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgGetClassiferUserData  API to retrieve user mode data associated with Classifer APPID.
+ *  @brief netapi_netcpCfgGetClassiferUserData  API to retrieve user mode data associated with Classifer APPID.
  *
  *  @details This api is used to retrieve user mode data associated with a flassifier APPID
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -305,11 +309,11 @@ static inline void*  netcp_cfgGetIpUserData(NETAPI_T h,
  *  @retval void*   pointer to user mode data.
  *  @pre       @ref netapi_init 
  */
-static inline void*  netcp_cfgGetClassiferUserData(NETAPI_T h,
-                                          NETCP_CFG_SA_T    app_id)
+static inline void*  netapi_netcpCfgGetClassiferUserData(NETAPI_T h,
+                                                         NETCP_CFG_SA_T app_id)
 {
     NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
-    int slot = (app_id >>8) &0xffff;
+    int slot = netapi_cfgGetMatchId(app_id);
     if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
     {
         return NULL;
@@ -320,7 +324,7 @@ static inline void*  netcp_cfgGetClassiferUserData(NETAPI_T h,
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgGetUserData    API to retrieve user mode data associated with APPID.
+ *  @brief netapi_netcpCfgGetUserData    API to retrieve user mode data associated with APPID.
  *
  *  @details This api is used to retrieve user mode data associated with an APPID
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -328,8 +332,8 @@ static inline void*  netcp_cfgGetClassiferUserData(NETAPI_T h,
  *  @retval void*   pointer to user mode data.
  *  @pre       @ref netapi_init 
  */
-static inline void*  netcp_cfgGetUserData(NETAPI_T h,
-                                          NETCP_CFG_SA_T    app_id)
+static inline void*  netapi_netcpCfgGetUserData(NETAPI_T h,
+                                                NETCP_CFG_SA_T app_id)
 {
     NETCP_CFG_SA_T appIdType;
     NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
@@ -338,20 +342,20 @@ static inline void*  netcp_cfgGetUserData(NETAPI_T h,
     switch(appIdType)
     {
         case(NETAPI_NETCP_MATCH_IPSEC):
-            Debug_printf("netcp_cfgGetUserData: ipsec appID found\n");
-            return (netcp_cfgGetIpSecUserData(h, app_id));
+            netapi_Log("netapi_netcpCfgGetUserData: ipsec appID found\n");
+            return (netapi_netcpCfgGetIpSecUserData(h, app_id));
             break;
         case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
-            Debug_printf("netcp_cfgGetUserData: policy appID found\n");
-            return (netcp_cfgGetPolicyUserData(h, app_id));
+            netapi_Log("netapi_netcpCfgGetUserData: policy appID found\n");
+            return (netapi_netcpCfgGetPolicyUserData(h, app_id));
             break;
         case(NETAPI_NETCP_MATCH_GENERIC_IP):
-            Debug_printf("netcp_cfgGetUserData: IP appID found\n");
-            return (netcp_cfgGetIpUserData(h, app_id));
+            netapi_Log("netapi_netcpCfgGetUserData: IP appID found\n");
+            return (netapi_netcpCfgGetIpUserData(h, app_id));
             break;
         case(NETAPI_NETCP_MATCH_CLASS):
-            Debug_printf("netcp_cfgGetUserData: classifier appID found\n");
-            return (netcp_cfgGetClassiferUserData(h, app_id));
+            netapi_Log("netapi_netcpCfgGetUserData: classifier appID found\n");
+            return (netapi_netcpCfgGetClassiferUserData(h, app_id));
             break;
         default:
             return NULL;
@@ -361,7 +365,7 @@ static inline void*  netcp_cfgGetUserData(NETAPI_T h,
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgUpdateUserData    API to retrieve user mode data associated with APPID.
+ *  @brief netapi_netcpCfgUpdateUserData    API to retrieve user mode data associated with APPID.
  *
  *  @details This api is used to retrieve user mode data associated with an APPID
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -369,14 +373,14 @@ static inline void*  netcp_cfgGetUserData(NETAPI_T h,
  *  @retval void*   pointer to user mode data.
  *  @pre       @ref netapi_init 
  */
-static inline netapi_RetValue netcp_cfgUpdateUserData(NETAPI_T h,
-                                          NETCP_CFG_SA_T    app_id,
-                                          void * user_data)
+static inline netapi_RetValue netapi_netcpCfgUpdateUserData(NETAPI_T h,
+                                                            NETCP_CFG_SA_T app_id,
+                                                            void * user_data)
 {
     NETCP_CFG_SA_T appIdType;
     NETAPI_NWAL_GLOBAL_CONTEXT_T *p = &netapi_get_global()->nwal_context;
 
-    int slot = (app_id >>8) &0xffff;
+    int slot = netapi_cfgGetMatchId(app_id);
     if ((slot <0 ) || (slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
     {
         return NETAPI_ERR_BAD_INPUT;
@@ -385,22 +389,22 @@ static inline netapi_RetValue netcp_cfgUpdateUserData(NETAPI_T h,
     switch(appIdType)
     {
         case(NETAPI_NETCP_MATCH_IPSEC):
-            Debug_printf("netcp_cfgUpdateUserData: ipsec appID found\n");
+            netapi_Log("netapi_netcpCfgUpdateUserData: ipsec appID found\n");
             p->tunnel[slot].user_data = user_data;
             return NETAPI_ERR_OK;
             break;
         case(NETAPI_NETCP_MATCH_IPSEC_POLICY):
-            Debug_printf("netcp_cfgUpdateUserData: policy appID found\n");
+            netapi_Log("netapi_netcpCfgUpdateUserData: policy appID found\n");
             p->policy[slot].user_data = user_data;
             return NETAPI_ERR_OK;
             break;
         case(NETAPI_NETCP_MATCH_GENERIC_IP):
-            Debug_printf("netcp_cfgUpdateUserData: IP appID found\n");
+            netapi_Log("netapi_netcpCfgUpdateUserData: IP appID found\n");
             p->ips[slot].user_data = user_data;
             return NETAPI_ERR_OK;
             break;
         case(NETAPI_NETCP_MATCH_CLASS):
-            Debug_printf("netcp_cfgUpdateUserData: classifier appID found\n");
+            netapi_Log("netapi_netcpCfgUpdateUserData: classifier appID found\n");
             p->classi[slot].user_data = user_data;
             return NETAPI_ERR_OK;
             break;
index 65a16e8b1510d5eed9ed15a4619b45aecea6e403..6f50f0978a1eaf88342562d2e6f48f4c10ecd4d3 100755 (executable)
@@ -7,7 +7,7 @@
  * @brief DESCRIPTION:  netapi version information for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
index edda8d55ac01af2bd508767551066f4c41ca54ea..2e7c4503e8d901be39589025ec6c2cd66b0feca6 100755 (executable)
@@ -233,66 +233,111 @@ typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
  * @note  APPIDs are present in RX packet meta data and tell "how far" the packet got
  * through the classification rules of NETCP. 
  * APPID is 32 bits:
- * bits 31-24 = MATCH STAGE (NETAPI_NECP_MATCH_xxx below)
- * bits 23-8  = identifier (depends on match stage)
- * bits  7-0  = logical mac interface
+ * bits 31-24 = NETAPI_NETCP_MATCH_STAGE
+ * bits 23-8  = NETAPI_NETCP_MATCH_ID identifier 
+ * bits  7-0  = NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE logical mac interface
 */
 
+#define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT 0 
+#define NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK 0xFF
+
+#define NETAPI_NETCP_MATCH_ID_SHIFT 8 
+#define NETAPI_NETCP_MATCH_ID_MASK 0xFFFF
+
+#define NETAPI_NETCP_MATCH_STAGE_SHIFT 24
+#define NETAPI_NETCP_MATCH_STAGE_MASK 0xFF
+
+#define netapi_cfgGetMatchStage(appid)  (((appid) >> NETAPI_NETCP_MATCH_STAGE_SHIFT) & NETAPI_NETCP_MATCH_STAGE_MASK)
+#define netapi_cfgGetMatchId(appid) (((appid) >> NETAPI_NETCP_MATCH_ID_SHIFT) & NETAPI_NETCP_MATCH_ID_MASK)
+#define netapi_cfgGetMatchLogicalMacIface(appid) (((appid) >> NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT) & \
+                                                    NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK)
+
+
 /**
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_MATCH_GENERIC_MAC
- *      This define is used for an APPID that indicates that a packet matched a MAC entry.  Entry # (logical interface) is in byte 0 of APPID.
- *      Packet did not match any other rule
+ *      This define is used for an APPID that indicates that a packet matched a MAC entry.
+ *      Logical MAC interface location:
+ *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
+ *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
+ *      Packet did not match any other rule.
  */
-#define NETAPI_NETCP_MATCH_GENERIC_MAC  0x10000000  //lower byte==interface
+#define NETAPI_NETCP_MATCH_GENERIC_MAC  0x10000000
 
 /**
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_MATCH_GENERIC_IP
- *      This define is used for an APPID that indicates that a packet matched a MAC entry.  Entry # (logical interface) is in byte 0 of APPID. 
- *      Packet also matched a generic IP rule attached to that interface.  The IP rule # for the interface
- *      is given in Bytes 3,2 of the APPID.   Packet did not match any other rule
+ *      This define is used for an APPID that indicates that a packet matched a MAC entry.
+ *      Logical MAC interface location:
+ *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
+ *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
+ *       IP rule number for this interface location:
+ *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
+ *          NETAPI_NETCP_MATCH_ID_MASK.
+ *      Packet also matched a generic IP rule attached to that interface.
+ *      Packet did not match any other rule.
  */
-#define NETAPI_NETCP_MATCH_GENERIC_IP   0x20000000  //lower byte==interface
-
+#define NETAPI_NETCP_MATCH_GENERIC_IP   0x20000000
 
 /**
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_MATCH_CLASS
- *      This define is used for an APPID that indicates that a packet matched a MAC entry.  Entry # (logical interface) is in byte 0 of APPID.
- *      Packet also matched a generic IP rule  attached to that interface OR a general IP rule added as part of
- *      the classifier or it matched a combination of ISPEC SA rule and a policy check.  Finally,
- *      Packet matched a L4 port rule that was added as part of a classifer.  Bytes 3-2
- *      give the ID of the classifier . Packet did not match any other rule
+ *      This define is used for an APPID that indicates that a packet matched a MAC entry.
+ *      Logical MAC interface location:
+ *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
+ *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
+ *      Classifer ID location:
+ *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
+ *          NETAPI_NETCP_MATCH_ID_MASK.
+ *      Packet also matched a generic IP rule attached to 
+ *      that interface OR a general IP rule added as part of the classifier or it matched a combination
+ *      of ISPEC SA rule and a policy check.  In addition, packet matched a L4 port rule that was added 
+ *      as part of a classifer. Packet did not match any other rule.
  */
-#define NETAPI_NETCP_MATCH_CLASS        0x80000000  //FULL MATCH or' in classifier (16 bits), lower byte==interface
+#define NETAPI_NETCP_MATCH_CLASS        0x80000000
 
 /**
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_MATCH_CLASS_L3
- *      This define is used for an APPID that indicates that a  packet matched a MAC entry.  Entry # (logical interface) is in byte 0 of APPID.
- *      Packet also  matched a general IP rule added as part of a classifier.  But it not match a
- *      L4 port or any other rule. We cannot say what classifer partially matched so Bytes 3-2 are
- *      not applicable
+ *      This define is used for an APPID that indicates that a  packet matched a MAC entry.
+ *      Logical MAC interface location:
+ *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
+ *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
+ *      Packet also  matched a general IP rule added as part 
+ *      of a classifier.  But it not match a L4 port or any other rule. 
+ *      We cannot determine what classifer partially matched so Bytes 3-2 are not applicable
  */
-#define NETAPI_NETCP_MATCH_CLASS_L3     0x40000000  //MATCHED L3 but not L4.  lower byte==interface
+#define NETAPI_NETCP_MATCH_CLASS_L3     0x40000000
 
 /**
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_MATCH_IPSEC
- *      This define is used for an APPID that indicates that a packet matched a MAC entry.  Entry # (logical interface) is in byte 0 of APPID.
- *      Packet also matched an IPSEC SA  rule (matched proto, dest ip and SPI).  The SA id  is in
- *      bytes 3-2 of APPID.  Packet did not match any other rule (so may have failed a policy check)
+ *      This define is used for an APPID that indicates that a packet matched a MAC entry.
+ *      Logical MAC interface location:
+ *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
+ *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
+ *      SA ID location:
+ *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
+ *          NETAPI_NETCP_MATCH_ID_MASK.
+ *      Packet also matched an IPSEC SA  rule (matched proto, destination ip and SPI).  
+ *      Packet did not match any other rule (so may have failed a policy check)
  */
-#define NETAPI_NETCP_MATCH_IPSEC        0x01000000  //lower byte==interface, Or' in SA id (16 bits)
+#define NETAPI_NETCP_MATCH_IPSEC        0x01000000  
+
 
 /**
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_MATCH_IPSEC_POLICY
- *      This define is used for an APPID that indicates that a packet matched a MAC entry.  Entry # (logical interface) is in byte 0 of APPID.
- *      Packet also matched an IPSEC SA rule (matched proto, dest ip and SPI).  Packet also matched
- *      a POLICY RULE - this is a check of the inner IP.  The IPSEC RX Policy ID  is in
- *      bytes 3-2 of APPID.  Packet did not match any other rule 
+ *      This define is used for an APPID that indicates that a packet matched a MAC entry
+ *      Logical MAC interface location:
+ *          Refer to NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_SHIFT and 
+ *          NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK.
+ *      Packet also matched an IPSEC SA rule (matched proto, 
+ *      dest ip and SPI).  Packet also matched a POLICY RULE (this is a check of the inner IP).
+ *      IPSEC RX Policy ID location:
+ *          Refer to NETAPI_NETCP_MATCH_ID_SHIFT and 
+ *          NETAPI_NETCP_MATCH_ID_MASK.
+ *      Packet did not match any other rule 
  */
 #define NETAPI_NETCP_MATCH_IPSEC_POLICY 0x02000000  //lower byte==interface, Or' in SA id (16 bits)
 
@@ -300,7 +345,7 @@ typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
  * @ingroup cfg_constants
  * @def NETAPI_NETCP_CFG_MATCH_EXCEPTION
  *      This define is used for an APPID that indicates that a packet is of type exception. 
       Actual exception id is in byte 0 of APPID.
*      Actual exception id is in byte 0 of APPID.
  */
 #define NETAPI_NETCP_CFG_MATCH_EXCEPTION     0x08000000
 
@@ -308,7 +353,7 @@ typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgAddFlow   API to add a flow
+ *  @brief netapi_netcpCfgAddFlow   API to add a flow
  * 
  *  @details This api is used to add a flow
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -320,7 +365,7 @@ typedef uint32_t NETCP_CFG_EXCEPTION_PKT_T;
  *  @retval     NETCP flow handle, @ref NETCP_CFG_FLOW_HANDLE_T
  *  @pre       @ref netapi_init
  */
-NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
+NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
                                             int n, 
                                             Pktlib_HeapHandle handles[],
                                             int sizes[],
@@ -329,16 +374,16 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgDelFlow   API to delete a flow
+ *  @brief netapi_netcpCfgDelFlow   API to delete a flow
  * 
  *  @details This api is used to delete a flow.
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
  *  @param[in]  p    handle to NETCP  flow
  *  @param[out] err     pointer to error return
  *  @retval     none
- *  @pre       @ref netapi_init, netcp_cfgAddFlow
+ *  @pre       @ref netapi_init, netapi_netcpCfgAddFlow
  */
-void netcp_cfgDelFlow(NETAPI_T h ,
+void netapi_netcpCfgDelFlow(NETAPI_T h ,
                                             NETCP_CFG_FLOW_HANDLE_T p ,
                                             int * err);
 
@@ -364,20 +409,18 @@ void netcp_cfgDelFlow(NETAPI_T h ,
  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
  *  @pre       @ref netapi_init
  */
-NETCP_CFG_IP_T  netcp_cfgAddIp(
-                  NETAPI_T  h,
-                  int  iface_no,
-                  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_ROUTE_HANDLE_T  route,
-                  void * user_data,
-                  int * err
-                  );
+NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T                   h,
+                                     int                        iface_no,
+                                     nwal_IpType                ipType,
+                                     nwalIpAddr_t*              ip_addr,
+                                     nwalIpOpt_t*               ip_qualifiers,
+                                     NETCP_CFG_ROUTE_HANDLE_T   route,
+                                     void*                      user_data,
+                                     int*                       err);
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgDelIp   API to delete IP interface
+ *  @brief netapi_netcpCfgDelIp   API to delete IP interface
  * 
  *  @details This api is used to delete an IP interface
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -389,22 +432,24 @@ NETCP_CFG_IP_T  netcp_cfgAddIp(
  *  @param[in]  ip_rule_id      @ref NETCP_CFG_IP_T
  *  @param[out] err     pointer to error return
  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
- *  @pre       @ref netapi_init , @ref netcp_cfgAddIp
+ *  @pre       @ref netapi_init , @ref netapi_netcpCfgAddIp
  */
-void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers, 
-                  NETCP_CFG_IP_T  ip_rule_id,
-                  int *err);
+void netapi_netcpCfgDelIp(NETAPI_T          h, 
+                          int               iface_no,
+                          nwal_IpType       ipType,
+                          nwalIpAddr_t*     ip_addr,
+                          nwalIpOpt_t*      ip_qualifiers, 
+                          NETCP_CFG_IP_T    ip_rule_id,
+                          int*              err);
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgCreateMacInterface  API to create a MAC interface
+ *  @brief netapi_netcpCfgCreateMacInterface  API to create a MAC interface
  * 
  *  @details This api is used to create a MAC interface.
  *      Once it is created, the MAC interface can be used to receive packets. The API
  *      adds a rule to the NETCP 1st level lookup tables to route all packets with destination
- *      MAC matching supplied argument and not matching any other lookup entry (see @ref netcp_cfgAddIp) to
+ *      MAC matching supplied argument and not matching any other lookup entry (see @ref netapi_netcpCfgAddIp) to
  *      the supplied route, @ref NETCP_CFG_ROUTE_T, (or default route).
  *      Packets arriving that match this rule are identified in meta data with Appid=  NETAPI_NETCP_MATCH_GENERIC_MAC
  *      Note: The internal SOC switch (if operating in full swithc mode) may need to  be "taught" that this mac
@@ -420,29 +465,29 @@ void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
  *  @retval     returns AppID for interface (this is returned in meta data for received packets matching this rule an no others, @ref NETCP_CFG_MACIF_T
  *  @pre       @ref netapi_init 
  */
-NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
-                    NETAPI_T  h,     
-                    uint8_t *p_mac, 
-                    int iface_no,
-                    int switch_port,
-                    NETCP_CFG_ROUTE_HANDLE_T  route,
-                    NETCP_CFG_VLAN_T  vlan,
-                    int state,
-                    int * err
-);
+NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T                   h,
+                                                     uint8_t*                   p_mac, 
+                                                     int                        iface_no,
+                                                     int                        switch_port,
+                                                     NETCP_CFG_ROUTE_HANDLE_T   route,
+                                                     NETCP_CFG_VLAN_T           vlan,
+                                                     int                        state,
+                                                     int *                      err);
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgDelMac   API to delete MAC  interface
+ *  @brief netapi_netcpCfgDelMac   API to delete MAC  interface
  * 
  *  @details This api is used to delete a MAC interface
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
  *  @param[in]  iface_no    interface number (0,1,..)
  *  @param[out] err     pointer to error return
  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
- *  @pre       @ref netapi_init , @ref netcp_cfgCreateMacInterface 
+ *  @pre       @ref netapi_init , @ref netapi_netcpCfgCreateMacInterface 
  */
-void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err);
+void netapi_netcpCfgDelMac(NETAPI_T     h,
+                           int          iface_no,
+                           int*         err);
 
 
 /**
@@ -460,10 +505,10 @@ typedef uint32_t NETCP_CFG_CLASS_T;
  */
 typedef struct NETCP_CFG_CLASS_L4_Tag
 {
-    int             iface;      /**< Indicates which MAC interface packet should be received on*/
-    NETCP_CFG_IP_T  ip;         /**< IP rule to match: see @ref NETCP_CFG_IP_T */
+    int                 iface;      /**< Indicates which MAC interface packet should be received on*/
+    NETCP_CFG_IP_T      ip;         /**< IP rule to match: see @ref NETCP_CFG_IP_T */
     nwal_appProtoType_t proto;   /**< L4 proto (-1 for don't care)*/
-    nwalAppProto_t   appProto;   /**< L4 Ports or equivalent */
+    nwalAppProto_t      appProto;   /**< L4 Ports or equivalent */
 
 } NETCP_CFG_CLASS_L4_T;
 
@@ -477,16 +522,15 @@ typedef struct NETCP_CFG_CLASS_L4_Tag
 //classifier L4 + policy  (L2, L3 (outer), tunnel, L3 (inner)  implied by policy
 typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
 {
-    int             iface;      /**< Indicates which MAC interface packet should be received from */
+    int                       iface;      /**< Indicates which MAC interface packet should be received from */
     NETCP_CFG_IPSEC_POLICY_T  ip_policy; /**< IPSEC policy configuration. see @ref NETCP_CFG_IPSEC_POLICY_T */
-    nwal_appProtoType_t proto;   /**< L4 proto (-1 for don't care)*/
-    nwalAppProto_t   appProto;   /**< L4 Ports or equivalent */
+    nwal_appProtoType_t       proto;   /**< L4 proto (-1 for don't care)*/
+    nwalAppProto_t            appProto;   /**< L4 Ports or equivalent */
 
 } NETCP_CFG_CLASS_L4_IPSEC_T;
 
 
 
-
 /**
  *  @ingroup cfg_structures
  *  @brief NETAPI Classifier L4/L3 configuration
@@ -495,15 +539,15 @@ typedef struct NETCP_CFG_CLASS_L4_IPSEC_Tag
  */
 typedef struct NETCP_CFG_CLASS_L3_L4_Tag
 {
-    int             iface;      /**< Indicates which MAC interface packet is from */
-    nwal_IpType ipType;         /**< IP address type, IPV4 or IPV6 */
-    nwalIpAddr_t  * ip_addr;    /**< IP address to match */
-    nwalIpOpt_t * ip_qualifiers;/**< IP address qualifiers */
-    NETCP_CFG_ROUTE_HANDLE_T p_fail_route; /**< What to do if L3 matches but L4 fails AND L3 is a 
-                                            * new rule.(if exisitng rule, then existing fail
-                                            *route will be used). */
-    nwal_appProtoType_t proto;   /**< L4 proto (-1 for don't care)*/
-    nwalAppProto_t   appProto;   /**< Ports or equivalent */
+    int                         iface;          /**< Indicates which MAC interface packet is from */
+    nwal_IpType                 ipType;         /**< IP address type, IPV4 or IPV6 */
+    nwalIpAddr_t*               ip_addr;        /**< IP address to match */
+    nwalIpOpt_t*                ip_qualifiers;  /**< IP address qualifiers */
+    NETCP_CFG_ROUTE_HANDLE_T    p_fail_route;   /**< What to do if L3 matches but L4 fails AND L3 is a 
+                                                     new rule.(if exisitng rule, then existing fail
+                                                     route will be used). */
+    nwal_appProtoType_t         proto;          /**< L4 proto (-1 for don't care)*/
+    nwalAppProto_t              appProto;       /**< Ports or equivalent */
 } NETCP_CFG_CLASS_L3_L4_T;
 
 /**
@@ -548,7 +592,7 @@ typedef struct NETCP_CFG_CLASSIFIER_Tag
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgAddClass   API to attach a classifier rule to NETCP.
+ *  @brief netapi_netcpCfgAddClass   API to attach a classifier rule to NETCP.
  *      This can be used to route a particular packet flow to a specific PKTIO channel
  * 
  *  @details This api can be used to route a particular packet flow to a particular PktIO channel, using a specific 
@@ -561,28 +605,29 @@ typedef struct NETCP_CFG_CLASSIFIER_Tag
  *  @param[out] err     pointer to error return
  *  @retval     returned AppID for attached rule. This is returned in RX meta data for packets matching this rule and no other, @ref NETCP_CFG_IP_T
  *  @pre       @ref netapi_init
- */NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
-                                    NETCP_CFG_CLASSIFIER_T *p_class,
-                                    NETCP_CFG_ROUTE_HANDLE_T p_route,
-                                    int action,void * user_data,
-                                    int * err);
+ */NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T                   h,
+                                             NETCP_CFG_CLASSIFIER_T*    p_class,
+                                             NETCP_CFG_ROUTE_HANDLE_T   p_route,
+                                             int                        action,
+                                             void*                      user_data,
+                                             int*                       err);
 
 
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgDelClass   API to delete a preconfigured classifier
+ *  @brief netapi_netcpCfgDelClass   API to delete a preconfigured classifier
  * 
  *  @details This API can be used to delete a preconfigured classifier
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
  *  @param[in]  classId
  *  @param[out] err     pointer to error return
  *  @retval     none
- *  @pre       @ref netapi_init, @ref netcp_cfgAddClass
+ *  @pre       @ref netapi_init, @ref netapi_netcpCfgAddClass
  */
-void netcp_cfgDelClass(NETAPI_T h,
-                       NETCP_CFG_CLASS_T classId,
-                       int *err);
+void netapi_netcpCfgDelClass(NETAPI_T           h,
+                             NETCP_CFG_CLASS_T  classId,
+                             int*               err);
 
 
 /**
@@ -590,19 +635,19 @@ void netcp_cfgDelClass(NETAPI_T h,
  *  @brief NETCP_CFG_STATS_CB   Callback function that is used to return statistics from NETCP
  * 
  *  @details The application provides a callback function that NETAPI  uses to report statistics.
- *  The request for stats is generated from the @ref netcp_cfgReqStats API.
- *  Note: to receive ths stats callback, the @ref netapi_netcpPoll funcition must be called
+ *  The request for stats is generated from the @ref netapi_netcpCfgReqStats API.
+ *  Note: to receive this stats callback, the @ref netapi_netcpPoll function must be called
  *  @param[in]  h   NETAPI instance handle, @ref NETAPI_T
  *  @param[out]  pPaStats    the PA (NETCP packet accelerator subsystem) statistics block 
  *  @retval     none 
- *  @pre       @ref netapi_init , @ref netcp_cfgReqStats, @ref netapi_netcpPoll
+ *  @pre       @ref netapi_init , @ref netapi_netcpCfgReqStats, @ref netapi_netcpPoll
  */
-typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h, 
+typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T      h,
                                    paSysStats_t* pPaStats);
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgReqStats   API to request statistics from NETCP
+ *  @brief netapi_netcpCfgReqStats   API to request statistics from NETCP
  * 
  *  @details This api is used to request a statistics from NETCP.  This will generate a stats request
  *  command to NETCP. Sometime later, the statistics result will arrive and will be passed to 
@@ -615,15 +660,15 @@ typedef void (*NETCP_CFG_STATS_CB)(NETAPI_T h,
  *  @retval     none 
  *  @pre       @ref netapi_init 
  */
-void netcp_cfgReqStats(NETAPI_T  h,
-                       NETCP_CFG_STATS_CB cb,
-                       int doClear,
-                       int *err);
+void netapi_netcpCfgReqStats(NETAPI_T               h,
+                             NETCP_CFG_STATS_CB     cb,
+                             int                    doClear,
+                             int*                   err);
 
 
 /**
  *  @ingroup cfg_functions
- *  @brief netcp_cfgExceptions    API to configure NETCP with global rules for exception packet handling
+ *  @brief netapi_netcpCfgExceptions    API to configure NETCP with global rules for exception packet handling
  *
  *  @details This api is used to configure NETCP with global rules of how to handle exception packets specified by exception_id.
  *  @param[in]  h    NETAPI instance handle, @ref NETAPI_T
@@ -633,10 +678,10 @@ void netcp_cfgReqStats(NETAPI_T  h,
  *  @retval returns app_id, @ref NETCP_CFG_EXCEPTION_PKT_T
  *  @pre       @ref netapi_init 
  */
-NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
-                                    int exception_id ,
-                                    nwal_matchAction_t action,
-                                    NETCP_CFG_ROUTE_HANDLE_T p_route);
+NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T                    h,
+                                                    int                         exception_id ,
+                                                    nwal_matchAction_t          action,
+                                                    NETCP_CFG_ROUTE_HANDLE_T    p_route);
 
 
 #endif
index 66d42fcb4956ed60023fab19e8ee2265a4a0ac1b..7bab14fc1e931a49ff685ee24b7070bdd98678eb 100755 (executable)
@@ -7,7 +7,7 @@
  * DESCRIPTION:  netapi synch utilities header file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
index b88d8b8edf8d773757b9ef2243598c8f9de62002..685981c462315f6681fdbe4b23c96446b30634fe 100755 (executable)
@@ -146,10 +146,10 @@ typedef struct PKTIO_METADATA_Tag
  */
     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 */
+        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  */
 
     void * sa_handle;                       /** This contains the appplication id associated with created SA.
@@ -163,8 +163,8 @@ typedef struct PKTIO_METADATA_Tag
  *
  *  @details This strucuture allows user space applications to specify the PKTIO packet send function.
  *
- *  @note This configuration is not expected at time of @ref pktio_open but can be updated via
- *        @ref pktio_control API.
+ *  @note This configuration is not expected at time of @ref netapi_pktioOpen but can be updated via
+ *        @ref netapi_pktioControl API.
  */
 typedef struct PKTIO_FAST_PATH_CONFIG_Tag
 {
@@ -337,13 +337,13 @@ typedef struct PKTIO_POLL_Tag
  *  @param[in]  n_pkts      Number of packets received.
   * @param[in]  ts          Timestamp associted with received packets.
  *  @retval     none
- *  @pre       @ref pktio_open
+ *  @pre       @ref netapi_pktioOpen
  */
-typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel,
-                         Ti_Pkt* p_recv[],
-                         PKTIO_METADATA_T p_meta[],
-                         int n_pkts,
-                         uint64_t ts);
+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
@@ -355,12 +355,12 @@ typedef void (*PKTIO_CB)(struct PKTIO_HANDLE_tag * channel,
  *  @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
+ *  @pre       @ref netapi_pktioOpen
  */
 typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
-                          Ti_Pkt* p_send,
-                          PKTIO_METADATA_T *p_meta,
-                          int * p_err);
+                          Ti_Pkt*                   p_send,
+                          PKTIO_METADATA_T*         p_meta,
+                          int*                      p_err);
 
 
 /**
@@ -372,11 +372,11 @@ typedef int (*PKTIO_SEND)(struct PKTIO_HANDLE_tag * channel,
  *  @param[in]  p_poll_cfg  @ref PKTIO_POLL_T, currently NOT_IMPLEMENTED
  *  @param[out] p_err       Pointer to error code.
  *  @retval     none 
- *  @pre       @ref pktio_open
+ *  @pre       @ref netapi_pktioOpen
  */
 typedef int (*PKTIO_POLL)(struct PKTIO_HANDLE_tag * channel,
-                          PKTIO_POLL_T * p_poll_cfg,
-                          int * p_err);
+                          PKTIO_POLL_T*             p_poll_cfg,
+                          int*                      p_err);
 
 
 /**
@@ -391,7 +391,7 @@ struct NETAPI_tag;
  *  @ingroup pktio_structures
  *  @brief PKTIO handle structure definition.
  *
- *  @details PKTIO handle strucutre which is returned from call to @ref pktio_create
+ *  @details PKTIO handle strucutre which is returned from call to @ref netapi_pktioCreate
  */
 typedef struct PKTIO_HANDLE_Tag
 {
@@ -528,18 +528,18 @@ typedef struct PKTIO_CONTROL_Tag
  *  @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);
+PKTIO_HANDLE_T * netapi_pktioCreate(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
+ *  must have already been created via @ref netapi_pktioCreate 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 
@@ -552,13 +552,13 @@ PKTIO_HANDLE_T * pktio_create(NETAPI_T netapi_handle,
  *  @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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate
  */
-PKTIO_HANDLE_T * pktio_open(NETAPI_T netapi_handle, 
-                            char *name,
-                            PKTIO_CB cb,
-                            PKTIO_CFG_T *p_cfg,
-                            int * err);
+PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T      netapi_handle, 
+                                 char*          name,
+                                 PKTIO_CB       cb,
+                                 PKTIO_CFG_T*   p_cfg,
+                                 int*           err);
 
 /**
  *  @ingroup pktio_functions
@@ -572,13 +572,13 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T netapi_handle,
  *  @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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-void pktio_control(PKTIO_HANDLE_T * handle,
-                    PKTIO_CB cb,
-                    PKTIO_CFG_T * p_cfg,
-                    PKTIO_CONTROL_T *p_control,
-                    int *err);
+void netapi_pktioControl(PKTIO_HANDLE_T*    handle,
+                         PKTIO_CB           cb,
+                         PKTIO_CFG_T*       p_cfg,
+                         PKTIO_CONTROL_T*   p_control,
+                         int*               err);
 
 /**
  *  @ingroup pktio_functions
@@ -589,10 +589,10 @@ void pktio_control(PKTIO_HANDLE_T * handle,
  *  @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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-void pktio_close(PKTIO_HANDLE_T * handle,
-                 int * err);
+void netapi_pktioClose(PKTIO_HANDLE_T*  handle,
+                       int*             err);
 
 /**
  *  @ingroup pktio_functions
@@ -603,10 +603,10 @@ void pktio_close(PKTIO_HANDLE_T * handle,
  *  @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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-void pktio_delete(PKTIO_HANDLE_T * handle,
-                  int * err);
+void netapi_pktioDelete(PKTIO_HANDLE_T* handle,
+                        int*            err);
 
 /**
  *  @ingroup pktio_functions
@@ -614,20 +614,20 @@ void pktio_delete(PKTIO_HANDLE_T * handle,
  *
  *  @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
+ *  must have already been created via @ref netapi_pktioCreate or opened
+ *  via @ref netapi_pktioOpen.  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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-static inline int  pktio_send(PKTIO_HANDLE_T * handle, 
-                              Ti_Pkt *pkt,
-                              PKTIO_METADATA_T *m,
-                              int * err)
+static inline int  pktio_send(PKTIO_HANDLE_T*   handle,
+                              Ti_Pkt*           pkt,
+                              PKTIO_METADATA_Tm,
+                              int*              err)
 {
    return handle->_send((struct PKTIO_HANDLE_tag *)handle, pkt, m, err);
 }
@@ -638,8 +638,8 @@ static inline int  pktio_send(PKTIO_HANDLE_T * handle,
  *
  *  @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
+ *  must have already been created via @ref netapi_pktioCreate or opened
+ *  via @ref netapi_pktioOpen.  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
@@ -647,13 +647,13 @@ static inline int  pktio_send(PKTIO_HANDLE_T * handle,
  *  @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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-int pktio_sendMulti(PKTIO_HANDLE_T *handle,
-                    Ti_Pkt * pkt[],
-                    PKTIO_METADATA_T * m[],
-                    int np,      
-                    int * err);
+int netapi_pktioSendMulti(PKTIO_HANDLE_T*   handle,
+                          Ti_Pkt*           pkt[],
+                          PKTIO_METADATA_T* m[],
+                          int               np,
+                          int*              err);
 
 /**
  *  @ingroup pktio_functions
@@ -662,18 +662,18 @@ int pktio_sendMulti(PKTIO_HANDLE_T *handle,
  *  @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
+ *  have already been created via @ref netapi_pktioCreate or opened
+ *  via @ref netapi_pktioOpen.  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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-static inline int pktio_poll(PKTIO_HANDLE_T * handle,
-                             PKTIO_POLL_T * p_poll_cfg,
-                             int * err)
+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);
 }
@@ -687,21 +687,18 @@ static inline int pktio_poll(PKTIO_HANDLE_T * handle,
  *  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
+ *  have already been created via @ref netapi_pktioCreate or opened
+ *  via @ref netapi_pktioOpen.  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
+ *  @pre       @ref netapi_init, @ref netapi_pktioCreate, @ref netapi_pktioOpen
  */
-int pktio_pollAll(NETAPI_T handle, 
-                  PKTIO_POLL_T * p_poll_cfg, 
-                  int *err);
-
-
-/* update max_n for poll */
+int netapi_pktioPollAll(NETAPI_T        handle, 
+                       PKTIO_POLL_T*    p_poll_cfg, 
+                       int*             err);
 
 
 /**
@@ -767,9 +764,9 @@ static inline Qmss_QueueHnd pktio_mGetDefaultNetCPL4Q(PKTIO_HANDLE_T *h)
  *  @ingroup pktio_functions
  *  @brief  API to perform descriptor push to QMSS Queue
  */
-static inline void pktio_mQmssQueuePushDescSizeRaw(Qmss_QueueHnd hnd,
-                                                       void *descAddr,
-                                                       uint32_t descSize)
+static inline void pktio_mQmssQueuePushDescSizeRaw(Qmss_QueueHnd    hnd,
+                                                   void*            descAddr,
+                                                   uint32_t         descSize)
 {
     return(Qmss_queuePushDescSizeRaw(hnd,descAddr,descSize));
 }
index 82278511ace732a5cc0aa7a98576cec1b7cfa38e..017c79b707630dd69eb9a0d0ba75a953d80992da 100755 (executable)
@@ -1,13 +1,14 @@
-/*******************************
+/***********************************************************************
  * FILE: netapi.c
- * Purpose:  implementation of netapi startup/shutdown
- **************************************************************
+ * Purpose:  Main initialization and shutdown routines of NETAPI 
+ *           user space transport library.
+ ***********************************************************************
  * FILE: netapi.c
  * 
  * DESCRIPTION:  netapi main source file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
  * *****************************/
-//#define NWAL_ENABLE_SA
-#include <stdio.h>
-#include <stdlib.h>
+
 #include <unistd.h>
-#include <string.h>
 #include "netapi.h"
-
-
-
-/*------------internal prototypes---------------*/
-static uint8_t* netapiSharedMemoryMalloc(uint32_t size);
-static void netapiSharedMemoryFree(uint8_t* ptr, uint32_t size);
-static int system_init(NETAPI_HANDLE_T *);
-static void netapi_cleanup_at_start(void);
-
-
-/*------------globals-----------------*/
-#define NUM_HOST_DESC  (TUNE_NETAPI_NUM_LOCAL_DESC)
-#define SIZE_LOCAL_DESC  (TUNE_NETAPI_DESC_SIZE) 
-#define SIZE_SHARED_DESC (TUNE_NETAPI_DESC_SIZE)
-
-#define CONFIG_BUFSIZE_PA_INST      256
-#define CONFIG_BUFSIZE_L2_TABLE     1000
-#define CONFIG_BUFSIZE_L3_TABLE     4000
+#include "netapi_loc.h"
 
 static NETAPI_CFG_T netapi_default_cfg=
 {
-TUNE_NETAPI_PERM_MEM_SZ,
-0,  //start of packet offset for hw to place data on rx for default flow
-TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
-TUNE_NETAPI_NUM_GLOBAL_DESC,        //total we will use
-TUNE_NETAPI_DEFAULT_NUM_BUFFERS,   //#descriptors+buffers in default heap
-TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS, //#descriptors w/o buffers in default heap
-TUNE_NETAPI_DEFAULT_BUFFER_SIZE,   //size of buffers in default heap
-0,0
+    TUNE_NETAPI_PERM_MEM_SZ,
+    0,  //start of packet offset for hw to place data on rx for default flow
+    TUNE_NETAPI_QM_CONFIG_MAX_DESC_NUM, //max number of descriptors in system
+    TUNE_NETAPI_NUM_GLOBAL_DESC,        //total we will use
+    TUNE_NETAPI_DEFAULT_NUM_BUFFERS,   //#descriptors+buffers in default heap
+    TUNE_NETAPI_DEFAULT_NUM_SOLO_DESCRIPTORS, //#descriptors w/o buffers in default heap
+    TUNE_NETAPI_DEFAULT_BUFFER_SIZE,   //size of buffers in default heap
+    0,0
 };
 
 /* Global variablesto hold virtual address of various subsystems */
 hplib_virtualAddrInfo_T netapi_VM_VirtAddr[HPLIB_MAX_MEM_POOLS];
+
 /* Global variables which needs to be populated with memory pool attributes
-    which is passed to HPLIB for memory pool initialization*/
+   which is passed to HPLIB for memory pool initialization*/
 hplib_memPoolAttr_T netapi_VM_MempoolAttr[HPLIB_MAX_MEM_POOLS];
 unsigned char *netapi_VM_QMemLocalDescRam;
 unsigned char *netapi_VM_QMemGlobalDescRam;
 unsigned char *netapi_VM_SaContextVaddr;
 
-static Pktlib_HeapIfTable  netapi_pktlib_ifTable;
-static NETAPI_GLOBAL_T netapi_global;
+Pktlib_HeapIfTable  netapi_pktlib_ifTable;
+NETAPI_GLOBAL_T netapi_global;
 NETAPI_GLOBAL_T * netapi_get_global(){ return &netapi_global;}
 
 /* utility API for NETAPI user to get pktlib if table to use if he creates his own heap */
 Pktlib_HeapIfTable *netapi_getPktlibIfTable(void) {return &netapi_pktlib_ifTable;}
 
-//zap a queue
-void netapi_zapQ(int queueNum);\
-
 
 /********************************************************************
 * FUNCTION PURPOSE:  API instantiates the NETAPI and allocated global resources.
@@ -165,8 +144,8 @@ NETAPI_T netapi_init(int master, NETAPI_CFG_T * p_cfg)
     /* system init */
     if(master==NETAPI_SYS_MASTER)
     {
-        err = system_init(p);
-        netcp_cfgExceptions(p, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+        err = netapip_systemInit(p);
+        netapi_netcpCfgExceptions(p, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
         if (err<0) 
         {
             goto ERR_netapi_init;
@@ -185,11 +164,11 @@ NETAPI_T netapi_init(int master, NETAPI_CFG_T * p_cfg)
     {
 
         /* Start the QMSS. */
-        if (netapi_start_qm() != 1)
+        if (netapip_startQm() != 1)
         {
             goto ERR_netapi_init;
         }
-        netapi_start_nwal(p_master->netcp_heap, 
+        netapip_startNwal(p_master->netcp_heap, 
                                        p_master->netcp_control_rx_heap,
                                        p_master->netcp_control_tx_heap, 
                                        &p->nwal_local,
@@ -198,7 +177,7 @@ NETAPI_T netapi_init(int master, NETAPI_CFG_T * p_cfg)
     }
     else
     {
-        Debug_printf("netapi_init: no master specified\n");
+        netapi_Log("netapi_init: no master specified\n");
         goto ERR_netapi_init;
     }
 
@@ -234,7 +213,7 @@ void netapi_shutdown(NETAPI_T h)
     NETAPI_HANDLE_T * p = (NETAPI_HANDLE_T *) h;
     if (!p) return;
 
-    Debug_printf(">netapi: WARNING shutdown may not be fully implemented\n");
+    netapi_Log("netapi: WARNING shutdown may not be fully implemented\n");
     if (p->master ==NETAPI_SYS_MASTER)
     {
         /* close nwal */
@@ -252,273 +231,21 @@ void netapi_shutdown(NETAPI_T h)
         {
             if (p->createdHeaps[i])  {netapi_closeHeap(h,p->createdHeaps[i]);p->createdHeaps[i]=NULL;}
         }
-        netapi_cleanup_at_start();  //clear 1st 50 not-specified queues..
+        netapip_cleanupAtStart();  //clear 1st 50 not-specified queues..
         hplib_vmTeardown();
     }
     free(p);
     return;
 }
 
-
-/********************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function to gracefully cleanup when startup
-*                                  issue occurs.
- ********************************************************************
- * DESCRIPTION:  NETAPI internal function to gracefully cleanup when startup
-*                                  issue occurs.
- ********************************************************************/
-void netapi_err_teardown() { netapi_cleanup_at_start(); exit(-99); }
-
-
-/***************************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function for virtual memory allocation.
- ***************************************************************************
- * DESCRIPTION:  NETAPI internal function for virtual memory allocation.
- **************************************************************************/
-
-static uint8_t* netapiSharedMemoryMalloc(uint32_t size)
-{
-return  (uint8_t *)hplib_vmMemAlloc(size +netapi_global.cfg.def_heap_extra_size , 128, 0); 
-}
-
-/********************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function for virtual memory free.
- ********************************************************************
- * DESCRIPTION:  NETAPI internal function for virtual memory free.
- ********************************************************************/
-static void netapiSharedMemoryFree(uint8_t* ptr, uint32_t size)
-{
-    /* Do Nothing. */
-    Debug_printf(">netapi Unexpected.  need to provide a free () for some reason!! \n");
-    return;
-}
-
-/********************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function system initialization
- ********************************************************************
- * DESCRIPTION:  NETAPI internal function system initialization
- ********************************************************************/
-static int system_init(NETAPI_HANDLE_T * handle) 
-{
-    int32_t             result;
-    Pktlib_HeapHandle   sharedHeapHandle;
-    Pktlib_HeapHandle   controlRxHeapHandle,controlTxHeapHandle;    
-    Pktlib_HeapCfg      heapCfg;
-    int32_t             errCode;
-    int count=0;
-
-#ifdef NETAPI_USE_DDR
-    /* Init attributes for DDR */
-    netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_KM_CACHED0;
-    netapi_VM_MempoolAttr[0].phys_addr = 0;
-    netapi_VM_MempoolAttr[0].size = 0;
-
-       /* Init attributes for un-cached MSMC */
-    netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_UN_CACHED;
-    netapi_VM_MempoolAttr[1].phys_addr = CSL_MSMC_SRAM_REGS;
-    netapi_VM_MempoolAttr[1].size = TUNE_NETAPI_PERM_MEM_SZ;
-#else
-    netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_KM_CACHED0;
-    netapi_VM_MempoolAttr[1].phys_addr = 0;
-    netapi_VM_MempoolAttr[1].size = 0;
-
-       /* Init attributes for un-cached MSMC */
-    netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_UN_CACHED;
-    netapi_VM_MempoolAttr[0].phys_addr = CSL_MSMC_SRAM_REGS;
-    netapi_VM_MempoolAttr[0].size = TUNE_NETAPI_PERM_MEM_SZ;
-#endif
-    /* initialize all the memory we are going to use
-       - chunk for buffers, descriptors
-       - memory mapped peripherals we use, such as QMSS, PA, etc */
-    result = hplib_vmInit(&netapi_VM_VirtAddr[0], 2, &netapi_VM_MempoolAttr[0]);
-
-    /* TODO: at this point, we need to create the QM regions which need to moved out of the above 
-    netapi_VM_memory_setup() call, also need to move out the SA context stuff */
-
-    if (result == hplib_OK) Debug_printf(">netapi: system init - memory set  up OK\n");
-    else {Debug_printf(">netap: system init - memory set up failed\n"); return -1;}
-
-
-#ifdef NETAPI_ENABLE_SECURITY
-#define SEC_CONTEXT_SZ 384  //not tunable
-/* allocate 2x number of tunnels since we need one for inflow and one for data mode */
-    netapi_VM_SaContextVaddr = hplib_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
-                                        SEC_CONTEXT_SZ), 128, 0);
-    if (!netapi_VM_SaContextVaddr)
-    {
-        Debug_printf(">netapi ERROR: Failed to map SA context memory region\n");
-        return (-1);
-    }
-    Debug_printf(">hplib VM_SaContext: Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
-
-#else
-   netapi_VM_SaContextVaddr= (char *) NULL;
-#endif
-
-/* TODO: the QM regions is application specific and needs to be moved since number of regions created is appliction specific, put this in system_init */
-    /* (3) Allocate 2 QM regions from continguous chunk above */
-    netapi_VM_QMemGlobalDescRam = 
-                                                            (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
-                                                                                                        TUNE_NETAPI_DESC_SIZE),
-                                                                                                        128, 0);
-
-    netapi_VM_QMemLocalDescRam =
-                                                            (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
-                                                                                                        TUNE_NETAPI_DESC_SIZE),
-                                                                                                        128, 0);
-    Debug_printf("netapi local desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
-
-    //get timer running
-#ifdef CORTEX_A8
-    netapi_init_timer();
-#endif
-     Debug_printf("system_init: returned from netapi_init_timer\n");
-
-    /* Initialize Queue Manager Sub System */
-    result = netapi_init_qm (netapi_global.cfg.def_max_descriptors); 
-    
-    if (result != 1)
-    {
-         Debug_printf("system_init: returned from netapi_init_qm with failure\n");
-        return -1;
-    }
-
-    /* Start the QMSS. */
-    if (netapi_start_qm() != 1)
-    {
-      Debug_printf("system_init: returned from netapi_start_qm with failure\n");
-        return -1;
-    }
-    
-
-    //clean our old junk in 1st bunch of queues that will be allocated to us
-    netapi_cleanup_at_start();
- Debug_printf("system_init: returned from netapi_cleanup_at_start\n");
-    /* Initialize the global descriptor memory region. */
-    result= netapi_qm_setup_mem_region( 
-                      netapi_global.cfg.def_tot_descriptors_for_us,
-                      SIZE_SHARED_DESC,
-                      (unsigned int *) netapi_VM_QMemGlobalDescRam,
-                      NETAPI_GLOBAL_REGION);
-    if(result <0) {Debug_printf(">netapi; can't setup QM shared region\n"); return -1;}
-
-Debug_printf(">system_init: returned from netapi_qm_setup_mem_region\n");
-#if 0 //todo setup 2nd region
-/* Initialize the local memory region configuration. */
-    result= netapi_qm_setup_mem_region( 
-                      NUM_HOST_DESC,
-                      SIZE_LOCAL_DESC,
-                      netapi_VM_QMemLocalDescRam,
-                      NETAPI_LOCAL_REGION);
-    if(result <0) {Debug_printf("can't setup local region\n"); return -1;}
-#endif
-    /* Initialize CPPI CPDMA */
-
-    result = netapi_init_cppi ();
-    Debug_printf(">system_init: returned from netapi_init_cppi\n");
-    if (result != 1)
-    {
-        Debug_printf (">netapi: Error initializing CPPI SubSystem error code : %d\n",result);
-        return -1;
-    }
-
-    /* CPPI and Queue Manager are initialized. */
-    Debug_printf (">netapi: Queue Manager and CPPI are initialized.\n");
-
-    /* create main pkt heap */
-    /* Initialize the Shared Heaps. */
-    Pktlib_sharedHeapInit();
-    Debug_printf(">system_init: returned from Pktlib_sharedHeapInit\n");
-    /* Populate the heap interface table. */
-    netapi_pktlib_ifTable.data_malloc             = netapiSharedMemoryMalloc;
-    netapi_pktlib_ifTable.data_free               = netapiSharedMemoryFree;
-
-    /* Initialize the heap configuration. */
-    memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
-    /* Populate the heap configuration */
-    heapCfg.name                = "netapi";
-    heapCfg.memRegion           = NETAPI_GLOBAL_REGION;
-    heapCfg.sharedHeap          = 1;
-    heapCfg.useStarvationQueue  = 0;
-    heapCfg.dataBufferSize      = netapi_global.cfg.def_heap_buf_size;
-    heapCfg.numPkts             = netapi_global.cfg.def_heap_n_descriptors;
-    heapCfg.numZeroBufferPackets= netapi_global.cfg.def_heap_n_zdescriptors;
-    heapCfg.heapInterfaceTable.data_malloc  = netapi_pktlib_ifTable.data_malloc;
-    heapCfg.heapInterfaceTable.data_free    = netapi_pktlib_ifTable.data_free;
-    heapCfg.dataBufferPktThreshold   = 0;
-    heapCfg.zeroBufferPktThreshold   = 0;
-
-    /* Create Shared Heap with specified configuration. */
-    sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
-     Debug_printf(">system_init: returned from Pktlib_createHeap1\n");
-    //todo -> cleanup on failure
-    if (!sharedHeapHandle) { Debug_printf(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
-    handle->netcp_heap= sharedHeapHandle;
-
-
-    /* Update for Control */
-    heapCfg.name                = "netapi_control_rx";
-    heapCfg.sharedHeap          = 1;
-    heapCfg.dataBufferSize      = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
-    heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
-    heapCfg.numZeroBufferPackets= 0;
-
-    controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
-     Debug_printf(">system_init: returned from Pktlib_createHeap2\n");
-   //todo -> cleanup on failure
-   if (!controlRxHeapHandle) { Debug_printf(">netapi -'netapi_control_rx' heap create failed, Error Code: %d\n",errCode); return -1;}
-   handle->netcp_control_rx_heap= controlRxHeapHandle;
-
-   
-   heapCfg.name                = "netapi_control_tx";
-   heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
-
-   controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
-    Debug_printf(">system_init: returned from Pktlib_createHeap3\n");
-   //todo -> cleanup on failure
-   if (!controlTxHeapHandle) { Debug_printf(">netapi -'netapi_control_tx' heap create failed, Error Code: %d\n",errCode); return -1;}
-   handle->netcp_control_tx_heap= controlTxHeapHandle;
-
-    /* now NWAL */
-    result = netapi_init_nwal(
-                              NETAPI_GLOBAL_REGION,
-                              &netapi_pktlib_ifTable, 
-                              &netapi_global.nwal_context,
-                              &netapi_global.cfg);
-    if (result<0) {Debug_printf(">netapi  init_nwal() failed\n"); return -1; }
- Debug_printf("system_init: returned from netapi_init_nwal\n");
-    /* start NWAL */
-
-
-    /* Common Initialization for all cores */
-    while(count < TUNE_NETAPI_MAX_NUM_TRANS)
-    {
-        netapi_global.nwal_context.transInfos[count].transId = count;
-        count++;
-    }
-    result = netapi_start_nwal(sharedHeapHandle, 
-                               controlRxHeapHandle,
-                               controlTxHeapHandle,
-                               &handle->nwal_local,
-                               &netapi_global.cfg,
-                               &netapi_global.nwal_context);
-    if (result<0) {Debug_printf("netapi start_nwal() failed\n"); return -1; }
-    Debug_printf("system_init: returned from netapi_start_nwal\n");
-    return 0;
-}
-
-/*************************************************************
- ******************MISC INTERNAL******************************
-**************************************************************/
-
 /***********************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function to poll the internal heaps
-*                    and any application created heaps that have been registered
-*                    with NETAPI instance.
+* FUNCTION PURPOSE:  API is used to poll for NETCP configuration response messages.
 ************************************************************************
-* DESCRIPTION:    The poll function checks the garbage collection queue 
-                  associated  with the heap and returns descriptors and 
-                  buffers when appropriate to the main free queue.
+* DESCRIPTION:  This API is used to poll the netapi internal heaps and any 
+ *              application-created heaps that have been registered with 
+ *              the netapi instance. The poll function checks the garbage collection 
+ *              queue associated with the heap and returns descriptors and buffers 
+ *              when appropriate to the main free queue.
 ***********************************************************************/
 void netapi_pollHeapGarbage(NETAPI_T h)
 {
@@ -536,11 +263,13 @@ void netapi_pollHeapGarbage(NETAPI_T h)
 }
 
 /****************************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function which poll NETCP control queue
-*                    for responses
+* FUNCTION PURPOSE:  API is used to poll for NETCP configuration response messages.
 ****************************************************************************
-* DESCRIPTION:  NETAPI internal function which poll NETCP control queue 
-*                    for responses
+* DESCRIPTION:  This API is used to poll the netapi internal heaps and any 
+ *              application-created heaps    that have been registered with the 
+ *              netapi instance. The poll function checks the garbage collection 
+ *              queue associated with the heap and returns descriptors and buffers
+ *              when appropriate to the main free queue.
 ***************************************************************************/
 void netapi_netcpPoll(NETAPI_T  p)
 {
@@ -548,94 +277,3 @@ void netapi_netcpPoll(NETAPI_T  p)
     nwal_pollCtl( ((NETAPI_GLOBAL_T *) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
 }
 
-/****************************************************************
- *****************Cleanup Functions******************************
-*****************************************************************/
-
-/****************************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function which performs clean for linux user space
- ****************************************************************************
- * DESCRIPTION:  NETAPI internal function which performs clean for linux user space
- ***************************************************************************/
-void netapi_zapQ(int queueNum)
-{
-    char * descPtr;
-    int i;
-    if (!queueNum) 
-    {
-        return;
-    }
-    for (i=0;;i+=1 )
-    {
-        /* Pop descriptor from source queue */
-        if ((descPtr = (char *)pktio_mQmssQueuePopRaw(queueNum)) == NULL)
-        {
-            break;
-        }
-    }
-    if(i)
-    {
-        Debug_printf("netapi_zapQ: @recovery -  %d descriptors cleaned from qn %d\n",i, queueNum);
-    }
-}
-
-//defensive: clean out stuff hanging around
-//
-//  open a bunch of free queues and zap them
-#define NQUEUES2CLEAR 35
-static Qmss_QueueHnd tempQH[NQUEUES2CLEAR];
-static void netapi_cleanup_at_start(void)
-{
-    int i;
-    uint8_t         isAllocated;
-
-    for(i=0;i<NQUEUES2CLEAR;i++) 
-    {
-        tempQH[i] = Qmss_queueOpen(Qmss_QueueType_GENERAL_PURPOSE_QUEUE,
-                                                  QMSS_PARAM_NOT_SPECIFIED, &isAllocated);
-        netapi_zapQ(tempQH[i]);
-    }
-
-    for(i=0;i<NQUEUES2CLEAR;i++)
-    {
-        Qmss_queueClose(tempQH[i]);
-    }
-}
-
-/****************************************************************************
-* FUNCTION PURPOSE:  NETAPI internal function to display internal heap stats.
- ****************************************************************************
- * DESCRIPTION:  NETAPI internal function to display internal heap stats.
- ***************************************************************************/
-void netapi_dump_internal_heap_stats(void)
-{
-    Pktlib_HeapStats    pktLibHeapStats;
-    Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2sa_heap,&pktLibHeapStats);
-    Debug_printf("PA2SA(ingress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
-                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-    Debug_printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
-                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
-                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-#if 0
-Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2saTX_heap,&pktLibHeapStats);
-Debug_printf("PA2SA(egress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
-                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-Debug_printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
-                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
-                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-#endif
-    Pktlib_getHeapStats(netapi_get_global()->nwal_context.sa2pa_heap,&pktLibHeapStats);
-    Debug_printf("SA2PA stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
-                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-    Debug_printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
-                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
-                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
-
-}
-
-
-
-
-
-
-
index 75a256881ffdaa4bacef4b7d3aec3fc35d586860..ea257fd4ff04e8ddb42385c272a863b14d0f6ec6 100755 (executable)
@@ -1,8 +1,9 @@
-/************************************************
+/****************************************************************************
 *  FILE:  netapi_init.c
-*  Global, local initialization of NETAPI
+*  Global, Private initialization and cleanup routines and defines of NETAPI
  *
- * DESCRIPTION: Functions to initialize framework resources for running NETAPI
+ * DESCRIPTION: Functions to initialize and cleanup framework resources 
+ *              for running NETAPI
  *
  * REVISION HISTORY:
  *
  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- ***********************************************/
+ ***************************************************************************/
 
 #include "netapi.h"
-
+#include "netapi_loc.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <ti/csl/csl_xmcAux.h>
 #include <ti/drv/qmss/qmss_qm.h>
 
+
+/* Global variablesto hold virtual address of various subsystems */
+extern hplib_virtualAddrInfo_T netapi_VM_VirtAddr[];
+
+/* Global variables which needs to be populated with memory pool attributes
+   which is passed to HPLIB for memory pool initialization*/
+extern hplib_memPoolAttr_T netapi_VM_MempoolAttr[];
+extern unsigned char *netapi_VM_QMemLocalDescRam;
+extern unsigned char *netapi_VM_QMemGlobalDescRam;
+extern unsigned char *netapi_VM_SaContextVaddr;
+
+extern Pktlib_HeapIfTable  netapi_pktlib_ifTable;
+extern NETAPI_GLOBAL_T netapi_global;
+
+
 /* TODO verify: */
 #define CACHE_LINESZ    64
 
-#define System_Debug_printf   Debug_printf
+
 #define ALIGN(x)    __attribute__((aligned (x)))
 
 /*****************************************************************************
@@ -100,7 +116,7 @@ uint8_t *cppiMemTxCtlLinkBuf = NULL;
  * DESCRIPTION:  Internal NETAPI function to setup the QM memory region,
  *               once per SOC
  ********************************************************************/
-int netapi_qm_setup_mem_region(
+int netapip_qmSetupMemRegion(
                       uint32_t          numDesc,
                       uint32_t          descSize,
                       uint32_t*         pDescMemBase,
@@ -118,7 +134,7 @@ int netapi_qm_setup_mem_region(
     memInfo.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR;
     memInfo.memRegion      = memRegion;
 
-    if(memRegion == NETAPI_GLOBAL_REGION)
+    if(memRegion == TUNE_NETAPI_QM_GLOBAL_REGION)
     {
         memInfo.startIndex = TUNE_NETAPI_QM_START_INDEX;  //was 0
         netapi_qm_region_index += numDesc;
@@ -137,7 +153,7 @@ int netapi_qm_setup_mem_region(
     result = Qmss_insertMemoryRegion (&memInfo);
     if (result < QMSS_SOK)  
     {
-      Debug_printf (">function setup_qm_region: Qmss_insertMemoryRegion returned error code %d\n", result);
+      netapi_Log (">function setup_qm_region: Qmss_insertMemoryRegion returned error code %d\n", result);
       return (-1);
     }
 
@@ -151,13 +167,13 @@ int netapi_qm_setup_mem_region(
  * DESCRIPTION:  Internal NETAPI function to start QM
  *               once per thread/core
  ********************************************************************/
-int netapi_start_qm(void)
+int netapip_startQm(void)
 {
      int32_t          result;
      result = Qmss_start();
      if (result != QMSS_SOK)
      {
-         System_Debug_printf (">start_qm: Qmss_start failed with error code %d\n", result);
+         netapi_Log (">start_qm: Qmss_start failed with error code %d\n", result);
          return (-1);
      }
      return 1;
@@ -219,7 +235,7 @@ uint8_t salldChanHandle[NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE
  ********************************************************************
  * DESCRIPTION:  Internal NETAPI function to initialize NWAL subsytem
  ********************************************************************/
-int netapi_init_nwal(
+int netapip_initNwal(
     int region2use,
     Pktlib_HeapIfTable * p_table,
     NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context, 
@@ -264,7 +280,7 @@ int netapi_init_nwal(
                       Pktlib_createHeap(&heapCfg, &errCode);
     if(nwalGlobCfg.pa2SaBufPool.bufPool[0].heapHandle == NULL)
     {
-        Debug_printf (">Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool , Error Code: %d\n",errCode); 
+        netapi_Log (">Pktlib_createHeap:Heap Creation Failed for PA to SA Buffer Pool , Error Code: %d\n",errCode); 
         netapi_err_teardown(); 
         return -1;
     }
@@ -282,7 +298,7 @@ int netapi_init_nwal(
         Pktlib_createHeap(&heapCfg, &errCode);
     if(nwalGlobCfg.sa2PaBufPool.bufPool[0].heapHandle == NULL)
     {
-        Debug_printf (">Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool  , Error Code: %d\n",errCode); 
+        netapi_Log (">Pktlib_createHeap:Heap Creation Failed for SA to PA Buffer Pool  , Error Code: %d\n",errCode); 
         netapi_err_teardown();
         return -1;
     }
@@ -313,7 +329,7 @@ int netapi_init_nwal(
                                    aligns);
     if(nwalRetVal != nwal_OK)
     {
-        Debug_printf (">netapi: init_nwal - nwal_getBufferReq Failed %d\n", nwalRetVal);
+        netapi_Log ("netapi: init_nwal - nwal_getBufferReq Failed %d\n", nwalRetVal);
         return nwal_FALSE;
     }
 
@@ -330,7 +346,7 @@ int netapi_init_nwal(
     bases[nwal_BUF_INDEX_INT_HANDLES] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)nwalHandleMem);
     if(NWAL_CHAN_HANDLE_SIZE  < sizes[nwal_BUF_INDEX_INT_HANDLES])
     {
-        Debug_printf("one\n");
+        netapi_Log("one\n");
         /* Resize Memory */
         while(1);
     }
@@ -339,17 +355,17 @@ int netapi_init_nwal(
     if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF0) < sizes[nwal_BUF_INDEX_PA_LLD_BUF0])
     {
         /* Resize Memory */
-        Debug_printf("two\n");
+        netapi_Log("two\n");
         while(1);
     }
     count++;
 
     bases[nwal_BUF_INDEX_PA_LLD_BUF1] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf1);
-    Debug_printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
+    netapi_Log("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
         NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1, sizes[nwal_BUF_INDEX_PA_LLD_BUF1]);
     if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1) < sizes[nwal_BUF_INDEX_PA_LLD_BUF1])
     {
-        Debug_printf("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
+        netapi_Log("NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1 %d, size[nwal_BUF_INDEX_PA_LLD_BUF1] %d\n",
             NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF1, sizes[nwal_BUF_INDEX_PA_LLD_BUF1]);
         /* Resize Memory */
         while(1);
@@ -359,7 +375,7 @@ int netapi_init_nwal(
     bases[nwal_BUF_INDEX_PA_LLD_BUF2] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)paBuf2);
     if((NETAPI_NWAL_CONFIG_BUFSIZE_PA_BUF2) < sizes[nwal_BUF_INDEX_PA_LLD_BUF2])
     {
-        Debug_printf("four\n");
+        netapi_Log("four\n");
         /* Resize Memory */
         while(1);
     }
@@ -368,7 +384,7 @@ int netapi_init_nwal(
     bases[nwal_BUF_INDEX_SA_LLD_HANDLE] = (uint32_t *)Osal_nwalLocToGlobAddr((uint32_t)salldHandle);
     if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE) < sizes[nwal_BUF_INDEX_SA_LLD_HANDLE])
     {
-        Debug_printf("five\n");
+        netapi_Log("five\n");
         /* Resize Memory */
         while(1);
     }
@@ -381,7 +397,7 @@ int netapi_init_nwal(
     if((NETAPI_NWAL_CONFIG_BUFSIZE_SA_LLD_HANDLE_PER_CHAN * TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2) <
         sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE])
     {
-        Debug_printf("netapi_init_nwal:  sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] %d\n",  sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]);
+        netapi_Log("netapip_initNwal:  sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE] %d\n",  sizes[nwal_BUF_INDEX_SA_LLD_CHAN_HANDLE]);
         /* Resize Memory */
         while(1);
     }
@@ -405,11 +421,11 @@ int netapi_init_nwal(
                              &p_nwal_context->nwalInstHandle);
     if(nwalRetVal != nwal_OK)
     {
-        Debug_printf (">netapi: init_nwal- nwal_create Failed %d\n",nwalRetVal);
+        netapi_Log ("netapi: init_nwal- nwal_create Failed %d\n",nwalRetVal);
         while(1);
     }
 
-    Debug_printf(">netapi: init_nwal - Global and Local Network initialization Successful \n");
+    netapi_Log("netapi: init_nwal - Global and Local Network initialization Successful \n");
     return 1;
 }
 
@@ -418,7 +434,7 @@ int netapi_init_nwal(
  ********************************************************************
  * DESCRIPTION:  Internal NETAPI function to start NWAL, per thread/core
  ********************************************************************/
-int netapi_start_nwal(Pktlib_HeapHandle pkt_heap,
+int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
                       Pktlib_HeapHandle cmd_rx_heap,
                       Pktlib_HeapHandle cmd_tx_heap,
                       NETAPI_NWAL_LOCAL_CONTEXT_T *p,
@@ -481,7 +497,7 @@ int netapi_start_nwal(Pktlib_HeapHandle pkt_heap,
 
     if(nwalRetVal != nwal_OK)
     {
-        Debug_printf (">nwal_start:Failed ->err %d !!!\n", nwalRetVal);
+        netapi_Log (">nwal_start:Failed ->err %d !!!\n", nwalRetVal);
         return -1;
     }
     p->state = NETAPI_NW_CXT_LOC_ACTIVE;
@@ -494,11 +510,342 @@ int netapi_start_nwal(Pktlib_HeapHandle pkt_heap,
  ***********************************************************************
  * DESCRIPTION:  Internal NETAPI function to initialize the 64 bit timer. for tci6614 ONLY
  **********************************************************************/
-int netapi_init_timer(void)
+int netapip_initTimer(void)
 {
 #ifdef CORTEX_A8
         return t64_start();
 #endif
 }
 
+/********************************************************************
+* FUNCTION PURPOSE:  NETAPI internal function to gracefully cleanup when startup
+*                                  issue occurs.
+ ********************************************************************
+ * DESCRIPTION:  NETAPI internal function to gracefully cleanup when startup
+*                                  issue occurs.
+ ********************************************************************/
+void netapi_err_teardown() { netapip_cleanupAtStart(); exit(-99); }
+
+
+/***************************************************************************
+* FUNCTION PURPOSE:  NETAPI internal function for virtual memory allocation.
+ ***************************************************************************
+ * DESCRIPTION:  NETAPI internal function for virtual memory allocation.
+ **************************************************************************/
+
+static uint8_t* netapip_sharedMemoryMalloc(uint32_t size)
+{
+return  (uint8_t *)hplib_vmMemAlloc(size +netapi_global.cfg.def_heap_extra_size , 128, 0); 
+}
+
+/********************************************************************
+* FUNCTION PURPOSE:  NETAPI internal function for virtual memory free.
+ ********************************************************************
+ * DESCRIPTION:  NETAPI internal function for virtual memory free.
+ ********************************************************************/
+static void netapip_sharedMemoryFree(uint8_t* ptr, uint32_t size)
+{
+    /* Do Nothing. */
+    netapi_Log("netapi Unexpected.  need to provide a free () for some reason!! \n");
+    return;
+}
+
+//defensive: clean out stuff hanging around
+//
+//  open a bunch of free queues and zap them
+#define NQUEUES2CLEAR 35
+static Qmss_QueueHnd tempQH[NQUEUES2CLEAR];
+void netapip_cleanupAtStart(void)
+{
+    int i;
+    uint8_t         isAllocated;
+
+    for(i=0;i<NQUEUES2CLEAR;i++) 
+    {
+        tempQH[i] = Qmss_queueOpen(Qmss_QueueType_GENERAL_PURPOSE_QUEUE,
+                                                  QMSS_PARAM_NOT_SPECIFIED, &isAllocated);
+        netapip_zapQ(tempQH[i]);
+    }
+
+    for(i=0;i<NQUEUES2CLEAR;i++)
+    {
+        Qmss_queueClose(tempQH[i]);
+    }
+}
+
+
+/********************************************************************
+* FUNCTION PURPOSE:  NETAPI internal function system initialization
+ ********************************************************************
+ * DESCRIPTION:  NETAPI internal function system initialization
+ ********************************************************************/
+int netapip_systemInit(NETAPI_HANDLE_T * handle) 
+{
+    int32_t             result;
+    Pktlib_HeapHandle   sharedHeapHandle;
+    Pktlib_HeapHandle   controlRxHeapHandle,controlTxHeapHandle;    
+    Pktlib_HeapCfg      heapCfg;
+    int32_t             errCode;
+    int count=0;
+
+#ifdef NETAPI_USE_DDR
+    /* Init attributes for DDR */
+    netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_KM_CACHED0;
+    netapi_VM_MempoolAttr[0].phys_addr = 0;
+    netapi_VM_MempoolAttr[0].size = 0;
+
+       /* Init attributes for un-cached MSMC */
+    netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_UN_CACHED;
+    netapi_VM_MempoolAttr[1].phys_addr = CSL_MSMC_SRAM_REGS;
+    netapi_VM_MempoolAttr[1].size = TUNE_NETAPI_PERM_MEM_SZ;
+#else
+    netapi_VM_MempoolAttr[1].attr = HPLIB_ATTR_KM_CACHED0;
+    netapi_VM_MempoolAttr[1].phys_addr = 0;
+    netapi_VM_MempoolAttr[1].size = 0;
+
+       /* Init attributes for un-cached MSMC */
+    netapi_VM_MempoolAttr[0].attr = HPLIB_ATTR_UN_CACHED;
+    netapi_VM_MempoolAttr[0].phys_addr = CSL_MSMC_SRAM_REGS;
+    netapi_VM_MempoolAttr[0].size = TUNE_NETAPI_PERM_MEM_SZ;
+#endif
+    /* initialize all the memory we are going to use
+       - chunk for buffers, descriptors
+       - memory mapped peripherals we use, such as QMSS, PA, etc */
+    result = hplib_vmInit(&netapi_VM_VirtAddr[0], 2, &netapi_VM_MempoolAttr[0]);
+
+    /* TODO: at this point, we need to create the QM regions which need to moved out of the above 
+    netapi_VM_memory_setup() call, also need to move out the SA context stuff */
+
+    if (result == hplib_OK) netapi_Log("netapi: system init - memory set  up OK\n");
+    else {netapi_Log(">netap: system init - memory set up failed\n"); return -1;}
+
+
+#ifdef NETAPI_ENABLE_SECURITY
+#define SEC_CONTEXT_SZ 384  //not tunable
+/* allocate 2x number of tunnels since we need one for inflow and one for data mode */
+    netapi_VM_SaContextVaddr = hplib_vmMemAlloc((TUNE_NETAPI_MAX_NUM_IPSEC_CHANNELS*2 *
+                                        SEC_CONTEXT_SZ), 128, 0);
+    if (!netapi_VM_SaContextVaddr)
+    {
+        netapi_Log("netapi ERROR: Failed to map SA context memory region\n");
+        return (-1);
+    }
+    netapi_Log(">hplib VM_SaContext: Memory mapped/allocated at address %p.\n", netapi_VM_SaContextVaddr);
+
+#else
+   netapi_VM_SaContextVaddr= (char *) NULL;
+#endif
+
+/*  TODO: the QM regions is application specific and needs to be moved 
+    since number of regions created is appliction specific, put this in netapip_systemInit */
+    /* (3) Allocate 2 QM regions from continguous chunk above */
+    netapi_VM_QMemGlobalDescRam = 
+                                                            (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_GLOBAL_DESC *
+                                                                                                        TUNE_NETAPI_DESC_SIZE),
+                                                                                                        128, 0);
+
+    netapi_VM_QMemLocalDescRam =
+                                                            (void *)hplib_vmMemAlloc((TUNE_NETAPI_NUM_LOCAL_DESC *
+                                                                                                        TUNE_NETAPI_DESC_SIZE),
+                                                                                                        128, 0);
+    netapi_Log("netapi local desc region=%x global desc region=%x\n", netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
+
+    //get timer running
+#ifdef CORTEX_A8
+    netapip_initTimer();
+#endif
+     netapi_Log("netapip_systemInit: returned from netapip_initTimer\n");
+
+    /* Initialize Queue Manager Sub System */
+    result = netapip_initQm (netapi_global.cfg.def_max_descriptors); 
+    
+    if (result != 1)
+    {
+         netapi_Log("netapip_systemInit: returned from netapip_initQm with failure\n");
+        return -1;
+    }
+
+    /* Start the QMSS. */
+    if (netapip_startQm() != 1)
+    {
+      netapi_Log("netapip_systemInit: returned from netapip_startQm with failure\n");
+        return -1;
+    }
+    
+
+    //clean our old junk in 1st bunch of queues that will be allocated to us
+    netapip_cleanupAtStart();
+ netapi_Log("netapip_systemInit: returned from netapip_cleanupAtStart\n");
+    /* Initialize the global descriptor memory region. */
+    result= netapip_qmSetupMemRegion( 
+                      netapi_global.cfg.def_tot_descriptors_for_us,
+                      TUNE_NETAPI_DESC_SIZE,
+                      (unsigned int *) netapi_VM_QMemGlobalDescRam,
+                      TUNE_NETAPI_QM_GLOBAL_REGION);
+    if(result <0) {netapi_Log("netapi; can't setup QM shared region\n"); return -1;}
+
+netapi_Log("netapip_systemInit: returned from netapip_qmSetupMemRegion\n");
+#if 0 //todo setup 2nd region
+/* Initialize the local memory region configuration. */
+    result= netapip_qmSetupMemRegion( 
+                      NUM_HOST_DESC,
+                      SIZE_LOCAL_DESC,
+                      netapi_VM_QMemLocalDescRam,
+                      NETAPI_LOCAL_REGION);
+    if(result <0) {netapi_Log("can't setup local region\n"); return -1;}
+#endif
+    /* Initialize CPPI CPDMA */
+
+    result = netapip_initCppi ();
+    netapi_Log("netapip_systemInit: returned from netapip_initCppi\n");
+    if (result != 1)
+    {
+        netapi_Log ("netapi: Error initializing CPPI SubSystem error code : %d\n",result);
+        return -1;
+    }
+
+    /* CPPI and Queue Manager are initialized. */
+    netapi_Log ("netapi: Queue Manager and CPPI are initialized.\n");
+
+    /* create main pkt heap */
+    /* Initialize the Shared Heaps. */
+    Pktlib_sharedHeapInit();
+    netapi_Log("netapip_systemInit: returned from Pktlib_sharedHeapInit\n");
+    /* Populate the heap interface table. */
+    netapi_pktlib_ifTable.data_malloc             = netapip_sharedMemoryMalloc;
+    netapi_pktlib_ifTable.data_free               = netapip_sharedMemoryFree;
+
+    /* Initialize the heap configuration. */
+    memset ((void *)&heapCfg, 0, sizeof(Pktlib_HeapCfg));
+    /* Populate the heap configuration */
+    heapCfg.name                = "netapi";
+    heapCfg.memRegion           = TUNE_NETAPI_QM_GLOBAL_REGION;
+    heapCfg.sharedHeap          = 1;
+    heapCfg.useStarvationQueue  = 0;
+    heapCfg.dataBufferSize      = netapi_global.cfg.def_heap_buf_size;
+    heapCfg.numPkts             = netapi_global.cfg.def_heap_n_descriptors;
+    heapCfg.numZeroBufferPackets= netapi_global.cfg.def_heap_n_zdescriptors;
+    heapCfg.heapInterfaceTable.data_malloc  = netapi_pktlib_ifTable.data_malloc;
+    heapCfg.heapInterfaceTable.data_free    = netapi_pktlib_ifTable.data_free;
+    heapCfg.dataBufferPktThreshold   = 0;
+    heapCfg.zeroBufferPktThreshold   = 0;
+
+    /* Create Shared Heap with specified configuration. */
+    sharedHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+     netapi_Log("netapip_systemInit: returned from Pktlib_createHeap1\n");
+    //todo -> cleanup on failure
+    if (!sharedHeapHandle) { netapi_Log(">'netapi' heap create failed, Error Code: %d\n",errCode); return -1;}
+    handle->netcp_heap= sharedHeapHandle;
+
+
+    /* Update for Control */
+    heapCfg.name                = "netapi_control_rx";
+    heapCfg.sharedHeap          = 1;
+    heapCfg.dataBufferSize      = TUNE_NETAPI_CONFIG_MAX_CTL_RXTX_BUF_SIZE;
+    heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_RX_BUF;
+    heapCfg.numZeroBufferPackets= 0;
+
+    controlRxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+     netapi_Log("netapip_systemInit: returned from Pktlib_createHeap2\n");
+   //todo -> cleanup on failure
+   if (!controlRxHeapHandle) { netapi_Log("netapi -'netapi_control_rx' heap create failed, Error Code: %d\n",errCode); return -1;}
+   handle->netcp_control_rx_heap= controlRxHeapHandle;
+
+   
+   heapCfg.name                = "netapi_control_tx";
+   heapCfg.numPkts             = TUNE_NETAPI_CONFIG_NUM_CTL_TX_BUF;
+
+   controlTxHeapHandle = Pktlib_createHeap(&heapCfg, &errCode);
+    netapi_Log("netapip_systemInit: returned from Pktlib_createHeap3\n");
+   //todo -> cleanup on failure
+   if (!controlTxHeapHandle) { netapi_Log("netapi -'netapi_control_tx' heap create failed, Error Code: %d\n",errCode); return -1;}
+   handle->netcp_control_tx_heap= controlTxHeapHandle;
+
+    /* now NWAL */
+    result = netapip_initNwal(
+                              TUNE_NETAPI_QM_GLOBAL_REGION,
+                              &netapi_pktlib_ifTable, 
+                              &netapi_global.nwal_context,
+                              &netapi_global.cfg);
+    if (result<0) {netapi_Log("netapi  init_nwal() failed\n"); return -1; }
+ netapi_Log("netapip_systemInit: returned from netapip_initNwal\n");
+    /* start NWAL */
+
+
+    /* Common Initialization for all cores */
+    while(count < TUNE_NETAPI_MAX_NUM_TRANS)
+    {
+        netapi_global.nwal_context.transInfos[count].transId = count;
+        count++;
+    }
+    result = netapip_startNwal(sharedHeapHandle, 
+                               controlRxHeapHandle,
+                               controlTxHeapHandle,
+                               &handle->nwal_local,
+                               &netapi_global.cfg,
+                               &netapi_global.nwal_context);
+    if (result<0) {netapi_Log("netapi start_nwal() failed\n"); return -1; }
+    netapi_Log("netapip_systemInit: returned from netapip_startNwal\n");
+    return 0;
+}
+
+
+/****************************************************************************
+* FUNCTION PURPOSE:  NETAPI internal function which performs clean for linux user space
+ ****************************************************************************
+ * DESCRIPTION:  NETAPI internal function which performs clean for linux user space
+ ***************************************************************************/
+void netapip_zapQ(int queueNum)
+{
+    char * descPtr;
+    int i;
+    if (!queueNum) 
+    {
+        return;
+    }
+    for (i=0;;i+=1 )
+    {
+        /* Pop descriptor from source queue */
+        if ((descPtr = (char *)pktio_mQmssQueuePopRaw(queueNum)) == NULL)
+        {
+            break;
+        }
+    }
+    if(i)
+    {
+        netapi_Log("netapip_zapQ: @recovery -  %d descriptors cleaned from qn %d\n",i, queueNum);
+    }
+}
+
+
+/****************************************************************************
+* FUNCTION PURPOSE:  NETAPI internal function to display internal heap stats.
+ ****************************************************************************
+ * DESCRIPTION:  NETAPI internal function to display internal heap stats.
+ ***************************************************************************/
+void netapi_dump_internal_heap_stats(void)
+{
+    Pktlib_HeapStats    pktLibHeapStats;
+    Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2sa_heap,&pktLibHeapStats);
+    netapi_Log("PA2SA(ingress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+    netapi_Log("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+#if 0
+Pktlib_getHeapStats(netapi_get_global()->nwal_context.pa2saTX_heap,&pktLibHeapStats);
+netapi_Log("PA2SA(egress) stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+netapi_Log("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+#endif
+    Pktlib_getHeapStats(netapi_get_global()->nwal_context.sa2pa_heap,&pktLibHeapStats);
+    netapi_Log("SA2PA stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+                                pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
+    netapi_Log("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n",
+                        pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
+                        pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
+
+}
 
index 76ae1ffa7239a9cb0ae04e04f6d25292c4b2ae1f..f35483ea7fd1d104aa9dbde0225a0918192802b3 100755 (executable)
@@ -224,38 +224,38 @@ typedef struct NETAPI_HANDLE_Tag
 } NETAPI_HANDLE_T;
 
 //internal initialization routines */
-int netapi_init_qm(int max_descriptors);
-int netapi_init_cppi(void);
-int netapi_start_qm(void);
-int netapi_init_nwal(
-     int region2use,
-     Pktlib_HeapIfTable * p_table,
-     NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
-     NETAPI_CFG_T *p_cfg );
-int netapi_start_nwal(Pktlib_HeapHandle pkt_heap,
-                    Pktlib_HeapHandle cmd_heapRx,
-                    Pktlib_HeapHandle cmd_heapTx,
-                     NETAPI_NWAL_LOCAL_CONTEXT_T *p ,
-                     NETAPI_CFG_T *p_cfg,
-                     NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context );
-
-int netapi_init_timer(void);
-int netapi_qm_setup_mem_region(
+int netapip_initQm(int max_descriptors);
+int netapip_initCppi(void);
+int netapip_startQm(void);
+int netapip_initNwal(int region2use,
+                     Pktlib_HeapIfTable * p_table,
+                     NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_context,
+                     NETAPI_CFG_T *p_cfg );
+
+int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
+                      Pktlib_HeapHandle cmd_heapRx,
+                      Pktlib_HeapHandle cmd_heapTx,
+                      NETAPI_NWAL_LOCAL_CONTEXT_T *p ,
+                      NETAPI_CFG_T *p_cfg,
+                      NETAPI_NWAL_GLOBAL_CONTEXT_T * p_nwal_glob_context );
+
+int netapip_initTimer(void);
+int netapip_qmSetupMemRegion(
                       unsigned int          numDesc,
                       unsigned int          descSize,
                       unsigned int*         pDescMemBase,
                       int                   memRegion);
-//for above
+
 #define NETAPI_GLOBAL_REGION TUNE_NETAPI_QM_GLOBAL_REGION 
 #define NETAPI_LOCAL_REGION ((NETAPI_GLOBAL_REGION)+1) 
 
 
 //nwal callbacks
-void netapi_NWALRxPktCallback     (uint32_t            appCookie,
-                                uint16_t             numPkts,
-                                nwalRxPktInfo_t*    pPktInfo,
-                                uint64_t            timestamp,
-                                nwal_Bool_t*        pFreePkt);
+void netapi_NWALRxPktCallback(uint32_t          appCookie,
+                              uint16_t          numPkts,
+                              nwalRxPktInfo_t*  pPktInfo,
+                              uint64_t          timestamp,
+                              nwal_Bool_t*      pFreePkt);
 
 void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
                           uint16_t            trans_id,
@@ -285,8 +285,8 @@ return &pp->pktios[0];
 //get scheduler block handle
 static inline void * netapi_get_scheduler(NETAPI_T p)
 {
-NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
-return pp->p_sched;
+    NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
+    return pp->p_sched;
 }
 
 /* return pointer to global area */
@@ -361,7 +361,7 @@ for(i=0;i<NETAPI_MAX_PKTIO; i++,pe++)
 }
 
 /* return the nwal global instance handle */
-static inline nwal_Handle netapi_return_nwal_instance_handle(NETAPI_T p)
+static inline nwal_Handle netapip_returnNwalInstanceHandle(NETAPI_T p)
 {
 
 NETAPI_HANDLE_T *pp = (NETAPI_HANDLE_T *) p;
@@ -371,13 +371,12 @@ return ((NETAPI_GLOBAL_T *)(pp->global))->nwal_context.nwalInstHandle;
 
 
 //utility to clear out a queue
-void netapi_zapQ(int queueNum);
-void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow,  Qmss_QueueHnd * p_q);
+void netapip_zapQ(int queueNum);
+void netapip_netcpCfgBuildRoute(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow,  Qmss_QueueHnd * p_q);
 
 //database utilities
-int netcp_cfgp_find_saslot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface);
-void netcp_cfgp_delete_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int sa_slot);
-void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+void netapip_netcpCfgDeleteSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int sa_slot);
+void netapip_netcpCfgInsertSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                           int sa_slot,  //we 'reserved it already'
                           int dir,
                           int mode,
@@ -386,17 +385,20 @@ void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                           void * handle_inflow,
                           void * handle_sideband,
                           nwalTxDmPSCmdInfo_t *dmPSCmdInfo;);
-void *netcp_cfgp_get_sa_handles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+void *netapip_netcpCfgGetSaHandles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                           int sa_slot, void ** p_sideband);
-void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no);
-NetapiNwalTransInfo_t *  netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId);
-void netapip_FreeTransInfo(NetapiNwalTransInfo_t* pTransInfo);
-void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+void* netapip_netcpCfgGetMacHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no);
+NetapiNwalTransInfo_t *  netapip_getFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId);
+void netapip_freeTransInfo(NetapiNwalTransInfo_t* pTransInfo);
+void *netapip_netcpCfgGetPolicy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                           int policy_slot);
-nwalTxDmPSCmdInfo_t* netcp_cfg_get_sa_sb_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+nwalTxDmPSCmdInfo_t* netapip_netcpCfgGetSaSBInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                                       NETCP_CFG_SA_T    sa_app_id);
-int netcp_cfg_get_sa_inflow_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+int netapip_netcpCfgGetSaInflowInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
                                       NETCP_CFG_SA_T    sa_app_id,
                                       uint32_t *swInfo0,
                                       uint32_t *swInfo1);
+
+int netapip_systemInit(NETAPI_HANDLE_T *);
+void netapip_cleanupAtStart(void);
 #endif
index 12fc2a97a1dfd2897d5cc6a87d23f7065a16e858..41988cb77571a224f3839cd1831949f88f558d76 100755 (executable)
@@ -8,7 +8,7 @@
  * DESCRIPTION:  netapi sample scheduler source file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
 
 
 /********************************************************************
- * FUNCTION PURPOSE:  API to get  scheduling context statistics
+ * FUNCTION PURPOSE:  API to get scheduling context statistics
  ********************************************************************
- * DESCRIPTION:  API to get  scheduling context statistics
+ * DESCRIPTION:  API to get scheduling context statistics
  ********************************************************************/
 void netapi_schedGetStats(NETAPI_SCHED_HANDLE_T *s, 
-    unsigned long long * p_pkts, 
-    unsigned long long * p_cycles,
-    unsigned long long * p_cache_cycles)
+                          unsigned long long * p_pkts, 
+                          unsigned long long * p_cycles,
+                          unsigned long long * p_cache_cycles)
 {
    *p_pkts= s->stats.num_pkts;
    *p_cycles= s->stats.busy_cycles;
@@ -77,23 +77,34 @@ NETAPI_SCHED_HANDLE_T * netapi_schedOpen(NETAPI_T n,
 {
     *p_err=0;
      NETAPI_SCHED_HANDLE_T * ph = (NETAPI_SCHED_HANDLE_T *) netapi_get_scheduler(n);
-    if(!ph) {*p_err= NETAPI_ERR_NOMEM; return NULL;}
-    if(!p_config) {*p_err=  NETAPI_ERR_BAD_INPUT; return NULL;}
+    if(!ph)
+    {
+        *p_err= NETAPI_ERR_NOMEM;
+        return NULL;
+    }
+    if(!p_config)
+    {
+        *p_err=  NETAPI_ERR_BAD_INPUT; 
+        return NULL;
+    }
     memcpy(&ph->config,p_config,sizeof(NETAPI_SCHED_CONFIG_T));
     ph->start =   hplib_mUtilGetTimestamp();
     ph->back = (void *) n;
     if (ph->config.valid_flags & NETAPI_SCHED_DURATION)
     {
-      if (ph->config.duration == NETAPI_SCHED_FOREVER) 
-      {
-          ph->shutdown_time=(uint64_t) -1; 
-      }
-      else
-      {
-          ph->shutdown_time = ph->start + ph->config.duration;
-      }
+        if (ph->config.duration == NETAPI_SCHED_FOREVER) 
+        {
+            ph->shutdown_time=(uint64_t) -1; 
+        }
+        else
+        {
+            ph->shutdown_time = ph->start + ph->config.duration;
+        }
+    }
+    else
+    {
+        ph->shutdown_time = (uint64_t) -1;
     }
-    else ph->shutdown_time = (uint64_t) -1;
     ph->state =NETAPI_SCHED_STATE_OPEN; 
     return(ph);
 }
@@ -120,7 +131,8 @@ int netapi_schedControl(NETAPI_SCHED_HANDLE_T *s,
  * DESCRIPTION:  API to get NETAPI scheduling context statistics
  ********************************************************************/
 /* main entry point.  caller gives up control to scheduler */
-int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s, int *p_err)
+int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s,
+                    int *p_err)
 {
     int err;
     *p_err=0;
@@ -143,8 +155,8 @@ int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s, int *p_err)
 
          cache_op_b2= Osal_cache_op_measure(&n_c_ops);
          t1=hplib_mUtilGetPmuCCNT();
-         //poll all  pktio channels we have open in RX mode 
-         pkts=pktio_pollAll((NETAPI_T) s->back, NULL, &err);
+         /* poll all  pktio channels we have open in RX mode */
+         pkts=netapi_pktioPollAll((NETAPI_T) s->back, NULL, &err);
          if (!pkts  && (s->config.yield == TRUE))
          {
             sched_yield();
@@ -158,27 +170,27 @@ int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s, int *p_err)
             s->stats.cache_cycles += (unsigned long long) cache_op_b2;
          }
 
-        //poll pktlib garbage collections for registered heaps
+        /* poll pktlib garbage collections for registered heaps */
         if (TRUE == s->config.pollGarbageQ)
         {
             netapi_pollHeapGarbage((NETAPI_T) s->back);
         }
 
 
-        //poll NETCP/PA control channels 
+        /*poll NETCP/PA control channels */
         if (TRUE == s->config.pollCtrlQ)
         {
             netapi_netcpPoll((NETAPI_T) s->back);
         }
 
-        //see if time to do a house keeping callback
+        /* see if time to do a house keeping callback */
         if ((s->config.valid_flags & NETAPI_SCHED_CBV) && s->config.house_cb)
         if (next_house<=0)
         {
             s->config.house_cb(s);
             next_house = s->config.interval;
         }
-        //see if we were closed and/or its time to close
+        /* see if we were closed and/or its time to close */
         if (s->state!= NETAPI_SCHED_STATE_OPEN) 
         {
             s->state=NETAPI_SCHED_STATE_CLOSE;
@@ -194,12 +206,14 @@ int netapi_schedRun(NETAPI_SCHED_HANDLE_T *s, int *p_err)
  * DESCRIPTION:  API to close a scheduling context
  ********************************************************************/
 /* shutdown scheduler context */
-int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s, NETAPI_SCHED_SHUTDOWN_T * p_close, int * p_err)
+int netapi_schedClose(NETAPI_SCHED_HANDLE_T * s, 
+                      NETAPI_SCHED_SHUTDOWN_T * p_close,
+                      int * p_err)
 {
     *p_err=0;
     if (p_close->shutdown_type == NETAPI_SCHED_SHUTDOWN_NOW)
     {
-        s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS;  //say we are closing
+        s->state=NETAPI_SCHED_STATE_CLOSE_IN_PROGRESS;
     }
   return 1;
 }
index 67c36060563d13bd5acce990e541a10948ab65fd..7d69af13ca9a70bef1f0cf0f43f71c9498712de2 100755 (executable)
@@ -4,10 +4,10 @@
  **************************************************************
  * @file netapi_sec.c
  * 
- * @brief DESCRIPTION:  netapi security  cfg file for user space transport
+ * @brief DESCRIPTION:  netapi security cfg file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
  * DESCRIPTION:  API to add an IPSEC SA
  ********************************************************************/
 NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
-                                int iface_no,
-                                NETAPI_SEC_SA_INFO_T *sa_info,
-                                nwalSecKeyParams_t * key_params,
-                                int inflow_mode,
-                                NETCP_CFG_ROUTE_HANDLE_T  route,
-                                void **p_data_mode_handle,
-                                void **p_inflow_mode_handle,
-                                void * p_user_data,
-                                int * perr)
+                               int iface_no,
+                               NETAPI_SEC_SA_INFO_T *sa_info,
+                               nwalSecKeyParams_t * key_params,
+                               int inflow_mode,
+                               NETCP_CFG_ROUTE_HANDLE_T  route,
+                               void **p_data_mode_handle,
+                               void **p_inflow_mode_handle,
+                               void * p_user_data,
+                               int * perr)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     nwal_RetValue       retValue;
@@ -72,38 +72,18 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
     uint32_t    swInfo0;
     uint32_t    swInfo1;
 
-    nwalCreateSAParams_t    createParam =
-    {
-        /* mac handle */
-        NULL,  //to be filled in
-        4,
-
-        /*nwalSaIpSecParam_t */  
-            {   
-                0,/* validParams */
-                nwal_SA_MODE_TUNNEL,  //update from input
-                64,/* replayWindow */
-                NWAL_SA_DIR_INBOUND,
-                0,
-                0,
-                NWAL_SA_AALG_HMAC_SHA1,                     /* update from input */
-                NWAL_SA_EALG_AES_CTR,                       /* update from input */
-                { 0x00},      /* remMacAddr:  NA */
-                12,                                                         /* update from input, mac size */
-                NWAL_MATCH_ACTION_CONTINUE_NEXT_ROUTE,       /* Continue parsing to next route for match */
-                NWAL_NEXT_ROUTE_FAIL_ACTION_HOST,            /* For next route fail action by default is route to host */
-                CPPI_PARAM_NOT_SPECIFIED,                    /* Use default flow configured to NWAL  if packet is routed to host */
-                QMSS_PARAM_NOT_SPECIFIED                     /* Use default queue configured to NWAL if packet is routed to host */
-        },
-        /* nwalSaIpSecKeyParams_t */
-        {0}
-    };
-    void * mac_handle = netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context,iface_no);
+    nwalCreateSAParams_t    createParam;
+
+    void * mac_handle = netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context,iface_no);
     *perr =0;
-    if ((!n) || (!sa_info)  ||  (!p_data_mode_handle) ) {*perr = NETAPI_ERR_BAD_INPUT; return -1;}
+    if ((!n) || (!sa_info)  ||  (!p_data_mode_handle))
+    {
+        *perr = NETAPI_ERR_BAD_INPUT;
+        return -1;
+    }
 
     /* reserve a slot */
-    tunnelId = netcp_cfgp_find_sa_slot(&netapi_get_global()->nwal_context,
+    tunnelId = netapip_netcpCfgFindSaSlot(&netapi_get_global()->nwal_context,
                            iface_no);
 
     if (tunnelId <0)
@@ -111,19 +91,24 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
         *perr= NETAPI_ERR_NOMEM;
         return -1;
     }
-    appId |=  (tunnelId<<8);
-    Debug_printf("netapi_secAddSA: app id: 0x%x\n", appId);
+    appId |=  (tunnelId << NETAPI_NETCP_MATCH_ID_SHIFT);
+    netapi_Log("netapi_secAddSA: app id: 0x%x\n", appId);
 
     *p_data_mode_handle= NULL;  
-    *p_inflow_mode_handle= NULL;  
+    *p_inflow_mode_handle= NULL;
+
+    /* Initialize defaults, can be updated from inputs to API */
+    memset(&createParam, 0, sizeof(nwalCreateSAParams_t));
+    createParam.saIpSecParam.appRxPktFlowId = CPPI_PARAM_NOT_SPECIFIED;
+    createParam.saIpSecParam.appRxPktQueue = QMSS_PARAM_NOT_SPECIFIED;
 
     if (inflow_mode & NETAPI_SEC_SA_INFLOW)
     {
-        pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+        pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
         if (!pTransInfo)
         {
             *perr =  NETAPI_ERR_BUSY;
-            netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+            netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
             return -1;
         }
         pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_SA;
@@ -162,7 +147,7 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
 
         if (route != NULL)
         {
-            netcp_cfgp_build_route(route,&createParam.saIpSecParam.appRxPktFlowId, 
+            netapip_netcpCfgBuildRoute(route,&createParam.saIpSecParam.appRxPktFlowId, 
                                          &createParam.saIpSecParam.appRxPktQueue);
         }
 
@@ -180,8 +165,8 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
         else if(retValue !=  nwal_OK)
         {
             *perr = NETAPI_ERR_NWAL_ERR0;
-            netapip_FreeTransInfo(pTransInfo);
-            netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+            netapip_freeTransInfo(pTransInfo);
+            netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
             return -1;
         }
 
@@ -198,15 +183,15 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
                 pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
                 pTransInfo->inUse = nwal_FALSE;
                 *perr = NETAPI_ERR_PA_FW;
-                Debug_printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
+                netapi_Log ("netapi_sec - ERROR returned by NETCP PA firmware %d\n",
                         *perr);
-                netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+                netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
                 return -1;
             }
         }
 
         *p_inflow_mode_handle=pTransInfo->handle;
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
 
         if (sa_info->dir == NWAL_SA_DIR_OUTBOUND)
         {
@@ -222,10 +207,10 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
                                      &swInfo0,
                                      &swInfo1) == nwal_TRUE)
             {
-                Debug_printf("netapisecAddSA swInfo0: 0x%x, swInfo1: 0x%x\n", swInfo0, swInfo1);
+                netapi_Log("netapisecAddSA swInfo0: 0x%x, swInfo1: 0x%x\n", swInfo0, swInfo1);
             }
             else
-                Debug_printf("netapisecAddSA: call to nwal_getSecAssoc() returne error\n");
+                netapi_Log("netapisecAddSA: call to nwal_getSecAssoc() returned error\n");
         }
     }
 
@@ -270,21 +255,21 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
         if(retValue != nwal_OK)
         {
             *perr = NETAPI_ERR_NWAL_ERR0;
-            Debug_printf ("netapi_secAddSA: nwal_setDMSecAssoc() returned Error Code %d\n",
+            netapi_Log ("netapi_secAddSA: nwal_setDMSecAssoc() returned Error Code %d\n",
             retValue);
-            netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+            netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
             return -1;
         }
 
-        Debug_printf("netapi_secAddSA: Creating sideband mode SA for %d ( mac %d)\n", tunnelId, iface_no); 
+        netapi_Log("netapi_secAddSA: Creating sideband mode SA for %d ( mac %d)\n", tunnelId, iface_no); 
         *p_data_mode_handle = dm_handle;
         memset(&dmPSCmdInfo, 0, sizeof(nwalTxDmPSCmdInfo_t));
-        retValue =  nwal_initDMPSCmdInfo(netapi_return_nwal_instance_handle(h),
+        retValue =  nwal_initDMPSCmdInfo(netapip_returnNwalInstanceHandle(h),
                                          *p_data_mode_handle,
                                          &dmPSCmdInfo); 
     }
 
-    netcp_cfgp_insert_sa(&netapi_get_global()->nwal_context,
+    netapip_netcpCfgInsertSa(&netapi_get_global()->nwal_context,
                           tunnelId,
                           (sa_info->dir ==   NWAL_SA_DIR_INBOUND) ? TRUE: FALSE,
                           inflow_mode,
@@ -305,10 +290,12 @@ NETCP_CFG_SA_T netapi_secAddSA(NETAPI_T h,
  * DESCRIPTION:  Internal function  to dynamically switch between inflow
  *                                  and sideband mode
  ********************************************************************/
-void netapi_secInflowMode(int iface, NETCP_CFG_SA_T sa,  int on)
+void netapi_secInflowMode(int iface,
+                          NETCP_CFG_SA_T sa,
+                          int on)
 {
     /* NOT_IMPLEMENTED */
-    Debug_printf("netapi_secInflowMode:  dynamic switch between inflow and sideband is NOT_IMPLEMENTED\n");
+    netapi_Log("netapi_secInflowMode:  dynamic switch between inflow and sideband is NOT_IMPLEMENTED\n");
 }
 
 /********************************************************************
@@ -316,25 +303,29 @@ void netapi_secInflowMode(int iface, NETCP_CFG_SA_T sa,  int on)
  ********************************************************************
  * DESCRIPTION:  Internal function to delete an IPSEC SA
  ********************************************************************/
-static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa_app_id, int flags, int *perr)
+static void netapi_secDelSA_internal(NETAPI_T h,
+                                     int iface_no,
+                                     NETCP_CFG_SA_T sa_app_id,
+                                     int flags,
+                                     int *perr)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     nwal_RetValue       retValue;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
-    int tunnelId = (sa_app_id >>8) &0xffff;
+    int tunnelId = (sa_app_id >> NETAPI_NETCP_MATCH_ID_SHIFT) &NETAPI_NETCP_MATCH_ID_MASK;
     void * handle_inflow;
     void * handle_sideband;
     int have_to_wait = 1;
 
-    handle_inflow = netcp_cfgp_get_sa_handles(&netapi_get_global()->nwal_context,
+    handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
                                           tunnelId, &handle_sideband);
     *perr =0;
 
     if(handle_inflow)
     {
     /* get a transaction id */
-        pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+        pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
         if (!pTransInfo)
         {
             *perr =  NETAPI_ERR_BUSY;
@@ -356,10 +347,10 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa
         else if(retValue !=  nwal_OK)
         {
                 *perr = NETAPI_ERR_NWAL_ERR0;
-                Debug_printf (">netcp cfg - ERROR: netapi_secDelSA_internal returned Error Code %d\n",
+                netapi_Log ("netcp_cfg - ERROR: netapi_secDelSA_internal returned Error Code %d\n",
                             retValue);
-                netapip_FreeTransInfo(pTransInfo);
-                netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context,tunnelId);
+                netapip_freeTransInfo(pTransInfo);
+                netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context,tunnelId);
         }
         if((trans_id != NWAL_TRANSID_SPIN_WAIT)&&(have_to_wait))
         {
@@ -372,17 +363,17 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa
             }
             if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
             {
-                netapip_FreeTransInfo(pTransInfo);
+                netapip_freeTransInfo(pTransInfo);
                 *perr = NETAPI_ERR_PA_FW;
                  if (!flags) 
-                    netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
-                Debug_printf (">netapi_sec - ERROR returned by NETCP PA firmware %d\n",
+                    netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context, tunnelId);
+                netapi_Log ("netapi_sec - ERROR returned by NETCP PA firmware %d\n",
                         *perr);
                 return;
            }
         }
-        Debug_printf (">netapi sec: inflow tunnel %d (iface %d) deleted\n",tunnelId,iface_no);
-        netapip_FreeTransInfo(pTransInfo);
+        netapi_Log ("netapi sec: inflow tunnel %d (iface %d) deleted\n",tunnelId,iface_no);
+        netapip_freeTransInfo(pTransInfo);
     }
     if (handle_sideband)
     {
@@ -391,17 +382,17 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa
         if(retValue !=  nwal_OK)
         {
             *perr = NETAPI_ERR_NWAL_ERR0;
-             Debug_printf (">netapi_sec  - ERROR: nwal_delDMSA returned Error Code %d\n",
+             netapi_Log ("netapi_sec  - ERROR: nwal_delDMSA returned Error Code %d\n",
                     retValue);
 
         }
         else 
-            Debug_printf(">netapi_sec: Sideband SA deleted\n");
+            netapi_Log("netapi_sec: Sideband SA deleted\n");
     }
    
     /* zap the entry */
     if (!flags)
-        netcp_cfgp_delete_sa(&netapi_get_global()->nwal_context, tunnelId);
+        netapip_netcpCfgDeleteSa(&netapi_get_global()->nwal_context, tunnelId);
 }
 
 /********************************************************************
@@ -409,7 +400,10 @@ static void netapi_secDelSA_internal(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa
  ********************************************************************
  * DESCRIPTION:  API to delete an IPSEC SA
  ********************************************************************/
-void netapi_secDelSA(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa_app_id,  int *perr)
+void netapi_secDelSA(NETAPI_T h,
+                     int iface_no,
+                     NETCP_CFG_SA_T sa_app_id,
+                     int *perr)
 {
     netapi_secDelSA_internal( h, iface_no,  sa_app_id, 0x00, perr);
 }
@@ -420,25 +414,26 @@ void netapi_secDelSA(NETAPI_T h,int iface_no, NETCP_CFG_SA_T  sa_app_id,  int *p
  ********************************************************************
  * DESCRIPTION:  API to add a recieve security policy
  ********************************************************************/
-NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
-                                NETCP_CFG_SA_T sa,  //tunnel to attach to
-                                nwal_IpType ipType,     //V4 or V6
-                                nwalIpAddr_t  * src_ip_addr,  //src (from where)
-                                nwalIpAddr_t  * dst_ip_addr,  //dst (us)
-                                nwalIpOpt_t * ip_qualifiers,  //other qualifiers
-                                NETCP_CFG_ROUTE_HANDLE_T  route,  //Optional route
-                                void * user_data, // optional user specified data associated with policy
-                                int * perr)
+NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, 
+                                               NETCP_CFG_SA_T sa,
+                                               nwal_IpType ipType,
+                                               nwalIpAddr_t * src_ip_addr,
+                                               nwalIpAddr_t * dst_ip_addr,
+                                               nwalIpOpt_t * ip_qualifiers,
+                                               NETCP_CFG_ROUTE_HANDLE_T  route,
+                                               void * user_data,
+                                               int * perr)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     nwal_RetValue       retValue;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
-    unsigned int appId = NETAPI_NETCP_MATCH_IPSEC_POLICY | (sa&0xff);
+    unsigned int appId = NETAPI_NETCP_MATCH_IPSEC_POLICY | (sa& NETAPI_NETCP_MATCH_ID_MASK);
     int policyId;
-    int tunnelId= (sa>>8)&0xff;
+    int tunnelId= netapi_cfgGetMatchId(sa);
     void * blah;
-    int iface_no = sa&0xff;
+    int iface_no = netapi_cfgGetMatchLogicalMacIface(sa);
+
     nwalSecPolParams_t createParam =
     {
         0,  /* handle */
@@ -462,7 +457,7 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
         return -1;
     }
 
-    sa_handle = netcp_cfgp_get_sa_handles(&netapi_get_global()->nwal_context,tunnelId,&blah);
+    sa_handle = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,tunnelId,&blah);
     if (!sa_handle)
     {
         *perr = NETAPI_ERR_BAD_INPUT;
@@ -470,7 +465,7 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
     }
 
     /* get a transaction id */
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *perr =  NETAPI_ERR_BUSY;
@@ -487,16 +482,16 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
     if (ip_qualifiers) memcpy(&createParam.ipOpt,ip_qualifiers ,sizeof(nwalIpOpt_t));
     if (route != NULL)
     {
-        netcp_cfgp_build_route(route,&createParam.appRxPktFlowId,
+        netapip_netcpCfgBuildRoute(route,&createParam.appRxPktFlowId,
                                      &createParam.appRxPktQueue);
     }
     /* reserve a slot */
-    policyId = netcp_cfgp_find_policy_slot(&netapi_get_global()->nwal_context,
+    policyId = netapip_netcpCfgFindPolicySlot(&netapi_get_global()->nwal_context,
                            tunnelId);
     if (policyId <0) 
     {
         *perr= NETAPI_ERR_NOMEM;
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return -1;
     }
     appId |=  (policyId<<8);
@@ -510,11 +505,11 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
     if(retValue !=  nwal_OK)
     {
         *perr = NETAPI_ERR_NWAL_ERR0;
-        Debug_printf (">netapi sec - ERROR: nwal_setPolicy returned Error Code %d\n",
+        netapi_Log ("netapi sec - ERROR: nwal_setPolicy returned Error Code %d\n",
                     retValue);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         
-        netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context,policyId);
+        netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context,policyId);
         return -1;
     }
 
@@ -528,22 +523,22 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *perr = NETAPI_ERR_PA_FW;
-            Debug_printf (">netapi_sec - ERROR2: netapi_secAddRxPolicy returned Error Code %d\n",
+            netapi_Log ("netapi_sec - ERROR2: netapi_secAddRxPolicy returned Error Code %d\n",
                     *perr);
-            netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context,policyId);
+            netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context,policyId);
             return -1;
         }
     }
-    Debug_printf (">netapi sec: SA %d added to tunnel %d  mac %d\n", policyId, tunnelId, iface_no);
+    netapi_Log ("netapi sec: SA %d added to tunnel %d  mac %d\n", policyId, tunnelId, iface_no);
 
     /* save stuff */
-    netcp_cfgp_insert_policy(&netapi_get_global()->nwal_context,
+    netapip_netcpCfgInsertPolicy(&netapi_get_global()->nwal_context,
                            policyId,
                           (void *) pTransInfo->handle,
                           user_data);
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
     return  (appId);
 }
 
@@ -552,16 +547,19 @@ NETCP_CFG_IPSEC_POLICY_T netapi_secAddRxPolicy(NETAPI_T h, //the  netapi handle
  ********************************************************************
  * DESCRIPTION:  Internal function to delete a recieve security policy
  ********************************************************************/
-static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T policy_app_id, int flags, int *perr)
+static void netapi_secDelRxPolicy_internal(NETAPI_T h,
+                                           NETCP_CFG_IPSEC_POLICY_T policy_app_id,
+                                           int flags,
+                                           int *perr)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     nwal_RetValue       retValue;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
-    int policyId = (policy_app_id >>8) &0xffff;
+    int policyId = netapi_cfgGetMatchId(policy_app_id);
     void * handle_policy=NULL;
 
-    handle_policy = netcp_cfgp_get_policy(&netapi_get_global()->nwal_context,policyId);
+    handle_policy = netapip_netcpCfgGetPolicy(&netapi_get_global()->nwal_context,policyId);
                                           ;
     if (!handle_policy)
     {
@@ -571,7 +569,7 @@ static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T
     *perr =0;
 
     /* get a transaction id */
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *perr =  NETAPI_ERR_BUSY;
@@ -590,9 +588,9 @@ static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T
     if(retValue !=  nwal_OK)
     {
         *perr = NETAPI_ERR_NWAL_ERR0;
-        Debug_printf (">netapi sec - ERROR: netapi_secDelRxPolicy_internal returned Error Code %d\n",
+        netapi_Log ("netapi sec - ERROR: netapi_secDelRxPolicy_internal returned Error Code %d\n",
                     retValue);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         goto ERR_netapi_secDelRxPolicy_internal;
     }
 
@@ -606,23 +604,23 @@ static void netapi_secDelRxPolicy_internal(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *perr = NETAPI_ERR_PA_FW;
-            Debug_printf (">netapi_sec - ERROR2: netapi_secDelRxPolicy_internal returned Error Code %d\n",
+            netapi_Log ("netapi_sec - ERROR2: netapi_secDelRxPolicy_internal returned Error Code %d\n",
                     *perr);
             //zap the entry
             if (!flags)
-                netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
+                netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context, policyId);
             goto ERR_netapi_secDelRxPolicy_internal;
             
         }
     }
-    Debug_printf (">netapi sec: policy %d (iface %d) deleted\n",policyId,(policy_app_id&0xff));
-    netapip_FreeTransInfo(pTransInfo);
+    netapi_Log ("netapi sec: policy %d (iface %d) deleted\n",policyId,(policy_app_id&0xff));
+    netapip_freeTransInfo(pTransInfo);
     /* zap the entry */
     if (!flags)
     {
-        netcp_cfgp_delete_policy(&netapi_get_global()->nwal_context, policyId);
+        netapip_netcpCfgDeletePolicy(&netapi_get_global()->nwal_context, policyId);
     }
 ERR_netapi_secDelRxPolicy_internal:
     return;
@@ -633,7 +631,9 @@ ERR_netapi_secDelRxPolicy_internal:
  ********************************************************************
  * DESCRIPTION:  API to delete a recieve security policy
  ********************************************************************/
-void netapi_secDelRxPolicy(NETAPI_T h, NETCP_CFG_IPSEC_POLICY_T policy_app_id, int *perr)
+void netapi_secDelRxPolicy(NETAPI_T h,
+                           NETCP_CFG_IPSEC_POLICY_T policy_app_id,
+                           int *perr)
 {
     netapi_secDelRxPolicy_internal(h,  policy_app_id, 0, perr);
 }
@@ -647,13 +647,12 @@ void  netapi_getSaStats (NETAPI_T               h,
                          NETCP_CFG_SA_T         handle,
                          NETAPI_SA_STATS_T*     pSaStats)
 {
-
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * handle_inflow;
     void * handle_sideband;
     int tunnelId = (handle >>8) &0xffff;
     int have_to_wait = 1;
-    handle_inflow = netcp_cfgp_get_sa_handles(&netapi_get_global()->nwal_context,
+    handle_inflow = netapip_netcpCfgGetSaHandles(&netapi_get_global()->nwal_context,
                                           tunnelId, &handle_sideband);
     if(handle_inflow)
     {
@@ -667,5 +666,4 @@ void  netapi_getSaStats (NETAPI_T               h,
                                                 handle_sideband, &(pSaStats->dataModeStats));
         pSaStats->validParams |= NETAPI_SIDEBAND_DATA_MODE_STAT_VALID;
     }
-    
 }
index a39fb9682711256781d3560a7f7fd520dacc8fe4..293ff7d74fd0c633919063c1fe59ceff35a0580f 100755 (executable)
@@ -7,7 +7,7 @@
  * DESCRIPTION:  netcp configuration main source file for user space transport
  *               library
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
 /******************************************************************
  ********************Netapi internal*************************************
 *******************************************************************/
-static hplib_spinLock_T netcp_cfg_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
+static hplib_spinLock_T netapi_netcp_cfg_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
 
 /********************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to get a free transaction id
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to get a free transaction id.
  ********************************************************************/
-NetapiNwalTransInfo_t *  netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwal_TransID_t *pTransId)
+NetapiNwalTransInfo_t * netapip_getFreeTransInfo(NETAPI_GLOBAL_T *p_global,
+                                                 nwal_TransID_t *pTransId)
 {
     uint16_t    count=0;
 
     count=0;
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
     while(count < TUNE_NETAPI_MAX_NUM_TRANS)
     {
         if((p_global->nwal_context.transInfos[count].inUse) != nwal_TRUE)
         {
             p_global->nwal_context.transInfos[count].inUse = nwal_TRUE;
             *pTransId = count;
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
             return(&p_global->nwal_context.transInfos[count]);
         }
         count++;
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
     /* trouble.  need to wait for one to free up*/
     /* to do: handle this by forcing a poll of cntrl queue*/
-    Debug_printf(">netcp_cfg: trying to get free transaction slot but all full!!\n");
+    netapi_Log(">netcp_cfg: trying to get free transaction slot but all full!!\n");
     return NULL;
 
 }
@@ -84,7 +85,7 @@ NetapiNwalTransInfo_t *  netapip_GetFreeTransInfo(NETAPI_GLOBAL_T *p_global, nwa
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to free a transaction id
  ********************************************************************/
-void netapip_FreeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
+void netapip_freeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
 {
     pTransInfo->inUse = nwal_FALSE;
     pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_IDLE;
@@ -95,7 +96,9 @@ void netapip_FreeTransInfo(NetapiNwalTransInfo_t *pTransInfo)
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to build a route
  ********************************************************************/
-void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow,  Qmss_QueueHnd * p_q)
+void netapip_netcpCfgBuildRoute(NETCP_CFG_ROUTE_T * p_route,
+                                int16_t * p_flow,  
+                                Qmss_QueueHnd * p_q)
 {
     if (!p_route) return;
     if (p_route->p_flow)  *p_flow= p_route->p_flow->flowid;
@@ -116,13 +119,14 @@ void netcp_cfgp_build_route(NETCP_CFG_ROUTE_T * p_route, int16_t * p_flow,  Qmss
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to find a free slot for an SA
  ********************************************************************/
-int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel)
+int netapip_netcpCfgFindPolicySlot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                   int tunnel)
 {
     int i;
     if ((tunnel <0 ) || (tunnel >=TUNE_NETAPI_MAX_SA))
         return -1;
 
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
     //find a free entry
     for(i=0;i<TUNE_NETAPI_MAX_POLICY;i++)
     {
@@ -130,11 +134,11 @@ int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel)
         {
             p->policy[i].in_use = 2; //pending
             p->policy[i].tunnel= tunnel; //save tunnel this is linked to 
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
     return -1;
 }
 
@@ -143,10 +147,8 @@ int netcp_cfgp_find_policy_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int tunnel)
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to delete a policy from policy list
  ********************************************************************/
-//internal: delete a policy from list 
-void netcp_cfgp_delete_policy(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-         int policy_slot )
+void netapip_netcpCfgDeletePolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                  int policy_slot)
 {
     if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
     {
@@ -161,10 +163,10 @@ void netcp_cfgp_delete_policy(
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to insert a policy to the policy list
  ********************************************************************/
-void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int policy_slot,  //we 'reserved it already'
-                          void * handle,
-                          void * user_data)
+void netapip_netcpCfgInsertPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                  int policy_slot,
+                                  void * handle,
+                                  void * user_data)
 {
     p->policy[policy_slot].in_use=1;
     p->policy[policy_slot].nwal_handle = handle;
@@ -177,8 +179,8 @@ void netcp_cfgp_insert_policy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ************************************************************************
  * DESCRIPTION:  Netapi internal function which returns NWAL handle for a policy
  ************************************************************************/
-void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int policy_slot)
+void *netapip_netcpCfgGetPolicy(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                int policy_slot)
 {
     if ((policy_slot <0 ) || (policy_slot >= TUNE_NETAPI_MAX_POLICY))
         return NULL;
@@ -192,14 +194,15 @@ void *netcp_cfgp_get_policy( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION:  Netapi internal function to find a free slot in SA list for an SA
  ********************************************************************/
-int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface)
+int netapip_netcpCfgFindSaSlot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                               int iface)
 {                                    
    int i;
    if (iface != NETCP_CFG_NO_INTERFACE)
    {
    if ((iface <0 ) || (iface >=TUNE_NETAPI_MAX_NUM_MAC)) return -1;
    }
-           hplib_mSpinLockLock(&netcp_cfg_lock);
+           hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
          //find a free entry
    for(i=0;i<TUNE_NETAPI_MAX_SA;i++)
    {                       
@@ -207,11 +210,11 @@ int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface)
        {
            p->tunnel[i].in_use = 2; //pending
            p->tunnel[i].iface= iface; //save iface
-           hplib_mSpinLockUnlock(&netcp_cfg_lock);
+           hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
            return i;
        }
    }
-   hplib_mSpinLockUnlock(&netcp_cfg_lock);
+   hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
    return -1;
 }
 
@@ -220,9 +223,8 @@ int netcp_cfgp_find_sa_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p, int iface)
  ********************************************************************
  * DESCRIPTION: Netapi internal function to delete an SA from SA list 
  ********************************************************************/
-void netcp_cfgp_delete_sa(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-         int sa_slot )
+void netapip_netcpCfgDeleteSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                              int sa_slot)
 {
     if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
     {
@@ -238,15 +240,14 @@ void netcp_cfgp_delete_sa(
  **************************************************************************
  * DESCRIPTION:  Internal function to retrieve SB command info template
  ***************************************************************************/
-nwalTxDmPSCmdInfo_t*  netcp_cfg_get_sa_sb_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                                      NETCP_CFG_SA_T    sa_app_id)
+nwalTxDmPSCmdInfo_t* netapip_netcpCfgGetSaSBInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                                 NETCP_CFG_SA_T    sa_app_id)
 {
-    int sa_slot = (sa_app_id >>8) &0xffff;
-        if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
+     int sa_slot = netapi_cfgGetMatchId(sa_app_id);
+    if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
     {
         return NULL;
     }
-
     return (&p->tunnel[sa_slot].dmPSCmdInfo);
 }
 
@@ -257,21 +258,19 @@ nwalTxDmPSCmdInfo_t*  netcp_cfg_get_sa_sb_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  * DESCRIPTION:  Internal function to retrieve Inflow mode 
  *                    software information required to transmit packet
  ***************************************************************************/
-int netcp_cfg_get_sa_inflow_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                                      NETCP_CFG_SA_T    sa_app_id,
-                                      uint32_t *swInfo0,
-                                      uint32_t *swInfo1)
+int netapip_netcpCfgGetSaInflowInfo(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                    NETCP_CFG_SA_T    sa_app_id,
+                                    uint32_t *swInfo0,
+                                    uint32_t *swInfo1)
 {
-    int sa_slot = (sa_app_id >>8) &0xffff;
+    int sa_slot = netapi_cfgGetMatchId(sa_app_id);
     if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
     {
         return 0;
     }
-
     *swInfo0 = p->tunnel[sa_slot].swInfo0;
     *swInfo1 = p->tunnel[sa_slot].swInfo1;
     return 1;
-
 }
 
 /********************************************************************
@@ -279,18 +278,18 @@ int netcp_cfg_get_sa_inflow_info(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION: Netapi internal function to insert an SA to the SA list 
  ********************************************************************/
-void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int sa_slot,  //we 'reserved it already'
-                          int dir,
-                          int mode,
-                          void * temp1,
-                          void * temp2,
-                          void * handle_inflow,
-                          void * handle_sideband,
-                          nwalTxDmPSCmdInfo_t *dmPSCmdInfo,
-                          uint32_t swInfo0,
-                          uint32_t swInfo1,
-                          void* user_data)
+void netapip_netcpCfgInsertSa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                              int sa_slot,
+                              int dir,
+                              int mode,
+                              void * temp1,
+                              void * temp2,
+                              void * handle_inflow,
+                              void * handle_sideband,
+                              nwalTxDmPSCmdInfo_t *dmPSCmdInfo,
+                              uint32_t swInfo0,
+                              uint32_t swInfo1,
+                              void* user_data)
 {
     p->tunnel[sa_slot].in_use=1;
     p->tunnel[sa_slot].inbound = dir;
@@ -300,7 +299,7 @@ void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
     p->tunnel[sa_slot].swInfo0 = swInfo0;
     p->tunnel[sa_slot].swInfo1 = swInfo1;
     p->tunnel[sa_slot].user_data = user_data;
-    Debug_printf("netcp_cfgp_insert_sa: swInfo0 0x%x, swInfo1: 0x%x, user data: %d\n",
+    netapi_Log("netapip_netcpCfgInsertSa: swInfo0 0x%x, swInfo1: 0x%x, user data: %d\n",
         p->tunnel[sa_slot].swInfo0, p->tunnel[sa_slot].swInfo1, (uint32_t)p->tunnel[sa_slot].user_data);
 
     if (dmPSCmdInfo)
@@ -315,8 +314,9 @@ void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION: Netapi internal function to return NWAL handles for an SA
  ********************************************************************/
- void *netcp_cfgp_get_sa_handles( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int sa_slot, void ** p_sideband)
+ void *netapip_netcpCfgGetSaHandles(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                    int sa_slot,
+                                    void ** p_sideband)
 {
     if ((sa_slot <0 ) || (sa_slot >= TUNE_NETAPI_MAX_SA))
         return NULL;
@@ -334,21 +334,21 @@ void netcp_cfgp_insert_sa(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION: Netapi internal function to find a free slot for a flow
  ********************************************************************/
-static int netcp_cfgp_find_flow_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
+static int netapip_netcpCfgFindFlowSlot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
 {
     int i;
     //find a free entry
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
     for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
     {
         if (!p->flows[i].in_use)
         {
-            p->flows[i].in_use = 2; //pending
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            p->flows[i].in_use = 2; /* pending */
+            hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
     return -1;
 }
 
@@ -357,7 +357,8 @@ static int netcp_cfgp_find_flow_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
  ********************************************************************
  * DESCRIPTION: Netapi internal function to find delete a flow from flow list
  ********************************************************************/
-static void netcp_cfgp_delete_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int slot)
+static void netapip_netcpCfgDeleteFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                       int slot)
 {
     if ((slot >=0 ) && (slot < TUNE_NETAPI_MAX_FLOWS))
     {
@@ -370,10 +371,9 @@ static void netcp_cfgp_delete_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int slot)
  ********************************************************************
  * DESCRIPTION: Netapi internal function to  delete a flow from flow list
  ********************************************************************/
-//internal:  insert a flow into flow slot
-static NETCP_CFG_FLOW_HANDLE_T netcp_cfgp_insert_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int slot,  //we 'reserved it already'
-                          void * handle)  //cppi flow handle. Save this for delete
+static NETCP_CFG_FLOW_HANDLE_T netapip_netcpCfgInsertFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                                          int slot,
+                                                          void * handle)
 {
     p->flows[slot].in_use=1;
     p->flows[slot].handle = handle;
@@ -387,23 +387,23 @@ static NETCP_CFG_FLOW_HANDLE_T netcp_cfgp_insert_flow(NETAPI_NWAL_GLOBAL_CONTEXT
  * DESCRIPTION: Netapi internal function to find entry matching the flowid. Returns
  * the slot number and the cPPI handle.
  ********************************************************************/
-static int netcp_cfgp_find_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int flowid,  
-                          void ** handle) 
+static int netapip_netcpCfgFindFlow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                    int flowid,  
+                                    void ** handle) 
 {
     int i;
     *handle=NULL;
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
     for(i=0;i<TUNE_NETAPI_MAX_FLOWS;i++)
     {
         if ((p->flows[i].in_use)&&(p->flows[i].flow.flowid == flowid))
         {
             *handle = p->flows[i].handle;
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
    return -1;
 }
 
@@ -412,27 +412,27 @@ static int netcp_cfgp_find_flow(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
 /*============================IP ADDRESSES==========================*/
 
 /***************************************************************************
- * FUNCTION PURPOSE:  Netapi internal function to find a free slot for IP rule in IP slot list 
+ * FUNCTION PURPOSE:  Netapi internal function to find a free slot for IP rule in IP slot list
  ***************************************************************************
  * DESCRIPTION: NNetapi internal function to find a free slot for IP rule in IP slot list
  ***************************************************************************/
-static int netcp_cfgp_find_ip_slot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int iface_no)
+static int netapip_netcpCfgFindIpSlot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                      int iface_no)
 {
     int i;
 
     //find a free entry
-    hplib_mSpinLockLock(&netcp_cfg_lock);
+    hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
     for(i=0;i<TUNE_NETAPI_MAX_NUM_IP;i++)
     {
         if (!p->ips[i].in_use)
         {
             p->ips[i].in_use = 2; //pending
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
+            hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
             return i;
         }
     }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
+    hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
     return -1;
 }
 
@@ -441,21 +441,25 @@ static int netcp_cfgp_find_ip_slot(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ***************************************************************************
  * DESCRIPTION: Netapi internal function to insert an IP address into interface
  ***************************************************************************/
-static void netcp_cfgp_insert_ip(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, 
-                          nwal_IpType ipType,
-                          nwalIpAddr_t *ip_addr, 
-                          nwalIpOpt_t *ip_qualifiers, 
-                          int iface_no,
-                          int ip_slot,  //we 'reserved it already'
-                          void * handle,
-                          void * user_data)
+static void netapip_netcpCfgInsertIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, 
+                                     nwal_IpType ipType,
+                                     nwalIpAddr_t *ip_addr, 
+                                     nwalIpOpt_t *ip_qualifiers, 
+                                     int iface_no,
+                                     int ip_slot,
+                                     void * handle,
+                                     void * user_data)
 {
-     p->ips[ip_slot].in_use=1;
+    p->ips[ip_slot].in_use=1;
     memcpy(&p->ips[ip_slot].ip_addr, ip_addr, sizeof(nwalIpAddr_t));
     if(ip_qualifiers)
+    {
         memcpy(&p->ips[ip_slot].ip_qualifiers, ip_qualifiers, sizeof(nwalIpOpt_t));
+    }
     else
+    {
         memset(&p->ips[ip_slot].ip_qualifiers, 0, sizeof(nwalIpOpt_t));
+    }
     p->ips[ip_slot].ip_type = ipType;
     p->ips[ip_slot].nwal_handle = handle;
     p->ips[ip_slot].user_data = user_data;
@@ -467,10 +471,9 @@ static void netcp_cfgp_insert_ip(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ***************************************************************************
  * DESCRIPTION: Netapi internal function to free IP slot associated with IP address
  ***************************************************************************/
-static void netcp_cfgp_delete_ip(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-         int iface_no,
-         int ip_slot )
+static void netapip_netcpCfgDeleteIp(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                     int iface_no,
+                                     int ip_slot)
 {
     if ((ip_slot >=0) &&(ip_slot <=TUNE_NETAPI_MAX_NUM_IP))
     {
@@ -483,10 +486,9 @@ static void netcp_cfgp_delete_ip(
  ***************************************************************************
  * DESCRIPTION: Netapi internal function to get IP handle associated with IP address
  ***************************************************************************/
-static void *netcp_cfgp_get_ip_handle(
-         NETAPI_NWAL_GLOBAL_CONTEXT_T *p, 
-         int iface_no,
-         int ip_slot )
+static void *netapip_netcpCfgGetIpHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         int iface_no,
+                                         int ip_slot)
 {
     if ((ip_slot <0)||(ip_slot>=TUNE_NETAPI_MAX_NUM_IP))
         return NULL;
@@ -504,8 +506,11 @@ static void *netcp_cfgp_get_ip_handle(
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to insert an interface to the interface list
  *******************************************************************************/
-static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char * p_mac,
-                           int iface_no, int state, NETCP_CFG_VLAN_T vlan, void * handle)
+static void netapip_netcpCfgInsertMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                      unsigned char * p_mac,
+                                      int iface_no, 
+                                      int state, NETCP_CFG_VLAN_T vlan, 
+                                      void * handle)
 {
     if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
     {
@@ -515,10 +520,10 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
         p->interfaces[iface_no].state = state;
         //todo p->interfaces[iface_no].vlan = vlan;
         p->interfaces[iface_no].nwal_handle = handle; //save handle assoicated with this rule
-        Debug_printf("netcp_cfgp_insert_mac, global context 0x%x\n", p);
+        netapi_Log("netapip_netcpCfgInsertMac, global context 0x%x\n", p);
     }
     else 
-        Debug_printf(">netcp_cfg insert interface # out of range %d\n",iface_no);
+        netapi_Log(">netapip_netcpCfgInsertMac insert interface # out of range %d\n",iface_no);
 
 }
 
@@ -527,26 +532,31 @@ static void netcp_cfgp_insert_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p, unsigned char
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to get handle associated with interface
  *******************************************************************************/
-void* netcp_cfgp_get_mac_handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
+void* netapip_netcpCfgGetMacHandle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                   int iface_no)
 {
-   if (iface_no == NETCP_CFG_NO_INTERFACE) return NULL;
-   if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_NUM_MAC))
-   {
-       return NULL;
-   }
-   else if ( p->interfaces[iface_no].in_use)
-   {
-     return (void *) p->interfaces[iface_no].nwal_handle;
-   }
-   //no valid entry in slot
-   return NULL;
+    if (iface_no == NETCP_CFG_NO_INTERFACE)
+    {
+        return NULL;
+    }
+    if ((iface_no <0 ) || (iface_no >= TUNE_NETAPI_MAX_NUM_MAC))
+    {
+        return NULL;
+    }
+    else if ( p->interfaces[iface_no].in_use)
+    {
+      return (void *) p->interfaces[iface_no].nwal_handle;
+    }
+    //no valid entry in slot
+    return NULL;
 }
 /*******************************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to delete interface from interface list
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to delete interface from interface list
  *******************************************************************************/
-static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
+static void netapip_netcpCfgDeleteMac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                      int iface_no)
 {
     if ((iface_no >=0 ) && (iface_no < TUNE_NETAPI_MAX_NUM_MAC))
     {
@@ -554,7 +564,6 @@ static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
     }
 }
 
-
 /*========================CLASSIFIERS==========================*/
 
 /*******************************************************************************
@@ -562,35 +571,34 @@ static void netcp_cfgp_delete_mac(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,int iface_no)
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to find a free slot for classifier rule
  *******************************************************************************/
-static int netcp_cfgp_find_class_slot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
+static int netapip_netcpCfgFindClassSlot( NETAPI_NWAL_GLOBAL_CONTEXT_T *p)
 {
-   int i;
-         //find a free entry\
-    hplib_mSpinLockLock(&netcp_cfg_lock);
-   for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
-   {
-       if (!p->classi[i].in_use)
-       {
-           p->classi[i].in_use = 2; //pending
-            hplib_mSpinLockUnlock(&netcp_cfg_lock);
-           return i;
-       }
-   }
-    hplib_mSpinLockUnlock(&netcp_cfg_lock);
-   return -1;
+    int i;
+    hplib_mSpinLockLock(&netapi_netcp_cfg_lock);
+    for(i=0;i<TUNE_NETAPI_MAX_CLASSIFIERS;i++)
+    {
+        if (!p->classi[i].in_use)
+        {
+            p->classi[i].in_use = 2; //pending
+            hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
+            return i;
+        }
+    }
+    hplib_mSpinLockUnlock(&netapi_netcp_cfg_lock);
+    return -1;
 }
 /*******************************************************************************
  * FUNCTION PURPOSE:  Netapi internal function to find a delete a classifer from classifer list
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to find a delete a classifer from classifer list
  *******************************************************************************/
-static void netcp_cfgp_delete_class(
+static void netapip_netcpCfgDeleteClass(
          NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
          int class_slot )
 {
     if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
     {
-        return ;
+        return;
     }
     p->classi[class_slot].in_use=0;
 }
@@ -600,21 +608,23 @@ static void netcp_cfgp_delete_class(
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to find a insert a classifer to classifer list
  *******************************************************************************/
-static void netcp_cfgp_insert_class(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                            int class_slot,  //we 'reserved it already'
-                            int class_type,
-                            void * L2_handle,
-                            void * L3_handle,
-                            void * L4_handle,
-                            void * user_data)
+static void netapip_netcpCfgInsertClass(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                        int class_slot,
+                                        int class_type,
+                                        void * L2_handle,
+                                        void * L3_handle,
+                                        void * L4_handle,
+                                        void * user_data)
 {
-    p->classi[class_slot].in_use=1;
-    p->classi[class_slot].nwal_L2_handle = L2_handle;
-    p->classi[class_slot].nwal_L3_handle = L3_handle;
-    p->classi[class_slot].nwal_L4_handle = L4_handle;
-    p->classi[class_slot].class_type = class_type;
-    p->classi[class_slot].user_data = user_data;
-    
+    if ((class_slot >=0 ) && (class_slot < TUNE_NETAPI_MAX_CLASSIFIERS))
+    {
+        p->classi[class_slot].in_use=1;
+        p->classi[class_slot].nwal_L2_handle = L2_handle;
+        p->classi[class_slot].nwal_L3_handle = L3_handle;
+        p->classi[class_slot].nwal_L4_handle = L4_handle;
+        p->classi[class_slot].class_type = class_type;
+        p->classi[class_slot].user_data = user_data;
+    }
 }
 
 /*******************************************************************************
@@ -622,11 +632,17 @@ static void netcp_cfgp_insert_class(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to get L4 nwal handle for classifier
  *******************************************************************************/
-static void *netcp_cfgp_get_l4_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int class_slot)
+static void *netapip_netcpCfgGetL4Handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         int class_slot)
 {
-    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) return NULL;
-    if (!p->classi[class_slot].in_use) return NULL;
+    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+    {
+        return NULL;
+    }
+    if (!p->classi[class_slot].in_use)
+    {
+        return NULL;
+    }
     return p->classi[class_slot].nwal_L4_handle;
 }
 
@@ -635,11 +651,17 @@ static void *netcp_cfgp_get_l4_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  *******************************************************************************
  * DESCRIPTION:  Netapi internal function to get L3 nwal handle for classifier
  *******************************************************************************/
-static void *netcp_cfgp_get_l3_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
-                          int class_slot)
+static void *netapip_netcpCfgGetL3Handle(NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
+                                         int class_slot)
 {
-    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS)) return NULL;
-    if (!p->classi[class_slot].in_use) return NULL;
+    if ((class_slot <0 ) || (class_slot >= TUNE_NETAPI_MAX_CLASSIFIERS))
+    {
+        return NULL;
+    }
+    if (!p->classi[class_slot].in_use)
+    {
+        return NULL;
+    }
     return p->classi[class_slot].nwal_L3_handle;
 }
 
@@ -654,7 +676,10 @@ static void *netcp_cfgp_get_l3_handle( NETAPI_NWAL_GLOBAL_CONTEXT_T *p,
  ********************************************************************
  * DESCRIPTION:  API to request statistics from NETCP
  ********************************************************************/
-void netcp_cfgReqStats(NETAPI_T  h, NETCP_CFG_STATS_CB cb, int doClear, int *err) 
+void netapi_netcpCfgReqStats(NETAPI_T  h, 
+                             NETCP_CFG_STATS_CB cb,
+                             int doClear,
+                             int *err) 
 {
     nwal_RetValue ret;
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
@@ -667,7 +692,7 @@ void netcp_cfgReqStats(NETAPI_T  h, NETCP_CFG_STATS_CB cb, int doClear, int *err
     }
     *err =0;
 
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &transId);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &transId);
     if (!pTransInfo) { *err =  NETAPI_ERR_BUSY; return ;}
     pTransInfo->transType = NETAPI_NWAL_HANDLE_STAT_REQUEST;
     pTransInfo->netapi_handle = h;
@@ -678,27 +703,25 @@ void netcp_cfgReqStats(NETAPI_T  h, NETCP_CFG_STATS_CB cb, int doClear, int *err
                               doClear);
     if(ret !=  nwal_OK)
     {
-        pTransInfo->inUse = nwal_FALSE;
+        //pTransInfo->inUse = nwal_FALSE;
         *err = NETAPI_ERR_BUSY;  //no resources??
-        Debug_printf("> netcp_cfg reqStats failed, err=%d\n",ret);
+        netapi_Log("> netapi_netcpCfg reqStats failed, err=%d\n",ret);
     }
-
+    netapip_freeTransInfo(pTransInfo);
 }
 /********************************************************************
  * FUNCTION PURPOSE:  API to create a MAC interface
  ********************************************************************
  * DESCRIPTION:  API to create a MAC interface
  ********************************************************************/
-NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
-                    NETAPI_T  h,
-                    uint8_t *p_mac,
-                    int  iface_no, 
-                    int switch_port, 
-                    NETCP_CFG_ROUTE_HANDLE_T  route,
-                    NETCP_CFG_VLAN_T  vlan,  //future
-                    int state,  //0=down, 1=up  //ignored
-                    int * err
-)
+NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T  h,
+                                                     uint8_t *p_mac,
+                                                     int  iface_no, 
+                                                     int switch_port, 
+                                                     NETCP_CFG_ROUTE_HANDLE_T  route,
+                                                     NETCP_CFG_VLAN_T  vlan,  //future
+                                                     int state,  //0=down, 1=up  //ignored
+                                                     int * err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     nwalMacParam_t   MacInfo=
@@ -720,7 +743,7 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
     if ((!n) || (!p_mac)) {*err = NETAPI_ERR_BAD_INPUT; return -1;}
     *err =0;
 
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
@@ -738,7 +761,7 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
 
     if (route != NULL)
     {
-        netcp_cfgp_build_route(route,&MacInfo.appRxPktFlowId, &MacInfo.appRxPktQueue);
+        netapip_netcpCfgBuildRoute(route,&MacInfo.appRxPktFlowId, &MacInfo.appRxPktQueue);
     }
     retValue = nwal_setMacIface( ((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
                                   trans_id,
@@ -748,9 +771,9 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
     if(retValue !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        Debug_printf (">netcp cfg - ERROR: nwal_setMacIface returned Error Code %d\n",
+        netapi_Log ("netapi_netcpCfg - ERROR: nwal_setMacIface returned Error Code %d\n",
                     retValue);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return -1;
     }
 
@@ -768,19 +791,19 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            Debug_printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+            netapi_Log (">netapi_netcpCfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
                     *err);
             return -1;
         }
 
     }
-    Debug_printf (">netcp cfg: MAC i/f %d added\n", iface_no);
-    netcp_cfgp_insert_mac(&netapi_get_global()->nwal_context, 
+    netapi_Log ("netapi_netcpCfg: MAC i/f %d added\n", iface_no);
+    netapip_netcpCfgInsertMac(&netapi_get_global()->nwal_context, 
                           p_mac, iface_no, state,vlan,
                           (void *) pTransInfo->handle);
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
     return  (NETAPI_NETCP_MATCH_GENERIC_MAC | iface_no);
 }
 
@@ -789,7 +812,9 @@ NETCP_CFG_MACIF_T  netcp_cfgCreateMacInterface(
  ********************************************************************
  * DESCRIPTION:  API to delete MAC  interface
  ********************************************************************/
-void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
+void netapi_netcpCfgDelMac(NETAPI_T h,
+                           int iface_no,
+                           int *err)
 {
     nwal_RetValue ret;
     NetapiNwalTransInfo_t *pTransInfo;
@@ -798,13 +823,15 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
     void * ifHandle;
 
     //get the nwal handle assoicated with this iface
-    ifHandle = netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no );
+    ifHandle = netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context, iface_no );
     if(!ifHandle) 
-            {*err = NETAPI_ERR_BAD_INPUT; return ;}
+    {
+        *err = NETAPI_ERR_BAD_INPUT; return ;
+    }
     *err =0;
 
     //get a transaction id
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
@@ -823,9 +850,9 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
     if(ret !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+        netapi_Log ("netapi_netcpCfg - ERROR: nwal_delMacIface returned Error Code %d\n",
                     ret);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return;
     }
     //wait here until its done since scheduler isn't running yet most likely..
@@ -842,18 +869,18 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            Debug_printf (">netcp_cfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
+            netapi_Log (">netapi_netcpCfgCreateMacInterface - ERROR returned by NETCP PA firmware %d\n",
                     *err);
-            netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context,  iface_no);
+            netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context,  iface_no);
             return;
         }
     }
-    Debug_printf (">netcp cfg: MAC i/f %d deleted\n",iface_no);
-    netapip_FreeTransInfo(pTransInfo);
+    netapi_Log ("netapi_netcpCfg: MAC i/f %d deleted\n",iface_no);
+    netapip_freeTransInfo(pTransInfo);
     //zap the entry
-    netcp_cfgp_delete_mac(&netapi_get_global()->nwal_context,  iface_no);
+    netapip_netcpCfgDeleteMac(&netapi_get_global()->nwal_context,  iface_no);
     return ;
 }
 
@@ -863,17 +890,17 @@ void netcp_cfgDelMac(NETAPI_T h,int iface_no,  int *err)
  ********************************************************************
  * DESCRIPTION:  NETAPi internal function to Add IP to MAC interface
  ********************************************************************/
-static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
-                  NETAPI_T  h,
-                  int  iface_no,
-                  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
-                  void * user_data,
-                  int * err,
-                  int  flag) //TRUE: add IP to iface.  False: add IP as part of classifier
-{
+static NETCP_CFG_IP_T  netapip_netcpCfgAddIpInternal(NETAPI_T  h,
+                                                     int  iface_no,
+                                                     nwal_IpType ipType,
+                                                     nwalIpAddr_t  * ip_addr,
+                                                     nwalIpOpt_t * ip_qualifiers,
+                                                     NETCP_CFG_ROUTE_HANDLE_T  route,/*NULL for default*/
+                                                     void * user_data,
+                                                     int * err,
+                                                     int  flag) /*TRUE: add IP to iface,
+                                                     FALSE: add IP as part of classifier */
+                            {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * n_handle=NULL;
     nwalIpParam_t    nwalIpParam= {
@@ -900,8 +927,8 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
 
     if (iface_no != NETCP_CFG_NO_INTERFACE)
     {
-        Debug_printf("netcp_cfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
-        Debug_printf("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
+        netapi_Log("netapip_netcpCfgAddIpInternal, in_use %d\n", netapi_get_global()->nwal_context.interfaces[iface_no].in_use);
+        netapi_Log("netcp-cfgAddIpInternal, p 0x%x\n", &netapi_get_global()->nwal_context);
         if(netapi_get_global()->nwal_context.interfaces[iface_no].in_use)
         {
             n_handle =  netapi_get_global()->nwal_context.interfaces[iface_no].nwal_handle;
@@ -915,7 +942,7 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     if (flag) //if adding IP to MAC then reserve a slot to save info
     {
         //find free slot for IP & reserve
-         ip_slot= netcp_cfgp_find_ip_slot(&netapi_get_global()->nwal_context, 
+         ip_slot= netapip_netcpCfgFindIpSlot(&netapi_get_global()->nwal_context, 
                                    iface_no);
         if (ip_slot <0) 
         {
@@ -925,13 +952,13 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     }
 
     //get a transaction object for config action
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
         if (flag)
         {
-            netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,
+            netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
                          iface_no,
                          ip_slot);
         }
@@ -947,7 +974,7 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     nwalIpParam.ipType=ipType;
     if(route)
     {
-        netcp_cfgp_build_route(route,&nwalIpParam.appRxPktFlowId, &nwalIpParam.appRxPktQueue);
+        netapip_netcpCfgBuildRoute(route,&nwalIpParam.appRxPktFlowId, &nwalIpParam.appRxPktQueue);
     }
     else{} //use nwal defaults
 
@@ -958,7 +985,7 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
 
     //build the rule id that will be returned when a packet matches 
     if (flag)
-        ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&&0xff)<<8);
+        ip_rule_id = NETAPI_NETCP_MATCH_GENERIC_IP | iface_no | ((ip_slot&& NETAPI_NETCP_MATCH_ID_MASK) << NETAPI_NETCP_MATCH_ID_SHIFT);
     else
         ip_rule_id = (NETAPI_NETCP_MATCH_CLASS_L3 | iface_no);
 
@@ -972,13 +999,13 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
     if(retValue !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        Debug_printf (">netcp cfg: nwal_setIP returned Error Code %d\n",
+        netapi_Log ("netcp_cfg: nwal_setIP returned Error Code %d\n",
                     retValue);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         //zap the entry
         if (flag)
         {
-            netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,
+            netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,
                          iface_no,
                          ip_slot);
         }
@@ -998,22 +1025,22 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            Debug_printf (">netcp_cfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+            netapi_Log (">netapip_netcpCfgAddIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
             return -1;
         }
     }
     if (flag)
     {
-        Debug_printf (">netcp cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);
-        netcp_cfgp_insert_ip(&netapi_get_global()->nwal_context, ipType, 
+        netapi_Log ("netcp_cfg: IP added to interface %d (slot%d)\n", iface_no, ip_slot);
+        netapip_netcpCfgInsertIp(&netapi_get_global()->nwal_context, ipType, 
                           ip_addr, ip_qualifiers, iface_no, ip_slot,
                           pTransInfo->handle, user_data);
     }
 
     temp = (NETCP_CFG_IP_T) pTransInfo->handle;
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
     return  (flag ? ip_rule_id:  temp);
 }
 
@@ -1022,19 +1049,17 @@ static NETCP_CFG_IP_T  netcp_cfgAddIpInternal(
  ********************************************************************
  * DESCRIPTION:  API to Add IP to MAC interface
  ********************************************************************/
-NETCP_CFG_IP_T  netcp_cfgAddIp(
-                  NETAPI_T  h,
-                  int  iface_no,
-                  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
-                  void * user_data,
-                  int * err
-                  )
+NETCP_CFG_IP_T  netapi_netcpCfgAddIp(NETAPI_T  h,
+                                     int  iface_no,
+                                     nwal_IpType ipType,
+                                     nwalIpAddr_t  * ip_addr,
+                                     nwalIpOpt_t * ip_qualifiers,
+                                     NETCP_CFG_ROUTE_HANDLE_T  route,  //NULL for default
+                                     void * user_data,
+                                     int * err)
 {
-    return netcp_cfgAddIpInternal(h, iface_no, ipType, ip_addr, 
-                                                        ip_qualifiers, route, user_data,err, 1);
+    return netapip_netcpCfgAddIpInternal(h, iface_no, ipType, ip_addr, 
+                                         ip_qualifiers, route, user_data,err, 1);
 }
 
 /********************************************************************
@@ -1042,25 +1067,27 @@ NETCP_CFG_IP_T  netcp_cfgAddIp(
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function to detach IP from MAC interface
  ********************************************************************/
-static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers, 
-                  NETCP_CFG_IP_T  ip_rule_id,
-                  int *err, 
-                  void * handle,   /* if flag==0, handle must be valid */
-                  int flag)        /* flag==0 => delete IP rule that was part of classifier, not interface */
+static void netapip_netcpCfgDelIpInternal(NETAPI_T h, 
+                                          int iface_no,
+                                          nwal_IpType ipType,
+                                          nwalIpAddr_t  * ip_addr,
+                                          nwalIpOpt_t * ip_qualifiers, 
+                                          NETCP_CFG_IP_T  ip_rule_id,
+                                          int *err, 
+                                          void * handle,   /* if flag==0, handle must be valid */
+                                          int flag)        /* flag==0 => delete IP rule that was part of classifier, not interface */
 {
     nwal_RetValue ret;
     NetapiNwalTransInfo_t *pTransInfo;
     nwal_TransID_t     trans_id;
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * ifHandle;
-    int ip_slot = (ip_rule_id>>8)&0xff;
+    int ip_slot = netapi_cfgGetMatchId(ip_rule_id);
 
     //get the nwal handle assoicated with this ip   
     if (flag)
     {
-        ifHandle = netcp_cfgp_get_ip_handle(
+        ifHandle = netapip_netcpCfgGetIpHandle(
                                         &netapi_get_global()->nwal_context, iface_no,
                                         ip_slot );
     }
@@ -1076,7 +1103,7 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
     *err =0;
 
     //get a transaction id
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY;
@@ -1094,9 +1121,9 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
     if(ret !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-        Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+        netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
                     ret);
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         return ;
     }
     //wait here until its done since scheduler isn't running yet most likely..
@@ -1113,22 +1140,18 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
         }
         if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
         {
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             *err = NETAPI_ERR_PA_FW;
-            Debug_printf (">netcp_cfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
+            netapi_Log (">netapip_netcpCfgDelIpInternal - ERROR returned by NETCP PA firmware %d\n", *err);
             return;
         }
     }
-    if (flag)
-        Debug_printf (">netcp cfg: attached IP deleted\n");
-    else
-        Debug_printf (">netcp cfg: Classifier IP rule deleted\n");
 
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
 
     //zap the entry
     if (flag)
-        netcp_cfgp_delete_ip(&netapi_get_global()->nwal_context,  
+        netapip_netcpCfgDeleteIp(&netapi_get_global()->nwal_context,  
                          iface_no,
                          ip_slot);
     return ;
@@ -1139,13 +1162,15 @@ static void netcp_cfgDelIpInternal(NETAPI_T h, int iface_no,  nwal_IpType ipType
  ********************************************************************
  * DESCRIPTION:  API  to detach IP from MAC interface
  ********************************************************************/
-void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
-                  nwalIpAddr_t  * ip_addr,
-                  nwalIpOpt_t * ip_qualifiers,
-                  NETCP_CFG_IP_T  ip_rule_id,
-                  int *err)
+void netapi_netcpCfgDelIp(NETAPI_T h,
+                          int iface_no,  
+                          nwal_IpType ipType,
+                          nwalIpAddr_t  * ip_addr,
+                          nwalIpOpt_t * ip_qualifiers,
+                          NETCP_CFG_IP_T  ip_rule_id,
+                          int *err)
 {
-    netcp_cfgDelIpInternal( h, iface_no, ipType,
+    netapip_netcpCfgDelIpInternal( h, iface_no, ipType,
                   ip_addr, ip_qualifiers, ip_rule_id,
                   err, NULL, 1);
     return;
@@ -1157,10 +1182,12 @@ void netcp_cfgDelIp(NETAPI_T h, int iface_no,  nwal_IpType ipType,
  ********************************************************************
  * DESCRIPTION:  API to attach a classifier rule to NETCP
  ********************************************************************/
-NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
-                                      NETCP_CFG_CLASSIFIER_T *p_class,
-                                      NETCP_CFG_ROUTE_HANDLE_T route,
-                                      int action, void * user_data, int * err)
+NETCP_CFG_CLASS_T netapi_netcpCfgAddClass(NETAPI_T h,
+                                          NETCP_CFG_CLASSIFIER_T *p_class,
+                                          NETCP_CFG_ROUTE_HANDLE_T route,
+                                          int action, 
+                                          void * user_data, 
+                                          int * err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * l3_handle=NULL;  //ip handle
@@ -1190,7 +1217,7 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
     switch(p_class->classType)
     {
         default:
-            Debug_printf(">netcp_cfg : classifier type %d not supported\n",p_class->classType);
+            netapi_Log(">netapi_netcpCfg : classifier type %d not supported\n",p_class->classType);
             break;
         case(NETCP_CFG_CLASS_TYPE_L3_L4):
         case(NETCP_CFG_CLASS_TYPE_L4):
@@ -1198,7 +1225,7 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             iface_no = p_class->u.c_l4.iface;
             if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
             {
-                ip_slot = (p_class->u.c_l4.ip>>8)&0xff;
+                ip_slot = netapi_cfgGetMatchId(p_class->u.c_l4.ip);
             }
 
             //verify that iface has been configured 
@@ -1214,7 +1241,7 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
             {
                 //verify that ip has been configured and get its handle
-                l3_handle = netcp_cfgp_get_ip_handle(
+                l3_handle = netapip_netcpCfgGetIpHandle(
                       &netapi_get_global()->nwal_context, iface_no,
                       ip_slot );
             }
@@ -1242,14 +1269,14 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
                 //find if we have a matching L3 handle for IP classifier; if not create it
                 retValue =  nwal_getIPAddr (((NETAPI_GLOBAL_T*) (n->global))->nwal_context.nwalInstHandle,
                             &tempParam,
-                            netcp_cfgp_get_mac_handle(&netapi_get_global()->nwal_context, iface_no ),
+                            netapip_netcpCfgGetMacHandle(&netapi_get_global()->nwal_context, iface_no ),
                             &l3_handle); 
                 if (retValue != nwal_TRUE) 
                 {
                     int ret;
                     //**NEW IP RULE  
                     //need to attach this IP RULE to the MAC
-                    l3_handle= (void *) netcp_cfgAddIpInternal(
+                    l3_handle= (void *) netapip_netcpCfgAddIpInternal(
                                       h, iface_no, 
                                       p_class->u.c_l3_l4.ipType,
                                       p_class->u.c_l3_l4.ip_addr,
@@ -1272,9 +1299,11 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
 
 
             //find free slot for CLASS & reserve
-            class_slot= netcp_cfgp_find_class_slot(&netapi_get_global()->nwal_context);
+            class_slot= netapip_netcpCfgFindClassSlot(&netapi_get_global()->nwal_context);
             if(class_slot<0) {*err = NETAPI_ERR_NOMEM; return -1;}
-            classHandle = NETAPI_NETCP_MATCH_CLASS | (class_slot<<8) | (iface_no&0xff);
+            classHandle = NETAPI_NETCP_MATCH_CLASS |
+                          (class_slot << NETAPI_NETCP_MATCH_ID_SHIFT) | 
+                          (iface_no & NETAPI_NETCP_MATCH_LOGICAL_MAC_IFACE_MASK);
             //build request from template
             tempCfg.inHandle=l3_handle;
             if (p_class->classType== NETCP_CFG_CLASS_TYPE_L4)
@@ -1291,12 +1320,12 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             tempCfg.matchAction = (action==NETCP_CFG_ACTION_TO_SW)  ? NWAL_MATCH_ACTION_HOST : NWAL_MATCH_ACTION_DISCARD;
             if (route)
             {
-                netcp_cfgp_build_route(route,&tempCfg.appRxPktFlowId, &tempCfg.appRxPktQueue);
+                netapip_netcpCfgBuildRoute(route,&tempCfg.appRxPktFlowId, &tempCfg.appRxPktQueue);
             }
 
 
             //get a transaction id
-            pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+            pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
             if (!pTransInfo)
             {
                 *err =  NETAPI_ERR_BUSY; 
@@ -1317,10 +1346,10 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
             if(retValue !=  nwal_OK)
             {
                 *err = NETAPI_ERR_NWAL_ERR0;
-                Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
+                netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n",
                         retValue);
-                netapip_FreeTransInfo(pTransInfo);
-                netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
+                netapip_freeTransInfo(pTransInfo);
+                netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
                 return -1;
             }
             //wait here until its done since scheduler isn't running yet most likely..
@@ -1337,15 +1366,15 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
                 }
                 if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
                 {
-                    netapip_FreeTransInfo(pTransInfo);
+                    netapip_freeTransInfo(pTransInfo);
                     *err = NETAPI_ERR_PA_FW;
-                    netcp_cfgp_delete_class(&netapi_get_global()->nwal_context, class_slot);
-                    Debug_printf (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
+                    netapip_netcpCfgDeleteClass(&netapi_get_global()->nwal_context, class_slot);
+                    netapi_Log (">netcp_cfgAddClass - ERROR returned by NETCP PA firmware %d\n", *err);
                     return -1;
                 }
             }
-            Debug_printf (">netcp cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
-            netcp_cfgp_insert_class(&netapi_get_global()->nwal_context, 
+            netapi_Log ("netcp_cfg: L4 Classifer added to interface %d ip %d (slot%d)\n", iface_no, ip_slot, class_slot);
+            netapip_netcpCfgInsertClass(&netapi_get_global()->nwal_context, 
                                    class_slot,
                                  p_class->classType, 
                                 NULL,  //L2 we have
@@ -1353,7 +1382,7 @@ NETCP_CFG_CLASS_T netcp_cfgAddClass(NETAPI_T h,
                                   pTransInfo->handle,
                                   user_data);
 
-            netapip_FreeTransInfo(pTransInfo);
+            netapip_freeTransInfo(pTransInfo);
             return classHandle;
     } //end switch
 
@@ -1365,9 +1394,9 @@ return -1;
  ********************************************************************
  * DESCRIPTION:  API to delete a preconfigured classifier
  ********************************************************************/
-void netcp_cfgDelClass(NETAPI_T h,
-                         NETCP_CFG_CLASS_T classId,
-                         int *err)
+void netapi_netcpCfgDelClass(NETAPI_T h,
+                             NETCP_CFG_CLASS_T classId,
+                             int *err)
 {
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
     void * L4_handle;  //class handle -> L4
@@ -1377,25 +1406,25 @@ void netcp_cfgDelClass(NETAPI_T h,
     nwal_TransID_t     trans_id;
     int class_slot=-1;
 
-    class_slot = (classId>>8)&0xffff;
-    L4_handle=netcp_cfgp_get_l4_handle(&netapi_get_global()->nwal_context, class_slot);
+    class_slot = netapi_cfgGetMatchId(classId);
+    L4_handle=netapip_netcpCfgGetL4Handle(&netapi_get_global()->nwal_context, class_slot);
     if(!L4_handle)
     {
         *err = NETAPI_ERR_BAD_INPUT; 
-        goto ERR_netcp_cfgDelClass;
+        goto ERR_netapi_netcpCfgDelClass;
     }
-    L3_handle = netcp_cfgp_get_l3_handle( &netapi_get_global()->nwal_context, class_slot );
+    L3_handle = netapip_netcpCfgGetL3Handle( &netapi_get_global()->nwal_context, class_slot );
     /* l3 handle might be NULL,, depending on type of classifier */
 
-    netcp_cfgp_delete_class(
+    netapip_netcpCfgDeleteClass(
                         &netapi_get_global()->nwal_context,
                         class_slot );
     //get a transaction id
-    pTransInfo = netapip_GetFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
+    pTransInfo = netapip_getFreeTransInfo((NETAPI_GLOBAL_T *) n->global, &trans_id);
     if (!pTransInfo)
     {
         *err =  NETAPI_ERR_BUSY; 
-        goto ERR_netcp_cfgDelClass;
+        goto ERR_netapi_netcpCfgDelClass;
     }
     pTransInfo->transType = NETAPI_NWAL_HANDLE_TRANS_PORT;
     pTransInfo->state = NETAPI_NWAL_HANDLE_STATE_CLOSE_PENDING;
@@ -1408,9 +1437,9 @@ void netcp_cfgDelClass(NETAPI_T h,
     if(retValue !=  nwal_OK)
     {
         *err = NETAPI_ERR_NWAL_ERR0;
-         Debug_printf (">netcp cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
-         netapip_FreeTransInfo(pTransInfo);
-         goto ERR_netcp_cfgDelClass;  /* todo: what about the L3? */
+         netapi_Log ("netcp_cfg - ERROR: nwal_delMacIface returned Error Code %d\n", retValue);
+         netapip_freeTransInfo(pTransInfo);
+         goto ERR_netapi_netcpCfgDelClass;  /* todo: what about the L3? */
     }
     //wait here until its done since scheduler isn't running yet most likely..
     // todo:  make this handled by scheduler poll later ??
@@ -1427,25 +1456,25 @@ void netcp_cfgDelClass(NETAPI_T h,
     }
     if (pTransInfo->state == NETAPI_NWAL_HANDLE_STATE_ERR)
     {
-        netapip_FreeTransInfo(pTransInfo);
+        netapip_freeTransInfo(pTransInfo);
         *err = NETAPI_ERR_PA_FW;
-         Debug_printf (">netcp_cfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
-         goto ERR_netcp_cfgDelClass;
+         netapi_Log (">netapi_netcpCfgDelClass - ERROR returned by NETCP PA firmware %d\n", *err);
+         goto ERR_netapi_netcpCfgDelClass;
     }
-    Debug_printf (">netcp cfg: Classifer deleted\n");
+    netapi_Log ("netcp_cfg: Classifer deleted\n");
     pTransInfo->state =  NETAPI_NWAL_HANDLE_STATE_IDLE;
     pTransInfo->inUse = nwal_FALSE;
 
     /* delete L3 if we have to */
     if (L3_handle)
     {
-        netcp_cfgDelIpInternal( h, 0, 0,
+        netapip_netcpCfgDelIpInternal( h, 0, 0,
                   NULL, NULL, 0,
                   err, L3_handle,  0);
     }
-    netapip_FreeTransInfo(pTransInfo);
+    netapip_freeTransInfo(pTransInfo);
 
-ERR_netcp_cfgDelClass:
+ERR_netapi_netcpCfgDelClass:
     return;
 }
 
@@ -1456,12 +1485,12 @@ ERR_netcp_cfgDelClass:
  ********************************************************************/
 /*--------------flow management--------*/
 // ADD A Flow
-NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
-                                            int n,
-                                            Pktlib_HeapHandle handles[],
-                                            int sizes[],
-                                            int byte_offset,
-                                            int * err )
+NETCP_CFG_FLOW_HANDLE_T netapi_netcpCfgAddFlow(NETAPI_T h,
+                                               int n,
+                                               Pktlib_HeapHandle handles[],
+                                               int sizes[],
+                                               int byte_offset,
+                                               int * err )
 {
     Cppi_RxFlowCfg  rxFlowCfg;
     Uint8           isAlloc;
@@ -1474,7 +1503,7 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
 
     *err= 0;  /* ok */
     //get a slot to save new flow
-    slot = netcp_cfgp_find_flow_slot(&netapi_get_global()->nwal_context);
+    slot = netapip_netcpCfgFindFlowSlot(&netapi_get_global()->nwal_context);
     if (slot<0) { *err= NETAPI_ERR_NOMEM;  return NULL; }
 
     //configure flow
@@ -1558,13 +1587,13 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
     if (FlowHnd == NULL)
     {
         *err= NETAPI_ERR_NORES;
-        netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot);
+        netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
         return (NULL);
     }
 
     //update slot
-    retVal = netcp_cfgp_insert_flow(&netapi_get_global()->nwal_context, slot, (void*) FlowHnd);
-    Debug_printf(">netcp cfg:  flow %d created\n",  ((NETCP_CFG_FLOW_T *) retVal)->flowid);
+    retVal = netapip_netcpCfgInsertFlow(&netapi_get_global()->nwal_context, slot, (void*) FlowHnd);
+    netapi_Log("netcp_cfg:  flow %d created\n",  ((NETCP_CFG_FLOW_T *) retVal)->flowid);
     return ( retVal);
 }
 
@@ -1573,13 +1602,15 @@ NETCP_CFG_FLOW_HANDLE_T netcp_cfgAddFlow(NETAPI_T h,
  ********************************************************************
  * DESCRIPTION:  API to delete a flow
  ********************************************************************/
-void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err)
+void netapi_netcpCfgDelFlow(NETAPI_T h ,
+                            NETCP_CFG_FLOW_HANDLE_T f , 
+                            int * err)
 {
     int slot;
     void * handle;
     *err=0;
     /* find entry */
-    slot = netcp_cfgp_find_flow(&netapi_get_global()->nwal_context, ((NETCP_CFG_FLOW_T *) f) ->flowid, &handle);
+    slot = netapip_netcpCfgFindFlow(&netapi_get_global()->nwal_context, ((NETCP_CFG_FLOW_T *) f) ->flowid, &handle);
     if (slot<0)
     {
         *err = NETAPI_ERR_BAD_INPUT; 
@@ -1587,8 +1618,8 @@ void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err)
     }
 
     Cppi_closeRxFlow( (Cppi_FlowHnd) handle);
-    netcp_cfgp_delete_flow(&netapi_get_global()->nwal_context, slot);
-    Debug_printf(">netcp cfg:  flow %d deleted\n",  ((NETCP_CFG_FLOW_T *) f)->flowid);
+    netapip_netcpCfgDeleteFlow(&netapi_get_global()->nwal_context, slot);
+    netapi_Log("netcp_cfg:  flow %d deleted\n",  ((NETCP_CFG_FLOW_T *) f)->flowid);
     return;
 }
 
@@ -1597,10 +1628,10 @@ void netcp_cfgDelFlow(NETAPI_T h , NETCP_CFG_FLOW_HANDLE_T f , int * err)
  ******************************************************************************
  * DESCRIPTION:  API to configure NETCP with global rules for exception packet handling
  *****************************************************************************/
-NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
-                                    int exception_id ,
-                                    nwal_matchAction_t action,
-                                    NETCP_CFG_ROUTE_HANDLE_T p_route)
+NETCP_CFG_EXCEPTION_PKT_T netapi_netcpCfgExceptions(NETAPI_T h,
+                                                    int exception_id ,
+                                                    nwal_matchAction_t action,
+                                                    NETCP_CFG_ROUTE_HANDLE_T p_route)
 {
     nwalCtlInfo_t   ctrl;
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) h;
@@ -1609,7 +1640,7 @@ NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
 
     if (p_route != NULL)
     {
-        netcp_cfgp_build_route(p_route, &ctrl.appRxPktFlowId,& ctrl.appRxPktQueue);
+        netapip_netcpCfgBuildRoute(p_route, &ctrl.appRxPktFlowId,& ctrl.appRxPktQueue);
     }
     else
     {
@@ -1645,9 +1676,9 @@ NETCP_CFG_EXCEPTION_PKT_T netcp_cfgExceptions(NETAPI_T h,
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function, NETCP command reply callback
  ********************************************************************/
-void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
-                          uint16_t            trans_id,
-                          nwal_RetValue     ret)
+void netapi_NWALCmdCallBack(nwal_AppId        appHandle,
+                            uint16_t            trans_id,
+                            nwal_RetValue     ret)
 {
     NetapiNwalTransInfo_t * p_trans;
     NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL;
@@ -1663,7 +1694,7 @@ void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
 
     if(ret != nwal_OK)
     {
-        Debug_printf (">netcp cfg : netapi_NWALCmdCallBack returned Error Code %d for trans_id %d\n",
+        netapi_Log ("netcp_cfg : netapi_NWALCmdCallBack returned Error Code %d for trans_id %d\n",
                     ret, trans_id);
         // update error code that is fialed  in p_trans */
         //todo: atomic inc
@@ -1738,7 +1769,7 @@ void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
             }
             default:
             {
-                Debug_printf ("netcp cfg> Invalid transaction type %d for trans_id: %d\n",
+                netapi_Log ("netcp cfg> Invalid transaction type %d for trans_id: %d\n",
                     p_trans->transType,trans_id);
                 break;
             }
@@ -1759,9 +1790,9 @@ void netapi_NWALCmdCallBack (nwal_AppId        appHandle,
  ********************************************************************
  * DESCRIPTION:  NETAPI internal function, PA stats reply callback
  ********************************************************************/
-void netapi_NWALCmdPaStatsReply (nwal_AppId        appHandle,
-                              nwal_TransID_t    trans_id,
-                              paSysStats_t      *stats)
+void netapi_NWALCmdPaStatsReply(nwal_AppId        appHandle,
+                                nwal_TransID_t    trans_id,
+                                paSysStats_t      *stats)
 {
     NetapiNwalTransInfo_t * p_trans;
     NETAPI_NWAL_LOCAL_CONTEXT_T *p_local=NULL;
index 263f847f78457b8b46d9aaba4d1ac38431ae9673..d116d974b8909a31885baf94bab804c00175c9e5 100755 (executable)
@@ -80,7 +80,7 @@ static inline void* NETAPI_GET_REG_VADDR (void *    virtBaseAddr,
  ********************************************************************
  * DESCRIPTION:  Internal NETAI function ti initialize CPPI
  ********************************************************************/
-int netapi_init_cppi(void)
+int netapip_initCppi(void)
 {
     int32_t result, i;
     Cppi_GlobalConfigParams     netapi_cppiGblCfgParams[CPPI_MAX_CPDMA];
@@ -169,7 +169,7 @@ int netapi_init_cppi(void)
     result = Cppi_init (netapi_cppiGblCfgParams);
     if (result != CPPI_SOK)
     {
-      Debug_printf (">function cppi_init: Cppi_init failed with error code %d\n", result);
+      netapi_Log (">function cppi_init: Cppi_init failed with error code %d\n", result);
       return (-1);
     }
      return 1;
@@ -180,7 +180,7 @@ int netapi_init_cppi(void)
  ********************************************************************
  * DESCRIPTION:  Internal NETAI function ti initialize QM (once per SOC)
  ********************************************************************/
-int netapi_init_qm(int max_descriptors)
+int netapip_initQm(int max_descriptors)
 {
     Qmss_InitCfg     qmssInitConfig;
     int32_t          result;
@@ -291,7 +291,7 @@ int netapi_init_qm(int max_descriptors)
 
     result = Qmss_init (&qmssInitConfig, &netapi_qmssGblCfgParams);
     if (result != QMSS_SOK)  {
-        Debug_printf (">function init_qm: qmss_Init failed with error code %d\n", result);
+        netapi_Log (">function init_qm: qmss_Init failed with error code %d\n", result);
         return (nwal_FALSE);
     }
     return 1;
index aaffb217410dc2539a9523671337b9346c07c886..c5e8467f17ed3427abf95149b94876274fd68154 100755 (executable)
@@ -77,7 +77,7 @@ static inline void* NETAPI_GET_REG_VADDR (void *    virtBaseAddr,
  *****************************************************************************
  * DESCRIPTION: The function will initialize the CPPI
  *****************************************************************************/
-int netapi_init_cppi(void)
+int netapip_initCppi(void)
 {
 
     int32_t                         result;
@@ -164,7 +164,7 @@ int netapi_init_cppi(void)
                              (uint32_t)netapi_cppiGblCfgParams.cpDmaCfgs[Cppi_CpDma_QMSS_CPDMA].rxFlowRegs);
     result = Cppi_init (&netapi_cppiGblCfgParams);
     if (result != CPPI_SOK)  {
-        Debug_printf ("function testNwGlobCppiInit: Cppi_init failed with error code %d\n", result);
+        netapi_Log ("function testNwGlobCppiInit: Cppi_init failed with error code %d\n", result);
         return (-1);
     }
     return (1);
@@ -175,7 +175,7 @@ int netapi_init_cppi(void)
  *****************************************************************************
  * DESCRIPTION: The function will initialize the Queue Manager
  *****************************************************************************/
-int netapi_init_qm(int max_descriptors)
+int netapip_initQm(int max_descriptors)
 {
     Qmss_InitCfg              qmssInitConfig;
     int32_t                   result;
@@ -276,7 +276,7 @@ int netapi_init_qm(int max_descriptors)
     result = Qmss_init (&qmssInitConfig, &netapi_qmssGblCfgParams);
     if (result != QMSS_SOK)
     {
-        Debug_printf ("function testNwGlobQmInit: qmss_Init failed with error code %d\n", result);
+        netapi_Log ("function testNwGlobQmInit: qmss_Init failed with error code %d\n", result);
         return (nwal_FALSE);
     }
     return 1;
index 6636d013f86a7a890dff1ba1b2e814926f5d5c7f..5cfd2dc7fa08eff6b210fb67bc1e62f017ab5d66 100755 (executable)
@@ -53,9 +53,8 @@
 
 static hplib_spinLock_T pktio_lock = hplib_spinLock_UNLOCKED_INITIALIZER;
 
-/*--------------------Utilites-----------------*/
-
 
+/* Utilites*/
 static PKTIO_HANDLE_T * pktiop_get_free_channel_slot(NETAPI_T n)
 {
     PKTIO_HANDLE_T ** pp = (PKTIO_HANDLE_T **) netapi_get_pktio_list(n);
@@ -75,9 +74,7 @@ static PKTIO_HANDLE_T * pktiop_get_free_channel_slot(NETAPI_T n)
 }
 
 
-/*-----------------------------------------------------*/
-/*          optimized send/rcv functions              */
-/*----------------------------------------------------*/
+/*Optimized send functions */
 
 
 /********************************************************************
@@ -89,7 +86,10 @@ static PKTIO_HANDLE_T * pktiop_get_free_channel_slot(NETAPI_T n)
  * with updates for L4 checksum,ESP Crypto and outgoing EMAC port 
  * to NetCP command.
  ********************************************************************/
-static int pktio_sendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                            Ti_Pkt *pkt,
+                                            PKTIO_METADATA_T *m,
+                                            int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
@@ -98,9 +98,9 @@ static int pktio_sendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt,
 
     NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
 
-    netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1);
+    netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1);
 
-    if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
     {
         nwal_mCmdSetL4CkSumCrypPort(pkt,
                                     &p->tx_psCmdInfo,
@@ -113,7 +113,7 @@ static int pktio_sendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt,
                                     swInfo1,
                                     0);
 
-        Debug_printf("pktio_send_L4CkSumCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1); 
+        netapi_Log("netapi_pktioSendL4CkSumCryptPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1); 
         pPloadDesc = Pktlib_getDescFromPacket(pkt);
         pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
         Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
@@ -132,7 +132,10 @@ static int pktio_sendL4CkSumCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt,
  * with updates for ESP Crypto and outgoing EMAC port 
  * to NetCP command.
  ********************************************************************/
-static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                     Ti_Pkt *pkt,
+                                     PKTIO_METADATA_T *m,
+                                     int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
@@ -141,9 +144,9 @@ static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO
 
     NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
 
-    netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1);
+    netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1);
 
-    if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
     {
         nwal_mCmdSetCrypPort(pkt,
                              &p->tx_psCmdInfo,
@@ -152,7 +155,7 @@ static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO
                               swInfo0, 
                               swInfo1,
                               0);
-        Debug_printf("pktio_send_L4CkSumAHCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1); 
+        netapi_Log("netapi_pktioSendCryptPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1); 
         pPloadDesc = Pktlib_getDescFromPacket(pkt);
         pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
         Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
@@ -171,7 +174,10 @@ static int pktio_send_CryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO
  * with updates for L4 checksum,AH Crypto and outgoing EMAC port 
  * to NetCP command.
  ********************************************************************/
-static int pktio_sendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                              Ti_Pkt *pkt,
+                                              PKTIO_METADATA_T *m,
+                                              int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
@@ -180,7 +186,7 @@ static int pktio_sendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pk
 
     NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
 
-    if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
     {
         nwal_mCmdSetL4CkSumAHCrypPort(pkt,
                                 &p->tx_psCmdInfo,
@@ -195,7 +201,7 @@ static int pktio_sendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pk
                                 pTxPktInfo->saAhMacSize,
                                 pTxPktInfo->enetPort);
 
-        Debug_printf("pktio_send_L4CkSumAHCryptoPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1); 
+        netapi_Log("netapi_pktioSendL4CkSumAHCryptPort: swinfo0 0x%x, swinfo1: 0x%x\n",swInfo0,swInfo1); 
         pPloadDesc = Pktlib_getDescFromPacket(pkt);
         pPloadDesc = Qmss_osalConvertDescVirtToPhy(pPloadDesc);
         Qmss_queuePushDescSizeRaw(p->tx_psCmdInfo.txQueue,
@@ -214,7 +220,10 @@ static int pktio_sendL4CkSumAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pk
  * with updates for AH Crypto and outgoing EMAC port 
  * to NetCP command.
  ********************************************************************/
-static int pktio_sendAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendAHCryptPort(struct PKTIO_HANDLE_tag * pp,
+                                       Ti_Pkt *pkt,
+                                       PKTIO_METADATA_T *m,
+                                       int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
@@ -223,7 +232,7 @@ static int pktio_sendAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTI
 
     NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
 
-    if (netcp_cfg_get_sa_inflow_info(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
+    if (netapip_netcpCfgGetSaInflowInfo(&netapi_get_global()->nwal_context, tunnel_id, &swInfo0, &swInfo1))
     {
         nwal_mCmdSetAHCrypPort(pkt,
                                 &p->tx_psCmdInfo,
@@ -255,14 +264,17 @@ static int pktio_sendAHCryptPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTI
  * with updates for L4 checksum and outgoing EMAC port 
  * to NetCP command.
  ********************************************************************/
-static int pktio_sendL4CkSumPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendL4CkSumPort(struct PKTIO_HANDLE_tag * pp,
+                                      Ti_Pkt *pkt,
+                                      PKTIO_METADATA_T *m,
+                                      int * err)
 {
 
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
     Cppi_HostDesc*          pPloadDesc;
-    Debug_printf("pktio_send_L4CkSumPort: non-ipsec packet sent with L4 chksum\n");
-    Debug_printf("pktio_send_L4CkSumPort, l4offbytes: %d, l4HdrLen: %d, enetPort %d\n",
+    netapi_Log("netapi_pktioSendL4CkSumPort: non-ipsec packet sent with L4 chksum\n");
+    netapi_Log("netapi_pktioSendL4CkSumPort: l4offbytes: %d, l4HdrLen: %d, enetPort %d\n",
                                 pTxPktInfo->l4OffBytes,
                                 pTxPktInfo->l4HdrLen,
                                 pTxPktInfo->enetPort);
@@ -288,7 +300,10 @@ static int pktio_sendL4CkSumPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTI
  * DESCRIPTION: Send packet via low level NWAL API's
  * with updates for outgoing EMAC port to NetCP command.
  ********************************************************************/
-static int pktio_sendPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendPort(struct PKTIO_HANDLE_tag * pp,
+                                Ti_Pkt *pkt, 
+                                PKTIO_METADATA_T *m, 
+                                int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t *pTxPktInfo = m->u.tx_meta;
@@ -309,7 +324,10 @@ static int pktio_sendPort(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METAD
  ********************************************************************
  * DESCRIPTION: Send packet via IPC queue
  ********************************************************************/
-static int pktio_send_ipc(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendIpc(struct PKTIO_HANDLE_tag * pp,
+                               Ti_Pkt *pkt,
+                               PKTIO_METADATA_T *m,
+                               int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     err=0;
@@ -321,7 +339,10 @@ static int pktio_send_ipc(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METAD
  ********************************************************************
  * DESCRIPTION: Send packet to NETCP via NWAL
  ********************************************************************/
-static int pktio_send_nwal(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendNwal(struct PKTIO_HANDLE_tag * pp,
+                                Ti_Pkt *pkt,
+                                PKTIO_METADATA_T *m,
+                                int * err)
 {
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
     nwalTxPktInfo_t * pPktInfo=m->u.tx_meta;
@@ -339,10 +360,13 @@ static int pktio_send_nwal(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_META
 /********************************************************************
  * FUNCTION PURPOSE: Send packet to SA via NWAL
  ********************************************************************
- * DESCRIPTION: Send packet to NETCP via NWAL for side band data mode channel 
- * via NWAL
+ * DESCRIPTION: Send packet to NETCP via NWAL for side band data mode 
+ * channel via NWAL
  ********************************************************************/
-static int pktio_send_sb(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendSb(struct PKTIO_HANDLE_tag * pp,
+                              Ti_Pkt *pkt, 
+                              PKTIO_METADATA_T *m, 
+                              int * err)
 {
     nwal_RetValue nwalRetVal;
     nwalTxDmPSCmdInfo_t     *dmPSCmdInfo;
@@ -354,7 +378,7 @@ static int pktio_send_sb(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADA
 
     NETCP_CFG_SA_T tunnel_id = (NETCP_CFG_SA_T) m->sa_handle;
 
-    dmPSCmdInfo = netcp_cfg_get_sa_sb_info(&netapi_get_global()->nwal_context, tunnel_id);
+    dmPSCmdInfo = netapip_netcpCfgGetSaSBInfo(&netapi_get_global()->nwal_context, tunnel_id);
     if (dmPSCmdInfo)
     {
         nwalRetVal = nwal_getDmRxQueue(pktio_mGetNwalInstance(p), &rxQ);
@@ -386,7 +410,10 @@ static int pktio_send_sb(struct PKTIO_HANDLE_tag * pp, Ti_Pkt *pkt, PKTIO_METADA
  ********************************************************************
  * DESCRIPTION: Stub function for send, do nothing.
  ********************************************************************/
-static int pktio_send_dummy(struct PKTIO_HANDLE_tag * p, Ti_Pkt *pkt, PKTIO_METADATA_T *m, int * err)
+static int netapi_pktioSendDummy(struct PKTIO_HANDLE_tag * p,
+                                 Ti_Pkt *pkt, 
+                                 PKTIO_METADATA_T *m, 
+                                 int * err)
 {
     *err =  NETAPI_ERR_BAD_INPUT;
     return -1;
@@ -397,7 +424,9 @@ static int pktio_send_dummy(struct PKTIO_HANDLE_tag * p, Ti_Pkt *pkt, PKTIO_META
  ********************************************************************
  * DESCRIPTION: Stub function for send, do nothing.
  ********************************************************************/
-static int pktio_poll_dummy(struct PKTIO_HANDLE_tag * p, PKTIO_POLL_T * p_poll_cfg,  int * err)
+static int netapi_pktioPollDummy(struct PKTIO_HANDLE_tag * p, 
+                                 PKTIO_POLL_T * p_poll_cfg,
+                                 int * err)
 {
     *err= NETAPI_ERR_BAD_INPUT;
     return 0;
@@ -408,7 +437,9 @@ static int pktio_poll_dummy(struct PKTIO_HANDLE_tag * p, PKTIO_POLL_T * p_poll_c
  ********************************************************************
  * DESCRIPTION: Poll IPC queue
  ********************************************************************/
-static int pktio_poll_ipc(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cfg,  int * err)
+static int netapi_pktioPollIpc(struct PKTIO_HANDLE_tag * pp, 
+                               PKTIO_POLL_T * p_poll_cfg,  
+                               int * err)
 {
     Ti_Pkt * pkt_list[PKTIO_MAX_RECV];
     PKTIO_METADATA_T meta_s[PKTIO_MAX_RECV];
@@ -440,7 +471,9 @@ static int pktio_poll_ipc(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cf
  ********************************************************************
  * DESCRIPTION: Poll nwal data queues for pkts from netcp
  ********************************************************************/
-static int pktio_poll_nwal(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cfg,  int * err)
+static int netapi_pktioPollNwal(struct PKTIO_HANDLE_tag * pp, 
+                                PKTIO_POLL_T * p_poll_cfg,  
+                                int * err)
 {
     int r=0;
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
@@ -460,7 +493,9 @@ static int pktio_poll_nwal(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_c
  ********************************************************************
  * DESCRIPTION: Poll nwal sideband queues for pkts from SA
  ********************************************************************/
-static int  pktio_poll_sb(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cfg,  int * err)
+static int  netapi_pktioPollSb(struct PKTIO_HANDLE_tag * pp, 
+                               PKTIO_POLL_T * p_poll_cfg,  
+                               int * err)
 {
     int r=0;
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
@@ -479,7 +514,9 @@ static int  pktio_poll_sb(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cf
  ********************************************************************
  * DESCRIPTION: Poll application provided NETCP RX queue
  ********************************************************************/
-static int pktio_poll_nwal_adj(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cfg,  int * err)
+static int netapi_pktioPollNwalAdj(struct PKTIO_HANDLE_tag * pp, 
+                                   PKTIO_POLL_T * p_poll_cfg,  
+                                   int * err)
 {
     int r=0;
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
@@ -502,7 +539,9 @@ static int pktio_poll_nwal_adj(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_po
  * DESCRIPTION: Poll application defined sideband queues for packets
  *                   from SA
  *************************************************************************/
-static int  pktio_poll_sb_adj(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_poll_cfg,  int * err)
+static int  netapi_pktioPollSbAdj(struct PKTIO_HANDLE_tag * pp, 
+                                  PKTIO_POLL_T * p_poll_cfg,  
+                                  int * err)
 {
     int r=0;
     PKTIO_HANDLE_T *p=(PKTIO_HANDLE_T*) pp;
@@ -522,8 +561,11 @@ static int  pktio_poll_sb_adj(struct PKTIO_HANDLE_tag * pp, PKTIO_POLL_T * p_pol
  ********************************************************************
  * DESCRIPTION:  API creates a NETAPI PKTIO channel 
  ********************************************************************/
-PKTIO_HANDLE_T * pktio_create(NETAPI_T n, char * name,
-                              PKTIO_CB cb, PKTIO_CFG_T * p_cfg, int * err)
+PKTIO_HANDLE_T * netapi_pktioCreate(NETAPI_T n,
+                                    char * name,
+                                    PKTIO_CB cb, 
+                                    PKTIO_CFG_T * p_cfg, 
+                                    int * err)
 {
     int r = 0;
     PKTIO_HANDLE_T *p;
@@ -543,8 +585,8 @@ PKTIO_HANDLE_T * pktio_create(NETAPI_T n, char * name,
     p->back = n;
     p->cb = cb;
     p->max_n = p_cfg->max_n;
-    p->_poll=pktio_poll_dummy;
-    p->_send=pktio_send_dummy;
+    p->_poll=netapi_pktioPollDummy;
+    p->_send=netapi_pktioSendDummy;
     memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
 
     /* create a  general queue (for now). todo: allow qnum to be passed in */
@@ -552,7 +594,7 @@ PKTIO_HANDLE_T * pktio_create(NETAPI_T n, char * name,
                        QMSS_PARAM_NOT_SPECIFIED, &isAllocated);
     if (p->q == (Qmss_QueueHnd) NULL)
     {
-        Debug_printf(">pktio_create:  queueOpen failed\n");
+        netapi_Log("netapi_pktioCreate:  queueOpen failed\n");
         p->inuse=0;
         *err= NETAPI_ERR_QLLD;  ///queue lld error
         return NULL;
@@ -561,20 +603,20 @@ PKTIO_HANDLE_T * pktio_create(NETAPI_T n, char * name,
     if (p_cfg->flags2 & PKTIO_PKT)
     {
        p->use_nwal = PKTIO_4_ADJ_NWAL;
-       p->_poll=pktio_poll_nwal_adj;
-       p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+       p->_poll=netapi_pktioPollNwalAdj;
+       p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
     }
     else if (p_cfg->flags2 & PKTIO_SB)
     {
        p->use_nwal = PKTIO_4_ADJ_SB;
-       p->_poll=pktio_poll_sb_adj;
-       p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+       p->_poll=netapi_pktioPollSbAdj;
+       p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
     }
     else
     {
         p->use_nwal=0;
-        if (p_cfg->flags1& PKTIO_TX) p->_send=pktio_send_ipc;
-        if (p_cfg->flags1& PKTIO_RX) p->_poll=pktio_poll_ipc;
+        if (p_cfg->flags1& PKTIO_TX) p->_send=netapi_pktioSendIpc;
+        if (p_cfg->flags1& PKTIO_RX) p->_poll=netapi_pktioPollIpc;
     }
 
     /* save name */ 
@@ -603,8 +645,11 @@ PKTIO_HANDLE_T * pktio_create(NETAPI_T n, char * name,
  ********************************************************************
  * DESCRIPTION:  API opens an existing  NETAPI PKTIO channel
  ********************************************************************/
-PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
-                            PKTIO_CB cb,  PKTIO_CFG_T * p_cfg, int * err)
+PKTIO_HANDLE_T * netapi_pktioOpen(NETAPI_T  n, 
+                                  char *name,
+                                  PKTIO_CB cb,  
+                                  PKTIO_CFG_T * p_cfg, 
+                                  int * err)
 {
     int r=0;
     PKTIO_HANDLE_T *p, *p2;
@@ -625,8 +670,8 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
     p->back = n;
     p->cb = cb;
     p->max_n = p_cfg->max_n;
-    p->_poll=pktio_poll_dummy;
-    p->_send=pktio_send_dummy;
+    p->_poll=netapi_pktioPollDummy;
+    p->_send=netapi_pktioSendDummy;
     memcpy((char *)&p->cfg, (char*) p_cfg, sizeof(PKTIO_CFG_T));
 
     /* special handling of NETCP_RX, NETCP_TX */
@@ -635,16 +680,16 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
        /* these have already been opened internally, so don't search in global list */
         p->use_nwal = PKTIO_DEF_NWAL;
         p->q = 0;  
-        p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+        p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
         if (!strcmp(name,NETCP_RX))
         {
-            p->_poll=pktio_poll_nwal; 
+            p->_poll=netapi_pktioPollNwal; 
             p->poll_flags= nwal_POLL_DEFAULT_GLOB_PKT_Q|
                                     nwal_POLL_DEFAULT_PER_PROC_PKT_Q;
         }
         if (!strcmp(name,NETCP_TX))
         {
-            p->_send=pktio_send_nwal;
+            p->_send=netapi_pktioSendNwal;
         }
     }
     else if( (!strcmp(name, NETCP_SB_RX)) || (!strcmp(name,NETCP_SB_TX)) )
@@ -652,9 +697,9 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
        /* these have already been opened internally, so don't search in global list */
         p->use_nwal =  PKTIO_DEF_SB;
         p->q = 0;
-        p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
-        if (!strcmp(name,NETCP_SB_RX)) p->_poll=pktio_poll_sb;
-        if (!strcmp(name,NETCP_SB_TX)) p->_send=pktio_send_sb;
+        p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
+        if (!strcmp(name,NETCP_SB_RX)) p->_poll=netapi_pktioPollSb;
+        if (!strcmp(name,NETCP_SB_TX)) p->_send=netapi_pktioSendSb;
     }
     else
     {
@@ -665,7 +710,7 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
         hplib_mSpinLockUnlock(&pktio_lock);
         if (!p_qnum ) 
         {
-            Debug_printf(">pktio_open: can't find %s\n",name);
+            netapi_Log("netapi_pktioOpen: can't find %s\n",name);
             p->inuse=0;
             *err= NETAPI_ERR_NOTFOUND;  ///queue lld error
             return NULL;
@@ -676,31 +721,31 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
                            p_qnum->qNum , &isAllocated);
         if (p->q == (Qmss_QueueHnd) NULL)
         {
-            Debug_printf(">pktio_create:  queueOpen failed\n");
+            netapi_Log("netapi_pktioCreate:  queueOpen failed\n");
             p->inuse=0;
             *err= NETAPI_ERR_QLLD;  ///queue lld error
             return NULL;
         }
         p->qInfo = Qmss_getQueueNumber(p->q);
-        Debug_printf("pktio_open: queueMgr %d,  queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
+        netapi_Log("netapi_pktioOpen: queueMgr %d,  queueNum; %d\n", p->qInfo.qMgr, p->qInfo.qNum);
         if (p_cfg->flags2 & PKTIO_PKT)
         {
            p->use_nwal = PKTIO_4_ADJ_NWAL;  //additonal RX q for nwal
-           p->_poll = pktio_poll_nwal_adj;
-           p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n); 
-           Debug_printf("pktio_open: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
+           p->_poll = netapi_pktioPollNwalAdj;
+           p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n); 
+           netapi_Log("netapi_pktioOpen: nwalInstanceHandle 0x%x\n", p->nwalInstanceHandle);
         } 
         else if (p_cfg->flags2 & PKTIO_SB)
         {
            p->use_nwal = PKTIO_4_ADJ_SB;  //additional RX q for sideband with NWAL
-           p->_poll = pktio_poll_sb_adj;
-           p->nwalInstanceHandle = netapi_return_nwal_instance_handle(n);
+           p->_poll = netapi_pktioPollSbAdj;
+           p->nwalInstanceHandle = netapip_returnNwalInstanceHandle(n);
         } 
         else 
         {
            p->use_nwal=0; //not handled by nwal
-            if (p_cfg->flags1& PKTIO_TX) p->_send=pktio_send_ipc;
-            if (p_cfg->flags1& PKTIO_RX) p->_poll=pktio_poll_ipc;
+            if (p_cfg->flags1& PKTIO_TX) p->_send=netapi_pktioSendIpc;
+            if (p_cfg->flags1& PKTIO_RX) p->_poll=netapi_pktioPollIpc;
         }
     }
 
@@ -709,7 +754,7 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
            strlen(name)<PKTIO_MAX_NAME ?
                    strlen(name):PKTIO_MAX_NAME);
 
-        Debug_printf("pktio_open: returning with sucess for name %s\n", p->name);
+        netapi_Log("netapi_pktioOpen: returning with sucess for name %s\n", p->name);
     return p;
 }
 
@@ -718,11 +763,11 @@ PKTIO_HANDLE_T * pktio_open(NETAPI_T  n, char *name,
  ********************************************************************
  * DESCRIPTION:  API controls an existing NETAPI PKTIO channel
  ********************************************************************/
-void pktio_control(PKTIO_HANDLE_T * p,
-                   PKTIO_CB cb,
-                   PKTIO_CFG_T * p_cfg,
-                   PKTIO_CONTROL_T * p_control,
-                   int *err)
+void netapi_pktioControl(PKTIO_HANDLE_T * p,
+                         PKTIO_CB cb,
+                         PKTIO_CFG_T * p_cfg,
+                         PKTIO_CONTROL_T * p_control,
+                         int *err)
 {
     nwal_RetValue       nwalRetVal;
     if (!p)
@@ -745,7 +790,7 @@ void pktio_control(PKTIO_HANDLE_T * p,
                 p->poll_flags=p_control->poll_flags;
                 break;
             case(PKTIO_CLEAR):
-                netapi_zapQ(p->q);
+                netapip_zapQ(p->q);
                 break;
             case (PKTIO_UPDATE_FAST_PATH):
                 if (p_cfg)
@@ -758,22 +803,22 @@ void pktio_control(PKTIO_HANDLE_T * p,
                         switch (p_cfg->fast_path_cfg.fp_send_option)
                         {
                             case (PKTIO_FP_ESP_L4CKSUM_PORT):
-                                p->_send = pktio_sendL4CkSumCryptPort;
+                                p->_send = netapi_pktioSendL4CkSumCryptPort;
                                 break;
                             case (PKTIO_FP_AH_L4CKSUM_PORT):
-                                p->_send = pktio_sendL4CkSumAHCryptPort;
+                                p->_send = netapi_pktioSendL4CkSumAHCryptPort;
                                 break;
                             case (PKTIO_FP_ESP_PORT):
-                                p->_send = pktio_send_CryptPort;
+                                p->_send = netapi_pktioSendCryptPort;
                                 break;
                             case (PKTIO_FP_AH_PORT):
-                                p->_send = pktio_sendAHCryptPort;
+                                p->_send = netapi_pktioSendAHCryptPort;
                                 break;
                             case (PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT):
-                                p->_send = pktio_sendPort;
+                                p->_send = netapi_pktioSendPort;
                                 break;
                             case (PKTIO_FP_L4CKSUM_PORT):
-                                p->_send = pktio_sendL4CkSumPort;
+                                p->_send = netapi_pktioSendL4CkSumPort;
                                 break;
                             default:
                                 break;
@@ -801,7 +846,7 @@ void pktio_control(PKTIO_HANDLE_T * p,
                 break;
             case(PKTIO_DIVERT):
             default:
-                Debug_printf(">pktio_control: pktio_control op %d not implemented\n",p_control->op);
+                netapi_Log("netapi_pktioControl: pktio_control op %d not implemented\n",p_control->op);
                 *err= NETAPI_ERR_NOT_IMPLEMENTED;
                 break;
         }
@@ -815,7 +860,8 @@ void pktio_control(PKTIO_HANDLE_T * p,
  ********************************************************************
  * DESCRIPTION:  API closes a NETAPI PKTIO channel
  ********************************************************************/
-void pktio_close(PKTIO_HANDLE_T * p, int * err)
+void netapi_pktioClose(PKTIO_HANDLE_T * p, 
+                       int * err)
 {
     if(!p) { *err=1; return;}
     *err=0;
@@ -831,7 +877,8 @@ void pktio_close(PKTIO_HANDLE_T * p, int * err)
  ********************************************************************
  * DESCRIPTION:  API deletes a NETAPI PKTIO channel
  ********************************************************************/
-void pktio_delete(PKTIO_HANDLE_T * p, int * err)
+void netapi_pktioDelete(PKTIO_HANDLE_T * p, 
+                        int * err)
 {
     if(!p) { *err=1; return;}
     *err=0;
@@ -841,7 +888,7 @@ void pktio_delete(PKTIO_HANDLE_T * p, int * err)
     hplib_mSpinLockUnlock(&pktio_lock);
         if((p->use_nwal != PKTIO_DEF_NWAL) && (p->use_nwal != PKTIO_DEF_SB)) 
     {
-                netapi_zapQ(p->q);   //since we are deleting, zap the queue 
+                netapip_zapQ(p->q);   //since we are deleting, zap the queue 
             Qmss_queueClose(p->q);
     }
     p->q=-1;
@@ -855,7 +902,11 @@ void pktio_delete(PKTIO_HANDLE_T * p, int * err)
  ********************************************************************
  * DESCRIPTION:  API sends multiple packets to a NETAPI PKTIO channel
  ********************************************************************/
-int pktio_sendMulti(PKTIO_HANDLE_T * p, Ti_Pkt * pkt[], PKTIO_METADATA_T * m[], int np, int* err)
+int netapi_pktioSendMulti(PKTIO_HANDLE_T * p, 
+                          Ti_Pkt * pkt[], 
+                          PKTIO_METADATA_T * m[], 
+                          int np, 
+                          int* err)
 {
     int r=0;
     for(r=0;r<np;r++)
@@ -872,7 +923,9 @@ int pktio_sendMulti(PKTIO_HANDLE_T * p, Ti_Pkt * pkt[], PKTIO_METADATA_T * m[],
  * DESCRIPTION:  API polls all NETAPI PKTIO channels associated with NETAPI_T
  * instance for received packets
  ********************************************************************/
-int pktio_pollAll(NETAPI_T  handle, PKTIO_POLL_T * p_poll_cfg, int *err)
+int netapi_pktioPollAll(NETAPI_T  handle, 
+                        PKTIO_POLL_T * p_poll_cfg, 
+                        int *err)
 {
     int i=0;
     int r=0;
@@ -899,11 +952,11 @@ int pktio_pollAll(NETAPI_T  handle, PKTIO_POLL_T * p_poll_cfg, int *err)
  * DESCRIPTION:  Callback that gets registered with NWAL for packet reception
  * appCookie is the pktio handle 
  **********************************************************************/
-void netapi_NWALRxPktCallback     (uint32_t            appCookie,
-                                uint16_t             numPkts,
-                                nwalRxPktInfo_t*    pPktInfo,
-                                uint64_t            timestamp,
-                                nwal_Bool_t*        pFreePkt)
+void netapi_NWALRxPktCallback(uint32_t            appCookie,
+                              uint16_t             numPkts,
+                              nwalRxPktInfo_t*    pPktInfo,
+                              uint64_t            timestamp,
+                              nwal_Bool_t*        pFreePkt)
 {
     PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
     int r=0;
@@ -930,10 +983,10 @@ void netapi_NWALRxPktCallback     (uint32_t            appCookie,
  * DESCRIPTION:  Callback that gets registered with NWAL for crypto reception,
  * appCookie is the pktio handle 
  **********************************************************************/
-void netapi_NWALSBPktCallback     (uint32_t            appCookie,
-                                uint16_t             numPkts,
-                                nwalDmRxPayloadInfo_t*  pDmRxPktInfo,
-                                nwal_Bool_t*        pFreePkt)
+void netapi_NWALSBPktCallback(uint32_t            appCookie,
+                              uint16_t             numPkts,
+                              nwalDmRxPayloadInfo_t*  pDmRxPktInfo,
+                              nwal_Bool_t*        pFreePkt)
 {
     PKTIO_HANDLE_T * p = (PKTIO_HANDLE_T *) appCookie;
     int r=0;
index f899c7d88075a3e870f1b08a7d4e2bb087231105..70aa08421ba2e0c802029845594c6bb48aae7975 100755 (executable)
@@ -247,7 +247,7 @@ NETCP_CFG_CLASSIFIER_T class_2_cfg=
    }
 };
 
-PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
+netapi_pktioControl_T zap_channel_control={PKTIO_CLEAR, NULL};
 
 /* security objects. (for loopback mode) */
 netTestSA_t sa_info[SA_CREATE_LOOP_COUNT];
@@ -1193,10 +1193,10 @@ void  build_sa_db(int i)
          trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
     }
     else
-        Debug_printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+        netapi_Log("build_sa_db(): invalid encryption/authentication combination selected\n");
 
-    //Debug_printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
-    Debug_printf("build_sa_db spi 0x%x\n", spi);
+    //netapi_Log("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
+    netapi_Log("build_sa_db spi 0x%x\n", spi);
     
 }
 
@@ -1217,7 +1217,7 @@ int main(int argc, char **argv)
 
     
     err= getrlimit(RLIMIT_STACK,&rl);
-    if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
+    if (!err) netapi_Log(" stack limit = %d\n",rl.rlim_cur); else netapi_Log("getrlimit failed\n");
 
 
     memset(&sa_info, 0, sizeof(sa_info));
@@ -1229,7 +1229,7 @@ int main(int argc, char **argv)
     ourHeap = Pktlib_findHeapByName("netapi");
     if (!ourHeap)
     {
-        Debug_printf("Pktlib_findHeapByName()  fail\n");
+        netapi_Log("Pktlib_findHeapByName()  fail\n");
         exit(1);
     }
 
@@ -1240,7 +1240,7 @@ int main(int argc, char **argv)
     pPktifTable = netapi_getPktlibIfTable();
     /* Populate the heap configuration */
     heapCfg.name                = "netapi-small";
-    heapCfg.memRegion           = NETAPI_GLOBAL_REGION;
+    heapCfg.memRegion           = TUNE_NETAPI_QM_GLOBAL_REGION;
     heapCfg.sharedHeap          = 1;
     heapCfg.useStarvationQueue  = 0;
     heapCfg.dataBufferSize      = 512;
@@ -1260,50 +1260,50 @@ int main(int argc, char **argv)
     netapi_registerHeap(netapi_handle, specialLarge);
 
     /* create a pktio channel */
-    our_chan=pktio_create(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
+    our_chan=netapi_pktioCreate(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
     if (!our_chan)
     {
-        Debug_printf("pktio create failed err=%d\n",err);
+        netapi_Log("pktio create failed err=%d\n",err);
         exit(1);
     }
 
     /* open netcp default tx, rx queues */
-    netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_esp)
     {
-        Debug_printf("pktio open TX failed err=%d\n",err);
+        netapi_Log("pktio open TX failed err=%d\n",err);
         exit(1);
     }
-    netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+    netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 
     if (!netcp_rx_chan)
     {
-        Debug_printf("pktio open RX failed err=%d\n",err);
+        netapi_Log("pktio open RX failed err=%d\n",err);
         exit(1);
     }
 
     /* create a pktio channel for specially classified pkts */
-    netcp_rx_chan2= pktio_create(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2,  &err);
-    if (!netcp_rx_chan2) {Debug_printf("pktio create RX2 failed err=%d\n",err); exit(1);}
+    netcp_rx_chan2= netapi_pktioCreate(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2,  &err);
+    if (!netcp_rx_chan2) {netapi_Log("pktio create RX2 failed err=%d\n",err); exit(1);}
 
     /* open netcp default tx, rx queues for sideband crypto */
-    netcp_sb_tx_chan= pktio_open(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+    netcp_sb_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
     if (!netcp_sb_tx_chan)
     {
-        Debug_printf("pktio open SB TX failed err=%d\n",err);
+        netapi_Log("pktio open SB TX failed err=%d\n",err);
         exit(1);
     }
-    netcp_sb_rx_chan= pktio_open(netapi_handle, NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
+    netcp_sb_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
     if (!netcp_sb_rx_chan)
     {
-        Debug_printf("pktio open SB RX failed err=%d\n",err);
+        netapi_Log("pktio open SB RX failed err=%d\n",err);
         exit(1);
     }
 
-    Debug_printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+    netapi_Log("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
     /* create scheduler instance */
     our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
-    if (!our_sched) {Debug_printf("sched create failed\n"); exit(1);}
+    if (!our_sched) {netapi_Log("sched create failed\n"); exit(1);}
 
     //#define PROMISCUOUS
 #define ETH0 0
@@ -1312,7 +1312,7 @@ int main(int argc, char **argv)
 
 #if 0
     /* add mac intefaces */
-    netcp_cfgCreateMacInterface(
+    netapi_netcpCfgCreateMacInterface(
                       netapi_handle,
                       &config.mac0[0],
                       ETH0,0,
@@ -1320,10 +1320,10 @@ int main(int argc, char **argv)
                       (NETCP_CFG_VLAN_T ) NULL ,  //future
                       1, 
                       &err);
-    if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); } 
+    if (err) {netapi_Log("addmac0 failed %d\n",err); exit(1); } 
 
     //attach an IP to this interface
-    ip_rule0[0]=netcp_cfgAddIp(
+    ip_rule0[0]=netapi_netcpCfgAddIp(
                       netapi_handle,
                       ETH0,
                       nwal_IPV4,
@@ -1332,10 +1332,10 @@ int main(int argc, char **argv)
                       (NETCP_CFG_ROUTE_HANDLE_T) NULL,
                       &err
                       );
-    if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); } 
+    if (err) {netapi_Log("addip0 failed %d\n",err); exit(1); } 
 
     //create a 2nd mac instance
-    netcp_cfgCreateMacInterface(
+    netapi_netcpCfgCreateMacInterface(
                       netapi_handle,
                       &config.mac1[0],
                       ETH1,1,
@@ -1343,10 +1343,10 @@ int main(int argc, char **argv)
                       (NETCP_CFG_VLAN_T ) NULL ,  //future
                       1,
                       &err);
-    if (err) {Debug_printf("addmac1 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addmac1 failed %d\n",err); exit(1); }
 
     //attach an IP to this interface
-    ip_rule1[0]=netcp_cfgAddIp(
+    ip_rule1[0]=netapi_netcpCfgAddIp(
                       netapi_handle,
                       ETH1,
                       nwal_IPV4,
@@ -1355,27 +1355,27 @@ int main(int argc, char **argv)
                       (NETCP_CFG_ROUTE_HANDLE_T) NULL,
                       &err
                       );
-    if (err) {Debug_printf("addip1 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addip1 failed %d\n",err); exit(1); }
 #endif
 
 
 #if todo
     //attach 2 classifiers to iface 0, ip0
     class_0_cfg.u.c_l4.ip = ip_rule0[0];
-    class_0 =  netcp_cfgAddClass(netapi_handle,
+    class_0 =  netapi_netcpCfgAddClass(netapi_handle,
                                  &class_0_cfg,
                                  NULL,
                                  NETCP_CFG_ACTION_TO_SW,
                                 &err);
-    if (err) {Debug_printf("addclass0 failed %d\n",err); exit(1);}
+    if (err) {netapi_Log("addclass0 failed %d\n",err); exit(1);}
 
     class_1_cfg.u.c_l4.ip = ip_rule0[0];
-    class_1 =  netcp_cfgAddClass(netapi_handle,
+    class_1 =  netapi_netcpCfgAddClass(netapi_handle,
                                  &class_1_cfg,
                                  NULL,
                                  NETCP_CFG_ACTION_TO_SW,
                                  &err);
-    if (err) {Debug_printf("addclass1 failed %d\n",err); exit(1);}
+    if (err) {netapi_Log("addclass1 failed %d\n",err); exit(1);}
 
 
     //3rd classifier has a different IP and route
@@ -1395,7 +1395,7 @@ int main(int argc, char **argv)
 
 //security stuff 
     p_trie_sa = trie_new();
-   if (!p_trie_sa) {Debug_printf("trie alloc for SA  failed\n"); exit(1);}
+   if (!p_trie_sa) {netapi_Log("trie alloc for SA  failed\n"); exit(1);}
 
     count = 0;
 
@@ -1403,7 +1403,7 @@ int main(int argc, char **argv)
    for (i = 0; i < MAC_CREATE_LOOP_COUNT ;i++)
     {
     /* add mac intefaces */
-    netcp_cfgCreateMacInterface(
+    netapi_netcpCfgCreateMacInterface(
                       netapi_handle,
                       &config.mac0[0],
                       i,0,
@@ -1411,10 +1411,10 @@ int main(int argc, char **argv)
                       (NETCP_CFG_VLAN_T ) NULL ,  //future
                       1, 
                       &err);
-    if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addmac0 failed %d\n",err); exit(1); }
     else
         {
-            Debug_printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+            netapi_Log("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
             config.mac0[3]++;
         }
     }
@@ -1422,7 +1422,7 @@ int main(int argc, char **argv)
    for (i = 0; i < IP_CREATE_LOOP_COUNT ;i++)
     {
     //attach an IP to this interface
-    ip_rule0[i]=netcp_cfgAddIp(
+    ip_rule0[i]=netapi_netcpCfgAddIp(
                       netapi_handle,
                       0,
                       nwal_IPV4,
@@ -1431,10 +1431,10 @@ int main(int argc, char **argv)
                       (NETCP_CFG_ROUTE_HANDLE_T) NULL,
                       &err
                       );
-    if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addip0 failed %d\n",err); exit(1); }
         else
         {
-            Debug_printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+            netapi_Log("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
             config.ip0.ipv4[3]++;
         }
 
@@ -1454,7 +1454,7 @@ int main(int argc, char **argv)
 
         build_sa_db(i);
         count++;
-        Debug_printf("main: calling netapi_secAddSA for rx, count = %d\n", count);
+        netapi_Log("main: calling netapi_secAddSA for rx, count = %d\n", count);
         sa_info[i].rx_tunnel = netapi_secAddSA(
             netapi_handle,
             config.ipsec_if_no, //iface #0 
@@ -1465,8 +1465,8 @@ int main(int argc, char **argv)
             &(sa_info[i].rx_data_mode_handle),
             &(sa_info[i].rx_inflow_mode_handle),
             &err);
-        //if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
-         if (err) {Debug_printf("addRxSa failed %d\n",err);}
+        //if (err) {netapi_Log("addRxSa failed %d\n",err); exit(1);}
+         if (err) {netapi_Log("addRxSa failed %d\n",err);}
 
 
     }
@@ -1479,7 +1479,7 @@ int main(int argc, char **argv)
     memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
     memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
          count++;
-        Debug_printf("main: calling netapi_secAddSA for tx, count = %d\n", count);
+        netapi_Log("main: calling netapi_secAddSA for tx, count = %d\n", count);
     sa_info[i].tx_tunnel = netapi_secAddSA( netapi_handle,
                  0, //iface #0 
                 &tx_sa[0],
@@ -1489,7 +1489,7 @@ int main(int argc, char **argv)
                 &(sa_info[i].tx_data_mode_handle),
                 &(sa_info[i].tx_inflow_mode_handle),
                 &err);
-    if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
+    if (err) {netapi_Log("addTxSa failed %d\n",err); exit(1);}
     }
 
 #endif
@@ -1499,9 +1499,9 @@ int main(int argc, char **argv)
      ************************************************/
 
     //delete Classifiers
-    netcp_cfgDelClass(netapi_handle, class_0, &err); 
-    netcp_cfgDelClass(netapi_handle, class_1, &err); 
-    //netcp_cfgDelClass(netapi_handle, class_2, &err); 
+    netapi_netcpCfgDelClass(netapi_handle, class_0, &err); 
+    netapi_netcpCfgDelClass(netapi_handle, class_1, &err); 
+    //netapi_netcpCfgDelClass(netapi_handle, class_2, &err); 
 
         count = 0;
     //delete policy
@@ -1512,10 +1512,10 @@ int main(int argc, char **argv)
                     netapi_secDelRxPolicy(netapi_handle, rx_policy[i], &err);
                 count ++;
                 //delete tunnels
-                 Debug_printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+                 netapi_Log("main: calling netapi_secDelSA for rx, count = %d\n", count);
                 netapi_secDelSA(netapi_handle, 0, sa_info[i].rx_tunnel, &err);
                 //sleep(1);
-                 //Debug_printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+                 //netapi_Log("main: calling netapi_secDelSA for tx, count = %d\n", count);
                 netapi_secDelSA(netapi_handle, 0, sa_info[i].tx_tunnel, &err);
         }
 #endif
@@ -1524,33 +1524,33 @@ int main(int argc, char **argv)
     //delete IPs and MAC Interfacess
     for (i = 0; i < IP_CREATE_LOOP_COUNT;i++)
     {
-         Debug_printf("calling netcp_cfgDelIp and  for index %d\n", i);
-        netcp_cfgDelIp(netapi_handle, i, 0, NULL, NULL, ip_rule0[i], &err);
-        netcp_cfgDelMac(netapi_handle,i,&err);
+         netapi_Log("calling netapi_netcpCfgDelIp and  for index %d\n", i);
+        netapi_netcpCfgDelIp(netapi_handle, i, 0, NULL, NULL, ip_rule0[i], &err);
+        netapi_netcpCfgDelMac(netapi_handle,i,&err);
     }
     for (i = 0; i < MAC_CREATE_LOOP_COUNT;i++)
     {
-         Debug_printf("calling  and netcp_cfgDelMac for index %d\n", i);
-         netcp_cfgDelMac(netapi_handle,i,&err);
+         netapi_Log("calling  and netapi_netcpCfgDelMac for index %d\n", i);
+         netapi_netcpCfgDelMac(netapi_handle,i,&err);
     }
 #endif
     //close pktio channels we opened
-    Debug_printf("main: calling pktio_close for netcp_tx_chan_esp\n");
-    pktio_close(netcp_tx_chan_esp ,&err);
-    Debug_printf("main: calling pktio_close for netcp_rx_chan\n");
-    pktio_close(netcp_rx_chan ,&err);
-    Debug_printf("main: calling pktio_close for netcp_sb_tx_chan\n");
-    pktio_close(netcp_sb_tx_chan ,&err);
-    Debug_printf("main: calling pktio_close for netcp_sb_rx_chan\n");
-    pktio_close(netcp_sb_rx_chan ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_tx_chan_esp\n");
+    netapi_pktioClose(netcp_tx_chan_esp ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_rx_chan\n");
+    netapi_pktioClose(netcp_rx_chan ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_sb_tx_chan\n");
+    netapi_pktioClose(netcp_sb_tx_chan ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_sb_rx_chan\n");
+    netapi_pktioClose(netcp_sb_rx_chan ,&err);
 
     //clear pktio channel we created
-    pktio_control(our_chan, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
-    pktio_control(netcp_rx_chan2, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
+    netapi_pktioControl(our_chan, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
+    netapi_pktioControl(netcp_rx_chan2, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
 
     //delete pktio channels we created
-    pktio_delete(our_chan, &err);
-    pktio_delete(netcp_rx_chan2,&err);
+    netapi_pktioDelete(our_chan, &err);
+    netapi_pktioDelete(netcp_rx_chan2,&err);
     netapi_shutdown(netapi_handle);
 
     }
index 11d63884554ed57baf6a0b56d213b462451a7797..3f121e1c83f234f0d2ac07c47acaea81fa5d1d32 100755 (executable)
@@ -176,8 +176,8 @@ void mysig(int x)
 {
   QUIT=1;
   scnt+=1;
-  Debug_printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
-  if (scnt > 10) {Debug_printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
+  netapi_Log(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
+  if (scnt > 10) {netapi_Log(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");exit(1);}
 
 }
 
@@ -266,7 +266,7 @@ NETCP_CFG_CLASSIFIER_T class_2_cfg=
    }
 };
 
-PKTIO_CONTROL_T zap_channel_control={PKTIO_CLEAR, NULL};
+netapi_pktioControl_T zap_channel_control={PKTIO_CLEAR, NULL};
 
 /* security objects. (for loopback mode) */
 netTestSA_t sa_info[SA_CREATE_LOOP_COUNT];
@@ -920,7 +920,7 @@ void  build_sa_db(int i)
     {
         
         tx_sa[0].spi = rx_sa[0].spi = hplib_mAtomic32AddReturn(&spi,1);
-        Debug_printf("coreid: %d, build_sa_db: spi %d\n", coreid, spi);
+        netapi_Log("coreid: %d, build_sa_db: spi %d\n", coreid, spi);
         /* static configuration, will not change */
         sa_info[i].tx_payload_info.aadSize = 0;
         sa_info[i].tx_payload_info.pAad = NULL;
@@ -1219,7 +1219,7 @@ void  build_sa_db(int i)
          trie_insert(p_trie_sa,(char *)&tmp_spi,4, (void *) &sa_info[i]); //asociate with tx sa SPI
     }
     else
-        Debug_printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+        netapi_Log("build_sa_db(): invalid encryption/authentication combination selected\n");
 
 }
 
@@ -1239,7 +1239,7 @@ void slow_path_thread(int coreid)
 
     
 
-    Debug_printf("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+    netapi_Log("slow_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
 
     CPU_ZERO( &cpu_set);
 #ifdef CORTEX_A15
@@ -1255,21 +1255,21 @@ void slow_path_thread(int coreid)
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
 
    /* open netcp default tx, rx queues */
-    tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    tx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     
     
 #ifdef EXPERIMENTAL
-    rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
 #else
-    rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 #endif
     
 #ifndef EXPERIMENTAL
     /* create a pktio channel for specially classified pkts */
     /* open netcp default tx, rx queues for sideband crypto */
-     sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+     sb_tx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
     
-    sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
+    sb_rx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
 #endif
 
 
@@ -1282,7 +1282,7 @@ void slow_path_thread(int coreid)
     scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
     if (!scheduler[coreid]) 
     {
-        Debug_printf("sched create failed for core%d\n",coreid); 
+        netapi_Log("sched create failed for core%d\n",coreid); 
         exit(1);
     }
       scheduler[coreid]->config.yield = FALSE;
@@ -1296,7 +1296,7 @@ void slow_path_thread(int coreid)
    for (i = 0; i < 30 ;i++)
     {
     /* add mac intefaces */
-    netcp_cfgCreateMacInterface(
+    netapi_netcpCfgCreateMacInterface(
                       worker_nh[coreid],
                       &config.mac0[0],
                       i,0,
@@ -1304,10 +1304,10 @@ void slow_path_thread(int coreid)
                       (NETCP_CFG_VLAN_T ) NULL ,  //future
                       1, 
                       &err);
-    if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addmac0 failed %d\n",err); exit(1); }
     else
         {
-            Debug_printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+            netapi_Log("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
             config.mac0[3]++;
         }
     }
@@ -1315,7 +1315,7 @@ void slow_path_thread(int coreid)
    for (i = 0; i < 30 ;i++)
     {
     //attach an IP to this interface
-    ip_rule0[i]=netcp_cfgAddIp(
+    ip_rule0[i]=netapi_netcpCfgAddIp(
                       worker_nh[coreid],
                       0,
                       nwal_IPV4,
@@ -1324,10 +1324,10 @@ void slow_path_thread(int coreid)
                       (NETCP_CFG_ROUTE_HANDLE_T) NULL,
                       &err
                       );
-    if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addip0 failed %d\n",err); exit(1); }
         else
         {
-            Debug_printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+            netapi_Log("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
             config.ip0.ipv4[3]++;
         }
 
@@ -1336,14 +1336,14 @@ sleep(1);
     //delete IPs and MAC Interfacess
     for (i = 0; i < 30;i++)
     {
-         Debug_printf("calling netcp_cfgDelIp and  for index %d\n", i);
-        netcp_cfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
-        netcp_cfgDelMac(worker_nh[coreid],i,&err);
+         netapi_Log("calling netapi_netcpCfgDelIp and  for index %d\n", i);
+        netapi_netcpCfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
+        netapi_netcpCfgDelMac(worker_nh[coreid],i,&err);
     }
     for (i = 0; i < 30;i++)
     {
-         Debug_printf("calling  and netcp_cfgDelMac for index %d\n", i);
-         netcp_cfgDelMac(worker_nh[coreid],i,&err);
+         netapi_Log("calling  and netapi_netcpCfgDelMac for index %d\n", i);
+         netapi_netcpCfgDelMac(worker_nh[coreid],i,&err);
     }
 #endif
 
@@ -1357,7 +1357,7 @@ sleep(1);
 
         build_sa_db(i);
         count++;
-        //Debug_printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid,  count);
+        //netapi_Log("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid,  count);
         sa_info[i].rx_tunnel = netapi_secAddSA(
             worker_nh[coreid],
             config.ipsec_if_no, //iface #0 
@@ -1368,8 +1368,8 @@ sleep(1);
             &(sa_info[i].rx_data_mode_handle),
             &(sa_info[i].rx_inflow_mode_handle),
             &err);
-        //if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
-         if (err) {Debug_printf("addRxSa failed %d\n",err);}
+        //if (err) {netapi_Log("addRxSa failed %d\n",err); exit(1);}
+         if (err) {netapi_Log("addRxSa failed %d\n",err);}
           sched_yield();
 
 
@@ -1384,7 +1384,7 @@ sleep(1);
     memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
     memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
          count++;
-        //Debug_printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid,  count);
+        //netapi_Log("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid,  count);
     sa_info[i].tx_tunnel = netapi_secAddSA( worker_nh[coreid],
                  0, //iface #0 
                 &tx_sa[0],
@@ -1394,7 +1394,7 @@ sleep(1);
                 &(sa_info[i].tx_data_mode_handle),
                 &(sa_info[i].tx_inflow_mode_handle),
                 &err);
-    if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
+    if (err) {netapi_Log("addTxSa failed %d\n",err); exit(1);}
      sched_yield();
     }
 sleep(1);
@@ -1406,10 +1406,10 @@ count = 0;
                     netapi_secDelRxPolicy(worker_nh[coreid], rx_policy[i], &err);
                 count ++;
                 //delete tunnels
-                 Debug_printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+                 netapi_Log("main: calling netapi_secDelSA for rx, count = %d\n", count);
                 netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].rx_tunnel, &err);
                 //sleep(1);
-                 //Debug_printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+                 //netapi_Log("main: calling netapi_secDelSA for tx, count = %d\n", count);
                 netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].tx_tunnel, &err);
         }
 #endif
@@ -1418,11 +1418,11 @@ count = 0;
             
     netapi_schedRun(scheduler[coreid], &err);
             
-    Debug_printf(">net_test: core %d worker thread done\n",coreid);
-    pktio_close(tx_chan, &err);
-    pktio_close(rx_chan, &err);
-    pktio_close(sb_tx_chan, &err);
-    pktio_close(sb_tx_chan, &err);
+    netapi_Log(">net_test: core %d worker thread done\n",coreid);
+    netapi_pktioClose(tx_chan, &err);
+    netapi_pktioClose(rx_chan, &err);
+    netapi_pktioClose(sb_tx_chan, &err);
+    netapi_pktioClose(sb_tx_chan, &err);
     netapi_shutdown(worker_nh[coreid]);
 }
 
@@ -1435,7 +1435,7 @@ void fast_path_thread(int coreid)
     PKTIO_HANDLE_T *sb_tx_chan;
     PKTIO_HANDLE_T *sb_rx_chan;
 
-    Debug_printf("fast_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
+    netapi_Log("fast_path_thread, mypid: %d, core_id %d\n", gettid(), coreid);
 #ifdef CORTEX_A15
     CPU_SET( coreid, &cpu_set);
         hplib_utilSetupCore(coreid, &cpu_set);
@@ -1449,21 +1449,21 @@ void fast_path_thread(int coreid)
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
 
    /* open netcp default tx, rx queues */
-    tx_chan = pktio_open(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    tx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     
     
 #ifdef EXPERIMENTAL
-    rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
 #else
-    rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 #endif
     
 #ifndef EXPERIMENTAL
     /* create a pktio channel for specially classified pkts */
     /* open netcp default tx, rx queues for sideband crypto */
-     sb_tx_chan = pktio_open(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+     sb_tx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
     
-    sb_rx_chan = pktio_open(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
+    sb_rx_chan = netapi_pktioOpen(worker_nh[coreid], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
 #endif
 
     netapi_setCookie(worker_nh[coreid],coreid);
@@ -1471,7 +1471,7 @@ void fast_path_thread(int coreid)
     scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
     if (!scheduler[coreid]) 
         {
-        Debug_printf("sched create failed for core%d\n",coreid); 
+        netapi_Log("sched create failed for core%d\n",coreid); 
         exit(1);
     }
 
@@ -1486,7 +1486,7 @@ void fast_path_thread(int coreid)
    for (i = 30; i < MAC_CREATE_LOOP_COUNT ;i++)
     {
     /* add mac intefaces */
-    netcp_cfgCreateMacInterface(
+    netapi_netcpCfgCreateMacInterface(
                       worker_nh[coreid],
                       &config.mac0[0],
                       i,0,
@@ -1494,10 +1494,10 @@ void fast_path_thread(int coreid)
                       (NETCP_CFG_VLAN_T ) NULL ,  //future
                       1, 
                       &err);
-    if (err) {Debug_printf("addmac0 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addmac0 failed %d\n",err); exit(1); }
     else
         {
-            Debug_printf("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
+            netapi_Log("addmac0 passed for index %d, mac before %d\n",i, config.mac0[5]);
             config.mac0[3]++;
         }
     }
@@ -1505,7 +1505,7 @@ void fast_path_thread(int coreid)
    for (i = 30; i < IP_CREATE_LOOP_COUNT ;i++)
     {
     //attach an IP to this interface
-    ip_rule0[i]=netcp_cfgAddIp(
+    ip_rule0[i]=netapi_netcpCfgAddIp(
                       worker_nh[coreid],
                       30,
                       nwal_IPV4,
@@ -1514,10 +1514,10 @@ void fast_path_thread(int coreid)
                       (NETCP_CFG_ROUTE_HANDLE_T) NULL,
                       &err
                       );
-    if (err) {Debug_printf("addip0 failed %d\n",err); exit(1); }
+    if (err) {netapi_Log("addip0 failed %d\n",err); exit(1); }
         else
         {
-            Debug_printf("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
+            netapi_Log("addip0 passed for index%d ip[3] %d\n",i, config.ip0.ipv4[3]);
             config.ip0.ipv4[3]++;
         }
 
@@ -1526,14 +1526,14 @@ sleep(1);
     //delete IPs and MAC Interfacess
     for (i = 30; i < IP_CREATE_LOOP_COUNT;i++)
     {
-         Debug_printf("calling netcp_cfgDelIp and  for index %d\n", i);
-        netcp_cfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
-        netcp_cfgDelMac(worker_nh[coreid],i,&err);
+         netapi_Log("calling netapi_netcpCfgDelIp and  for index %d\n", i);
+        netapi_netcpCfgDelIp(worker_nh[coreid], i, 0, NULL, NULL, ip_rule0[i], &err);
+        netapi_netcpCfgDelMac(worker_nh[coreid],i,&err);
     }
     for (i = 30; i < MAC_CREATE_LOOP_COUNT;i++)
     {
-         Debug_printf("calling  and netcp_cfgDelMac for index %d\n", i);
-         netcp_cfgDelMac(worker_nh[coreid],i,&err);
+         netapi_Log("calling  and netapi_netcpCfgDelMac for index %d\n", i);
+         netapi_netcpCfgDelMac(worker_nh[coreid],i,&err);
     }
 #endif
 
@@ -1548,7 +1548,7 @@ sleep(1);
 
         build_sa_db(i);
         count++;
-        //Debug_printf("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid,  count);
+        //netapi_Log("thread: %d: calling netapi_secAddSA for rx, count = %d\n",coreid,  count);
         sa_info[i].rx_tunnel = netapi_secAddSA(
             worker_nh[coreid],
             config.ipsec_if_no, //iface #0 
@@ -1559,8 +1559,8 @@ sleep(1);
             &(sa_info[i].rx_data_mode_handle),
             &(sa_info[i].rx_inflow_mode_handle),
             &err);
-        //if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
-         if (err) {Debug_printf("addRxSa failed %d\n",err);}
+        //if (err) {netapi_Log("addRxSa failed %d\n",err); exit(1);}
+         if (err) {netapi_Log("addRxSa failed %d\n",err);}
           sched_yield();
 
     }
@@ -1574,7 +1574,7 @@ sleep(1);
     memcpy(&(tx_sa[0].src), &config.local_ipsec_ip,4);
     memcpy(&(tx_sa[0].dst), &config.remote_ipsec_ip,4);
          count++;
-        //Debug_printf("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid,  count);
+        //netapi_Log("thread: %d: calling netapi_secAddSA for tx, count = %d\n",coreid,  count);
     sa_info[i].tx_tunnel = netapi_secAddSA( worker_nh[coreid],
                  0, //iface #0 
                 &tx_sa[0],
@@ -1584,7 +1584,7 @@ sleep(1);
                 &(sa_info[i].tx_data_mode_handle),
                 &(sa_info[i].tx_inflow_mode_handle),
                 &err);
-    if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
+    if (err) {netapi_Log("addTxSa failed %d\n",err); exit(1);}
      sched_yield();
     }
 
@@ -1597,20 +1597,20 @@ sleep(1);
                     netapi_secDelRxPolicy(worker_nh[coreid], rx_policy[i], &err);
                 count ++;
                 //delete tunnels
-                 //Debug_printf("main: calling netapi_secDelSA for rx, count = %d\n", count);
+                 //netapi_Log("main: calling netapi_secDelSA for rx, count = %d\n", count);
                 netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].rx_tunnel, &err);
                 //sleep(1);
-                 //Debug_printf("main: calling netapi_secDelSA for tx, count = %d\n", count);
+                 //netapi_Log("main: calling netapi_secDelSA for tx, count = %d\n", count);
                 netapi_secDelSA(worker_nh[coreid], 0, sa_info[i].tx_tunnel, &err);
         }
 #endif
 
     netapi_schedRun(scheduler[coreid], &err);
-    Debug_printf(">net_test: core %d worker thread done\n",coreid);
-    pktio_close(tx_chan, &err);
-    pktio_close(rx_chan, &err);
-    pktio_close(sb_tx_chan, &err);
-    pktio_close(sb_tx_chan, &err);
+    netapi_Log(">net_test: core %d worker thread done\n",coreid);
+    netapi_pktioClose(tx_chan, &err);
+    netapi_pktioClose(rx_chan, &err);
+    netapi_pktioClose(sb_tx_chan, &err);
+    netapi_pktioClose(sb_tx_chan, &err);
     netapi_shutdown(worker_nh[coreid]);
 }
 
@@ -1634,7 +1634,7 @@ int main(int argc, char **argv)
 
     
     err= getrlimit(RLIMIT_STACK,&rl);
-    if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
+    if (!err) netapi_Log(" stack limit = %d\n",rl.rlim_cur); else netapi_Log("getrlimit failed\n");
 
 
     memset(&sa_info, 0, sizeof(sa_info));
@@ -1646,7 +1646,7 @@ int main(int argc, char **argv)
     ourHeap = Pktlib_findHeapByName("netapi");
     if (!ourHeap)
     {
-        Debug_printf("Pktlib_findHeapByName()  fail\n");
+        netapi_Log("Pktlib_findHeapByName()  fail\n");
         exit(1);
     }
 
@@ -1657,7 +1657,7 @@ int main(int argc, char **argv)
     pPktifTable = netapi_getPktlibIfTable();
     /* Populate the heap configuration */
     heapCfg.name                = "netapi-small";
-    heapCfg.memRegion           = NETAPI_GLOBAL_REGION;
+    heapCfg.memRegion           = TUNE_NETAPI_QM_GLOBAL_REGION;
     heapCfg.sharedHeap          = 1;
     heapCfg.useStarvationQueue  = 0;
     heapCfg.dataBufferSize      = 512;
@@ -1677,50 +1677,50 @@ int main(int argc, char **argv)
     netapi_registerHeap(netapi_handle, specialLarge);
 
     /* create a pktio channel */
-    our_chan=pktio_create(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
+    our_chan=netapi_pktioCreate(netapi_handle,"our1stq",(PKTIO_CB) recv_cb_bench, &our_chan_cfg,&err);
     if (!our_chan)
     {
-        Debug_printf("pktio create failed err=%d\n",err);
+        netapi_Log("pktio create failed err=%d\n",err);
         exit(1);
     }
 
     /* open netcp default tx, rx queues */
-    netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_esp)
     {
-        Debug_printf("pktio open TX failed err=%d\n",err);
+        netapi_Log("pktio open TX failed err=%d\n",err);
         exit(1);
     }
-    netcp_rx_chan= pktio_open(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+    netcp_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 
     if (!netcp_rx_chan)
     {
-        Debug_printf("pktio open RX failed err=%d\n",err);
+        netapi_Log("pktio open RX failed err=%d\n",err);
         exit(1);
     }
 
     /* create a pktio channel for specially classified pkts */
-    netcp_rx_chan2= pktio_create(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2,  &err);
-    if (!netcp_rx_chan2) {Debug_printf("pktio create RX2 failed err=%d\n",err); exit(1);}
+    netcp_rx_chan2= netapi_pktioCreate(netapi_handle, "classq", (PKTIO_CB) recv_cb, &netcp_rx_cfg2,  &err);
+    if (!netcp_rx_chan2) {netapi_Log("pktio create RX2 failed err=%d\n",err); exit(1);}
 
     /* open netcp default tx, rx queues for sideband crypto */
-    netcp_sb_tx_chan= pktio_open(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+    netcp_sb_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
     if (!netcp_sb_tx_chan)
     {
-        Debug_printf("pktio open SB TX failed err=%d\n",err);
+        netapi_Log("pktio open SB TX failed err=%d\n",err);
         exit(1);
     }
-    netcp_sb_rx_chan= pktio_open(netapi_handle, NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
+    netcp_sb_rx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
     if (!netcp_sb_rx_chan)
     {
-        Debug_printf("pktio open SB RX failed err=%d\n",err);
+        netapi_Log("pktio open SB RX failed err=%d\n",err);
         exit(1);
     }
 
-    Debug_printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+    netapi_Log("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
     /* create scheduler instance */
     our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
-    if (!our_sched) {Debug_printf("sched create failed\n"); exit(1);}
+    if (!our_sched) {netapi_Log("sched create failed\n"); exit(1);}
 
     //#define PROMISCUOUS
 #define ETH0 0
@@ -1728,7 +1728,7 @@ int main(int argc, char **argv)
 
 //security stuff 
     p_trie_sa = trie_new();
-   if (!p_trie_sa) {Debug_printf("trie alloc for SA  failed\n"); exit(1);}
+   if (!p_trie_sa) {netapi_Log("trie alloc for SA  failed\n"); exit(1);}
 
 
 #ifdef MULTI_THREAD
@@ -1743,7 +1743,7 @@ int main(int argc, char **argv)
                 perror( "malloc" );
                 return -1;
         }
-        Debug_printf( "Starting %d threads...\n", procs );
+        netapi_Log( "Starting %d threads...\n", procs );
 
         if (pthread_create( &thrs[0], NULL, slow_path_thread,
                         (void *)0 ))
@@ -1761,7 +1761,7 @@ int main(int argc, char **argv)
         //this thread of execution (main) now just waits on user input
         for(;;)
         {
-           Debug_printf(">");
+           netapi_Log(">");
            c=getchar();
            if (c=='q') 
            {
@@ -1769,11 +1769,11 @@ int main(int argc, char **argv)
                 break;
            }
            //else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
-           else if (c=='h') Debug_printf("'q' to quit,  's' for stats, 'h' for help\n");
+           else if (c=='h') netapi_Log("'q' to quit,  's' for stats, 'h' for help\n");
         }
 
         //wait for completion 
-        Debug_printf("main task now pending on slow/fast path completion\n");
+        netapi_Log("main task now pending on slow/fast path completion\n");
         for (i = 0; i < procs; i++)
                 pthread_join( thrs[i], NULL );
 
@@ -1816,28 +1816,28 @@ int main(int argc, char **argv)
      ************************************************/
 
     //delete Classifiers
-    netcp_cfgDelClass(netapi_handle, class_0, &err); 
-    netcp_cfgDelClass(netapi_handle, class_1, &err); 
-    //netcp_cfgDelClass(netapi_handle, class_2, &err); 
+    netapi_netcpCfgDelClass(netapi_handle, class_0, &err); 
+    netapi_netcpCfgDelClass(netapi_handle, class_1, &err); 
+    //netapi_netcpCfgDelClass(netapi_handle, class_2, &err); 
 
         count = 0;
     //close pktio channels we opened
-    Debug_printf("main: calling pktio_close for netcp_tx_chan_esp\n");
-    pktio_close(netcp_tx_chan_esp ,&err);
-    Debug_printf("main: calling pktio_close for netcp_rx_chan\n");
-    pktio_close(netcp_rx_chan ,&err);
-    Debug_printf("main: calling pktio_close for netcp_sb_tx_chan\n");
-    pktio_close(netcp_sb_tx_chan ,&err);
-    Debug_printf("main: calling pktio_close for netcp_sb_rx_chan\n");
-    pktio_close(netcp_sb_rx_chan ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_tx_chan_esp\n");
+    netapi_pktioClose(netcp_tx_chan_esp ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_rx_chan\n");
+    netapi_pktioClose(netcp_rx_chan ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_sb_tx_chan\n");
+    netapi_pktioClose(netcp_sb_tx_chan ,&err);
+    netapi_Log("main: calling netapi_pktioClose for netcp_sb_rx_chan\n");
+    netapi_pktioClose(netcp_sb_rx_chan ,&err);
 
     //clear pktio channel we created
-    pktio_control(our_chan, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
-    pktio_control(netcp_rx_chan2, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
+    netapi_pktioControl(our_chan, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
+    netapi_pktioControl(netcp_rx_chan2, (PKTIO_CB) NULL, (PKTIO_CFG_T *) NULL, &zap_channel_control, &err);
 
     //delete pktio channels we created
-    pktio_delete(our_chan, &err);
-    pktio_delete(netcp_rx_chan2,&err);
+    netapi_pktioDelete(our_chan, &err);
+    netapi_pktioDelete(netcp_rx_chan2,&err);
     netapi_shutdown(netapi_handle);
 
 }
index a621c65516b30edc8d6437f0130bf1747b763f80..d678f126031fbaf50f49a47ecca380e23771eab6 100755 (executable)
@@ -7,7 +7,7 @@
  * DESCRIPTION:  netapi user space transport
  *               library  test application
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2010-2011
  * 
@@ -536,7 +536,6 @@ void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
     /* loop over received pkts */
     for(i=0;i<n_pkts;i++)
     {
-        Debug_printf("recv_cb: appId 0x%x\n", meta[i].u.rx_meta->appId);
         ifno = ((unsigned int)meta[i].u.rx_meta->appId)&0xff;
         
         enet_port = meta[i].u.rx_meta->enetPort;
@@ -549,8 +548,8 @@ void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
 
         if(((unsigned int)meta[i].u.rx_meta->appId) == expPkt_appid)
         {
-            Debug_printf("recv_cb: received exception packet\n");
-              Pktlib_freePacket(tip);
+            netapi_Log("recv_cb: received exception packet\n");
+            Pktlib_freePacket(tip);
             if(((unsigned int)meta[i].u.rx_meta->rxFlag1  & NWAL_RX_IP_FRAGMENT_PKT) ==
                                              NWAL_RX_IP_FRAGMENT_PKT)
             {
@@ -577,12 +576,12 @@ void recv_cb(struct PKTIO_HANDLE_Tag * channel, Ti_Pkt* p_recv[],
 #ifdef DEBUG_DESC
         if (stats[coreid].rx<16)
         {
-            Debug_printf(">rx dmp.."); 
+            netapi_Log(">rx dmp.."); 
             dump_descr((long *) tip, stats[coreid].rx);
         }
         else if (stats[coreid].rx>99) 
         {
-            Debug_printf(">rx dmp.."); 
+            netapi_Log(">rx dmp.."); 
             dump_descr((long *) tip,stats[coreid].rx);
         }
 #endif
@@ -765,17 +764,17 @@ nwalTxPktInfo_t txPktInfoNoCrypto =
 void close_pktio_channels(void)
 {
     int err;
-    pktio_close(netcp_tx_chan_esp ,&err);
-    pktio_close(netcp_tx_chan_ah ,&err);
-    pktio_close(netcp_sb_tx_chan ,&err);
-    pktio_close(netcp_tx_chan_no_crypto,&err);
+    netapi_pktioClose(netcp_tx_chan_esp ,&err);
+    netapi_pktioClose(netcp_tx_chan_ah ,&err);
+    netapi_pktioClose(netcp_sb_tx_chan ,&err);
+    netapi_pktioClose(netcp_tx_chan_no_crypto,&err);
 }
 
 void open_pktio_tx_channels(void)
 {
     int err;
     /* open netcp default  TX for ESP packets */
-    netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_esp)
     {
         printf("pktio open TX failed err=%d\n",err);
@@ -790,12 +789,12 @@ void open_pktio_tx_channels(void)
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_L4CKSUM_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
-            pktio_control(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
+            netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
         }
     }
 
     /*/* open netcp default  TX for AH packets */
-    netcp_tx_chan_ah= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_ah)
     {
         printf("pktio open TX failed err=%d\n",err);
@@ -810,12 +809,12 @@ void open_pktio_tx_channels(void)
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_L4CKSUM_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
-            pktio_control(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
+            netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
         }
     }
 
     /* open netcp default  TX channels for non-Crypto packets */
-    netcp_tx_chan_no_crypto= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_no_crypto)
     {
         printf("pktio open TX failed err=%d\n",err);
@@ -830,12 +829,12 @@ void open_pktio_tx_channels(void)
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_L4CKSUM_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
-            pktio_control(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
+            netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
         }
     }
 
     /* open netcp default  TX channels for SB crypto */
-    netcp_sb_tx_chan= pktio_open(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+    netcp_sb_tx_chan= netapi_pktioOpen(netapi_handle, NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
     if (!netcp_sb_tx_chan)
     {
         printf("pktio open SB TX failed err=%d\n",err);
@@ -847,7 +846,7 @@ void open_pktio_tx_channels(void)
 #ifdef MULTI_THREAD
 NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
 
-void slow_path_thread(int thread_num)
+void slow_path_thread(uint32_t thread_num)
 {
     int err, i;;
 
@@ -859,14 +858,14 @@ void slow_path_thread(int thread_num)
     CPU_ZERO( &cpu_set);
     printf("fast_path_thread: settting up for thread number %d\n", thread_num);
 #ifdef CORTEX_A15
-    for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+    for (i = netTestCfg.sp_proc_start[thread_num]; i <= netTestCfg.sp_proc_end[thread_num];i++)
     {
         printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
         CPU_SET( i, &cpu_set);
     }
     hplib_utilSetupCore(thread_num, &cpu_set);
 #else
-    for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+    for (i = netTestCfg.sp_proc_start[thread_num]; i <= netTestCfg.sp_proc_end[thread_num];i++)
     {
         printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
         CPU_SET( i, &cpu_set);
@@ -875,20 +874,18 @@ void slow_path_thread(int thread_num)
 #endif
     worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
 
-    //NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
-
    /* open netcp default RX channels*/
     
-    rx_chan = pktio_open(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
     
-    sb_rx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
+    sb_rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
 
-    netapi_setCookie(worker_nh[thread_num],(void*) thread_num);
+    netapi_setCookie(worker_nh[thread_num],(void*)(thread_num | NET_TEST_SP_THREAD_MASK));
 
     scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
     if (!scheduler[thread_num]) 
     {
-        printf("sched create failed for core%d\n",thread_num); 
+        printf("sched create failed for core%d\n",thread_num);
         exit(1);
     }
     scheduler[thread_num]->config.yield = TRUE;
@@ -899,13 +896,12 @@ void slow_path_thread(int thread_num)
     netapi_schedRun(scheduler[thread_num], &err);
     printf(">net_test: core %d worker thread done\n",thread_num);
 
-    //pktio_close(tx_chan, &err);
-    pktio_close(rx_chan, &err);
-    pktio_close(sb_rx_chan, &err);
+    netapi_pktioClose(rx_chan, &err);
+    netapi_pktioClose(sb_rx_chan, &err);
     netapi_shutdown(worker_nh[thread_num]);
 }
 
-void fast_path_thread(int thread_num)
+void fast_path_thread(uint32_t thread_num)
 {
     int err, i;
     PKTIO_HANDLE_T *rx_chan;
@@ -930,20 +926,18 @@ void fast_path_thread(int thread_num)
 #endif
     worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
 
-    //NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
-
    /* open netcp default RX channels*/
-    rx_chan = pktio_open(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb, &netcp_rx_cfg,  &err);
 
     /* create a pktio channel for specially classified pkts */
     /* open netcp default tx, rx queues for sideband crypto */
-     //sb_tx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
-     sb_rx_chan = pktio_open(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
+     //sb_tx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_TX, NULL, &netcp_sb_tx_cfg,  &err);
+     sb_rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_SB_RX, (PKTIO_CB) recv_sb_cb, &netcp_sb_rx_cfg,  &err);
 
 
     
     netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
-    //our_core = coreid;
+    
     scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
     if (!scheduler[thread_num]) 
         {
@@ -960,9 +954,9 @@ void fast_path_thread(int thread_num)
      netapi_schedRun(scheduler[thread_num], &err);
     printf(">net_test: core %d worker thread done\n",thread_num);
 
-    pktio_close(rx_chan, &err);
+    netapi_pktioClose(rx_chan, &err);
 
-    pktio_close(sb_rx_chan, &err);
+    netapi_pktioClose(sb_rx_chan, &err);
     netapi_shutdown(worker_nh[thread_num]);
 }
 
@@ -1017,8 +1011,8 @@ int main(int argc, char **argv)
     netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
 
     /* configure expection packet handling with netapi */
-    netcp_cfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
-    expPkt_appid = netcp_cfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+    netapi_netcpCfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+    expPkt_appid = netapi_netcpCfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
 
     /* open the main heap */
     ourHeap = Pktlib_findHeapByName("netapi");
index 431e1e3cec5c3d075c0815f1d4ef388b6afd0dc4..46dafaac2ab224906b8e192eaf805cfa715fb13a 100755 (executable)
@@ -65,6 +65,7 @@
 #define netTest_AES_GMAC_IV_LEN          8
 #define netTest_NULL_IV_LEN             0
 #define netTest_ICV_LEN                 12
+#define netTest_HMAC_SHA256_RFC_4868_ICV_LEN 16
 #define netTest_AES_GCM_CCM_ICV_LEN     16
 #define netTest_AES_GMAC_ICV_LEN     16
 
index c916411acfa8d32a444561043c2e4d123437635d..d76ea88113c82e5ccc792f1155c21ccf4a948a52 100755 (executable)
@@ -7,7 +7,7 @@
  * DESCRIPTION:  netapi user space transport
  *               library  net_test_router application
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
@@ -170,7 +170,7 @@ nwalTxPktInfo_t txPktInfoESP =
     NULL,                                                                                               /* p_pkt */
     NWAL_TX_FLAG1_DO_IPSEC_ESP_CRYPTO| NWAL_TX_FLAG1_DO_IPV4_CHKSUM| NWAL_TX_FLAG1_META_DATA_VALID,      /* txFlags */
     0,                                                                                                  /* lpbackPass */
-    0,                                                                                                  /* enetport */
+    1,                                                                                                  /* enetport */
     0,                                                                                                  /* msuSize */
     0,                                                                                                   /* startOffset */
     netTest_MAC_HEADER_LEN  + netTest_IP_HEADER_LEN,                                                    /* saOffBytes */
@@ -229,9 +229,9 @@ nwalTxPktInfo_t txPktInfoNoCrypto =
 void close_pktio_channels(void)
 {
     int err;
-    pktio_close(netcp_tx_chan_no_crypto ,&err);
-    pktio_close(netcp_tx_chan_esp ,&err);
-    pktio_close(netcp_tx_chan_ah ,&err);
+    netapi_pktioClose(netcp_tx_chan_no_crypto ,&err);
+    netapi_pktioClose(netcp_tx_chan_esp ,&err);
+    netapi_pktioClose(netcp_tx_chan_ah ,&err);
 }
 
 
@@ -240,10 +240,10 @@ void open_pktio_tx_channels()
 {
     int err;
     /* open netcp default  TX channels */
-    netcp_tx_chan_no_crypto= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_no_crypto= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_no_crypto)
     {
-        Debug_printf("pktio open TX failed err=%d\n",err);
+        netapi_Log("pktio open TX failed err=%d\n",err);
         exit(1);
     }
     else
@@ -255,14 +255,14 @@ void open_pktio_tx_channels()
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_NO_CRYPTO_NO_CKSUM_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoNoCrypto;
-            //pktio_control(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
+            //netapi_pktioControl(netcp_tx_chan_no_crypto, NULL, &cfg, &control, &err);
         }
     }
     /* open netcp default  TX for ESP packets */
-    netcp_tx_chan_esp= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_esp= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_esp)
     {
-        Debug_printf("pktio open TX failed err=%d\n",err);
+        netapi_Log("pktio open TX failed err=%d\n",err);
         exit(1);
     }
     else
@@ -274,15 +274,15 @@ void open_pktio_tx_channels()
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_ESP_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoESP;
-            //pktio_control(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
+            //netapi_pktioControl(netcp_tx_chan_esp, NULL, &cfg, &control, &err);
         }
     }
 
     /*/* open netcp default  TX for AH packets */
-    netcp_tx_chan_ah= pktio_open(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
+    netcp_tx_chan_ah= netapi_pktioOpen(netapi_handle, NETCP_TX, NULL, &netcp_tx_cfg,  &err);
     if (!netcp_tx_chan_ah)
     {
-        Debug_printf("pktio open TX failed err=%d\n",err);
+        netapi_Log("pktio open TX failed err=%d\n",err);
         exit(1);
     }
     else
@@ -294,7 +294,7 @@ void open_pktio_tx_channels()
             PKTIO_CFG_T cfg;
             cfg.fast_path_cfg.fp_send_option = PKTIO_FP_AH_PORT;
             cfg.fast_path_cfg.txPktInfo= &txPktInfoAH;
-            //pktio_control(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
+            //netapi_pktioControl(netcp_tx_chan_ah, NULL, &cfg, &control, &err);
         }
     }
 }
@@ -303,9 +303,9 @@ void open_pktio_tx_channels()
 
 
 NETAPI_T worker_nh[TUNE_NETAPI_NUM_CORES];
-void slow_path_thread(int coreid)
+void slow_path_thread(uint32_t thread_num)
 {
-    int err;
+    int err,i;
     PKTIO_HANDLE_T *rx_chan;
     PKTIO_HANDLE_T *sb_tx_chan;
     PKTIO_HANDLE_T *sb_rx_chan;
@@ -313,84 +313,100 @@ void slow_path_thread(int coreid)
 
     CPU_ZERO( &cpu_set);
 #ifdef CORTEX_A15
-    CPU_SET( coreid, &cpu_set);
-    hplib_utilSetupCore(coreid, &cpu_set);
+    for (i = netTestCfg.sp_proc_start[thread_num]; i <= netTestCfg.sp_proc_end[thread_num];i++)
+    {
+        printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupCore(thread_num, &cpu_set);
 #else
-      CPU_SET( 0, &cpu_set);
-    hplib_utilSetupCore(coreid+1, &cpu_set);
+    for (i = netTestCfg.sp_proc_start[thread_num]; i <= netTestCfg.sp_proc_end[thread_num];i++)
+    {
+        printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupCore(thread_num, &cpu_set);
 #endif
-    worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+    worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
 
-    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
 
    /* open netcp RX channel */
-    rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
+    rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
 
 
 
-    netapi_setCookie(worker_nh[coreid],(void*)coreid);
+    netapi_setCookie(worker_nh[thread_num],(void*) (thread_num | NET_TEST_SP_THREAD_MASK));
       
-    scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
-    if (!scheduler[coreid]) 
+    scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
+    if (!scheduler[thread_num]) 
     {
-        Debug_printf("sched create failed for core%d\n",coreid); 
+        netapi_Log("sched create failed for core%d\n",thread_num); 
         exit(1);
     }
-      scheduler[coreid]->config.yield = FALSE;
-       scheduler[coreid]->config.pollGarbageQ = TRUE;
-        scheduler[coreid]->config.pollCtrlQ = TRUE;
+      scheduler[thread_num]->config.yield = FALSE;
+      scheduler[thread_num]->config.pollGarbageQ = TRUE;
+      scheduler[thread_num]->config.pollCtrlQ = TRUE;
             /*********************************************/
     /**************Entry point into scheduler ****/
     /*********************************************/
-    netapi_schedRun(scheduler[coreid], &err);
-    Debug_printf(">net_test: core %d worker thread done\n",coreid);
+    netapi_schedRun(scheduler[thread_num], &err);
+    netapi_Log(">net_test: core %d worker thread done\n",thread_num);
 
-    pktio_close(rx_chan, &err);
-    netapi_shutdown(worker_nh[coreid]);
+    netapi_pktioClose(rx_chan, &err);
+    netapi_shutdown(worker_nh[thread_num]);
 }
 
 
-void fast_path_thread(int coreid)
+void fast_path_thread(uint32_t thread_num)
 {
-    int err;
+    int err,i;
     PKTIO_HANDLE_T *rx_chan;
     PKTIO_HANDLE_T *sb_tx_chan;
     //PKTIO_HANDLE_T *sb_rx_chan;
 
 #ifdef CORTEX_A15
-    CPU_SET( coreid, &cpu_set);
-        hplib_utilSetupCore(coreid, &cpu_set);
+    for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+    {
+        printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupCore(thread_num, &cpu_set);
 #else
-      CPU_SET( 0, &cpu_set);
-    hplib_utilSetupCore(coreid + 1, &cpu_set);
+    for (i = netTestCfg.fp_proc_start[thread_num]; i <= netTestCfg.fp_proc_end[thread_num];i++)
+    {
+        printf("fast_path_thread: setting cpu %d to cpu_set\n", i);
+        CPU_SET( i, &cpu_set);
+    }
+    hplib_utilSetupCore(thread_num, &cpu_set);
 #endif
-    worker_nh[coreid]=netapi_init(NETAPI_CORE_MASTER,NULL);
+    worker_nh[thread_num]=netapi_init(NETAPI_CORE_MASTER,NULL);
 
-    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[coreid];
+    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) worker_nh[thread_num];
 
    /* open netcp RX channel */
-    rx_chan = pktio_open(worker_nh[coreid], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
-    netapi_setCookie(worker_nh[coreid],(void*)coreid);
+    rx_chan = netapi_pktioOpen(worker_nh[thread_num], NETCP_RX, (PKTIO_CB) recv_cb_router, &netcp_rx_cfg,  &err);
+    netapi_setCookie(worker_nh[thread_num],(void*)thread_num);
 
-    scheduler[coreid] =netapi_schedOpen(worker_nh[coreid],&our_sched_cfg, &err);
-    if (!scheduler[coreid]) 
+    scheduler[thread_num] =netapi_schedOpen(worker_nh[thread_num],&our_sched_cfg, &err);
+    if (!scheduler[thread_num]) 
         {
-        Debug_printf("sched create failed for core%d\n",coreid); 
+        netapi_Log("sched create failed for core%d\n",thread_num); 
         exit(1);
     }
 
     /*********************************************/
     /**************Entry point into scheduler ****/
     /*********************************************/
-    scheduler[coreid]->config.yield = FALSE;
-     scheduler[coreid]->config.pollGarbageQ = FALSE;
-     scheduler[coreid]->config.pollCtrlQ = FALSE;
+    scheduler[thread_num]->config.yield = FALSE;
+     scheduler[thread_num]->config.pollGarbageQ = FALSE;
+     scheduler[thread_num]->config.pollCtrlQ = FALSE;
      //sleep(100000);
-    netapi_schedRun(scheduler[coreid], &err);
-    Debug_printf(">net_test: core %d worker thread done\n",coreid);
+    netapi_schedRun(scheduler[thread_num], &err);
+    netapi_Log(">net_test: core %d worker thread done\n",thread_num);
 
-    pktio_close(rx_chan, &err);
-    netapi_shutdown(worker_nh[coreid]);
+    netapi_pktioClose(rx_chan, &err);
+    netapi_shutdown(worker_nh[thread_num]);
 \r}
 
 #endif
@@ -413,7 +429,7 @@ int main(int argc, char **argv)
 
 
     err= getrlimit(RLIMIT_STACK,&rl);
-    if (!err) Debug_printf(" stack limit = %d\n",rl.rlim_cur); else Debug_printf("getrlimit failed\n");
+    if (!err) netapi_Log(" stack limit = %d\n",rl.rlim_cur); else netapi_Log("getrlimit failed\n");
 
      /* install signal handler for ^c */
     signal(SIGINT,mysig);
@@ -421,7 +437,7 @@ int main(int argc, char **argv)
     fpr = fopen(input_file_name, "r");
     if (fpr == NULL) 
     {
-        Debug_printf("Error in opening %s input file\n", input_file_name);
+        netapi_Log("Error in opening %s input file\n", input_file_name);
         exit(1);
     }
     else
@@ -443,24 +459,24 @@ int main(int argc, char **argv)
     netapi_handle = netapi_init(NETAPI_SYS_MASTER, &our_netapi_default_cfg);
 
     /* configure expection packet handling with netapi */
-    netcp_cfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
-    expPkt_appid = netcp_cfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+    netapi_netcpCfgExceptions(netapi_handle, NETCP_CFG_ALL_EXCEPTIONS, NETCP_CFG_ACTION_DISCARD, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
+    expPkt_appid = netapi_netcpCfgExceptions(netapi_handle, 7, NETCP_CFG_ACTION_TO_SW, (NETCP_CFG_ROUTE_HANDLE_T) NULL);
 
     /* open the main heap */
     ourHeap = Pktlib_findHeapByName("netapi");
     if (!ourHeap)
     {
-        Debug_printf("Pktlib_findHeapByName()  fail\n");
+        netapi_Log("Pktlib_findHeapByName()  fail\n");
         exit(1);
     }
 
     /* Open all required PKTIO TX channels */
     open_pktio_tx_channels();
 
-    Debug_printf("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
+    netapi_Log("net_test> %d bytes left in our CMA area\n", netapi_getBufMemRemainder());
     /* create scheduler instance */
     our_sched =netapi_schedOpen(netapi_handle,&our_sched_cfg, &err);
-    if (!our_sched) {Debug_printf("sched create failed\n"); exit(1);}
+    if (!our_sched) {netapi_Log("sched create failed\n"); exit(1);}
 
 
     /*create net_test MAC interfaces, attach IP to created MAC interfaces */
@@ -470,7 +486,7 @@ int main(int argc, char **argv)
     p_trie_sa_rx = trie_new();
     p_trie_sa_tx = trie_new();
    if (!p_trie_sa_rx || !p_trie_sa_tx)
-        {Debug_printf("trie alloc for SA  failed\n"); exit(1);}
+        {netapi_Log("trie alloc for SA  failed\n"); exit(1);}
 
     /* Create RX SA's, RX Policy and TX SA's, all SA configuration parameters are read from net_test_config.txt file */
     create_sec_associations();
@@ -487,11 +503,11 @@ int main(int argc, char **argv)
         //this thread of execution (main) now just waits on user input
         for(;;)
         {
-           Debug_printf(">");
+           printf(">");
            c=getchar();
            if (c=='q') {QUIT=1;break;}
            else if (c=='s') our_stats_cb(netapi_handle, &netcp_stats);
-           else if (c=='h') Debug_printf("'q' to quit,  's' for stats, 'h' for help\n");
+           else if (c=='h') printf("'q' to quit,  's' for stats, 'h' for help\n");
         }
 
 }
index 7bfb14a5f715d52eec741e0f09e5c038f5a3d840..800841afd6aecbce73560e344bbd5275ed08b594 100755 (executable)
@@ -6,7 +6,7 @@
  * 
  * DESCRIPTION:  net_test application security associations utilities
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
@@ -558,9 +558,9 @@ void  build_sa_db(int i)
          }
     }
     else
-        Debug_printf("build_sa_db(): invalid encryption/authentication combination selected\n");
+        netapi_Log("build_sa_db(): invalid encryption/authentication combination selected\n");
 
-    //Debug_printf("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
+    //netapi_Log("sa_build_db(): authOffset %d, innerIpOffset %d, encOffset %d\n", sa_info[i].tx_payload_info.authOffset, sa_info[i].inner_ip_offset, sa_info[i].tx_payload_info.encOffset);
     
     
 }
@@ -588,7 +588,7 @@ int create_sec_associations(void)
             &(sa_info[i].rx_inflow_mode_handle),
             (void*) saId,
             &err);
-            if (err) {Debug_printf("addRxSa failed %d\n",err); exit(1);}
+            if (err) {netapi_Log("addRxSa failed %d\n",err); exit(1);}
 
             if (netTestCfg.ipsec_mode_rx == IPSEC_MODE_RX_INFLOW)
             {
@@ -604,7 +604,7 @@ int create_sec_associations(void)
                              &err);
                 if (err)
                 {
-                    Debug_printf("addSaPolicy failed  %d, for index %d\n",err,i); 
+                    netapi_Log("addSaPolicy failed  %d, for index %d\n",err,i); 
                     exit(1);
                 }
             }
@@ -628,7 +628,7 @@ int create_sec_associations(void)
                 &(sa_info[i].tx_inflow_mode_handle),
                 (void*)saId,
                 &err);
-            if (err) {Debug_printf("addTxSa failed %d\n",err); exit(1);}
+            if (err) {netapi_Log("addTxSa failed %d\n",err); exit(1);}
 
         }
     }
@@ -645,7 +645,7 @@ void delete_sec_associations()
         {
             if (rx_policy[i])
                 netapi_secDelRxPolicy(netapi_handle, rx_policy[i], &err);
-            if (err == 0) Debug_printf("polcicy deleted  %d\n", i );
+            if (err == 0) netapi_Log("polcicy deleted  %d\n", i );
                 //delete tunnels
             netapi_secDelSA(netapi_handle, 0, sa_info[i].rx_tunnel, &err);
         }
index fdeb383880d4c757a3728ab35fccbaf4445a77bd..c6bee4de33066eb463d16fc3b1bfa794987adadc 100755 (executable)
@@ -6,7 +6,7 @@
  * 
  * DESCRIPTION:  net_test application thread utilities
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2013
  * 
@@ -74,7 +74,7 @@ void create_sp_fp_threads(void)
         perror( "malloc" );
         exit(1);
     }
-    Debug_printf( "Starting %d threads...\n", netTestCfg.num_sp_threads );
+    netapi_Log( "Starting %d threads...\n", netTestCfg.num_sp_threads );
 
     for (i = 0; i < netTestCfg.num_sp_threads; i++)
     {
@@ -105,7 +105,7 @@ void sp_fp_thread_cleanup(void)
 {
     int i;
     //wait for completion 
-    Debug_printf("main task now pending on slow/fast path completion\n");
+    netapi_Log("main task now pending on slow/fast path completion\n");
     for (i = 0; i < netTestCfg.num_sp_threads; i++)
             pthread_join( sp_threads[i], NULL );
 
index a4cde1f628721d6f347b7a2220c992c12a733f94..9bc50564f953bea1d7d4a35ba0478c6046b826c8 100755 (executable)
@@ -6,7 +6,7 @@
  * 
  * DESCRIPTION:  net_test application general utilities
  * 
- * REVISION HISTORY:  rev 0.0.1 
+ * REVISION HISTORY:
  *
  *  Copyright (c) Texas Instruments Incorporated 2010-2011
  * 
@@ -108,7 +108,7 @@ if (NWAL_RX_FLAG1_META_DATA_VALID & p_meta->u.rx_meta->rxFlag1)
     if (c==0)  stats[coreid].n_class0_rx +=1;
     else if (c==1) stats[coreid].n_class1_rx +=1;
     else if (c==2) stats[coreid].n_class2_rx +=1;
-    else Debug_printf("**NET_TEST RX -unknown class: %x\n",  p_meta->u.rx_meta->appId);
+    else netapi_Log("**NET_TEST RX -unknown class: %x\n",  p_meta->u.rx_meta->appId);
 }
 }
 
@@ -122,10 +122,10 @@ void mysig(int x)
 {
     QUIT=1;
     scnt+=1;
-    Debug_printf(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
+    netapi_Log(">net_test: recv'd signal %d cnt=%d\n",x,scnt);
     if (scnt > 10)
     {
-        Debug_printf(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");
+        netapi_Log(">net_test: WARNING EXITING WITH PROPER SHUTDOWN, LUTS LEFT ACTIVE\n");
         exit(1);
     }
 }
@@ -135,19 +135,19 @@ unsigned long peek(unsigned long * p)
 }
 void dump_descr(unsigned long *p, int n)
 {
-    Debug_printf("--------dump of descriptor %d %x\n", n, (int) p);
-    Debug_printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
-    Debug_printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
-    Debug_printf("-----------------------------\n");
+    netapi_Log("--------dump of descriptor %d %x\n", n, (int) p);
+    netapi_Log("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
+    netapi_Log("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
+    netapi_Log("-----------------------------\n");
 }
 void dump_header(unsigned long *p, int n, int a, int r)
 {
-    Debug_printf("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
-    Debug_printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
-    Debug_printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
-    Debug_printf("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
-    Debug_printf("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
-    Debug_printf("-----------------------------\n");
+    netapi_Log("--------dump of header %d %x appID=%x flag1=%x\n", n, (int) p,a,r);
+    netapi_Log("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
+    netapi_Log("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
+    netapi_Log("> %x %x %x %x %x %x %x %x\n",p[16],p[17],p[18],p[19],p[20],p[21],p[22],p[23]);
+    netapi_Log("> %x %x %x %x %x %x %x %x\n",p[24],p[25],p[26],p[27],p[28],p[29],p[30],p[31]);
+    netapi_Log("-----------------------------\n");
 }
 
 void  netapi_dump_buf
@@ -170,7 +170,7 @@ void  netapi_dump_buf
 
     tmp_buf = (uint8_t *)(buf);
 
-    Debug_printf("netapi *:  - 8 bit word hex Length: %d Start \n",buf_length);
+    netapi_Log("netapi *:  - 8 bit word hex Length: %d Start \n",buf_length);
     do
     {
     row_count = (dump_size - count);
@@ -189,27 +189,27 @@ void  netapi_dump_buf
         {
             case 4:
             {
-                Debug_printf("netapi *:%02d : %02x    %02x    %02x    %02x \n",
+                netapi_Log("netapi *:%02d : %02x    %02x    %02x    %02x \n",
                       count,tmp_buf[0],tmp_buf[1],tmp_buf[2],tmp_buf[3]);
                 break;
             }
             case 3:
             {
-                Debug_printf("netapi *: %02d : %02x    %02x    %02x \n",
+                netapi_Log("netapi *: %02d : %02x    %02x    %02x \n",
                       count,tmp_buf[0],tmp_buf[1],tmp_buf[2]);
                 break;
             }
 
             case 2:
             {
-                Debug_printf("netapi *: %02d : %02x    %02x \n",
+                netapi_Log("netapi *: %02d : %02x    %02x \n",
                       count,tmp_buf[0],tmp_buf[1]);
                 break;
             }
 
             case 1:
             {
-                Debug_printf("netapi *: %02d : %02x \n",
+                netapi_Log("netapi *: %02d : %02x \n",
                       count,tmp_buf[0]);
                 break;
             }
@@ -217,7 +217,7 @@ void  netapi_dump_buf
             default:
             {
                 /* Should never reach here */
-                Debug_printf("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n", row_count);
+                netapi_Log("netapi *: Internal Error in netapi_dump_buf().Row Count: %d \n", row_count);
                 return;
             }
         }
@@ -227,7 +227,7 @@ void  netapi_dump_buf
 
     }while(count < dump_size);
 
-    Debug_printf("netapi *:  - Byte hex Dump End \n");
+    netapi_Log("netapi *:  - Byte hex Dump End \n");
 
 }
 long htonl(long x)
@@ -339,23 +339,23 @@ void print_ipsec_stats(Sa_IpsecStats_t     *p_saIpsecStats, nwal_saAALG auth, nw
 #if 0
     if(retVal != nwal_OK)
     {
-        System_System_Debug_printf("CORE: %d Error getting IP Sec Stats: Ret Status: %d \n",
+        System_System_netapi_Log("CORE: %d Error getting IP Sec Stats: Ret Status: %d \n",
                        retVal);
         return(nwal_FALSE);
     }
     if((p_saIpsecStats->pktEncHi) ||(p_saIpsecStats->pktEncLo))
     {
-        Debug_Debug_printf("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
+        Debug_netapi_Log("------------- IPSec TX (Encryption Channel) Stats BEGIN --\n");
     }
     else
     {
-        Debug_printf("------------- IPSec RX (Decryption Channel) Stats BEGIN --\n");
+        netapi_Log("------------- IPSec RX (Decryption Channel) Stats BEGIN --\n");
     }
 #endif
-    Debug_printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
-    Debug_printf("IPSec replayOld:0x%x,replayDup:0x%x,authFail:0x%x \n",
+    netapi_Log("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
+    netapi_Log("IPSec replayOld:0x%x,replayDup:0x%x,authFail:0x%x \n",
                    p_saIpsecStats->replayOld,p_saIpsecStats->replayDup,p_saIpsecStats->authFail);
-    Debug_printf("IPSec txESN:0x%x,rxESN:0x%x,pktEncHi:0x%x,pktEncLo:0x%x,pktDecHi:0x%x,pktDecLo:0x%x \n",
+    netapi_Log("IPSec txESN:0x%x,rxESN:0x%x,pktEncHi:0x%x,pktEncLo:0x%x,pktDecHi:0x%x,pktDecLo:0x%x \n",
                    p_saIpsecStats->txESN,p_saIpsecStats->rxESN,p_saIpsecStats->pktEncHi,
                    p_saIpsecStats->pktEncLo,p_saIpsecStats->pktDecHi,p_saIpsecStats->pktDecLo);
 }
@@ -363,8 +363,8 @@ void print_ipsec_stats(Sa_IpsecStats_t     *p_saIpsecStats, nwal_saAALG auth, nw
 void print_datamode_stats(Sa_DataModeStats_t     *p_saDataModeStats, nwal_saAALG auth, nwal_saEALG cipher)
 {
 
-    Debug_printf("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
-    Debug_printf(" Packets processedHi: 0x%x, Packets processed Lo:0x%x\n",
+    netapi_Log("\nAutentication mode: %d, Encryption Mode: %d\n", auth, cipher);
+    netapi_Log(" Packets processedHi: 0x%x, Packets processed Lo:0x%x\n",
             p_saDataModeStats->pktHi, p_saDataModeStats->pktLo);
 }
 
@@ -405,19 +405,19 @@ NETAPI_SA_STATS_T netapi_sa_stats;
 
     for (i=0;i < TUNE_NETAPI_NUM_CORES;i++)
     {
-        Debug_printf("Per Core Statistics for CORE %d\n", i);
-        Debug_printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats[i].n_stats_cb);
-        Debug_printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%dsecRx=%d\t"
+        printf("Per Core Statistics for CORE %d\n", i);
+        printf(">*****stats @ %lld (#cbs%d) \n", hplib_mUtilGetTimestamp(),stats[i].n_stats_cb);
+        printf(">itx=%d rx=%d tx=%d bad=%d slow=%d \n>rx_class0=%d rx_class1=%d rx_class2=%dsecRx=%d\t"
             "secPRX=%d sb_rx=%d sb_tx=%d auth_ok=%d sec_tx=%d  min_rx=%d min_tx=%d  fragPkt=%d, exceptionPktOther=%d\n",
          stats[i].itx, stats[i].rx, stats[i].tx, stats[i].n_bad, stats[i].n_new, 
          stats[i].n_class0_rx, stats[i].n_class1_rx,  stats[i].n_class2_rx, stats[i].sec_rx,
          stats[i].secp_rx, stats[i].sb_rx, stats[i].sb_tx, stats[i].n_auth_ok,
          stats[i].sec_tx, stats[i].rx_min, stats[i].tx_min, stats[i].exceptionPktsFrag, stats[i].exceptionPktsOther);
-        Debug_printf(">if rx stats:  %d %d %d\n",stats[i].if_rx[0],stats[i].if_rx[1],stats[i].if_rx[2]);
-        Debug_printf(">core rx stats:  %d \n",stats[i].core_rx);
+        printf(">if rx stats:  %d %d %d\n",stats[i].if_rx[0],stats[i].if_rx[1],stats[i].if_rx[2]);
+        printf(">core rx stats:  %d \n",stats[i].core_rx);
 
         if (stats[i].rx && stats[i].tx)
-            Debug_printf("decrypt time per packet(avg): %lu, encrypt  time per packet(avg): %lu\n", 
+            printf("decrypt time per packet(avg): %lu, encrypt  time per packet(avg): %lu\n", 
             (unsigned long) stats[i].total_decrypt_time/stats[i].rx, (unsigned long) stats[i].total_encrypt_time/stats[i].tx);
 
 
@@ -439,9 +439,9 @@ NETAPI_SA_STATS_T netapi_sa_stats;
         {
             bcpp_tx = 0L;
         }
-        Debug_printf(">         ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
+        printf(">         ++ busy cycles pp=%lld (%lld wo cache ops) (app+tx= %lld) (tx= %lld) ++\n",
          bcpp,bcpp_noc,bcpp_app, bcpp_tx);
-        Debug_printf("\n");
+        printf("\n");
     }
 
 #ifdef MULTI_THREAD
@@ -461,50 +461,50 @@ netapi_schedGetStats(our_sched, &npL,&cyclesL,&ccyclesL);
 
 if(pPaStats)
 {
-       Debug_printf("C1 number of packets:           %d\n", pPaStats->classify1.nPackets);
-       Debug_printf("C1 number IPv4 packets:         %d\n", pPaStats->classify1.nIpv4Packets);
-       Debug_printf("C1 number IPv6 packets:        %d\n", pPaStats->classify1.nIpv6Packets);
-       Debug_printf("C1 number Custom packets:        %d\n", pPaStats->classify1.nCustomPackets);
-       Debug_printf("C1 number SRIO packets:        %d\n", pPaStats->classify1.nSrioPackets);
-       Debug_printf("C1 number LLC/SNAP Fail packets:        %d\n", pPaStats->classify1.nLlcSnapFail);
-       Debug_printf("C1 number table matched:        %d\n", pPaStats->classify1.nTableMatch);
-       Debug_printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
-       Debug_printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
-       Debug_printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
-       Debug_printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
-       Debug_printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
-       Debug_printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
-       Debug_printf ("C1 number of parse fail:        %d\n",pPaStats->classify1.nParseFail);
-       Debug_printf("C1 number of Invalid IPv6 Opt:  %d\n", pPaStats->classify1.nInvalidIPv6Opt);
-       Debug_printf("C1 number of TX IP Fragments:  %d\n", pPaStats->classify1.nTxIpFrag);
-       Debug_printf ("C1 number of silent discard:    %d\n",pPaStats->classify1.nSilentDiscard);
-       Debug_printf("C1 number of invalid control:   %d\n", pPaStats->classify1.nInvalidControl);
-       Debug_printf ("C1 number of invalid states:    %d\n",pPaStats->classify1.nInvalidState);
-       Debug_printf ("C1 number of system fails:      %d\n",pPaStats->classify1.nSystemFail);
-       Debug_printf ("C2 number Packets  :           %d\n",pPaStats->classify2.nPackets);
-       Debug_printf ("C2 number udp           :      %d\n",pPaStats->classify2.nUdp);
-       Debug_printf ("C2 number tcp           :      %d\n",pPaStats->classify2.nTcp);
-       Debug_printf ("C2 number Custom       :      %d\n",pPaStats->classify2.nCustom);
-       Debug_printf ("C2 number silent drop   :      %d\n",pPaStats->classify2.nSilentDiscard);
-       Debug_printf ("C2 number invalid cntrl :      %d\n\n",pPaStats->classify2.nInvalidControl);
-       Debug_printf ("C2 number Modify Stats Cmd Fail :      %d\n\n",pPaStats->modify.nCommandFail);
+       printf("C1 number of packets:           %d\n", pPaStats->classify1.nPackets);
+       printf("C1 number IPv4 packets:         %d\n", pPaStats->classify1.nIpv4Packets);
+       printf("C1 number IPv6 packets:        %d\n", pPaStats->classify1.nIpv6Packets);
+       printf("C1 number Custom packets:        %d\n", pPaStats->classify1.nCustomPackets);
+       printf("C1 number SRIO packets:        %d\n", pPaStats->classify1.nSrioPackets);
+       printf("C1 number LLC/SNAP Fail packets:        %d\n", pPaStats->classify1.nLlcSnapFail);
+       printf("C1 number table matched:        %d\n", pPaStats->classify1.nTableMatch);
+       printf("C1 number failed table matched: %d\n", pPaStats->classify1.nNoTableMatch);
+       printf("C1 number IP Fragmented packets: %d\n", pPaStats->classify1.nIpFrag);
+       printf("C1 number IP Depth Overflow: %d\n", pPaStats->classify1.nIpDepthOverflow);
+       printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);
+       printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);
+       printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);
+       printf ("C1 number of parse fail:        %d\n",pPaStats->classify1.nParseFail);
+       printf("C1 number of Invalid IPv6 Opt:  %d\n", pPaStats->classify1.nInvalidIPv6Opt);
+       printf("C1 number of TX IP Fragments:  %d\n", pPaStats->classify1.nTxIpFrag);
+       printf ("C1 number of silent discard:    %d\n",pPaStats->classify1.nSilentDiscard);
+       printf("C1 number of invalid control:   %d\n", pPaStats->classify1.nInvalidControl);
+       printf ("C1 number of invalid states:    %d\n",pPaStats->classify1.nInvalidState);
+       printf ("C1 number of system fails:      %d\n",pPaStats->classify1.nSystemFail);
+       printf ("C2 number Packets  :           %d\n",pPaStats->classify2.nPackets);
+       printf ("C2 number udp           :      %d\n",pPaStats->classify2.nUdp);
+       printf ("C2 number tcp           :      %d\n",pPaStats->classify2.nTcp);
+       printf ("C2 number Custom       :      %d\n",pPaStats->classify2.nCustom);
+       printf ("C2 number silent drop   :      %d\n",pPaStats->classify2.nSilentDiscard);
+       printf ("C2 number invalid cntrl :      %d\n\n",pPaStats->classify2.nInvalidControl);
+       printf ("C2 number Modify Stats Cmd Fail :      %d\n\n",pPaStats->modify.nCommandFail);
 }
 Pktlib_getHeapStats(ourHeap, &pktLibHeapStats);
-Debug_printf("main heap stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
+printf("main heap stats>  #free=%d #zb=%d #garbage=%d\n", pktLibHeapStats.numFreeDataPackets,
                                 pktLibHeapStats.numZeroBufferPackets, pktLibHeapStats.numPacketsinGarbage);
-Debug_printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n", 
+printf("               >  #dataBufThreshStatus=%d #dataBufStarvCounter=%d #zBufThreshStatus=%d #zBufStarvCounter=%d \n", 
                         pktLibHeapStats.dataBufferThresholdStatus,pktLibHeapStats.dataBufferStarvationCounter,
                         pktLibHeapStats.zeroDataBufferThresholdStatus, pktLibHeapStats.zeroDataBufferStarvationCounter);
 
 #if 0
-Debug_printf("pa2sa descriptor area dump\n");
+netapi_Log("pa2sa descriptor area dump\n");
 for(i=0;i<TUNE_NETAPI_CONFIG_MAX_PA_TO_SA_DESC;i++)
 {
    extern long * pa2sa_descr_base;
    long * tip= &pa2sa_descr_base[32*i]; 
    dump_descr(tip, i);
 }
-Debug_printf("sa2pa descriptor area dump\n");
+netapi_Log("sa2pa descriptor area dump\n");
 for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
 {
    extern long * sa2pa_descr_base;
@@ -549,7 +549,7 @@ for(i=0;i<TUNE_NETAPI_CONFIG_MAX_SA_TO_PA_DESC;i++)
             }
         }
         else
-            Debug_printf("our_stats_cb: invalid SA direction\n");
+            netapi_Log("our_stats_cb: invalid SA direction\n");
     }
     netapi_dump_internal_heap_stats();
 }
@@ -611,7 +611,7 @@ void parse_mac_address(netTestConfigFile_t *pConfig)
             sscanf(&pConfig->switch_port[i][0],"sp%d",&netTestCfg.switch_port[i]);
         }
     }
-    Debug_printf("parse_mac_address: number of mac address %d\n", netTestCfg.num_macs);
+    netapi_Log("parse_mac_address: number of mac address %d\n", netTestCfg.num_macs);
 
 }
 void parse_ip_address(netTestConfigFile_t *pConfig)
@@ -627,7 +627,7 @@ void parse_ip_address(netTestConfigFile_t *pConfig)
             sscanf(&pConfig->attach_iface[i][0],"mac%d",&netTestCfg.attach_iface[i]);
         }
     }
-    Debug_printf("parse_ip_address: number of ip address %d\n", netTestCfg.num_ips);
+    netapi_Log("parse_ip_address: number of ip address %d\n", netTestCfg.num_ips);
 }
 void parse_ipsec_mode(netTestConfigFile_t *pConfig)
 {
@@ -644,7 +644,7 @@ void parse_ipsec_mode(netTestConfigFile_t *pConfig)
         }
         else
         {
-            Debug_printf("parse_ipsec_mode(), invalid RX ipsec mode in config file \n");
+            netapi_Log("parse_ipsec_mode(), invalid RX ipsec mode in config file \n");
         }
     }
 
@@ -660,7 +660,7 @@ void parse_ipsec_mode(netTestConfigFile_t *pConfig)
         }
         else
         {
-            Debug_printf("parse_ipsec_mode(), invalid TX ipsec mode in config file \n");
+            netapi_Log("parse_ipsec_mode(), invalid TX ipsec mode in config file \n");
         }
     }
 
@@ -670,7 +670,7 @@ void parse_auth_mode(char *auth_mode_str, nwal_saAALG *auth_mode)
 {
     if (strlen(auth_mode_str))
     {
-        Debug_printf("strlen of auth_mode_str is %d\n", strlen(auth_mode_str));
+        netapi_Log("strlen of auth_mode_str is %d\n", strlen(auth_mode_str));
 
         if (strcmp(auth_mode_str, "NULL") == 0)
         {
@@ -702,7 +702,7 @@ void parse_auth_mode(char *auth_mode_str, nwal_saAALG *auth_mode)
         }
         else
         {
-            Debug_printf("parse_auth_mode: invalid auth mode specified\n");
+            netapi_Log("parse_auth_mode: invalid auth mode specified\n");
         }
     }
 }
@@ -741,7 +741,7 @@ void parse_encr_mode(char *ency_mode_str, nwal_saEALG*encr_mode)
         }
         else
         {
-            Debug_printf("parse_encr_mode: invalid auth mode specified\n");
+            netapi_Log("parse_encr_mode: invalid auth mode specified\n");
         }
     }
 }
@@ -753,16 +753,16 @@ void parse_proto(char *proto_str, nwal_IpSecProto *proto)
         if (strcmp(proto_str, "ESP") == 0)
         {
             *proto= nwal_IpSecProtoESP;
-            Debug_printf("parse_proto(): setting proto  to ESP\n");
+            netapi_Log("parse_proto(): setting proto  to ESP\n");
         }
         else if (strcmp(proto_str, "AH") == 0)
         {
             *proto = nwal_IpSecProtoAH;
-            Debug_printf("parse_proto(): setting proto to AH\n");
+            netapi_Log("parse_proto(): setting proto to AH\n");
         }
         else
         {
-            Debug_printf("parse_proto(), invalid RX ipsec mode in config file \n");
+            netapi_Log("parse_proto(), invalid RX ipsec mode in config file \n");
         }
     }
 }
@@ -783,7 +783,7 @@ void parse_mode(char *mode_str, nwal_saMode *mode)
         }
         else
         {
-            Debug_printf("parse_mode(), invalid RX ipsec mode in config file \n");
+            netapi_Log("parse_mode(), invalid RX ipsec mode in config file \n");
         }
     }
 }
@@ -802,7 +802,7 @@ void parse_ipType(char *ip_type_str, nwal_IpType *ipType)
         }
         else
         {
-            Debug_printf("parse_ipType(), invalid RX ipsec mode in config file \n");
+            netapi_Log("parse_ipType(), invalid RX ipsec mode in config file \n");
         }
     }
 }
@@ -851,7 +851,7 @@ void parse_dir(char* dir_str, nwal_SaDir *dir)
             *dir = NWAL_SA_DIR_OUTBOUND;
         }
         else
-            Debug_printf("parse_dir: invalid direction\n");
+            netapi_Log("parse_dir: invalid direction\n");
     }
 }
 void parse_one_fp(char * p_fp_str, uint8_t* start, uint8_t* end)
@@ -863,7 +863,7 @@ void parse_one_fp(char * p_fp_str, uint8_t* start, uint8_t* end)
     *start = atoi(pch);
     pch = strtok (NULL,"-");
     *end = atoi(pch);
-    Debug_printf("parse_one_fp: start %d, end %d\n", *start, *end);
+    netapi_Log("parse_one_fp: start %d, end %d\n", *start, *end);
 }
 
 
@@ -881,10 +881,10 @@ void parse_sp(netTestConfigFile_t *pConfig)
         if (strlen(&pConfig->sp_thread_num[i][0]))
         {
             netTestCfg.sp_thread_num[i] = atoi((char*)(&pConfig->sp_thread_num[i]));
-            Debug_printf("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
+            netapi_Log("parse_sp: thread_num[%d]: %d\n", i, netTestCfg.sp_thread_num[i]);
         }
     }
-    Debug_printf("parse_sp: number of sp threads  %d\n", netTestCfg.num_sp_threads);
+    netapi_Log("parse_sp: number of sp threads  %d\n", netTestCfg.num_sp_threads);
 
 }
 
@@ -903,10 +903,10 @@ void parse_fp(netTestConfigFile_t *pConfig)
         if (strlen(&pConfig->fp_thread_num[i][0]))
         {
             netTestCfg.fp_thread_num[i] = atoi((char*)(&pConfig->fp_thread_num[i]));
-            Debug_printf("parse_fp: thread_num[%d]: %d\n", i, netTestCfg.fp_thread_num[i]);
+            netapi_Log("parse_fp: thread_num[%d]: %d\n", i, netTestCfg.fp_thread_num[i]);
         }
     }
-    Debug_printf("parse_fp: number of fp threads  %d\n", netTestCfg.num_fp_threads);
+    netapi_Log("parse_fp: number of fp threads  %d\n", netTestCfg.num_fp_threads);
 
 }
 
@@ -916,7 +916,7 @@ void parse_ipsec_if_no(netTestConfigFile_t *pConfig)
     if (strlen(&pConfig->ipsec_if_no[0]))
     {
         netTestCfg.ipsec_if_no= atoi(&pConfig->ipsec_if_no[0]);
-        Debug_printf("parse_ipsec_if_no %d\n",netTestCfg.ipsec_if_no);
+        netapi_Log("parse_ipsec_if_no %d\n",netTestCfg.ipsec_if_no);
     }
 }
 
@@ -964,7 +964,7 @@ void parse_routes(netTestConfigFile_t *pConfig)
         {
             port=atoi(&pConfig->ports[i][0]);
           if((port<1)||(port>2)) continue; //bad port #: only 1 or 2 valid
-          Debug_printf("parse_routes [%d]: %s\n", i, &pConfig->routes[i][0]);
+          netapi_Log("parse_routes [%d]: %s\n", i, &pConfig->routes[i][0]);
           if(strncmp(&pConfig->routes[i][0],"MAC",3)==0)
           {
              routes[i].out_port = port;
@@ -997,7 +997,7 @@ void parse_routes(netTestConfigFile_t *pConfig)
          n_dst_ips+=1;
       }
     }
-//Debug_printf(">Route DB built.  %d entries\n",n_dst_ips);
+//netapi_Log(">Route DB built.  %d entries\n",n_dst_ips);
 }
 
 void parse_config_file(FILE * fpr, netTestConfigFile_t *pConfig)
@@ -1059,7 +1059,7 @@ void parse_config_file(FILE * fpr, netTestConfigFile_t *pConfig)
         sprintf(temp_str,"sa%d",sa_count);
         if(strcmp(key, temp_str) == 0)
         {
-            Debug_printf("parse_config_file, temp_str %s, sa_count: %d\n", temp_str, sa_count);
+            netapi_Log("parse_config_file, temp_str %s, sa_count: %d\n", temp_str, sa_count);
             CHECK_SET_PARAM_SA(temp_str, 
                                                 (char*)&pConfig->sa_config[sa_count].dir,
                                                 (char*)&pConfig->sa_config[sa_count].spi,
@@ -1175,10 +1175,10 @@ void house(NETAPI_SCHED_HANDLE_T * s)
     Cppi_HostDesc*      pPktDesc;
     NETAPI_SCHED_SHUTDOWN_T sched_shutdown;
 
-    int coreid = 0;  //who we are
+    uint32_t coreid = 0;  //who we are
 #ifdef MULTI_THREAD
     NETAPI_T nh= netapi_schedGetHandle(s);
-    coreid=(int) netapi_getCookie(nh);
+    coreid=(uint32_t) netapi_getCookie(nh);
 
     if (QUIT) 
     {
@@ -1187,17 +1187,22 @@ void house(NETAPI_SCHED_HANDLE_T * s)
         return;
     }
 
-    if (coreid==0) //slave
+    
+    /* only slow path threads get netcp stats */
+    if (coreid & NET_TEST_SP_THREAD_MASK)
     {
-    netcp_cfgReqStats(nh, our_stats_cb_mt, 0,&err); 
+        netapi_netcpCfgReqStats(nh, our_stats_cb_mt, 0,&err); 
     }
+
+    coreid = NET_TEST_THREAD_NUM_MASK & coreid;
 #else
+    coreid = NET_TEST_THREAD_NUM_MASK & coreid;
     if(done_burst)
     {
         house_pkts_gened+=TX_BURST;
-        Debug_printf("net_test> request stats at n=%d \n",house_pkts_gened);
-        netcp_cfgReqStats(netapi_handle, our_stats_cb, 0,&err);
-        if (err!=0) {Debug_printf("stats req failed\n");}
+        netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
+        netapi_netcpCfgReqStats(netapi_handle, our_stats_cb, 0,&err);
+        if (err!=0) {netapi_Log("stats req failed\n");}
         if (house_pkts_gened >= np2process+ 100)
         {
             sched_shutdown.shutdown_type = NETAPI_SCHED_SHUTDOWN_NOW;
@@ -1212,9 +1217,9 @@ void house(NETAPI_SCHED_HANDLE_T * s)
     //reguest stats 
     if ((house_pkts_gened>0) && (! (house_pkts_gened%1000)) )
     {
-       Debug_printf("net_test> request stats at n=%d \n",house_pkts_gened);
-       netcp_cfgReqStats(netapi_handle, our_stats_cb, 0,&err); 
-       if (err!=0) {Debug_printf("stats req failed\n");}
+       netapi_Log("net_test> request stats at n=%d \n",house_pkts_gened);
+       netapi_netcpCfgReqStats(netapi_handle, our_stats_cb, 0,&err); 
+       if (err!=0) {netapi_Log("stats req failed\n");}
     }
 
 
@@ -1283,7 +1288,7 @@ void house(NETAPI_SCHED_HANDLE_T * s)
                              &meta_tx,
                              &flowPSCmdInfo) != nwal_OK)
         {
-            Debug_printf("nwal_initPSCmdInfo() ERROR \n");
+            netapi_Log("nwal_initPSCmdInfo() ERROR \n");
         }
         nwal_flow_vv2= hplib_mUtilGetPmuCCNT();
         nwal_sum_flow_vv1 += (nwal_flow_vv1-vv1); 
@@ -1322,7 +1327,7 @@ void house(NETAPI_SCHED_HANDLE_T * s)
 
     sum_vv3 += (vv3-vv2)-(long) (cache_op_b2-cache_op_b1); //sub out cache op cost
 
-    // Debug_printf("pktio send. full=%d metadata=%d pktio_send=%d\n", vv3-vv1,  vv2-vv1,  vv3-vv2);
+    // netapi_Log("pktio send. full=%d metadata=%d pktio_send=%d\n", vv3-vv1,  vv2-vv1,  vv3-vv2);
     stats[coreid].itx +=1;
     house_pkts_gened +=1;
     }
@@ -1331,11 +1336,11 @@ void house(NETAPI_SCHED_HANDLE_T * s)
         ccycles =Osal_cache_op_measure(&n_c_ops);
         if (sum_vv1) 
         {
-            Debug_printf("BURST NWAL Fast send %d pkts.  metadata=%d Cmd Label Creation Cost=%d  nwal Fast Send Cost (less cacheop)= %d n_c_ops=%lld cache_op_time=%lld (pp-> %d)\n", 
+            netapi_Log("BURST NWAL Fast send %d pkts.  metadata=%d Cmd Label Creation Cost=%d  nwal Fast Send Cost (less cacheop)= %d n_c_ops=%lld cache_op_time=%lld (pp-> %d)\n", 
               stats[coreid].itx, sum_vv1/stats[coreid].itx,  nwal_sum_flow_vv2, sum_vv3/stats[coreid].itx, 
               n_c_ops, ccycles, n_c_ops? (ccycles/(n_c_ops/2L)) : 0);
 #if 0
-            Debug_printf("NWAL Profile Cycles: Prof1= %d,Prof2=%d,Prof3=%d,Prof4=%d,Prof5=%d ,Prof6=%d \n",
+            netapi_Log("NWAL Profile Cycles: Prof1= %d,Prof2=%d,Prof3=%d,Prof4=%d,Prof5=%d ,Prof6=%d \n",
               nwal_sum_vv1/stats[coreid].itx,nwal_sum_vv2/stats[coreid].itx,nwal_sum_vv3/stats[coreid].itx,
               nwal_sum_vv4/stats[coreid].itx,nwal_sum_vv5/stats[coreid].itx,nwal_sum_vv6/stats[coreid].itx);
   
@@ -1343,7 +1348,7 @@ void house(NETAPI_SCHED_HANDLE_T * s)
 
             if(stats[core_id].itx2)
             {
-                Debug_printf("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
+                netapi_Log("nwal_flowSend Profile Cycles: Prof1= %d,Prof2=%d \n",
                 nwal_sum_flow_vv1/stats[coreid].itx2,nwal_sum_flow_vv2/stats[coreid].itx2);
             }
         }
@@ -1358,7 +1363,7 @@ void create_interfaces(void)
     for (i = 0; i < netTestCfg.num_macs; i++)
     {
         /* add mac intefaces */
-        mac[i] = netcp_cfgCreateMacInterface(
+        mac[i] = netapi_netcpCfgCreateMacInterface(
                           netapi_handle,
                           &netTestCfg.mac[i][0],
                           i,
@@ -1369,16 +1374,16 @@ void create_interfaces(void)
                           &err);
        if (err)
        {
-            Debug_printf("addmac %d  failed %d\n",i, err);
+            netapi_Log("addmac %d  failed %d\n",i, err);
         //exit(1); 
        }
        else
-        Debug_printf("create_interfaces, added mac sucess\n");
+        netapi_Log("create_interfaces, added mac sucess\n");
     }
     for (i = 0; i < netTestCfg.num_ips; i++)
     {
         //attach an IP to this interface
-        ip_rule[i]=netcp_cfgAddIp(
+        ip_rule[i]=netapi_netcpCfgAddIp(
                           netapi_handle,
                           netTestCfg.attach_iface[i],
                           nwal_IPV4,
@@ -1389,11 +1394,11 @@ void create_interfaces(void)
                           &err
                           );
         if (err) {
-            Debug_printf("addip %d failed %d\n", i, err);
+            netapi_Log("addip %d failed %d\n", i, err);
         //exit(1); 
         }
         else
-            Debug_printf("create_interfaces, added ip sucess\n");
+            netapi_Log("create_interfaces, added ip sucess\n");
     }
 }
 
@@ -1405,17 +1410,17 @@ void delete_interfaces(void)
     for (i = 0; i < netTestCfg.num_ips; i++)
     {
         err = 0;
-        netcp_cfgDelIp(netapi_handle, netTestCfg.attach_iface[i], nwal_IPV4, 
+        netapi_netcpCfgDelIp(netapi_handle, netTestCfg.attach_iface[i], nwal_IPV4, 
                       NULL, NULL, ip_rule[i], &err);
     }
     for (i = 0; i < netTestCfg.num_macs; i++)
     {
         err = 0;
-        netcp_cfgDelMac(netapi_handle,i,&err);
+        netapi_netcpCfgDelMac(netapi_handle,i,&err);
     }
     
-    //netcp_cfgDelMac(netapi_handle,0,&err);
-    //netcp_cfgDelMac(netapi_handle,1,&err);
+    //netapi_netcpCfgDelMac(netapi_handle,0,&err);
+    //netapi_netcpCfgDelMac(netapi_handle,1,&err);
 
 }
 
index ba07d53a55edcedeb14a4715df4244167f723ba7..07bf17786f17275e7b72efc26945e7963df1e835 100755 (executable)
@@ -36,6 +36,9 @@
 
 #define PKT_LEN 1400
 
+#define NET_TEST_SP_THREAD_MASK 0xF0000000
+#define NET_TEST_THREAD_NUM_MASK 0x000000FF
+
 typedef struct {
     unsigned char           mac[NET_TEST_MAX_MAC][6];
     uint8_t                 num_macs;
@@ -164,7 +167,7 @@ void house(NETAPI_SCHED_HANDLE_T *s);
 
 void create_interfaces(void);
 void delete_interfaces(void);
-void slow_path_thread(int coreid);
-void fast_path_thread(int coreid);
+void slow_path_thread(uint32_t coreid);
+void fast_path_thread(uint32_t coreid);
 #endif
 
index 85496e1625729f238875ac8f08cc1a46886aeca6..b407c52de3b39d662f602054b68e59f779d7b90a 100755 (executable)
@@ -296,7 +296,7 @@ main()
 Trie * p_trie;
 char * p_res;
 p_trie = trie_new();
-if (!p_trie) {Debug_printf("trie alloc failed\n"); exit(1);}
+if (!p_trie) {netapi_Log("trie alloc failed\n"); exit(1);}
 
 trie_insert(p_trie,"key1","this is key 1");
 trie_insert(p_trie,"key12","this is key 2");
@@ -304,22 +304,22 @@ trie_insert(p_trie,"key3","this is key 3");
 trie_insert(p_trie,"key4","this is key 4");
 
 p_res= trie_lookup(p_trie,"key1");
-Debug_printf("lookup %s = %s\n", "key1", p_res ?  p_res : "not found");
+netapi_Log("lookup %s = %s\n", "key1", p_res ?  p_res : "not found");
 
 p_res= trie_lookup(p_trie,"key12");
-Debug_printf("lookup %s = %s\n", "key2", p_res ?  p_res : "not found");
+netapi_Log("lookup %s = %s\n", "key2", p_res ?  p_res : "not found");
 
 p_res= trie_lookup(p_trie,"key3");
-Debug_printf("lookup %s = %s\n", "key3", p_res ?  p_res : "not found");
+netapi_Log("lookup %s = %s\n", "key3", p_res ?  p_res : "not found");
 
 p_res= trie_lookup(p_trie,"key4");
-Debug_printf("lookup %s = %s\n", "key4", p_res ?  p_res : "not found");
+netapi_Log("lookup %s = %s\n", "key4", p_res ?  p_res : "not found");
 
 p_res= trie_lookup(p_trie,"key5");
-Debug_printf("lookup %s = %s\n", "key5", p_res ?  p_res : "not found");
+netapi_Log("lookup %s = %s\n", "key5", p_res ?  p_res : "not found");
 
 p_res= trie_lookup(p_trie,"k5");
-Debug_printf("lookup %s = %s\n", "k5", p_res ?  p_res : "not found");
+netapi_Log("lookup %s = %s\n", "k5", p_res ?  p_res : "not found");
 
 trie_free(p_trie);
 
index 12101b761d290961e683abd3e6a42b7367405aac..6833ab302187ee0724711950cc3b224be2c7cba5 100755 (executable)
 //dump_descr
 void dump_descr(unsigned long *p, int n)
 {
-   Debug_printf("--------dump of descriptor %d %x\n", n, (int) p);
-   Debug_printf("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
-   Debug_printf("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
-   Debug_printf("-----------------------------\n");
+   netapi_Log("--------dump of descriptor %d %x\n", n, (int) p);
+   netapi_Log("> %x %x %x %x %x %x %x %x\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
+   netapi_Log("> %x %x %x %x %x %x %x %x\n",p[8],p[9],p[10],p[11],p[12],p[13],p[14],p[15]);
+   netapi_Log("-----------------------------\n");
 }
 
 static inline unsigned long netapi_timing_start(void)
@@ -74,7 +74,7 @@ static inline unsigned long netapi_timing_stop(void)
 }
 
   
-#define FATAL do { fDebug_printf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
+#define FATAL do { fprintf(stderr, "Error at line %d, file %s (%d) [%s]\n", \
   __LINE__, __FILE__, errno, strerror(errno)); exit(1); } while(0)
  
 #define MAP_SIZE 4096UL
@@ -99,7 +99,7 @@ int num2dump=32;
 
        
        if(argc < 2) {
-               fDebug_printf(stderr, "\nUsage:\t%s { address } nun ] ]\n"
+               fprintf(stderr, "\nUsage:\t%s { address } nun ] ]\n"
                        "\taddress : memory address to act upon\n"
                        "\tnum    : #descriptors to be dumped (def 32)\n\n",
                        argv[0]);
@@ -110,13 +110,13 @@ int num2dump=32;
 
 
     if((fd = open("/dev/mem", ((cached) ? (O_RDWR) : (O_RDWR | O_SYNC)))) == -1) FATAL;
-    Debug_printf("/dev/mem opened.\n"); 
+    netapi_Log("/dev/mem opened.\n"); 
     fflush(stdout);
     
     /* Map one page */
     map_base = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, target & ~MAP_MASK);
     if(map_base == (void *) -1) FATAL;
-    Debug_printf("Memory mapped at address %p. (cached=%d)\n", map_base,cached); 
+    netapi_Log("Memory mapped at address %p. (cached=%d)\n", map_base,cached); 
     fflush(stdout);
     
     virt_addr = map_base + (target & MAP_MASK);