Changeset c5ac872


Ignore:
Timestamp:
02/05/15 14:07:27 (6 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:
1bad1e2
Parents:
3440627
Message:

Fixed compile error when using DAG 5.2 libraries

The name of the ioctl to fetch DUCK information had changed in DAG version 5
and the old one no longer worked.

Fixed bug where reading from a DAG card using trace_event would not
produce DUCK packets, even if the user requested them.

Added support for the new DUCK format present in DAG version 5.

Location:
lib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lib/format_dag25.c

    r4bd6393 rc5ac872  
    523523                        /* This option is used to specify the frequency of DUCK
    524524                         * updates */
    525                         DUCK.duck_freq = *(int *)data;
     525                        DUCK.duck_freq = *(int *)data;
    526526                        return 0;
    527527                case TRACE_OPTION_SNAPLEN:
     
    584584        struct timeval zero, nopoll;
    585585        uint8_t *top, *bottom, *starttop;
    586         uint64_t diff = 0;
    587586        top = bottom = NULL;
    588587
     
    723722}
    724723
     724#ifdef DAGIOC_CARD_DUCK
     725#define LIBTRACE_DUCK_IOCTL DAGIOC_CARD_DUCK
     726#define LIBTRACE_DUCK_VERSION TRACE_RT_DUCK_5_0
     727#else
     728#ifdef DAGIOCDUCK
     729#define LIBTRACE_DUCK_IOCTL DAGIOCDUCK
     730#define LIBTRACE_DUCK_VERSION TRACE_RT_DUCK_2_5
     731#else
     732#warning "DAG appears to be missing DUCK support"
     733#endif
     734#endif
     735
    725736/* Extracts DUCK information from the DAG card and produces a DUCK packet */
    726737static int dag_get_duckinfo(libtrace_t *libtrace,
    727738                                libtrace_packet_t *packet) {
     739
     740        if (DUCK.duck_freq == 0)
     741                return 0;
     742
     743#ifndef LIBTRACE_DUCK_IOCTL
     744        trace_set_err(libtrace, errno,
     745                "Requested DUCK information but unable to determine the correct ioctl for DUCK");
     746        DUCK.duck_freq = 0;
     747        return -1;
     748#endif
     749
     750        if (DUCK.last_pkt - DUCK.last_duck < DUCK.duck_freq)
     751                return 0;
    728752
    729753        /* Allocate memory for the DUCK data */
     
    745769        /* No need to check if we can get DUCK or not - we're modern
    746770         * enough so just grab the DUCK info */
    747         if ((ioctl(FORMAT_DATA->device->fd, DAGIOCDUCK,
     771        if ((ioctl(FORMAT_DATA->device->fd, LIBTRACE_DUCK_IOCTL,
    748772                                        (duckinf_t *)packet->payload) < 0)) {
    749                 trace_set_err(libtrace, errno, "Error using DAGIOCDUCK");
     773                trace_set_err(libtrace, errno, "Error using DUCK ioctl");
     774                DUCK.duck_freq = 0;
    750775                return -1;
    751776        }
    752777
    753         packet->type = TRACE_RT_DUCK_2_5;
    754 
    755         /* Set the packet's tracce to point at a DUCK trace, so that the
     778        packet->type = LIBTRACE_DUCK_VERSION;
     779
     780        /* Set the packet's trace to point at a DUCK trace, so that the
    756781         * DUCK format functions will be called on the packet rather than the
    757782         * DAG ones */
    758783        if (!DUCK.dummy_duck)
    759                 DUCK.dummy_duck = trace_create_dead("rt:localhost:3434");
     784                DUCK.dummy_duck = trace_create_dead("duck:dummy");
    760785        packet->trace = DUCK.dummy_duck;
     786        DUCK.last_duck = DUCK.last_pkt;
    761787        return sizeof(duckinf_t);
    762788}
     
    10571083
    10581084        /* Check if we're due for a DUCK report */
    1059         if (DUCK.last_pkt - DUCK.last_duck > DUCK.duck_freq &&
    1060                         DUCK.duck_freq != 0) {
    1061                 size = dag_get_duckinfo(libtrace, packet);
    1062                 DUCK.last_duck = DUCK.last_pkt;
    1063                 if (size != 0) {
    1064                         return size;
    1065                 }
    1066                 /* No DUCK support, so don't waste our time anymore */
    1067                 DUCK.duck_freq = 0;
    1068         }
     1085        size = dag_get_duckinfo(libtrace, packet);
     1086
     1087        if (size != 0)
     1088                return size;
     1089
    10691090
    10701091        /* Don't let anyone try to free our DAG memory hole! */
     
    11241145        int numbytes;
    11251146        uint32_t flags = 0;
    1126         struct timeval minwait;
     1147        struct timeval minwait, tv;
    11271148       
    11281149        minwait.tv_sec = 0;
    11291150        minwait.tv_usec = 10000;
     1151
     1152        /* Check if we're meant to provide a DUCK update */
     1153        numbytes = dag_get_duckinfo(libtrace, packet);
     1154        if (numbytes < 0) {
     1155                event.type = TRACE_EVENT_TERMINATE;
     1156                return event;
     1157        } else if (numbytes > 0) {
     1158                event.type = TRACE_EVENT_PACKET;
     1159                return event;
     1160        }
    11301161       
    11311162        if (dag_set_stream_poll(FORMAT_DATA->device->fd,
     
    12001231                }
    12011232
     1233                /* Update the DUCK timer */
     1234                tv = trace_get_timeval(packet);
     1235                DUCK.last_pkt = tv.tv_sec;
     1236               
    12021237                if (libtrace->snaplen > 0) {
    12031238                        trace_set_capture_length(packet, libtrace->snaplen);
  • lib/format_duck.c

    r9b097ea rc5ac872  
    216216                duck_size = sizeof(duck2_5_t);
    217217                packet->type = TRACE_RT_DUCK_2_5;
     218        } else if (DATA(libtrace)->dag_version == TRACE_RT_DUCK_5_0) {
     219                duck_size = sizeof(duck5_0_t);
     220                packet->type = TRACE_RT_DUCK_5_0;
    218221        } else {
    219222                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET,
     
    252255
    253256        if (packet->type != TRACE_RT_DUCK_2_4
    254                         && packet->type != TRACE_RT_DUCK_2_5) {
     257                        && packet->type != TRACE_RT_DUCK_2_5 &&
     258                        packet->type != TRACE_RT_DUCK_5_0) {
    255259                trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET,
    256260                                "Only DUCK packets may be written to a DUCK file");
     
    287291                case TRACE_RT_DUCK_2_5:
    288292                        return sizeof(duck2_5_t);
     293                case TRACE_RT_DUCK_5_0:
     294                        return sizeof(duck5_0_t);
    289295                default:
    290296                        trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET,
  • lib/format_rt.c

    rc70f59f rc5ac872  
    430430                case TRACE_RT_DUCK_2_4:
    431431                case TRACE_RT_DUCK_2_5:
     432                case TRACE_RT_DUCK_5_0:
    432433                        if (!RT_INFO->dummy_duck) {
    433434                                RT_INFO->dummy_duck = trace_create_dead("duck:dummy");
  • lib/libtrace.h.in

    r3fc3267 rc5ac872  
    383383        TRACE_RT_CLIENTDROP     =17,/**< Reliable client was lost */
    384384        TRACE_RT_METADATA       =18,/**< Packet contains server meta-data */
     385        TRACE_RT_DUCK_5_0       =19,/**< Dag 5.0 Duck */
    385386
    386387        /** Not actually used - all DATA types begin from this value */
  • lib/rt_protocol.h

    r81c0b9e rc5ac872  
    249249} PACKED duck2_5_t;
    250250
     251typedef struct duck5_0 {
     252        int64_t         Phase_Correction;
     253        uint64_t        Last_Ticks;
     254        uint64_t        Last_TSC;
     255        /* XXX Stat_Start and Stat_End are time_t in dagioctl.h, which means
     256         * they could in theory be 32 or 64 bit depending on the architecture
     257         * when capturing. I'm going to assume 5.0 era DAG captures are taking
     258         * place on a 64 bit arch, rather than have to deal with the varying
     259         * sizes (especially given nobody really uses DUCK these days).
     260         */
     261        uint64_t        Stat_Start, Stat_End;
     262        uint32_t        Crystal_Freq;
     263        uint32_t        Synth_Freq;
     264        uint32_t        Resyncs;
     265        uint32_t        Bad_Pulses;
     266        uint32_t        Worst_Freq_Err, Worst_Phase_Err;
     267        uint32_t        Health_Thresh;
     268        uint32_t        Pulses, Single_Pulses_Missing, Longest_Pulse_Missing;
     269        uint32_t        Health, Sickness;
     270        int32_t         Freq_Err, Phase_Err;
     271        uint32_t        Set_Duck_Field;
     272} PACKED duck5_0_t;
     273
    251274/*
    252275typedef struct rt_duck_2_4 {
Note: See TracChangeset for help on using the changeset viewer.