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