]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/netapi.git/commitdiff
SDOCM00112200: Making NETAPI tuneable parameters configurable in code
authorTinku Mannan <tmannan@ti.com>
Tue, 11 Nov 2014 20:15:45 +0000 (15:15 -0500)
committerTinku Mannan <tmannan@ti.com>
Tue, 11 Nov 2014 20:15:45 +0000 (15:15 -0500)
16 files changed:
ti/runtime/netapi/applications/ipsec_offload/ipsecmgr/src/netapi_ipsecmgr.c
ti/runtime/netapi/netapi.h
ti/runtime/netapi/netapi_tune.h
ti/runtime/netapi/netcp_cfg.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/netcp_cfg.c
ti/runtime/netapi/test/ifdma_test.c
ti/runtime/netapi/test/net_test_bench.c
ti/runtime/netapi/test/net_test_config.txt
ti/runtime/netapi/test/net_test_loopback.c
ti/runtime/netapi/test/net_test_max_params.c
ti/runtime/netapi/test/net_test_router.c
ti/runtime/netapi/test/nt_bridge.c
ti/runtime/netapi/utils/netapi_util_rm.c

index 0fb26c1e057085b6f1130d06abaa8fdc2a431f9a..d3129d6a1c4e8a149e7370a926c6b4e4e9a79962 100755 (executable)
@@ -135,7 +135,9 @@ static NETAPI_CFG_T our_netapi_default_cfg=
     128,    //tail room
     256,    //extra room
     0,
-    NULL
+    NULL,
+    0,
+    0
 };
 
 
index 4d5955cac5cc9c76a20fd7f6a18ee0cbef6ab194..e1225c5156fc1b58b74f3a6ba0336cd82431ca86 100755 (executable)
@@ -302,6 +302,17 @@ void netapi_netcpPoll(NETAPI_T  p);
  */
 void netapi_pollHeapGarbage(NETAPI_T p);
 
+/**
+ *  @ingroup netapi_gen_functions
+ *  @brief netapi_getMemoryRegionId  API is used to return configured descriptor
+ *         memory region Id
+ *
+ *  @details  API is used to return configured descriptor memory region Id
+ *  @param[in]  p   The NETAPI handle, @ref NETAPI_T
+ *  @retval     Memory Resgion Id, -1 on error
+ *  @pre        @ref netapi_init
+ */
+int netapi_getMemoryRegionId(NETAPI_T  p);
 #ifdef __cplusplus
 }
 #endif
