Renaming demo files to reflect transport, fix stats collection for multi-proc
authorTinku Mannan <tmannan@ti.com>
Fri, 8 Aug 2014 16:39:05 +0000 (12:39 -0400)
committerTinku Mannan <tmannan@ti.com>
Fri, 8 Aug 2014 17:49:49 +0000 (13:49 -0400)
ti/runtime/netapi/demo/src/navl_wrapper.c
ti/runtime/netapi/demo/src/transport_dpi_demo.c [moved from ti/runtime/netapi/demo/src/netapi_dpi_demo.c with 92% similarity]
ti/runtime/netapi/demo/src/transport_dpi_demo.h [moved from ti/runtime/netapi/demo/src/netapi_dpi_demo.h with 100% similarity]

index 27f3be04586d724a4e348b7b1fd5171a12397536..5c3737e77f4f7eadbe0506227a3e32f56c612d65 100755 (executable)
@@ -434,10 +434,10 @@ navl_classify_callback(navl_handle_t handle,
 #endif
                 }
             }
-            idx += sprintf(&buf[idx], "/%s", g_reader->stats_pkt[threadId -1][protoid].name);
+            idx += sprintf(&buf[idx], "/%s", g_reader->stats_pkt[threadId-1][protoid].name);
         }
         printf(" Pkt: %u (%u bytes), Conn: %" PRIu64 ", App: %s (%s), State: %s, Stack: %s, Error: %s\n", packet->sequence
-        , packet->size, packet->connid, g_reader->stats_pkt[threadId -1][packet->appidx].name
+        , packet->size, packet->connid, g_reader->stats_pkt[threadId-1][packet->appidx].name
         , get_confidence_string(confidence), get_state_string(state), buf, get_error_string(error));
     }
 
@@ -473,11 +473,11 @@ navl_classify_callback(navl_handle_t handle,
                        for (idx = 0, it = navl_proto_first(g_reader->navl, result); navl_proto_valid(g_reader->navl, it); navl_proto_next(g_reader->navl, it))
                        {
                                protoid = navl_proto_get_index(g_reader->navl, it);
-                               idx += sprintf(&buf[idx], "/%s", g_reader->stats_pkt[threadId -1][protoid].name);
+                               idx += sprintf(&buf[idx], "/%s", g_reader->stats_pkt[fp_thread][protoid].name);
                        }
 
                        printf(" Pkt: %u (%u bytes), Conn: %" PRIu64 ", App: %s (%s), State: %s, Stack: %s, Error: %s\n"
-                               , packet->sequence, packet->size, conn_id, g_reader->stats_pkt[threadId -1][packet->appidx].name
+                               , packet->sequence, packet->size, conn_id, g_reader->stats_pkt[fp_thread][packet->appidx].name
                                , get_confidence_string(confidence), get_state_string(state), buf, get_error_string(error));
                }
        }
@@ -535,29 +535,29 @@ int navl_process_pkt(unsigned char *p_pkt, int len)
 
     /* Update the stats. If classification was not enabled, then the appidx will be 0 and all packets
      * captured will be accumulated there */
-    g_reader->stats_pkt[threadId -1][packet.appidx].packets++;
-    g_reader->stats_pkt[threadId -1][packet.appidx].bytes += packet.size;
+    g_reader->stats_pkt[threadId-1][packet.appidx].packets++;
+    g_reader->stats_pkt[threadId-1][packet.appidx].bytes += packet.size;
     if(class)
-        g_reader->stats_pkt[threadId -1][packet.appidx].class++;
+        g_reader->stats_pkt[threadId-1][packet.appidx].class++;
     //update timing
     v2 = netapi_timing_start();
     temp=v2-v1;
     mf2= pDpiStats->malloc_cycles + pDpiStats->free_cycles;
     timing+= (unsigned long long) temp;
-    g_reader->stats_pkt[threadId -1][packet.appidx].cycles += (unsigned long long) temp;
-    g_reader->stats_pkt[threadId -1][packet.appidx].cycles_nomem += ((unsigned long long) temp - (mf2-mf1));
+    g_reader->stats_pkt[threadId-1][packet.appidx].cycles += (unsigned long long) temp;
+    g_reader->stats_pkt[threadId-1][packet.appidx].cycles_nomem += ((unsigned long long) temp - (mf2-mf1));
 
-    if (g_reader->stats_pkt[threadId -1][packet.appidx].cycles_min > temp)
-        g_reader->stats_pkt[threadId -1][packet.appidx].cycles_min = temp;
+    if (g_reader->stats_pkt[threadId-1][packet.appidx].cycles_min > temp)
+        g_reader->stats_pkt[threadId-1][packet.appidx].cycles_min = temp;
 
