Commit | Line | Data |
---|---|---|
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 |
39 | static void initProcessingLTTVStandard(SyncState* const syncState, |
40 | LttvTracesetContext* const traceSetContext); | |
41 | static void destroyProcessingLTTVStandard(SyncState* const syncState); | |
42 | ||
43 | static void finalizeProcessingLTTVStandard(SyncState* const syncState); | |
44 | static void printProcessingStatsLTTVStandard(SyncState* const syncState); | |
66eaf2eb BP |
45 | static void writeProcessingGraphVariablesLTTVStandard(SyncState* const |
46 | syncState, const unsigned int i); | |
467066ee BP |
47 | static void writeProcessingTraceTraceOptionsLTTVStandard(SyncState* const |
48 | syncState, const unsigned int i, const unsigned int j); | |
49 | static void writeProcessingTraceTimeOptionsLTTVStandard(SyncState* const | |
8d7d16dd | 50 | syncState, const unsigned int i, const unsigned int j); |
70407e86 BP |
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, | |
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 | */ | |
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: set of LTTV traces | |
95 | */ | |
96 | static 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 | */ | |
164 | static 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 | ||
235 | g_debug("traceset start %ld.%09ld end %ld.%09ld\n", | |
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 | */ | |
250 | static 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 | */ | |
291 | static 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 | */ | |
332 | static 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 | ||
350 | g_debug("Cleaning up pendingRecv list\n"); | |
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 | */ | |
371 | static 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 | ||
400 | g_debug("XXXX 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= ©TCPEvent; |
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 BP |
470 | |
471 | g_debug("Output event done\n"); | |
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= ©Event; |
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 | |
10341d26 | 508 | g_debug("Adding inE %p for skb %p to pendingRecv\n", inE, skb); |
70407e86 BP |
509 | } |
510 | else | |
511 | { | |
512 | g_debug("\n"); | |
513 | } | |
514 | } | |
fea7219b | 515 | else if (info->name == LTT_EVENT_TCPV4_RCV_EXTENDED) |
70407e86 | 516 | { |
10341d26 | 517 | Event* inE; |
70407e86 BP |
518 | void* skb; |
519 | ||
520 | // Search pendingRecv for an event with the same skb | |
521 | skb= (void*) (long) ltt_event_get_long_unsigned(event, | |
522 | lttv_trace_get_hook_field(traceHook, 0)); | |
523 | ||
10341d26 | 524 | inE= (Event*) |
70407e86 BP |
525 | g_hash_table_lookup(processingData->pendingRecv[traceNum], skb); |
526 | if (inE == NULL) | |
527 | { | |
528 | // This should only happen in case of lost events | |
f6691532 | 529 | g_warning("No matching pending receive event found"); |
70407e86 BP |
530 | } |
531 | else | |
532 | { | |
533 | if (syncState->stats) | |
534 | { | |
f6691532 | 535 | processingData->stats->totRecvTCP++; |
70407e86 BP |
536 | } |
537 | ||
538 | // If it's there, remove it and proceed with a receive event | |
539 | g_hash_table_steal(processingData->pendingRecv[traceNum], skb); | |
540 | ||
10341d26 BP |
541 | inE->type= TCP; |
542 | inE->event.tcpEvent= malloc(sizeof(TCPEvent)); | |
d4721e1a | 543 | inE->copy= ©TCPEvent; |
10341d26 BP |
544 | inE->destroy= &destroyTCPEvent; |
545 | inE->event.tcpEvent->direction= IN; | |
546 | inE->event.tcpEvent->segmentKey= malloc(sizeof(SegmentKey)); | |
547 | inE->event.tcpEvent->segmentKey->connectionKey.saddr= | |
d4721e1a BP |
548 | htonl(ltt_event_get_unsigned(event, |
549 | lttv_trace_get_hook_field(traceHook, 1))); | |
10341d26 | 550 | inE->event.tcpEvent->segmentKey->connectionKey.daddr= |
d4721e1a BP |
551 | htonl(ltt_event_get_unsigned(event, |
552 | lttv_trace_get_hook_field(traceHook, 2))); | |
10341d26 BP |
553 | inE->event.tcpEvent->segmentKey->tot_len= |
554 | ltt_event_get_unsigned(event, | |
555 | lttv_trace_get_hook_field(traceHook, 3)); | |
556 | inE->event.tcpEvent->segmentKey->ihl= | |
557 | ltt_event_get_unsigned(event, | |
558 | lttv_trace_get_hook_field(traceHook, 4)); | |
559 | inE->event.tcpEvent->segmentKey->connectionKey.source= | |
560 | ltt_event_get_unsigned(event, | |
561 | lttv_trace_get_hook_field(traceHook, 5)); | |
562 | inE->event.tcpEvent->segmentKey->connectionKey.dest= | |
563 | ltt_event_get_unsigned(event, | |
564 | lttv_trace_get_hook_field(traceHook, 6)); | |
565 | inE->event.tcpEvent->segmentKey->seq= | |
566 | ltt_event_get_unsigned(event, | |
567 | lttv_trace_get_hook_field(traceHook, 7)); | |
568 | inE->event.tcpEvent->segmentKey->ack_seq= | |
569 | ltt_event_get_unsigned(event, | |
570 | lttv_trace_get_hook_field(traceHook, 8)); | |
571 | inE->event.tcpEvent->segmentKey->doff= | |
572 | ltt_event_get_unsigned(event, | |
573 | lttv_trace_get_hook_field(traceHook, 9)); | |
574 | inE->event.tcpEvent->segmentKey->ack= | |
575 | ltt_event_get_unsigned(event, | |
576 | lttv_trace_get_hook_field(traceHook, 10)); | |
577 | inE->event.tcpEvent->segmentKey->rst= | |
578 | ltt_event_get_unsigned(event, | |
579 | lttv_trace_get_hook_field(traceHook, 11)); | |
580 | inE->event.tcpEvent->segmentKey->syn= | |
581 | ltt_event_get_unsigned(event, | |
582 | lttv_trace_get_hook_field(traceHook, 12)); | |
583 | inE->event.tcpEvent->segmentKey->fin= | |
584 | ltt_event_get_unsigned(event, | |
585 | lttv_trace_get_hook_field(traceHook, 13)); | |
586 | ||
587 | syncState->matchingModule->matchEvent(syncState, inE); | |
70407e86 | 588 | |
f6691532 | 589 | g_debug("TCP input event %p for skb %p done\n", inE, skb); |
70407e86 BP |
590 | } |
591 | } | |
f6691532 | 592 | else if (info->name == LTT_EVENT_UDPV4_RCV_EXTENDED) |
70407e86 | 593 | { |
f6691532 BP |
594 | Event* inE; |
595 | void* skb; | |
70407e86 | 596 | |
f6691532 BP |
597 | // Search pendingRecv for an event with the same skb |
598 | skb= (void*) (long) ltt_event_get_long_unsigned(event, | |
599 | lttv_trace_get_hook_field(traceHook, 0)); | |
70407e86 | 600 | |
f6691532 BP |
601 | inE= (Event*) |
602 | g_hash_table_lookup(processingData->pendingRecv[traceNum], skb); | |
603 | if (inE == NULL) | |
604 | { | |
605 | // This should only happen in case of lost events | |
606 | g_warning("No matching pending receive event found"); | |
607 | } | |
608 | else | |
609 | { | |
610 | guint64 dataStart; | |
70407e86 | 611 | |
f6691532 BP |
612 | if (syncState->stats) |
613 | { | |
614 | processingData->stats->totRecvUDP++; | |
615 | } | |
616 | ||
617 | // If it's there, remove it and proceed with a receive event | |
618 | g_hash_table_steal(processingData->pendingRecv[traceNum], skb); | |
619 | ||
620 | inE->type= UDP; | |
621 | inE->event.udpEvent= malloc(sizeof(UDPEvent)); | |
d4721e1a | 622 | inE->copy= ©UDPEvent; |
f6691532 BP |
623 | inE->destroy= &destroyUDPEvent; |
624 | inE->event.udpEvent->direction= IN; | |
625 | inE->event.udpEvent->datagramKey= malloc(sizeof(DatagramKey)); | |
626 | inE->event.udpEvent->datagramKey->saddr= | |
d4721e1a BP |
627 | htonl(ltt_event_get_unsigned(event, |
628 | lttv_trace_get_hook_field(traceHook, 1))); | |
f6691532 | 629 | inE->event.udpEvent->datagramKey->daddr= |
d4721e1a BP |
630 | htonl(ltt_event_get_unsigned(event, |
631 | lttv_trace_get_hook_field(traceHook, 2))); | |
f6691532 BP |
632 | inE->event.udpEvent->unicast= ltt_event_get_unsigned(event, |
633 | lttv_trace_get_hook_field(traceHook, 3)) == 0 ? false : true; | |
634 | inE->event.udpEvent->datagramKey->ulen= | |
635 | ltt_event_get_unsigned(event, | |
636 | lttv_trace_get_hook_field(traceHook, 4)); | |
637 | inE->event.udpEvent->datagramKey->source= | |
638 | ltt_event_get_unsigned(event, | |
639 | lttv_trace_get_hook_field(traceHook, 5)); | |
640 | inE->event.udpEvent->datagramKey->dest= | |
641 | ltt_event_get_unsigned(event, | |
642 | lttv_trace_get_hook_field(traceHook, 6)); | |
643 | dataStart= ltt_event_get_long_unsigned(event, | |
644 | lttv_trace_get_hook_field(traceHook, 7)); | |
645 | g_assert_cmpuint(sizeof(inE->event.udpEvent->datagramKey->dataKey), | |
646 | ==, sizeof(guint64)); | |
647 | if (inE->event.udpEvent->datagramKey->ulen - 8 >= | |
648 | sizeof(inE->event.udpEvent->datagramKey->dataKey)) | |
649 | { | |
650 | memcpy(inE->event.udpEvent->datagramKey->dataKey, &dataStart, | |
651 | sizeof(inE->event.udpEvent->datagramKey->dataKey)); | |
652 | } | |
653 | else | |
654 | { | |
655 | memset(inE->event.udpEvent->datagramKey->dataKey, 0, | |
656 | sizeof(inE->event.udpEvent->datagramKey->dataKey)); | |
657 | memcpy(inE->event.udpEvent->datagramKey->dataKey, &dataStart, | |
658 | inE->event.udpEvent->datagramKey->ulen - 8); | |
659 | } | |
660 | ||
661 | syncState->matchingModule->matchEvent(syncState, inE); | |
662 | ||
663 | g_debug("UDP input event %p for skb %p done\n", inE, skb); | |
664 | } | |
70407e86 BP |
665 | } |
666 | else | |
667 | { | |
668 | g_assert_not_reached(); | |
669 | } | |
670 | ||
671 | return FALSE; | |
672 | } | |
08365995 BP |
673 | |
674 | ||
66eaf2eb BP |
675 | /* |
676 | * Write the processing-specific variables in the gnuplot script. | |
677 | * | |
678 | * Args: | |
679 | * syncState: container for synchronization data | |
680 | * i: trace number | |
681 | */ | |
682 | static void writeProcessingGraphVariablesLTTVStandard(SyncState* const | |
683 | syncState, const unsigned int i) | |
684 | { | |
685 | ProcessingDataLTTVStandard* processingData= syncState->processingData; | |
686 | ProcessingGraphsLTTVStandard* traceI= &processingData->graphs[i]; | |
687 | ||
688 | fprintf(syncState->graphsStream, "clock_freq_%u= %.3f\n", i, (double) | |
689 | traceI->startFreq / traceI->freqScale); | |
690 | } | |
691 | ||
692 | ||
08365995 | 693 | /* |
d6ee5003 | 694 | * Write the processing-specific options in the gnuplot script. |
08365995 BP |
695 | * |
696 | * Args: | |
08365995 BP |
697 | * syncState: container for synchronization data |
698 | * i: first trace number | |
699 | * j: second trace number, garanteed to be larger than i | |
700 | */ | |
467066ee | 701 | static void writeProcessingTraceTraceOptionsLTTVStandard(SyncState* const |
8d7d16dd | 702 | syncState, const unsigned int i, const unsigned int j) |
08365995 BP |
703 | { |
704 | ProcessingDataLTTVStandard* processingData; | |
1633c5a5 | 705 | ProcessingGraphsLTTVStandard* traceI, * traceJ; |
08365995 BP |
706 | |
707 | processingData= (ProcessingDataLTTVStandard*) syncState->processingData; | |
708 | ||
1633c5a5 BP |
709 | traceI= &processingData->graphs[i]; |
710 | traceJ= &processingData->graphs[j]; | |
08365995 | 711 | |
8d7d16dd | 712 | fprintf(syncState->graphsStream, |
d6ee5003 BP |
713 | "set key inside right bottom\n" |
714 | "set xlabel \"Clock %1$u\"\n" | |
715 | "set xtics nomirror\n" | |
66eaf2eb | 716 | "set ylabel \"Clock %2$u\"\n" |
d6ee5003 | 717 | "set ytics nomirror\n" |
08365995 | 718 | "set x2label \"Clock %1$d (s)\"\n" |
66eaf2eb | 719 | "set x2range [GPVAL_X_MIN / clock_freq_%1$u : GPVAL_X_MAX / clock_freq_%1$u]\n" |
08365995 | 720 | "set x2tics\n" |
66eaf2eb BP |
721 | "set y2label \"Clock %2$d (s)\"\n" |
722 | "set y2range [GPVAL_Y_MIN / clock_freq_%2$u : GPVAL_Y_MAX / clock_freq_%2$u]\n" | |
723 | "set y2tics\n", i, j); | |
08365995 | 724 | } |
467066ee BP |
725 | |
726 | ||
727 | /* | |
728 | * Write the processing-specific options in the gnuplot script. | |
729 | * | |
730 | * Args: | |
731 | * syncState: container for synchronization data | |
732 | * i: first trace number | |
733 | * j: second trace number, garanteed to be larger than i | |
734 | */ | |
735 | static void writeProcessingTraceTimeOptionsLTTVStandard(SyncState* const | |
736 | syncState, const unsigned int i, const unsigned int j) | |
737 | { | |
738 | ProcessingDataLTTVStandard* processingData; | |
739 | ProcessingGraphsLTTVStandard* traceI, * traceJ; | |
740 | ||
741 | processingData= (ProcessingDataLTTVStandard*) syncState->processingData; | |
742 | ||
743 | traceI= &processingData->graphs[i]; | |
744 | traceJ= &processingData->graphs[j]; | |
745 | ||
746 | fprintf(syncState->graphsStream, | |
747 | "set key inside right bottom\n" | |
748 | "set xlabel \"Clock %1$u\"\n" | |
749 | "set xtics nomirror\n" | |
750 | "set ylabel \"time (s)\"\n" | |
751 | "set ytics nomirror\n" | |
752 | "set x2label \"Clock %1$d (s)\"\n" | |
66eaf2eb BP |
753 | "set x2range [GPVAL_X_MIN / clock_freq_%1$u : GPVAL_X_MAX / clock_freq_%1$u]\n" |
754 | "set x2tics\n", i); | |
467066ee | 755 | } |