Skip to content

Commit 2147bbb

Browse files
Merge pull request #21 from microsoft/matt/stats_range_issue
Fix stats range issue
2 parents efbae1b + 9dc7121 commit 2147bbb

32 files changed

Lines changed: 226 additions & 315 deletions

codelets/mac/mac_helpers.h

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,27 @@
66

77
#include "jbpf_srsran_contexts.h"
88

9-
#define MAX_NUM_UE (32)
10-
11-
12-
#define MAC_STATS_INIT(__dest) \
13-
do { \
14-
__dest.count = 0; \
15-
__dest.total = 0; \
16-
__dest.min = UINT32_MAX; \
17-
__dest.max = 0; \
18-
} while (0)
19-
20-
21-
22-
#define MAC_STATS_UPDATE(__dest, __src) \
23-
do { \
24-
__dest.count++; \
25-
if (__src < __dest.min) { \
26-
__dest.min = __src; \
27-
} \
28-
if (__src > __dest.max) { \
29-
__dest.max = __src; \
30-
} \
31-
__dest.total += __src; \
32-
} while (0)
33-
34-
35-
36-
37-
#define MAC_TRAFFIC_STATS_INIT(__dest) \
38-
do { \
39-
__dest.count = 0; \
40-
__dest.total = 0; \
41-
} while (0)
42-
43-
#define MAC_TRAFFIC_STATS_UPDATE(__dest, __v) \
44-
do { \
45-
__dest.count++; \
46-
__dest.total += __v; \
47-
} while (0)
48-
9+
#include "../utils/stats_utils.h"
4910

11+
#define MAX_NUM_UE (32)
5012

5113

5214
#define MAC_HARQ_STATS_INIT(__dest, __cell_id, __rnti, __du_ue_index) \
5315
do { \
5416
__dest.cell_id = __cell_id; \
5517
__dest.rnti = __rnti; \
5618
__dest.du_ue_index = __du_ue_index; \
57-
MAC_STATS_INIT(__dest.cons_retx); \
58-
MAC_STATS_INIT(__dest.mcs); \
19+
STATS_INIT(__dest.cons_retx); \
20+
STATS_INIT(__dest.mcs); \
5921
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].count = 0; \
6022
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].has_cqi = false; \
61-
MAC_TRAFFIC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].tbs_bytes); \
23+
TRAFFIC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].tbs_bytes); \
6224
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].count = 0; \
6325
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].has_cqi = false; \
64-
MAC_TRAFFIC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].tbs_bytes);\
26+
TRAFFIC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].tbs_bytes);\
6527
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].count = 0; \
6628
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].has_cqi = false; \
67-
MAC_TRAFFIC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].tbs_bytes); \
29+
TRAFFIC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].tbs_bytes); \
6830
} while (0)
6931

7032
#define MAC_HARQ_STATS_INIT_UL MAC_HARQ_STATS_INIT_DL
@@ -73,11 +35,11 @@
7335
do { \
7436
MAC_HARQ_STATS_INIT(__dest, __cell_id, __rnti, __du_ue_index); \
7537
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].has_cqi = true; \
76-
MAC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].cqi); \
38+
STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_TX].cqi); \
7739
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].has_cqi = true; \
78-
MAC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].cqi); \
40+
STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_RETX].cqi); \
7941
__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].has_cqi = true; \
80-
MAC_STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].cqi); \
42+
STATS_INIT(__dest.perHarqTypeStats[JBPF_HARQ_EVENT_FAILURE].cqi); \
8143
} while (0)
8244

8345

