Changeset f625817 for tools


Ignore:
Timestamp:
09/11/15 15:00:27 (5 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
322c516
Parents:
8c7490fe
Message:

Reworked callback API and removed old per_msg and reporter functions

Updated tracertstats to use the new callback API.

Extended the callback approach to the reporter thread as well as the per
packet threads.

Added libtrace_callback_set_t structure, which is used to register the
user callback functions.

Added callback functionality for MESSAGE_RESULT (needed now that reporter
threads also do callbacks) and MESSAGE_USER (for user-defined messages). The
MESSAGE_USER callback is essentially the same as the old per_msg function
style.

Updated combiners to use send_message to pass results to the reporter thread.
send_message itself is now no longer static, so that combiners can use it.

Disabled building of tracestats_parallel as it was using the older version
of the callback API. Will update in a future commit.

Location:
tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tools/tracertstats/tracertstats.c

    r8c7490fe rf625817  
    130130
    131131static uint64_t glob_last_ts = 0;
    132 static void process_result(libtrace_t *trace, int mesg,
    133                            libtrace_generic_t data,
    134                            libtrace_thread_t *sender UNUSED) {
     132static void cb_result(libtrace_t *trace, libtrace_thread_t *sender UNUSED,
     133                void *global UNUSED, void *tls UNUSED,
     134                libtrace_result_t *result) {
    135135        uint64_t ts = 0;
    136136        static bool stopped = false;
     
    142142                return;
    143143
    144         switch (mesg) {
    145                 case MESSAGE_RESULT:
    146                 ts = data.res->key;
    147                 res = data.res->value.ptr;
    148                 if (glob_last_ts == 0)
    149                         glob_last_ts = ts;
    150                 while ((glob_last_ts >> 32) < (ts >> 32)) {
    151                         report_results(glob_last_ts >> 32, count, bytes);
    152                         count = 0;
    153                         bytes = 0;
    154                         for (j = 0; j < filter_count; j++)
    155                                 filters[j].count = filters[j].bytes = 0;
    156                         glob_last_ts = ts;
    157                 }
    158                 count += res->total.count;
    159                 packets_seen += res->total.count;
    160                 bytes += res->total.bytes;
    161                 for (j = 0; j < filter_count; j++) {
    162                         filters[j].count += res->filters[j].count;
    163                         filters[j].bytes += res->filters[j].bytes;
    164                 }
    165                 free(res);
    166         }
     144        ts = result->key;
     145        res = result->value.ptr;
     146        if (glob_last_ts == 0)
     147                glob_last_ts = ts;
     148        while ((glob_last_ts >> 32) < (ts >> 32)) {
     149                report_results(glob_last_ts >> 32, count, bytes);
     150                count = 0;
     151                bytes = 0;
     152                for (j = 0; j < filter_count; j++)
     153                        filters[j].count = filters[j].bytes = 0;
     154                glob_last_ts = ts;
     155        }
     156        count += res->total.count;
     157        packets_seen += res->total.count;
     158        bytes += res->total.bytes;
     159        for (j = 0; j < filter_count; j++) {
     160                filters[j].count += res->filters[j].count;
     161                filters[j].bytes += res->filters[j].bytes;
     162        }
     163        free(res);
    167164
    168165        /* Be careful to only call pstop once from within this thread! */
     
    246243{
    247244        libtrace_t *trace = NULL;
    248         if (!merge_inputs)
     245        libtrace_callback_set_t *pktcbs, *repcbs;
     246
     247        if (!merge_inputs)
    249248                create_output(uri);
    250249
     
    268267        }
    269268
    270         trace_cb_starting(trace, cb_starting);
    271         trace_cb_stopping(trace, cb_stopping);
    272         trace_cb_packet(trace, cb_packet);
    273         trace_cb_tick_count(trace, cb_tick);
    274         trace_cb_tick_interval(trace, cb_tick);
    275 
    276         if (trace_pstart(trace, NULL, NULL, process_result)==-1) {
     269        pktcbs = trace_create_callback_set();
     270        trace_set_starting_cb(pktcbs, cb_starting);
     271        trace_set_stopping_cb(pktcbs, cb_stopping);
     272        trace_set_packet_cb(pktcbs, cb_packet);
     273        trace_set_tick_count_cb(pktcbs, cb_tick);
     274        trace_set_tick_interval_cb(pktcbs, cb_tick);
     275
     276        repcbs = trace_create_callback_set();
     277        trace_set_result_cb(repcbs, cb_result);
     278
     279        if (trace_pstart(trace, NULL, pktcbs, repcbs)==-1) {
    277280                trace_perror(trace,"Failed to start trace");
    278281                trace_destroy(trace);
     282                trace_destroy_callback_set(pktcbs);
     283                trace_destroy_callback_set(repcbs);
    279284                if (!merge_inputs)
    280285                        output_destroy(output);
     
    292297
    293298        trace_destroy(trace);
     299        trace_destroy_callback_set(pktcbs);
     300        trace_destroy_callback_set(repcbs);
    294301
    295302        if (!merge_inputs)
  • tools/tracestats/Makefile.am

    r29bbef0 rf625817  
    1 bin_PROGRAMS = tracestats tracestats_parallel
     1bin_PROGRAMS = tracestats
    22bin_SCRIPTS = tracesummary
    33
     
    77include ../Makefile.tools
    88tracestats_SOURCES = tracestats.c
    9 tracestats_parallel_SOURCES = tracestats_parallel.c
Note: See TracChangeset for help on using the changeset viewer.