Commit 3c39f09d authored by francescomani's avatar francescomani

Merge remote-tracking branch 'origin/develop' into NR_MCS_BLER

parents b1e14c2c c1ae0962
......@@ -15,7 +15,7 @@ channelmod = {
ds_tdl = 0;
},
{
model_name = "rfsimu_channel_ue1"
model_name = "rfsimu_channel_ue0"
type = "AWGN";
ploss_dB = 0;
noise_power_dB = 0;
......
This diff is collapsed.
......@@ -6,7 +6,7 @@ eNBs =
(
{
////////// Identification parameters:
eNB_ID = 0xe00;
eNB_ID = 0xe05;
cell_type = "CELL_MACRO_ENB";
......
......@@ -251,6 +251,7 @@ RUs = (
eNB_instances = [0];
bf_weights = [0x00007fff, 0x00007fff];
#clock_src = "external";
sf_extension = 0
sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
}
);
......
......@@ -253,8 +253,8 @@ MACRLCs = (
num_cc = 1;
tr_s_preference = "local_L1";
tr_n_preference = "local_RRC";
pusch_TargetSNRx10 = 200;
pucch_TargetSNRx10 = 150;
# pusch_TargetSNRx10 = 200;
# pucch_TargetSNRx10 = 150;
ulsch_max_slots_inactivity=20;
}
);
......@@ -265,7 +265,7 @@ L1s = (
tr_n_preference = "local_mac";
pusch_proc_threads = 2;
prach_dtx_threshold = 120;
pucch0_dtx_threshold = 150;
# pucch0_dtx_threshold = 150;
}
);
......@@ -288,7 +288,7 @@ RUs = (
# bf_weights = [0x00007fff, 0x00000000, 0x00000000, 0x00007fff];
## beamforming 4x4 matrix:
#bf_weights = [0x00007fff, 0x0000, 0x0000, 0x0000, 0x00000000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff, 0x0000, 0x0000, 0x0000, 0x0000, 0x00007fff];
sf_extension = 0
sdr_addrs = "mgmt_addr=192.168.18.240,addr=192.168.10.2,second_addr=192.168.20.2,clock_source=internal,time_source=internal"
}
);
......
......@@ -219,7 +219,7 @@ gNBs =
GNB_IPV4_ADDRESS_FOR_NG_AMF = "CI_GNB_IP_ADDR";
GNB_INTERFACE_NAME_FOR_NGU = "eth0";
GNB_IPV4_ADDRESS_FOR_NGU = "CI_GNB_IP_ADDR";
GNB_PORT_FOR_S1U = 2152; # Spec 2152
GNB_PORT_FOR_NGU = 2152; # Spec 2152
};
}
......
......@@ -59,7 +59,7 @@
<testCase id="030000">
<class>Initialize_eNB</class>
<desc>Initialize eNB</desc>
<Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.nsa_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args>
<Initialize_eNB_args>-O ci-scripts/conf_files/enb.band38.lte_2x2.100PRB.usrpn310.conf --usrp-tx-thread-config 1 --thread-pool 0,2,4,6</Initialize_eNB_args>
<eNB_instance>0</eNB_instance>
<eNB_serverId>0</eNB_serverId>
<air_interface>lte</air_interface>
......
......@@ -34,6 +34,8 @@
#include "assertions.h"
#include "nr_common.h"
const char *duplex_mode[]={"FDD","TDD"};
// Table 5.2-1 NR operating bands in FR1 & FR2 (3GPP TS 38.101)
// Table 5.4.2.3-1 Applicable NR-ARFCN per operating band in FR1 & FR2 (3GPP TS 38.101)
// Notes:
......@@ -249,6 +251,176 @@ int get_dmrs_port(int nl, uint16_t dmrs_ports) {
return p;
}
int get_num_dmrs(uint16_t dmrs_mask ) {
int num_dmrs=0;
for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1);
return(num_dmrs);
}
lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index)
{
lte_frame_type_t current_type;
int32_t delta_duplex = get_delta_duplex(current_band, scs_index);
if (delta_duplex == 0)
current_type = TDD;
else
current_type = FDD;
LOG_I(NR_MAC, "NR band %d, duplex mode %s, duplex spacing = %d KHz\n", current_band, duplex_mode[current_type], delta_duplex);
return current_type;
}
// Computes the duplex spacing (either positive or negative) in KHz
int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index)
{
int nr_table_idx = get_nr_table_idx(nr_bandP, scs_index);
int32_t delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min);
LOG_I(NR_MAC, "NR band duplex spacing is %d KHz (nr_bandtable[%d].band = %d)\n", delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band);
return delta_duplex;
}
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band)
{
if (nr_band < 100) { //FR1
switch(mu) {
case 0 :
if (nb_rb<=25)
return 5;
if (nb_rb<=52)
return 10;
if (nb_rb<=79)
return 15;
if (nb_rb<=106)
return 20;
if (nb_rb<=133)
return 25;
if (nb_rb<=160)
return 30;
if (nb_rb<=216)
return 40;
if (nb_rb<=270)
return 50;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
case 1 :
if (nb_rb<=11)
return 5;
if (nb_rb<=24)
return 10;
if (nb_rb<=38)
return 15;
if (nb_rb<=51)
return 20;
if (nb_rb<=65)
return 25;
if (nb_rb<=78)
return 30;
if (nb_rb<=106)
return 40;
if (nb_rb<=133)
return 50;
if (nb_rb<=162)
return 60;
if (nb_rb<=189)
return 70;
if (nb_rb<=217)
return 80;
if (nb_rb<=245)
return 90;
if (nb_rb<=273)
return 100;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
case 2 :
if (nb_rb<=11)
return 10;
if (nb_rb<=18)
return 15;
if (nb_rb<=24)
return 20;
if (nb_rb<=31)
return 25;
if (nb_rb<=38)
return 30;
if (nb_rb<=51)
return 40;
if (nb_rb<=65)
return 50;
if (nb_rb<=79)
return 60;
if (nb_rb<=93)
return 70;
if (nb_rb<=107)
return 80;
if (nb_rb<=121)
return 90;
if (nb_rb<=135)
return 100;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
default:
AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band);
}
}
else {
switch(mu) {
case 2 :
if (nb_rb<=66)
return 50;
if (nb_rb<=132)
return 100;
if (nb_rb<=264)
return 200;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
case 3 :
if (nb_rb<=32)
return 50;
if (nb_rb<=66)
return 100;
if (nb_rb<=132)
return 200;
if (nb_rb<=264)
return 400;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
default:
AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band);
}
}
}
// Returns the corresponding row index of the NR table
int get_nr_table_idx(int nr_bandP, uint8_t scs_index) {
int i, j;
int scs_khz = 15 << scs_index;
int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95};
size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]);
for(j = 0; j < s; j++){
if (nr_bandP == supplementary_bands[j])
AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]);
}
AssertFatal(nr_bandP <= nr_bandtable[nr_bandtable_size-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[nr_bandtable_size-1].band);
for (i = 0; i < nr_bandtable_size && nr_bandtable[i].band != nr_bandP; i++);
// selection of correct Deltaf raster according to SCS
if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz))
i++;
LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min);
return i;
}
int get_subband_size(int NPRB,int size) {
// implements table 5.2.1.4-2 from 36.214
......
......@@ -35,6 +35,7 @@
#include <stdint.h>
#include "assertions.h"
#include "PHY/defs_common.h"
typedef struct nr_bandentry_s {
int16_t band;
......@@ -50,6 +51,11 @@ typedef struct nr_bandentry_s {
extern const size_t nr_bandtable_size;
extern nr_bandentry_t nr_bandtable[];
int get_num_dmrs(uint16_t dmrs_mask);
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);
int get_nr_table_idx(int nr_bandP, uint8_t scs_index);
int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index);
lte_frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index);
uint16_t get_band(uint64_t downlink_frequency, int32_t delta_duplex);
int NRRIV2BW(int locationAndBandwidth,int N_RB);
int NRRIV2PRBOFFSET(int locationAndBandwidth,int N_RB);
......
This diff is collapsed.
......@@ -108,6 +108,7 @@ typedef struct cmdparser {
/* global variables used by the telnet server */
typedef struct {
pthread_t telnet_pthread; // thread id of the telnet server
pthread_t telnetclt_pthread; // thread id of the telnet client (used when listenstdin set to true)
int telnetdbg; // debug level of the server
int priority; // server running priority
char *histfile; // command history
......@@ -119,6 +120,7 @@ typedef struct {
char msgbuff[TELNET_MAX_MSGLENGTH]; // internal buffer of the client_printf function which is used to print to the client terminal */
unsigned int listenport; // ip port the telnet server is listening on
unsigned int listenaddr; // ip address the telnet server is listening on
unsigned int listenstdin; // enable command input from stdin
unsigned int loopcount; // loop command param: number of loop iteration
unsigned int loopdelay; // loop command param: delay in ms between 2 iterations
unsigned int phyprntbuff_size; // for phy module, dump_eNB_stats function buffer size
......
/*
* 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_nrue_measurements.c
* \brief: implementation of telnet commands related to nrUE measurments
* \author Francois TABURET
* \date 2021
* \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"
#include "common/utils/LOG/log.h"
#include "common/config/config_userapi.h"
#include "telnetsrv_measurements.h"
#include "telnetsrv_ltemeasur_def.h"
#include "telnetsrv_cpumeasur_def.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_defs.h"
#include "openair1/PHY/phy_extern_nr_ue.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 nrUEmeasurgroups[] = {
// {"ue", GROUP_LTESTATS,0, measurcmd_display_macstats, {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_NRUEMEASURGROUPS (sizeof(nrUEmeasurgroups)/sizeof(telnet_measurgroupdef_t))
static double cpufreq;
#define HDR "---------------------------------"
int get_measurgroups(telnet_measurgroupdef_t **measurgroups) {
*measurgroups = nrUEmeasurgroups;
return TELNET_NUM_NRUEMEASURGROUPS;
}
void measurcmd_display_phycpu(telnet_printfunc_t prnt) {
PHY_VARS_NR_UE *UE = PHY_vars_UE_g[0][0];
telnet_cpumeasurdef_t cpumeasur[]=CPU_PHYNRUE_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));
}
//----------------------------------------------------------------------------------------------------
void measurcmd_display_macstats_ue(telnet_printfunc_t prnt) {
UE_info_t *UE_info = &(RC.mac[eNB_id]->UE_info);
for (int UE_id=UE_info->list.head; UE_id>=0; UE_id=UE_info->list.next[UE_id]) {
for (int i=0; i<UE_info->numactiveCCs[UE_id]; i++) {
int CC_id = UE_info->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 *macuestatptr = &(UE_info->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_info_t *UE_info = &(RC.mac[eNB_id]->UE_info);
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_info->list.head; UE_id>=0; UE_id=UE_info->list.next[UE_id]) {
#define NB_eNB_INST 1
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt,eNB_id, ENB_FLAG_YES,UE_info->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
*/
......@@ -8,9 +8,9 @@ set(TELNETSRV_SOURCE
)
add_library(telnetsrv MODULE ${TELNETSRV_SOURCE} )
target_link_libraries(telnetsrv PRIVATE history)
target_link_libraries(telnetsrv PRIVATE history ncurses form )
foreach(TELNETLIB enb gnb 4gUE 5gUE)
foreach(TELNETLIB enb gnb 4Gue 5Gue)
set(TELNETLIB_SRCS "")
foreach(TELNETLIB_ASRC measurements phycmd)
set(TELNETLIB_SRC ${OPENAIR_DIR}/common/utils/telnetsrv/telnetsrv_${TELNETLIB}_${TELNETLIB_ASRC}.c)
......@@ -32,4 +32,4 @@ install(TARGETS telnetsrv DESTINATION bin)
if (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build")
install(TARGETS telnetsrv DESTINATION ${OPENAIR_BUILD_DIR}/ran_build/build)
endif (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build")
\ No newline at end of file
endif (EXISTS "${OPENAIR_BUILD_DIR}/ran_build/build" AND IS_DIRECTORY "${OPENAIR_BUILD_DIR}/ran_build/build")
......@@ -64,13 +64,30 @@ void measurcmd_display_groups(telnet_printfunc_t prnt,telnet_measurgroupdef_t *m
} /* 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":" | " );
}
static char *stridx(int max,int i, char *buff) {
if (max>1)
sprintf(buff,"[%d]",i);
else
sprintf(buff," ");
return buff;
}
void measurcmd_display_cpumeasures(telnet_printfunc_t prnt, telnet_cpumeasurdef_t *cpumeasure, int cpumeasure_size) {
int p=0;
char stridx1[16];
char stridx2[16];
for (int i=0; i<cpumeasure_size; i++)
for (int o1=0;o1<cpumeasure[i].num_occur1;o1++)
for (int o2=0;o2<=cpumeasure[i].num_occur2;o2++)
{
prnt("%02d %*s%s%s: %15.3f us; %15d %s",p,TELNET_MAXMEASURNAME_LEN+7,(cpumeasure+i)->statname,
stridx(cpumeasure[i].num_occur1,o1,stridx1),stridx(cpumeasure[i].num_occur2,o2,stridx2),
((cpumeasure+i+o1+o2)->astatptr->trials!=0)?(((cpumeasure+i+o1+o2)->astatptr->diff)/((cpumeasure+i+o1+o2)->astatptr->trials))/cpufreq/1000:0,
(cpumeasure+i+o1+o2)->astatptr->trials, ((p%2)==1)?"|\n":" | " );
p++;
}
prnt("\n\n");
} /* measurcmd_display_measures */
......@@ -137,11 +154,17 @@ int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt) {
}
telnet_measurgroupdef_t *measurgroups;
int num_measurgroups = fptr( &measurgroups);
int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
if (s>0) {
if ( strcmp(subcmd,"groups") == 0) {
if ( strcmp(subcmd,"inq") == 0) {
notifiedFIFO_elt_t *msg =newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
time_stats_msg_t *msgdata=NotifiedFifoData(msg);
msgdata->msgid = TIMESTAT_MSGID_DISPLAY;
msgdata->displayFunc = prnt;
pushNotifiedFIFO(&measur_fifo, msg);
} else if ( strcmp(subcmd,"groups") == 0){
measurcmd_display_groups(prnt,measurgroups,num_measurgroups);
badcmd=0;
} else {
......@@ -182,13 +205,13 @@ int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt) {
int badcmd=1;
if (debug > 0)
prnt(" measurcmd_show received %s\n",buf);
prnt(" measurcmd_cpustats 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);
......@@ -203,6 +226,64 @@ int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt) {
free(subcmd);
return CMDSTATUS_FOUND;
}
void measurcmd_async_help(telnet_printfunc_t prnt) {
}
int measurcmd_async(char *buf, int debug, telnet_printfunc_t prnt) {
char *subcmd=NULL;
int idx1, idx2;
int okcmd=0;
if (buf == NULL) {
measurcmd_async_help(prnt);
return CMDSTATUS_FOUND;
}
if (debug > 0)
prnt(" measurcmd_async received %s\n",buf);
int s = sscanf(buf,"%ms %i-%i\n",&subcmd, &idx1,&idx2);
if (s==1) {
if ( strcmp(subcmd,"enable") == 0) {
init_meas();
okcmd=1;
} else if ( strcmp(subcmd,"disable") == 0) {
end_meas();
okcmd=1;
}
} else if ( s == 3 ) {
int msgid;
if ( strcmp(subcmd,"enable") == 0) {
msgid = TIMESTAT_MSGID_ENABLE;
okcmd=1;
} else if ( strcmp(subcmd,"disable") == 0) {
msgid = TIMESTAT_MSGID_DISABLE;
okcmd=1;
} else if ( strcmp(subcmd,"display") == 0) {
msgid = TIMESTAT_MSGID_DISPLAY;
okcmd=1;
}
if (okcmd) {
notifiedFIFO_elt_t *nfe = newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
time_stats_msg_t *msg = (time_stats_msg_t *)NotifiedFifoData(nfe);
msg->msgid = msgid ;
msg->displayFunc = prnt;
for(int i=idx1; i<idx2; i++) {
msg->timestat_id =i;
pushNotifiedFIFO(&measur_fifo, nfe);
}
}
}
if (!(okcmd)) {
prnt("Unknown command: %s\n",buf);
}
free(subcmd);
return CMDSTATUS_FOUND;
}
/*-------------------------------------------------------------------------------------*/
/* function called at telnet server init to add the measur command */
......
......@@ -49,6 +49,9 @@ typedef struct cpumeasurdef {
char statname[TELNET_MAXMEASURNAME_LEN];
time_stats_t *astatptr;
unsigned int statemask;
uint8_t num_occur1;
uint8_t num_occur2;
uint8_t num_occur3;
} telnet_cpumeasurdef_t;
typedef struct ltemeasurdef {
......@@ -60,6 +63,7 @@ typedef struct ltemeasurdef {
#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];
......@@ -79,9 +83,11 @@ typedef struct mesurgroupdef {
#ifdef TELNETSRV_MEASURMENTS_MAIN
int measurcmd_show(char *buf, int debug, telnet_printfunc_t prnt);
int measurcmd_cpustats(char *buf, int debug, telnet_printfunc_t prnt);
int measurcmd_async(char *buf, int debug, telnet_printfunc_t prnt);
telnetshell_cmddef_t measur_cmdarray[] = {
{"show", "groups | <group name>" , measurcmd_show},
{"show", "groups | <group name> | inq" , measurcmd_show},
{"cpustats","[enable | disable]",measurcmd_cpustats},
{"async","[enable | disable]",measurcmd_async},
{"","",NULL}
};
......
......@@ -33,6 +33,7 @@
#include "common/utils/assertions.h"
#include "common/utils/system.h"
#include "common/ran_context.h"
#include "../../ARCH/COMMON/common_lib.h"
#include "../../ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
......@@ -47,8 +48,6 @@
#include "PHY/INIT/phy_init.h"
#include "SCHED_NR/sched_nr.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
......
......@@ -21,6 +21,7 @@
#include "executables/nr-softmodem-common.h"
#include "common/utils/nr/nr_common.h"
#include "common/ran_context.h"
#include "PHY/defs_gNB.h"
#include "PHY/phy_extern.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
......@@ -35,7 +36,6 @@
#include "MBSFN-SubframeConfigList.h"*/
#include "openair1/PHY/defs_RU.h"
#include "openair1/PHY/CODING/nrLDPC_extern.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "assertions.h"
#include <math.h>
......
......@@ -22,7 +22,6 @@
#include "phy_init.h"
#include "common/utils/nr/nr_common.h"
#include "common/utils/LOG/log.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
/// Subcarrier spacings in Hz indexed by numerology index
uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, 120e3, 240e3};
......
......@@ -129,18 +129,14 @@ int nr_slot_fep(PHY_VARS_NR_UE *ue,
rxdata_ptr = (int16_t *)tmp_dft_in;
}
#if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats);
#endif
dft(dftsize,
rxdata_ptr,
(int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],
1);
#if UE_TIMING_TRACE
stop_meas(&ue->rx_dft_stats);
#endif
int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot;
int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[0])[symbol+symb_offset];
......@@ -249,18 +245,14 @@ int nr_slot_fep_init_sync(PHY_VARS_NR_UE *ue,
}
#if UE_TIMING_TRACE
start_meas(&ue->rx_dft_stats);
#endif
dft(dftsize,
rxdata_ptr,
(int16_t *)&common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[aa][frame_parms->ofdm_symbol_size*symbol],
1);
#if UE_TIMING_TRACE
stop_meas(&ue->rx_dft_stats);
#endif
int symb_offset = (Ns%frame_parms->slots_per_subframe)*frame_parms->symbols_per_slot;
int32_t rot2 = ((uint32_t*)frame_parms->symbol_rotation[0])[symbol + symb_offset];
......
......@@ -37,7 +37,7 @@
#include "PHY/NR_REFSIG/dmrs_nr.h"
#include "PHY/NR_REFSIG/ptrs_nr.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "common/utils/nr/nr_common.h"
//#define DEBUG_DLSCH
//#define DEBUG_DLSCH_MAPPING
......
......@@ -39,10 +39,10 @@
#include "PHY/NR_TRANSPORT/nr_transport_proto.h"
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
#include "PHY/NR_TRANSPORT/nr_dlsch.h"
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
#include "SCHED_NR/sched_nr.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "common/utils/LOG/log.h"
#include "common/utils/nr/nr_common.h"
#include <syscall.h>
#include <openair2/UTIL/OPT/opt.h>
......
......@@ -37,7 +37,6 @@
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h"
#include "T.h"
......
......@@ -35,7 +35,6 @@
#include "PHY/defs_nr_common.h"
#include "PHY/defs_gNB.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#define NR_PBCH_PDU_BITS 24
......@@ -315,6 +314,7 @@ int nr_find_pucch(uint16_t rnti,
void init_prach_list(PHY_VARS_gNB *gNB);
void init_prach_ru_list(RU_t *ru);
void free_nr_ru_prach_entry(RU_t *ru, int prach_id);
uint8_t get_nr_prach_duration(uint8_t prach_format);
void nr_generate_csi_rs(PHY_VARS_gNB *gNB,
int16_t amp,
......
......@@ -36,7 +36,6 @@
#include "PHY/phy_extern_nr_ue.h"
#include "common/utils/LOG/log.h"
#include "PHY/sse_intrin.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
//#define k1 1000
#define k1 ((long long int) 1000)
......
......@@ -36,10 +36,8 @@
#include <string.h>
#endif
#include <LAYER2/NR_MAC_UE/mac_defs.h>
#include <LAYER2/NR_MAC_UE/mac_proto.h>
#include "executables/softmodem-common.h"
#include "executables/softmodem-common.h"
#include "nr_transport_proto_ue.h"
#include "PHY/CODING/nrPolar_tools/nr_polar_dci_defs.h"
#include "PHY/phy_extern_nr_ue.h"
......
......@@ -45,11 +45,6 @@
//#define DEBUG_HARQ
//#include "LAYER2/MAC/extern.h"
//#include "LAYER2/MAC/defs.h"
//#include "../openair2/LAYER2/MAC/extern.h"
//#include "../openair2/LAYER2/MAC/defs.h"
//#define DEBUG_DCI
#define NR_PDCCH_DCI_TOOLS
//#define NR_PDCCH_DCI_TOOLS_DEBUG
......
......@@ -41,6 +41,7 @@
#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h"
#include "PHY/NR_REFSIG/nr_refsig.h"
#include "PHY/NR_REFSIG/dmrs_nr.h"
#include "common/utils/nr/nr_common.h"
#ifndef USER_MODE
#define NOCYGWIN_STATIC static
......@@ -163,9 +164,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
// int avg_0[2];
// int avg_1[2];
#if UE_TIMING_TRACE
uint8_t slot = 0;
#endif
unsigned char aatx=0,aarx=0;
......@@ -331,12 +330,10 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
DevAssert(dlsch1_harq);
}
#if UE_TIMING_TRACE
if(symbol > ue->frame_parms.symbols_per_slot>>1)
{
slot = 1;
}
#endif
#ifdef DEBUG_HARQ
printf("Demod dlsch0_harq->pmi_alloc %d\n", dlsch0_harq->pmi_alloc);
......@@ -346,9 +343,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
uint8_t config_type = dlsch0_harq->dmrsConfigType;
if (beamforming_mode==0) {//No beamforming
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#endif
if (dlsch0_harq->Nl > 1)//More than or equal 2 layers
nb_rb = nr_dlsch_extract_rbs_multiple(common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF,
pdsch_vars[gNB_id]->dl_ch_estimates,
......@@ -389,7 +384,6 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
len = (pilots==1)? ((config_type==NFAPI_NR_DMRS_TYPE1)?nb_rb*(12-6*dlsch0_harq->n_dmrs_cdm_groups): nb_rb*(12-4*dlsch0_harq->n_dmrs_cdm_groups)):(nb_rb*12);
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n",
......@@ -398,11 +392,8 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d type %d: Pilot/Data extraction %5.2f \n",
frame,nr_slot_rx,slot,symbol,type,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#endif
#endif
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#endif
n_tx = dlsch0_harq->Nl;
n_rx = frame_parms->nb_antennas_rx;
......@@ -416,18 +407,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
len,
nb_rb_pdsch);
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Scale %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#endif
#endif
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#endif
if (first_symbol_flag==1) {
if (beamforming_mode==0){
nr_dlsch_channel_level(pdsch_vars[gNB_id]->dl_ch_estimates_ext,
......@@ -482,19 +468,14 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
}
#endif
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d first_symbol_flag %d: Channel Level %5.2f \n",frame,nr_slot_rx,slot,symbol,first_symbol_flag,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#endif
#endif
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#endif
// Now channel compensation
if (dlsch0_harq->mimo_mode<NR_DUALSTREAM) {
nr_dlsch_channel_compensation(pdsch_vars[gNB_id]->rxdataF_ext,
......@@ -539,18 +520,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
0);
}
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d log2_maxh %d channel_level %d: Channel Comp %5.2f \n", frame, nr_slot_rx, slot, symbol, pdsch_vars[gNB_id]->log2_maxh, proc->channel_level, ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#endif
#endif
// MRC
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#endif
if (frame_parms->nb_antennas_rx > 1) {
if (dlsch0_harq->mimo_mode<NR_DUALSTREAM) {
......@@ -603,19 +579,13 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
//i_mod should have been passed as a parameter
}
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: Channel Combine %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#endif
#endif
#if UE_TIMING_TRACE
start_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#endif
/* Store the valid DL RE's */
pdsch_vars[gNB_id]->dl_valid_re[symbol-1] = len;
......@@ -692,14 +662,12 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
}
#if UE_TIMING_TRACE
stop_meas(&ue->generic_stat_bis[proc->thread_id][slot]);
#if DISABLE_LOG_X
printf("[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#else
LOG_I(PHY, "[AbsSFN %u.%d] Slot%d Symbol %d: LLR Computation %5.2f \n",frame,nr_slot_rx,slot,symbol,ue->generic_stat_bis[proc->thread_id][slot].p_time/(cpuf*1000.0));
#endif
#endif
// Please keep it: useful for debugging
#ifdef DEBUG_PDSCH_RX
......
......@@ -126,15 +126,11 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
// initialization of structure
current_ssb = create_ssb_node(l,hf);
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats);
#endif
// computing correlation between received DMRS symbols and transmitted sequence for current i_ssb and n_hf
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_dmrs_correlation(ue,proc,0,0,i,i-pbch_initial_symbol,current_ssb);
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
current_ssb->metric = current_ssb->c_re*current_ssb->c_re + current_ssb->c_im*current_ssb->c_im;
......@@ -150,15 +146,11 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
NR_UE_SSB *temp_ptr=best_ssb;
while (ret!=0 && temp_ptr != NULL) {
#if UE_TIMING_TRACE
start_meas(&ue->dlsch_channel_estimation_stats);
#endif
// computing channel estimation for selected best ssb
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_channel_estimation(ue,proc,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf);
#if UE_TIMING_TRACE
stop_meas(&ue->dlsch_channel_estimation_stats);
#endif
ret = nr_rx_pbch(ue,
proc,
......
......@@ -39,7 +39,6 @@
#include "PHY/CODING/nrLDPC_extern.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include <openair2/UTIL/OPT/opt.h>
//#define DEBUG_ULSCH_CODING
......
......@@ -44,8 +44,6 @@
#include "PHY/TOOLS/tools_defs.h"
#include "executables/nr-softmodem.h"
#include "executables/softmodem-common.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h"
#include "PHY/NR_REFSIG/ul_ref_seq_nr.h"
//#define DEBUG_PUSCH_MAPPING
......@@ -143,7 +141,12 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
ulsch_ue->Nid_cell = Nid_cell;
get_num_re_dmrs(pusch_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols);
for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) {
if((ul_dmrs_symb_pos >> i) & 0x01)
number_dmrs_symbols += 1;
}
nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data;
LOG_D(PHY,"ulsch %x : start_rb %d bwp_start %d start_sc %d start_symbol %d num_symbols %d cdmgrpsnodata %d num_dmrs %d dmrs_re_per_rb %d\n",
rnti,start_rb,pusch_pdu->bwp_start,start_sc,start_symbol,number_of_symbols,cdm_grps_no_data,number_dmrs_symbols,nb_dmrs_re_per_rb);
......
......@@ -34,7 +34,6 @@
#include "PHY/defs_nr_common.h"
#include "PHY/defs_nr_UE.h"
//#include "PHY/extern.h"
//#include "LAYER2/MAC/extern.h"
#include "PHY/NR_UE_TRANSPORT/pucch_nr.h"
#include "PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h"
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
......
......@@ -37,7 +37,6 @@
#include "PHY/defs_nr_common.h"
#include "PHY/defs_nr_UE.h"
//#include "PHY/extern.h"
//#include "LAYER2/MAC/extern.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
......
......@@ -18,17 +18,27 @@
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
#define _GNU_SOURCE
#include <stdio.h>
#include "time_meas.h"
#include <math.h>
#include <unistd.h>
#include <string.h>
#include "assertions.h"
#ifndef PHYSIM
#include <pthread.h>
#include "common/config/config_userapi.h"
#endif
// global var for openair performance profiler
int opp_enabled = 0;
double cpu_freq_GHz __attribute__ ((aligned(32)));
double cpu_freq_GHz __attribute__ ((aligned(32)))=0.0;
#ifndef PHYSIM
static uint32_t max_cpumeasur;
static time_stats_t **measur_table;
notifiedFIFO_t measur_fifo;
#endif
double get_cpu_freq_GHz(void)
{
if (cpu_freq_GHz <1 ) {
......@@ -133,3 +143,112 @@ double get_time_meas_us(time_stats_t *ts)
return 0;
}
#ifndef PHYSIM
/* function for the asynchronous measurment module: cpu stat are sent to a dedicated thread
* which is in charge of computing the cpu time spent in a given function/algorithm...
*/
time_stats_t *register_meas(char *name)
{
for (int i=0; i<max_cpumeasur; i++) {
if (measur_table[i] == NULL) {
measur_table[i] = (time_stats_t *)malloc(sizeof(time_stats_t));
memset(measur_table[i] ,0,sizeof(time_stats_t));
measur_table[i]->meas_name = strdup(name);
measur_table[i]->meas_index = i;
measur_table[i]->tpoolmsg =newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
measur_table[i]->tstatptr = (time_stats_msg_t *)NotifiedFifoData(measur_table[i]->tpoolmsg);
return measur_table[i];
}
}
return NULL;
}
void free_measurtbl(void) {
for (int i=0; i<max_cpumeasur; i++) {
if (measur_table[i] != NULL) {
free(measur_table[i]->meas_name);
delNotifiedFIFO_elt(measur_table[i]->tpoolmsg);
free(measur_table[i]);
}
}
//free the fifo...
}
void run_cpumeasur(void) {
struct sched_param schedp;
pthread_setname_np(pthread_self(), "measur");
schedp.sched_priority=0;
int rt=pthread_setschedparam(pthread_self(), SCHED_IDLE, &schedp);
AssertFatal(rt==0, "couldn't set measur thread priority: %s\n",strerror(errno));
initNotifiedFIFO(&measur_fifo);
while(1) {
notifiedFIFO_elt_t *msg = pullNotifiedFIFO(&measur_fifo);
time_stats_msg_t *tsm = (time_stats_msg_t *)NotifiedFifoData(msg);
switch(tsm->msgid) {
case TIMESTAT_MSGID_START:
measur_table[tsm->timestat_id]->in=tsm->ts;
(measur_table[tsm->timestat_id]->trials)++;
break;
case TIMESTAT_MSGID_STOP:
/// process duration is the difference between two clock points
measur_table[tsm->timestat_id]->p_time = (tsm->ts - measur_table[tsm->timestat_id]->in);
measur_table[tsm->timestat_id]->diff += measur_table[tsm->timestat_id]->p_time;
if ( measur_table[tsm->timestat_id]->p_time > measur_table[tsm->timestat_id]->max )
measur_table[tsm->timestat_id]->max = measur_table[tsm->timestat_id]->p_time;
break;
case TIMESTAT_MSGID_DISPLAY:
{
char aline[256];
int start, stop;
if (tsm->displayFunc != NULL) {
if(tsm->timestat_id >= 0) {
start=tsm->timestat_id ;
stop=start+1;
}
else {
start=0;
stop=max_cpumeasur ;
}
for (int i=start ; i<stop ; i++) {
if (measur_table[i] != NULL) {
sprintf(aline,"%s: %15.3f us ",measur_table[i]->meas_name, measur_table[i]->trials==0?0:( (measur_table[i]->trials/measur_table[i]->diff )/ cpu_freq_GHz /1000 ));
tsm->displayFunc(aline);
}
}
}
}
break;
case TIMESTAT_MSGID_END:
free_measurtbl();
delNotifiedFIFO_elt(msg);
pthread_exit(NULL);
break;
default:
break;
}
delNotifiedFIFO_elt(msg);
}
}
void init_meas(void) {
pthread_t thid;
paramdef_t cpumeasur_params[] = CPUMEASUR_PARAMS_DESC;
int numparams=sizeof(cpumeasur_params)/sizeof(paramdef_t);
int rt = config_get( cpumeasur_params,numparams,CPUMEASUR_SECTION);
AssertFatal(rt >= 0, "cpumeasur configuration couldn't be performed");
measur_table=calloc(max_cpumeasur,sizeof( time_stats_t *));
AssertFatal(measur_table!=NULL, "couldn't allocate %u cpu measurements entries\n",max_cpumeasur);
rt=pthread_create(&thid,NULL, (void *(*)(void *))run_cpumeasur, NULL);
AssertFatal(rt==0, "couldn't create cpu measurment thread: %s\n",strerror(errno));
}
void end_meas(void) {
notifiedFIFO_elt_t *nfe = newNotifiedFIFO_elt(sizeof(time_stats_msg_t),0,NULL,NULL);
time_stats_msg_t *msg = (time_stats_msg_t *)NotifiedFifoData(nfe);
msg->msgid = TIMESTAT_MSGID_END ;
pushNotifiedFIFO(&measur_fifo, nfe);
}
#endif
......@@ -31,30 +31,56 @@
#include <pthread.h>
#include <linux/kernel.h>
#include <linux/types.h>
#ifndef PHYSIM
#include "common/utils/threadPool/thread-pool.h"
#endif
// global var to enable openair performance profiler
extern int opp_enabled;
extern double cpu_freq_GHz __attribute__ ((aligned(32)));;
// structure to store data to compute cpu measurment
#if defined(__x86_64__) || defined(__i386__)
typedef struct {
long long in;
long long diff;
long long p_time; /*!< \brief absolute process duration */
long long diff_square; /*!< \brief process duration square */
long long max;
int trials;
int meas_flag;
} time_stats_t;
#define OAI_CPUTIME_TYPE long long
#elif defined(__arm__)
#define OAI_CPUTIME_TYPE uint32_t
#else
#error "building on unsupported CPU architecture"
#endif
#define TIMESTAT_MSGID_START 0 /*!< \brief send time at measure starting point */
#define TIMESTAT_MSGID_STOP 1 /*!< \brief send time at measure end point */
#define TIMESTAT_MSGID_ENABLE 2 /*!< \brief enable measure point */
#define TIMESTAT_MSGID_DISABLE 3 /*!< \brief disable measure point */
#define TIMESTAT_MSGID_DISPLAY 10 /*!< \brief display measure */
#define TIMESTAT_MSGID_END 11 /*!< \brief stops the measure threads and free assocated resources */
typedef void(*meas_printfunc_t)(const char* format, ...);
typedef struct {
uint32_t in;
uint32_t diff;
uint32_t p_time; /*!< \brief absolute process duration */
uint32_t diff_square; /*!< \brief process duration square */
uint32_t max;
int trials;
} time_stats_t;
int msgid; /*!< \brief message id, as defined by TIMESTAT_MSGID_X macros */
int timestat_id; /*!< \brief points to the time_stats_t entry in cpumeas table */
OAI_CPUTIME_TYPE ts; /*!< \brief time stamp */
meas_printfunc_t displayFunc; /*!< \brief function to call when DISPLAY message is received*/
} time_stats_msg_t;
typedef struct {
OAI_CPUTIME_TYPE in; /*!< \brief time at measure starting point */
OAI_CPUTIME_TYPE diff; /*!< \brief average difference between time at starting point and time at endpoint*/
OAI_CPUTIME_TYPE p_time; /*!< \brief absolute process duration */
OAI_CPUTIME_TYPE diff_square; /*!< \brief process duration square */
OAI_CPUTIME_TYPE max; /*!< \brief maximum difference between time at starting point and time at endpoint*/
int trials; /*!< \brief number of start point - end point iterations */
int meas_flag; /*!< \brief 1: stop_meas not called (consecutive calls of start_meas) */
char *meas_name; /*!< \brief name to use when printing the measure (not used for PHY simulators)*/
int meas_index; /*!< \brief index of this measure in the measure array (not used for PHY simulators)*/
int meas_enabled; /*!< \brief per measure enablement flag. send_meas tests this flag, unused today in start_meas and stop_meas*/
#ifndef PHYSIM
notifiedFIFO_elt_t *tpoolmsg; /*!< \brief message pushed to the cpu measurment queue to report a measure START or STOP */
time_stats_msg_t *tstatptr; /*!< \brief pointer to the time_stats_msg_t data in the tpoolmsg, stored here for perf considerations*/
#endif
} time_stats_t;
#define MEASURE_ENABLED(X) (X->meas_enabled)
static inline void start_meas(time_stats_t *ts) __attribute__((always_inline));
static inline void stop_meas(time_stats_t *ts) __attribute__((always_inline));
......@@ -137,4 +163,28 @@ static inline void copy_meas(time_stats_t *dst_ts,time_stats_t *src_ts) {
dst_ts->max=src_ts->max;
}
}
#ifndef PHYSIM
extern notifiedFIFO_t measur_fifo;
#define CPUMEASUR_SECTION "cpumeasur"
#define CPUMEASUR_PARAMS_DESC { \
{"max_cpumeasur", "Max number of cpu measur entries", 0, uptr:&max_cpumeasur, defintval:100, TYPE_UINT, 0},\
}
void init_meas(void);
time_stats_t *register_meas(char *name);
#define START_MEAS(X) send_meas(X, TIMESTAT_MSGID_START)
#define STOP_MEAS(X) send_meas(X, TIMESTAT_MSGID_STOP)
static inline void send_meas(time_stats_t *ts, int msgid) {
if (MEASURE_ENABLED(ts) ) {
ts->tstatptr->timestat_id=ts->meas_index;
ts->tstatptr->msgid = msgid ;
ts->tstatptr->ts = rdtsc_oai();
pushNotifiedFIFO(&measur_fifo, ts->tpoolmsg);
}
}
void end_meas(void);
#endif //ifndef PHYSIM
#endif
......@@ -30,6 +30,7 @@
* \warning
*/
#include "fapi_nr_l1.h"
#include "common/ran_context.h"
#include "PHY/NR_TRANSPORT/nr_transport_proto.h"
#include "PHY/NR_TRANSPORT/nr_dlsch.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
......@@ -146,7 +147,7 @@ void nr_schedule_response(NR_Sched_Rsp_t *Sched_INFO){
AssertFatal(RC.gNB!=NULL,"RC.gNB is null\n");
AssertFatal(RC.gNB[Mod_id]!=NULL,"RC.gNB[%d] is null\n",Mod_id);
gNB = RC.gNB[Mod_id];
gNB = RC.gNB[Mod_id];
notifiedFIFO_elt_t *res;
res = pullTpool(gNB->resp_L1_tx, gNB->threadPool);
......
......@@ -49,6 +49,59 @@
extern uint8_t nfapi_mode;
uint8_t get_nr_prach_duration(uint8_t prach_format){
switch(prach_format){
case 0: // format 0
return 0;
case 1: // format 1
return 0;
case 2: // format 2
return 0;
case 3: // format 3
return 0;
case 4: // format A1
return 2;
case 5: // format A2
return 4;
case 6: // format A3
return 6;
case 7: // format B1
return 2;
case 8: // format B4
return 12;
case 9: // format C0
return 2;
case 10: // format C2
return 6;
case 11: // format A1/B1
return 2;
case 12: // format A2/B2
return 4;
case 13: // format A3/B3
return 6;
default :
AssertFatal(1==0,"Invalid Prach format\n");
break;
}
}
void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot) {
uint16_t max_preamble[4]={0},max_preamble_energy[4]={0},max_preamble_delay[4]={0};
......
......@@ -340,8 +340,6 @@ uint16_t nr_get_n1_pucch(PHY_VARS_NR_UE *phy_vars_ue,
*/
UE_MODE_t get_nrUE_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t gNB_index);
uint8_t get_ra_PreambleIndex(uint8_t Mod_id, uint8_t CC_id, uint8_t gNB_id);
/*! \brief This function implements the power control mechanism for PUCCH from 36.213.
@param phy_vars_ue PHY variables
@param proc Pointer to proc descriptor
......
This diff is collapsed.
......@@ -38,7 +38,6 @@
#include "PHY/defs_nr_UE.h"
#include <openair1/SCHED/sched_common.h>
#include <openair1/PHY/NR_UE_TRANSPORT/pucch_nr.h>
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "openair1/PHY/NR_UE_ESTIMATION/nr_estimation.h"
#include <openair1/PHY/impl_defs_nr.h>
#include <common/utils/nr/nr_common.h>
......@@ -58,115 +57,6 @@
uint8_t nr_is_cqi_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id);
uint8_t nr_is_ri_TXOp(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t gNB_id);
/* TS 36.213 Table 9.2.5.2-1: Code rate corresponding to higher layer parameter PUCCH-F2-maximum-coderate, */
/* or PUCCH-F3-maximum-coderate, or PUCCH-F4-maximum-coderate */
/* add one additional element set to 0 for parsing the array until this end */
/* stored values are code rates * 100 */
//static const int code_rate_r_time_100[8] = { (0.08 * 100), (0.15 * 100), (0.25*100), (0.35*100), (0.45*100), (0.60*100), (0.80*100), 0 } ;
static float RSRP_meas_mapping_nr[98]
= {
-140,
-139,
-138,
-137,
-136,
-135,
-134,
-133,
-132,
-131,
-130,
-129,
-128,
-127,
-126,
-125,
-124,
-123,
-122,
-121,
-120,
-119,
-118,
-117,
-116,
-115,
-114,
-113,
-112,
-111,
-110,
-109,
-108,
-107,
-106,
-105,
-104,
-103,
-102,
-101,
-100,
-99,
-98,
-97,
-96,
-95,
-94,
-93,
-92,
-91,
-90,
-89,
-88,
-87,
-86,
-85,
-84,
-83,
-82,
-81,
-80,
-79,
-78,
-77,
-76,
-75,
-74,
-73,
-72,
-71,
-70,
-69,
-68,
-67,
-66,
-65,
-64,
-63,
-62,
-61,
-60,
-59,
-58,
-57,
-56,
-55,
-54,
-53,
-52,
-51,
-50,
-49,
-48,
-47,
-46,
-45,
-44,
-43
}
;
long
binary_search_float_nr(
float elements[],
......@@ -394,187 +284,10 @@ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue,
}
/*******************************************************************
*
* NAME : check_pucch_format
*
* PARAMETERS : ue context
* processing slots of reception/transmission
* gNB_id identifier
*
* RETURN : harq process identifier
*
* DESCRIPTION : return tx harq process identifier for given transmission slot
* YS 38.213 9.2.2 PUCCH Formats for UCI transmission
*
*********************************************************************/
boolean_t check_pucch_format(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx, int uci_size)
{
pucch_format_nr_t selected_pucch_format;
pucch_format_nr_t selected_pucch_format_second;
/*NR_SetupRelease_PUCCH_FormatConfig_t *identified_format = NULL;
switch (format_pucch) {
case pucch_format1_nr:
if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1 != NULL)
identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format1;
break;
case pucch_format2_nr:
if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format2 != NULL)
identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format2;
break;
case pucch_format3_nr:
if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3 != NULL)
identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format3;
break;
case pucch_format4_nr:
if (mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4 != NULL)
identified_format = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup->format4;
break;
default:
break;
}*/
/* if ((identified_format != NULL) && (identified_format->choice.setup->nrofSlots[0] != 1)) {
LOG_E(PHY,"PUCCH not implemented multislots transmission : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
return (FALSE);
}*/
if (nb_symbols_for_tx <= 2) {
if (uci_size <= 2) {
selected_pucch_format = pucch_format0_nr;
selected_pucch_format_second = selected_pucch_format;
}
else {
selected_pucch_format = pucch_format2_nr;
selected_pucch_format_second = selected_pucch_format;
}
}
else {
if (nb_symbols_for_tx >= 4) {
if (uci_size <= 2) {
selected_pucch_format = pucch_format1_nr;
selected_pucch_format_second = selected_pucch_format;
}
else {
selected_pucch_format = pucch_format3_nr; /* in this case choice can be done between two formats */
selected_pucch_format_second = pucch_format4_nr;
}
}
else {
LOG_D(PHY,"PUCCH Undefined PUCCH format : set PUCCH to format 4 : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
return (FALSE);
}
}
NR_TST_PHY_PRINTF("PUCCH format %d nb symbols total %d uci size %d selected format %d \n", format_pucch, nb_symbols_for_tx, uci_size, selected_pucch_format);
if (format_pucch != selected_pucch_format) {
if (format_pucch != selected_pucch_format_second) {
NR_TST_PHY_PRINTF("PUCCH mismatched of selected format: at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
LOG_D(PHY,"PUCCH format mismatched of selected format: at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
return (FALSE);
}
else {
return (TRUE);
}
}
else {
return (TRUE);
}
}
/*******************************************************************
*
* NAME : get_csi_nr
* PARAMETERS : ue context
* processing slots of reception/transmission
* gNB_id identifier
*
* RETURN : size of csi payload
*
* DESCRIPTION : CSI management is not already implemented
* so it has been simulated thank to two functions:
* - set_csi_nr
* - get_csi_nr
*
*********************************************************************/
int dummy_csi_status = 0;
uint32_t dummy_csi_payload = 0;
/* FFS TODO_NR code that should be developed */
uint16_t get_nr_csi_bitlen(NR_UE_MAC_INST_t *mac) {
uint16_t csi_bitlen =0;
uint16_t rsrp_bitlen = 0;
uint16_t diff_rsrp_bitlen = 0;
uint16_t nb_ssbri_cri = 0;
uint16_t cri_ssbri_bitlen = 0;
NR_CSI_MeasConfig_t *csi_MeasConfig = mac->cg->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup;
struct NR_CSI_ResourceConfig__csi_RS_ResourceSetList__nzp_CSI_RS_SSB * nzp_CSI_RS_SSB = csi_MeasConfig->csi_ResourceConfigToAddModList->list.array[0]->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB;
uint16_t nb_csi_ssb_report = nzp_CSI_RS_SSB->csi_SSB_ResourceSetList!=NULL ? nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list.count:0;
if (0 != nb_csi_ssb_report){
uint8_t nb_ssb_resources =0;
if (NULL != csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)
nb_ssbri_cri = *(csi_MeasConfig->csi_ReportConfigToAddModList->list.array[0]->groupBasedBeamReporting.choice.disabled->nrofReportedRS)+1;
else
nb_ssbri_cri = 1;
nb_ssb_resources = csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list.array[0]->csi_SSB_ResourceList.list.count;
if (nb_ssb_resources){
cri_ssbri_bitlen =ceil(log2 (nb_ssb_resources));
rsrp_bitlen = 7;
diff_rsrp_bitlen = 4;
}
else{
cri_ssbri_bitlen =0;
rsrp_bitlen = 0;
diff_rsrp_bitlen = 0;
}
csi_bitlen = ((cri_ssbri_bitlen * nb_ssbri_cri) + rsrp_bitlen +(diff_rsrp_bitlen *(nb_ssbri_cri -1 ))) *nb_csi_ssb_report;
//printf("get csi bitlen %d nb_ssbri_cri %d nb_csi_report %d nb_resources %d\n", csi_bitlen,nb_ssbri_cri ,nb_csi_ssb_report, nb_ssb_resources);
}
return csi_bitlen;
}
int get_csi_nr(NR_UE_MAC_INST_t *mac, PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload)
{
VOID_PARAMETER ue;
VOID_PARAMETER gNB_id;
float rsrp_db[7];
int nElem = 98;
int rsrp_offset = 17;
int csi_status = 0;
csi_status = get_nr_csi_bitlen(mac);
rsrp_db[0] = get_nr_RSRP(0,0,0);
if (csi_status == 0) {
*csi_payload = 0;
}
else {
*csi_payload = binary_search_float_nr(RSRP_meas_mapping_nr,nElem, rsrp_db[0]) + rsrp_offset;
}
return (csi_status);
}
/* FFS TODO_NR code that should be removed */
......
......@@ -41,8 +41,6 @@
/************** INCLUDE *******************************************/
#include "PHY/defs_nr_UE.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_defs.h"
#include "RRC/NR_UE/rrc_proto.h"
#ifdef DEFINE_VARIABLES_PUCCH_UE_NR_H
......@@ -65,31 +63,6 @@ void pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue,
uint8_t gNB_id,
UE_nr_rxtx_proc_t *proc);
/** \brief This function check pucch format
@param ue context
@param gNB_id identity
@param format_pucch pucch format
@param nb_symbols_for_tx number of symbols for pucch transmission
@param uci size number of uci bits
@returns TRUE pucch format matched uci size and constraints, FALSE invalid pucch format */
boolean_t check_pucch_format(NR_UE_MAC_INST_t *mac, uint8_t gNB_id, pucch_format_nr_t format_pucch, int nb_symbols_for_tx,
int uci_size);
/** \brief This function reads current CSI
@param ue context
@param gNB_id identity
@param csi_payload is updated with CSI
@returns number of bits of CSI */
int get_csi_nr(NR_UE_MAC_INST_t *mac, PHY_VARS_NR_UE *ue, uint8_t gNB_id, uint32_t *csi_payload);
/** \brief This dummy function sets current CSI for simulation
@param csi_status
@param csi_payload is updated with CSI
@returns none */
uint16_t get_nr_csi_bitlen(NR_UE_MAC_INST_t *mac);
void set_csi_nr(int csi_status, uint32_t csi_payload);
......
......@@ -27,6 +27,7 @@
#include <unistd.h>
#include "common/ran_context.h"
#include "common/config/config_userapi.h"
#include "common/utils/nr/nr_common.h"
#include "common/utils/LOG/log.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "LAYER2/NR_MAC_UE/mac_defs.h"
......@@ -429,7 +430,9 @@ int main(int argc, char **argv)
FILE *scg_fd=NULL;
while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:d:e:m:w:T:U:q")) != -1) {
while ((c = getopt (argc, argv, "f:hA:pf:g:in:s:S:t:x:y:z:M:N:F:GR:dPIL:Ea:b:D:e:m:w:T:U:q")) != -1) {
switch (c) {
case 'f':
scg_fd = fopen(optarg,"r");
......@@ -595,7 +598,7 @@ int main(int argc, char **argv)
case 'b':
g_rbSize = atoi(optarg);
break;
case 'd':
case 'D':
dlsch_threads = atoi(optarg);
break;
case 'e':
......@@ -668,7 +671,7 @@ int main(int argc, char **argv)
printf("-U Change DMRS Config, arguments list DMRS TYPE{0=A,1=B} DMRS AddPos{0:2} DMRS ConfType{1:2}, e.g. -U 3 0 2 1 \n");
printf("-P Print DLSCH performances\n");
printf("-w Write txdata to binary file (one frame)\n");
printf("-d number of dlsch threads, 0: no dlsch parallelization\n");
printf("-D number of dlsch threads, 0: no dlsch parallelization\n");
exit (-1);
break;
}
......@@ -685,7 +688,7 @@ int main(int argc, char **argv)
if (snr1set==0)
snr1 = snr0+10;
init_dlsch_tpool(dlsch_threads);
RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
......@@ -977,7 +980,11 @@ int main(int argc, char **argv)
reset_meas(&msgDataTx->phy_proc_tx);
gNB->phy_proc_tx_0 = &msgDataTx->phy_proc_tx;
pushTpool(gNB->threadPool,msgL1Tx);
if (dlsch_threads ) {
init_dlsch_tpool(dlsch_threads);
pthread_t dlsch0_threads;
threadCreate(&dlsch0_threads, dlsch_thread, (void *)UE, "DLthread", -1, OAI_PRIORITY_RT_MAX-1);
}
for (SNR = snr0; SNR < snr1; SNR += .2) {
varArray_t *table_tx=initVarArray(1000,sizeof(double));
......
......@@ -28,6 +28,7 @@
#include "common/config/config_userapi.h"
#include "common/utils/LOG/log.h"
#include "common/ran_context.h"
#include "common/utils/nr/nr_common.h"
#include "PHY/types.h"
#include "PHY/defs_nr_common.h"
#include "PHY/defs_nr_UE.h"
......
......@@ -47,6 +47,7 @@
#include "nr_unitary_defs.h"
#include "OCG_vars.h"
#include <openair2/LAYER2/MAC/mac_vars.h>
#include <openair2/LAYER2/NR_MAC_COMMON/nr_mac_common.h>
#include <openair2/RRC/LTE/rrc_vars.h>
#include <executables/softmodem-common.h>
#include <openair2/RRC/NR_UE/rrc_defs.h>
......
......@@ -359,7 +359,6 @@ void get_info_from_tda_tables(int default_abc,
}
const char *prachfmt[]={"0","1","2","3", "A1","A2","A3","B1","B4","C0","C2","A1/B1","A2/B2","A3/B3"};
const char *duplex_mode[]={"FDD","TDD"};
uint16_t get_NCS(uint8_t index, uint16_t format0, uint8_t restricted_set_config) {
......@@ -1573,60 +1572,6 @@ int get_nr_prach_occasion_info_from_index(uint8_t index,
}
uint8_t get_nr_prach_duration(uint8_t prach_format){
switch(prach_format){
case 0: // format 0
return 0;
case 1: // format 1
return 0;
case 2: // format 2
return 0;
case 3: // format 3
return 0;
case 4: // format A1
return 2;
case 5: // format A2
return 4;
case 6: // format A3
return 6;
case 7: // format B1
return 2;
case 8: // format B4
return 12;
case 9: // format C0
return 2;
case 10: // format C2
return 6;
case 11: // format A1/B1
return 2;
case 12: // format A2/B2
return 4;
case 13: // format A3/B3
return 6;
default :
AssertFatal(1==0,"Invalid Prach format\n");
break;
}
}
int get_nr_prach_info_from_index(uint8_t index,
int frame,
int slot,
......@@ -1981,170 +1926,6 @@ int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = {
{0, 3072, -1, -1, 3, 1539, -1, -1}, //14 // (DMRS l' position)
};
// Returns the corresponding row index of the NR table
int get_nr_table_idx(int nr_bandP, uint8_t scs_index)
{
int i, j;
int scs_khz = 15 << scs_index;
int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95};
size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]);
for(j = 0; j < s; j++){
if (nr_bandP == supplementary_bands[j])
AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]);
}
AssertFatal(nr_bandP <= nr_bandtable[nr_bandtable_size-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[nr_bandtable_size-1].band);
for (i = 0; i < nr_bandtable_size && nr_bandtable[i].band != nr_bandP; i++);
// selection of correct Deltaf raster according to SCS
if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz))
i++;
LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min);
return i;
}
// Computes the duplex spacing (either positive or negative) in KHz
int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index)
{
int nr_table_idx = get_nr_table_idx(nr_bandP, scs_index);
int32_t delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min);
LOG_I(NR_MAC, "NR band duplex spacing is %d KHz (nr_bandtable[%d].band = %d)\n", delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band);
return delta_duplex;
}
lte_frame_type_t get_frame_type(uint16_t current_band, uint8_t scs_index)
{
lte_frame_type_t current_type;
int32_t delta_duplex = get_delta_duplex(current_band, scs_index);
if (delta_duplex == 0)
current_type = TDD;
else
current_type = FDD;
LOG_I(NR_MAC, "NR band %d, duplex mode %s, duplex spacing = %d KHz\n", current_band, duplex_mode[current_type], delta_duplex);
return current_type;
}
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band)
{
if (nr_band < 100) { //FR1
switch(mu) {
case 0 :
if (nb_rb<=25)
return 5;
if (nb_rb<=52)
return 10;
if (nb_rb<=79)
return 15;
if (nb_rb<=106)
return 20;
if (nb_rb<=133)
return 25;
if (nb_rb<=160)
return 30;
if (nb_rb<=216)
return 40;
if (nb_rb<=270)
return 50;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
case 1 :
if (nb_rb<=11)
return 5;
if (nb_rb<=24)
return 10;
if (nb_rb<=38)
return 15;
if (nb_rb<=51)
return 20;
if (nb_rb<=65)
return 25;
if (nb_rb<=78)
return 30;
if (nb_rb<=106)
return 40;
if (nb_rb<=133)
return 50;
if (nb_rb<=162)
return 60;
if (nb_rb<=189)
return 70;
if (nb_rb<=217)
return 80;
if (nb_rb<=245)
return 90;
if (nb_rb<=273)
return 100;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
case 2 :
if (nb_rb<=11)
return 10;
if (nb_rb<=18)
return 15;
if (nb_rb<=24)
return 20;
if (nb_rb<=31)
return 25;
if (nb_rb<=38)
return 30;
if (nb_rb<=51)
return 40;
if (nb_rb<=65)
return 50;
if (nb_rb<=79)
return 60;
if (nb_rb<=93)
return 70;
if (nb_rb<=107)
return 80;
if (nb_rb<=121)
return 90;
if (nb_rb<=135)
return 100;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
default:
AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band);
}
}
else {
switch(mu) {
case 2 :
if (nb_rb<=66)
return 50;
if (nb_rb<=132)
return 100;
if (nb_rb<=264)
return 200;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
case 3 :
if (nb_rb<=32)
return 50;
if (nb_rb<=66)
return 100;
if (nb_rb<=132)
return 200;
if (nb_rb<=264)
return 400;
AssertFatal(1==0,"Number of DL resource blocks %d undefined for mu %d and band %d\n", nb_rb, mu, nr_band);
break;
default:
AssertFatal(1==0,"Numerology %d undefined for band %d in FR1\n", mu,nr_band);
}
}
}
void get_delta_arfcn(int i, uint32_t nrarfcn, uint64_t N_OFFs){
......@@ -2516,13 +2297,7 @@ static inline uint8_t get_table_idx(uint8_t mcs_table, uint8_t dci_format, uint8
return 1;
}
int get_num_dmrs(uint16_t dmrs_mask ) {
int num_dmrs=0;
for (int i=0;i<16;i++) num_dmrs+=((dmrs_mask>>i)&1);
return(num_dmrs);
}
/* returns the total DMRS symbols in a slot*/
uint8_t get_num_dmrs_symbols(NR_PDSCH_Config_t *pdsch_Config,int dmrs_TypeA_Position,int NrOfSymbols, int startSymbol, int mappingtype){
return get_num_dmrs(fill_dmrs_mask(pdsch_Config,dmrs_TypeA_Position,NrOfSymbols, startSymbol, mappingtype));
......@@ -3606,13 +3381,23 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD
uint16_t ssb_start_symbol,
NR_SubcarrierSpacing_t scs_ssb,
frequency_range_t frequency_range,
int nr_band,
uint32_t ssb_index,
uint32_t ssb_period,
uint32_t ssb_offset_point_a) {
NR_SubcarrierSpacing_t scs_pdcch;
channel_bandwidth_t min_channel_bw = bw_10MHz; // TODO remove hardcoding and implement Table 5.3.5-1 in 38.104
channel_bandwidth_t min_channel_bw;
// according to Table 5.3.5-1 in 38.104
// band 79 is the only one which minimum is 40
// for all the other channels it is either 10 or 5
// and there is no difference between the two for this implementation so it is set it to 10
if (nr_band == 79)
min_channel_bw = bw_40MHz;
else
min_channel_bw = bw_10MHz;
if (frequency_range == FR2) {
if(mib->subCarrierSpacingCommon == NR_MIB__subCarrierSpacingCommon_scs15or60)
......
......@@ -37,12 +37,6 @@
#include "nr_mac.h"
#include "openair1/PHY/impl_defs_nr.h"
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);
lte_frame_type_t get_frame_type(uint16_t nr_bandP, uint8_t scs_index);
int32_t get_delta_duplex(int nr_bandP, uint8_t scs_index);
uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn);
uint32_t to_nrarfcn(int nr_bandP, uint64_t dl_CarrierFreq, uint8_t scs_index, uint32_t bw);
......@@ -97,8 +91,6 @@ int get_nr_prach_occasion_info_from_index(uint8_t index,
uint16_t *N_RA_sfn,
uint8_t *max_association_period);
uint8_t get_nr_prach_duration(uint8_t prach_format);
uint8_t get_pusch_mcs_table(long *mcs_Table,
int is_tp,
int dci_format,
......@@ -121,7 +113,6 @@ int64_t *get_prach_config_info(frequency_range_t freq_range,
uint16_t get_NCS(uint8_t index, uint16_t format, uint8_t restricted_set_config);
int get_num_dmrs(uint16_t dmrs_mask );
uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position);
int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength, uint8_t start_symbolt, uint8_t dmrs_typeA_position);
......@@ -136,6 +127,7 @@ void get_type0_PDCCH_CSS_config_parameters(NR_Type0_PDCCH_CSS_config_t *type0_PD
uint16_t ssb_start_symbol,
NR_SubcarrierSpacing_t scs_ssb,
frequency_range_t frequency_range,
int nr_band,
uint32_t ssb_index,
uint32_t ssb_period,
uint32_t ssb_offset_point_a);
......
......@@ -270,23 +270,6 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
fapi_nr_ul_config_pucch_pdu *pucch_pdu,
int O_SR, int O_ACK, int O_CSI);
/** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure.
@param Mod_id Module id of UE
@returns Po_NOMINAL_PUSCH (PREAMBLE_RECEIVED_TARGET_POWER+DELTA_PREAMBLE
*/
int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t module_idP, uint8_t CC_id);
/** \brief Function to compute DELTA_PREAMBLE from 38.321 subclause 7.3
(for RA power ramping procedure and Msg3 PUSCH power control policy)
@param Mod_id Module id of UE
@returns DELTA_PREAMBLE
*/
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format);
/** \brief Function to compute configured maximum output power according to clause 6.2.4 of 3GPP TS 38.101-1 version 16.5.0 Release 16
@param Mod_id Module id of UE
*/
long nr_get_Pcmax(module_id_t mod_id);
/* Random Access */
......@@ -390,10 +373,6 @@ int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *p
void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id);
void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15);
void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
uint8_t *nb_dmrs_re_per_rb,
uint16_t *number_dmrs_symbols);
void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac);
void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint16_t *bwp_ind, uint8_t *dci_format);
......
......@@ -35,150 +35,9 @@
#include "mac_defs.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h"
#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h"
#include "NR_P-Max.h"
/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc!=NULL) ?
mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup:
mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
int prach_sequence_length = (mac->scc!=NULL)?(mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - 1) : (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present-1);
uint8_t prachConfigIndex, mu;
AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n");
// SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211
switch (scs){
case NR_SubcarrierSpacing_kHz15:
mu = 0;
break;
case NR_SubcarrierSpacing_kHz30:
mu = 1;
break;
case NR_SubcarrierSpacing_kHz60:
mu = 2;
break;
case NR_SubcarrierSpacing_kHz120:
mu = 3;
break;
case NR_SubcarrierSpacing_kHz240:
mu = 4;
break;
case NR_SubcarrierSpacing_spare3:
mu = 5;
break;
case NR_SubcarrierSpacing_spare2:
mu = 6;
break;
case NR_SubcarrierSpacing_spare1:
mu = 7;
break;
default:
AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %lu\n", scs);
}
// Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211
prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex;
if (prach_sequence_length == 0) {
AssertFatal(prach_format < 4, "Illegal PRACH format %d for sequence length 839\n", prach_format);
switch (prach_format) {
// long preamble formats
case 0:
case 3:
return 0;
case 1:
return -3;
case 2:
return -6;
}
} else {
switch (prach_format) { // short preamble formats
case 0:
case 3:
return 8 + 3*mu;
case 1:
case 4:
case 8:
return 5 + 3*mu;
case 2:
case 5:
return 3 + 3*mu;
case 6:
return 3*mu;
case 7:
return 5 + 3*mu;
default:
AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex);
}
}
return 0;
}
// TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration
// Measurement units:
// - preambleReceivedTargetPower dBm (-202..-60, 2 dBm granularity)
// - delta_preamble dB
// - RA_PREAMBLE_POWER_RAMPING_STEP dB
// - POWER_OFFSET_2STEP_RA dB
// returns receivedTargerPower in dBm
int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
int8_t receivedTargerPower;
int8_t delta_preamble;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc != NULL) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower;
delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format);
receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP + prach_resources->POWER_OFFSET_2STEP_RA;
LOG_D(MAC, "In %s: receivedTargerPower is %d dBm \n", __FUNCTION__, receivedTargerPower);
return receivedTargerPower;
}
void get_num_re_dmrs(nfapi_nr_ue_pusch_pdu_t *pusch_pdu,
uint8_t *nb_dmrs_re_per_rb,
uint16_t *number_dmrs_symbols){
int start_symbol = pusch_pdu->start_symbol_index;
uint8_t number_of_symbols = pusch_pdu->nr_of_symbols;
uint16_t ul_dmrs_symb_pos = pusch_pdu->ul_dmrs_symb_pos;
uint8_t dmrs_type = pusch_pdu->dmrs_config_type;
uint8_t cdm_grps_no_data = pusch_pdu->num_dmrs_cdm_grps_no_data;
*number_dmrs_symbols = 0;
for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) {
if((ul_dmrs_symb_pos >> i) & 0x01)
*number_dmrs_symbols += 1;
}
*nb_dmrs_re_per_rb = ((dmrs_type == pusch_dmrs_type1) ? 6:4)*cdm_grps_no_data;
}
// Implementation of 6.2.4 Configured ransmitted power
// 3GPP TS 38.101-1 version 16.5.0 Release 16
......
/*
* 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
*/
/** \brief Function to compute configured maximum output power according to clause 6.2.4 of 3GPP TS 38.101-1 version 16.5.0 Release 16
@param Mod_id Module id of UE
*/
long nr_get_Pcmax(module_id_t mod_id);
/** @}*/
......@@ -30,23 +30,18 @@
* \warning
*/
/* Tools */
#include "SIMULATION/TOOLS/sim.h" // for taus
/* RRC */
#include "NR_RACH-ConfigCommon.h"
#include "RRC/NR_UE/rrc_proto.h"
/* PHY */
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
#include "PHY/defs_common.h"
#include "PHY/defs_nr_common.h"
#include "PHY/NR_UE_ESTIMATION/nr_estimation.h"
/* MAC */
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "NR_MAC_COMMON/nr_mac.h"
#include "LAYER2/NR_MAC_UE/mac_proto.h"
#include "LAYER2/NR_MAC_UE/nr_l1_helpers.h"
#include <executables/softmodem-common.h>
......@@ -198,6 +193,130 @@ void init_RA(module_id_t mod_id,
}
}
/* TS 38.321 subclause 7.3 - return DELTA_PREAMBLE values in dB */
int8_t nr_get_DELTA_PREAMBLE(module_id_t mod_id, int CC_id, uint16_t prach_format){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc!=NULL) ?
mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup:
mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
NR_SubcarrierSpacing_t scs = *nr_rach_ConfigCommon->msg1_SubcarrierSpacing;
int prach_sequence_length = (mac->scc!=NULL)?(mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present - 1) : (mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup->prach_RootSequenceIndex.present-1);
uint8_t prachConfigIndex, mu;
AssertFatal(CC_id == 0, "Transmission on secondary CCs is not supported yet\n");
// SCS configuration from msg1_SubcarrierSpacing and table 4.2-1 in TS 38.211
switch (scs){
case NR_SubcarrierSpacing_kHz15:
mu = 0;
break;
case NR_SubcarrierSpacing_kHz30:
mu = 1;
break;
case NR_SubcarrierSpacing_kHz60:
mu = 2;
break;
case NR_SubcarrierSpacing_kHz120:
mu = 3;
break;
case NR_SubcarrierSpacing_kHz240:
mu = 4;
break;
case NR_SubcarrierSpacing_spare3:
mu = 5;
break;
case NR_SubcarrierSpacing_spare2:
mu = 6;
break;
case NR_SubcarrierSpacing_spare1:
mu = 7;
break;
default:
AssertFatal(1 == 0,"Unknown msg1_SubcarrierSpacing %lu\n", scs);
}
// Preamble formats given by prach_ConfigurationIndex and tables 6.3.3.2-2 and 6.3.3.2-2 in TS 38.211
prachConfigIndex = nr_rach_ConfigCommon->rach_ConfigGeneric.prach_ConfigurationIndex;
if (prach_sequence_length == 0) {
AssertFatal(prach_format < 4, "Illegal PRACH format %d for sequence length 839\n", prach_format);
switch (prach_format) {
// long preamble formats
case 0:
case 3:
return 0;
case 1:
return -3;
case 2:
return -6;
}
} else {
switch (prach_format) { // short preamble formats
case 0:
case 3:
return 8 + 3*mu;
case 1:
case 4:
case 8:
return 5 + 3*mu;
case 2:
case 5:
return 3 + 3*mu;
case 6:
return 3*mu;
case 7:
return 5 + 3*mu;
default:
AssertFatal(1 == 0, "[UE %d] ue_procedures.c: FATAL, Illegal preambleFormat %d, prachConfigIndex %d\n", mod_id, prach_format, prachConfigIndex);
}
}
return 0;
}
// TS 38.321 subclause 5.1.3 - RA preamble transmission - ra_PREAMBLE_RECEIVED_TARGET_POWER configuration
// Measurement units:
// - preambleReceivedTargetPower dBm (-202..-60, 2 dBm granularity)
// - delta_preamble dB
// - RA_PREAMBLE_POWER_RAMPING_STEP dB
// - POWER_OFFSET_2STEP_RA dB
// returns receivedTargerPower in dBm
int nr_get_Po_NOMINAL_PUSCH(NR_PRACH_RESOURCES_t *prach_resources, module_id_t mod_id, uint8_t CC_id){
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
int8_t receivedTargerPower;
int8_t delta_preamble;
NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon = (mac->scc != NULL) ? mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup: mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.rach_ConfigCommon->choice.setup;
long preambleReceivedTargetPower = nr_rach_ConfigCommon->rach_ConfigGeneric.preambleReceivedTargetPower;
delta_preamble = nr_get_DELTA_PREAMBLE(mod_id, CC_id, prach_resources->prach_format);
receivedTargerPower = preambleReceivedTargetPower + delta_preamble + (prach_resources->RA_PREAMBLE_POWER_RAMPING_COUNTER - 1) * prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP + prach_resources->POWER_OFFSET_2STEP_RA;
LOG_D(MAC, "In %s: receivedTargerPower is %d dBm \n", __FUNCTION__, receivedTargerPower);
return receivedTargerPower;
}
void ssb_rach_config(RA_config_t *ra, NR_PRACH_RESOURCES_t *prach_resources, NR_RACH_ConfigCommon_t *nr_rach_ConfigCommon, fapi_nr_ul_config_prach_pdu *prach_pdu){
// Determine the SSB to RACH mapping ratio
......@@ -280,6 +399,10 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
int PLThreshold = 0;
long deltaPreamble_Msg3 = 0;
uint8_t noGroupB = 0;
// Random seed generation
long long tmp = rdtsc_oai();
unsigned short int *seed = (unsigned short int*)&tmp;
RA_config_t *ra = &mac->ra;
NR_RACH_ConfigCommon_t *setup;
if (mac->scc) setup = mac->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup;
......@@ -378,28 +501,28 @@ void ra_preambles_config(NR_PRACH_RESOURCES_t *prach_resources, NR_UE_MAC_INST_t
if(ra->ra_PreambleIndex < 0 || ra->ra_PreambleIndex > 63) {
if (noGroupB) {
// use Group A preamble
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % ra->cb_preambles_per_ssb);
ra->RA_usedGroupA = 1;
} else if ((ra->Msg3_size < messageSizeGroupA) && (dl_pathloss > PLThreshold)) {
// Group B is configured and RA preamble Group A is used
// - todo add condition on CCCH_sdu_size for initiation by CCCH
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % sizeOfRA_PreamblesGroupA);
ra->RA_usedGroupA = 1;
} else {
// Group B preamble is configured and used
// the first sizeOfRA_PreamblesGroupA RA preambles belong to RA Preambles Group A
// the remaining belong to RA Preambles Group B
ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + (nrand48(seed) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->RA_usedGroupA = 0;
}
}
} else { // Msg3 is being retransmitted
if (ra->RA_usedGroupA && noGroupB) {
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % ra->cb_preambles_per_ssb);
ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % ra->cb_preambles_per_ssb);
} else if (ra->RA_usedGroupA && !noGroupB){
ra->ra_PreambleIndex = ra->starting_preamble_nb + ((taus()) % sizeOfRA_PreamblesGroupA);
ra->ra_PreambleIndex = ra->starting_preamble_nb + (nrand48(seed) % sizeOfRA_PreamblesGroupA);
} else {
ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + ((taus()) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
ra->ra_PreambleIndex = ra->starting_preamble_nb + sizeOfRA_PreamblesGroupA + (nrand48(seed) % (ra->cb_preambles_per_ssb - sizeOfRA_PreamblesGroupA));
}
}
prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex;
......@@ -467,7 +590,8 @@ void nr_get_prach_resources(module_id_t mod_id,
if (rach_ConfigDedicated) {
if (rach_ConfigDedicated->cfra){
uint8_t cfra_ssb_resource_idx = 0;
prach_resources->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex;
ra->ra_PreambleIndex = rach_ConfigDedicated->cfra->resources.choice.ssb->ssb_ResourceList.list.array[cfra_ssb_resource_idx]->ra_PreambleIndex;
prach_resources->ra_PreambleIndex = ra->ra_PreambleIndex;
LOG_D(MAC, "In %s: selected RA preamble index %d for contention-free random access procedure for SSB with Id %d\n", __FUNCTION__, prach_resources->ra_PreambleIndex, cfra_ssb_resource_idx);
}
} else {
......@@ -837,6 +961,9 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra;
// Random seed generation
long long tmp = rdtsc_oai();
unsigned short int *seed = (unsigned short int*)&tmp;
ra->first_Msg3 = 1;
ra->ra_PreambleIndex = -1;
......@@ -850,7 +977,7 @@ void nr_ra_failed(uint8_t mod_id, uint8_t CC_id, NR_PRACH_RESOURCES_t *prach_res
LOG_D(MAC, "In %s: [UE %d][%d.%d] Maximum number of RACH attempts (%d) reached, selecting backoff time...\n",
__FUNCTION__, mod_id, frame, slot, ra->preambleTransMax);
ra->RA_backoff_cnt = rand() % (prach_resources->RA_PREAMBLE_BACKOFF + 1);
ra->RA_backoff_cnt = nrand48(seed) % (prach_resources->RA_PREAMBLE_BACKOFF + 1);
prach_resources->RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
prach_resources->RA_PREAMBLE_POWER_RAMPING_STEP += 2; // 2 dB increment
prach_resources->ra_PREAMBLE_RECEIVED_TARGET_POWER = nr_get_Po_NOMINAL_PUSCH(prach_resources, mod_id, CC_id);
......
......@@ -54,7 +54,6 @@
/* PHY */
#include "PHY/NR_TRANSPORT/nr_dci.h"
#include "executables/softmodem-common.h"
#include "SCHED_NR_UE/defs.h"
/* utils */
#include "assertions.h"
......@@ -1396,7 +1395,7 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
mac->cg->physicalCellGroupConfig &&
(mac->cg->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH != NULL ||
mac->cg->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook != 1)) {
LOG_E(PHY,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
LOG_E(MAC,"PUCCH Unsupported cell group configuration : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME);
return;
}
else if (mac->cg &&
......@@ -3612,8 +3611,6 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
return 0;
}
int cc_id = dl_info->cc_id;
uint8_t gNB_id = dl_info->gNB_index;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
RA_config_t *ra = &mac->ra;
uint8_t n_subPDUs = 0; // number of RAR payloads
......@@ -3625,7 +3622,7 @@ int nr_ue_process_rar(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t
int ret = 0;
NR_RA_HEADER_RAPID *rarh = (NR_RA_HEADER_RAPID *) dlsch_buffer; // RAR subheader pointer
NR_MAC_RAR *rar = (NR_MAC_RAR *) (dlsch_buffer + 1); // RAR subPDU pointer
uint8_t preamble_index = get_ra_PreambleIndex(mod_id, cc_id, gNB_id); //prach_resources->ra_PreambleIndex;
uint8_t preamble_index = ra->ra_PreambleIndex;
LOG_D(NR_MAC, "In %s:[%d.%d]: [UE %d][RAPROC] invoking MAC for received RAR (current preamble %d)\n", __FUNCTION__, frame, slot, mod_id, preamble_index);
......
......@@ -840,7 +840,14 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
return -1;
}
get_num_re_dmrs(pusch_config_pdu, &nb_dmrs_re_per_rb, &number_dmrs_symbols);
int start_symbol = pusch_config_pdu->start_symbol_index;
int number_of_symbols = pusch_config_pdu->nr_of_symbols;
for (int i = start_symbol; i < start_symbol + number_of_symbols; i++) {
if((pusch_config_pdu->ul_dmrs_symb_pos >> i) & 0x01)
number_dmrs_symbols += 1;
}
nb_dmrs_re_per_rb = ((pusch_config_pdu->dmrs_config_type == pusch_dmrs_type1) ? 6:4)*pusch_config_pdu->num_dmrs_cdm_grps_no_data;
// Compute TBS
pusch_config_pdu->pusch_data.tb_size = nr_compute_tbs(pusch_config_pdu->qam_mod_order,
......@@ -1993,6 +2000,7 @@ void nr_ue_sib1_scheduler(module_id_t module_idP,
ssb_start_symbol,
scs_ssb,
frequency_range,
mac->nr_band,
ssb_index,
1, // If the UE is not configured with a periodicity, the UE assumes a periodicity of a half frame
ssb_offset_point_a);
......
......@@ -33,7 +33,7 @@
#include "COMMON/platform_types.h"
#include "COMMON/platform_constants.h"
#include "common/ran_context.h"
#include "common/utils/nr/nr_common.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
......
......@@ -46,9 +46,6 @@
//#include "LAYER2/MAC/pre_processor.c"
#include "pdcp.h"
#include "openair1/PHY/defs_gNB.h"
#include "openair1/PHY/NR_TRANSPORT/nr_dlsch.h"
#include "intertask_interface.h"
#include "executables/softmodem-common.h"
......@@ -62,92 +59,6 @@ uint16_t nr_pdcch_order_table[6] = { 31, 31, 511, 2047, 2047, 8191 };
uint8_t vnf_first_sched_entry = 1;
void clear_mac_stats(gNB_MAC_INST *gNB) {
memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t));
}
#define MACSTATSSTRLEN 16384
void dump_mac_stats(gNB_MAC_INST *gNB)
{
NR_UE_info_t *UE_info = &gNB->UE_info;
int num = 1;
FILE *fd=fopen("nrMAC_stats.log","w");
AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno));
char output[MACSTATSSTRLEN];
memset(output,0,MACSTATSSTRLEN);
int stroff=0;
for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) {
NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id];
const NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0;
stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm\n",
UE_id,
UE_info->rnti[UE_id],
num++,
UE_info->num_UEs,
UE_info->UE_sched_ctrl[UE_id].ph,
UE_info->UE_sched_ctrl[UE_id].pcmax);
LOG_I(MAC, "UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n",
UE_id,
UE_info->rnti[UE_id],
num++,
UE_info->num_UEs,
UE_info->UE_sched_ctrl[UE_id].ph,
UE_info->UE_sched_ctrl[UE_id].pcmax,
avg_rsrp,
stats->num_rsrp_meas);
stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, pucch0_DTX %d, BLER %.5f MCS %d\n",
UE_id,
stats->dlsch_rounds[0], stats->dlsch_rounds[1],
stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, stats->pucch0_DTX,
sched_ctrl->dl_bler_stats.bler, sched_ctrl->dl_bler_stats.mcs);
LOG_I(MAC, "UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, pucch0_DTX %d, BLER %.5f MCS %d\n",
UE_id,
stats->dlsch_rounds[0], stats->dlsch_rounds[1],
stats->dlsch_rounds[2], stats->dlsch_rounds[3], stats->dlsch_errors, stats->pucch0_DTX,
sched_ctrl->dl_bler_stats.bler, sched_ctrl->dl_bler_stats.mcs);
stats->num_rsrp_meas = 0;
stats->cumul_rsrp = 0 ;
stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes);
stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n",
UE_id,
stats->ulsch_rounds[0], stats->ulsch_rounds[1],
stats->ulsch_rounds[2], stats->ulsch_rounds[3],
stats->ulsch_DTX,
stats->ulsch_errors);
stroff+=sprintf(output+stroff,
"UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n",
UE_id,
stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx);
LOG_I(NR_MAC, "UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes);
LOG_I(NR_MAC, "UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_errors %d, ulsch_DTX %d\n",
UE_id, stats->ulsch_rounds[0], stats->ulsch_rounds[1], stats->ulsch_rounds[2], stats->ulsch_rounds[3],
stats->ulsch_errors, stats->ulsch_DTX);
LOG_I(NR_MAC,
"UE %d: ulsch_total_bytes (scheduled/received): %d / %d\n",
UE_id,
stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx);
for (int lc_id = 0; lc_id < 63; lc_id++) {
if (stats->lc_bytes_tx[lc_id] > 0) {
stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]);
LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]);
}
if (stats->lc_bytes_rx[lc_id] > 0) {
stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]);
LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]);
}
}
}
print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL);
if (stroff>0) fprintf(fd,"%s",output);
fclose(fd);
}
void clear_nr_nfapi_information(gNB_MAC_INST * gNB,
int CC_idP,
frame_t frameP,
......@@ -366,6 +277,7 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frame, slot,module_idP);
const int bwp_id = 1;
char stats_output[16384];
gNB_MAC_INST *gNB = RC.nrmac[module_idP];
NR_COMMON_channels_t *cc = gNB->common_channels;
......@@ -433,8 +345,11 @@ void gNB_dlsch_ulsch_scheduler(module_id_t module_idP,
}
if ((slot == 0) && (frame & 127) == 0) dump_mac_stats(RC.nrmac[module_idP]);
if ((slot == 0) && (frame & 127) == 0) {
stats_output[0]='\0';
dump_mac_stats(RC.nrmac[module_idP],stats_output,16384);
LOG_I(NR_MAC,"Frame.Slot %d.%d\n%s\n",frame,slot,stats_output);
}
// This schedules MIB
schedule_nr_mib(module_idP, frame, slot);
......
......@@ -219,6 +219,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
ssb_start_symbol,
scs,
FR1,
band,
i_ssb,
ssb_frame_periodicity,
offset_pointa);
......@@ -246,6 +247,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
ssb_start_symbol,
scs,
FR1,
band,
i_ssb,
ssb_frame_periodicity,
offset_pointa);
......@@ -281,6 +283,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP)
ssb_start_symbol,
scs,
FR2,
band,
i_ssb,
ssb_frame_periodicity,
offset_pointa);
......
......@@ -29,11 +29,7 @@
*/
/*PHY*/
#include "PHY/CODING/coding_defs.h"
#include "PHY/defs_nr_common.h"
#include "common/utils/nr/nr_common.h"
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
/*MAC*/
#include "NR_MAC_COMMON/nr_mac.h"
#include "NR_MAC_gNB/nr_mac_gNB.h"
......@@ -635,12 +631,12 @@ bool allocate_dl_retransmission(module_id_t module_id,
return false;
}
sched_ctrl->sched_pdsch.pucch_allocation = alloc;
/* just reuse from previous scheduling opportunity, set new start RB */
sched_ctrl->sched_pdsch = *retInfo;
sched_ctrl->sched_pdsch.rbStart = rbStart;
sched_ctrl->sched_pdsch.pucch_allocation = alloc;
/* retransmissions: directly allocate */
*n_rb_sched -= sched_ctrl->sched_pdsch.rbSize;
for (int rb = 0; rb < sched_ctrl->sched_pdsch.rbSize; rb++)
......@@ -960,7 +956,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
UE_info->mac_stats[UE_id].dlsch_rounds[harq->round]++;
LOG_I(NR_MAC,
"%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) TPC %d\n",
"%4d.%2d [DLSCH/PDSCH/PUCCH] UE %d RNTI %04x DCI L %d start %3d RBs %3d startSymbol %2d nb_symbol %2d dmrspos %x MCS %2d TBS %4d HARQ PID %2d round %d RV %d NDI %d dl_data_to_ULACK %d (%d.%d) PUCCH allocation %d TPC %d\n",
frame,
slot,
UE_id,
......@@ -980,6 +976,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
pucch->timing_indicator,
pucch->frame,
pucch->ul_slot,
sched_pdsch->pucch_allocation,
sched_ctrl->tpc1);
NR_BWP_Downlink_t *bwp = sched_ctrl->active_bwp;
......
......@@ -29,11 +29,8 @@
*/
#include "nr_mac_gNB.h"
#include "SCHED_NR/sched_nr.h"
#include "NR_MAC_gNB/mac_proto.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
#include "PHY/NR_TRANSPORT/nr_dlsch.h"
#include "PHY/NR_TRANSPORT/nr_dci.h"
#include "executables/nr-softmodem.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac.h"
#include "executables/softmodem-common.h"
......@@ -376,14 +373,12 @@ void nr_preprocessor_phytest(module_id_t module_id,
sched_pdsch->rbStart = rbStart;
sched_pdsch->rbSize = rbSize;
const int tda = sched_ctrl->active_bwp ? RC.nrmac[module_id]->preferred_dl_tda[sched_ctrl->active_bwp->bwp_Id][slot] : 1;
const uint8_t num_dmrs_cdm_grps_no_data = 1;
const long f = 1;
const long f = sched_ctrl->active_bwp ? sched_ctrl->search_space->searchSpaceType->choice.ue_Specific->dci_Formats : 0;
ps->nrOfLayers = target_dl_Nl;
if (ps->time_domain_allocation != tda || ps->numDmrsCdmGrpsNoData != num_dmrs_cdm_grps_no_data)
if (ps->time_domain_allocation != tda)
nr_set_pdsch_semi_static(
scc, UE_info->CellGroup[UE_id], sched_ctrl->active_bwp, NULL, tda, f, ps);
sched_pdsch->mcs = target_dl_mcs;
sched_pdsch->Qm = nr_get_Qm_dl(sched_pdsch->mcs, ps->mcsTableIdx);
sched_pdsch->R = nr_get_code_rate_dl(sched_pdsch->mcs, ps->mcsTableIdx);
......
......@@ -1334,28 +1334,28 @@ void fill_dci_pdu_rel15(const NR_ServingCellConfigCommon_t *scc,
pos = 1;
// Freq domain assignment 0-16 bit
fsize = (int)ceil(log2((N_RB * (N_RB + 1)) >> 1));
LOG_D(PHY, "fsize = %i\n", fsize);
LOG_D(NR_MAC, "fsize = %i\n", fsize);
for (int i = 0; i < fsize; i++)
*dci_pdu |= (((uint64_t)dci_pdu_rel15->frequency_domain_assignment.val >> (fsize - i - 1)) & 1) << (dci_size - pos++);
LOG_D(PHY, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val);
LOG_D(NR_MAC, "dci_pdu_rel15->frequency_domain_assignment.val = %i\n", dci_pdu_rel15->frequency_domain_assignment.val);
// Time domain assignment 4 bit
for (int i = 0; i < 4; i++)
*dci_pdu |= (((uint64_t)dci_pdu_rel15->time_domain_assignment.val >> (3 - i)) & 1) << (dci_size - pos++);
LOG_D(PHY, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val);
LOG_D(NR_MAC, "dci_pdu_rel15->time_domain_assignment.val = %i\n", dci_pdu_rel15->time_domain_assignment.val);
// VRB to PRB mapping 1 bit
*dci_pdu |= ((uint64_t)dci_pdu_rel15->vrb_to_prb_mapping.val & 1) << (dci_size - pos++);
LOG_D(PHY, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val);
LOG_D(NR_MAC, "dci_pdu_rel15->vrb_to_prb_mapping.val = %i\n", dci_pdu_rel15->vrb_to_prb_mapping.val);
// MCS 5bit //bit over 32, so dci_pdu ++
for (int i = 0; i < 5; i++)
*dci_pdu |= (((uint64_t)dci_pdu_rel15->mcs >> (4 - i)) & 1) << (dci_size - pos++);
LOG_D(PHY, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs);
LOG_D(NR_MAC, "dci_pdu_rel15->mcs = %i\n", dci_pdu_rel15->mcs);
// Redundancy version 2bit
for (int i = 0; i < 2; i++)
*dci_pdu |= (((uint64_t)dci_pdu_rel15->rv >> (1 - i)) & 1) << (dci_size - pos++);
LOG_D(PHY, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv);
LOG_D(NR_MAC, "dci_pdu_rel15->rv = %i\n", dci_pdu_rel15->rv);
// System information indicator 1bit
*dci_pdu |= ((uint64_t)dci_pdu_rel15->system_info_indicator&1)<<(dci_size-pos++);
LOG_D(PHY, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator);
LOG_D(NR_MAC, "dci_pdu_rel15->system_info_indicator = %i\n", dci_pdu_rel15->system_info_indicator);
break;
case NR_RNTI_TC:
......
......@@ -31,8 +31,6 @@
#ifndef __LAYER2_NR_MAC_PROTO_H__
#define __LAYER2_NR_MAC_PROTO_H__
#include "PHY/defs_gNB.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "NR_TAG-Id.h"
......@@ -443,4 +441,5 @@ bool nr_find_nb_rb(uint16_t Qm,
void nr_sr_reporting(int Mod_idP, frame_t frameP, sub_frame_t slotP);
void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen);
#endif /*__LAYER2_NR_MAC_PROTO_H__*/
......@@ -45,6 +45,92 @@
extern RAN_CONTEXT_t RC;
#define MACSTATSSTRLEN 16384
void *nrmac_stats_thread(void *arg) {
gNB_MAC_INST *gNB = (gNB_MAC_INST *)arg;
char output[MACSTATSSTRLEN];
memset(output,0,MACSTATSSTRLEN);
FILE *fd=fopen("nrMAC_stats.log","w");
AssertFatal(fd!=NULL,"Cannot open nrMAC_stats.log, error %s\n",strerror(errno));
while (oai_exit == 0) {
dump_mac_stats(gNB,output,MACSTATSSTRLEN);
fprintf(fd,"%s\n",output);
fflush(fd);
usleep(200000);
fseek(fd,0,SEEK_SET);
}
fclose(fd);
return (void *)0;
}
void clear_mac_stats(gNB_MAC_INST *gNB) {
memset((void*)gNB->UE_info.mac_stats,0,MAX_MOBILES_PER_GNB*sizeof(NR_mac_stats_t));
}
void dump_mac_stats(gNB_MAC_INST *gNB, char *output, int strlen)
{
NR_UE_info_t *UE_info = &gNB->UE_info;
int num = 1;
int stroff=0;
if (UE_info->num_UEs == 0) return;
for (int UE_id = UE_info->list.head; UE_id >= 0; UE_id = UE_info->list.next[UE_id]) {
const NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl[UE_id];
NR_mac_stats_t *stats = &UE_info->mac_stats[UE_id];
const int avg_rsrp = stats->num_rsrp_meas > 0 ? stats->cumul_rsrp / stats->num_rsrp_meas : 0;
stroff+=sprintf(output+stroff,"UE ID %d RNTI %04x (%d/%d) PH %d dB PCMAX %d dBm, average RSRP %d (%d meas)\n",
UE_id,
UE_info->rnti[UE_id],
num++,
UE_info->num_UEs,
sched_ctrl->ph,
sched_ctrl->pcmax,
avg_rsrp,
stats->num_rsrp_meas);
stroff+=sprintf(output+stroff,"UE %d: dlsch_rounds %d/%d/%d/%d, dlsch_errors %d, pucch0_DTX %d, BLER %.5f MCS %d\n",
UE_id,
stats->dlsch_rounds[0], stats->dlsch_rounds[1],
stats->dlsch_rounds[2], stats->dlsch_rounds[3],
stats->dlsch_errors,
stats->pucch0_DTX,
sched_ctrl->dl_bler_stats.bler,
sched_ctrl->dl_bler_stats.mcs);
stats->num_rsrp_meas = 0;
stats->cumul_rsrp = 0 ;
stroff+=sprintf(output+stroff,"UE %d: dlsch_total_bytes %d\n", UE_id, stats->dlsch_total_bytes);
stroff+=sprintf(output+stroff,"UE %d: ulsch_rounds %d/%d/%d/%d, ulsch_DTX %d, ulsch_errors %d\n",
UE_id,
stats->ulsch_rounds[0], stats->ulsch_rounds[1],
stats->ulsch_rounds[2], stats->ulsch_rounds[3],
stats->ulsch_DTX,
stats->ulsch_errors);
stroff+=sprintf(output+stroff,
"UE %d: ulsch_total_bytes_scheduled %d, ulsch_total_bytes_received %d\n",
UE_id,
stats->ulsch_total_bytes_scheduled, stats->ulsch_total_bytes_rx);
for (int lc_id = 0; lc_id < 63; lc_id++) {
if (stats->lc_bytes_tx[lc_id] > 0) {
stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]);
LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes TX\n", UE_id, lc_id, stats->lc_bytes_tx[lc_id]);
}
if (stats->lc_bytes_rx[lc_id] > 0) {
stroff+=sprintf(output+stroff, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]);
LOG_D(NR_MAC, "UE %d: LCID %d: %d bytes RX\n", UE_id, lc_id, stats->lc_bytes_rx[lc_id]);
}
}
}
print_meas(&gNB->eNB_scheduler, "DL & UL scheduling timing stats", NULL, NULL);
}
void mac_top_init_gNB(void)
{
module_id_t i;
......@@ -90,6 +176,7 @@ void mac_top_init_gNB(void)
RC.nrmac[i]->pre_processor_dl = nr_init_fr1_dlsch_preprocessor(i, 0);
RC.nrmac[i]->pre_processor_ul = nr_init_fr1_ulsch_preprocessor(i, 0);
}
pthread_create(&RC.nrmac[i]->stats_thread,NULL,nrmac_stats_thread,(void*)RC.nrmac[i]);
}//END for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
......@@ -103,6 +190,7 @@ void mac_top_init_gNB(void)
rrc_init_nr_global_param();
} else {
RC.nrmac = NULL;
}
......
......@@ -675,6 +675,7 @@ typedef struct gNB_MAC_INST_s {
NR_TAG_t *tag;
/// Pointer to IF module instance for PHY
NR_IF_Module_t *if_inst;
pthread_t stats_thread;
/// Pusch target SNR
int pusch_target_snrx10;
/// Pucch target SNR
......
......@@ -603,7 +603,7 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
//int optval;
int bytes_received;
sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
pc5s_header_t *pc5s_header = NULL;
pc5s_header_t *pc5s_header = NULL;
rb_id_t rab_id = 0;
//TTN for D2D (PC5S)
// receive a message from ProSe App
......@@ -704,6 +704,12 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
pc5s_header->rb_id,
rab_id,
pc5s_header->data_size);
/* pointers to pc5s_header fields possibly not aligned because pc5s_header points to a packed structure
* Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and
* gcc, from v9, now warns about it. fix these warnings by using local variables
*/
uint32_t sourceL2Id = pc5s_header->sourceL2Id;
uint32_t destinationL2Id = pc5s_header->destinationL2Id;
pdcp_data_req(
&ctxt,
SRB_FLAG_NO,
......@@ -713,9 +719,11 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
pc5s_header->data_size,
(unsigned char *)receive_buf,
PDCP_TRANSMISSION_MODE_DATA,
&pc5s_header->sourceL2Id,
&pc5s_header->destinationL2Id
&sourceL2Id,
&destinationL2Id
);
pc5s_header->sourceL2Id = sourceL2Id;
pc5s_header->destinationL2Id=destinationL2Id;
} else { /* else of h_rc == HASH_TABLE_OK */
MSC_LOG_RX_DISCARDED_MESSAGE(
(ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
......@@ -759,6 +767,12 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
pc5s_header->rb_id,
DEFAULT_RAB_ID,
pc5s_header->data_size);
/* pointers to pc5s_header fields possibly not aligned because pc5s_header points to a packed structure
* Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and
* gcc, from v9, now warns about it. fix these warnings by using local variables
*/
uint32_t sourceL2Id = pc5s_header->sourceL2Id;
uint32_t destinationL2Id = pc5s_header->destinationL2Id;
pdcp_data_req (
&ctxt,
SRB_FLAG_NO,
......@@ -768,9 +782,11 @@ void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP)
pc5s_header->data_size,
(unsigned char *)receive_buf,
PDCP_TRANSMISSION_MODE_DATA,
&pc5s_header->sourceL2Id,
&pc5s_header->destinationL2Id
&sourceL2Id,
&destinationL2Id
);
pc5s_header->sourceL2Id = sourceL2Id;
pc5s_header->destinationL2Id=destinationL2Id;
}
} /* end of !ctxt.enb_flag */
......
......@@ -2969,6 +2969,12 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index,
UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize = siWindowLength_int[sib1->si_WindowLength];
LOG_I( RRC, "[FRAME unknown][RRC_UE][MOD %02"PRIu8"][][--- MAC_CONFIG_REQ (SIB1 params eNB %"PRIu8") --->][MAC_UE][MOD %02"PRIu8"][]\n",
ctxt_pP->module_id, eNB_index, ctxt_pP->module_id );
/* pointers to SIperiod inthe Info struct points to a packed structure
* Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and
* gcc, from v9, now warns about it. fix these warnings by removing the indirection on data
* Not sure if SiPeriod can be modified, reassign after function call for security
*/
uint16_t Aligned_SIperiod = UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod;
rrc_mac_config_req_ue(ctxt_pP->module_id, 0, eNB_index,
(LTE_RadioResourceConfigCommonSIB_t *)NULL,
(struct LTE_PhysicalConfigDedicated *)NULL,
......@@ -2981,7 +2987,7 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index,
UE_rrc_inst[ctxt_pP->module_id].sib1[eNB_index]->tdd_Config,
(LTE_MobilityControlInfo_t *) NULL,
&UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIwindowsize,
&UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod,
&Aligned_SIperiod,
NULL,
NULL,
NULL,
......@@ -2995,6 +3001,7 @@ int decode_SIB1( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index,
(struct LTE_NonMBSFN_SubframeConfig_r14 *)NULL,
(LTE_MBSFN_AreaInfoList_r9_t *)NULL
);
UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIperiod=Aligned_SIperiod;
LOG_I(RRC,"Setting SIStatus bit 0 to 1\n");
UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIStatus = 1;
UE_rrc_inst[ctxt_pP->module_id].Info[eNB_index].SIB1systemInfoValueTag = sib1->systemInfoValueTag;
......
......@@ -364,7 +364,7 @@ typedef struct UE_RRC_INFO_s {
uint8_t SIwindowsize_MBMS; //!< Corresponds to the SIB1 si-WindowLength parameter. The unit is ms. Possible values are (final): 1,2,5,10,15,20,40
uint8_t handoverTarget;
HO_STATE_t ho_state;
uint16_t SIperiod; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
uint16_t SIperiod ; //!< Corresponds to the SIB1 si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120
uint16_t SIperiod_MBMS; //!< Corresponds to the SIB1-MBMS si-Periodicity parameter (multiplied by 10). Possible values are (final): 80,160,320,640,1280,2560,5120 TODO
unsigned short UE_index;
uint32_t T300_active;
......
......@@ -81,7 +81,12 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length)
LOG_FUNC_IN;
int bytes;
Byte_t** data = NULL;
/* pointers to msg fields possibly not aligned because msg points to a packed structure
* Using these possibly unaligned pointers in a function call may trigger alignment errors at run time and
* gcc, from v9, now warns about it. fix these warnings by removing the indirection on data
* (in fact i don't understand this code data seems to be useless...)
*/
Byte_t *data = NULL;
/* Get the message type */
msg->msgID = *(uint16_t*)(buffer);
......@@ -91,49 +96,49 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length)
case AS_NAS_ESTABLISH_REQ:
/* NAS signalling connection establish request */
bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_req.initialNasMsg.data;
data = msg->msg.nas_establish_req.initialNasMsg.data;
break;
case AS_NAS_ESTABLISH_IND:
/* NAS signalling connection establishment indication */
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_ind.initialNasMsg.data;
data = msg->msg.nas_establish_ind.initialNasMsg.data;
break;
case AS_NAS_ESTABLISH_RSP:
/* NAS signalling connection establishment response */
bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_rsp.nasMsg.data;
data = msg->msg.nas_establish_rsp.nasMsg.data;
break;
case AS_NAS_ESTABLISH_CNF:
/* NAS signalling connection establishment confirm */
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*);
data = &msg->msg.nas_establish_cnf.nasMsg.data;
data = msg->msg.nas_establish_cnf.nasMsg.data;
break;
case AS_UL_INFO_TRANSFER_REQ:
/* Uplink L3 data transfer request */
bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*);
data = &msg->msg.ul_info_transfer_req.nasMsg.data;
data = msg->msg.ul_info_transfer_req.nasMsg.data;
break;
case AS_UL_INFO_TRANSFER_IND:
/* Uplink L3 data transfer indication */
bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*);
data = &msg->msg.ul_info_transfer_ind.nasMsg.data;
data = msg->msg.ul_info_transfer_ind.nasMsg.data;
break;
case AS_DL_INFO_TRANSFER_REQ:
/* Downlink L3 data transfer request */
bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*);
data = &msg->msg.dl_info_transfer_req.nasMsg.data;
data = msg->msg.dl_info_transfer_req.nasMsg.data;
break;
case AS_DL_INFO_TRANSFER_IND:
/* Downlink L3 data transfer indication */
bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*);
data = &msg->msg.dl_info_transfer_ind.nasMsg.data;
data = msg->msg.dl_info_transfer_ind.nasMsg.data;
break;
case AS_BROADCAST_INFO_IND:
......@@ -166,7 +171,8 @@ int as_message_decode(const char* buffer, as_message_t* msg, int length)
if (bytes > 0) {
if (data) {
/* Set the pointer to dedicated NAS information */
*data = (Byte_t*)(buffer + bytes);
/* wasn't data already computed above for specific cases here we override ?? */
data = (Byte_t *)buffer + bytes;
}
/* Decode the message */
......@@ -201,8 +207,10 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
LOG_FUNC_IN;
int bytes = sizeof(msg->msgID);
as_nas_info_t* nas_msg = NULL;
as_nas_info_t nas_msg;
Byte_t *dataptr=NULL;
uint32_t len=0;
switch (msg->msgID) {
case AS_BROADCAST_INFO_IND:
/* Broadcast information */
......@@ -237,25 +245,30 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_NAS_ESTABLISH_REQ:
/* NAS signalling connection establish request */
bytes += sizeof(nas_establish_req_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_req.initialNasMsg;
nas_msg = msg->msg.nas_establish_req.initialNasMsg;
break;
case AS_NAS_ESTABLISH_IND:
/* NAS signalling connection establish indication */
bytes += sizeof(nas_establish_ind_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_ind.initialNasMsg;
nas_msg = msg->msg.nas_establish_ind.initialNasMsg;
dataptr=(Byte_t *)&(msg->msg.nas_establish_ind.initialNasMsg.data);
len=msg->msg.nas_establish_ind.initialNasMsg.length;
break;
case AS_NAS_ESTABLISH_RSP:
/* NAS signalling connection establish response */
bytes += sizeof(nas_establish_rsp_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_rsp.nasMsg;
nas_msg = msg->msg.nas_establish_rsp.nasMsg;
break;
case AS_NAS_ESTABLISH_CNF:
/* NAS signalling connection establish confirm */
bytes += sizeof(nas_establish_cnf_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.nas_establish_cnf.nasMsg;
nas_msg = msg->msg.nas_establish_cnf.nasMsg;
dataptr=(Byte_t *)&(msg->msg.nas_establish_cnf.nasMsg.data);
len=msg->msg.nas_establish_ind.initialNasMsg.length;
break;
case AS_NAS_RELEASE_REQ:
......@@ -271,7 +284,7 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_UL_INFO_TRANSFER_REQ:
/* Uplink L3 data transfer request */
bytes += sizeof(ul_info_transfer_req_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.ul_info_transfer_req.nasMsg;
nas_msg = msg->msg.ul_info_transfer_req.nasMsg;
break;
case AS_UL_INFO_TRANSFER_CNF:
......@@ -282,13 +295,13 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_UL_INFO_TRANSFER_IND:
/* Uplink L3 data transfer indication */
bytes += sizeof(ul_info_transfer_ind_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.ul_info_transfer_ind.nasMsg;
nas_msg = msg->msg.ul_info_transfer_ind.nasMsg;
break;
case AS_DL_INFO_TRANSFER_REQ:
/* Downlink L3 data transfer */
bytes += sizeof(dl_info_transfer_req_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.dl_info_transfer_req.nasMsg;
nas_msg = msg->msg.dl_info_transfer_req.nasMsg;
break;
case AS_DL_INFO_TRANSFER_CNF:
......@@ -299,7 +312,8 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
case AS_DL_INFO_TRANSFER_IND:
/* Downlink L3 data transfer indication */
bytes += sizeof(dl_info_transfer_ind_t) - sizeof(Byte_t*);
nas_msg = &msg->msg.dl_info_transfer_ind.nasMsg;
nas_msg = msg->msg.dl_info_transfer_ind.nasMsg;
break;
case AS_RAB_ESTABLISH_REQ:
......@@ -343,14 +357,14 @@ int as_message_encode(char* buffer, as_message_t* msg, int length)
/* Encode the AS message */
memcpy(buffer, (unsigned char*)msg, bytes);
if ( nas_msg && (nas_msg->length > 0) ) {
if ( (dataptr!=NULL) && (len > 0) ) {
/* Copy the NAS message */
memcpy(buffer + bytes, nas_msg->data, nas_msg->length);
bytes += nas_msg->length;
memcpy(buffer + bytes, nas_msg.data, nas_msg.length);
bytes += len;
/* Release NAS message memory */
free(nas_msg->data);
nas_msg->length = 0;
nas_msg->data = NULL;
free(nas_msg.data);
len=0;
dataptr = NULL;
}
LOG_FUNC_RETURN (bytes);
......
......@@ -136,17 +136,25 @@ static int _emm_as_encrypt(
static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg);
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *,
ul_info_transfer_req_t *);
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *,
nas_establish_req_t *);
static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *);
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, ul_info_transfer_req_t *);
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, ul_info_transfer_req_t *);
static int _emm_as_release_req(const emm_as_release_t *, nas_release_req_t *);
static int _emm_as_cell_info_req(const emm_as_cell_info_t *, cell_info_req_t *);
/* prototyping of the following function modified: the last parameter turned to a void pointer
* instead of a ponter to the union field of the as_msg packed structure. This is to avoid new warnings introduced
* from gcc V9 which warns when accessing fields in a packed structure which may result in an alignment problem
* at run time. Modifications allow gcc to know at compile time that it cannot assume any alignment for those pointers.
* On X86 this is not fatal, as at run time the problem can be fixed (but it's better for perf to avoid). On other
* processor as Arm i think it can end in seg fault
*/
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *,
void *ul_info_transfer_req_unaligned);
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *,
void *nas_establish_req_unaligned);
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg, void *ul_info_transfer_req_unaligned);
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *, void *ul_info_transfer_req_unaligned);
static int _emm_as_release_req(const emm_as_release_t *, void *nas_release_req_unaligned);
/****************************************************************************/
/****************** E X P O R T E D F U N C T I O N S ******************/
......@@ -938,32 +946,32 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
case _EMMAS_DATA_REQ:
as_msg.msgID = _emm_as_data_req(user->emm_data,
&msg->u.data,
&as_msg.msg.ul_info_transfer_req);
(void *)(&as_msg.msg.ul_info_transfer_req));
break;
case _EMMAS_STATUS_IND:
as_msg.msgID = _emm_as_status_ind(user->emm_data,
&msg->u.status,
&as_msg.msg.ul_info_transfer_req);
(void *)(&as_msg.msg.ul_info_transfer_req));
break;
case _EMMAS_RELEASE_REQ:
as_msg.msgID = _emm_as_release_req(
&msg->u.release,
&as_msg.msg.nas_release_req);
(void *)(&as_msg.msg.nas_release_req));
break;
case _EMMAS_SECURITY_RES:
as_msg.msgID = _emm_as_security_res(user->emm_data,
&msg->u.security,
&as_msg.msg.ul_info_transfer_req);
(void *)(&as_msg.msg.ul_info_transfer_req));
break;
case _EMMAS_ESTABLISH_REQ:
as_msg.msgID = _emm_as_establish_req(user->emm_data,
&msg->u.establish,
&as_msg.msg.nas_establish_req);
(void *)(&as_msg.msg.nas_establish_req));
break;
......@@ -1069,10 +1077,10 @@ static int _emm_as_send(const nas_user_t *user, const emm_as_t *msg)
** **
***************************************************************************/
static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg,
ul_info_transfer_req_t *as_msg)
void *ul_info_transfer_req_unaligned)
{
LOG_FUNC_IN;
ul_info_transfer_req_t *as_msg = (ul_info_transfer_req_t *)ul_info_transfer_req_unaligned;
int size = 0;
int is_encoded = FALSE;
......@@ -1165,12 +1173,12 @@ static int _emm_as_data_req(const emm_data_t *emm_data, const emm_as_data_t *msg
** **
***************************************************************************/
static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t *msg,
ul_info_transfer_req_t *as_msg)
void *ul_info_transfer_req_unaligned)
{
LOG_FUNC_IN;
int size = 0;
ul_info_transfer_req_t *as_msg = (ul_info_transfer_req_t *)ul_info_transfer_req_unaligned;
LOG_TRACE(INFO, "EMMAS-SAP - Send AS status indication (cause=%d)",
msg->emm_cause);
......@@ -1239,12 +1247,12 @@ static int _emm_as_status_ind(const emm_data_t *emm_data, const emm_as_status_t
** **
***************************************************************************/
static int _emm_as_release_req(const emm_as_release_t *msg,
nas_release_req_t *as_msg)
void *nas_release_req_unaligned)
{
LOG_FUNC_IN;
LOG_TRACE(INFO, "EMMAS-SAP - Send AS release request");
nas_release_req_t *as_msg = (nas_release_req_t *)nas_release_req_unaligned;
/* Setup the AS message */
if (msg->guti) {
as_msg->s_tmsi.MMEcode = msg->guti->gummei.MMEcode;
......@@ -1279,10 +1287,10 @@ static int _emm_as_release_req(const emm_as_release_t *msg,
** **
***************************************************************************/
static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_security_t *msg,
ul_info_transfer_req_t *as_msg)
void *ul_info_transfer_req_unaligned)
{
LOG_FUNC_IN;
ul_info_transfer_req_t *as_msg=(ul_info_transfer_req_t *)ul_info_transfer_req_unaligned;
int size = 0;
LOG_TRACE(INFO, "EMMAS-SAP - Send AS security response");
......@@ -1373,12 +1381,12 @@ static int _emm_as_security_res(const emm_data_t *emm_data, const emm_as_securit
** **
***************************************************************************/
static int _emm_as_establish_req(const emm_data_t *emm_data, const emm_as_establish_t *msg,
nas_establish_req_t *as_msg)
void *nas_establish_req_unaligned)
{
LOG_FUNC_IN;
int size = 0;
nas_establish_req_t *as_msg = (nas_establish_req_t *)nas_establish_req_unaligned;
LOG_TRACE(INFO, "EMMAS-SAP - Send AS connection establish request");
nas_message_t nas_msg;
......
......@@ -141,11 +141,11 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data)
case AS_CELL_INFO_CNF: {
/* Received cell information confirm */
const cell_info_cnf_t *info = &msg->msg.cell_info_cnf;
int cell_found = (info->errCode == AS_SUCCESS);
rc = nas_proc_cell_info(user, cell_found, info->tac,
info->cellID, info->rat,
info->rsrp, info->rsrq);
/* remove using pointers to fiels of the packed structure msg as it
* triggers warnings with gcc version 9 */
const cell_info_cnf_t info = msg->msg.cell_info_cnf;
int cell_found = (info.errCode == AS_SUCCESS);
rc = nas_proc_cell_info(user, cell_found, info.tac, info.cellID, info.rat, info.rsrp, info.rsrq);
break;
}
......@@ -157,12 +157,12 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data)
case AS_NAS_ESTABLISH_CNF: {
/* Received NAS signalling connection establishment confirm */
const nas_establish_cnf_t *confirm = &msg->msg.nas_establish_cnf;
const nas_establish_cnf_t confirm = msg->msg.nas_establish_cnf;
if ( (confirm->errCode == AS_SUCCESS) ||
(confirm->errCode == AS_TERMINATED_NAS) ) {
rc = nas_proc_establish_cnf(user, confirm->nasMsg.data,
confirm->nasMsg.length);
if ( (confirm.errCode == AS_SUCCESS) ||
(confirm.errCode == AS_TERMINATED_NAS) ) {
rc = nas_proc_establish_cnf(user, confirm.nasMsg.data,
confirm.nasMsg.length);
} else {
LOG_TRACE(WARNING, "NET-MAIN - "
"Initial NAS message not delivered");
......@@ -191,10 +191,10 @@ int nas_network_process_data(nas_user_t *user, int msg_id, const void *data)
break;
case AS_DL_INFO_TRANSFER_IND: {
const dl_info_transfer_ind_t *info = &msg->msg.dl_info_transfer_ind;
const dl_info_transfer_ind_t info = msg->msg.dl_info_transfer_ind;
/* Received downlink data transfer indication */
rc = nas_proc_dl_transfer_ind(user, info->nasMsg.data,
info->nasMsg.length);
rc = nas_proc_dl_transfer_ind(user, info.nasMsg.data,
info.nasMsg.length);
break;
}
......
......@@ -74,6 +74,12 @@ class gtpEndPoint {
int ipVersion;
map<int,teidData_t> ue2te_mapping;
map<int,rntiData_t> te2ue_mapping;
// we use the same port number for source and destination address
// this allow using non standard gtp port number (different from 2152)
// and so, for example tu run 4G and 5G cores on one system
tcp_udp_port_t get_dstport() {
return (tcp_udp_port_t)atol(addr.destinationService);
}
};
class gtpEndPoints {
......@@ -99,6 +105,8 @@ int legacyInstanceMapping=0;
#define compatInst(a) ((a)==0 || (a)==INSTANCE_DEFAULT?legacyInstanceMapping:a)
#define GTPV1U_HEADER_SIZE (8)
static int gtpv1uCreateAndSendMsg(int h, uint32_t peerIp, uint16_t peerPort, teid_t teid, uint8_t *Msg,int msgLen,
bool seqNumFlag, bool npduNumFlag, bool extHdrFlag, int seqNum, int npduNum, int extHdrType) {
AssertFatal(extHdrFlag==false,"Not developped");
......@@ -299,7 +307,6 @@ static int udpServerSocket(openAddr_s addr) {
LOG_E(GTPU,"getaddrinfo error: %s\n", gai_strerror(status));
return -1;
}
int sockfd=-1;
// loop through all the results and bind to the first we can
......@@ -459,17 +466,18 @@ int ocp_gtpv1u_create_s1u_tunnel(instance_t instance,
create_tunnel_req->rnti,
create_tunnel_req->num_tunnels,
create_tunnel_req->sgw_S1u_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
AssertFatal(create_tunnel_req->eps_bearer_id[i] > 4,
"From legacy code not clear, seems impossible (bearer=%d)\n",
create_tunnel_req->eps_bearer_id[i]);
int incoming_rb_id=create_tunnel_req->eps_bearer_id[i]-4;
teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti,
incoming_rb_id,
create_tunnel_req->eps_bearer_id[i],
create_tunnel_req->sgw_S1u_teid[i],
create_tunnel_req->sgw_addr[i], 2152,
create_tunnel_req->sgw_addr[i], dstport,
pdcp_data_req);
create_tunnel_resp->status=0;
create_tunnel_resp->rnti=create_tunnel_req->rnti;
......@@ -525,13 +533,13 @@ int gtpv1u_create_ngu_tunnel( const instance_t instance,
create_tunnel_req->rnti,
create_tunnel_req->num_tunnels,
create_tunnel_req->upf_NGu_teid[0]);
tcp_udp_port_t dstport=globGtp.instances[compatInst(instance)].get_dstport();
for (int i = 0; i < create_tunnel_req->num_tunnels; i++) {
teid_t teid=newGtpuCreateTunnel(compatInst(instance), create_tunnel_req->rnti,
create_tunnel_req->incoming_rb_id[i],
create_tunnel_req->pdusession_id[i],
create_tunnel_req->upf_NGu_teid[i],
create_tunnel_req->upf_addr[i], 2152,
create_tunnel_req->upf_addr[i], dstport,
pdcp_data_req);
create_tunnel_resp->status=0;
create_tunnel_resp->rnti=create_tunnel_req->rnti;
......@@ -869,6 +877,7 @@ void *ocp_gtpv1uTask(void *args) {
// to be dev: should be removed, to use API
strcpy(addr.originHost, GTPV1U_ENB_S1_REQ(message_p).addrStr);
strcpy(addr.originService, GTPV1U_ENB_S1_REQ(message_p).portStr);
strcpy(addr.destinationService,addr.originService);
AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n");
break;
......@@ -876,6 +885,7 @@ void *ocp_gtpv1uTask(void *args) {
// to be dev: should be removed, to use API
strcpy(addr.originHost, GTPV1U_ENB_S1_REQ(message_p).addrStr);
strcpy(addr.originService, GTPV1U_ENB_S1_REQ(message_p).portStr);
strcpy(addr.destinationService,addr.originService);
AssertFatal((legacyInstanceMapping=ocp_gtpv1Init(addr))!=0,"Instance 0 reserved for legacy\n");
break;
......
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