- Timestamp:
- 02/27/15 17:31:03 (6 years ago)
- 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:
- 98dc1ba
- Parents:
- 7718e54
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/libtrace.h.in
r2adc1d0 r0ec8a7c 3507 3507 float rfloat; 3508 3508 double rdouble; 3509 } libtrace_generic_types_t; 3509 } libtrace_generic_t; 3510 ct_assert(sizeof(libtrace_generic_t) == 8); 3510 3511 3511 3512 typedef struct libtrace_message_t { 3512 3513 int code; 3513 libtrace_generic_t ypes_tadditional;3514 libtrace_generic_t additional; 3514 3515 libtrace_thread_t *sender; 3515 3516 } libtrace_message_t; … … 3518 3519 typedef struct libtrace_result_t { 3519 3520 uint64_t key; 3520 libtrace_generic_t ypes_tvalue;3521 libtrace_generic_t value; 3521 3522 int type; 3522 3523 } libtrace_result_t; … … 3525 3526 #define RESULT_TICK 2 3526 3527 3527 3528 typedef void* (*fn_per_pkt)(libtrace_t* trace, libtrace_packet_t *p, libtrace_message_t *m, libtrace_thread_t *thread); 3528 /** 3529 * The definition for the main function that the user supplies to process 3530 * packets. 3531 * 3532 * @param trace The trace the packet is related to. 3533 * @param thread The thread the trace is related to. 3534 * @param mesg_code The type of data ready, the most important being MESSAGE_PACKET. 3535 * In this case data.pkt contains the packet. 3536 * @param data A generic union of types that fit into 8 bytes, containing 3537 * information dependent upon the mesg_code. 3538 * @param sender The thread that the message originated from. 3539 * 3540 * The values of data and sender depend upon the mesg_code. Please see the 3541 * documentation for the message as to what value these will contain. 3542 */ 3543 typedef void* (*fn_per_pkt)(libtrace_t* trace, 3544 libtrace_thread_t *thread, 3545 int mesg_code, 3546 libtrace_generic_t data, 3547 libtrace_thread_t *sender); 3529 3548 typedef void (*fn_reporter)(libtrace_t* trace, libtrace_result_t *r, libtrace_message_t *m); 3530 3549 typedef uint64_t (*fn_hasher)(const libtrace_packet_t* packet, void *data); … … 3537 3556 DLLEXPORT void libtrace_result_set_key(libtrace_result_t * result, uint64_t key); 3538 3557 DLLEXPORT uint64_t libtrace_result_get_key(libtrace_result_t * result); 3539 DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_t ypes_tvalue);3540 DLLEXPORT libtrace_generic_t ypes_tlibtrace_result_get_value(libtrace_result_t * result);3541 DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_t ypes_tvalue);3558 DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_t value); 3559 DLLEXPORT libtrace_generic_t libtrace_result_get_value(libtrace_result_t * result); 3560 DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_t value); 3542 3561 DLLEXPORT void trace_destroy_result(libtrace_result_t ** result); 3543 3562 … … 3549 3568 3550 3569 3551 DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_t ypes_tvalue, int type);3570 DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_t value, int type); 3552 3571 typedef struct libtrace_vector libtrace_vector_t; 3553 3572 … … 3599 3618 3600 3619 enum libtrace_messages { 3620 MESSAGE_PACKET, 3601 3621 MESSAGE_STARTING, 3602 3622 MESSAGE_RESUMING, … … 3613 3633 MESSAGE_POST_RANGE, 3614 3634 MESSAGE_TICK, 3615 MESSAGE_USER 3635 MESSAGE_USER = 1000 3616 3636 }; 3617 3637 … … 3854 3874 * chosen. 3855 3875 */ 3856 libtrace_generic_t ypes_tconfiguration;3876 libtrace_generic_t configuration; 3857 3877 }; 3858 3878 3859 DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_t ypes_tconfig);3879 DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_t config); 3860 3880 3861 3881 #define READ_EOF 0 -
lib/trace_parallel.c
r7718e54 r0ec8a7c 385 385 libtrace_packet_t **packet, 386 386 bool tracetime) { 387 387 388 if ((*packet)->error > 0) { 388 389 if (tracetime) { … … 391 392 } 392 393 t->accepted_packets++; 393 *packet = (*trace->per_pkt)(trace, *packet, NULL, t); 394 libtrace_generic_t data = {.pkt = *packet}; 395 *packet = (*trace->per_pkt)(trace, t, MESSAGE_PACKET, data, t); 394 396 trace_fin_packet(*packet); 395 397 } else { 396 libtrace_message_t message;397 398 assert((*packet)->error == READ_TICK); 398 message.code = MESSAGE_TICK; 399 message.additional.uint64 = trace_packet_get_order(*packet); 400 message.sender = t; 401 (*trace->per_pkt)(trace, NULL, &message, t); 399 libtrace_generic_t data = {.uint64 = trace_packet_get_order(*packet)}; 400 (*trace->per_pkt)(trace, t, MESSAGE_TICK, data, t); 402 401 } 403 402 return 0; … … 462 461 libtrace_packet_t *packets[], 463 462 int nb_packets, int *empty, int *offset) { 464 libtrace_message_t message = {0};465 463 libtrace_packet_t * packet = NULL; 466 464 467 465 /* Let the user thread know we are going to pause */ 468 message.code = MESSAGE_PAUSING; 469 message.sender = t; 470 (*trace->per_pkt)(trace, NULL, &message, t); 466 (*trace->per_pkt)(trace, t, MESSAGE_PAUSING, (libtrace_generic_t){0}, t); 471 467 472 468 /* Send through any remaining packets (or messages) without delay */ … … 511 507 /* Now we do the actual pause, this returns when we resumed */ 512 508 trace_thread_pause(trace, t); 513 message.code = MESSAGE_RESUMING; 514 (*trace->per_pkt)(trace, NULL, &message, t); 509 (*trace->per_pkt)(trace, t, MESSAGE_RESUMING, (libtrace_generic_t){0}, t); 515 510 return 1; 516 511 } … … 558 553 559 554 /* Let the per_packet function know we have started */ 560 message.code = MESSAGE_STARTING; 561 message.sender = t; 562 (*trace->per_pkt)(trace, NULL, &message, t); 563 message.code = MESSAGE_RESUMING; 564 (*trace->per_pkt)(trace, NULL, &message, t); 565 555 (*trace->per_pkt)(trace, t, MESSAGE_STARTING, (libtrace_generic_t){0}, t); 556 (*trace->per_pkt)(trace, t, MESSAGE_RESUMING, (libtrace_generic_t){0}, t); 566 557 567 558 for (;;) { … … 586 577 goto eof; 587 578 } 588 (*trace->per_pkt)(trace, NULL, &message, t);579 (*trace->per_pkt)(trace, t, message.code, message.additional, message.sender); 589 580 /* Continue and the empty messages out before packets */ 590 581 continue; … … 653 644 654 645 // Let the per_packet function know we have stopped 655 message.code = MESSAGE_PAUSING; 656 message.sender = t; 657 (*trace->per_pkt)(trace, NULL, &message, t); 658 message.code = MESSAGE_STOPPING; 659 message.additional.uint64 = 0; 660 (*trace->per_pkt)(trace, NULL, &message, t); 646 (*trace->per_pkt)(trace, t, MESSAGE_PAUSING, (libtrace_generic_t){0}, t); 647 (*trace->per_pkt)(trace, t, MESSAGE_STOPPING, (libtrace_generic_t){0}, t); 661 648 662 649 // Free any remaining packets … … 2101 2088 return result->key; 2102 2089 } 2103 DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_t ypes_tvalue) {2090 DLLEXPORT void libtrace_result_set_value(libtrace_result_t * result, libtrace_generic_t value) { 2104 2091 result->value = value; 2105 2092 } 2106 DLLEXPORT libtrace_generic_t ypes_tlibtrace_result_get_value(libtrace_result_t * result) {2093 DLLEXPORT libtrace_generic_t libtrace_result_get_value(libtrace_result_t * result) { 2107 2094 return result->value; 2108 2095 } 2109 DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_t ypes_tvalue) {2096 DLLEXPORT void libtrace_result_set_key_value(libtrace_result_t * result, uint64_t key, libtrace_generic_t value) { 2110 2097 result->key = key; 2111 2098 result->value = value; … … 2155 2142 * Should only be called by a perpkt thread, i.e. from a perpkt handler 2156 2143 */ 2157 DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_t ypes_tvalue, int type) {2144 DLLEXPORT void trace_publish_result(libtrace_t *libtrace, libtrace_thread_t *t, uint64_t key, libtrace_generic_t value, int type) { 2158 2145 libtrace_result_t res; 2159 2146 res.type = type; … … 2168 2155 * Sets a combiner function against the trace. 2169 2156 */ 2170 DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_t ypes_tconfig){2157 DLLEXPORT void trace_set_combiner(libtrace_t *trace, const libtrace_combine_t *combiner, libtrace_generic_t config){ 2171 2158 if (combiner) { 2172 2159 trace->combiner = *combiner;
Note: See TracChangeset
for help on using the changeset viewer.