-    if (g_reader->stats_pkt[threadId -1][packet.appidx].cycles_max  < temp)
+    if (g_reader->stats_pkt[threadId-1][packet.appidx].cycles_max  < temp)
     {
-        g_reader->stats_pkt[threadId -1][packet.appidx].cycles_max = temp;
+        g_reader->stats_pkt[threadId-1][packet.appidx].cycles_max = temp;
 
     }
     
 
-    add2bin((temp - (unsigned long)(mf2-mf1)),&g_reader->stats_pkt[threadId -1][packet.appidx].bin_cycles[0]); 
+    add2bin((temp - (unsigned long)(mf2-mf1)),&g_reader->stats_pkt[threadId-1][packet.appidx].bin_cycles[0]); 
     pDpiStats->n_ops+=1;
     if (temp > pDpiStats->max_time) pDpiStats->max_time = temp;
     if (temp< pDpiStats->min_time) pDpiStats->min_time = temp;
@@ -571,7 +571,7 @@ int navl_done(void)
     return 1;
 }
 
-void navl_results(int threadId)
+void navl_results(int fp_thread)
 {
     int idx;
     int i;
@@ -583,7 +583,7 @@ void navl_results(int threadId)
 
     if (g_reader->option_dpi)
     {
-        printf("\n NAVL DPI stats for CORE ID %d\n", threadId);
+        printf("\n NAVL DPI stats for CORE ID %d\n", fp_thread + 1);
         printf("\n AppProto    Packets  Class   Bytes        Cycles/Pkt      Cyclesnomem/Pkt  (min)  (max) ");
         for(i=0;i<MAX_BIN;i++)
             printf("<%s ",binStr[i]);
@@ -595,25 +595,25 @@ void navl_results(int threadId)
     {
         if (g_reader->option_dpi)
         {
-            if (g_reader->stats_pkt[threadId -1][idx].packets)
+            if (g_reader->stats_pkt[fp_thread][idx].packets)
             {
                 /* We need to provide protocol definitions */  
                 printf(" %-12s%-12" PRIu64 " %" PRIu64 " %" PRIu64 "      %" PRIu64 "       %" PRIu64 "    %ld    %ld    " , 
-                        g_reader->stats_pkt[threadId -1][idx].name,
-                        g_reader->stats_pkt[threadId -1][idx].packets, 
-                        g_reader->stats_pkt[threadId -1][idx].class, 
-                        g_reader->stats_pkt[threadId -1][idx].bytes,
-                        g_reader->stats_pkt[threadId -1][idx].cycles/g_reader->stats_pkt[threadId -1][idx].packets, 
-                        g_reader->stats_pkt[threadId -1][idx].cycles_nomem/g_reader->stats_pkt[threadId -1][idx].packets,
-                        g_reader->stats_pkt[threadId -1][idx].cycles_min,
-                        g_reader->stats_pkt[threadId -1][idx].cycles_max);
-                for(i=0;i<MAX_BIN;i++) printf("%ld ",g_reader->stats_pkt[threadId -1][idx].bin_cycles[i]);
+                        g_reader->stats_pkt[fp_thread][idx].name,
+                        g_reader->stats_pkt[fp_thread][idx].packets, 
+                        g_reader->stats_pkt[fp_thread][idx].class, 
+                        g_reader->stats_pkt[fp_thread][idx].bytes,
+                        g_reader->stats_pkt[fp_thread][idx].cycles/g_reader->stats_pkt[fp_thread][idx].packets, 
+                        g_reader->stats_pkt[fp_thread][idx].cycles_nomem/g_reader->stats_pkt[fp_thread][idx].packets,
+                        g_reader->stats_pkt[fp_thread][idx].cycles_min,
+                        g_reader->stats_pkt[fp_thread][idx].cycles_max);
+                for(i=0;i<MAX_BIN;i++) printf("%ld ",g_reader->stats_pkt[fp_thread][idx].bin_cycles[i]);
                 printf("\n");
             }
         }
 
-        total_packets += g_reader->stats_pkt[threadId -1][idx].packets;
-        total_bytes += g_reader->stats_pkt[threadId -1][idx].bytes;
+        total_packets += g_reader->stats_pkt[fp_thread][idx].packets;
+        total_bytes += g_reader->stats_pkt[fp_thread][idx].bytes;
     }
 
     if (!total_packets)
@@ -672,7 +672,7 @@ navl_wrapper_mem_stat_print()
 }
 
 
