Commit 5a519297 authored by frtabu's avatar frtabu

Add cpu measurements access from telnet server

parent bbf4cc31
......@@ -501,21 +501,31 @@ int process_command(char *buf) {
}/* strncmp: module name test */
else if (strncasecmp(modulename,"loop",4) == 0 ) {
int f = fcntl(telnetparams.new_socket,F_GETFL);
fcntl (telnetparams.new_socket, F_SETFL, O_NONBLOCK | f);
int f1=fcntl (telnetparams.new_socket, F_SETFL, O_NONBLOCK | f);
if (f<0 || f1 <0) {
client_printf( " Loop won't be cancelable: %s\n",strerror(errno) );
}
for(int lc=0; lc<telnetparams.loopcount; lc++) {
char dummybuff[20];
char tbuff[64];
int rs;
client_printf(CSI "1J" CSI "1;10H " STDFMT "%s %i/%i\n",
get_time(tbuff,sizeof(tbuff)),lc,telnetparams.loopcount );
process_command(bufbck+strlen("loop")+1);
usleep(telnetparams.loopdelay * 1000);
rs = read(telnetparams.new_socket,dummybuff,sizeof(dummybuff));
errno=0;
int rs = read(telnetparams.new_socket,dummybuff,sizeof(dummybuff));
if ( rs > 0 ) {
if (telnetparams.telnetdbg > 0)
client_printf("Received \"%s\" status %d, errno %s while running loop\n",dummybuff,rs,strerror(errno));
if ( errno != EAGAIN && errno != EWOULDBLOCK) {
client_printf( STDFMT " Loop canceled, iteration %i/%i\n",lc,telnetparams.loopcount );
lc=telnetparams.loopcount;
break;
}
usleep(telnetparams.loopdelay * 1000);
}
fcntl (telnetparams.new_socket, F_SETFL, f);
......
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file common/utils/telnetsrv/telnetsrv_cpumeasur_def.h
* \brief: definitions of macro used to initialize the telnet_ltemeasurdef_t
* \ strucures arrays which are then used by the display functions
* \ in telnetsrv_measurements.c.
* \author Francois TABURET
* \date 2019
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#define CPU_PHYENB_MEASURE \
{ \
{"phy_proc_tx", &(phyvars->phy_proc_tx),0},\
{"phy_proc_rx", &(phyvars->phy_proc_rx),0},\
{"rx_prach", &(phyvars->rx_prach),0},\
{"ofdm_mod", &(phyvars->ofdm_mod_stats),0},\
{"dlsch_common_and_dci", &(phyvars->dlsch_common_and_dci),0},\
{"dlsch_ue_specific", &(phyvars->dlsch_ue_specific),0},\
{"dlsch_encoding", &(phyvars->dlsch_encoding_stats),0},\
{"dlsch_modulation", &(phyvars->dlsch_modulation_stats),0},\
{"dlsch_scrambling", &(phyvars->dlsch_scrambling_stats),0},\
{"dlsch_rate_matching", &(phyvars->dlsch_rate_matching_stats),0},\
{"dlsch_turbo_encod_prep", &(phyvars->dlsch_turbo_encoding_preperation_stats),0},\
{"dlsch_turbo_encod_segm", &(phyvars->dlsch_turbo_encoding_segmentation_stats),0},\
{"dlsch_turbo_encod", &(phyvars->dlsch_turbo_encoding_stats),0},\
{"dlsch_turbo_encod_waiting", &(phyvars->dlsch_turbo_encoding_waiting_stats),0},\
{"dlsch_turbo_encod_signal", &(phyvars->dlsch_turbo_encoding_signal_stats),0},\
{"dlsch_turbo_encod_main", &(phyvars->dlsch_turbo_encoding_main_stats),0},\
{"dlsch_turbo_encod_wakeup0", &(phyvars->dlsch_turbo_encoding_wakeup_stats0),0},\
{"dlsch_turbo_encod_wakeup1", &(phyvars->dlsch_turbo_encoding_wakeup_stats1),0},\
{"dlsch_interleaving", &(phyvars->dlsch_interleaving_stats),0},\
{"rx_dft", &(phyvars->rx_dft_stats),0},\
{"ulsch_channel_estimation", &(phyvars->ulsch_channel_estimation_stats),0},\
{"ulsch_freq_offset_estimation", &(phyvars->ulsch_freq_offset_estimation_stats),0},\
{"ulsch_decoding", &(phyvars->ulsch_decoding_stats),0},\
{"ulsch_demodulation", &(phyvars->ulsch_demodulation_stats),0},\
{"ulsch_rate_unmatching", &(phyvars->ulsch_rate_unmatching_stats),0},\
{"ulsch_turbo_decoding", &(phyvars->ulsch_turbo_decoding_stats),0},\
{"ulsch_deinterleaving", &(phyvars->ulsch_deinterleaving_stats),0},\
{"ulsch_demultiplexing", &(phyvars->ulsch_demultiplexing_stats),0},\
{"ulsch_llr", &(phyvars->ulsch_llr_stats),0},\
{"ulsch_tc_init", &(phyvars->ulsch_tc_init_stats),0},\
{"ulsch_tc_alpha", &(phyvars->ulsch_tc_alpha_stats),0},\
{"ulsch_tc_beta", &(phyvars->ulsch_tc_beta_stats),0},\
{"ulsch_tc_gamma", &(phyvars->ulsch_tc_gamma_stats),0},\
{"ulsch_tc_ext", &(phyvars->ulsch_tc_ext_stats),0},\
{"ulsch_tc_intl1", &(phyvars->ulsch_tc_intl1_stats),0},\
{"ulsch_tc_intl2", &(phyvars->ulsch_tc_intl2_stats),0},\
}
#define CPU_MACENB_MEASURE \
{ \
{"eNB_scheduler", &(macvars->eNB_scheduler),0},\
{"schedule_si", &(macvars->schedule_si),0},\
{"schedule_ra", &(macvars->schedule_ra),0},\
{"schedule_ulsch", &(macvars->schedule_ulsch),0},\
{"fill_DLSCH_dci", &(macvars->fill_DLSCH_dci),0},\
{"schedule_dlsch_pre", &(macvars->schedule_dlsch_preprocessor),0},\
{"schedule_dlsch", &(macvars->schedule_dlsch),0},\
{"schedule_mch", &(macvars->schedule_mch),0},\
{"rx_ulsch_sdu", &(macvars->rx_ulsch_sdu),0},\
{"schedule_pch", &(macvars->schedule_pch),0},\
}
#define CPU_PDCPENB_MEASURE \
{ \
{"pdcp_run", &(pdcpvars->pdcp_run),0},\
{"data_req", &(pdcpvars->data_req),0},\
{"data_ind", &(pdcpvars->data_ind),0},\
{"apply_security", &(pdcpvars->apply_security),0},\
{"validate_security", &(pdcpvars->validate_security),0},\
{"pdcp_ip", &(pdcpvars->pdcp_ip),0},\
{"ip_pdcp", &(pdcpvars->ip_pdcp),0},\
}
......@@ -19,10 +19,10 @@
* contact@openairinterface.org
*/
/*! \file common/utils/telnetsrv/telnetsrv_proccmd.c
* \brief: implementation of telnet commands related to this linux process
/*! \file common/utils/telnetsrv/telnetsrv_measurements.c
* \brief: implementation of telnet commands related to measurments
* \author Francois TABURET
* \date 2017
* \date 2019
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
......@@ -46,71 +46,128 @@
#define TELNETSRV_MEASURMENTS_MAIN
#include "common/utils/LOG/log.h"
#include "common/config/config_userapi.h"
#include "telnetsrv_measurments.h"
#include "telnetsrv_measurements.h"
#include "telnetsrv_ltemeasur_def.h"
#include "telnetsrv_cpumeasur_def.h"
#include "openair2/LAYER2/MAC/mac.h"
#include "openair1/PHY/phy_extern.h"
void measurcmd_display_macstats(telnet_printfunc_t prnt);
void measurcmd_display_macstats_ue(telnet_printfunc_t prnt);
void measurcmd_display_rlcstats(telnet_printfunc_t prnt);
void measurcmd_display_phycpu(telnet_printfunc_t prnt);
void measurcmd_display_maccpu(telnet_printfunc_t prnt);
void measurcmd_display_pdcpcpu(telnet_printfunc_t prnt);
static telnet_measurgroupdef_t measurgroups[] = {
{"enb", GROUP_LTESTATS,0, measurcmd_display_macstats, {NULL}},
{"enbues",GROUP_LTESTATS,0, measurcmd_display_macstats_ue,{NULL}},
{"rlc", GROUP_LTESTATS,0, measurcmd_display_rlcstats, {NULL}},
{"enbues",GROUP_LTESTATS,0, measurcmd_display_macstats_ue,{NULL}},
{"rlc", GROUP_LTESTATS,0, measurcmd_display_rlcstats, {NULL}},
{"phycpu",GROUP_CPUSTATS,0, measurcmd_display_phycpu, {NULL}},
{"maccpu",GROUP_CPUSTATS,0, measurcmd_display_maccpu, {NULL}},
{"pdcpcpu",GROUP_CPUSTATS,0, measurcmd_display_pdcpcpu, {NULL}},
};
#define TELNET_NUM_MEASURGROUPS (sizeof(measurgroups)/sizeof(telnet_measurgroupdef_t))
static int eNB_id =0;
static char *grouptypes[] = {"ltestats","cpustats"};
static double cpufreq;
#define TELNET_NUM_MEASURTYPES (sizeof(grouptypes)/sizeof(char *))
#define HDR "---------------------------------"
void measurcmd_display_groups(telnet_printfunc_t prnt) {
prnt(" %*s %10s %s\n",TELNET_MAXMEASURNAME_LEN-1,"name","type","nombre de mesures");
for(int i=0; i<TELNET_NUM_MEASURGROUPS; i++)
prnt("%02d %*s %10s %i\n",i,TELNET_MAXMEASURNAME_LEN-1,measurgroups[i].groupname,
grouptypes[measurgroups[i].type], measurgroups[i].size);
prnt(" %*s %10s %s\n",TELNET_MAXMEASURNAME_LEN-1,"name","type","nombre de mesures");
for(int i=0; i<TELNET_NUM_MEASURGROUPS; i++)
prnt("%02d %*s %10s %i\n",i,TELNET_MAXMEASURNAME_LEN-1,measurgroups[i].groupname,
grouptypes[measurgroups[i].type], measurgroups[i].size);
} /* measurcmd_display_groups */
/*----------------------------------------------------------------------------------------------------*/
/* cpu measurements functions */
void measurcmd_display_cpumeasures(telnet_printfunc_t prnt, telnet_cpumeasurdef_t *cpumeasure, int cpumeasure_size) {
for (int i=0; i<cpumeasure_size; i++) {
prnt("%02d %*s: %15.3f us; %15d %s",i,TELNET_MAXMEASURNAME_LEN-1,(cpumeasure+i)->statname,
((cpumeasure+i)->astatptr->trials!=0)?(((cpumeasure+i)->astatptr->diff)/((cpumeasure+i)->astatptr->trials))/cpufreq/1000:0,
(cpumeasure+i)->astatptr->trials, ((i%2)==1)?"|\n":" | " );
}
prnt("\n\n");
} /* measurcmd_display_measures */
#define PRINT_CPUMEAS_STATE ((cpumeas(CPUMEAS_GETSTATE))?"enabled":"disabled")
void measurcmd_display_phycpu(telnet_printfunc_t prnt) {
PHY_VARS_eNB *phyvars = RC.eNB[eNB_id][0];
telnet_cpumeasurdef_t cpumeasur[]=CPU_PHYENB_MEASURE;
prnt("%s cpu (%1.1g GHz) measurements: PHY (cpustats %s) %s\n",HDR,cpufreq,
PRINT_CPUMEAS_STATE,HDR);
measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t));
}
void measurcmd_display_maccpu(telnet_printfunc_t prnt) {
eNB_MAC_INST *macvars = RC.mac[eNB_id];
telnet_cpumeasurdef_t cpumeasur[]=CPU_MACENB_MEASURE;
prnt("%s cpu (%1.1g GHz) measurements: MAC (cpustats %s) %s\n",HDR,cpufreq,
PRINT_CPUMEAS_STATE,HDR);
measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t));
}
void measurcmd_display_pdcpcpu(telnet_printfunc_t prnt) {
pdcp_stats_t *pdcpvars = &(eNB_pdcp_stats[eNB_id]);
telnet_cpumeasurdef_t cpumeasur[]=CPU_PDCPENB_MEASURE;
prnt("%s cpu (%1.1g GHz) measurements: PDCP (cpustats %s) %s \n",HDR,cpufreq,
PRINT_CPUMEAS_STATE,HDR);
measurcmd_display_cpumeasures(prnt, cpumeasur, sizeof(cpumeasur)/sizeof(telnet_cpumeasurdef_t));
}
/*----------------------------------------------------------------------------------------------------*/
/* lte measurements functions */
uint64_t measurcmd_getstatvalue(telnet_ltemeasurdef_t *measur,telnet_printfunc_t prnt) {
uint64_t val;
uint64_t val;
switch(measur->vtyp) {
case TELNET_VARTYPE_INT64:
val = (uint64_t)(*((uint64_t *)(measur->vptr)));
break;
val = (uint64_t)(*((uint64_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_INT32:
val = (uint64_t)(*((uint32_t *)(measur->vptr)));
break;
val = (uint64_t)(*((uint32_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_INT16:
val = (uint64_t)(*((uint16_t *)(measur->vptr)));
break;
val = (uint64_t)(*((uint16_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_INT8:
val = (uint64_t)(*((uint8_t *)(measur->vptr)));
break;
val = (uint64_t)(*((uint8_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_UINT:
val = (uint64_t)(*((unsigned int *)(measur->vptr)));
break;
val = (uint64_t)(*((unsigned int *)(measur->vptr)));
break;
default:
prnt("%s %i: unknown type \n",measur->statname,measur->vtyp);
val = (uint64_t)(*((uint64_t *)(measur->vptr)));
break;
prnt("%s %i: unknown type \n",measur->statname,measur->vtyp);
val = (uint64_t)(*((uint64_t *)(measur->vptr)));
break;
}
return val;
} /* measurcmd_getstatvalue */
void measurcmd_display_measures(telnet_printfunc_t prnt, telnet_ltemeasurdef_t *statsptr, int stats_size) {
for (int i=0; i<stats_size; i++) {
prnt("%*s = %15llu%s",TELNET_MAXMEASURNAME_LEN-1,statsptr[i].statname,
measurcmd_getstatvalue(&(statsptr[i]),prnt), ((i%3)==2)?"\n":" ");
measurcmd_getstatvalue(&(statsptr[i]),prnt), ((i%3)==2)?"\n":" ");
}
prnt("\n\n");
} /* measurcmd_display_measures */
void measurcmd_display_macstats_ue(telnet_printfunc_t prnt) {
UE_list_t *UE_list = &(RC.mac[eNB_id]->UE_list);
for (int UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
for (int UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
for (int i=0; i<UE_list->numactiveCCs[UE_id]; i++) {
int CC_id = UE_list->ordered_CCids[i][UE_id];
prnt("%s UE %i Id %i CCid %i %s\n",HDR,i,UE_id,CC_id,HDR);
......@@ -122,7 +179,6 @@ void measurcmd_display_macstats_ue(telnet_printfunc_t prnt) {
} /* measurcmd_display_macstats_ue */
void measurcmd_display_macstats(telnet_printfunc_t prnt) {
for (int CC_id=0 ; CC_id < MAX_NUM_CCs; CC_id++) {
eNB_STATS *macstatptr=&(RC.mac[eNB_id]->eNB_stats[CC_id]);
telnet_ltemeasurdef_t statsptr[]=LTEMAC_MEASURE;
......@@ -130,26 +186,25 @@ void measurcmd_display_macstats(telnet_printfunc_t prnt) {
HDR, eNB_id, CC_id, RC.mac[eNB_id]->frame,HDR);
measurcmd_display_measures(prnt,statsptr,sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t));
}
} /* measurcmd_display_macstats */
void measurcmd_display_one_rlcstat(telnet_printfunc_t prnt, int UE_id, telnet_ltemeasurdef_t *statsptr, int num_rlcmeasure, unsigned int *rlcstats,
char * rbid_str, protocol_ctxt_t *ctxt, const srb_flag_t srb_flagP, const rb_id_t rb_idP)
void measurcmd_display_one_rlcstat(telnet_printfunc_t prnt, int UE_id, telnet_ltemeasurdef_t *statsptr, int num_rlcmeasure, unsigned int *rlcstats,
char *rbid_str, protocol_ctxt_t *ctxt, const srb_flag_t srb_flagP, const rb_id_t rb_idP)
{
int rlc_status = rlc_stat_req(ctxt,srb_flagP,rb_idP,
rlcstats, rlcstats+1, rlcstats+2, rlcstats+3, rlcstats+4, rlcstats+5,
rlcstats+6, rlcstats+7, rlcstats+8, rlcstats+9, rlcstats+10, rlcstats+11,
rlcstats+12, rlcstats+13, rlcstats+14, rlcstats+15, rlcstats+16, rlcstats+17,
rlcstats+18, rlcstats+19, rlcstats+20, rlcstats+21, rlcstats+22, rlcstats+23,
rlcstats+24, rlcstats+25, rlcstats+26, rlcstats+27);
if (rlc_status == RLC_OP_STATUS_OK) {
prnt("%s UE %i RLC %s mode %s %s\n",HDR,UE_id, rbid_str,
(rlcstats[0]==RLC_MODE_AM)? "AM": (rlcstats[0]==RLC_MODE_UM)?"UM":"NONE",HDR);
measurcmd_display_measures(prnt, statsptr, num_rlcmeasure);
}
int rlc_status = rlc_stat_req(ctxt,srb_flagP,rb_idP,
rlcstats, rlcstats+1, rlcstats+2, rlcstats+3, rlcstats+4, rlcstats+5,
rlcstats+6, rlcstats+7, rlcstats+8, rlcstats+9, rlcstats+10, rlcstats+11,
rlcstats+12, rlcstats+13, rlcstats+14, rlcstats+15, rlcstats+16, rlcstats+17,
rlcstats+18, rlcstats+19, rlcstats+20, rlcstats+21, rlcstats+22, rlcstats+23,
rlcstats+24, rlcstats+25, rlcstats+26, rlcstats+27);
if (rlc_status == RLC_OP_STATUS_OK) {
prnt("%s UE %i RLC %s mode %s %s\n",HDR,UE_id, rbid_str,
(rlcstats[0]==RLC_MODE_AM)? "AM": (rlcstats[0]==RLC_MODE_UM)?"UM":"NONE",HDR);
measurcmd_display_measures(prnt, statsptr, num_rlcmeasure);
}
} /* status measurcmd_rlc_stat_req */
......@@ -158,61 +213,104 @@ void measurcmd_display_rlcstats(telnet_printfunc_t prnt) {
UE_list_t *UE_list = &(RC.mac[eNB_id]->UE_list);
telnet_ltemeasurdef_t statsptr[]=LTE_RLCMEASURE;
int num_rlcmeasure = sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t );
unsigned int *rlcstats = malloc(num_rlcmeasure*sizeof(unsigned int));
unsigned int *rlcstats = malloc(num_rlcmeasure*sizeof(unsigned int));
eNB_MAC_INST *eNB = RC.mac[eNB_id];
for(int i=0; i <num_rlcmeasure ;i++) {
for(int i=0; i <num_rlcmeasure ; i++) {
statsptr[i].vptr = rlcstats + i;
}
}
for (int UE_id=UE_list->head; UE_id>=0; UE_id=UE_list->next[UE_id]) {
#define NB_eNB_INST 1
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,eNB_id, ENB_FLAG_YES,UE_list->eNB_UE_stats[0][UE_id].crnti,
eNB->frame,eNB->subframe,eNB_id);
#define NB_eNB_INST 1
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,eNB_id, ENB_FLAG_YES,UE_list->eNB_UE_stats[0][UE_id].crnti,
eNB->frame,eNB->subframe,eNB_id);
measurcmd_display_one_rlcstat(prnt, UE_id, statsptr, num_rlcmeasure, rlcstats, "DCCH", &ctxt, SRB_FLAG_YES, DCCH);
measurcmd_display_one_rlcstat(prnt, UE_id, statsptr, num_rlcmeasure, rlcstats, "DTCH", &ctxt, SRB_FLAG_NO, DTCH-2);
}
} /* measurcmd_display_macstats_ue */
int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt)
{
char *subcmd=NULL;
int idx1, idx2;
/*------------------------------------------------------------------------------------------------------------------------*/
/* function called by the telnet server when measur command is entered */
int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt) {
char *subcmd=NULL;
int idx1, idx2;
int badcmd=1;
if (debug > 0)
prnt(" measurcmd_show received %s\n",buf);
// char tmp[20480];
// dump_eNB_l2_stats(tmp, 0);
// prnt("%s\n",tmp);
int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
if (s>0) {
if ( strcmp(subcmd,"groups") == 0)
measurcmd_display_groups(prnt);
else {
for (int i=0; i<TELNET_NUM_MEASURTYPES; i++) {
if(strcmp(subcmd,grouptypes[i]) == 0) {
for(int j=0; j<TELNET_NUM_MEASURGROUPS; j++) {
if(i == measurgroups[j].type) {
measurgroups[j].displayfunc(prnt);
}
} /* for j...*/
}
}/* for i...*/
for (int i=0; i<TELNET_NUM_MEASURGROUPS; i++) {
if(strcmp(subcmd,measurgroups[i].groupname) == 0) {
measurgroups[i].displayfunc(prnt);
break;
}
}
prnt(" measurcmd_show received %s\n",buf);
// char tmp[20480];
// dump_eNB_l2_stats(tmp, 0);
// prnt("%s\n",tmp);
int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
if (s>0) {
if ( strcmp(subcmd,"groups") == 0) {
measurcmd_display_groups(prnt);
badcmd=0;
} else {
for (int i=0; i<TELNET_NUM_MEASURTYPES; i++) {
if(strcmp(subcmd,grouptypes[i]) == 0) {
for(int j=0; j<TELNET_NUM_MEASURGROUPS; j++) {
if(i == measurgroups[j].type) {
badcmd=0;
measurgroups[j].displayfunc(prnt);
}
} /* for j...*/
}
}/* for i...*/
for (int i=0; i<TELNET_NUM_MEASURGROUPS; i++) {
if(strcmp(subcmd,measurgroups[i].groupname) == 0) {
measurgroups[i].displayfunc(prnt);
badcmd=0;
break;
}
}
}
free(subcmd);
free(subcmd);
} /* s>0 */
return 0;
}
/*-------------------------------------------------------------------------------------*/
if (badcmd) {
prnt("%s: unknown measur command\n",buf);
}
void add_measur_cmds(void)
{
add_telnetcmd("measur",measur_vardef,measur_cmdarray);
return CMDSTATUS_FOUND;
}
int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt) {
char *subcmd=NULL;
int idx1, idx2;
int badcmd=1;
if (debug > 0)
prnt(" measurcmd_show received %s\n",buf);
int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
if (s>0) {
if ( strcmp(subcmd,"enable") == 0) {
cpumeas(CPUMEAS_ENABLE);
badcmd=0;
} else if ( strcmp(subcmd,"disable") == 0) {
cpumeas(CPUMEAS_DISABLE);
badcmd=0;
}
}
if (badcmd) {
prnt("Cpu measurments state: %s\n",PRINT_CPUMEAS_STATE);
}
free(subcmd);
return CMDSTATUS_FOUND;
}
/*-------------------------------------------------------------------------------------*/
/* function called at telnet server init to add the measur command */
void add_measur_cmds(void) {
add_telnetcmd("measur",measur_vardef,measur_cmdarray);
cpufreq = get_cpu_freq_GHz();
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file common/utils/telnetsrv/telnetsrv_measurements.h
* \brief: Include file defining constants, structures and function prototypes
* \ used to implement the measurements functionality of the telnet server
* \author Francois TABURET
* \date 2019
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#include <dlfcn.h>
#include "telnetsrv.h"
#include "openair1/PHY/defs_eNB.h"
#ifdef TELNETSRV_MEASURMENTS_MAIN
#define TELNET_MAXMEASURNAME_LEN 30
#define TELNET_MAXMEASURGROUPS 10
telnetshell_vardef_t measur_vardef[] = {
{"",0,NULL}
};
typedef struct cpumeasurdef {
char statname[TELNET_MAXMEASURNAME_LEN];
time_stats_t *astatptr;
unsigned int statemask;
} telnet_cpumeasurdef_t;
typedef struct ltemeasurdef {
char statname[TELNET_MAXMEASURNAME_LEN];
void *vptr;
char vtyp;
unsigned int statemask;
} telnet_ltemeasurdef_t;
#define GROUP_LTESTATS 0
#define GROUP_CPUSTATS 1
typedef void(*measur_dislayfunc_t)(telnet_printfunc_t prnt);
typedef struct mesurgroupdef {
char groupname[TELNET_MAXMEASURNAME_LEN];
unsigned char type;
unsigned char size;
measur_dislayfunc_t displayfunc;
union {
telnet_cpumeasurdef_t *cpustats;
telnet_ltemeasurdef_t *ltestats;
};
} telnet_measurgroupdef_t;
#define MACSTATS_NAME(valptr) #valptr
#define LTEMAC_MEASURGROUP_NAME "ltemac"
#define PHYCPU_MEASURGROUP_NAME "phycpu"
int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt);
int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt);
telnetshell_cmddef_t measur_cmdarray[] = {
{"show", "groups | <group name>" , measurcmd_show},
{"cpustats","[enable | disable]",measurcmd_cpustats},
{"","",NULL}
};
#else
extern void add_measur_cmds(void);
#endif /* TELNETSRV_MEASURCMD_MAIN */
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file common/utils/telnetsrv/telnetsrv_proccmd.h
* \brief: Include file defining telnet commands related to this linux process
* \author Francois TABURET
* \date 2017
* \version 0.1
* \company NOKIA BellLabs France
* \email: francois.taburet@nokia-bell-labs.com
* \note
* \warning
*/
#include <dlfcn.h>
#include "telnetsrv.h"
#include "openair1/PHY/defs_eNB.h"
#ifdef TELNETSRV_MEASURMENTS_MAIN
#define TELNET_MAXMEASURNAME_LEN 30
#define TELNET_MAXMEASURGROUPS 10
telnetshell_vardef_t measur_vardef[] = {
{"",0,NULL}
};
typedef struct cpumeasurdef {
char statname[TELNET_MAXMEASURNAME_LEN];
time_stats_t *astatptr;
unsigned int statemask;
} telnet_cpumeasurdef_t;
typedef struct ltemeasurdef {
char statname[TELNET_MAXMEASURNAME_LEN];
void *vptr;
char vtyp;
unsigned int statemask;
} telnet_ltemeasurdef_t;
#define GROUP_LTESTATS 0
#define GROUP_CPUSTATS 1
typedef void(*measur_dislayfunc_t)(telnet_printfunc_t prnt);
typedef struct mesurgroupdef {
char groupname[TELNET_MAXMEASURNAME_LEN];
unsigned char type;
unsigned char size;
measur_dislayfunc_t displayfunc;
union {
telnet_cpumeasurdef_t *cpustats;
telnet_ltemeasurdef_t *ltestats;
};
}telnet_measurgroupdef_t;
#define LTEMAC_MEASURE \
{ \
{"total_num_bcch_pdu", &(macstatptr->total_num_bcch_pdu),TELNET_VARTYPE_INT32,0},\
{"bcch_buffer", &(macstatptr->bcch_buffer),TELNET_VARTYPE_INT32,0},\
{"total_bcch_buffer", &(macstatptr->total_bcch_buffer),TELNET_VARTYPE_INT32,0},\
{"bcch_mcs", &(macstatptr->bcch_mcs),TELNET_VARTYPE_INT32,0},\
{"total_num_ccch_pdu", &(macstatptr->total_num_ccch_pdu),TELNET_VARTYPE_INT32,0},\
{"ccch_buffer", &(macstatptr->ccch_buffer),TELNET_VARTYPE_INT32,0},\
{"total_ccch_buffer", &(macstatptr->total_ccch_buffer),TELNET_VARTYPE_INT32,0},\
{"ccch_mcs", &(macstatptr->ccch_mcs),TELNET_VARTYPE_INT32,0},\
{"total_num_pcch_pdu", &(macstatptr->total_num_pcch_pdu),TELNET_VARTYPE_INT32,0},\
{"pcch_buffer", &(macstatptr->pcch_buffer),TELNET_VARTYPE_INT32,0},\
{"total_pcch_buffer", &(macstatptr->total_pcch_buffer),TELNET_VARTYPE_INT32,0},\
{"pcch_mcs", &(macstatptr->pcch_mcs),TELNET_VARTYPE_INT32,0},\
{"num_dlactive_UEs", &(macstatptr->num_dlactive_UEs),TELNET_VARTYPE_INT16,0},\
{"available_prbs", &(macstatptr->available_prbs),TELNET_VARTYPE_INT16,0},\
{"total_available_prbs", &(macstatptr->total_available_prbs),TELNET_VARTYPE_INT32,0},\
{"available_ncces", &(macstatptr->available_ncces),TELNET_VARTYPE_INT16,0},\
{"dlsch_bitrate", &(macstatptr->dlsch_bitrate),TELNET_VARTYPE_INT32,0},\
{"dlsch_bytes_tx", &(macstatptr->dlsch_bytes_tx),TELNET_VARTYPE_INT32,0},\
{"dlsch_pdus_tx", &(macstatptr->dlsch_pdus_tx),TELNET_VARTYPE_INT32,0},\
{"total_dlsch_bitrate", &(macstatptr->total_dlsch_bitrate),TELNET_VARTYPE_INT32,0},\
{"total_dlsch_bytes_tx", &(macstatptr->total_dlsch_bytes_tx),TELNET_VARTYPE_INT32,0},\
{"total_dlsch_pdus_tx", &(macstatptr->total_dlsch_pdus_tx),TELNET_VARTYPE_INT32,0},\
{"ulsch_bitrate", &(macstatptr->ulsch_bitrate),TELNET_VARTYPE_INT32,0},\
{"ulsch_bytes_rx", &(macstatptr->ulsch_bytes_rx),TELNET_VARTYPE_INT32,0},\
{"ulsch_pdus_rx", &(macstatptr->ulsch_pdus_rx),TELNET_VARTYPE_INT32,0},\
{"total_ulsch_bitrate", &(macstatptr->total_ulsch_bitrate),TELNET_VARTYPE_INT32,0},\
{"total_ulsch_bytes_rx", &(macstatptr->total_ulsch_bytes_rx),TELNET_VARTYPE_INT32,0},\
{"total_ulsch_pdus_rx", &(macstatptr->total_ulsch_pdus_rx),TELNET_VARTYPE_INT32,0},\
{"sched_decisions", &(macstatptr->sched_decisions),TELNET_VARTYPE_INT32,0},\
{"missed_deadlines", &(macstatptr->missed_deadlines),TELNET_VARTYPE_INT32,0},\
}
#define LTEMAC_UEMEASURE \
{ \
{"dlsch_mcs1", &(macuestatptr->dlsch_mcs1),TELNET_VARTYPE_INT8,0},\
{"dlsch_mcs2", &(macuestatptr->dlsch_mcs2),TELNET_VARTYPE_INT8,0},\
{"rbs_used", &(macuestatptr->rbs_used),TELNET_VARTYPE_INT32,0},\
{"rbs_used_retx", &(macuestatptr->rbs_used_retx),TELNET_VARTYPE_INT16,0},\
{"total_rbs_used", &(macuestatptr->total_rbs_used),TELNET_VARTYPE_INT16,0},\
{"ncce_used", &(macuestatptr->ncce_used),TELNET_VARTYPE_INT16,0},\
{"ncce_used_retx", &(macuestatptr->ncce_used_retx),TELNET_VARTYPE_INT16,0},\
{"TBS", &(macuestatptr->TBS),TELNET_VARTYPE_INT32,0},\
{"total_pdu_bytes", &(macuestatptr->total_pdu_bytes),TELNET_VARTYPE_INT64,0},\
{"total_num_pdus", &(macuestatptr->total_num_pdus),TELNET_VARTYPE_INT32,0},\
{"overhead_bytes", &(macuestatptr->overhead_bytes),TELNET_VARTYPE_INT64,0},\
{"crnti", &(macuestatptr->crnti),TELNET_VARTYPE_INT16,0},\
{"normalized_rx_power", &(macuestatptr->normalized_rx_power),TELNET_VARTYPE_INT32,0},\
{"target_rx_power", &(macuestatptr->target_rx_power),TELNET_VARTYPE_INT32,0},\
{"ulsch_mcs1", &(macuestatptr->ulsch_mcs1),TELNET_VARTYPE_INT8,0},\
{"ulsch_mcs2", &(macuestatptr->ulsch_mcs2),TELNET_VARTYPE_INT8,0},\
{"rbs_used_rx", &(macuestatptr->rbs_used_rx),TELNET_VARTYPE_INT32,0},\
{"rbs_used_retx_rx", &(macuestatptr->rbs_used_retx_rx),TELNET_VARTYPE_INT32,0},\
{"total_rbs_used_rx", &(macuestatptr->total_rbs_used_rx),TELNET_VARTYPE_INT32,0},\
{"ulsch_TBS", &(macuestatptr->ulsch_TBS),TELNET_VARTYPE_INT32,0},\
{"total_pdu_bytes_rx", &(macuestatptr->total_pdu_bytes_rx),TELNET_VARTYPE_INT64,0},\
{"total_num_pdus_rx", &(macuestatptr->total_num_pdus_rx),TELNET_VARTYPE_INT32,0},\
{"num_errors_rx", &(macuestatptr->num_errors_rx),TELNET_VARTYPE_INT32,0},\
}
#define LTE_RLCMEASURE \
{ \
{"rlc_mode", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_pdcp_sdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_pdcp_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_pdcp_sdu_discarded", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_pdcp_bytes_discarded", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_data_pdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_data_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_retransmit_pdu_by_status", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_retransmit_bytes_by_status", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_retransmit_pdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_retransmit_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_control_pdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"tx_control_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_pdcp_sdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_pdcp_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_pdus_duplicate", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_bytes_duplicate", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_pdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_pdu_dropped", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_bytes_dropped", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_pdu_out_of_window", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_data_bytes_out_of_window", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_control_pdu", NULL, TELNET_VARTYPE_UINT, 0},\
{"rx_control_bytes", NULL, TELNET_VARTYPE_UINT, 0},\
{"timer_reorder_tout", NULL, TELNET_VARTYPE_UINT, 0},\
{"timer_poll_retrans_tout", NULL, TELNET_VARTYPE_UINT, 0},\
{"timer_status_prohibit_tout", NULL, TELNET_VARTYPE_UINT, 0},\
}
#define MACSTATS_NAME(valptr) #valptr
#define LTEMAC_MEASURGROUP_NAME "ltemac"
#define PHYCPU_MEASURGROUP_NAME "phycpu"
int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt);
telnetshell_cmddef_t measur_cmdarray[] = {
{"show", LTEMAC_MEASURGROUP_NAME "|" PHYCPU_MEASURGROUP_NAME , measurcmd_show},
{"","",NULL},
};
#else
extern void add_measur_cmds(void);
#endif /* TELNETSRV_MEASURCMD_MAIN */
......@@ -29,7 +29,6 @@ int opp_enabled = 0;
double get_cpu_freq_GHz(void) {
time_stats_t ts = {0};
reset_meas(&ts);
ts.trials++;
......@@ -38,32 +37,40 @@ double get_cpu_freq_GHz(void) {
ts.diff = (rdtsc_oai()-ts.in);
cpu_freq_GHz = (double)ts.diff/1000000000;
printf("CPU Freq is %f \n", cpu_freq_GHz);
return cpu_freq_GHz;
return cpu_freq_GHz;
}
int cpumeas(int action) {
switch (action) {
case CPUMEAS_ENABLE:
opp_enabled = 1;
break;
case CPUMEAS_DISABLE:
opp_enabled = 0;
break;
case CPUMEAS_GETSTATE:
default:
break;
}
void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){
return opp_enabled;
}
void print_meas_now(time_stats_t *ts, const char *name, FILE *file_name) {
if (opp_enabled) {
//static double cpu_freq_GHz = 3.2;
//if (cpu_freq_GHz == 0.0)
//cpu_freq_GHz = get_cpu_freq_GHz(); // super slow
//cpu_freq_GHz = get_cpu_freq_GHz(); // super slow
if (ts->trials>0) {
//fprintf(file_name,"Name %25s: Processing %15.3f ms for SF %d, diff_now %15.3f \n", name,(ts->p_time/(cpu_freq_GHz*1000000.0)),subframe,ts->p_time);
fprintf(file_name,"%15.3f us, diff_now %15.3f \n",(ts->p_time/(cpu_freq_GHz*1000.0)),(double)ts->p_time);
}
}
}
void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time)
{
void print_meas(time_stats_t *ts, const char *name, time_stats_t *total_exec_time, time_stats_t *sf_exec_time) {
if (opp_enabled) {
static int first_time = 0;
static double cpu_freq_GHz = 0.0;
......@@ -81,7 +88,6 @@ void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_ti
if (ts->trials>0) {
//printf("%20s: total: %10.3f ms, average: %10.3f us (%10d trials)\n", name, ts->diff/cpu_freq_GHz/1000000.0, ts->diff/ts->trials/cpu_freq_GHz/1000.0, ts->trials);
if ((total_exec_time == NULL) || (sf_exec_time== NULL)) {
fprintf(stderr, "%25s: %15.3f us; %15d;\n",
name,
......@@ -98,12 +104,9 @@ void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_ti
}
}
}
}
double get_time_meas_us(time_stats_t *ts)
{
double get_time_meas_us(time_stats_t *ts) {
static double cpu_freq_GHz = 0.0;
if (cpu_freq_GHz == 0.0)
......
......@@ -61,23 +61,21 @@ static inline void start_meas(time_stats_t *ts) __attribute__((always_inline));
static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline));
void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name);
void print_meas(time_stats_t *ts, const char* name, time_stats_t * total_exec_time, time_stats_t * sf_exec_time);
void print_meas_now(time_stats_t *ts, const char *name, FILE *file_name);
void print_meas(time_stats_t *ts, const char *name, time_stats_t *total_exec_time, time_stats_t *sf_exec_time);
double get_time_meas_us(time_stats_t *ts);
double get_cpu_freq_GHz(void);
#if defined(__i386__)
static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline));
static inline unsigned long long rdtsc_oai(void)
{
static inline unsigned long long rdtsc_oai(void) {
unsigned long long int x;
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
return x;
}
#elif defined(__x86_64__)
static inline unsigned long long rdtsc_oai(void) __attribute__((always_inline));
static inline unsigned long long rdtsc_oai(void)
{
static inline unsigned long long rdtsc_oai(void) {
unsigned long long a, d;
__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
return (d<<32) | a;
......@@ -85,61 +83,54 @@ static inline unsigned long long rdtsc_oai(void)
#elif defined(__arm__)
static inline uint32_t rdtsc_oai(void) __attribute__((always_inline));
static inline uint32_t rdtsc_oai(void)
{
static inline uint32_t rdtsc_oai(void) {
uint32_t r = 0;
asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(r) );
return r;
}
#endif
static inline void start_meas(time_stats_t *ts)
{
#define CPUMEAS_DISABLE 0
#define CPUMEAS_ENABLE 1
#define CPUMEAS_GETSTATE 2
int cpumeas(int action);
static inline void start_meas(time_stats_t *ts) {
if (opp_enabled) {
if (ts->meas_flag==0) {
ts->trials++;
ts->in = rdtsc_oai();
ts->meas_flag=1;
}
else {
} else {
ts->in = rdtsc_oai();
}
}
}
static inline void stop_meas(time_stats_t *ts)
{
static inline void stop_meas(time_stats_t *ts) {
if (opp_enabled) {
long long out = rdtsc_oai();
ts->diff += (out-ts->in);
/// process duration is the difference between two clock points
ts->p_time = (out-ts->in);
ts->diff_square += (out-ts->in)*(out-ts->in);
if ((out-ts->in) > ts->max)
ts->max = out-ts->in;
ts->meas_flag=0;
ts->meas_flag=0;
}
}
static inline void reset_meas(time_stats_t *ts) {
ts->trials=0;
ts->diff=0;
ts->p_time=0;
ts->diff_square=0;
ts->max=0;
ts->meas_flag=0;
}
static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts)
{
static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) {
if (opp_enabled) {
dst_ts->trials=src_ts->trials;
dst_ts->diff=src_ts->diff;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment