4b5f69ecd839c82ee37980034767d81411cdb4b0
[lttv.git] / lttv / lttv / sync / event_processing_lttng_standard.c
1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2009 Benjamin Poirier <benjamin.poirier@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
16 * MA 02111-1307, USA.
17 */
18
19 #define _ISOC99_SOURCE
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <linux/if_ether.h>
26 #include <math.h>
27 #include <netinet/in.h>
28 #include <stdarg.h>
29 #include <stdint.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 #include "sync_chain.h"
34 #include "event_processing_lttng_common.h"
35
36 #include "event_processing_lttng_standard.h"
37
38
39 // Functions common to all processing modules
40 static void initProcessingLTTVStandard(SyncState* const syncState, ...);
41 static void destroyProcessingLTTVStandard(SyncState* const syncState);
42
43 static void finalizeProcessingLTTVStandard(SyncState* const syncState);
44 static void printProcessingStatsLTTVStandard(SyncState* const syncState);
45 static void writeProcessingGraphVariablesLTTVStandard(SyncState* const
46 syncState, const unsigned int i);
47 static void writeProcessingTraceTraceOptionsLTTVStandard(SyncState* const
48 syncState, const unsigned int i, const unsigned int j);
49 static void writeProcessingTraceTimeOptionsLTTVStandard(SyncState* const
50 syncState, const unsigned int i, const unsigned int j);
51
52 // Functions specific to this module
53 static void registerProcessingLTTVStandard() __attribute__((constructor (102)));
54 static gboolean processEventLTTVStandard(void* hookData, void* callData);
55 static void partialDestroyProcessingLTTVStandard(SyncState* const syncState);
56
57
58 static ProcessingModule processingModuleLTTVStandard = {
59 .name= "LTTV-standard",
60 .initProcessing= &initProcessingLTTVStandard,
61 .destroyProcessing= &destroyProcessingLTTVStandard,
62 .finalizeProcessing= &finalizeProcessingLTTVStandard,
63 .printProcessingStats= &printProcessingStatsLTTVStandard,
64 .graphFunctions= {
65 .writeVariables= &writeProcessingGraphVariablesLTTVStandard,
66 .writeTraceTraceOptions= &writeProcessingTraceTraceOptionsLTTVStandard,
67 .writeTraceTimeOptions= &writeProcessingTraceTimeOptionsLTTVStandard,
68 },
69 };
70
71
72 /*
73 * Processing Module registering function
74 */
75 static void registerProcessingLTTVStandard()
76 {
77 g_queue_push_tail(&processingModules, &processingModuleLTTVStandard);
78
79 createQuarks();
80 }
81
82
83 /*
84 * Allocate and initialize data structures for synchronizing a traceset.
85 * Register event hooks.
86 *
87 * Args:
88 * syncState: container for synchronization data.
89 * This function allocates these processingData members:
90 * traceNumTable
91 * pendingRecv
92 * hookListList
93 * stats
94 * traceSetContext: LttvTracesetContext*, set of LTTV traces
95 */
96 static void initProcessingLTTVStandard(SyncState* const syncState, ...)
97 {
98 unsigned int i;
99 ProcessingDataLTTVStandard* processingData;
100 va_list ap;
101
102 processingData= malloc(sizeof(ProcessingDataLTTVStandard));
103 syncState->processingData= processingData;
104 va_start(ap, syncState);
105 processingData->traceSetContext= va_arg(ap, LttvTracesetContext*);
106 va_end(ap);
107
108 if (syncState->stats)
109 {
110 processingData->stats= calloc(1, sizeof(ProcessingStatsLTTVStandard));
111 }
112 else
113 {
114 processingData->stats= NULL;
115 }
116
117 processingData->traceNumTable= g_hash_table_new(&g_direct_hash, NULL);
118 processingData->hookListList= g_array_sized_new(FALSE, FALSE,
119 sizeof(GArray*), syncState->traceNb);
120 processingData->pendingRecv= malloc(sizeof(GHashTable*) *
121 syncState->traceNb);
122
123 for(i= 0; i < syncState->traceNb; i++)
124 {
125 g_hash_table_insert(processingData->traceNumTable,
126 processingData->traceSetContext->traces[i]->t, (gpointer) i);
127 }
128
129 if (syncState->graphsStream)
130 {
131 processingData->graphs= malloc(syncState->traceNb *
132 sizeof(ProcessingGraphsLTTVStandard));
133
134 for(i= 0; i < syncState->traceNb; i++)
135 {
136 LttTrace* traceI= processingData->traceSetContext->traces[i]->t;
137
138 processingData->graphs[i].startFreq= traceI->start_freq;
139 processingData->graphs[i].freqScale= traceI->freq_scale;
140 }
141 }
142 else
143 {
144 processingData->graphs= NULL;
145 }
146
147 for(i= 0; i < syncState->traceNb; i++)
148 {
149 processingData->pendingRecv[i]= g_hash_table_new_full(&g_direct_hash,
150 NULL, NULL, &gdnDestroyEvent);
151 }
152
153 registerHooks(processingData->hookListList,
154 processingData->traceSetContext, &processEventLTTVStandard, syncState,
155 syncState->matchingModule->canMatch);
156 }
157
158
159 /*
160 * Call the partial processing destroyer, obtain and adjust the factors from
161 * downstream
162 *
163 * Args:
164 * syncState container for synchronization data.
165 */
166 static void finalizeProcessingLTTVStandard(SyncState* const syncState)
167 {
168 unsigned int i;
169 GArray* factors;
170 double minOffset, minDrift;
171 unsigned int refFreqTrace;
172 ProcessingDataLTTVStandard* processingData;
173
174 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
175
176 partialDestroyProcessingLTTVStandard(syncState);
177
178 factors= syncState->matchingModule->finalizeMatching(syncState);
179
180 /* The offsets are adjusted so the lowest one is 0. This is done because
181 * of a Lttv specific limitation: events cannot have negative times. By
182 * having non-negative offsets, events cannot be moved backwards to
183 * negative times.
184 */
185 minOffset= 0;
186 for (i= 0; i < syncState->traceNb; i++)
187 {
188 minOffset= MIN(g_array_index(factors, Factors, i).offset, minOffset);
189 }
190
191 for (i= 0; i < syncState->traceNb; i++)
192 {
193 g_array_index(factors, Factors, i).offset-= minOffset;
194 }
195
196 /* Because the timestamps are corrected at the TSC level (not at the
197 * LttTime level) all trace frequencies must be made equal. We choose to
198 * use the frequency of the system with the lowest drift
199 */
200 minDrift= INFINITY;
201 refFreqTrace= 0;
202 for (i= 0; i < syncState->traceNb; i++)
203 {
204 if (g_array_index(factors, Factors, i).drift < minDrift)
205 {
206 minDrift= g_array_index(factors, Factors, i).drift;
207 refFreqTrace= i;
208 }
209 }
210 g_assert(syncState->traceNb == 0 || minDrift != INFINITY);
211
212 // Write the factors to the LttTrace structures
213 for (i= 0; i < syncState->traceNb; i++)
214 {
215 LttTrace* t;
216 Factors* traceFactors;
217
218 t= processingData->traceSetContext->traces[i]->t;
219 traceFactors= &g_array_index(factors, Factors, i);
220
221 t->drift= traceFactors->drift;
222 t->offset= traceFactors->offset;
223 t->start_freq=
224 processingData->traceSetContext->traces[refFreqTrace]->t->start_freq;
225 t->freq_scale=
226 processingData->traceSetContext->traces[refFreqTrace]->t->freq_scale;
227 t->start_time_from_tsc =
228 ltt_time_from_uint64(tsc_to_uint64(t->freq_scale, t->start_freq,
229 t->drift * t->start_tsc + t->offset));
230 }
231
232 g_array_free(factors, TRUE);
233
234 lttv_traceset_context_compute_time_span(processingData->traceSetContext,
235 &processingData->traceSetContext->time_span);
236
237 g_debug("traceset start %ld.%09ld end %ld.%09ld",
238 processingData->traceSetContext->time_span.start_time.tv_sec,
239 processingData->traceSetContext->time_span.start_time.tv_nsec,
240 processingData->traceSetContext->time_span.end_time.tv_sec,
241 processingData->traceSetContext->time_span.end_time.tv_nsec);
242 }
243
244
245 /*
246 * Print statistics related to processing Must be called after
247 * finalizeProcessing.
248 *
249 * Args:
250 * syncState container for synchronization data.
251 */
252 static void printProcessingStatsLTTVStandard(SyncState* const syncState)
253 {
254 ProcessingDataLTTVStandard* processingData;
255
256 if (!syncState->stats)
257 {
258 return;
259 }
260
261 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
262
263 printf("LTTV processing stats:\n");
264 printf("\treceived frames: %d\n", processingData->stats->totRecv);
265 printf("\treceived frames that are IP: %d\n",
266 processingData->stats->totRecvIp);
267 if (syncState->matchingModule->canMatch[TCP])
268 {
269 printf("\treceived and processed packets that are TCP: %d\n",
270 processingData->stats->totRecvTCP);
271 }
272 if (syncState->matchingModule->canMatch[UDP])
273 {
274 printf("\treceived and processed packets that are UDP: %d\n",
275 processingData->stats->totRecvUDP);
276 }
277 if (syncState->matchingModule->canMatch[TCP])
278 {
279 printf("\tsent packets that are TCP: %d\n",
280 processingData->stats->totOutE);
281 }
282 }
283
284
285 /*
286 * Unregister event hooks. Deallocate processingData.
287 *
288 * Args:
289 * syncState: container for synchronization data.
290 * This function deallocates these processingData members:
291 * stats
292 */
293 static void destroyProcessingLTTVStandard(SyncState* const syncState)
294 {
295 ProcessingDataLTTVStandard* processingData;
296
297 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
298
299 if (processingData == NULL)
300 {
301 return;
302 }
303
304 partialDestroyProcessingLTTVStandard(syncState);
305
306 if (syncState->stats)
307 {
308 free(processingData->stats);
309 }
310
311 if (syncState->graphsStream)
312 {
313 free(processingData->graphs);
314 }
315
316 free(syncState->processingData);
317 syncState->processingData= NULL;
318 }
319
320
321 /*
322 * Unregister event hooks. Deallocate some of processingData.
323 *
324 * This function can be called right after the events have been processed to
325 * free some data structures that are not needed for finalization.
326 *
327 * Args:
328 * syncState: container for synchronization data.
329 * This function deallocates these members:
330 * traceNumTable
331 * hookListList
332 * pendingRecv
333 */
334 static void partialDestroyProcessingLTTVStandard(SyncState* const syncState)
335 {
336 unsigned int i;
337 ProcessingDataLTTVStandard* processingData;
338
339 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
340
341 if (processingData == NULL || processingData->traceNumTable == NULL)
342 {
343 return;
344 }
345
346 g_hash_table_destroy(processingData->traceNumTable);
347 processingData->traceNumTable= NULL;
348
349 for(i= 0; i < syncState->traceNb; i++)
350 {
351
352 g_debug("Cleaning up pendingRecv list");
353 g_hash_table_destroy(processingData->pendingRecv[i]);
354 }
355 free(processingData->pendingRecv);
356
357 unregisterHooks(processingData->hookListList,
358 processingData->traceSetContext);
359 }
360
361
362 /*
363 * Lttv hook function that will be called for network events
364 *
365 * Args:
366 * hookData: LttvTraceHook* for the type of event that generated the call
367 * callData: LttvTracefileContext* at the moment of the event
368 *
369 * Returns:
370 * FALSE Always returns FALSE, meaning to keep processing hooks for
371 * this event
372 */
373 static gboolean processEventLTTVStandard(void* hookData, void* callData)
374 {
375 LttvTraceHook* traceHook;
376 LttvTracefileContext* tfc;
377 LttEvent* event;
378 LttCycleCount tsc;
379 LttTime time;
380 WallTime wTime;
381 LttTrace* trace;
382 unsigned long traceNum;
383 struct marker_info* info;
384 SyncState* syncState;
385 ProcessingDataLTTVStandard* processingData;
386
387 traceHook= (LttvTraceHook*) hookData;
388 tfc= (LttvTracefileContext*) callData;
389 trace= tfc->t_context->t;
390 syncState= (SyncState*) traceHook->hook_data;
391 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
392 event= ltt_tracefile_get_event(tfc->tf);
393 info= marker_get_info_from_id(tfc->tf->mdata, event->event_id);
394 tsc= ltt_event_cycle_count(event);
395 time= ltt_event_time(event);
396 wTime.seconds= time.tv_sec;
397 wTime.nanosec= time.tv_nsec;
398
399 g_assert(g_hash_table_lookup_extended(processingData->traceNumTable,
400 trace, NULL, (gpointer*) &traceNum));
401
402 g_debug("Process event: time: %ld.%09ld trace: %ld (%p) name: %s ",
403 time.tv_sec, time.tv_nsec, traceNum, trace,
404 g_quark_to_string(info->name));
405
406 if (info->name == LTT_EVENT_DEV_XMIT_EXTENDED)
407 {
408 Event* outE;
409
410 if (!ltt_event_get_unsigned(event,
411 lttv_trace_get_hook_field(traceHook, 1)) == ETH_P_IP ||
412 !ltt_event_get_unsigned(event,
413 lttv_trace_get_hook_field(traceHook, 2)) == IPPROTO_TCP)
414 {
415 return FALSE;
416 }
417
418 if (!syncState->matchingModule->canMatch[TCP])
419 {
420 return FALSE;
421 }
422
423 if (syncState->stats)
424 {
425 processingData->stats->totOutE++;
426 }
427
428 outE= malloc(sizeof(Event));
429 outE->traceNum= traceNum;
430 outE->cpuTime= tsc;
431 outE->wallTime= wTime;
432 outE->type= TCP;
433 outE->copy= &copyTCPEvent;
434 outE->destroy= &destroyTCPEvent;
435 outE->event.tcpEvent= malloc(sizeof(TCPEvent));
436 outE->event.tcpEvent->direction= OUT;
437 outE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey));
438 outE->event.tcpEvent->segmentKey->connectionKey.saddr=
439 htonl(ltt_event_get_unsigned(event,
440 lttv_trace_get_hook_field(traceHook, 3)));
441 outE->event.tcpEvent->segmentKey->connectionKey.daddr=
442 htonl(ltt_event_get_unsigned(event,
443 lttv_trace_get_hook_field(traceHook, 4)));
444 outE->event.tcpEvent->segmentKey->tot_len=
445 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
446 5));
447 outE->event.tcpEvent->segmentKey->ihl= ltt_event_get_unsigned(event,
448 lttv_trace_get_hook_field(traceHook, 6));
449 outE->event.tcpEvent->segmentKey->connectionKey.source=
450 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
451 7));
452 outE->event.tcpEvent->segmentKey->connectionKey.dest=
453 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
454 8));
455 outE->event.tcpEvent->segmentKey->seq= ltt_event_get_unsigned(event,
456 lttv_trace_get_hook_field(traceHook, 9));
457 outE->event.tcpEvent->segmentKey->ack_seq=
458 ltt_event_get_unsigned(event, lttv_trace_get_hook_field(traceHook,
459 10));
460 outE->event.tcpEvent->segmentKey->doff= ltt_event_get_unsigned(event,
461 lttv_trace_get_hook_field(traceHook, 11));
462 outE->event.tcpEvent->segmentKey->ack= ltt_event_get_unsigned(event,
463 lttv_trace_get_hook_field(traceHook, 12));
464 outE->event.tcpEvent->segmentKey->rst= ltt_event_get_unsigned(event,
465 lttv_trace_get_hook_field(traceHook, 13));
466 outE->event.tcpEvent->segmentKey->syn= ltt_event_get_unsigned(event,
467 lttv_trace_get_hook_field(traceHook, 14));
468 outE->event.tcpEvent->segmentKey->fin= ltt_event_get_unsigned(event,
469 lttv_trace_get_hook_field(traceHook, 15));
470
471 syncState->matchingModule->matchEvent(syncState, outE);
472
473 g_debug("Output event done");
474 }
475 else if (info->name == LTT_EVENT_DEV_RECEIVE)
476 {
477 guint32 protocol;
478
479 if (syncState->stats)
480 {
481 processingData->stats->totRecv++;
482 }
483
484 protocol= ltt_event_get_unsigned(event,
485 lttv_trace_get_hook_field(traceHook, 1));
486
487 if (protocol == ETH_P_IP)
488 {
489 Event* inE;
490 void* skb;
491
492 if (syncState->stats)
493 {
494 processingData->stats->totRecvIp++;
495 }
496
497 inE= malloc(sizeof(Event));
498 inE->traceNum= traceNum;
499 inE->cpuTime= tsc;
500 inE->wallTime= wTime;
501 inE->event.tcpEvent= NULL;
502 inE->copy= &copyEvent;
503 inE->destroy= &destroyEvent;
504
505 skb= (void*) (long) ltt_event_get_long_unsigned(event,
506 lttv_trace_get_hook_field(traceHook, 0));
507 g_hash_table_replace(processingData->pendingRecv[traceNum], skb,
508 inE);
509
510 g_debug("Adding inE %p for skb %p to pendingRecv", inE, skb);
511 }
512 }
513 else if (info->name == LTT_EVENT_TCPV4_RCV_EXTENDED)
514 {
515 Event* inE;
516 void* skb;
517
518 // Search pendingRecv for an event with the same skb
519 skb= (void*) (long) ltt_event_get_long_unsigned(event,
520 lttv_trace_get_hook_field(traceHook, 0));
521
522 inE= (Event*)
523 g_hash_table_lookup(processingData->pendingRecv[traceNum], skb);
524 if (inE == NULL)
525 {
526 // This should only happen in case of lost events
527 g_warning("No matching pending receive event found");
528 }
529 else
530 {
531 if (syncState->stats)
532 {
533 processingData->stats->totRecvTCP++;
534 }
535
536 // If it's there, remove it and proceed with a receive event
537 g_hash_table_steal(processingData->pendingRecv[traceNum], skb);
538
539 inE->type= TCP;
540 inE->event.tcpEvent= malloc(sizeof(TCPEvent));
541 inE->copy= &copyTCPEvent;
542 inE->destroy= &destroyTCPEvent;
543 inE->event.tcpEvent->direction= IN;
544 inE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey));
545 inE->event.tcpEvent->segmentKey->connectionKey.saddr=
546 htonl(ltt_event_get_unsigned(event,
547 lttv_trace_get_hook_field(traceHook, 1)));
548 inE->event.tcpEvent->segmentKey->connectionKey.daddr=
549 htonl(ltt_event_get_unsigned(event,
550 lttv_trace_get_hook_field(traceHook, 2)));
551 inE->event.tcpEvent->segmentKey->tot_len=
552 ltt_event_get_unsigned(event,
553 lttv_trace_get_hook_field(traceHook, 3));
554 inE->event.tcpEvent->segmentKey->ihl=
555 ltt_event_get_unsigned(event,
556 lttv_trace_get_hook_field(traceHook, 4));
557 inE->event.tcpEvent->segmentKey->connectionKey.source=
558 ltt_event_get_unsigned(event,
559 lttv_trace_get_hook_field(traceHook, 5));
560 inE->event.tcpEvent->segmentKey->connectionKey.dest=
561 ltt_event_get_unsigned(event,
562 lttv_trace_get_hook_field(traceHook, 6));
563 inE->event.tcpEvent->segmentKey->seq=
564 ltt_event_get_unsigned(event,
565 lttv_trace_get_hook_field(traceHook, 7));
566 inE->event.tcpEvent->segmentKey->ack_seq=
567 ltt_event_get_unsigned(event,
568 lttv_trace_get_hook_field(traceHook, 8));
569 inE->event.tcpEvent->segmentKey->doff=
570 ltt_event_get_unsigned(event,
571 lttv_trace_get_hook_field(traceHook, 9));
572 inE->event.tcpEvent->segmentKey->ack=
573 ltt_event_get_unsigned(event,
574 lttv_trace_get_hook_field(traceHook, 10));
575 inE->event.tcpEvent->segmentKey->rst=
576 ltt_event_get_unsigned(event,
577 lttv_trace_get_hook_field(traceHook, 11));
578 inE->event.tcpEvent->segmentKey->syn=
579 ltt_event_get_unsigned(event,
580 lttv_trace_get_hook_field(traceHook, 12));
581 inE->event.tcpEvent->segmentKey->fin=
582 ltt_event_get_unsigned(event,
583 lttv_trace_get_hook_field(traceHook, 13));
584
585 syncState->matchingModule->matchEvent(syncState, inE);
586
587 g_debug("TCP input event %p for skb %p done", inE, skb);
588 }
589 }
590 else if (info->name == LTT_EVENT_UDPV4_RCV_EXTENDED)
591 {
592 Event* inE;
593 void* skb;
594
595 // Search pendingRecv for an event with the same skb
596 skb= (void*) (long) ltt_event_get_long_unsigned(event,
597 lttv_trace_get_hook_field(traceHook, 0));
598
599 inE= (Event*)
600 g_hash_table_lookup(processingData->pendingRecv[traceNum], skb);
601 if (inE == NULL)
602 {
603 // This should only happen in case of lost events
604 g_warning("No matching pending receive event found");
605 }
606 else
607 {
608 guint64 dataStart;
609
610 if (syncState->stats)
611 {
612 processingData->stats->totRecvUDP++;
613 }
614
615 // If it's there, remove it and proceed with a receive event
616 g_hash_table_steal(processingData->pendingRecv[traceNum], skb);
617
618 inE->type= UDP;
619 inE->event.udpEvent= malloc(sizeof(UDPEvent));
620 inE->copy= &copyUDPEvent;
621 inE->destroy= &destroyUDPEvent;
622 inE->event.udpEvent->direction= IN;
623 inE->event.udpEvent->datagramKey= malloc(sizeof(DatagramKey));
624 inE->event.udpEvent->datagramKey->saddr=
625 htonl(ltt_event_get_unsigned(event,
626 lttv_trace_get_hook_field(traceHook, 1)));
627 inE->event.udpEvent->datagramKey->daddr=
628 htonl(ltt_event_get_unsigned(event,
629 lttv_trace_get_hook_field(traceHook, 2)));
630 inE->event.udpEvent->unicast= ltt_event_get_unsigned(event,
631 lttv_trace_get_hook_field(traceHook, 3)) == 0 ? false : true;
632 inE->event.udpEvent->datagramKey->ulen=
633 ltt_event_get_unsigned(event,
634 lttv_trace_get_hook_field(traceHook, 4));
635 inE->event.udpEvent->datagramKey->source=
636 ltt_event_get_unsigned(event,
637 lttv_trace_get_hook_field(traceHook, 5));
638 inE->event.udpEvent->datagramKey->dest=
639 ltt_event_get_unsigned(event,
640 lttv_trace_get_hook_field(traceHook, 6));
641 dataStart= ltt_event_get_long_unsigned(event,
642 lttv_trace_get_hook_field(traceHook, 7));
643 g_assert_cmpuint(sizeof(inE->event.udpEvent->datagramKey->dataKey),
644 ==, sizeof(guint64));
645 if (inE->event.udpEvent->datagramKey->ulen - 8 >=
646 sizeof(inE->event.udpEvent->datagramKey->dataKey))
647 {
648 memcpy(inE->event.udpEvent->datagramKey->dataKey, &dataStart,
649 sizeof(inE->event.udpEvent->datagramKey->dataKey));
650 }
651 else
652 {
653 memset(inE->event.udpEvent->datagramKey->dataKey, 0,
654 sizeof(inE->event.udpEvent->datagramKey->dataKey));
655 memcpy(inE->event.udpEvent->datagramKey->dataKey, &dataStart,
656 inE->event.udpEvent->datagramKey->ulen - 8);
657 }
658
659 syncState->matchingModule->matchEvent(syncState, inE);
660
661 g_debug("UDP input event %p for skb %p done", inE, skb);
662 }
663 }
664 else
665 {
666 g_assert_not_reached();
667 }
668
669 return FALSE;
670 }
671
672
673 /*
674 * Write the processing-specific variables in the gnuplot script.
675 *
676 * Args:
677 * syncState: container for synchronization data
678 * i: trace number
679 */
680 static void writeProcessingGraphVariablesLTTVStandard(SyncState* const
681 syncState, const unsigned int i)
682 {
683 ProcessingDataLTTVStandard* processingData= syncState->processingData;
684 ProcessingGraphsLTTVStandard* traceI= &processingData->graphs[i];
685
686 fprintf(syncState->graphsStream, "clock_freq_%u= %.3f\n", i, (double)
687 traceI->startFreq / traceI->freqScale);
688 }
689
690
691 /*
692 * Write the processing-specific options in the gnuplot script.
693 *
694 * Args:
695 * syncState: container for synchronization data
696 * i: first trace number
697 * j: second trace number, garanteed to be larger than i
698 */
699 static void writeProcessingTraceTraceOptionsLTTVStandard(SyncState* const
700 syncState, const unsigned int i, const unsigned int j)
701 {
702 ProcessingDataLTTVStandard* processingData;
703 ProcessingGraphsLTTVStandard* traceI, * traceJ;
704
705 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
706
707 traceI= &processingData->graphs[i];
708 traceJ= &processingData->graphs[j];
709
710 fprintf(syncState->graphsStream,
711 "set key inside right bottom\n"
712 "set xlabel \"Clock %1$u\"\n"
713 "set xtics nomirror\n"
714 "set ylabel \"Clock %2$u\"\n"
715 "set ytics nomirror\n"
716 "set x2label \"Clock %1$d (s)\"\n"
717 "set x2range [GPVAL_X_MIN / clock_freq_%1$u : GPVAL_X_MAX / clock_freq_%1$u]\n"
718 "set x2tics\n"
719 "set y2label \"Clock %2$d (s)\"\n"
720 "set y2range [GPVAL_Y_MIN / clock_freq_%2$u : GPVAL_Y_MAX / clock_freq_%2$u]\n"
721 "set y2tics\n", i, j);
722 }
723
724
725 /*
726 * Write the processing-specific options in the gnuplot script.
727 *
728 * Args:
729 * syncState: container for synchronization data
730 * i: first trace number
731 * j: second trace number, garanteed to be larger than i
732 */
733 static void writeProcessingTraceTimeOptionsLTTVStandard(SyncState* const
734 syncState, const unsigned int i, const unsigned int j)
735 {
736 ProcessingDataLTTVStandard* processingData;
737 ProcessingGraphsLTTVStandard* traceI, * traceJ;
738
739 processingData= (ProcessingDataLTTVStandard*) syncState->processingData;
740
741 traceI= &processingData->graphs[i];
742 traceJ= &processingData->graphs[j];
743
744 fprintf(syncState->graphsStream,
745 "set key inside right bottom\n"
746 "set xlabel \"Clock %1$u\"\n"
747 "set xtics nomirror\n"
748 "set ylabel \"time (s)\"\n"
749 "set ytics nomirror\n"
750 "set x2label \"Clock %1$d (s)\"\n"
751 "set x2range [GPVAL_X_MIN / clock_freq_%1$u : GPVAL_X_MAX / clock_freq_%1$u]\n"
752 "set x2tics\n", i);
753 }
This page took 0.048553 seconds and 3 git commands to generate.