Commit eb6e5ffe authored by frtabu's avatar frtabu

rewrite lte stats display, prepare cpu stats display

parent 05f395b2
......@@ -58,7 +58,7 @@
#include "telnetsrv_phycmd.h"
#include "telnetsrv_proccmd.h"
static char *telnet_defstatmod[] = {"softmodem","phy","loader"};
static char *telnet_defstatmod[] = {"softmodem","phy","loader","measur"};
static telnetsrv_params_t telnetparams;
#define TELNETSRV_LISTENADDR 0
#define TELNETSRV_LISTENPORT 1
......@@ -500,11 +500,10 @@ int process_command(char *buf) {
}/* else */
}/* strncmp: module name test */
else if (strncasecmp(modulename,"loop",4) == 0 ) {
int lc;
int f = fcntl(telnetparams.new_socket,F_GETFL);
fcntl (telnetparams.new_socket, F_SETFL, O_NONBLOCK | f);
for(lc=0; lc<telnetparams.loopcount; lc++) {
for(int lc=0; lc<telnetparams.loopcount; lc++) {
char dummybuff[20];
char tbuff[64];
int rs;
......
......@@ -69,7 +69,8 @@ typedef struct cmddef {
#define TELNET_VARTYPE_INT64 3
#define TELNET_VARTYPE_STRING 4
#define TELNET_VARTYPE_DOUBLE 5
//#define TELNET_VARTYPE_PTR 6
#define TELNET_VARTYPE_INT8 6
#define TELNET_VARTYPE_UINT 7
typedef struct variabledef {
char varname[TELNET_CMD_MAXSIZE];
char vartype;
......
......@@ -9,6 +9,7 @@ set(TELNETSRV_SOURCE
${TELNETROOT}/telnetsrv_phycmd.c
${TELNETROOT}/telnetsrv_proccmd.c
${TELNETROOT}/telnetsrv_loader.c
${TELNETROOT}/telnetsrv_measurements.c
)
#set(TELNETSRV_ETHDEVCMD_SOURCE
......
/*
* 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.c
* \brief: implementation of 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
*/
#define _GNU_SOURCE
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#define TELNETSERVERCODE
#include "telnetsrv.h"
#define TELNETSRV_MEASURMENTS_MAIN
#include "common/utils/LOG/log.h"
#include "common/config/config_userapi.h"
#include "telnetsrv_measurments.h"
#include "openair2/LAYER2/MAC/mac.h"
#include "openair1/PHY/phy_extern.h"
static telnet_measurgroupdef_t *measurgroups[TELNET_MAXMEASURGROUPS];
static int telnet_num_measurgroups=0;
static int eNB_id =0;
static char *grouptypes[] = {"ltemac","cpustats"};
#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);
} /* measurcmd_display_groups */
uint64_t measurcmd_getstatvalue(telnet_ltemeasurdef_t *measur,telnet_printfunc_t prnt) {
uint64_t val;
switch(measur->vtyp) {
case TELNET_VARTYPE_INT64:
val = (uint64_t)(*((uint64_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_INT32:
val = (uint64_t)(*((uint32_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_INT16:
val = (uint64_t)(*((uint16_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_INT8:
val = (uint64_t)(*((uint8_t *)(measur->vptr)));
break;
case TELNET_VARTYPE_UINT:
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;
}
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":" ");
}
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 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);
eNB_UE_STATS *macstatptr = &(UE_list->eNB_UE_stats[CC_id][UE_id]);
telnet_ltemeasurdef_t statsptr[]=LTEMAC_UEMEASURE;
measurcmd_display_measures(prnt, statsptr, sizeof(statsptr)/sizeof(telnet_ltemeasurdef_t));
}
}
} /* 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;
prnt("%s eNB %i mac stats CC %i frame %u %s\n",
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)
{
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 */
void measurcmd_display_rlcstats(telnet_printfunc_t prnt) {
protocol_ctxt_t ctxt;
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));
eNB_MAC_INST *eNB = RC.mac[eNB_id];
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);
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;
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 if ( strcmp(subcmd,"lte") == 0) {
measurcmd_display_macstats(prnt);
measurcmd_display_macstats_ue(prnt);
measurcmd_display_rlcstats(prnt);
}
else
prnt("%s: Unknown command\n",buf);
free(subcmd);
}
return 0;
}
/*-------------------------------------------------------------------------------------*/
void add_measur_cmds(void)
{
add_telnetcmd("measur",measur_vardef,measur_cmdarray);
}
/*
* 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_LTEMACSTATS 0
#define GROUP_CPUSTATS 1
typedef struct mesurgroupdef {
char groupname[TELNET_MAXMEASURNAME_LEN];
unsigned char type;
unsigned char size;
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", &(macstatptr->dlsch_mcs1),TELNET_VARTYPE_INT8,0},\
{"dlsch_mcs2", &(macstatptr->dlsch_mcs2),TELNET_VARTYPE_INT8,0},\
{"rbs_used", &(macstatptr->rbs_used),TELNET_VARTYPE_INT32,0},\
{"rbs_used_retx", &(macstatptr->rbs_used_retx),TELNET_VARTYPE_INT16,0},\
{"total_rbs_used", &(macstatptr->total_rbs_used),TELNET_VARTYPE_INT16,0},\
{"ncce_used", &(macstatptr->ncce_used),TELNET_VARTYPE_INT16,0},\
{"ncce_used_retx", &(macstatptr->ncce_used_retx),TELNET_VARTYPE_INT16,0},\
{"TBS", &(macstatptr->TBS),TELNET_VARTYPE_INT32,0},\
{"total_pdu_bytes", &(macstatptr->total_pdu_bytes),TELNET_VARTYPE_INT64,0},\
{"total_num_pdus", &(macstatptr->total_num_pdus),TELNET_VARTYPE_INT32,0},\
{"overhead_bytes", &(macstatptr->overhead_bytes),TELNET_VARTYPE_INT64,0},\
{"crnti", &(macstatptr->crnti),TELNET_VARTYPE_INT16,0},\
{"normalized_rx_power", &(macstatptr->normalized_rx_power),TELNET_VARTYPE_INT32,0},\
{"target_rx_power", &(macstatptr->target_rx_power),TELNET_VARTYPE_INT32,0},\
{"ulsch_mcs1", &(macstatptr->ulsch_mcs1),TELNET_VARTYPE_INT8,0},\
{"ulsch_mcs2", &(macstatptr->ulsch_mcs2),TELNET_VARTYPE_INT8,0},\
{"rbs_used_rx", &(macstatptr->rbs_used_rx),TELNET_VARTYPE_INT32,0},\
{"rbs_used_retx_rx", &(macstatptr->rbs_used_retx_rx),TELNET_VARTYPE_INT32,0},\
{"total_rbs_used_rx", &(macstatptr->total_rbs_used_rx),TELNET_VARTYPE_INT32,0},\
{"ulsch_TBS", &(macstatptr->ulsch_TBS),TELNET_VARTYPE_INT32,0},\
{"total_pdu_bytes_rx", &(macstatptr->total_pdu_bytes_rx),TELNET_VARTYPE_INT64,0},\
{"total_num_pdus_rx", &(macstatptr->total_num_pdus_rx),TELNET_VARTYPE_INT32,0},\
{"num_errors_rx", &(macstatptr->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 */
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