index 76972e6b31d5c2129c8a2c53af793d92337929d2..e813fa3b4799e54d321b584e7c1df6a3e50fc84a 100755 (executable)
@@ -182,44 +182,6 @@ extern "C" {
  */
 #define TUNE_NETAPI_DESC_SIZE  128
 
-#ifdef NETAPI_USE_DDR
-/**
- * @ingroup tune_parameters
- * @def  TUNE_NETAPI_QM_START_INDEX
- *      This defines the queue manager start index
- * @note This must reflect what the kernel is uding for their region, see device tree blob for details.
- */
-#define TUNE_NETAPI_QM_START_INDEX  0x2000  //WARNING:  must reflect what kernel is using for their region, see device tree blob
-
-//#define TUNE_NETAPI_QM_START_INDEX  0
-/**
- * @ingroup tune_parameters
- * @def  TUNE_NETAPI_QM_GLOBAL_REGION
- *      This defines the queue manager global region
- * @note This must reflect what the kernel is using for their region, see device tree blob for details.
- */
-#define TUNE_NETAPI_QM_GLOBAL_REGION 18  //WARNING: must reflect what kernel is using for their region, see device tree blob
-//#define TUNE_NETAPI_QM_GLOBAL_REGION 0  //WARNING: must reflect what kernel is using for their region, see device tree blob
-
-#else //use msmc..
-/**
- * @ingroup tune_parameters
- * @def  TUNE_NETAPI_QM_START_INDEX
-  *     This defines the queue manager start index
- * @note This must reflect what the kernel is uding for their region, see device tree blob for details.
- */
-#define TUNE_NETAPI_QM_START_INDEX  0  //ok to use 0 since kernel is somewhere higher
-
-/**
- * @ingroup tune_parameters
- * @def  TUNE_NETAPI_QM_GLOBAL_REGION
- *      This defines the queue manager global region
- * @note This must reflect what the kernel is uding for their region, see device tree blob for details.
- */
-#define  TUNE_NETAPI_QM_GLOBAL_REGION 0  //ok to use 0 since msmc addr < ddr addr 
-
-#endif
-
 /**
  * @ingroup tune_parameters
  * @def TUNE_NETAPI_NWAL_ENABLE_PASS_LOOPBACK
index dd0cde68b2553d40c9d62873cc3860f03cda615f..a668fd40d5476ab19ef1d747e8361413b934015b 100755 (executable)
@@ -89,6 +89,22 @@ typedef struct NETAPI_CFG_Tag
  int def_heap_extra_size;           /**<  Size of extra space at end of buffer */ 
  int def_multi_process;             /**<  Flag to indicate if NETAPI init is for multi-process environment */
  void *rmHandle;                    /**<  Optional: Resource Manager (RM) server handle to use RM for re                                                    souce allocations*/
+ int memoryRegion;                  /**<  Optional: Specify the descriptor memory region to be used,
+                                          must be a valid memory  region index
+                                          (0 to Maximum number of memory regions supported
+                                          Not used when using Resouce Manager(RM)as QMSS via RM will
+                                          return available Memory Region Id.
+                                          */
+ int start_index;                   /**<  Optional: Used to leave holes by configuring dummy regions which
+                                          can be later configured with actual values. May either be
+                                          specified by the user (for example, to select "internal" or
+                                          "external" linking RAM, or set to QMSS_START_INDEX_NOT_SPECIFIED,
+                                          QMSS_PARAM_NOT_SPECIFIED to have LLD/RM select a compatible startIndex
+                                          from anywhere with free indicies, or QMSS_START_INDEX_INTERNAL.
+                                          for internal linking RAM, QMSS_START_INDEX_EXTERNAL for external linking RAM. 
+                                          Not used when using Resouce Manager(RM)as QMSS via RM will
+                                          return available Memory Region Id and determine avialable start index.
+                                          */
 }  NETAPI_CFG_T;
 
 /* @note:
index 7c005e29cf75e17a3c19e8b83c8bb326675896a8..a97feb7bca2a45d2e501a16446415889e6690e9b 100755 (executable)
@@ -460,4 +460,16 @@ void netapi_netcpPoll(NETAPI_T  p)
     NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) p;
     nwal_pollCtl( ((NETAPI_GLOBAL_T *) (n->global))->nwal_context.nwalInstHandle,NULL,NULL);
 }
-
+/**************************************************************************************
+* FUNCTION PURPOSE:  API is used to return configured descriptor memory region Id.
+***************************************************************************************
+* DESCRIPTION:  This API is used to return the configured descriptor memory region Id.
+**************************************************************************************/
+int netapi_getMemoryRegionId(NETAPI_T  p)
+{
+    NETAPI_HANDLE_T * n = (NETAPI_HANDLE_T *) p;
+    if(netapi_proc_master)
+        return (netapi_proc_master->memRegion);
+    else
+        return -1;
+}
index 7a3519a2cf9cb736984fc8d5b6f6df6018beb37a..b193630fc048c6c4d0795b5cb90ae1d87c777bc7 100755 (executable)
@@ -140,49 +140,37 @@ int netapip_qmSetupMemRegion(
                       uint32_t          numDesc,
                       uint32_t          descSize,
                       uint32_t*         pDescMemBase,
-                      int               memRegion)
+                      int               memRegion,
+                      int               start_index)
 {
     //Qmss_MemRegInfo   memInfo;
-    Int32             result;
-    Int               n;
-    static int  netapi_qm_region_index=0;
+    int result;
 
     memset(&memInfo,0,sizeof(Qmss_MemRegInfo));
     memInfo.descBase       = pDescMemBase;
     memInfo.descSize       = descSize;
     memInfo.descNum        = numDesc;
     memInfo.manageDescFlag = Qmss_ManageDesc_MANAGE_DESCRIPTOR;
+
     if (pRmClientHandle)
     {
         memInfo.memRegion = -1;
+        memInfo.startIndex = QMSS_START_INDEX_NOT_SPECIFIED;
     }
     else
     {
         memInfo.memRegion = memRegion;
-        if(memRegion == TUNE_NETAPI_QM_GLOBAL_REGION)
-        {
-            memInfo.startIndex = TUNE_NETAPI_QM_START_INDEX;  //was 0
-            netapi_qm_region_index += numDesc;
-        }else if(memRegion ==NETAPI_LOCAL_REGION)
-        {
-            /* 2nd region for descriptors (perhaps private?) */
-            memInfo.startIndex     = netapi_qm_region_index;
-        }
-        else
-        {
-            return -1 ;
-        }
+        memInfo.startIndex = start_index;
     }
+
     memset (pDescMemBase, 0, (descSize * numDesc));
 
     result = Qmss_insertMemoryRegion (&memInfo);
-    
+
     if (result < QMSS_SOK)  
     {
-        netapi_Log ("netapip_qmSetupMemRegion: Qmss_insertMemoryRegion returned error code %d\n", result);
         return (-1);
     }
-    printf("netapip_qmSetupMemRegion: region: %d\n", memInfo.memRegion);
     netapi_proc_master->memRegion = memInfo.memRegion;
     return 1;
 }