-void navl_results2(int threadId)
+void navl_results2(int fp_thread)
 {
     int idx;
     int i;
@@ -702,7 +702,7 @@ void navl_results2(int threadId)
 
     //if (g_reader->option_dpi)
     {
-        printf("\n NAVL DPI stats for CORE ID %d\n", threadId);
+        printf("\n NAVL DPI stats for CORE ID %d\n", fp_thread);
         printf("\n AppProto    Packets  Class   Bytes        Cycles/Pkt      Cyclesnomem/Pkt  (min)  (max) ");
         for(i=0;i<MAX_BIN;i++)
             printf("<%s ",binStr[i]);
@@ -714,25 +714,25 @@ void navl_results2(int threadId)
     {
         //if (g_reader->option_dpi)
         {
-            if (g_reader.stats_pkt[threadId -1][idx].packets)
+            if (g_reader.stats_pkt[fp_thread][idx].packets)
             {
                 /* We need to provide protocol definitions */  
                 printf(" %-12s%-12" PRIu64 " %" PRIu64 " %" PRIu64 "      %" PRIu64 "       %" PRIu64 "    %ld    %ld    " , 
-                        g_reader.stats_pkt[threadId -1][idx].name,
-                        g_reader.stats_pkt[threadId -1][idx].packets, 
-                        g_reader.stats_pkt[threadId -1][idx].class, 
-                        g_reader.stats_pkt[threadId -1][idx].bytes,
-                        g_reader.stats_pkt[threadId -1][idx].cycles/g_reader.stats_pkt[threadId -1][idx].packets, 
-                        g_reader.stats_pkt[threadId -1][idx].cycles_nomem/g_reader.stats_pkt[threadId -1][idx].packets,
-                        g_reader.stats_pkt[threadId -1][idx].cycles_min,
-                        g_reader.stats_pkt[threadId -1][idx].cycles_max);
-                for(i=0;i<MAX_BIN;i++) printf("%ld ",g_reader.stats_pkt[threadId -1][idx].bin_cycles[i]);
+                        g_reader.stats_pkt[fp_thread][idx].name,
+                        g_reader.stats_pkt[fp_thread][idx].packets, 
+                        g_reader.stats_pkt[fp_thread][idx].class, 
+                        g_reader.stats_pkt[fp_thread][idx].bytes,
+                        g_reader.stats_pkt[fp_thread][idx].cycles/g_reader.stats_pkt[fp_thread][idx].packets, 
+                        g_reader.stats_pkt[fp_thread][idx].cycles_nomem/g_reader.stats_pkt[fp_thread][idx].packets,
+                        g_reader.stats_pkt[fp_thread][idx].cycles_min,
+                        g_reader.stats_pkt[fp_thread][idx].cycles_max);
+                for(i=0;i<MAX_BIN;i++) printf("%ld ",g_reader.stats_pkt[fp_thread][idx].bin_cycles[i]);
                 printf("\n");
             }
         }
 
-        total_packets += g_reader.stats_pkt[threadId -1][idx].packets;
-        total_bytes += g_reader.stats_pkt[threadId -1][idx].bytes;
+        total_packets += g_reader.stats_pkt[fp_thread][idx].packets;
+        total_bytes += g_reader.stats_pkt[fp_thread][idx].bytes;
     }
 
     if (!total_packets)
similarity index 92%
rename from ti/runtime/netapi/demo/src/netapi_dpi_demo.c
rename to ti/runtime/netapi/demo/src/transport_dpi_demo.c
index b9d1bc0c36fc9cd90f26e4b24d02d853d782aa74..08c5791f7a823f4a46aef3d2acaee16a24cd09a6 100755 (executable)
@@ -53,7 +53,7 @@
 #include <ti/runtime/netapi/netapi.h>\r
 #include <ti/runtime/hplib/hplib.h>\r
 #include "ti/runtime/netapi/pktio.h"\r
-#include "netapi_dpi_demo.h"\r
+#include "transport_dpi_demo.h"\r
 #include "navl_wrapper.h"\r
 //#include "ti/runtime/netapi/test/net_test.h"\r
 #include <ti/drv/sa/salld.h>\r
@@ -416,8 +416,10 @@ void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats)
     pGlobDpiStats->m_bytes,\r
     pGlobDpiStats->n_err,\r
     pGlobDpiStats->f_op, pGlobDpiStats->m_cycles, pGlobDpiStats->f_cycles);\r
