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