codelets/mac/mac_sched_crc_stats.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,16 @@ uint64_t jbpf_main(void* state)
9090
out->stats[ind % MAX_NUM_UE].retx_hist[i] = 0;
9191
}
9292
out->stats[ind % MAX_NUM_UE].harq_failure = 0;
93-
out->stats[ind % MAX_NUM_UE].min_sinr = UINT32_MAX;
94-
out->stats[ind % MAX_NUM_UE].min_rsrp = UINT32_MAX;
95-
out->stats[ind % MAX_NUM_UE].max_sinr = 0;
96-
out->stats[ind % MAX_NUM_UE].max_rsrp = INT32_MIN;
93+
94+
// Initialise to int16 limits as original SINR is an int16
95+
out->stats[ind % MAX_NUM_UE].min_sinr = INT16_MAX;
96+
out->stats[ind % MAX_NUM_UE].max_sinr = INT16_MIN;
9797
out->stats[ind % MAX_NUM_UE].sum_sinr = 0;
98-
out->stats[ind % MAX_NUM_UE].sum_rsrp = 0;
9998
out->stats[ind % MAX_NUM_UE].cnt_sinr = 0;
99+
100+
out->stats[ind % MAX_NUM_UE].min_rsrp = UINT32_MAX;
101+
out->stats[ind % MAX_NUM_UE].max_rsrp = 0;
102+
out->stats[ind % MAX_NUM_UE].sum_rsrp = 0;
100103
out->stats[ind % MAX_NUM_UE].cnt_rsrp = 0;
101104
}
102105

@@ -140,8 +143,11 @@ uint64_t jbpf_main(void* state)
140143

141144

142145
if (mac_ctx.ul_sinr_dB.has_value()) {
146+
147+
// valid range of ul_sinr_dB is [-65.534, 65.534]
148+
143149
// We ignore decimal part of SINR
144-
uint32_t ul_sinr_dB = (uint32_t) fixedpt_toint(float_to_fixed(mac_ctx.ul_sinr_dB.value()));
150+
int32_t ul_sinr_dB = (int32_t)fixedpt_toint(float_to_fixed(mac_ctx.ul_sinr_dB.value()));
145151
if (ul_sinr_dB < out->stats[ind].min_sinr) {
146152
out->stats[ind].min_sinr = ul_sinr_dB;
147153
}
@@ -165,6 +171,9 @@ uint64_t jbpf_main(void* state)
165171
}
166172

167173
if (mac_ctx.ul_rsrp_dBFS.has_value()) {
174+
175+
// valid range of ul_rsrp_dBFS is [-128.0, 6425.4]
176+
168177
// We ignore decimal part of RSRP
169178
int32_t ul_rsrp_dB = (int32_t) fixedpt_toint(float_to_fixed(mac_ctx.ul_rsrp_dBFS.value()));
170179

codelets/mac/mac_sched_crc_stats.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ message t_crc_stats {
1111
required uint32 cnt_tx = 4;
1212
repeated uint32 retx_hist = 5;
1313
required uint32 harq_failure = 6;
14-
required uint32 min_sinr = 7;
14+
required int32 min_sinr = 7;
1515
required int32 min_rsrp = 8;
16-
required uint32 max_sinr = 9;
16+
required int32 max_sinr = 9;
1717
required int32 max_rsrp = 10;
18-
required uint32 sum_sinr = 11;
18+
required int32 sum_sinr = 11;
1919
required int32 sum_rsrp = 12;
2020
required uint32 cnt_sinr = 13;
2121
required uint32 cnt_rsrp = 14;

codelets/mac/mac_sched_dl_harq_stats.cpp

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "jbpf_defs.h"
1818
#include "jbpf_helper.h"
1919
#include "jbpf_helper_utils.h"
20-
20+
#include "../utils/stats_utils.h"
2121

2222
struct jbpf_load_map_def SEC("maps") dl_harq_not_empty = {
2323
.type = JBPF_MAP_TYPE_ARRAY,
@@ -39,20 +39,6 @@ DEFINE_PROTOHASH_32(dl_harq_hash, MAX_NUM_UE);
3939

4040

4141

42-
43-
#define STATS_UPDATE(dest, src) \
44-
do { \
45-
dest.count++; \
46-
if (src < dest.min) { \
47-
dest.min = src; \
48-
} \
49-
if (src > dest.max) { \
50-
dest.max = src; \
51-
} \
52-
dest.total += src; \
53-
} while (0)
54-
55-
5642
//#define DEBUG_PRINT
5743

5844
extern "C" SEC("jbpf_ran_mac_sched")
@@ -91,16 +77,16 @@ uint64_t jbpf_main(void* state)
9177
if (reinterpret_cast<const uint8_t*>(&harq_info) + sizeof(jbpf_mac_sched_harq_ctx_info_dl) <= reinterpret_cast<const uint8_t*>(ctx->data_end)) {
9278

9379
// cons_retx
94-
MAC_STATS_UPDATE(out->stats[ind % MAX_NUM_UE].cons_retx, harq_info.h.nof_retxs);
80+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE].cons_retx, harq_info.h.nof_retxs);
9581

9682
// mcs
97-
MAC_STATS_UPDATE(out->stats[ind % MAX_NUM_UE].mcs, harq_info.h.mcs);
83+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE].mcs, harq_info.h.mcs);
9884