@@ -668,7 +656,6 @@ int netapip_startNwal(Pktlib_HeapHandle pkt_heap,
                  pInstPoolPaBaseAddr = (void *)paEntry;
 
             nwal_getLocContextBufferReq(TUNE_NETAPI_NUM_CORES, &localCtxSize);
-            printf("testNwGlobInit: localCtxSize: 0x%x\n", localCtxSize);
             pNwalLocCtxMem = malloc(localCtxSize);
             if (pNwalLocCtxMem == NULL)
             {
@@ -886,7 +873,8 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
                            pnetapiShm->netapi_global.cfg.def_tot_descriptors_for_us,
                            TUNE_NETAPI_DESC_SIZE,
                            (unsigned int *) netapi_VM_QMemGlobalDescRam,
-                           TUNE_NETAPI_QM_GLOBAL_REGION);
+                           pnetapiShm->netapi_global.cfg.memoryRegion,
+                           pnetapiShm->netapi_global.cfg.start_index);
         if(result <0)
         {
             netapi_Log("netapip_systemInit: can't setup QM shared region\n");
@@ -980,7 +968,7 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
             return -1;
         if (hplib_checkMallocArea(1) != hplib_OK)
             return -1;
-#if 1
+
 #ifdef NETAPI_ENABLE_SECURITY
                 /* 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 *
@@ -1012,7 +1000,6 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
         netapi_Log("netapip_systemInit(procMaster): desc region=%x global desc region=%x\n",
             netapi_VM_QMemLocalDescRam, netapi_VM_QMemGlobalDescRam);
 
-#endif
 
         /****************************************************
          * partial initialization.  For process, not for SOC
@@ -1031,18 +1018,18 @@ int netapip_systemInit(NETAPI_HANDLE_T * handle,
             netapi_Log("netapip_systemInit: returned from netapip_startQm with failure\n");
             return -1;
         }
-#if 1
+
         result= netapip_qmSetupMemRegion( 
                            pnetapiShm->netapi_global.cfg.def_tot_descriptors_for_us,
                            TUNE_NETAPI_DESC_SIZE,
                            (unsigned int *) netapi_VM_QMemGlobalDescRam,
-                           TUNE_NETAPI_QM_GLOBAL_REGION);
+                           pnetapiShm->netapi_global.cfg.memoryRegion,
+                           pnetapiShm->netapi_global.cfg.start_index);
         if(result <0)
         {
             netapi_Log("netapip_systemInit: can't setup QM shared region\n");
             return -1;
         }
-#endif
         /* Initialize CPPI CPDMA */
         result = netapip_initCppi(pRmClientHandle);
         if (result != 1)
index f49a4d022d7587fa1c817d5ce2ffeda374e88b19..81a07b7bfaee3a47885f3e6d0ab60387be30135f 100755 (executable)
@@ -273,10 +273,8 @@ int netapip_initTimer(void);
 int netapip_qmSetupMemRegion(unsigned int          numDesc,
                              unsigned int          descSize,
                              unsigned int*         pDescMemBase,
-                             int                   memRegion);
-
-#define NETAPI_GLOBAL_REGION TUNE_NETAPI_QM_GLOBAL_REGION 
-#define NETAPI_LOCAL_REGION ((NETAPI_GLOBAL_REGION)+1) 
+                             int                   memRegion,
+                             int                   start_index);
 
 
 //nwal callbacks
