source: soft/giet_vm/applications/classif/main.c @ 548

Last change on this file since 548 was 542, checked in by bellefin, 9 years ago

Using the heap_init() function

File size: 24.2 KB
RevLine 
[502]1///////////////////////////////////////////////////////////////////////////////////////
[457]2// File   : main.c   (for classif application)
3// Date   : november 2014
4// author : Alain Greiner
[502]5///////////////////////////////////////////////////////////////////////////////////////
[480]6// This multi-threaded application takes a stream of Gigabit Ethernet packets,
7// and makes packet analysis and classification, based on the source MAC address.
[488]8// It uses the NIC peripheral, and the distributed kernel chbufs accessed by the CMA
9// component to receive and send packets on the Gigabit Ethernet port.
[457]10//
[502]11// It can run on architectures containing up to 16 * 16 clusters,
12// and up to 8 processors per cluster.
13//
14// This application is described as a TCG (Task and Communication Graph)
15// containing (N+2) tasks per cluster:
[488]16// - one "load" task
[502]17// - one "store" task
[488]18// - N "analyse" tasks
[502]19// The containers are distributed (N+2 containers per cluster):
[488]20// - one RX container (part of the kernel rx_chbuf), in the kernel heap.
21// - one TX container (part of the kernel tx-chbuf), in the kernel heap.
22// - N working containers (one per analysis task), in the user heap.
23// In each cluster, the "load", analysis" and "store" tasks communicates through
24// three local MWMR fifos:
25// - fifo_l2a : tranfer a full container from "load" to "analyse" task.
26// - fifo_a2s : transfer a full container from "analyse" to "store" task.
27// - fifo_s2l : transfer an empty container from "store" to "load" task.
28// For each fifo, one item is a 32 bits word defining the index of an
29// available working container.
30// The pointers on the working containers, and the pointers on the MWMR fifos
31// are global arrays stored in cluster[0][0].
[457]32// a local MWMR fifo containing NB_PROCS_MAX containers (one item = one container).
[480]33// The MWMR fifo descriptors array is defined as a global variable in cluster[0][0].
[457]34//
[542]35// Initialisation is done in three steps by the "load" & "store" tasks:
36// - Task "load" in cluster[0][0] initialises the heaps in all clusters. Other tasks
37//   are waiting on the global_sync synchronisation variable.
38// - Then task "load" in cluster[0][0] initialises the barrier between all "load"
39//   tasks, allocates NIC & CMA RX channel, and starts the NIC_CMA RX transfer.
[502]40//   Other "load" tasks are waiting on the load_sync synchronisation variable.
41//   Task "store" in cluster[0][0] initialises the barrier between all "store" tasks,
42//   allocates NIC & CMA TX channels, and starts the NIC_CMA TX transfer.
43//   Other "store" tasks are waiting on the store_sync synchronisation variable.
44// - When this global initialisation is completed, the "load" task in all clusters
45//   allocates the working containers and the MWMR fifos descriptors from the
46//   user local heap. In each cluster, the "analyse" and "store" tasks are waiting
47//   the local initialisation completion on the local_sync[x][y] variables.
[488]48//
49// When initialisation is completed, all tasks loop on containers:
50// 1) The "load" task get an empty working container from the fifo_s2l,
51//    transfer one container from the kernel rx_chbuf to this user container,
52//    and transfer ownership of this container to one "analysis" task by writing
53//    into the fifo_l2a.   
54// 2) The "analyse" task get one working container from the fifo_l2a, analyse
55//    each packet header, compute the packet type (depending on the SRC MAC address),
56//    increment the correspondint classification counter, and transpose the SRC
57//    and the DST MAC addresses fot TX tranmission.
58// 3) The "store" task transfer get a full working container from the fifo_a2s,
59//    transfer this user container content to the the kernel tx_chbuf,
60//    and transfer ownership of this empty container to the "load" task by writing
61//    into the fifo_s2l.   
[502]62//     
63// Instrumentation results display is done by the "store" task in cluster[0][0]
64// when all "store" tasks completed the number of clusters specified by the
65// CONTAINERS_MAX parameter.
66///////////////////////////////////////////////////////////////////////////////////////
[457]67
68#include "stdio.h"
[502]69#include "user_barrier.h"
[457]70#include "malloc.h"
71#include "user_lock.h"
72#include "mwmr_channel.h"
73
[502]74#define X_SIZE_MAX      16
75#define Y_SIZE_MAX      16
76#define NPROCS_MAX      8
[536]77#define CONTAINERS_MAX  50
[502]78#define VERBOSE_ANALYSE 0
[457]79
[502]80///////////////////////////////////////////////////////////////////////////////////////
[473]81//    Global variables
[488]82// The MWMR channels (descriptors and buffers), as well as the working containers
83// used by the "analysis" tasks are distributed in clusters.
84// But the pointers on these distributed structures are shared arrays
85// stored in cluster[0][0].
[502]86///////////////////////////////////////////////////////////////////////////////////////
[457]87
[502]88// pointers on distributed containers
89unsigned int*       container[X_SIZE_MAX][Y_SIZE_MAX][NPROCS_MAX-2]; 
[457]90
[488]91// pointers on distributed mwmr fifos containing : temp[x][y][l] container descriptors
[502]92mwmr_channel_t*     mwmr_l2a[X_SIZE_MAX][Y_SIZE_MAX]; 
93mwmr_channel_t*     mwmr_a2s[X_SIZE_MAX][Y_SIZE_MAX];
94mwmr_channel_t*     mwmr_s2l[X_SIZE_MAX][Y_SIZE_MAX]; 
[457]95
[488]96// local synchros signaling local MWMR fifos initialisation completion
[502]97volatile unsigned int        local_sync[X_SIZE_MAX][Y_SIZE_MAX]; 
[457]98
[488]99// global synchro signaling global initialisation completion
[542]100volatile unsigned int        global_sync = 0;
101volatile unsigned int        load_sync   = 0; 
102volatile unsigned int        store_sync  = 0; 
[457]103
[488]104// instrumentation counters
105unsigned int        counter[16];
[457]106
[502]107// distributed barrier between "load" tasks
108giet_sqt_barrier_t  rx_barrier;
[457]109
[502]110// distributed barrier between "store" tasks
111giet_sqt_barrier_t  tx_barrier;
112
[488]113// NIC_RX and NIC_TX channel index
114unsigned int        nic_rx_channel;
115unsigned int        nic_tx_channel;
116
[480]117/////////////////////////////////////////
[457]118__attribute__ ((constructor)) void load()
[480]119/////////////////////////////////////////
[457]120{
[502]121    // each "load" task get platform parameters
[542]122    unsigned int    x_size;                     // number of clusters in a row
[502]123    unsigned int    y_size;                     // number of clusters in a column
124    unsigned int    nprocs;                     // number of processors per cluster
125    giet_procs_number( &x_size, &y_size, &nprocs );
126
127    giet_assert( (x_size <= X_SIZE_MAX) && 
128                 (y_size <= Y_SIZE_MAX) && 
129                 (nprocs <= NPROCS_MAX) , 
130                 "[CLASSIF ERROR] illegal platform parameters" );
131
[488]132    // each "load" task get processor identifiers
[457]133    unsigned int    x;
134    unsigned int    y;
135    unsigned int    l;
136    giet_proc_xyp( &x, &y, &l );
137
[542]138    // "load" task[0][0]
139    // - initialises the heap in every cluster
140    // - initialises barrier between all load tasks,
141    // - allocates the NIC & CMA RX channels, and start the NIC_CMA RX transfer.
[488]142    // Other "load" tasks wait completion
143    if ( (x==0) && (y==0) )
144    {
[502]145        giet_shr_printf("\n*** Task load on P[%d][%d][%d] starts at cycle %d\n"
146                        "  x_size = %d / y_size = %d / nprocs = %d\n",
147                        x , y , l , giet_proctime() , x_size, y_size, nprocs );
[542]148
149    unsigned int xid;  // x cluster coordinate index
150    unsigned int yid;  // y cluster coordinate index
151
152    for ( xid = 0 ; xid < x_size ; xid++ )
153      {
154        for ( yid = 0 ; yid < y_size ; yid++ )
155          {
156            heap_init( xid, yid );
157          }
158      }
159   
160        global_sync = 1;
161
[502]162        sqt_barrier_init( &rx_barrier, x_size , y_size , 1 );
163        nic_rx_channel = giet_nic_rx_alloc( x_size , y_size );
[488]164        giet_nic_rx_start( nic_rx_channel );
165        load_sync = 1;
166    }
167    else
168    {
169        while ( load_sync == 0 ) asm volatile ("nop");
170    }   
[457]171
[502]172    // each load tasks allocates containers[x][y][n] (from local heap)
[488]173    // and register pointers in the local stack
174    unsigned int   n;
[502]175    unsigned int*  cont[NPROCS_MAX-2]; 
176    unsigned int   analysis_tasks = nprocs-2;
[473]177
[502]178    for ( n = 0 ; n < analysis_tasks ; n++ )
[488]179    {
180        container[x][y][n] = malloc( 4096 );
181        cont[n]            = container[x][y][n];
182    }
183   
[502]184    // each load task allocates data buffers for mwmr fifos (from local heap)
185    unsigned int*  data_l2a = malloc( analysis_tasks<<2 );
186    unsigned int*  data_a2s = malloc( analysis_tasks<<2 );
187    unsigned int*  data_s2l = malloc( analysis_tasks<<2 );
[473]188
[502]189    // each load task allocates mwmr fifos descriptors (from local heap)
[488]190    mwmr_l2a[x][y] = malloc( sizeof(mwmr_channel_t) );
191    mwmr_a2s[x][y] = malloc( sizeof(mwmr_channel_t) );
192    mwmr_s2l[x][y] = malloc( sizeof(mwmr_channel_t) );
[473]193
[502]194    // each load task registers local pointers on mwmr fifos in local stack
[488]195    mwmr_channel_t* fifo_l2a = mwmr_l2a[x][y];
196    mwmr_channel_t* fifo_a2s = mwmr_a2s[x][y];
197    mwmr_channel_t* fifo_s2l = mwmr_s2l[x][y];
198
[502]199    // each load task initialises local mwmr fifos descriptors
[488]200    // ( width = 4 bytes / depth = number of analysis tasks )
[502]201    mwmr_init( fifo_l2a , data_l2a , 1 , analysis_tasks );
202    mwmr_init( fifo_a2s , data_a2s , 1 , analysis_tasks );
203    mwmr_init( fifo_s2l , data_s2l , 1 , analysis_tasks );
[488]204
205   
[502]206    // each load task initialises local containers as empty in fifo_s2l
207    for ( n = 0 ; n < analysis_tasks ; n++ ) mwmr_write( fifo_s2l , &n , 1 );
[488]208
[502]209    // each load task[x][y] signals mwmr fifos initialisation completion
[488]210    // to other tasks in same cluster[x][y]
211    local_sync[x][y] = 1;
212
[502]213    // load task[0][0] displays status
[488]214    if ( (x==0) && (y==0) )
215    giet_shr_printf("\n*** Task load on P[%d,%d,%d] enters main loop at cycle %d\n"
216                    "      nic_rx_channel = %d / nic_tx_channel = %d\n"
217                    "      &mwmr_l2a  = %x / &data_l2a  = %x\n"
218                    "      &mwmr_a2s  = %x / &data_a2s  = %x\n"
219                    "      &mwmr_s2l  = %x / &data_s2l  = %x\n"
220                    "      &cont[0]   = %x\n"
[473]221                    "      x_size = %d / y_size = %d / nprocs = %d\n",
[488]222                    x , y , l , giet_proctime(), 
223                    nic_rx_channel , nic_tx_channel,
224                    (unsigned int)fifo_l2a, (unsigned int)data_l2a,
225                    (unsigned int)fifo_a2s, (unsigned int)data_a2s,
226                    (unsigned int)fifo_s2l, (unsigned int)data_s2l,
227                    (unsigned int)cont[0],
[502]228                    x_size, y_size, nprocs );
[488]229 
230    /////////////////////////////////////////////////////////////
[502]231    // All load tasks enter the main loop (on containers)
232    unsigned int  count = 0;     // loaded containers count
233    unsigned int  index;         // available container index
234    unsigned int* temp;          // pointer on available container
[457]235
[488]236    while ( count < CONTAINERS_MAX ) 
237    { 
[502]238        // get one empty container index from fifo_s2l
[488]239        mwmr_read( fifo_s2l , &index , 1 );
240        temp = cont[index];
241
[502]242        // get one container from  kernel rx_chbuf
[488]243        giet_nic_rx_move( nic_rx_channel, temp );
244
245        // get packets number
246        unsigned int npackets = temp[0] & 0x0000FFFF;
247        unsigned int nwords   = temp[0] >> 16;
248
[502]249        if ( (x==0) && (y==0) )
[488]250        giet_shr_printf("\n*** Task load on P[%d,%d,%d] get container %d at cycle %d"
251                        " : %d packets / %d words\n",
252                        x, y, l, count, giet_proctime(), npackets, nwords );
253
[502]254        // put the full container index to fifo_l2a
[488]255        mwmr_write( fifo_l2a, &index , 1 );
256
257        count++;
258    }
259
260    // all "load" tasks synchronise before stats
[502]261    sqt_barrier_wait( &rx_barrier );
[488]262
263    // "load" task[0][0] stops the NIC_CMA RX transfer and displays stats
264    if ( (x==0) && (y==0) ) 
[457]265    {
[488]266        giet_nic_rx_stop( nic_rx_channel );
267        giet_nic_rx_stats( nic_rx_channel );
268    }
[457]269
[488]270    // all "load" task exit
271    giet_exit("Task completed");
272 
273} // end load()
[457]274
275
[488]276//////////////////////////////////////////
277__attribute__ ((constructor)) void store()
278//////////////////////////////////////////
279{
[502]280    // each "load" task get platform parameters
281    unsigned int    x_size;                                             // number of clusters in row
282    unsigned int    y_size;                     // number of clusters in a column
283    unsigned int    nprocs;                     // number of processors per cluster
284    giet_procs_number( &x_size, &y_size, &nprocs );
285
[488]286    // get processor identifiers
287    unsigned int    x;
288    unsigned int    y;
289    unsigned int    l;
290    giet_proc_xyp( &x, &y, &l );
291
[542]292    // "Store" tasks wait completion of heaps initialization
293    while ( global_sync == 0 ) asm volatile ("nop");
294
[488]295    // "store" task[0][0] initialises the barrier between all "store" tasks,
296    // allocates NIC & CMA TX channels, and starts the NIC_CMA TX transfer.
297    // Other "store" tasks wait completion.
298    if ( (x==0) && (y==0) )
299    {
[502]300        giet_shr_printf("\n*** Task store on P[%d][%d][%d] starts at cycle %d\n"
301                        "  x_size = %d / y_size = %d / nprocs = %d\n",
302                        x , y , l , giet_proctime() , x_size, y_size, nprocs );
[488]303 
[502]304        sqt_barrier_init( &tx_barrier , x_size , y_size , 1 );
305        nic_tx_channel = giet_nic_tx_alloc( x_size , y_size );
[488]306        giet_nic_tx_start( nic_tx_channel );
307        store_sync = 1;
[457]308    }
309    else
310    {
[488]311        while ( store_sync == 0 ) asm volatile ("nop");
[457]312    }   
313
[488]314    // all "store" tasks wait mwmr channels initialisation
315    while ( local_sync[x][y] == 0 ) asm volatile ("nop");
[457]316
[502]317    // each "store" tasks register pointers on working containers in local stack
[488]318    unsigned int   n;
[502]319    unsigned int   analysis_tasks = nprocs-2;
320    unsigned int*  cont[NPROCS_MAX-2]; 
321
322    for ( n = 0 ; n < analysis_tasks ; n++ )
[488]323    {
324        cont[n] = container[x][y][n];
325    }
326   
327    // all "store" tasks register pointers on mwmr fifos in local stack
328    mwmr_channel_t* fifo_l2a = mwmr_l2a[x][y];
329    mwmr_channel_t* fifo_a2s = mwmr_a2s[x][y];
330    mwmr_channel_t* fifo_s2l = mwmr_s2l[x][y];
331
332    // "store" task[0][0] displays status
333    if ( (x==0) && (y==0) )
334    giet_shr_printf("\n*** Task store on P[%d,%d,%d] enters main loop at cycle %d\n"
335                    "      &mwmr_l2a  = %x\n"
336                    "      &mwmr_a2s  = %x\n"
337                    "      &mwmr_s2l  = %x\n"
338                    "      &cont[0]   = %x\n",
339                    x , y , l , giet_proctime(), 
340                    (unsigned int)fifo_l2a,
341                    (unsigned int)fifo_a2s,
342                    (unsigned int)fifo_s2l,
343                    (unsigned int)cont[0] );
344
345
346    /////////////////////////////////////////////////////////////
347    // all "store" tasks enter the main loop (on containers)
348    unsigned int count = 0;     // stored containers count
349    unsigned int index;         // empty container index
350    unsigned int* temp;         // pointer on empty container
351
352    while ( count < CONTAINERS_MAX ) 
[457]353    { 
[488]354        // get one working container index from fifo_a2s
355        mwmr_read( fifo_a2s , &index , 1 );
356        temp = cont[index];
[457]357
[488]358        // put one container to  kernel tx_chbuf
359        giet_nic_tx_move( nic_tx_channel, temp );
360
[457]361        // get packets number
362        unsigned int npackets = temp[0] & 0x0000FFFF;
363        unsigned int nwords   = temp[0] >> 16;
364
[502]365        if ( (x==0) && (y==0) )
[488]366        giet_shr_printf("\n*** Task store on P[%d,%d,%d] get container %d at cycle %d"
[457]367                        " : %d packets / %d words\n",
[488]368                        x, y, l, count, giet_proctime(), npackets, nwords );
[457]369
[488]370        // put the working container index to fifo_s2l
371        mwmr_write( fifo_s2l, &index , 1 );
[457]372
[488]373        count++;
[457]374    }
375
[488]376    // all "store" tasks synchronise before result display
[502]377    sqt_barrier_wait( &tx_barrier );
[457]378
[488]379    // "store" task[0,0] stops NIC_CMA TX transfer and displays results
[457]380    if ( (x==0) && (y==0) )
381    {
[488]382        giet_nic_tx_stop( nic_tx_channel );
[473]383
[480]384        giet_shr_printf("\n@@@@ Classification Results @@@\n"
[457]385                        " - TYPE 0 : %d packets\n"
386                        " - TYPE 1 : %d packets\n"
387                        " - TYPE 2 : %d packets\n"
388                        " - TYPE 3 : %d packets\n"
389                        " - TYPE 4 : %d packets\n"
390                        " - TYPE 5 : %d packets\n"
391                        " - TYPE 6 : %d packets\n"
392                        " - TYPE 7 : %d packets\n"
393                        " - TYPE 8 : %d packets\n"
394                        " - TYPE 9 : %d packets\n"
395                        " - TYPE A : %d packets\n"
396                        " - TYPE B : %d packets\n"
397                        " - TYPE C : %d packets\n"
398                        " - TYPE D : %d packets\n"
399                        " - TYPE E : %d packets\n"
[488]400                        " - TYPE F : %d packets\n"
401                        "    TOTAL = %d packets\n",
402                        counter[0x0], counter[0x1], counter[0x2], counter[0x3],
403                        counter[0x4], counter[0x5], counter[0x6], counter[0x7],
404                        counter[0x8], counter[0x9], counter[0xA], counter[0xB],
405                        counter[0xC], counter[0xD], counter[0xE], counter[0xF],
406                        counter[0x0]+ counter[0x1]+ counter[0x2]+ counter[0x3]+
407                        counter[0x4]+ counter[0x5]+ counter[0x6]+ counter[0x7]+
408                        counter[0x8]+ counter[0x9]+ counter[0xA]+ counter[0xB]+
409                        counter[0xC]+ counter[0xD]+ counter[0xE]+ counter[0xF] );
[457]410
[488]411        giet_nic_tx_stats( nic_tx_channel );
[457]412    }
413
[488]414    // all "store" task exit
[457]415    giet_exit("Task completed");
416
[488]417} // end store()
418
419
[457]420////////////////////////////////////////////
421__attribute__ ((constructor)) void analyse()
422////////////////////////////////////////////
423{
[502]424    // each "load" task get platform parameters
425    unsigned int    x_size;                                             // number of clusters in row
426    unsigned int    y_size;                     // number of clusters in a column
427    unsigned int    nprocs;                     // number of processors per cluster
428    giet_procs_number( &x_size, &y_size, &nprocs );
429
[457]430    // get processor identifiers
431    unsigned int    x;
432    unsigned int    y;
433    unsigned int    l;
434    giet_proc_xyp( &x, &y, &l );
435
[488]436    if ( (x==0) && (y==0) )
437    {
[502]438        giet_shr_printf("\n*** Task analyse on P[%d][%d][%d] starts at cycle %d\n"
439                        "  x_size = %d / y_size = %d / nprocs = %d\n",
440                        x , y , l , giet_proctime() , x_size, y_size, nprocs );
[488]441    }
[542]442
443    // all "analyse" tasks wait heaps and mwmr channels initialisation
[473]444    while ( local_sync[x][y] == 0 ) asm volatile ("nop");
445
[488]446    // all "analyse" tasks register pointers on working containers in local stack
447    unsigned int   n;
[502]448    unsigned int   analysis_tasks = nprocs-2;
449    unsigned int*  cont[NPROCS_MAX-2]; 
450    for ( n = 0 ; n < analysis_tasks ; n++ )
[488]451    {
452        cont[n] = container[x][y][n];
453    }
[457]454
[488]455    // all "analyse" tasks register pointers on mwmr fifos in local stack
456    mwmr_channel_t* fifo_l2a = mwmr_l2a[x][y];
457    mwmr_channel_t* fifo_a2s = mwmr_a2s[x][y];
458
459    // "analyse" task[0][0] display status
460    if ( (x==0) && (y==0) )
461    giet_shr_printf("\n*** Task analyse on P[%d,%d,%d] enters main loop at cycle %d\n"
462                    "       &mwmr_l2a = %x\n"
463                    "       &mwmr_a2s = %x\n"
464                    "       &cont[0]  = %x\n",
[457]465                    x, y, l, giet_proctime(), 
[488]466                    (unsigned int)fifo_l2a,
467                    (unsigned int)fifo_a2s,
468                    (unsigned int)cont[0] );
469     
470    /////////////////////////////////////////////////////////////
471    // all "analyse" tasks enter the main loop (on containers)
472    unsigned int  index;           // available container index
473    unsigned int* temp;            // pointer on available container
474    unsigned int  nwords;          // number of words in container
475    unsigned int  npackets;        // number of packets in container
476    unsigned int  length;          // number of bytes in current packet
477    unsigned int  first;           // current packet first word in container
478    unsigned int  type;            // current packet type
479    unsigned int  p;               // current packet index
480
481#if VERBOSE_ANALYSE
482    unsigned int       verbose_len[10]; // save length for all packets in one container
483    unsigned long long verbose_dst[10]; // save length for all packets in one container
484    unsigned long long verbose_src[10]; // save length for all packets in one container
485#endif
486
[457]487    while ( 1 )
488    { 
489
[488]490#if VERBOSE_ANALYSE
491            for( p = 0 ; p < 10 ; p++ )
492            {
493                verbose_len[p] = 0;
494                verbose_dst[p] = 0;
495                verbose_src[p] = 0;
496            }
497#endif
498        // get one working container index from fifo_l2a
499        mwmr_read( fifo_l2a , &index , 1 );
500        temp = cont[index];
501
502        // get packets number and words number
[457]503        npackets = temp[0] & 0x0000FFFF;
504        nwords   = temp[0] >> 16;
505
[488]506        if ( (x==0) && (y==0) )
507        giet_shr_printf("\n*** Task analyse on P[%d,%d,%d] get container at cycle %d"
[457]508                        " : %d packets / %d words\n",
509                                                x, y, l, giet_proctime(), npackets, nwords );
510
511        // initialize word index in container
[488]512        first = 34;
[457]513
514        // loop on packets
515        for( p = 0 ; p < npackets ; p++ )
516        {
517            // get packet length from container header
518            if ( (p & 0x1) == 0 )  length = temp[1+(p>>1)] >> 16;
519            else                   length = temp[1+(p>>1)] & 0x0000FFFF;
520
[488]521            // compute packet DST and SRC MAC addresses
522            unsigned int word0 = temp[first];
523            unsigned int word1 = temp[first + 1];
524            unsigned int word2 = temp[first + 2];
[457]525
[502]526#if VERBOSE_ANALYSE
[488]527            unsigned long long dst = ((unsigned long long)(word1 & 0xFFFF0000)>>16) |
528                                     (((unsigned long long)word0)<<16);
529            unsigned long long src = ((unsigned long long)(word1 & 0x0000FFFF)<<32) |
530                                     ((unsigned long long)word2);
531            if ( p < 10 )
532            {
533                verbose_len[p] = length;
534                verbose_dst[p] = dst;
535                verbose_src[p] = src;
536            }
537#endif
538            // compute type from SRC MAC address and increment counter
539            type = word1 & 0x0000000F;
540            atomic_increment( &counter[type], 1 );
[457]541
[488]542            // exchange SRC & DST MAC addresses for TX
543            temp[first]     = ((word1 & 0x0000FFFF)<<16) | ((word2 & 0xFFFF0000)>>16);
544            temp[first + 1] = ((word2 & 0x0000FFFF)<<16) | ((word0 & 0xFFFF0000)>>16);
545            temp[first + 2] = ((word0 & 0x0000FFFF)<<16) | ((word1 & 0xFFFF0000)>>16);
546
547            // update first word index
548            if ( length & 0x3 ) first += (length>>2)+1;
549            else                first += (length>>2);
[457]550        }
[488]551       
552#if VERBOSE_ANALYSE
553        if ( (x==0) && (y==0) )
554        giet_shr_printf("\n*** Task analyse on P[%d,%d,%d] completes at cycle %d\n"
555                        "   - Packet 0 : plen = %d / dst_mac = %l / src_mac = %l\n"
556                        "   - Packet 1 : plen = %d / dst_mac = %l / src_mac = %l\n"
557                        "   - Packet 2 : plen = %d / dst_mac = %l / src_mac = %l\n"
558                        "   - Packet 3 : plen = %d / dst_mac = %l / src_mac = %l\n"
559                        "   - Packet 4 : plen = %d / dst_mac = %l / src_mac = %l\n"
560                        "   - Packet 5 : plen = %d / dst_mac = %l / src_mac = %l\n"
561                        "   - Packet 6 : plen = %d / dst_mac = %l / src_mac = %l\n"
562                        "   - Packet 7 : plen = %d / dst_mac = %l / src_mac = %l\n"
563                        "   - Packet 8 : plen = %d / dst_mac = %l / src_mac = %l\n"
564                        "   - Packet 9 : plen = %d / dst_mac = %l / src_mac = %l\n",
565                        x , y , l , giet_proctime() , 
566                        verbose_len[0] , verbose_dst[0] , verbose_src[0] ,
567                        verbose_len[1] , verbose_dst[1] , verbose_src[1] ,
568                        verbose_len[2] , verbose_dst[2] , verbose_src[2] ,
569                        verbose_len[3] , verbose_dst[3] , verbose_src[3] ,
570                        verbose_len[4] , verbose_dst[4] , verbose_src[4] ,
571                        verbose_len[5] , verbose_dst[5] , verbose_src[5] ,
572                        verbose_len[6] , verbose_dst[6] , verbose_src[6] ,
573                        verbose_len[7] , verbose_dst[7] , verbose_src[7] ,
574                        verbose_len[8] , verbose_dst[8] , verbose_src[8] ,
575                        verbose_len[9] , verbose_dst[9] , verbose_src[9] );
576#endif
577           
578        // pseudo-random delay
579        for( p = 0 ; p < (giet_rand()>>4) ; p++ ) asm volatile ("nop");
580
581        // put the working container index to fifo_a2s
582        mwmr_write( fifo_a2s , &index , 1 );
[457]583    }
584} // end analyse()
585
Note: See TracBrowser for help on using the repository browser.