Use snprintf() in dump_mac_stats()
This commit is contained in:
@@ -534,7 +534,7 @@ int get_mcs_from_bler(const NR_bler_options_t *bler_options,
|
|||||||
|
|
||||||
void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP);
|
void nr_sr_reporting(gNB_MAC_INST *nrmac, frame_t frameP, sub_frame_t slotP);
|
||||||
|
|
||||||
size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp);
|
size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset_rsrp);
|
||||||
|
|
||||||
void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl);
|
void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl);
|
||||||
|
|
||||||
|
|||||||
@@ -78,11 +78,12 @@ void clear_mac_stats(gNB_MAC_INST *gNB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rsrp)
|
size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, size_t strlen, bool reset_rsrp)
|
||||||
{
|
{
|
||||||
int num = 1;
|
int num = 1;
|
||||||
|
const char *begin = output;
|
||||||
|
const char *end = output + strlen;
|
||||||
|
|
||||||
int stroff=0;
|
|
||||||
pthread_mutex_lock(&gNB->UE_info.mutex);
|
pthread_mutex_lock(&gNB->UE_info.mutex);
|
||||||
UE_iterator(gNB->UE_info.list, UE) {
|
UE_iterator(gNB->UE_info.list, UE) {
|
||||||
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
|
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
|
||||||
@@ -90,60 +91,77 @@ size_t dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen, bool reset_rs
|
|||||||
const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0;
|
const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0;
|
||||||
|
|
||||||
|
|
||||||
stroff+=sprintf(output+stroff,"UE RNTI %04x (%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n",
|
output += snprintf(output,
|
||||||
UE->rnti,
|
end - output,
|
||||||
num++,
|
"UE RNTI %04x (%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n",
|
||||||
sched_ctrl->ph,
|
UE->rnti,
|
||||||
sched_ctrl->pcmax,
|
num++,
|
||||||
avg_rsrp,
|
sched_ctrl->ph,
|
||||||
stats->num_rsrp_meas);
|
sched_ctrl->pcmax,
|
||||||
stroff+=sprintf(output+stroff,"UE %04x: CQI %d, RI %d, PMI (%d,%d)\n",
|
avg_rsrp,
|
||||||
UE->rnti,
|
stats->num_rsrp_meas);
|
||||||
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb,
|
output += snprintf(output,
|
||||||
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.ri+1,
|
end - output,
|
||||||
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1,
|
"UE %04x: CQI %d, RI %d, PMI (%d,%d)\n",
|
||||||
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2);
|
UE->rnti,
|
||||||
|
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.wb_cqi_1tb,
|
||||||
stroff+=sprintf(output+stroff,"UE %04x: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n",
|
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.ri+1,
|
||||||
UE->rnti,
|
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x1,
|
||||||
|
UE->UE_sched_ctrl.CSI_report.cri_ri_li_pmi_cqi_report.pmi_x2);
|
||||||
|
|
||||||
stats->dl.rounds[0], stats->dl.rounds[1],
|
output += snprintf(output,
|
||||||
stats->dl.rounds[2], stats->dl.rounds[3],
|
end - output,
|
||||||
stats->dl.errors,
|
"UE %04x: dlsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", dlsch_errors %"PRIu64", pucch0_DTX %d, BLER %.5f MCS %d\n",
|
||||||
stats->pucch0_DTX,
|
UE->rnti,
|
||||||
sched_ctrl->dl_bler_stats.bler,
|
stats->dl.rounds[0], stats->dl.rounds[1],
|
||||||
sched_ctrl->dl_bler_stats.mcs);
|
stats->dl.rounds[2], stats->dl.rounds[3],
|
||||||
|
stats->dl.errors,
|
||||||
|
stats->pucch0_DTX,
|
||||||
|
sched_ctrl->dl_bler_stats.bler,
|
||||||
|
sched_ctrl->dl_bler_stats.mcs);
|
||||||
if (reset_rsrp) {
|
if (reset_rsrp) {
|
||||||
stats->num_rsrp_meas = 0;
|
stats->num_rsrp_meas = 0;
|
||||||
stats->cumul_rsrp = 0;
|
stats->cumul_rsrp = 0;
|
||||||
}
|
}
|
||||||
stroff+=sprintf(output+stroff,"UE %04x: dlsch_total_bytes %"PRIu64"\n", UE->rnti, stats->dl.total_bytes);
|
output += snprintf(output,
|
||||||
stroff+=sprintf(output+stroff,"UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n",
|
end - output,
|
||||||
UE->rnti,
|
"UE %04x: dlsch_total_bytes %"PRIu64"\n",
|
||||||
stats->ul.rounds[0], stats->ul.rounds[1],
|
UE->rnti,
|
||||||
stats->ul.rounds[2], stats->ul.rounds[3],
|
stats->dl.total_bytes);
|
||||||
stats->ulsch_DTX,
|
output += snprintf(output,
|
||||||
stats->ul.errors,
|
end - output,
|
||||||
sched_ctrl->ul_bler_stats.bler,
|
"UE %04x: ulsch_rounds %"PRIu64"/%"PRIu64"/%"PRIu64"/%"PRIu64", ulsch_DTX %d, ulsch_errors %"PRIu64", BLER %.5f MCS %d\n",
|
||||||
sched_ctrl->ul_bler_stats.mcs);
|
UE->rnti,
|
||||||
stroff+=sprintf(output+stroff,
|
stats->ul.rounds[0], stats->ul.rounds[1],
|
||||||
"UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n",
|
stats->ul.rounds[2], stats->ul.rounds[3],
|
||||||
UE->rnti,
|
stats->ulsch_DTX,
|
||||||
stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes);
|
stats->ul.errors,
|
||||||
|
sched_ctrl->ul_bler_stats.bler,
|
||||||
|
sched_ctrl->ul_bler_stats.mcs);
|
||||||
|
output += snprintf(output,
|
||||||
|
end - output,
|
||||||
|
"UE %04x: ulsch_total_bytes_scheduled %"PRIu64", ulsch_total_bytes_received %"PRIu64"\n",
|
||||||
|
UE->rnti,
|
||||||
|
stats->ulsch_total_bytes_scheduled, stats->ul.total_bytes);
|
||||||
for (int lc_id = 0; lc_id < 63; lc_id++) {
|
for (int lc_id = 0; lc_id < 63; lc_id++) {
|
||||||
if (stats->dl.lc_bytes[lc_id] > 0) {
|
if (stats->dl.lc_bytes[lc_id] > 0)
|
||||||
stroff+=sprintf(output+stroff, "UE %04x: LCID %d: %"PRIu64" bytes TX\n", UE->rnti, lc_id, stats->dl.lc_bytes[lc_id]);
|
output += snprintf(output,
|
||||||
LOG_D(NR_MAC, "UE %04x: LCID %d: %"PRIu64" bytes TX\n", UE->rnti, lc_id, stats->dl.lc_bytes[lc_id]);
|
end - output,
|
||||||
}
|
"UE %04x: LCID %d: %"PRIu64" bytes TX\n",
|
||||||
if (stats->ul.lc_bytes[lc_id] > 0) {
|
UE->rnti,
|
||||||
stroff+=sprintf(output+stroff, "UE %04x: LCID %d: %"PRIu64" bytes RX\n", UE->rnti, lc_id, stats->ul.lc_bytes[lc_id]);
|
lc_id,
|
||||||
LOG_D(NR_MAC, "UE %04x: LCID %d: %"PRIu64" bytes RX\n", UE->rnti, lc_id, stats->ul.lc_bytes[lc_id]);
|
stats->dl.lc_bytes[lc_id]);
|
||||||
|
if (stats->ul.lc_bytes[lc_id] > 0)
|
||||||
}
|
output += snprintf(output,
|
||||||
|
end - output,
|
||||||
|
"UE %04x: LCID %d: %"PRIu64" bytes RX\n",
|
||||||
|
UE->rnti,
|
||||||
|
lc_id,
|
||||||
|
stats->ul.lc_bytes[lc_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&gNB->UE_info.mutex);
|
pthread_mutex_unlock(&gNB->UE_info.mutex);
|
||||||
return stroff;
|
return output - begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user