index 4b08a6f034f5b3a8b0ef2921028b1b56c788c8e8..657885c94deca9c764dad3a430be886decf726af 100755 (executable)
@@ -858,14 +858,6 @@ NETCP_CFG_MACIF_T  netapi_netcpCfgCreateMacInterface(NETAPI_T  h,
                 //macInfo.appRxPktFlowId = route->p_flow;
                 //macInfo.appRxPktQueue = route->p_dest_q;
                 macInfo.routeType = NWAL_ROUTE_PKTTYPE_EQOS;
-                printf("netapi_netcpCfgCreateMacInterface: mac: 0x%x:0x%x:0x%x:0x%x:0x%x:0x%x, swp: 0x%x\n",
-                        macInfo.macAddr[0],
-                        macInfo.macAddr[1],
-                        macInfo.macAddr[2],
-                        macInfo.macAddr[3],
-                        macInfo.macAddr[4],
-                        macInfo.macAddr[5],
-                        macInfo.egress_switch_port);
                 macInfo.matchAction = NWAL_MATCH_ACTION_HOST;
            }
         }
index 50c9ba5c7188b8f842f1a8cf1208238e241f39e5..d02a530debf4ce1c104d5fc1d2cc05af675f7c96 100755 (executable)
@@ -134,7 +134,9 @@ TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
 128   ,  //tail room
 256,      //extra room 
 0,
-NULL
+NULL,
+18,
+0x2000
 };
 
 Pktlib_HeapHandle OurHeap;     //default heap, used by producer
@@ -309,7 +311,7 @@ int main(int argc, char **argv)
 
     /* Populate the heap configuration */
     heapCfg.name                = "netapi-consumer";
-    heapCfg.memRegion           = NETAPI_GLOBAL_REGION;
+    heapCfg.memRegion           = netapi_getMemoryRegionId(netapi_handle);
     heapCfg.sharedHeap          = 1;
     heapCfg.useStarvationQueue  = 0;
     heapCfg.dataBufferSize      = TUNE_NETAPI_DEFAULT_BUFFER_SIZE;
index 95aca3272d01e39795e5c2202a3f81d2e77d1a66..52bb2832dce9c5455bdbfd1b0f69e2f15f733d48 100755 (executable)
@@ -168,7 +168,9 @@ TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
 128,       //tail room
 256,      //extra room
 0,
-NULL
+NULL,
+-1,
+-1
 };
 
 Pktlib_HeapHandle OurHeap;     //default heap, used by producer
