Commit bbe79b5b authored by hardy's avatar hardy

Merge remote-tracking branch 'origin/NR_UE_Capabilities' into integration_2022_wk03_b

parents b0d462e0 2ded9658
......@@ -89,6 +89,8 @@ At the UE the --phy-test flag will
```bash sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --phy-test```
In phy-test mode it is possible to mimic the reception of UE Capabilities at gNB by passing through the command line parameter `--uecap_file` the location and file name of the input UE Capability file, e.g. `--uecap_file ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml`
### Launch UE in another window
```bash sudo ./nr-uesoftmodem --phy-test [--rrc_config_path ../../../ci-scripts/rrc-files]```
......@@ -122,6 +124,8 @@ gNB on machine 1:
`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-LTE-EPC/CONF/gnb.band78.tm1.106PRB.usrpn300.conf --do-ra`
In do-ra mode it is possible to mimic the reception of UE Capabilities at gNB by passing through the command line parameter `--uecap_file` the location and file name of the input UE Capability file, e.g. `--uecap_file ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml`
UE on machine 2:
`sudo ./nr-uesoftmodem --do-ra`
......@@ -161,13 +165,17 @@ gNB on machine 1:
UE on machine 2:
`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --sa`
`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 -s 516 --sa`
With the RF simulator (on the same machine):
`sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/gnb.sa.band78.fr1.106PRB.usrpb210.conf --rfsim --sa`
`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 --rfsim --sa`
`sudo ./nr-uesoftmodem -r 106 --numerology 1 --band 78 -C 3619200000 -s 516 --rfsim --sa`
where `-r` sets the transmission bandwidth configuration in terms of RBs, `-C` sets the downlink carrier frequency and `-s` sets the SSB start subcarrier.
Additionally, at UE side `--uecap_file` option can be used to pass the UE Capabilities input file (path location + filename), e.g. `--uecap_file ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/uecap.xml`
## IF setup with OAI
......
......@@ -89,6 +89,7 @@
#define CONFIG_HLP_DISABLNBIOT "disable nb-iot, even if defined in config\n"
#define CONFIG_HLP_DISABLETIMECORR "disable UE timing correction\n"
#define CONFIG_HLP_RRC_CFG_PATH "path for RRC configuration\n"
#define CONFIG_HLP_UECAP_FILE "path for UE Capabilities file\n"
#define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n"
#define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n"
......
......@@ -111,16 +111,11 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
//Temp fix for inexistent NR upper layer
unsigned char NB_gNB_INST = 1;
char *uecap_file;
int UE_scan = 1;
int UE_scan_carrier = 0;
runmode_t mode = normal_txrx;
static double snr_dB=20;
FILE *input_fd=NULL;
#if MAX_NUM_CCs == 1
rx_gain_t rx_gain_mode[MAX_NUM_CCs][4] = {{max_gain,max_gain,max_gain,max_gain}};
double tx_gain[MAX_NUM_CCs][4] = {{20,0,0,0}};
......@@ -193,8 +188,6 @@ openair0_config_t openair0_cfg[MAX_CARDS];
double cpuf;
extern char uecap_xer[1024];
char uecap_xer_in=0;
/* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed
* this is very hackish - find a proper solution
......@@ -710,6 +703,7 @@ int main( int argc, char **argv ) {
// don't create if node doesn't connect to RRC/S1/GTP
int ret=create_gNB_tasks(1);
AssertFatal(ret==0,"cannot create ITTI tasks\n");
/* Start the agent. If it is turned off in the configuration, it won't start */
/*
RCconfig_nr_flexran();
......
......@@ -29,6 +29,7 @@
{"D" , CONFIG_HLP_DLBM_PHYTEST,0, u64ptr:&dlsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \
{"U" , CONFIG_HLP_ULBM_PHYTEST,0, u64ptr:&ulsch_slot_bitmap, defintval:0, TYPE_UINT64, 0}, \
{"usrp-tx-thread-config", CONFIG_HLP_USRP_THREAD, 0, iptr:&usrp_tx_thread, defstrval:0, TYPE_INT, 0}, \
{"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \
{"s" , CONFIG_HLP_SNR, 0, dblptr:&snr_dB, defdblval:25, TYPE_DOUBLE, 0}, \
}
......@@ -41,6 +42,7 @@ extern uint32_t target_dl_bw;
extern uint32_t target_ul_bw;
extern uint64_t dlsch_slot_bitmap;
extern uint64_t ulsch_slot_bitmap;
extern char *uecap_file;
// In nr-gnb.c
extern void init_gNB(int single_thread_flag,int wait_for_sync);
......
......@@ -1140,13 +1140,15 @@ void *UE_thread(void *arg) {
return NULL;
}
void init_NR_UE(int nb_inst, char* rrc_config_path) {
void init_NR_UE(int nb_inst,
char* uecap_file,
char* rrc_config_path) {
int inst;
NR_UE_MAC_INST_t *mac_inst;
NR_UE_RRC_INST_t* rrc_inst;
for (inst=0; inst < nb_inst; inst++) {
AssertFatal((rrc_inst = nr_l3_init_ue(rrc_config_path)) != NULL, "can not initialize RRC module\n");
AssertFatal((rrc_inst = nr_l3_init_ue(uecap_file,rrc_config_path)) != NULL, "can not initialize RRC module\n");
AssertFatal((mac_inst = nr_l2_init_ue(rrc_inst)) != NULL, "can not initialize L2 module\n");
AssertFatal((mac_inst->if_module = nr_ue_if_module_init(inst)) != NULL, "can not initialize IF module\n");
}
......
......@@ -118,6 +118,7 @@ int vcdflag = 0;
double rx_gain_off = 0.0;
char *usrp_args = NULL;
char *rrc_config_path = NULL;
char *uecap_file = NULL;
int dumpframe = 0;
uint64_t downlink_frequency[MAX_NUM_CCs][4];
......@@ -150,8 +151,6 @@ int numerology = 0;
int oaisim_flag = 0;
int emulate_rf = 0;
uint32_t N_RB_DL = 106;
char uecap_xer_in = 0;
char uecap_xer[1024];
/* see file openair2/LAYER2/MAC/main.c for why abstraction_flag is needed
* this is very hackish - find a proper solution
......@@ -264,14 +263,6 @@ static void get_options(void) {
if (vcdflag > 0)
ouput_vcd = 1;
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) {
// Here the configuration file is the XER encoded UE capabilities
// Read it in and store in asn1c data structures
sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME"));
printf("%s\n",uecap_xer);
uecap_xer_in=1;
} /* UE with config file */
}
// set PHY vars from command line
......@@ -454,7 +445,7 @@ int main( int argc, char **argv ) {
#endif
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
init_NR_UE(1,rrc_config_path);
init_NR_UE(1,uecap_file,rrc_config_path);
int mode_offset = get_softmodem_params()->nsa ? NUMBER_OF_UE_MAX : 1;
uint16_t node_number = get_softmodem_params()->node_number;
......
......@@ -34,6 +34,7 @@
{"offset-divisor", CONFIG_HLP_OFFSET_DIV, 0, uptr:(uint32_t *)&nrUE_params.ofdm_offset_divisor, defuintval:UINT_MAX, TYPE_UINT32, 0}, \
{"nr-dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&nr_dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \
{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&vcdflag, defintval:0, TYPE_INT, 0}, \
{"uecap_file", CONFIG_HLP_UECAP_FILE, 0, strptr:(char **)&uecap_file, defstrval:"./uecap.xml", TYPE_STRING, 0}, \
{"rrc_config_path", CONFIG_HLP_RRC_CFG_PATH,0, strptr:(char **)&rrc_config_path, defstrval:"./", TYPE_STRING, 0}, \
{"ue-idx-standalone", NULL, 0, u16ptr:&ue_idx_standalone, defuintval:0xFFFF, TYPE_UINT16, 0} \
}
......@@ -85,7 +86,7 @@ extern nrUE_params_t *get_nrUE_params(void);
// In nr-ue.c
extern int setup_nr_ue_buffers(PHY_VARS_NR_UE **phy_vars_ue, openair0_config_t *openair0_cfg);
extern void fill_ue_band_info(void);
extern void init_NR_UE(int, char*);
extern void init_NR_UE(int, char*, char*);
extern void init_NR_UE_threads(int);
extern void reset_opp_meas(void);
extern void print_opp_meas(void);
......
......@@ -522,6 +522,8 @@ typedef struct gNB_RRC_INST_s {
int cell_info_configured;
pthread_mutex_t cell_info_mutex;
char *uecap_file;
// security configuration (preferred algorithms)
nr_security_configuration_t security;
} gNB_RRC_INST;
......
......@@ -202,49 +202,6 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration
pthread_mutex_unlock(&rrc->cell_info_mutex);
if (get_softmodem_params()->phy_test > 0 || get_softmodem_params()->do_ra > 0) {
// This is for phytest only, emulate first X2 message if uecap.raw file is present
FILE *fd;
fd = fopen("uecap.raw","r");
if (fd != NULL) {
char buffer[4096];
int msg_len=fread(buffer,1,4096,fd);
LOG_I(RRC,"Read in %d bytes for uecap\n",msg_len);
LTE_UL_DCCH_Message_t *LTE_UL_DCCH_Message;
asn_dec_rval_t dec_rval = uper_decode_complete( NULL,
&asn_DEF_LTE_UL_DCCH_Message,
(void **)&LTE_UL_DCCH_Message,
(uint8_t *)buffer,
msg_len);
if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) {
AssertFatal(1==0,"NR_UL_DCCH_MESSAGE decode error\n");
// free the memory
SEQUENCE_free( &asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message, 1 );
return;
}
fclose(fd);
xer_fprint(stdout,&asn_DEF_LTE_UL_DCCH_Message, LTE_UL_DCCH_Message);
// recreate enough of X2 EN-DC Container
AssertFatal(LTE_UL_DCCH_Message->message.choice.c1.present == LTE_UL_DCCH_MessageType__c1_PR_ueCapabilityInformation,
"ueCapabilityInformation not present\n");
NR_CG_ConfigInfo_t *CG_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo));
CG_ConfigInfo->criticalExtensions.present = NR_CG_ConfigInfo__criticalExtensions_PR_c1;
CG_ConfigInfo->criticalExtensions.choice.c1 = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1));
CG_ConfigInfo->criticalExtensions.choice.c1->present = NR_CG_ConfigInfo__criticalExtensions__c1_PR_cg_ConfigInfo;
CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo = calloc(1,sizeof(*CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo));
NR_CG_ConfigInfo_IEs_t *cg_ConfigInfo = CG_ConfigInfo->criticalExtensions.choice.c1->choice.cg_ConfigInfo;
cg_ConfigInfo->ue_CapabilityInfo = calloc(1,sizeof(*cg_ConfigInfo->ue_CapabilityInfo));
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_LTE_UE_CapabilityRAT_ContainerList,NULL,
(void *)&LTE_UL_DCCH_Message->message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList,buffer,4096);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
OCTET_STRING_fromBuf(cg_ConfigInfo->ue_CapabilityInfo,
(const char *)buffer,
(enc_rval.encoded+7)>>3);
parse_CG_ConfigInfo(rrc,CG_ConfigInfo,NULL);
} else {
struct rrc_gNB_ue_context_s *ue_context_p = rrc_gNB_allocate_new_UE_context(rrc);
ue_context_p->ue_context.spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig));
ue_context_p->ue_context.spCellConfig->spCellConfigDedicated = configuration->scd;
......@@ -253,7 +210,6 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration
rrc_add_nsa_user(rrc,ue_context_p,NULL);
}
}
}
}
char openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_RrcConfigurationReq *configuration) {
......
......@@ -38,6 +38,7 @@
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
#include "openair2/RRC/LTE/rrc_eNB_GTPV1U.h"
#include "executables/softmodem-common.h"
#include "executables/nr-softmodem.h"
#include <openair2/RRC/NR/rrc_gNB_UE_context.h>
#include <openair3/ocp-gtpu/gtp_itf.h>
#include "UTIL/OSA/osa_defs.h"
......@@ -143,6 +144,30 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc,struct rrc_gNB_ue_context_s *ue_context_
unsigned char *kUPenc = NULL;
unsigned char *kUPint = NULL;
int i;
// In case of phy-test and do-ra mode, read UE capabilities directly from file
if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1) {
NR_UE_NR_Capability_t* UE_Capability_nr = NULL;
char UE_NR_Capability_xer[65536];
FILE *f = NULL;
if (uecap_file)
f = fopen(uecap_file, "r");
if(f){
size_t size = fread(UE_NR_Capability_xer, 1, sizeof UE_NR_Capability_xer, f);
if (size == 0 || size == sizeof UE_NR_Capability_xer)
LOG_E(NR_RRC,"UE Capabilities XER file %s is too large (%ld)\n", uecap_file, size);
else {
UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t));
asn_dec_rval_t dec_rval = xer_decode(0, &asn_DEF_NR_UE_NR_Capability, (void *)&UE_Capability_nr, UE_NR_Capability_xer, size);
assert(dec_rval.code == RC_OK);
xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr);
}
}
else
LOG_E(NR_RRC,"Could not open UE Capabilities input file. Not handling OAI UE Capabilities.\n");
ue_context_p->ue_context.UE_Capability_nr = UE_Capability_nr;
}
// NR RRCReconfiguration
AssertFatal(rrc->Nb_ue < MAX_NR_RRC_UE_CONTEXTS,"cannot add another UE\n");
ue_context_p->ue_context.reconfig = calloc(1,sizeof(NR_RRCReconfiguration_t));
......
......@@ -34,8 +34,8 @@
#include "rrc_proto.h"
#include "common/utils/LOG/log.h"
NR_UE_RRC_INST_t* nr_l3_init_ue(char* rrc_config_path){
NR_UE_RRC_INST_t* nr_l3_init_ue(char* uecap, char* rrc_config_path){
//LOG_I(RRC, "[MAIN] NR UE MAC initialization...\n");
return openair_rrc_top_init_ue_nr(rrc_config_path);
return openair_rrc_top_init_ue_nr(uecap,rrc_config_path);
}
......@@ -422,7 +422,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type,
}
NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){
NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* uecap_file, char* rrc_config_path){
int nr_ue;
if(NB_NR_UE_INST > 0){
NR_UE_rrc_inst = (NR_UE_RRC_INST_t *)calloc(NB_NR_UE_INST , sizeof(NR_UE_RRC_INST_t));
......@@ -496,6 +496,8 @@ NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char* rrc_config_path){
RRC_LIST_INIT(NR_UE_rrc_inst[nr_ue].CSI_ReportConfig_list, NR_maxNrofCSI_ReportConfigurations);
}
NR_UE_rrc_inst->uecap_file = uecap_file;
if (get_softmodem_params()->phy_test==1 || get_softmodem_params()->do_ra==1) {
// read in files for RRCReconfiguration and RBconfig
FILE *fd;
......@@ -2634,14 +2636,18 @@ nr_rrc_ue_process_ueCapabilityEnquiry(
//-----------------------------------------------------------------------------
{
asn_enc_rval_t enc_rval;
asn_dec_rval_t dec_rval;
NR_UL_DCCH_Message_t ul_dcch_msg;
NR_UE_CapabilityRAT_Container_t ue_CapabilityRAT_Container;
char UE_NR_Capability_xer[65536];
size_t size;
uint8_t buffer[200];
int i;
LOG_I(NR_RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing UECapabilityEnquiry (gNB %d)\n",
ctxt_pP->module_id,
ctxt_pP->frame,
gNB_index);
memset((void *)&ul_dcch_msg,0,sizeof(NR_UL_DCCH_Message_t));
memset((void *)&ue_CapabilityRAT_Container,0,sizeof(NR_UE_CapabilityRAT_Container_t));
ul_dcch_msg.message.present = NR_UL_DCCH_MessageType_PR_c1;
......@@ -2650,20 +2656,35 @@ nr_rrc_ue_process_ueCapabilityEnquiry(
ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation = CALLOC(1, sizeof(struct NR_UECapabilityInformation));
ul_dcch_msg.message.choice.c1->choice.ueCapabilityInformation->rrc_TransactionIdentifier = UECapabilityEnquiry->rrc_TransactionIdentifier;
ue_CapabilityRAT_Container.rat_Type = NR_RAT_Type_nr;
NR_UE_NR_Capability_t* UE_Capability_nr;
NR_UE_NR_Capability_t* UE_Capability_nr = NULL;
char *file_path = NR_UE_rrc_inst[ctxt_pP->module_id].uecap_file;
FILE *f = NULL;
if (file_path)
f = fopen(file_path, "r");
if(f){
size = fread(UE_NR_Capability_xer, 1, sizeof UE_NR_Capability_xer, f);
if (size == 0 || size == sizeof UE_NR_Capability_xer) {
LOG_E(NR_RRC,"UE Capabilities XER file %s is too large (%ld)\n", file_path,size);
free(UE_Capability_nr);
return;
}
dec_rval = xer_decode(0, &asn_DEF_NR_UE_NR_Capability, (void *)&UE_Capability_nr, UE_NR_Capability_xer, size);
assert(dec_rval.code == RC_OK);
}
else {
UE_Capability_nr = CALLOC(1,sizeof(NR_UE_NR_Capability_t));
NR_BandNR_t *nr_bandnr;
nr_bandnr = CALLOC(1,sizeof(NR_BandNR_t));
nr_bandnr->bandNR = 1;
ASN_SEQUENCE_ADD(
&UE_Capability_nr->rf_Parameters.supportedBandListNR.list,
ASN_SEQUENCE_ADD(&UE_Capability_nr->rf_Parameters.supportedBandListNR.list,
nr_bandnr);
}
OAI_NR_UECapability_t *UECap;
UECap = CALLOC(1,sizeof(OAI_NR_UECapability_t));
UECap->UE_NR_Capability = UE_Capability_nr;
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout,&asn_DEF_NR_UE_NR_Capability,(void *)UE_Capability_nr);
}
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_UE_NR_Capability,
NULL,
......
......@@ -70,7 +70,7 @@ typedef enum {
nr_RadioBearerConfigX_r15=1
} nsa_message_t;
#define MAX_UE_NR_CAPABILITY_SIZE 255
#define MAX_UE_NR_CAPABILITY_SIZE 2048
typedef struct OAI_NR_UECapability_s {
uint8_t sdu[MAX_UE_NR_CAPABILITY_SIZE];
uint8_t sdu_size;
......@@ -120,6 +120,8 @@ typedef struct NR_UE_RRC_INST_s {
NR_DRB_ToAddMod_t *DRB_config[NB_CNX_UE][8];
rb_id_t *defaultDRB; // remember the ID of the default DRB
char *uecap_file;
NR_SRB_INFO Srb0[NB_SIG_CNX_UE];
NR_SRB_INFO_TABLE_ENTRY Srb1[NB_CNX_UE];
NR_SRB_INFO_TABLE_ENTRY Srb2[NB_CNX_UE];
......
......@@ -56,14 +56,14 @@ extern queue_t nr_wait_ul_tti_req_queue;
// main_rrc.c
//
/**\brief Layer 3 initialization*/
NR_UE_RRC_INST_t* nr_l3_init_ue(char*);
NR_UE_RRC_INST_t* nr_l3_init_ue(char*,char*);
//
// UE_rrc.c
//
/**\brief Initial the top level RRC structure instance*/
NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*);
NR_UE_RRC_INST_t* openair_rrc_top_init_ue_nr(char*,char*);
......
This diff is collapsed.
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