Changeset c5ac872
- Timestamp:
- 02/05/15 14:07:27 (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:
- 1bad1e2
- Parents:
- 3440627
- Location:
- lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_dag25.c
r4bd6393 rc5ac872 523 523 /* This option is used to specify the frequency of DUCK 524 524 * updates */ 525 525 DUCK.duck_freq = *(int *)data; 526 526 return 0; 527 527 case TRACE_OPTION_SNAPLEN: … … 584 584 struct timeval zero, nopoll; 585 585 uint8_t *top, *bottom, *starttop; 586 uint64_t diff = 0;587 586 top = bottom = NULL; 588 587 … … 723 722 } 724 723 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 725 736 /* Extracts DUCK information from the DAG card and produces a DUCK packet */ 726 737 static int dag_get_duckinfo(libtrace_t *libtrace, 727 738 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; 728 752 729 753 /* Allocate memory for the DUCK data */ … … 745 769 /* No need to check if we can get DUCK or not - we're modern 746 770 * 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, 748 772 (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; 750 775 return -1; 751 776 } 752 777 753 packet->type = TRACE_RT_DUCK_2_5;754 755 /* Set the packet's trac ce to point at a DUCK trace, so that the778 packet->type = LIBTRACE_DUCK_VERSION; 779 780 /* Set the packet's trace to point at a DUCK trace, so that the 756 781 * DUCK format functions will be called on the packet rather than the 757 782 * DAG ones */ 758 783 if (!DUCK.dummy_duck) 759 DUCK.dummy_duck = trace_create_dead(" rt:localhost:3434");784 DUCK.dummy_duck = trace_create_dead("duck:dummy"); 760 785 packet->trace = DUCK.dummy_duck; 786 DUCK.last_duck = DUCK.last_pkt; 761 787 return sizeof(duckinf_t); 762 788 } … … 1057 1083 1058 1084 /* 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 1069 1090 1070 1091 /* Don't let anyone try to free our DAG memory hole! */ … … 1124 1145 int numbytes; 1125 1146 uint32_t flags = 0; 1126 struct timeval minwait ;1147 struct timeval minwait, tv; 1127 1148 1128 1149 minwait.tv_sec = 0; 1129 1150 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 } 1130 1161 1131 1162 if (dag_set_stream_poll(FORMAT_DATA->device->fd, … … 1200 1231 } 1201 1232 1233 /* Update the DUCK timer */ 1234 tv = trace_get_timeval(packet); 1235 DUCK.last_pkt = tv.tv_sec; 1236 1202 1237 if (libtrace->snaplen > 0) { 1203 1238 trace_set_capture_length(packet, libtrace->snaplen); -
lib/format_duck.c
r9b097ea rc5ac872 216 216 duck_size = sizeof(duck2_5_t); 217 217 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; 218 221 } else { 219 222 trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, … … 252 255 253 256 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) { 255 259 trace_set_err_out(libtrace, TRACE_ERR_BAD_PACKET, 256 260 "Only DUCK packets may be written to a DUCK file"); … … 287 291 case TRACE_RT_DUCK_2_5: 288 292 return sizeof(duck2_5_t); 293 case TRACE_RT_DUCK_5_0: 294 return sizeof(duck5_0_t); 289 295 default: 290 296 trace_set_err(packet->trace,TRACE_ERR_BAD_PACKET, -
lib/format_rt.c
rc70f59f rc5ac872 430 430 case TRACE_RT_DUCK_2_4: 431 431 case TRACE_RT_DUCK_2_5: 432 case TRACE_RT_DUCK_5_0: 432 433 if (!RT_INFO->dummy_duck) { 433 434 RT_INFO->dummy_duck = trace_create_dead("duck:dummy"); -
lib/libtrace.h.in
r3fc3267 rc5ac872 383 383 TRACE_RT_CLIENTDROP =17,/**< Reliable client was lost */ 384 384 TRACE_RT_METADATA =18,/**< Packet contains server meta-data */ 385 TRACE_RT_DUCK_5_0 =19,/**< Dag 5.0 Duck */ 385 386 386 387 /** Not actually used - all DATA types begin from this value */ -
lib/rt_protocol.h
r81c0b9e rc5ac872 249 249 } PACKED duck2_5_t; 250 250 251 typedef 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 251 274 /* 252 275 typedef struct rt_duck_2_4 {
Note: See TracChangeset
for help on using the changeset viewer.