9985
// perHarqTypeStats
10086
t_harq_type_stats& hts = out->stats[ind % MAX_NUM_UE].perHarqTypeStats[harq_info.h.harq_type % JBPF_HARQ_EVENT_NUM];
10187
hts.count++;
102-
MAC_TRAFFIC_STATS_UPDATE(hts.tbs_bytes, harq_info.h.tbs_bytes);
103-
MAC_STATS_UPDATE(hts.cqi, harq_info.cqi);
88+
TRAFFIC_STATS_UPDATE(hts.tbs_bytes, harq_info.h.tbs_bytes);
89+
STATS_UPDATE(hts.cqi, harq_info.cqi);
10490
}
10591

10692
*not_empty_stats = 1;

codelets/mac/mac_sched_harq_stats.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ syntax = "proto2";
55

66
message t_harq_stat_item {
77
required uint32 count = 1;
8-
required uint32 total = 2;
8+
required uint64 total = 2;
99
required uint32 min = 3;
1010
required uint32 max = 4;
1111
}
1212

1313
message t_harq_stat_traffic_item {
1414
required uint32 count = 1;
15-
required uint32 total = 2;
15+
required uint64 total = 2;
1616
}
1717

1818
message t_harq_type_stats {

codelets/mac/mac_sched_uci_pdu_stats.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "jbpf_defs.h"
1818
#include "jbpf_helper.h"
1919
#include "jbpf_helper_utils.h"
20-
20+
#include "../utils/stats_utils.h"
2121

2222

2323
struct jbpf_load_map_def SEC("maps") uci_not_empty = {
@@ -41,19 +41,6 @@ DEFINE_PROTOHASH_32(uci_hash, MAX_NUM_UE);
4141

4242

4343

44-
#define STATS_UPDATE(dest, src) \
45-
do { \
46-
dest.count++; \
47-
if (src < dest.min) { \
48-
dest.min = src; \
49-
} \
50-
if (src > dest.max) { \
51-
dest.max = src; \
52-
} \
53-
dest.total += src; \
54-
} while (0)
55-
56-
5744
//#define DEBUG_PRINT
5845

5946
extern "C" SEC("jbpf_ran_mac_sched")

codelets/mac/mac_sched_ue_deletion.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,13 @@ uint64_t jbpf_main(void* state)
124124
crc_out->stats[ind % MAX_NUM_UE].retx_hist[i] = 0;
125125
}
126126
crc_out->stats[ind % MAX_NUM_UE].harq_failure = 0;
127-
crc_out->stats[ind % MAX_NUM_UE].min_sinr = UINT32_MAX;
128-
crc_out->stats[ind % MAX_NUM_UE].min_rsrp = UINT32_MAX;
129-
crc_out->stats[ind % MAX_NUM_UE].max_sinr = 0;
130-
crc_out->stats[ind % MAX_NUM_UE].max_rsrp = INT32_MIN;
127+
crc_out->stats[ind % MAX_NUM_UE].min_sinr = INT16_MAX;
128+
crc_out->stats[ind % MAX_NUM_UE].max_sinr = INT16_MIN;
131129
crc_out->stats[ind % MAX_NUM_UE].sum_sinr = 0;
132-
crc_out->stats[ind % MAX_NUM_UE].sum_rsrp = 0;
133130
crc_out->stats[ind % MAX_NUM_UE].cnt_sinr = 0;
131+
crc_out->stats[ind % MAX_NUM_UE].min_rsrp = UINT32_MAX;
132+
crc_out->stats[ind % MAX_NUM_UE].max_rsrp = 0;
133+
crc_out->stats[ind % MAX_NUM_UE].sum_rsrp = 0;
134134
crc_out->stats[ind % MAX_NUM_UE].cnt_rsrp = 0;
135135

136136
ind = JBPF_PROTOHASH_LOOKUP_ELEM_32(uci_out, stats, uci_hash, ctx->du_ue_index, new_val);

codelets/mac/mac_sched_ul_harq_stats.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "jbpf_defs.h"
1818
#include "jbpf_helper.h"
1919
#include "jbpf_helper_utils.h"
20-
20+
#include "../utils/stats_utils.h"
2121

2222
struct jbpf_load_map_def SEC("maps") ul_harq_not_empty = {
2323
.type = JBPF_MAP_TYPE_ARRAY,
@@ -39,20 +39,6 @@ DEFINE_PROTOHASH_32(ul_harq_hash, MAX_NUM_UE);
3939

4040

4141

42-
43-
#define STATS_UPDATE(dest, src) \
44-
do { \
45-
dest.count++; \
46-
if (src < dest.min) { \
47-
dest.min = src; \
48-
} \
49-
if (src > dest.max) { \
50-
dest.max = src; \
51-
} \
52-
dest.total += src; \
53-
} while (0)
54-
55-
5642
//#define DEBUG_PRINT
5743

5844
extern "C" SEC("jbpf_ran_mac_sched")
@@ -91,15 +77,15 @@ uint64_t jbpf_main(void* state)
9177
if (reinterpret_cast<const uint8_t*>(&harq_info) + sizeof(jbpf_mac_sched_harq_ctx_info) <= reinterpret_cast<const uint8_t*>(ctx->data_end)) {
9278

9379
// cons_retx
94-
MAC_STATS_UPDATE(out->stats[ind % MAX_NUM_UE].cons_retx, harq_info.nof_retxs);
80+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE].cons_retx, harq_info.nof_retxs);
9581

9682
// mcs
97-
MAC_STATS_UPDATE(out->stats[ind % MAX_NUM_UE].mcs, harq_info.mcs);
83+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE].mcs, harq_info.mcs);
9884