index 1011c495ea0fa28cffe8c9e2fb3aa3930d6563e3..b38ccddb506dfbf4b77b77b0711c95f38739ac6d 100755 (executable)
@@ -35,9 +35,9 @@ dest_udp_port_config = 30000
 
 #sa0 = dir spi prot saMode iptype srcip destip window auth cipher esnlo esphi encrkeysize authkeysize encrkey pauthkey tunnel_id
 
-sa0 = INBOUND 0x11111111 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
+sa0 = INBOUND 0x11111111 ESP TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_SHA1 AES_CBC 0 0 16 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x2
 
-sa1 = OUTBOUND 0x11111111 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 32 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23  0x2
+sa1 = OUTBOUND 0x11111111 ESP TUNNEL IPV4 192.168.1.100 192.168.1.10 64 HMAC_SHA1 AES_CBC 0 0 16 20 55,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23  0x2
 
 sa2 = INBOUND 0x44444444 AH TUNNEL IPV4 192.168.1.10 192.168.1.100 64 HMAC_MD5 NULL 0 0 0 16 00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,00,11,22,33,44,55,66,77,88,99,AA,BB,CC,DD,EE,FF,30,31,32,33 00,01,02,03,04,05,06,07,08,09,0A,0B,0C,0D,0E,0F,10,11,12,13,14,15,16,17,18,19,1A,1B,1C,1D,1E,1F,20,21,22,23 0x1
 
index f8b901b292c140d2287365174d53d671dde35462..299c15bab29048aac042076bb76ea7be7fdb461e 100755 (executable)
@@ -124,7 +124,9 @@ static NETAPI_CFG_T our_netapi_default_cfg=
     128, //tail room
     256, //extra room
     0,
-    NULL
+    NULL,
+    -1,
+    -1
 };
 
 NETAPI_T netapi_handle;
index d30a63b5439263cbbe65992483e8d76729ff2565..b90bccee1ec1617323ee7fe88d5df2ebddfe7087 100755 (executable)
@@ -105,7 +105,9 @@ TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
 128,       //tail room
 256,      //extra room
 0,
-NULL
+NULL,
+18,
+0x2000
 };
 
 NETAPI_T netapi_handle;
index 45d693f87c306c44c18e9db854f1326ab1ad8a93..48837d410111a8d17031cfaf147929088f8472e0 100755 (executable)
@@ -129,17 +129,19 @@ extern paSysStats_t netcp_stats;
  *****************************************/
 static NETAPI_CFG_T our_netapi_default_cfg=
 {
-TUNE_NETAPI_PERM_MEM_SZ,
-128,  //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
-64, //#descriptors w/o buffers in default heap
-TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
-128,  //tail room
-256,  //extra room
-0,
-NULL
+    TUNE_NETAPI_PERM_MEM_SZ,
+    128,  //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
+    64, //#descriptors w/o buffers in default heap
+    TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
+    128,  //tail room
+    256,  //extra room
+    0,
+    NULL,
+    -1,
+    -1
 };
 
 
index 53e274ca961e223af5f6ee92420481e344174aa7..436cff3d1d8638d4606f7c86aeea6293158cc2f1 100755 (executable)
@@ -501,7 +501,9 @@ TUNE_NETAPI_DEFAULT_BUFFER_SIZE+128+128,  //size of buffers in default heap
 128,       //tail room
 256,      //extra room,
 0,
-NULL
+NULL,
+18,
+0x2000
 };
 
 Pktlib_HeapHandle OurHeap;     //default heap, used by producer
index ef2908ac478bdde7d9c83169ab3170e6703d9fb8..2c442c386d5045616cd2d8424f9ecf4db1f48b5b 100755 (executable)
@@ -328,7 +328,6 @@ int initRm (void)
     rmClientHandle = Rm_init(&rmInitCfg, &result);
     RM_ERROR_CHECK(RM_OK, result, rmClientName, "Initialization failed");
 
-    printf("\n\nInitialized %s\n\n", rmClientName);
 
     /* Open Client service handle */
     rmClientServiceHandle = Rm_serviceOpenHandle(rmClientHandle, &result);