-    navl_results(1);\r
-    navl_results(2);\r
+    for(i=0; i< NUM_FP_PROCS;i++)\r
+    {\r
+        navl_results(i);\r
+    }\r
 #endif\r
     if(pPaStats)\r
     {\r
@@ -434,20 +436,20 @@ void our_stats_cb(NETAPI_T h, paSysStats_t* pPaStats)
         printf("C1 number VLAN Depth Overflow: %d\n", pPaStats->classify1.nVlanDepthOverflow);\r
         printf("C1 number GRE Depth Overflow: %d\n", pPaStats->classify1.nGreDepthOverflow);\r
         printf("C1 number MPLS Packets: %d\n", pPaStats->classify1.nMplsPackets);\r
-        printf ("C1 number of parse fail:        %d\n",pPaStats->classify1.nParseFail);\r
+        printf("C1 number of parse fail:        %d\n",pPaStats->classify1.nParseFail);\r
         printf("C1 number of Invalid IPv6 Opt:  %d\n", pPaStats->classify1.nInvalidIPv6Opt);\r
         printf("C1 number of TX IP Fragments:  %d\n", pPaStats->classify1.nTxIpFrag);\r
-        printf ("C1 number of silent discard:    %d\n",pPaStats->classify1.nSilentDiscard);\r
+        printf("C1 number of silent discard:    %d\n",pPaStats->classify1.nSilentDiscard);\r
         printf("C1 number of invalid control:   %d\n", pPaStats->classify1.nInvalidControl);\r
-        printf ("C1 number of invalid states:    %d\n",pPaStats->classify1.nInvalidState);\r
-        printf ("C1 number of system fails:      %d\n",pPaStats->classify1.nSystemFail);\r
-        printf ("C2 number Packets  :           %d\n",pPaStats->classify2.nPackets);\r
-        printf ("C2 number udp           :      %d\n",pPaStats->classify2.nUdp);\r
-        printf ("C2 number tcp           :      %d\n",pPaStats->classify2.nTcp);\r
-        printf ("C2 number Custom       :      %d\n",pPaStats->classify2.nCustom);\r
-        printf ("C2 number silent drop   :      %d\n",pPaStats->classify2.nSilentDiscard);\r
-        printf ("C2 number invalid cntrl :      %d\n\n",pPaStats->classify2.nInvalidControl);\r
-        printf ("C2 number Modify Stats Cmd Fail :      %d\n\n",pPaStats->modify.nCommandFail);\r
+        printf("C1 number of invalid states:    %d\n",pPaStats->classify1.nInvalidState);\r
+        printf("C1 number of system fails:      %d\n",pPaStats->classify1.nSystemFail);\r
+        printf("C2 number Packets  :           %d\n",pPaStats->classify2.nPackets);\r
+        printf("C2 number udp           :      %d\n",pPaStats->classify2.nUdp);\r
+        printf("C2 number tcp           :      %d\n",pPaStats->classify2.nTcp);\r
+        printf("C2 number Custom       :      %d\n",pPaStats->classify2.nCustom);\r
+        printf("C2 number silent drop   :      %d\n",pPaStats->classify2.nSilentDiscard);\r
+        printf("C2 number invalid cntrl :      %d\n\n",pPaStats->classify2.nInvalidControl);\r
+        printf("C2 number Modify Stats Cmd Fail :      %d\n\n",pPaStats->modify.nCommandFail);\r
     }\r
     Pktlib_getHeapStats(OurHeap, &pktLibHeapStats);\r
 \r
@@ -811,21 +813,8 @@ int main(int argc, char **argv)
             pStats2 = pTemp + sizeof(navl_wrapper_cfg_info_t) +\r
                     (sizeof(navl_wrapper_pkt_stat_t)*pNavlCfg->num_protocols);\r
 \r
-\r
             pTemp = hplib_shmGetEntry(pShmBase, APP_ENTRY_2);\r
             pGlobDpiStats = (struct dpi_stats*) pTemp;\r
-               navl_return_stats(\r
-            &pGlobDpiStats->n_ops,\r
-            &pGlobDpiStats->n_class,\r
-            &pGlobDpiStats->min_time,\r
-            &pGlobDpiStats->max_time,\r
-            &pGlobDpiStats->tot,\r
-            &pGlobDpiStats->m_op,\r
-            &pGlobDpiStats->m_bytes,\r
-            &pGlobDpiStats->n_err,\r
-            &pGlobDpiStats->f_op,\r
-            &pGlobDpiStats->m_cycles,\r
-            &pGlobDpiStats->f_cycles);\r
 \r
             printf("dpi stats:  nops=%d nclass=%d min cycle=%d max cycle=%d ave cycle=%lld #mallocs=%d #mbytes=%d n_err=%d fops=%d mCycles=%d fCycles=%d\n",\r
             pGlobDpiStats->n_ops,\r
@@ -837,9 +826,10 @@ int main(int argc, char **argv)
             pGlobDpiStats->m_bytes,\r
             pGlobDpiStats->n_err,\r
             pGlobDpiStats->f_op, pGlobDpiStats->m_cycles, pGlobDpiStats->f_cycles);\r
-            navl_results2(1);\r
-            navl_results2(2);\r
-            \r
+            for(i=0;i < NUM_FP_PROCS; i++)\r
+            {\r
+                navl_results2(i);\r
+            }\r
             exit(1);\r
         }\r
     }\r