9985
// perHarqTypeStats
10086
t_harq_type_stats& hts = out->stats[ind % MAX_NUM_UE].perHarqTypeStats[harq_info.harq_type % JBPF_HARQ_EVENT_NUM];
10187
hts.count++;
102-
MAC_TRAFFIC_STATS_UPDATE(hts.tbs_bytes, harq_info.tbs_bytes);
88+
TRAFFIC_STATS_UPDATE(hts.tbs_bytes, harq_info.tbs_bytes);
10389
}
10490

10591
*not_empty_stats = 1;

codelets/pdcp/pdcp_dl_discard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ uint64_t jbpf_main(void* state)
9090
// update window_info
9191
const jbpf_queue_info_t* queue_info = &pdcp_ctx.window_info;
9292
if (queue_info->used) {
93-
PDCP_STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_pkts, queue_info->num_pkts);
94-
PDCP_STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_bytes, queue_info->num_bytes);
93+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_pkts, queue_info->num_pkts);
94+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_bytes, queue_info->num_bytes);
9595
out->stats[ind % MAX_NUM_UE_RB].has_pdu_window_pkts = true;
9696
out->stats[ind % MAX_NUM_UE_RB].has_pdu_window_bytes = true;
9797
}

codelets/pdcp/pdcp_dl_new_sdu.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "../utils/misc_utils.h"
1212
#include "../utils/hashmap_utils.h"
13+
#include "../utils/stats_utils.h"
1314

1415

1516
#define SEC(NAME) __attribute__((section(NAME), used))
@@ -89,14 +90,14 @@ uint64_t jbpf_main(void* state)
8990

9091
const jbpf_queue_info_t* queue_info = &pdcp_ctx.window_info;
9192
if (queue_info->used) {
92-
PDCP_STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_pkts, queue_info->num_pkts);
93-
PDCP_STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_bytes, queue_info->num_bytes);
93+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_pkts, queue_info->num_pkts);
94+
STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].pdu_window_bytes, queue_info->num_bytes);
9495
out->stats[ind % MAX_NUM_UE_RB].has_pdu_window_pkts = true;
9596
out->stats[ind % MAX_NUM_UE_RB].has_pdu_window_bytes = true;
9697
}
9798

9899
// update sdu_new_bytes
99-
PDCP_TRAFFIC_STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].sdu_new_bytes, sdu_length);
100+
TRAFFIC_STATS_UPDATE(out->stats[ind % MAX_NUM_UE_RB].sdu_new_bytes, sdu_length);
100101

101102
*not_empty_stats = 1;
102103

0 commit comments

Comments
 (0)