Commit 5b5a25a9 authored by matzakos's avatar matzakos

nr-ip noS1 uplink integration (testing with RFSIMULATOR only): Uplink IP...

nr-ip noS1 uplink integration (testing with RFSIMULATOR only): Uplink IP packets received at the gNB and reaching at pdcp layer. Asserion error at pdcp_fifo_flush_sdus when trying to write on the nas socket
parent 35fda01e
...@@ -124,6 +124,7 @@ int threequarter_fs=0; ...@@ -124,6 +124,7 @@ int threequarter_fs=0;
uint32_t downlink_frequency[MAX_NUM_CCs][4]; uint32_t downlink_frequency[MAX_NUM_CCs][4];
int32_t uplink_frequency_offset[MAX_NUM_CCs][4]; int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
//int32_t uplink_counter = 0;
extern int16_t nr_dlsch_demod_shift; extern int16_t nr_dlsch_demod_shift;
......
...@@ -593,16 +593,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -593,16 +593,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
p_procTime); p_procTime);
if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) { if (check_crc((uint8_t*)llrProcBuf,length_dec,harq_process->F,crc_type)) {
#ifdef PRINT_CRC_CHECK //#ifdef PRINT_CRC_CHECK
//if (prnt_crc_cnt % 10 == 0) //if (prnt_crc_cnt % 10 == 0)
LOG_I(PHY, "Segment %d CRC OK\n",r); LOG_I(PHY, "Segment %d CRC OK\n",r);
#endif //#endif
ret = no_iteration_ldpc; ret = no_iteration_ldpc;
} else { } else {
#ifdef PRINT_CRC_CHECK //#ifdef PRINT_CRC_CHECK
//if (prnt_crc_cnt%10 == 0) //if (prnt_crc_cnt%10 == 0)
LOG_I(PHY, "CRC NOK\n"); LOG_I(PHY, "CRC NOK\n");
#endif //#endif
ret = ulsch->max_ldpc_iterations + 1; ret = ulsch->max_ldpc_iterations + 1;
} }
...@@ -719,6 +719,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -719,6 +719,13 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
} }
LOG_I(PHY, "output encoder: \n");
for (i = 0; i < harq_process->TBS / 8; i++) {
//harq_process_ul_ue->a[i] = (unsigned char) rand();
//printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
printf("0x%02x",harq_process->b[i]);
}
ulsch->last_iteration_cnt = ret; ulsch->last_iteration_cnt = ret;
return(ret); return(ret);
......
...@@ -1076,8 +1076,9 @@ void nr_pusch_codeword_scrambling(uint8_t *in, ...@@ -1076,8 +1076,9 @@ void nr_pusch_codeword_scrambling(uint8_t *in,
- transform precoding - transform precoding
*/ */
void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
unsigned char harq_pid, unsigned char harq_pid,
uint8_t frame,
uint8_t slot, uint8_t slot,
uint8_t thread_id, uint8_t thread_id,
int gNB_id); int gNB_id);
......
...@@ -41,10 +41,13 @@ ...@@ -41,10 +41,13 @@
#include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"
#include "PHY/defs_nr_common.h" #include "PHY/defs_nr_common.h"
#include "PHY/TOOLS/tools_defs.h" #include "PHY/TOOLS/tools_defs.h"
#include "executables/nr-softmodem.h"
//#define DEBUG_SCFDMA //#define DEBUG_SCFDMA
//#define DEBUG_PUSCH_MAPPING //#define DEBUG_PUSCH_MAPPING
//extern int32_t uplink_counter;
void nr_pusch_codeword_scrambling(uint8_t *in, void nr_pusch_codeword_scrambling(uint8_t *in,
uint32_t size, uint32_t size,
uint32_t Nid, uint32_t Nid,
...@@ -84,8 +87,9 @@ void nr_pusch_codeword_scrambling(uint8_t *in, ...@@ -84,8 +87,9 @@ void nr_pusch_codeword_scrambling(uint8_t *in,
} }
void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, uint8_t nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
unsigned char harq_pid, unsigned char harq_pid,
uint8_t frame,
uint8_t slot, uint8_t slot,
uint8_t thread_id, uint8_t thread_id,
int gNB_id) { int gNB_id) {
...@@ -104,11 +108,13 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -104,11 +108,13 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int ap, start_symbol, Nid_cell, i; int ap, start_symbol, Nid_cell, i;
int sample_offsetF, N_RE_prime, N_PRB_oh; int sample_offsetF, N_RE_prime, N_PRB_oh;
uint16_t n_rnti; uint16_t n_rnti;
uint8_t data_existing =0;
NR_UE_ULSCH_t *ulsch_ue; NR_UE_ULSCH_t *ulsch_ue;
NR_UL_UE_HARQ_t *harq_process_ul_ue; NR_UL_UE_HARQ_t *harq_process_ul_ue;
NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms;
NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id]; NR_UE_PUSCH *pusch_ue = UE->pusch_vars[thread_id][gNB_id];
uint8_t ulsch_input_buffer[MAX_ULSCH_PAYLOAD_BYTES];
num_of_codewords = 1; // tmp assumption num_of_codewords = 1; // tmp assumption
length_dmrs = 1; length_dmrs = 1;
...@@ -141,17 +147,41 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -141,17 +147,41 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
0, 0,
harq_process_ul_ue->Nl); harq_process_ul_ue->Nl);
uint8_t access_mode = SCHEDULED_ACCESS;
//-----------------------------------------------------// //-----------------------------------------------------//
// to be removed later when MAC is ready // to be removed later when MAC is ready
if (harq_process_ul_ue != NULL){ if (harq_process_ul_ue != NULL){
for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) {
harq_process_ul_ue->a[i] = (unsigned char) rand(); if (IS_SOFTMODEM_NOS1){
//printf("input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]); data_existing = nr_ue_get_sdu(UE->Mod_id, UE->CC_id, frame,
} slot, 0, ulsch_input_buffer, harq_process_ul_ue->TBS/8, &access_mode);
if(data_existing){
//harq_process_ul_ue->a = (unsigned char*)calloc(harq_process_ul_ue->TBS/8, sizeof(unsigned char));
memcpy(harq_process_ul_ue->a, ulsch_input_buffer, harq_process_ul_ue->TBS/8);
LOG_I(PHY, "input encoder: \n");
for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) {
//harq_process_ul_ue->a[i] = (unsigned char) rand();
//printf("a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
//printf("0x%02x",harq_process_ul_ue->a[i]);
printf("0x%02x",harq_process_ul_ue->b[i]);
}
}
}
//else if(uplink_counter == 0){ //if(!IS_SOFTMODEM_NOS1){
else{
LOG_E(PHY, "Random data to be tranmsitted: \n");
for (i = 0; i < harq_process_ul_ue->TBS / 8; i++) {
harq_process_ul_ue->a[i] = (unsigned char) rand();
//printf(" input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
}
data_existing = 1;
//uplink_counter++;
}
} else { } else {
LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n"); LOG_E(PHY, "[phy_procedures_nrUE_TX] harq_process_ul_ue is NULL !!\n");
return; return 0;
} }
//-----------------------------------------------------// //-----------------------------------------------------//
...@@ -159,6 +189,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -159,6 +189,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
/////////////////////////ULSCH coding///////////////////////// /////////////////////////ULSCH coding/////////////////////////
/////////// ///////////
//if(data_existing){
nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid); nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid);
/////////// ///////////
...@@ -203,8 +235,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -203,8 +235,10 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
//}
} }
//if(data_existing){
start_symbol = 14 - harq_process_ul_ue->number_of_symbols; start_symbol = 14 - harq_process_ul_ue->number_of_symbols;
/////////////////////////DMRS Modulation///////////////////////// /////////////////////////DMRS Modulation/////////////////////////
...@@ -335,10 +369,13 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, ...@@ -335,10 +369,13 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
} }
} }
//}
/////////// ///////////
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
return; LOG_I(PHY, "Is data existing ?: %d \n", data_existing);
return data_existing;
} }
...@@ -369,6 +406,13 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE, ...@@ -369,6 +406,13 @@ uint8_t nr_ue_pusch_common_procedures(PHY_VARS_NR_UE *UE,
if (tx_offset < 0) if (tx_offset < 0)
tx_offset += frame_parms->samples_per_frame; tx_offset += frame_parms->samples_per_frame;
// clear the transmit data array for the current subframe
/*for (int aa=0; aa<UE->frame_parms.nb_antennas_tx; aa++) {
memset(&UE->common_vars.txdata[aa][tx_offset],0,UE->frame_parms.samples_per_slot*sizeof(int32_t));
//memset(&UE->common_vars.txdataF[aa][tx_offset],0,UE->frame_parms.samples_per_slot*sizeof(int32_t));
}*/
txdata = UE->common_vars.txdata; txdata = UE->common_vars.txdata;
txdataF = UE->common_vars.txdataF; txdataF = UE->common_vars.txdataF;
......
...@@ -46,3 +46,5 @@ void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot, ...@@ -46,3 +46,5 @@ void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
uint8_t *sdu); uint8_t *sdu);
void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid); void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, uint8_t harq_pid);
void nr_fill_crc_indication (PHY_VARS_gNB *gNB, int UE_id, int frame, int slot_rx, uint8_t crc_flag);
...@@ -260,8 +260,12 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id ...@@ -260,8 +260,12 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int UE_id
if (ret > gNB->ulsch[UE_id][0]->max_ldpc_iterations) if (ret > gNB->ulsch[UE_id][0]->max_ldpc_iterations)
LOG_I(PHY, "ULSCH in error\n"); LOG_I(PHY, "ULSCH in error\n");
else //gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b
LOG_I(PHY, "ULSCH received ok\n"); else if(gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b!=NULL){
LOG_I(PHY, "ULSCH received ok, number of iterations: %d \n", ret);
nr_fill_crc_indication (gNB, UE_id, frame_rx, slot_rx, 0);
nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid);
}
} }
...@@ -272,25 +276,28 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, ...@@ -272,25 +276,28 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
// [hna] TO BE CLEANED // [hna] TO BE CLEANED
// -------------------- // --------------------
// nfapi_rx_indication_pdu_t *pdu; nfapi_rx_indication_pdu_t *pdu;
int timing_advance_update; int timing_advance_update;
int sync_pos; int sync_pos;
// pthread_mutex_lock(&gNB->UL_INFO_mutex); NR_gNB_ULSCH_t *ulsch = gNB->ulsch[UE_id][0];
NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid];
pthread_mutex_lock(&gNB->UL_INFO_mutex);
// gNB->UL_INFO.rx_ind.sfn_sf = frame<<4| slot_rx; gNB->UL_INFO.rx_ind.sfn_sf = frame<<4| slot_rx;
// gNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG; gNB->UL_INFO.rx_ind.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
// pdu = &gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus]; pdu = &gNB->UL_INFO.rx_ind.rx_indication_body.rx_pdu_list[gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus];
// pdu->rx_ue_information.handle = gNB->ulsch[UE_id+1][0]->handle; //pdu->rx_ue_information.handle = gNB->ulsch[UE_id+1][0]->handle;
// pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG; pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
// pdu->rx_ue_information.rnti = gNB->ulsch[UE_id+1][0]->rnti; pdu->rx_ue_information.rnti = gNB->ulsch[UE_id][0]->rnti;
// pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG; pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG;
// pdu->rx_indication_rel8.length = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->TBS>>3; pdu->rx_indication_rel8.length = gNB->ulsch[UE_id][0]->harq_processes[harq_pid]->TBS>>3;
// pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation pdu->rx_indication_rel8.offset = 1; // DJP - I dont understand - but broken unless 1 ???? 0; // filled in at the end of the UL_INFO formation
// pdu->data = gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b; pdu->data = harq_process->b;//gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b;
// estimate timing advance for MAC // estimate timing advance for MAC
sync_pos = nr_est_timing_advance_pusch(gNB, UE_id); sync_pos = nr_est_timing_advance_pusch(gNB, UE_id);
timing_advance_update = sync_pos; // - gNB->frame_parms.nb_prefix_samples/4; //to check timing_advance_update = sync_pos; // - gNB->frame_parms.nb_prefix_samples/4; //to check
...@@ -314,23 +321,40 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id, ...@@ -314,23 +321,40 @@ void nr_fill_rx_indication(PHY_VARS_gNB *gNB, int frame, int slot_rx, int UE_id,
if (timing_advance_update < 0) timing_advance_update = 0; if (timing_advance_update < 0) timing_advance_update = 0;
if (timing_advance_update > 63) timing_advance_update = 63; if (timing_advance_update > 63) timing_advance_update = 63;
// pdu->rx_indication_rel8.timing_advance = timing_advance_update; pdu->rx_indication_rel8.timing_advance = timing_advance_update;
// estimate UL_CQI for MAC (from antenna port 0 only) // estimate UL_CQI for MAC (from antenna port 0 only)
// int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*gNB->measurements.n0_power_dB[0]); int SNRtimes10 = dB_fixed_times10(gNB->pusch_vars[UE_id]->ulsch_power[0]) - 300;//(10*gNB->measurements.n0_power_dB[0]);
// if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0; if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0;
// else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255; else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255;
// else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5; else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5;
// LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n", // LOG_D(PHY,"[PUSCH %d] Frame %d Subframe %d Filling RX_indication with SNR %d (%d), timing_advance %d (update %d)\n",
// harq_pid,frame,slot_rx,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance, // harq_pid,frame,slot_rx,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance,
// timing_advance_update); // timing_advance_update);
// gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++; gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus++;
// gNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | slot_rx; gNB->UL_INFO.rx_ind.sfn_sf = frame<<4 | slot_rx;
pthread_mutex_unlock(&gNB->UL_INFO_mutex);
}
// pthread_mutex_unlock(&gNB->UL_INFO_mutex); void nr_fill_crc_indication (PHY_VARS_gNB *gNB, int UE_id, int frame, int slot_rx, uint8_t crc_flag) {
pthread_mutex_lock(&gNB->UL_INFO_mutex);
nfapi_crc_indication_pdu_t *pdu = &gNB->UL_INFO. crc_ind.crc_indication_body.crc_pdu_list[gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs];
gNB->UL_INFO.crc_ind.sfn_sf = frame<<4 | slot_rx;
gNB->UL_INFO.crc_ind.header.message_id = NFAPI_CRC_INDICATION;
gNB->UL_INFO.crc_ind.crc_indication_body.tl.tag = NFAPI_CRC_INDICATION_BODY_TAG;
pdu->instance_length = 0; // don't know what to do with this
// pdu->rx_ue_information.handle = handle;
pdu->rx_ue_information.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
pdu->rx_ue_information.rnti = gNB->ulsch[UE_id][0]->rnti;
pdu->crc_indication_rel8.tl.tag = NFAPI_CRC_INDICATION_REL8_TAG;
pdu->crc_indication_rel8.crc_flag = crc_flag;
gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs++;
//LOG_D(PHY, "%s() rnti:%04x crcs:%d crc_flag:%d\n", __FUNCTION__, pdu->rx_ue_information.rnti, eNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, crc_flag);
pthread_mutex_unlock(&gNB->UL_INFO_mutex);
} }
...@@ -382,7 +406,8 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) ...@@ -382,7 +406,8 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
//LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[UE_id]->rxdataF_comp[0],6900,1,1); //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[UE_id]->rxdataF_comp[0],6900,1,1);
//LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[UE_id]->rxdataF_ext[0],6900,1,1); //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[UE_id]->rxdataF_ext[0],6900,1,1);
nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid); nr_ulsch_procedures(gNB, frame_rx, slot_rx, UE_id, harq_pid);
nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid); // indicate SDU to MAC /*nr_fill_crc_indication (gNB, UE_id, frame_rx, slot_rx, 1);
nr_fill_rx_indication(gNB, frame_rx, slot_rx, UE_id, harq_pid); // indicate SDU to MAC*/
} }
} }
} }
......
...@@ -2481,9 +2481,11 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, ...@@ -2481,9 +2481,11 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
#endif #endif
uint8_t harq_pid = 0; //temporary implementation uint8_t harq_pid = 0; //temporary implementation
uint8_t data_existing = 0;
nr_ue_ulsch_procedures(ue, data_existing = nr_ue_ulsch_procedures(ue,
harq_pid, harq_pid,
frame_tx,
slot_tx, slot_tx,
thread_id, thread_id,
gNB_id); gNB_id);
...@@ -2498,13 +2500,15 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue, ...@@ -2498,13 +2500,15 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
} // UE_mode==PUSCH } // UE_mode==PUSCH
*/ */
//if(data_existing){
nr_ue_pusch_common_procedures(ue, LOG_I(PHY, "Sending data \n");
nr_ue_pusch_common_procedures(ue,
harq_pid, harq_pid,
slot_tx, slot_tx,
thread_id, thread_id,
gNB_id, gNB_id,
&ue->frame_parms); &ue->frame_parms);
//}
......
...@@ -945,6 +945,7 @@ rx_sdu(const module_id_t enb_mod_idP, ...@@ -945,6 +945,7 @@ rx_sdu(const module_id_t enb_mod_idP,
stop_meas(&mac->rx_ulsch_sdu); stop_meas(&mac->rx_ulsch_sdu);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
/* /*
* Return the BSR table index corresponding to the number of bytes in input * Return the BSR table index corresponding to the number of bytes in input
......
...@@ -136,5 +136,9 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index, ...@@ -136,5 +136,9 @@ int8_t nr_ue_process_dlsch(module_id_t module_id, int cc_id, uint8_t gNB_index,
void nr_ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_frame_t subframeP, uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index); void nr_ue_send_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP, sub_frame_t subframeP, uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index);
uint8_t nr_ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
sub_frame_t subframe, uint8_t eNB_index,
uint8_t *ulsch_buffer, uint16_t buflen, uint8_t *access_mode);
#endif #endif
/** @}*/ /** @}*/
...@@ -548,3 +548,211 @@ void nr_schedule_uss_ulsch_phytest(nfapi_nr_ul_tti_request_t *UL_tti_req, ...@@ -548,3 +548,211 @@ void nr_schedule_uss_ulsch_phytest(nfapi_nr_ul_tti_request_t *UL_tti_req,
//pusch_pdu->beamforming; //not used for now //pusch_pdu->beamforming; //not used for now
} }
} }
void
nr_rx_sdu(const module_id_t enb_mod_idP,
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP,
uint8_t *sduP,
const uint16_t sdu_lenP,
const uint16_t timing_advance,
const uint8_t ul_cqi)
//-----------------------------------------------------------------------------
{
int current_rnti = 0;
int UE_id = -1;
int RA_id = 0;
int old_rnti = -1;
int old_UE_id = -1;
int crnti_rx = 0;
//int harq_pid = 0;
int first_rb = 0;
unsigned char num_ce = 0;
unsigned char num_sdu = 0;
unsigned char *payload_ptr = NULL;
unsigned char rx_ces[MAX_NUM_CE];
unsigned char rx_lcids[NB_RB_MAX];
unsigned short rx_lengths[NB_RB_MAX];
uint8_t lcgid = 0;
int lcgid_updated[4] = {0, 0, 0, 0};
//eNB_MAC_INST *mac = NULL;
UE_list_t *UE_list = NULL;
rrc_eNB_ue_context_t *ue_contextP = NULL;
UE_sched_ctrl_t *UE_scheduling_control = NULL;
UE_TEMPLATE *UE_template_ptr = NULL;
/* Init */
current_rnti = rntiP;
UE_id = 0; //find_UE_id(enb_mod_idP, current_rnti);
//mac = RC.mac[enb_mod_idP];
//harq_pid = subframe2harqpid(&mac->common_channels[CC_idP], frameP, subframeP);
//UE_list = &mac->UE_list;
memset(rx_ces, 0, MAX_NUM_CE * sizeof(unsigned char));
memset(rx_lcids, 0, NB_RB_MAX * sizeof(unsigned char));
memset(rx_lengths, 0, NB_RB_MAX * sizeof(unsigned short));
//start_meas(&mac->rx_ulsch_sdu);
payload_ptr = parse_ulsch_header(sduP, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths, sdu_lenP);
if (payload_ptr == NULL) {
LOG_E(MAC,"[eNB %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n",
enb_mod_idP,
CC_idP,
current_rnti,
UE_id);
return;
}
/* Control element */
for (int i = 0; i < num_ce; i++) {
switch (rx_ces[i]) { // implement and process PHR + CRNTI + BSR
case POWER_HEADROOM:
break;
case CRNTI:
break;
case TRUNCATED_BSR:
case SHORT_BSR:
break;
case LONG_BSR:
break;
default:
LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n",
enb_mod_idP,
CC_idP,
rx_ces[i]);
break;
} // end switch on control element
} // end for loop on control element
for (int i = 0; i < num_sdu; i++) {
LOG_I(MAC, "SDU Number %d MAC Subheader SDU_LCID %d, length %d\n",
i,
rx_lcids[i],
rx_lengths[i]);
T(T_ENB_MAC_UE_UL_SDU,
T_INT(enb_mod_idP),
T_INT(CC_idP),
T_INT(current_rnti),
T_INT(frameP),
T_INT(subframeP),
T_INT(rx_lcids[i]),
T_INT(rx_lengths[i]));
T(T_ENB_MAC_UE_UL_SDU_WITH_DATA,
T_INT(enb_mod_idP),
T_INT(CC_idP),
T_INT(current_rnti),
T_INT(frameP),
T_INT(subframeP),
T_INT(rx_lcids[i]),
T_INT(rx_lengths[i]),
T_BUFFER(payload_ptr, rx_lengths[i]));
switch (rx_lcids[i]) {
case CCCH:
break;
case DCCH:
case DCCH1:
break;
// all the DRBS
case DTCH:
default:
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_T(MAC, "offset: %d\n",
(unsigned char) ((unsigned char *) payload_ptr - sduP));
for (int j = 0; j < 32; j++) {
LOG_T(MAC, "%x ", payload_ptr[j]);
}
LOG_T(MAC, "\n");
#endif
if (rx_lcids[i] < NB_RB_MAX) {
LOG_D(MAC, "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d\n",
enb_mod_idP,
CC_idP,
frameP,
rx_lengths[i],
UE_id,
rx_lcids[i]);
if (UE_id != -1) {
/* Adjust buffer occupancy of the correponding logical channel group */
LOG_D(MAC, "[eNB %d] CC_id %d Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d \n",
enb_mod_idP,
CC_idP,
frameP,
rx_lengths[i],
UE_id,
rx_lcids[i]);
if ((rx_lengths[i] < SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0)) { // MAX SIZE OF transport block
mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL);
} else { /* rx_length[i] Max size */
UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1;
LOG_E(MAC, "[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ",
enb_mod_idP,
CC_idP,
frameP,
rx_lcids[i],
UE_id);
}
} else { // end if (UE_id != -1)
LOG_E(MAC,"[eNB %d] CC_id %d Frame %d : received unsupported or unknown LCID %d from UE %d ",
enb_mod_idP,
CC_idP,
frameP,
rx_lcids[i],
UE_id);
}
}
break;
}
payload_ptr += rx_lengths[i];
}
/* Program ACK for PHICH */
/*LOG_D(MAC, "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n",
current_rnti,
harq_pid,
first_rb);
nfapi_hi_dci0_request_t *hi_dci0_req;
uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP);
hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10];
nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body;
nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci +
hi_dci0_req_body->number_of_hi];
memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu);
hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = first_rb;
hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0;
hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 1;
hi_dci0_req_body->number_of_hi++;
hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP,subframeP, 0);
hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG;
hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, sf_ahead_dl);
hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;*/
/* NN--> FK: we could either check the payload, or use a phy helper to detect a false msg3 */
}
...@@ -145,4 +145,15 @@ void config_nr_mib(int Mod_idP, ...@@ -145,4 +145,15 @@ void config_nr_mib(int Mod_idP,
int cellBarred, int cellBarred,
int intraFreqReselection); int intraFreqReselection);
void
nr_rx_sdu(const module_id_t enb_mod_idP,
const int CC_idP,
const frame_t frameP,
const sub_frame_t subframeP,
const rnti_t rntiP,
uint8_t *sduP,
const uint16_t sdu_lenP,
const uint16_t timing_advance,
const uint8_t ul_cqi);
#endif /*__LAYER2_NR_MAC_PROTO_H__*/ #endif /*__LAYER2_NR_MAC_PROTO_H__*/
...@@ -128,6 +128,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) { ...@@ -128,6 +128,7 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) {
ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
} else if (ENB_NAS_USE_TUN) { } else if (ENB_NAS_USE_TUN) {
ret = write(nas_sock_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite ); ret = write(nas_sock_fd[0], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),sizeToWrite );
LOG_I(PDCP, "ENB_NAS_USE_TUN is enabled, ret: %d, ctxt_pP->module_id:%d, sizeToWrite:%d, header size:%d \n", ctxt_pP->module_id, ret, sizeToWrite, sizeof (pdcp_data_ind_header_t));
} else if (PDCP_USE_NETLINK) { } else if (PDCP_USE_NETLINK) {
memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeToWrite); memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeToWrite);
nas_nlh_tx->nlmsg_len = sizeToWrite; nas_nlh_tx->nlmsg_len = sizeToWrite;
......
...@@ -65,6 +65,9 @@ void mac_rlc_data_ind ( ...@@ -65,6 +65,9 @@ void mac_rlc_data_ind (
nr_rlc_manager_lock(nr_rlc_ue_manager); nr_rlc_manager_lock(nr_rlc_ue_manager);
ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rntiP); ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rntiP);
if(ue == NULL)
LOG_I(RLC, "RLC instance for the given UE was not found \n");
switch (channel_idP) { switch (channel_idP) {
case 1 ... 2: rb = ue->srb[channel_idP - 1]; break; case 1 ... 2: rb = ue->srb[channel_idP - 1]; break;
case 3 ... 7: rb = ue->drb[channel_idP - 3]; break; case 3 ... 7: rb = ue->drb[channel_idP - 3]; break;
...@@ -72,12 +75,13 @@ void mac_rlc_data_ind ( ...@@ -72,12 +75,13 @@ void mac_rlc_data_ind (
} }
if (rb != NULL) { if (rb != NULL) {
LOG_W(RLC, "RB found! (channel ID %d) \n", channel_idP);
rb->set_time(rb, nr_rlc_current_time); rb->set_time(rb, nr_rlc_current_time);
rb->recv_pdu(rb, buffer_pP, tb_sizeP); rb->recv_pdu(rb, buffer_pP, tb_sizeP);
} else { } else {
LOG_E(RLC, "%s:%d:%s: fatal: no RB found (channel ID %d)\n", LOG_E(RLC, "%s:%d:%s: fatal: no RB found (channel ID %d)\n",
__FILE__, __LINE__, __FUNCTION__, channel_idP); __FILE__, __LINE__, __FUNCTION__, channel_idP);
exit(1); //exit(1);
} }
nr_rlc_manager_unlock(nr_rlc_ue_manager); nr_rlc_manager_unlock(nr_rlc_ue_manager);
......
...@@ -182,7 +182,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) { ...@@ -182,7 +182,7 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->slot); LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->slot);
rx_sdu(UL_info->module_id, nr_rx_sdu(UL_info->module_id,
UL_info->CC_id, UL_info->CC_id,
NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot, NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot,
...@@ -192,8 +192,8 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) { ...@@ -192,8 +192,8 @@ void handle_nr_ulsch(NR_UL_IND_t *UL_info) {
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi); UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
} else { } else {
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot); LOG_I(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot);
rx_sdu(UL_info->module_id, nr_rx_sdu(UL_info->module_id,
UL_info->CC_id, UL_info->CC_id,
NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame, NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot, NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->slot,
......
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