Changeset 480 for soft/giet_vm/applications/classif
- Timestamp:
- Jan 1, 2015, 8:06:14 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/classif/main.c
r473 r480 4 4 // author : Alain Greiner 5 5 ///////////////////////////////////////////////////////////////////////////////////////////// 6 // This multi-threaded application takes a Gigabit Ethernet packets stream, and7 // makes apacket analysis and classification, based on the source MAC address.8 // It uses the NIC peripheral, and the chained buffer build by the CMA component9 // to consume packets on the Gigabit Ethernet port.10 // 11 // Itis described as a TCG (Task and Communication Graph) containing6 // This multi-threaded application takes a stream of Gigabit Ethernet packets, 7 // and makes packet analysis and classification, based on the source MAC address. 8 // It uses the NIC peripheral, and the distributed kernel chbuf filled by the CMA 9 // component to consume packets on the Gigabit Ethernet port. 10 // 11 // This application is described as a TCG (Task and Communication Graph) containing 12 12 // - one "load" task per cluster. 13 13 // - from one to three "analyse" tasks per cluster. 14 14 // In each cluster, the "load" task communicates with the local "analyse" tasks through 15 15 // a local MWMR fifo containing NB_PROCS_MAX containers (one item = one container). 16 // The MWMR fifo descriptor and the data buffer containing the containers are defined 17 // as global variables distributed in (up to) 16 clusters. 16 // The MWMR fifo descriptors array is defined as a global variable in cluster[0][0]. 18 17 // 19 18 // Initialisation is done in two steps by the "load" tasks: … … 21 20 // the barrier between all "load" tasks. Other "load" tasks are waiting on the 22 21 // global_sync synchronisation variable. 23 // - In each cluster[x][y], the load" task allocates the MWMR fifo descriptor & the data24 // buffer in the local heap, and store the pointers on a global array of pointers.22 // - In each cluster[x][y], the "load" task allocates the MWMR fifo descriptor and 23 // the data buffer in the local heap, and initializes the MWMR descriptor. 25 24 // The "analyse" tasks are waiting on the sync[x][y] variables. 26 25 // … … 35 34 // 2) The "analyse" task transfer one container from the local MWMR fifo to a private 36 35 // local buffer. It analyse each packet contained in the container, compute the 37 // packet type, depending on the 4 MSB bits of the source MAC address, 38 // and increment the corresponding counters. 36 // packet type, depending on the source MAC address, and increment the counters. 39 37 // 40 38 // It uses the he following hardware parameters, defined in the hard_config.h file: … … 51 49 #include "hard_config.h" 52 50 53 #define LOAD_VERBOSE 054 #define ANALYSE_VERBOSE 055 51 #define CONTAINERS_MAX 10 56 52 57 53 /////////////////////////////////////////////////////////////////////////////////////////// 58 54 // Global variables 59 // The communication channelsare distributed in the clusters,60 // but the pointers array s are global variablesin cluster[0][0]55 // The MWMR channels (descriptors and buffers) are distributed in the clusters, 56 // but the pointers array is stored in cluster[0][0] 61 57 /////////////////////////////////////////////////////////////////////////////////////////// 62 58 … … 73 69 unsigned int nic_channel; // allocated NIC channel index 74 70 75 ///////////////////////////////////////// //////////////////////////////////////////////////71 ///////////////////////////////////////// 76 72 __attribute__ ((constructor)) void load() 77 ///////////////////////////////////////// //////////////////////////////////////////////////73 ///////////////////////////////////////// 78 74 { 79 75 // get processor identifiers … … 83 79 giet_proc_xyp( &x, &y, &l ); 84 80 85 if (X_SIZE > 4 ) giet_exit("The X_SIZE parameter cannot be larger than 4\n");86 if (Y_SIZE > 4 ) giet_exit("The Y_SIZE parameter cannot be larger than 4\n");87 88 81 // local buffer to store one container in private stack 89 82 unsigned int temp[1024]; 90 83 91 // giet_shr_printf("\n@@@ P[%d,%d,%d] enters load task at cycle %d\n",92 // x, y, l, giet_proctime() );93 94 84 // allocates data buffer for MWMR fifo in local heap 95 85 unsigned int* data = malloc( NB_PROCS_MAX<<12 ); 96 86 97 //giet_shr_printf("\n@@@ P[%d,%d,%d] completes data malloc at cycle %d "98 // "/ &data = %x\n", x, y, l, giet_proctime(), (unsigned int)data );99 100 87 // allocates MWMR fifo descriptor in local heap 101 mwmr_channel_t* fifo = malloc( sizeof(mwmr_channel_t) ); 102 103 //giet_shr_printf("\n@@@ P[%d,%d,%d] completes mwmr malloc at cycle %d " 104 // "/ &mwmr = %x\n", x, y, l, giet_proctime(), (unsigned int)mwmr ); 105 106 // makes copy of pointer in global array for "analyse" tasks 107 mwmr[x][y] = fifo; 108 109 // display status for cluster[X_SIZE-1][Y_SIZE-1] 88 mwmr[x][y] = malloc( sizeof(mwmr_channel_t) ); 89 mwmr_channel_t* fifo = mwmr[x][y]; 90 91 // initialises local MWMR fifo : width = 4kbytes / depth = NB_PROCS_MAX 92 mwmr_init( fifo , data , 1024 , NB_PROCS_MAX ); 93 94 // display for cluster[X_SIZE-1][Y_SIZE-1] 110 95 if ( (x==X_SIZE-1) && (y==Y_SIZE-1) ) 111 96 giet_shr_printf("\n*** Task load starts on P[%d,%d,%d] at cycle %d\n" 112 " & fifo= %x / &data = %x / &sync = %x\n"97 " &mwmr = %x / &data = %x / &sync = %x\n" 113 98 " x_size = %d / y_size = %d / nprocs = %d\n", 114 99 x , y , l , giet_proctime() , 115 (unsigned int)fifo , (unsigned int)data, (unsigned int)(&local_sync[x][y]),100 (unsigned int)fifo, (unsigned int)data, (unsigned int)(&local_sync[x][y]), 116 101 X_SIZE, Y_SIZE, NB_PROCS_MAX ); 117 102 118 103 // Task load on cluster[0,0] makes global initialisation: 119 104 // - NIC & CMA channels allocation & initialisation. 120 // - barrier for allload tasks initialisation.105 // - barrier for load tasks initialisation. 121 106 // Other load task wait completion. 122 107 if ( (x==0) && (y==0) ) … … 131 116 barrier_init( &barrier, X_SIZE * Y_SIZE ); 132 117 133 // clear NIC RX channels stats134 giet_nic_rx_clear();135 136 118 global_sync = 1; 137 119 } … … 141 123 } 142 124 143 // Each load task initialises local MWMR fifo (width = 4kbytes / depth = NB_PROCS_MAX) 144 mwmr_init( fifo , data , 1024 , NB_PROCS_MAX ); 145 146 // signal MWMR fifo initialisation completion to analyse tasks 125 // "load" task signals MWMR initialisation to "analyse" tasks 147 126 local_sync[x][y] = 1; 148 127 … … 177 156 giet_nic_rx_stop(); 178 157 179 giet_shr_printf("\n@@@@ Clas ification Results @@@\n"158 giet_shr_printf("\n@@@@ Classification Results @@@\n" 180 159 " - TYPE 0 : %d packets\n" 181 160 " - TYPE 1 : %d packets\n" … … 232 211 if ( (x==X_SIZE-1) && (y==Y_SIZE-1) ) 233 212 giet_shr_printf("\n*** Task analyse starts on P[%d,%d,%d] at cycle %d\n" 234 " & fifo= %x / &sync = %x\n",213 " &mwmr = %x / &sync = %x\n", 235 214 x, y, l, giet_proctime(), 236 215 (unsigned int)fifo, (unsigned int)(&local_sync[x][y]) ); … … 267 246 else length = temp[1+(p>>1)] & 0x0000FFFF; 268 247 269 // get packet type (source mac address 4 MSB bits)270 type = (temp[word+1] & 0x0000 F000) >> 12;248 // get packet type (source mac address) 249 type = (temp[word+1] & 0x0000000F); 271 250 272 251 // increment counter
Note: See TracChangeset
for help on using the changeset viewer.