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