Ignore:
Timestamp:
08/21/15 11:22:30 (6 years ago)
Author:
Richard Sanger <rsangerarj@…>
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:
eea427f
Parents:
76291d1
Message:

Updates the new interface to be more complete

This should work around any issues with systems without thread support.
This still remains compatible with existing code.
Examples/tools/tests still need to be updated to make use of the new interface.
And tests also need to be updated.
Adds debug memory stats as an option to configure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace_parallel.h

    r76291d1 r4007dbb  
    154154         * @param data unused, do not use this
    155155         * @param sender The sender will be set as the current thread
     156         * @return When using a function callback for starting, the returned
     157         * value is stored against the thread tls. Otherwise the return is ignored.
    156158         */
    157159        MESSAGE_STARTING,
     
    211213         * sent once a new packet is encountered
    212214         *
    213          * @
     215         * @see trace_get_first_packet()
    214216         */
    215217        MESSAGE_FIRST_PACKET,
     
    225227         * trace_post_reporter()
    226228         *
    227          * @see trace_get_first_packet()
    228229         */
    229230        MESSAGE_POST_REPORTER,
     
    236237         * with an earlier time-stamp.
    237238         *
    238          * @param data data.uint64_t holds the system time-stamp in the
     239         * @param data data.uint64 holds the system time-stamp in the
    239240         * erf format
    240241         * @param sender should be ignored
     
    248249         * threads will see it between the same packets.
    249250         *
    250          * @param data The number of packets seen so far across all threads
     251         * @param data data.uint64 holds the number of packets seen so far across all threads
    251252         * @param sender Set to the current per-packet thread
    252253         */
     
    397398/**
    398399 * The definition for the main function that the user supplies to process
    399  * packets.
     400 * messages.
    400401 *
    401402 * @param trace The trace the packet is related to.
     
    412413 * documentation for the message as to what value these will contain.
    413414 */
    414 typedef void* (*fn_per_pkt)(libtrace_t* trace,
    415                             libtrace_thread_t *thread,
    416                             int mesg_code,
    417                             libtrace_generic_t data,
    418                             libtrace_thread_t *sender);
     415typedef void* (*fn_cb_msg)(libtrace_t* trace,
     416                           libtrace_thread_t *thread,
     417                           int mesg_code,
     418                           libtrace_generic_t data,
     419                           libtrace_thread_t *sender);
    419420
    420421/**
     
    452453 * @param libtrace The input trace to start
    453454 * @param global_blob Global data related to this trace accessible using trace_get_global()
    454  * @param per_pkt A user supplied function called when a packet is ready
     455 * @param per_msg A user supplied function called when a message is ready
    455456 * @param reporter A user supplied function called when a result is ready.
    456457 * Optional if NULL the reporter thread will not be started.
     
    459460 * This can also be used to restart an existing parallel trace,
    460461 * that has previously been paused using trace_ppause().
    461  * In this case global_blob,per_pkt and reporter will only be updated
     462 * In this case global_blob,per_msg and reporter will only be updated
    462463 * if they are non-null. Otherwise their previous values will be maintained.
    463464 *
    464465 */
    465466DLLEXPORT int trace_pstart(libtrace_t *libtrace, void* global_blob,
    466                            fn_per_pkt per_pkt, fn_reporter reporter);
    467 
     467                           fn_cb_msg per_msg, fn_reporter reporter);
     468
     469/**
     470 *
     471 * @param libtrace The parallel trace
     472 * @param t The thread that is running
     473 * @param global The global storage
     474 * @return The returned value is stored against the threads tls.
     475 *         This is typically passed as tls argument to other messages.
     476 */
     477typedef void* (*fn_cb_starting)(libtrace_t *libtrace,
     478                                     libtrace_thread_t *t,
     479                                     void *global);
     480
     481/**
     482 * @param libtrace The parallel trace
     483 * @param t The thread that is running
     484 * @param global The global storage
     485 * @param tls The thread local storage
     486 */
     487typedef void (*fn_cb_dataless)(libtrace_t *libtrace,
     488                                    libtrace_thread_t *t,
     489                                    void *global,
     490                                    void *tls);
     491
     492/**
     493 * @param libtrace The parallel trace
     494 * @param t The thread that is running
     495 * @param global The global storage
     496 * @param tls The thread local storage
     497 */
     498typedef void (*fn_cb_first_packet)(libtrace_t *libtrace,
     499                                   libtrace_thread_t *t,
     500                                   void *global,
     501                                   void *tls,
     502                                   libtrace_packet_t *first_packet,
     503                                   libtrace_thread_t *sender);
     504
     505/**
     506 * @param libtrace The parallel trace
     507 * @param t The thread that is running
     508 * @param global The global storage
     509 * @param tls The thread local storage
     510 * @param uint64_t Either the timestamp or packet count depending on message type
     511 */
     512typedef void (*fn_cb_tick)(libtrace_t *libtrace,
     513                           libtrace_thread_t *t,
     514                           void *global,
     515                           void *tls,
     516                           uint64_t order);
    468517
    469518/**
    470519 * @param libtrace The parallel trace
    471520 * @param t The thread
    472  * @param data The data associated with the message
     521 * @param packet The packet associated with the message
    473522 * @param global The global storage
    474523 * @param tls The thread local storage
    475  */
    476 typedef void* (*fn_handler)(libtrace_t *libtrace,
    477                                libtrace_thread_t *t,
    478                                libtrace_generic_t data,
    479                                void *global,
    480                                void *tls);
     524 *
     525 * @return optionally a packet which is handed back to the library,
     526 *         typically this is the packet supplied. Otherwise NULL.
     527 */
     528typedef libtrace_packet_t* (*fn_cb_packet)(libtrace_t *libtrace,
     529                                           libtrace_thread_t *t,
     530                                           void *global,
     531                                           void *tls,
     532                                           libtrace_packet_t *packet);
    481533
    482534/** Registers a built-in message with a handler.
     
    489541 * @return 0 if successful otherwise -1.
    490542 */
    491 DLLEXPORT int trace_set_handler(libtrace_t *libtrace, enum libtrace_messages message, fn_handler handler);
     543
     544DLLEXPORT int trace_cb_starting(libtrace_t *libtrace, fn_cb_starting handler);
     545DLLEXPORT int trace_cb_stopping(libtrace_t *libtrace, fn_cb_dataless handler);
     546DLLEXPORT int trace_cb_resuming(libtrace_t *libtrace, fn_cb_dataless handler);
     547DLLEXPORT int trace_cb_pausing(libtrace_t *libtrace, fn_cb_dataless handler);
     548DLLEXPORT int trace_cb_packet(libtrace_t *libtrace, fn_cb_packet handler);
     549DLLEXPORT int trace_cb_first_packet(libtrace_t *libtrace, fn_cb_first_packet handler);
     550DLLEXPORT int trace_cb_tick_count(libtrace_t *libtrace, fn_cb_tick handler);
     551DLLEXPORT int trace_cb_tick_interval(libtrace_t *libtrace, fn_cb_tick handler);
    492552
    493553/** Pauses a trace previously started with trace_pstart()
Note: See TracChangeset for help on using the changeset viewer.