-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathxran_packets_report.c
More file actions
52 lines (40 loc) · 1.22 KB
/
xran_packets_report.c
File metadata and controls
52 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include "jbpf_defs.h"
#include "jbpf_helper.h"
#include "xran_packet_info.pb.h"
#include "jbpf_srsran_contexts.h"
#include "xran_format.h"
#include "../utils/misc_utils.h"
// output map for stats
jbpf_ringbuf_map(output_map, packet_stats, 256);
// map to store data before sending to output_map
struct jbpf_load_map_def SEC("maps") output_tmp_map = {
.type = JBPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(packet_stats),
.max_entries = 1,
};
//#define DEBUG_PRINT
SEC("jbpf_stats")
uint64_t
jbpf_main(void* state)
{
int zero_index=0;
packet_stats *out = (packet_stats *)jbpf_map_lookup_elem(&output_tmp_map, &zero_index);
if (!out) {
return JBPF_CODELET_FAILURE;
}
uint64_t timestamp = jbpf_time_get_ns();
out->timestamp = timestamp;
int ret = jbpf_ringbuf_output(&output_map, (void *)out, sizeof(packet_stats));
// zero the stats
jbpf_map_clear(&output_tmp_map);
if (ret < 0) {
#ifdef DEBUG_PRINT
jbpf_printf_debug("xran_packets_report: Failure: jbpf_ringbuf_output\n");
#endif
return JBPF_CODELET_FAILURE;
}
return JBPF_CODELET_SUCCESS;
}