Merge branch 'episys/master' into episys-merge
Conflicts: common/utils/LOG/log.h common/utils/ocp_itti/intertask_interface.cpp nfapi/oai_integration/nfapi_vnf.c nfapi/open-nFAPI/nfapi/src/nfapi.c openair2/LAYER2/MAC/main_ue.c openair2/LAYER2/PDCP_v10.1.0/pdcp.c openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c openair2/PHY_INTERFACE/phy_stub_UE.c openair2/RRC/LTE/rrc_UE.c openair2/RRC/LTE/rrc_eNB.c openair3/NAS/UE/ESM/esm_ebr_context.c targets/COMMON/openairinterface5g_limits.h targets/RT/USER/lte-softmodem.c targets/RT/USER/lte-uesoftmodem.c
This commit is contained in:
@@ -73,8 +73,8 @@
|
||||
#define MAX_eNB 2
|
||||
#define MAX_gNB 2
|
||||
#else
|
||||
#define MAX_MOBILES_PER_ENB 4
|
||||
#define MAX_MOBILES_PER_ENB_NB_IoT 4
|
||||
#define MAX_MOBILES_PER_ENB 40
|
||||
#define MAX_MOBILES_PER_ENB_NB_IoT 40
|
||||
#define MAX_MOBILES_PER_GNB 2//16
|
||||
#define MAX_eNB 2
|
||||
#define MAX_gNB 2
|
||||
|
||||
@@ -720,7 +720,7 @@ int DU_send_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
|
||||
LOG_E(F1AP, "Did not find the UE context associated with UE RNTOI %x, ue_context_p is NULL\n", rnti);
|
||||
|
||||
} else {
|
||||
LOG_I(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti);
|
||||
LOG_A(F1AP, "Processing RRCConnectionSetupComplete UE %x\n", rnti);
|
||||
ue_context_p->ue_context.Status = RRC_CONNECTED;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -798,7 +798,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP,
|
||||
RC.mac[Mod_idP]->common_channels[CC_idP].Ncp = Ncp;
|
||||
RC.mac[Mod_idP]->common_channels[CC_idP].eutra_band = eutra_band;
|
||||
RC.mac[Mod_idP]->common_channels[CC_idP].dl_CarrierFreq = dl_CarrierFreq;
|
||||
LOG_I(MAC,
|
||||
LOG_A(MAC,
|
||||
"Configuring MIB for instance %d, CCid %d : (band %d,N_RB_DL %d,Nid_cell %d,p %d,DL freq %u,phich_config.resource %d, phich_config.duration %d)\n",
|
||||
Mod_idP,
|
||||
CC_idP,
|
||||
@@ -1065,7 +1065,7 @@ int rrc_mac_config_req_eNB(module_id_t Mod_idP,
|
||||
while(RC.mac[Mod_idP]->if_inst->PHY_config_req == NULL) {
|
||||
// DJP AssertFatal(RC.mac[Mod_idP]->if_inst->PHY_config_req != NULL,"if_inst->phy_config_request is null\n");
|
||||
usleep(100 * 1000);
|
||||
printf("Waiting for PHY_config_req\n");
|
||||
LOG_I(MAC, "Waiting for PHY_config_req\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP,
|
||||
LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
|
||||
}
|
||||
|
||||
if(NFAPI_MODE != NFAPI_UE_STUB_PNF)
|
||||
if(NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF)
|
||||
phy_config_harq_ue(Mod_idP, 0, eNB_index, UE_mac_inst[Mod_idP].scheduling_info.maxHARQ_Tx);
|
||||
|
||||
if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) {
|
||||
@@ -311,7 +311,7 @@ rrc_mac_config_req_ue(module_id_t Mod_idP,
|
||||
}
|
||||
|
||||
if (physicalConfigDedicated != NULL) {
|
||||
if(NFAPI_MODE != NFAPI_UE_STUB_PNF)
|
||||
if(NFAPI_MODE != NFAPI_UE_STUB_PNF && NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF)
|
||||
phy_config_dedicated_ue(Mod_idP, 0, eNB_index,
|
||||
physicalConfigDedicated);
|
||||
|
||||
|
||||
@@ -313,6 +313,7 @@ schedule_SR (module_id_t module_idP,
|
||||
nfapi_ul_config_request_body_t *ul_req_body = NULL;
|
||||
LTE_SchedulingRequestConfig_t *SRconfig = NULL;
|
||||
nfapi_ul_config_sr_information sr;
|
||||
memset(&sr, 0, sizeof(sr));
|
||||
|
||||
for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
|
||||
eNB->UL_req[CC_id].sfn_sf = (frameP << 4) + subframeP;
|
||||
@@ -576,6 +577,27 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP,
|
||||
UE_sched_ctrl_t *UE_scheduling_control = NULL;
|
||||
start_meas(&(eNB->eNB_scheduler));
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, VCD_FUNCTION_IN);
|
||||
// TODO: Better solution needed this is the first
|
||||
// 3 indications of this function on startup
|
||||
// 1303275.278188 [MAC] XXX 0.0 -> 0.4 = 4
|
||||
// 1303275.279443 [MAC] XXX 0.4 -> 639.5 = 6391
|
||||
// 1303275.348686 [MAC] XXX 646.3 -> 646.3 = 0
|
||||
int delta = (frameP * 10 + subframeP) - (eNB->frame * 10 + eNB->subframe);
|
||||
if (delta < 0)
|
||||
{
|
||||
delta += 10240; // sfn_sf decimal values range from 0 to 10239
|
||||
}
|
||||
// If we ever see a difference this big something is very wrong
|
||||
// This threshold is arbitrary
|
||||
if (delta > 8500 || delta == 0) // 850 frames
|
||||
{
|
||||
LOG_I(MAC, "scheduler ignoring outerspace %d.%d -> %d.%d = %d\n",
|
||||
eNB->frame, eNB->subframe, frameP, subframeP, delta);
|
||||
return;
|
||||
}
|
||||
LOG_I(MAC, "Entering dlsch_ulsch scheduler %d.%d -> %d.%d = %d\n",
|
||||
eNB->frame, eNB->subframe, frameP, subframeP, delta);
|
||||
|
||||
eNB->frame = frameP;
|
||||
eNB->subframe = subframeP;
|
||||
|
||||
|
||||
@@ -918,7 +918,7 @@ generate_Msg4(module_id_t module_idP,
|
||||
module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);
|
||||
// AssertFatal(rrc_sdu_length > 0,
|
||||
// "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length);
|
||||
LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n",
|
||||
LOG_A(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n",
|
||||
module_idP, CC_idP, frameP, subframeP, ra->rnti);
|
||||
/// Choose first 4 RBs for Msg4, should really check that these are free!
|
||||
first_rb = 0;
|
||||
@@ -1288,7 +1288,7 @@ initiate_ra_proc(module_id_t module_idP,
|
||||
prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
|
||||
}
|
||||
|
||||
LOG_D(MAC,
|
||||
LOG_I(MAC,
|
||||
"[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n",
|
||||
module_idP, CC_id, frameP, subframeP, preamble_index);
|
||||
LOG_D(MAC,
|
||||
|
||||
@@ -289,7 +289,7 @@ PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id,
|
||||
UE_MODE_t UE_mode;
|
||||
|
||||
// Modification for phy_stub_ue operation
|
||||
if(NFAPI_MODE == NFAPI_UE_STUB_PNF) { // phy_stub_ue mode
|
||||
if(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) { // phy_stub_ue mode
|
||||
UE_mode = UE_mac_inst[module_idP].UE_mode[0];
|
||||
LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode);
|
||||
} else { // Full stack mode
|
||||
|
||||
@@ -67,6 +67,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra
|
||||
LOG_D(PHY, "Found RAR with the intended RAPID %d\n",
|
||||
rarh->RAPID);
|
||||
rar = (uint8_t *) (dlsch_buffer + n_rarh + (n_rarpy - 1) * 6);
|
||||
UE_mac_inst[module_idP].UE_mode[0] = RA_RESPONSE;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,9 +78,10 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra
|
||||
}
|
||||
|
||||
if (rarh->E == 0) {
|
||||
LOG_I(PHY,
|
||||
LOG_I(MAC,
|
||||
"No RAR found with the intended RAPID. The closest RAPID in all RARs is %d\n",
|
||||
best_rx_rapid);
|
||||
UE_mac_inst[module_idP].UE_mode[0] = PRACH;
|
||||
break;
|
||||
} else {
|
||||
rarh++;
|
||||
@@ -94,7 +96,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra
|
||||
return (0xffff);
|
||||
}
|
||||
|
||||
LOG_I(MAC,
|
||||
LOG_A(MAC,
|
||||
"[UE %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",
|
||||
module_idP, frameP, *(uint8_t *) rarh, rar[0], rar[1], rar[2],
|
||||
rar[3], rar[4], rar[5], rarh->RAPID, preamble_index);
|
||||
@@ -130,7 +132,7 @@ uint16_t ue_process_rar(const module_id_t module_idP, const int CC_id, const fra
|
||||
}
|
||||
|
||||
// move the selected RAR to the front of the RA_PDSCH buffer
|
||||
memcpy(selected_rar_buffer + 0, (uint8_t *) rarh, 1);
|
||||
memcpy(selected_rar_buffer + 1, (uint8_t *) rar, 6);
|
||||
memmove(selected_rar_buffer + 0, (uint8_t *) rarh, 1);
|
||||
memmove(selected_rar_buffer + 1, (uint8_t *) rar, 6);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -156,15 +156,13 @@ void ue_init_mac(module_id_t module_idP) {
|
||||
UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0;
|
||||
}
|
||||
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) {
|
||||
pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL);
|
||||
UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH;
|
||||
UE_mac_inst[module_idP].UE_mode[0] = PRACH; //NOT_SYNCHED;
|
||||
UE_mac_inst[module_idP].first_ULSCH_Tx =0;
|
||||
UE_mac_inst[module_idP].SI_Decoded = 0;
|
||||
next_ra_frame = 0;
|
||||
next_Mod_id = 0;
|
||||
tx_request_pdu_list = NULL;
|
||||
tx_req_num_elems = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -418,7 +416,7 @@ ue_send_sdu(module_id_t module_idP,
|
||||
|
||||
if (payload_ptr != NULL) {
|
||||
for (i = 0; i < num_ce; i++) {
|
||||
// printf("ce %d : %d\n",i,rx_ces[i]);
|
||||
LOG_I(MAC, "ce %d : %d\n",i,rx_ces[i]);
|
||||
switch (rx_ces[i]) {
|
||||
case UE_CONT_RES:
|
||||
LOG_I(MAC,
|
||||
@@ -443,7 +441,7 @@ ue_send_sdu(module_id_t module_idP,
|
||||
"[UE %d][RAPROC] Contention detected, RA failed\n",
|
||||
module_idP);
|
||||
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // phy_stub mode
|
||||
// Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to
|
||||
// PRACH state.
|
||||
LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n");
|
||||
@@ -469,7 +467,7 @@ ue_send_sdu(module_id_t module_idP,
|
||||
[module_idP].
|
||||
RA_contention_resolution_timer_active = 0;
|
||||
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // phy_stub mode
|
||||
// Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH
|
||||
UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH;
|
||||
} else { // Full stack mode
|
||||
@@ -487,7 +485,7 @@ ue_send_sdu(module_id_t module_idP,
|
||||
#endif
|
||||
|
||||
// Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct?
|
||||
if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
|
||||
if (NFAPI_MODE!=NFAPI_UE_STUB_PNF && NFAPI_MODE!=NFAPI_MODE_STANDALONE_PNF) {
|
||||
process_timing_advance(module_idP,CC_id,payload_ptr[0]);
|
||||
}
|
||||
|
||||
@@ -2747,7 +2745,7 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
|
||||
|
||||
// build PHR and update the timers
|
||||
if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) {
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) {
|
||||
//Substitute with a static value for the MAC layer abstraction (phy_stub mode)
|
||||
phr_p->PH = 60;
|
||||
} else {
|
||||
@@ -3198,7 +3196,7 @@ ue_scheduler(const module_id_t module_idP,
|
||||
"Module id %u Contention resolution timer expired, RA failed\n",
|
||||
module_idP);
|
||||
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode
|
||||
if(NFAPI_MODE==NFAPI_UE_STUB_PNF || NFAPI_MODE==NFAPI_MODE_STANDALONE_PNF) { // phy_stub mode
|
||||
// Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to
|
||||
// PRACH state.
|
||||
LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n");
|
||||
|
||||
@@ -986,7 +986,7 @@ pdcp_data_ind(
|
||||
* for the UE compiled in noS1 mode, we need 0
|
||||
* TODO: be sure of this
|
||||
*/
|
||||
if (NFAPI_MODE == NFAPI_UE_STUB_PNF ) {
|
||||
if (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
|
||||
pdcpHead->inst = ctxt_pP->module_id;
|
||||
} else { // nfapi_mode
|
||||
if (UE_NAS_USE_TUN) {
|
||||
@@ -2251,7 +2251,7 @@ void pdcp_set_pdcp_data_ind_func(pdcp_data_ind_func_t pdcp_data_ind) {
|
||||
pdcp_params.pdcp_data_ind_func = pdcp_data_ind;
|
||||
}
|
||||
|
||||
uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
|
||||
uint64_t pdcp_module_init( uint64_t pdcp_optmask, int id) {
|
||||
/* temporary enforce netlink when UE_NAS_USE_TUN is set,
|
||||
this is while switching from noS1 as build option
|
||||
to noS1 as config option */
|
||||
@@ -2268,18 +2268,18 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
|
||||
nas_getparams();
|
||||
|
||||
if(UE_NAS_USE_TUN) {
|
||||
int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )? MAX_MOBILES_PER_ENB : 1;
|
||||
int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)? MAX_MOBILES_PER_ENB : 1;
|
||||
netlink_init_tun("ue",num_if);
|
||||
if (IS_SOFTMODEM_NOS1)
|
||||
nas_config(1, 1, 2, "ue");
|
||||
netlink_init_mbms_tun("uem");
|
||||
nas_config(1, 1, 2, "ue");
|
||||
netlink_init_mbms_tun("uem", id);
|
||||
nas_config_mbms(1, 2, 2, "uem");
|
||||
LOG_I(PDCP, "UE pdcp will use tun interface\n");
|
||||
} else if(ENB_NAS_USE_TUN) {
|
||||
netlink_init_tun("enb",1);
|
||||
netlink_init_tun("enb", 1, 0);
|
||||
nas_config(1, 1, 1, "enb");
|
||||
if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){
|
||||
netlink_init_mbms_tun("enm");
|
||||
netlink_init_mbms_tun("enm", 0);
|
||||
nas_config_mbms(1, 2, 1, "enm");
|
||||
LOG_I(PDCP, "ENB pdcp will use mbms tun interface\n");
|
||||
}
|
||||
@@ -2291,8 +2291,8 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
|
||||
}else{
|
||||
if(pdcp_optmask & ENB_NAS_USE_TUN_W_MBMS_BIT){
|
||||
LOG_W(PDCP, "ENB pdcp will use tun interface for MBMS\n");
|
||||
netlink_init_mbms_tun("enm");
|
||||
nas_config_mbms_s1(1, 2, 1, "enm");
|
||||
netlink_init_mbms_tun("enm", 1);
|
||||
nas_config_mbms_s1(1, 2, 1, "enm");
|
||||
}else
|
||||
LOG_E(PDCP, "ENB pdcp will not use tun interface\n");
|
||||
}
|
||||
|
||||
@@ -402,7 +402,7 @@ void pdcp_mbms_run (
|
||||
*/
|
||||
void pdcp_run (
|
||||
const protocol_ctxt_t *const ctxt_pP);
|
||||
uint64_t pdcp_module_init (uint64_t pdcp_optmask);
|
||||
uint64_t pdcp_module_init (uint64_t pdcp_optmask, int ue_id);
|
||||
void pdcp_module_cleanup (void);
|
||||
void nr_ip_over_LTE_DRB_preconfiguration (void);
|
||||
void pdcp_layer_init (void);
|
||||
|
||||
@@ -91,7 +91,7 @@ extern struct msghdr nas_msg_rx;
|
||||
|
||||
|
||||
extern int gtpv1u_new_data_req( uint8_t enb_module_idP, rnti_t ue_rntiP, uint8_t rab_idP, uint8_t *buffer_pP, uint32_t buf_lenP, uint32_t buf_offsetP);
|
||||
|
||||
uint16_t ue_id_g;// global variable to identify ue id for each ue. Change happens only in main function of lte-uesoftmodem.c
|
||||
|
||||
void debug_pdcp_pc5s_sdu(sidelink_pc5s_element *sl_pc5s_msg, char *title) {
|
||||
LOG_I(PDCP,"%s: \nPC5S message, header traffic_type: %d)\n", title, sl_pc5s_msg->pc5s_header.traffic_type);
|
||||
@@ -217,8 +217,15 @@ int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) {
|
||||
do {
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 );
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 );
|
||||
len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
|
||||
if (ue_id_g == 0)
|
||||
{
|
||||
len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
len = read(UE_NAS_USE_TUN?nas_sock_fd[ue_id_g]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
|
||||
}
|
||||
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
|
||||
|
||||
if (len<=0) continue;
|
||||
|
||||
@@ -497,7 +504,10 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx
|
||||
}
|
||||
}
|
||||
} else { // ctxt.enb_flag => UE
|
||||
if (NFAPI_MODE == NFAPI_UE_STUB_PNF) {
|
||||
if (NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) {
|
||||
#ifdef UESIM_EXPANSION
|
||||
ctxt.module_id = inst_pdcp_list[pdcp_read_header_g.inst];
|
||||
#else
|
||||
ctxt.module_id = pdcp_read_header_g.inst;
|
||||
} else {
|
||||
ctxt.module_id = 0;
|
||||
@@ -549,8 +559,8 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx
|
||||
pdcp_read_header_g.data_size,
|
||||
(unsigned char *)NLMSG_DATA(nas_nlh_rx),
|
||||
PDCP_TRANSMISSION_MODE_DATA,
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.sourceL2Id,
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.destinationL2Id
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)?NULL:&pdcp_read_header_g.sourceL2Id,
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF || NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF)?NULL:&pdcp_read_header_g.destinationL2Id
|
||||
);
|
||||
} else { /* else of h_rc == HASH_TABLE_OK */
|
||||
MSC_LOG_RX_DISCARDED_MESSAGE(
|
||||
@@ -594,8 +604,8 @@ int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctx
|
||||
pdcp_read_header_g.data_size,
|
||||
(unsigned char *)NLMSG_DATA(nas_nlh_rx),
|
||||
PDCP_TRANSMISSION_MODE_DATA,
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.sourceL2Id,
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.destinationL2Id
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF|| NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? NULL :&pdcp_read_header_g.sourceL2Id,
|
||||
(NFAPI_MODE == NFAPI_UE_STUB_PNF|| NFAPI_MODE == NFAPI_MODE_STANDALONE_PNF) ? NULL :&pdcp_read_header_g.destinationL2Id
|
||||
);
|
||||
} /* rab_id == 0 */
|
||||
} /*pdcp_read_state_g != 0 */
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/queue_test
|
||||
@@ -22,25 +22,31 @@ extern UL_RCC_IND_t UL_RCC_INFO;
|
||||
uint16_t frame_cnt=0;
|
||||
void handle_rach(UL_IND_t *UL_info) {
|
||||
int i;
|
||||
|
||||
if(NFAPI_MODE == NFAPI_MODE_VNF) {
|
||||
for(uint8_t j = 0; j < NUM_NFPAI_SUBFRAME; j++) {
|
||||
if (UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles>0) {
|
||||
AssertFatal(UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n");
|
||||
LOG_D(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_RCC_INFO.rach_ind[j].sfn_sf));
|
||||
initiate_ra_proc(UL_info->module_id,
|
||||
UL_info->CC_id,
|
||||
NFAPI_SFNSF2SFN(UL_RCC_INFO.rach_ind[j].sfn_sf),
|
||||
NFAPI_SFNSF2SF(UL_RCC_INFO.rach_ind[j].sfn_sf),
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.preamble,
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.rnti,
|
||||
0
|
||||
);
|
||||
free(UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list);
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles = 0;
|
||||
UL_RCC_INFO.rach_ind[j].header.message_id = 0;
|
||||
int j = UL_info->subframe;
|
||||
AssertFatal(j < sizeof(UL_RCC_INFO.rach_ind) / sizeof(UL_RCC_INFO.rach_ind[0]), "j index out of range of index of rach_ind\n");
|
||||
if (NFAPI_MODE == NFAPI_MODE_VNF)
|
||||
{
|
||||
if (UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles > 0)
|
||||
{
|
||||
if (UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles > 1)
|
||||
{
|
||||
LOG_D(MAC, "handle_rach j: %d UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles: %d\n",
|
||||
j, UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles);
|
||||
LOG_D(MAC, "UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:Frame: %d Subframe: %d\n",
|
||||
UL_info->frame, UL_info->subframe, NFAPI_SFNSF2SFN(UL_RCC_INFO.rach_ind[j].sfn_sf), NFAPI_SFNSF2SF(UL_RCC_INFO.rach_ind[j].sfn_sf));
|
||||
}
|
||||
AssertFatal(UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles == 1, "More than 1 preamble not supported\n"); // dump frame/sf and all things in UL_RCC_INFO
|
||||
initiate_ra_proc(UL_info->module_id,
|
||||
UL_info->CC_id,
|
||||
NFAPI_SFNSF2SFN(UL_RCC_INFO.rach_ind[j].sfn_sf),
|
||||
NFAPI_SFNSF2SF(UL_RCC_INFO.rach_ind[j].sfn_sf),
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.preamble,
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list[0].preamble_rel8.rnti,
|
||||
0);
|
||||
free(UL_RCC_INFO.rach_ind[j].rach_indication_body.preamble_list);
|
||||
UL_RCC_INFO.rach_ind[j].rach_indication_body.number_of_preambles = 0;
|
||||
UL_RCC_INFO.rach_ind[j].header.message_id = 0;
|
||||
}
|
||||
} else {
|
||||
if (UL_info->rach_ind.rach_indication_body.number_of_preambles>0) {
|
||||
@@ -788,6 +794,7 @@ IF_Module_t *IF_Module_init(int Mod_id) {
|
||||
"allocation of if_inst[%d]->if_mutex fails\n",Mod_id);
|
||||
}
|
||||
|
||||
memset(&UL_RCC_INFO, 0, sizeof(UL_RCC_INFO));
|
||||
return if_inst[Mod_id];
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ typedef struct {
|
||||
} UL_IND_t;
|
||||
|
||||
// Downlink subframe P7
|
||||
#define NUM_NFPAI_SUBFRAME 5
|
||||
#define NUM_NFPAI_SUBFRAME 10
|
||||
typedef struct {
|
||||
/// harq indication list
|
||||
nfapi_harq_indication_t harq_ind[NUM_NFPAI_SUBFRAME];
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -13,21 +13,19 @@
|
||||
#include "openair2/PHY_INTERFACE/IF_Module.h"
|
||||
#include "nfapi_interface.h"
|
||||
#include "nfapi_pnf_interface.h"
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include "nfapi/oai_integration/vendor_ext.h"
|
||||
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
|
||||
//#include "openair1/PHY/defs.h"
|
||||
//#include "openair1/PHY/LTE_TRANSPORT/defs.h"
|
||||
#include "queue.h"
|
||||
|
||||
//below 2 difinitions move to phy_stub_UE.c to add initialization when difinition.
|
||||
extern UL_IND_t *UL_INFO;
|
||||
extern nfapi_tx_request_pdu_t* tx_request_pdu_list;
|
||||
// New
|
||||
/// Pointers to config_request types. Used from nfapi callback functions.
|
||||
//below 3 difinitions move to phy_stub_UE.c to add initialization when difinition.
|
||||
extern nfapi_dl_config_request_t* dl_config_req;
|
||||
extern nfapi_ul_config_request_t* ul_config_req;
|
||||
extern nfapi_hi_dci0_request_t* hi_dci0_req;
|
||||
|
||||
int tx_req_num_elems;
|
||||
|
||||
//below 2 difinitions move to lte-ue.c to add initialization when difinition.
|
||||
//int next_ra_frame;
|
||||
@@ -61,16 +59,19 @@ void send_nfapi_UL_indications(UL_IND_t UL_INFO);
|
||||
|
||||
//void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe);
|
||||
|
||||
void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index);
|
||||
void fill_rx_indication_UE_MAC(module_id_t Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t *ulsch_buffer, uint16_t buflen, uint16_t rnti, int index,
|
||||
nfapi_ul_config_request_t *ul_config_req);
|
||||
|
||||
|
||||
// This function should be indicating directly to the eNB when there is a planned scheduling request at the MAC layer
|
||||
// of the UE. It should get called from ue_get_SR()
|
||||
void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti);
|
||||
void fill_sr_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint16_t rnti,
|
||||
nfapi_ul_config_request_t *ul_config_req);
|
||||
|
||||
// In our case the this function will be always indicating ACK to the MAC of the eNB (i.e. always assuming)
|
||||
// successful decoding.
|
||||
void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti);
|
||||
void fill_crc_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t crc_flag, int index, uint16_t rnti,
|
||||
nfapi_ul_config_request_t *ul_config_req);
|
||||
|
||||
|
||||
void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL_INFO, uint8_t ra_PreambleIndex, uint16_t ra_RNTI);
|
||||
@@ -79,9 +80,11 @@ void fill_rach_indication_UE_MAC(int Mod_id,int frame,int subframe, UL_IND_t *UL
|
||||
void fill_ulsch_cqi_indication_UE_MAC(int Mod_id, uint16_t frame,uint8_t subframe, UL_IND_t *UL_INFO, uint16_t rnti);
|
||||
|
||||
|
||||
void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti);
|
||||
void fill_ulsch_harq_indication_UE_MAC(int Mod_id, int frame,int subframe, UL_IND_t *UL_INFO, nfapi_ul_config_ulsch_harq_information *harq_information, uint16_t rnti,
|
||||
nfapi_ul_config_request_t *ul_config_req);
|
||||
|
||||
void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO,nfapi_ul_config_harq_information *harq_information, uint16_t rnti
|
||||
void fill_uci_harq_indication_UE_MAC(int Mod_id, int frame, int subframe, UL_IND_t *UL_INFO,nfapi_ul_config_harq_information *harq_information, uint16_t rnti,
|
||||
nfapi_ul_config_request_t *ul_config_req
|
||||
/*uint8_t tdd_mapping_mode,
|
||||
uint16_t tdd_multiplexing_mask*/);
|
||||
|
||||
@@ -89,13 +92,29 @@ int ul_config_req_UE_MAC(nfapi_ul_config_request_t* req, int frame, int subframe
|
||||
|
||||
void handle_nfapi_ul_pdu_UE_MAC(module_id_t Mod_id,
|
||||
nfapi_ul_config_request_pdu_t *ul_config_pdu,
|
||||
uint16_t frame,uint8_t subframe,uint8_t srs_present, int index);
|
||||
uint16_t frame,uint8_t subframe,uint8_t srs_present, int index,
|
||||
nfapi_ul_config_request_t *ul_config_req);
|
||||
|
||||
typedef struct nfapi_tx_req_pdu_list_t
|
||||
{
|
||||
int num_pdus; /* number .pdus[] objects */
|
||||
nfapi_tx_request_pdu_t pdus[]; /* see "struct hack" */
|
||||
} nfapi_tx_req_pdu_list_t;
|
||||
|
||||
typedef struct nfapi_dl_config_req_tx_req_t
|
||||
{
|
||||
nfapi_dl_config_request_t *dl_config_req;
|
||||
nfapi_tx_req_pdu_list_t *tx_req_pdu_list;
|
||||
} nfapi_dl_config_req_tx_req_t;
|
||||
|
||||
void nfapi_free_tx_req_pdu_list(nfapi_tx_req_pdu_list_t *);
|
||||
|
||||
void dl_config_req_UE_MAC_dci(int sfn,
|
||||
int sf,
|
||||
nfapi_dl_config_request_pdu_t *dci,
|
||||
nfapi_dl_config_request_pdu_t *dlsch,
|
||||
int num_ue);
|
||||
int num_ue,
|
||||
nfapi_tx_req_pdu_list_t *);
|
||||
void dl_config_req_UE_MAC_bch(int sfn,
|
||||
int sf,
|
||||
nfapi_dl_config_request_pdu_t *bch,
|
||||
@@ -103,7 +122,8 @@ void dl_config_req_UE_MAC_bch(int sfn,
|
||||
void dl_config_req_UE_MAC_mch(int sfn,
|
||||
int sf,
|
||||
nfapi_dl_config_request_pdu_t *bch,
|
||||
int num_ue);
|
||||
int num_ue,
|
||||
nfapi_tx_req_pdu_list_t *);
|
||||
|
||||
int tx_req_UE_MAC(nfapi_tx_request_t* req);
|
||||
|
||||
@@ -129,6 +149,38 @@ int memcpy_hi_dci0_req (L1_rxtx_proc_t *proc, nfapi_pnf_p7_config_t* pnf_p7, nfa
|
||||
|
||||
void UE_config_stub_pnf(void);
|
||||
|
||||
void *memcpy_tx_req_standalone(nfapi_tx_request_t *tx_req);
|
||||
|
||||
void *memcpy_dl_config_req_standalone(nfapi_dl_config_request_t *dl_config_req);
|
||||
|
||||
// open an SCTP socket with a standalone PNF module
|
||||
void ue_init_standalone_socket(const char *addr, int tx_port, int rx_port);
|
||||
|
||||
// read from standalone pnf socket call corresponding memcpy functions
|
||||
void *ue_standalone_pnf_task(void *context);
|
||||
void send_standalone_msg(UL_IND_t *UL, nfapi_message_id_e msg_type);
|
||||
void send_standalone_dummy(void);
|
||||
void enqueue_dl_config_req_tx_req(nfapi_dl_config_request_t *dl_config_req, nfapi_tx_request_t *tx_req);
|
||||
|
||||
// Convert downlink nfapi messages to a string.
|
||||
// Returned memory is malloc'ed, caller is responsible for freeing.
|
||||
char *nfapi_dl_config_req_to_string(nfapi_dl_config_request_t *req);
|
||||
char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req);
|
||||
|
||||
// Convert downlink nfapi messages to a string.
|
||||
// Returned memory is statically allocated.
|
||||
const char *dl_pdu_type_to_string(uint8_t pdu_type);
|
||||
const char *ul_pdu_type_to_string(uint8_t pdu_type);
|
||||
|
||||
extern queue_t dl_config_req_tx_req_queue;
|
||||
extern queue_t ul_config_req_queue;
|
||||
extern queue_t hi_dci0_req_queue;
|
||||
|
||||
extern nfapi_ul_config_request_t* ul_config_req;
|
||||
extern nfapi_hi_dci0_request_t* hi_dci0_req;
|
||||
|
||||
extern int current_sfn_sf;
|
||||
|
||||
extern sem_t sfn_semaphore;
|
||||
|
||||
#endif /* PHY_STUB_UE_H_ */
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
#include "queue.h"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef UNITTEST
|
||||
#include <stdio.h>
|
||||
#define LOG_ERROR(MSG) printf(MSG "\n")
|
||||
#else
|
||||
#include "common/utils/LOG/log.h"
|
||||
#define LOG_ERROR(MSG) LOG_E(PHY, MSG "\n")
|
||||
#endif
|
||||
|
||||
void init_queue(queue_t *q)
|
||||
{
|
||||
memset(q, 0, sizeof(*q));
|
||||
pthread_mutex_init(&q->mutex, NULL);
|
||||
}
|
||||
|
||||
bool put_queue(queue_t *q, void *item)
|
||||
{
|
||||
assert(item != NULL);
|
||||
if (pthread_mutex_lock(&q->mutex) != 0)
|
||||
{
|
||||
LOG_ERROR("put_queue: mutex_lock failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool queued;
|
||||
if (q->num_items >= MAX_QUEUE_SIZE)
|
||||
{
|
||||
LOG_ERROR("put_queue: queue is full");
|
||||
queued = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(q->items[q->write_index] == NULL);
|
||||
q->items[q->write_index] = item;
|
||||
q->write_index = (q->write_index + 1) % MAX_QUEUE_SIZE;
|
||||
q->num_items++;
|
||||
queued = true;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&q->mutex);
|
||||
return queued;
|
||||
}
|
||||
|
||||
void *get_queue(queue_t *q)
|
||||
{
|
||||
void *item = NULL;
|
||||
if (pthread_mutex_lock(&q->mutex) != 0)
|
||||
{
|
||||
LOG_ERROR("get_queue: mutex_lock failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (q->num_items > 0)
|
||||
{
|
||||
item = q->items[q->read_index];
|
||||
assert(item != NULL);
|
||||
q->items[q->read_index] = NULL;
|
||||
q->read_index = (q->read_index + 1) % MAX_QUEUE_SIZE;
|
||||
q->num_items--;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&q->mutex);
|
||||
return item;
|
||||
}
|
||||
|
||||
bool requeue(queue_t *q, void *item)
|
||||
{
|
||||
assert(item != NULL);
|
||||
if (pthread_mutex_lock(&q->mutex) != 0)
|
||||
{
|
||||
LOG_ERROR("requeue: mutex_lock failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool queued;
|
||||
if (q->num_items >= MAX_QUEUE_SIZE)
|
||||
{
|
||||
LOG_ERROR("requeue: queue is full");
|
||||
queued = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
q->read_index = (q->read_index + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE;
|
||||
assert(q->items[q->read_index] == NULL);
|
||||
q->items[q->read_index] = item;
|
||||
q->num_items++;
|
||||
queued = true;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&q->mutex);
|
||||
return queued;
|
||||
}
|
||||
|
||||
void *unqueue(queue_t *q)
|
||||
{
|
||||
void *item = NULL;
|
||||
if (pthread_mutex_lock(&q->mutex) != 0) {
|
||||
LOG_ERROR("unqueue: mutex_lock failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (q->num_items > 0) {
|
||||
q->write_index = (q->write_index + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE;
|
||||
item = q->items[q->write_index];
|
||||
q->items[q->write_index] = NULL;
|
||||
q->num_items--;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&q->mutex);
|
||||
return item;
|
||||
}
|
||||
|
||||
void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, void *wanted)
|
||||
{
|
||||
if (pthread_mutex_lock(&q->mutex) != 0)
|
||||
{
|
||||
LOG_ERROR("unqueue_matching: mutex_lock failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *item = NULL;
|
||||
size_t endi = q->write_index;
|
||||
for (size_t i = 0; i < q->num_items; i++)
|
||||
{
|
||||
if (max_depth == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
--max_depth;
|
||||
|
||||
endi = (endi + MAX_QUEUE_SIZE - 1) % MAX_QUEUE_SIZE;
|
||||
void *candidate = q->items[endi];
|
||||
if (matcher(wanted, candidate))
|
||||
{
|
||||
item = candidate;
|
||||
// delete item from the queue and move other items down
|
||||
for (;;)
|
||||
{
|
||||
size_t j = (endi + 1) % MAX_QUEUE_SIZE;
|
||||
if (j == q->write_index)
|
||||
{
|
||||
q->items[endi] = NULL;
|
||||
q->write_index = endi;
|
||||
q->num_items--;
|
||||
break;
|
||||
}
|
||||
q->items[endi] = q->items[j];
|
||||
endi = j;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&q->mutex);
|
||||
return item;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
queue_t is a basic thread-safe non-blocking fixed-size queue.
|
||||
|
||||
put_queue returns false if the queue is full.
|
||||
get_queue returns NULL if the queue is empty.
|
||||
|
||||
Example usage:
|
||||
|
||||
// Initialization:
|
||||
queue_t fooq;
|
||||
init_queue(&fooq);
|
||||
|
||||
// Producer:
|
||||
foo_t *item = new_foo();
|
||||
if (!put_queue(&fooq, item))
|
||||
delete_foo(item);
|
||||
|
||||
// Consumer:
|
||||
foo_t *item = get_queue(&fooq);
|
||||
if (item)
|
||||
{
|
||||
do_something_with_foo(item);
|
||||
delete_foo(item);
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define MAX_QUEUE_SIZE 512
|
||||
|
||||
typedef struct queue_t
|
||||
{
|
||||
void *items[MAX_QUEUE_SIZE];
|
||||
size_t read_index, write_index;
|
||||
size_t num_items;
|
||||
pthread_mutex_t mutex;
|
||||
} queue_t;
|
||||
|
||||
void init_queue(queue_t *q);
|
||||
bool put_queue(queue_t *q, void *item);
|
||||
void *get_queue(queue_t *q);
|
||||
|
||||
/* Put the given item back onto this queue at the head.
|
||||
(The next call to put_queue would return this item.)
|
||||
Return true if successful, false if the queue was full */
|
||||
bool requeue(queue_t *q, void *item);
|
||||
|
||||
/* Remove the last item queued.
|
||||
Return the item or NULL if the queue was empty */
|
||||
void *unqueue(queue_t *q);
|
||||
|
||||
typedef bool queue_matcher_t(void *wanted, void *candidate);
|
||||
|
||||
/* Unqueue the most recently queued item for which `matcher(wanted, candidate)`
|
||||
returns true where `candidate` is an item currently on the queue.
|
||||
Look only at the last `max_depth` items on the queue, at most.
|
||||
Returns the candidate item, or NULL if none matches */
|
||||
void *unqueue_matching(queue_t *q, size_t max_depth, queue_matcher_t *matcher, void *wanted);
|
||||
@@ -0,0 +1,226 @@
|
||||
#include "queue.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FAIL do { \
|
||||
printf("\n*** FAILED at %s line %d\n", __FILE__, __LINE__); \
|
||||
pass = false; \
|
||||
} while (0)
|
||||
|
||||
#define EQUAL(A, B) do { \
|
||||
if ((A) != (B)) \
|
||||
FAIL; \
|
||||
} while (0)
|
||||
|
||||
typedef uint32_t Thing_t; /* actual type doesn't matter */
|
||||
|
||||
static Thing_t things[MAX_QUEUE_SIZE];
|
||||
static Thing_t thing1, thing2;
|
||||
|
||||
static bool matcher(void *wanted, void *candidate)
|
||||
{
|
||||
return wanted == candidate;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
bool pass = true;
|
||||
queue_t queue;
|
||||
init_queue(&queue);
|
||||
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
{
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* queue is full */
|
||||
if (put_queue(&queue, &thing1))
|
||||
FAIL;
|
||||
|
||||
Thing_t *p;
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[i]);
|
||||
}
|
||||
|
||||
/* queue is empty */
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, NULL);
|
||||
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
{
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[0]);
|
||||
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[1]);
|
||||
|
||||
if (!requeue(&queue, &thing1))
|
||||
FAIL;
|
||||
if (!requeue(&queue, &thing2))
|
||||
FAIL;
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &thing2);
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &thing1);
|
||||
|
||||
if (!requeue(&queue, &things[1]))
|
||||
FAIL;
|
||||
if (!requeue(&queue, &things[0]))
|
||||
FAIL;
|
||||
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE / 2; ++i)
|
||||
{
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[i]);
|
||||
}
|
||||
|
||||
for (int i = MAX_QUEUE_SIZE / 2; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
FAIL;
|
||||
}
|
||||
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[MAX_QUEUE_SIZE / 2]);
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[MAX_QUEUE_SIZE / 2 + 1]);
|
||||
|
||||
// ---- unqueue ----
|
||||
|
||||
init_queue(&queue);
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
{
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
for (int i = MAX_QUEUE_SIZE; --i >= 0;)
|
||||
{
|
||||
p = unqueue(&queue);
|
||||
EQUAL(p, &things[i]);
|
||||
EQUAL(queue.num_items, i);
|
||||
}
|
||||
EQUAL(queue.num_items, 0);
|
||||
if (!put_queue(&queue, &thing1))
|
||||
FAIL;
|
||||
if (!put_queue(&queue, &thing2))
|
||||
FAIL;
|
||||
EQUAL(queue.num_items, 2);
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &thing1);
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &thing2);
|
||||
|
||||
// ---- unqueue_matching ----
|
||||
|
||||
init_queue(&queue);
|
||||
|
||||
// empty queue
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1);
|
||||
EQUAL(p, NULL);
|
||||
EQUAL(queue.num_items, 0);
|
||||
|
||||
// one item in queue
|
||||
if (!put_queue(&queue, &thing1))
|
||||
FAIL;
|
||||
EQUAL(queue.num_items, 1);
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing2);
|
||||
EQUAL(p, NULL);
|
||||
EQUAL(queue.num_items, 1);
|
||||
|
||||
p = unqueue_matching(&queue, /*max_queue=*/ 0, matcher, &thing1);
|
||||
EQUAL(p, NULL);
|
||||
EQUAL(queue.num_items, 1);
|
||||
|
||||
p = unqueue_matching(&queue, /*max_queue=*/ 1, matcher, &thing1);
|
||||
EQUAL(p, &thing1);
|
||||
EQUAL(queue.num_items, 0);
|
||||
|
||||
// more max_queue values
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
{
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
p = unqueue_matching(&queue, /*max_queue=*/ 0, matcher, &things[MAX_QUEUE_SIZE - 1]);
|
||||
EQUAL(p, NULL);
|
||||
p = unqueue_matching(&queue, /*max_queue=*/ 1, matcher, &things[MAX_QUEUE_SIZE - 1]);
|
||||
EQUAL(p, &things[MAX_QUEUE_SIZE - 1]);
|
||||
EQUAL(queue.num_items, MAX_QUEUE_SIZE - 1);
|
||||
p = unqueue_matching(&queue, /*max_queue=*/ MAX_QUEUE_SIZE - 2, matcher, &things[0]);
|
||||
EQUAL(p, NULL);
|
||||
p = unqueue_matching(&queue, /*max_queue=*/ MAX_QUEUE_SIZE - 1, matcher, &things[0]);
|
||||
EQUAL(p, &things[0]);
|
||||
EQUAL(queue.num_items, MAX_QUEUE_SIZE - 2);
|
||||
|
||||
// fill the queue then remove every other item
|
||||
init_queue(&queue);
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
{
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1);
|
||||
EQUAL(p, NULL);
|
||||
for (int i = MAX_QUEUE_SIZE - 1; i >= 0; i -= 2)
|
||||
{
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &things[i]);
|
||||
EQUAL(p, &things[i]);
|
||||
}
|
||||
EQUAL(queue.num_items, MAX_QUEUE_SIZE / 2);
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1);
|
||||
EQUAL(p, NULL);
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; i += 2)
|
||||
{
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[i]);
|
||||
}
|
||||
EQUAL(queue.num_items, 0);
|
||||
|
||||
// fill the queue then remove every third item
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (!put_queue(&queue, &things[i]))
|
||||
{
|
||||
FAIL;
|
||||
}
|
||||
}
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1);
|
||||
EQUAL(p, NULL);
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; i += 3)
|
||||
{
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &things[i]);
|
||||
EQUAL(p, &things[i]);
|
||||
}
|
||||
EQUAL(queue.num_items, MAX_QUEUE_SIZE * 2 / 3);
|
||||
p = unqueue_matching(&queue, MAX_QUEUE_SIZE, matcher, &thing1);
|
||||
EQUAL(p, NULL);
|
||||
for (int i = 0; i < MAX_QUEUE_SIZE; ++i)
|
||||
{
|
||||
if (i % 3 == 0)
|
||||
continue;
|
||||
p = get_queue(&queue);
|
||||
EQUAL(p, &things[i]);
|
||||
}
|
||||
EQUAL(queue.num_items, 0);
|
||||
|
||||
if (!pass)
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
opts=(
|
||||
-Wall -Werror
|
||||
-Wno-error=int-to-pointer-cast
|
||||
-Wno-int-to-pointer-cast
|
||||
-DUNITTEST
|
||||
)
|
||||
|
||||
set -x
|
||||
|
||||
gcc "${opts[@]}" -fsanitize=address -o queue_test queue_test.c queue.c || exit
|
||||
./queue_test || exit
|
||||
|
||||
gcc "${opts[@]}" -o queue_test queue_test.c queue.c || exit
|
||||
valgrind ./queue_test || exit
|
||||
|
||||
: PASS
|
||||
@@ -407,12 +407,12 @@ char openair_rrc_ue_init( const module_id_t ue_mod_idP, const unsigned char eNB_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP, const uint8_t eNB_index ) {
|
||||
uint8_t i=0,rv[6];
|
||||
uint8_t rv[6];
|
||||
|
||||
if(UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size ==0) {
|
||||
// Get RRCConnectionRequest, fill random for now
|
||||
// Generate random byte stream for contention resolution
|
||||
for (i=0; i<6; i++) {
|
||||
for (int i=0; i<6; i++) {
|
||||
#ifdef SMBV
|
||||
// if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed
|
||||
rv[i]=i;
|
||||
@@ -421,6 +421,14 @@ void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP,
|
||||
#endif
|
||||
LOG_T(RRC,"%x.",rv[i]);
|
||||
}
|
||||
LOG_I(RRC, "%s: random = %02X %02X %02X %02X %02X %02X\n",
|
||||
__func__,
|
||||
rv[0],
|
||||
rv[1],
|
||||
rv[2],
|
||||
rv[3],
|
||||
rv[4],
|
||||
rv[5]);
|
||||
|
||||
LOG_T(RRC,"\n");
|
||||
UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size =
|
||||
@@ -431,8 +439,8 @@ void rrc_ue_generate_RRCConnectionRequest( const protocol_ctxt_t *const ctxt_pP,
|
||||
LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCConnectionRequest (bytes %d, eNB %d)\n",
|
||||
ctxt_pP->module_id, ctxt_pP->frame, UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index);
|
||||
|
||||
for (i=0; i<UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size; i++) {
|
||||
LOG_T(RRC,"%x.",UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload[i]);
|
||||
for (int i=0; i<UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.payload_size; i++) {
|
||||
LOG_T(RRC,"%x.\n",UE_rrc_inst[ctxt_pP->module_id].Srb0[eNB_index].Tx_buffer.Payload[i]);
|
||||
}
|
||||
|
||||
LOG_T(RRC,"\n");
|
||||
@@ -622,7 +630,7 @@ int rrc_ue_decode_ccch( const protocol_ctxt_t *const ctxt_pP, const SRB_INFO *co
|
||||
break;
|
||||
|
||||
case LTE_DL_CCCH_MessageType__c1_PR_rrcConnectionSetup:
|
||||
LOG_I(RRC,
|
||||
LOG_A(RRC,
|
||||
"[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup RNTI %x\n",
|
||||
ctxt_pP->module_id,
|
||||
ctxt_pP->frame,
|
||||
@@ -1694,7 +1702,7 @@ rrc_ue_process_ueCapabilityEnquiry(
|
||||
xer_fprint(stdout, &asn_DEF_LTE_UL_DCCH_Message, (void *)&ul_dcch_msg);
|
||||
}
|
||||
|
||||
LOG_I(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
|
||||
LOG_A(RRC,"UECapabilityInformation Encoded %zd bits (%zd bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8);
|
||||
rrc_data_req_ue (
|
||||
ctxt_pP,
|
||||
DCCH,
|
||||
|
||||
@@ -155,7 +155,7 @@ init_SI(
|
||||
LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__);
|
||||
|
||||
if(configuration->radioresourceconfig[CC_id].mbms_dedicated_serving_cell == TRUE) {
|
||||
LOG_I(RRC, "Configuring MIB FeMBMS (N_RB_DL %d)\n",
|
||||
LOG_A(RRC, "Configuring MIB FeMBMS (N_RB_DL %d)\n",
|
||||
(int)configuration->N_RB_DL[CC_id]);
|
||||
RC.rrc[ctxt_pP->module_id]->carrier[CC_id].MIB_FeMBMS = (uint8_t *) malloc16(4);
|
||||
do_MIB_FeMBMS(&RC.rrc[ctxt_pP->module_id]->carrier[CC_id],
|
||||
@@ -256,7 +256,7 @@ init_SI(
|
||||
carrier->N_RB_DL = configuration->N_RB_DL[CC_id];
|
||||
carrier->pbch_repetition = configuration->pbch_repetition[CC_id];
|
||||
LOG_I(RRC, "configuration->schedulingInfoSIB1_BR_r13[CC_id] %d\n",(int)configuration->schedulingInfoSIB1_BR_r13[CC_id]);
|
||||
LOG_I(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n",
|
||||
LOG_A(RRC, "Configuring MIB (N_RB_DL %d,phich_Resource %d,phich_Duration %d)\n",
|
||||
(int)configuration->N_RB_DL[CC_id],
|
||||
(int)configuration->radioresourceconfig[CC_id].phich_resource,
|
||||
(int)configuration->radioresourceconfig[CC_id].phich_duration);
|
||||
@@ -1198,7 +1198,7 @@ rrc_eNB_process_RRCConnectionSetupComplete(
|
||||
)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
LOG_I(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing LTE_RRCConnectionSetupComplete from UE (SRB1 Active)\n",
|
||||
LOG_A(RRC, PROTOCOL_RRC_CTXT_UE_FMT" [RAPROC] Logical Channel UL-DCCH, " "processing LTE_RRCConnectionSetupComplete from UE (SRB1 Active)\n",
|
||||
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
|
||||
ue_context_pP->ue_context.Srb1.Active = 1;
|
||||
ue_context_pP->ue_context.Status = RRC_CONNECTED;
|
||||
|
||||
Reference in New Issue
Block a user