-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpdcp_ul_deletion.cpp
More file actions
executable file
·76 lines (48 loc) · 2 KB
/
pdcp_ul_deletion.cpp
File metadata and controls
executable file
·76 lines (48 loc) · 2 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include <linux/bpf.h>
#include "jbpf_srsran_contexts.h"
#include "pdcp_helpers.h"
#include "pdcp_ul_stats.pb.h"
#include "../utils/misc_utils.h"
#include "../utils/hashmap_utils.h"
#define SEC(NAME) __attribute__((section(NAME), used))
#include "jbpf_defs.h"
#include "jbpf_helper.h"
#define MAX_NUM_UE_RB (256)
struct jbpf_load_map_def SEC("maps") stats_map_ul = {
.type = JBPF_MAP_TYPE_ARRAY,
.key_size = sizeof(int),
.value_size = sizeof(ul_stats),
.max_entries = 1,
};
DEFINE_PROTOHASH_64(ul_hash, MAX_NUM_UE_RB);
//#define DEBUG_PRINT
extern "C" SEC("jbpf_srsran_generic")
uint64_t jbpf_main(void* state)
{
int zero_index=0;
struct jbpf_ran_generic_ctx *ctx = (jbpf_ran_generic_ctx *)state;
const jbpf_pdcp_ctx_info& pdcp_ctx = *reinterpret_cast<const jbpf_pdcp_ctx_info*>(ctx->data);
// Ensure the object is within valid bounds
if (reinterpret_cast<const uint8_t*>(&pdcp_ctx) + sizeof(jbpf_pdcp_ctx_info) > reinterpret_cast<const uint8_t*>(ctx->data_end)) {
return JBPF_CODELET_FAILURE; // Out-of-bounds access
}
ul_stats *out = (ul_stats *)jbpf_map_lookup_elem(&stats_map_ul, &zero_index);
if (!out)
return JBPF_CODELET_FAILURE;
// create explicit rbid
int rb_id = RBID_2_EXPLICIT(pdcp_ctx.is_srb, pdcp_ctx.rb_id);
#ifdef DEBUG_PRINT
jbpf_printf_debug("pdcp_ul_deletion: cu_ue_index=%d, rb_id=%d\n",
ue_index, rb_id);
#endif
// When a bearer context is setup, we need to reset the last acked
// At the beginning, 0 is not acked so set to "-1".
int new_val = 0;
uint32_t ind = JBPF_PROTOHASH_LOOKUP_ELEM_64(out, stats, ul_hash, pdcp_ctx.cu_ue_index, rb_id, new_val);
PDCP_UL_STATS_INIT(out->stats[ind % MAX_NUM_UE_RB], pdcp_ctx.cu_ue_index, pdcp_ctx.is_srb,
pdcp_ctx.rb_id, pdcp_ctx.rlc_mode);
out->stats[ind % MAX_NUM_UE_RB].rlc_mode = JBPF_RLC_MODE_MAX;
return JBPF_CODELET_SUCCESS;
}