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;
uint32_t downlink_frequency[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;
......
......@@ -593,16 +593,16 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
p_procTime);
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)
LOG_I(PHY, "Segment %d CRC OK\n",r);
#endif
//#endif
ret = no_iteration_ldpc;
} else {
#ifdef PRINT_CRC_CHECK
//#ifdef PRINT_CRC_CHECK
//if (prnt_crc_cnt%10 == 0)
LOG_I(PHY, "CRC NOK\n");
#endif
//#endif
ret = ulsch->max_ldpc_iterations + 1;
}
......@@ -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;
return(ret);
......
......@@ -1076,8 +1076,9 @@ void nr_pusch_codeword_scrambling(uint8_t *in,
- 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,
uint8_t frame,
uint8_t slot,
uint8_t thread_id,
int gNB_id);
......
......@@ -41,10 +41,13 @@
#include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"
#include "PHY/defs_nr_common.h"
#include "PHY/TOOLS/tools_defs.h"
#include "executables/nr-softmodem.h"
//#define DEBUG_SCFDMA
//#define DEBUG_PUSCH_MAPPING
//extern int32_t uplink_counter;
void nr_pusch_codeword_scrambling(uint8_t *in,
uint32_t size,
uint32_t Nid,
......@@ -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,
uint8_t frame,
uint8_t slot,
uint8_t thread_id,
int gNB_id) {
......@@ -104,11 +108,13 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
int ap, start_symbol, Nid_cell, i;
int sample_offsetF, N_RE_prime, N_PRB_oh;
uint16_t n_rnti;
uint8_t data_existing =0;
NR_UE_ULSCH_t *ulsch_ue;
NR_UL_UE_HARQ_t *harq_process_ul_ue;
NR_DL_FRAME_PARMS *frame_parms = &UE->frame_parms;
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
length_dmrs = 1;
......@@ -141,17 +147,41 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
0,
harq_process_ul_ue->Nl);
uint8_t access_mode = SCHEDULED_ACCESS;
//-----------------------------------------------------//
// to be removed later when MAC is ready
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();
//printf("input encoder a[%d]=0x%02x\n",i,harq_process_ul_ue->a[i]);
}
if (IS_SOFTMODEM_NOS1){
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 {
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,
/////////////////////////ULSCH coding/////////////////////////
///////////
//if(data_existing){
nr_ulsch_encoding(ulsch_ue, frame_parms, harq_pid);
///////////
......@@ -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;
/////////////////////////DMRS Modulation/////////////////////////
......@@ -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,
if (tx_offset < 0)
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;
txdataF = UE->common_vars.txdataF;
......
......@@ -46,3 +46,5 @@ void handle_nr_nfapi_dlsch_pdu(PHY_VARS_gNB *gNB,int frame,int slot,
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_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
if (ret > gNB->ulsch[UE_id][0]->max_ldpc_iterations)
LOG_I(PHY, "ULSCH in error\n");
else
LOG_I(PHY, "ULSCH received ok\n");
//gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b
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,
// [hna] TO BE CLEANED
// --------------------
// nfapi_rx_indication_pdu_t *pdu;
nfapi_rx_indication_pdu_t *pdu;
int timing_advance_update;
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.rx_indication_body.tl.tag = NFAPI_RX_INDICATION_BODY_TAG;
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;
// 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.tl.tag = NFAPI_RX_UE_INFORMATION_TAG;
// pdu->rx_ue_information.rnti = gNB->ulsch[UE_id+1][0]->rnti;
// 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.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->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.rnti = gNB->ulsch[UE_id][0]->rnti;
pdu->rx_indication_rel8.tl.tag = NFAPI_RX_INDICATION_REL8_TAG;
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->data = harq_process->b;//gNB->ulsch[UE_id+1][0]->harq_processes[harq_pid]->b;
// estimate timing advance for MAC
sync_pos = nr_est_timing_advance_pusch(gNB, UE_id);
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,
if (timing_advance_update < 0) timing_advance_update = 0;
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)
// 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;
// else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255;
// else pdu->rx_indication_rel8.ul_cqi=(640+SNRtimes10)/5;
if (SNRtimes10 < -640) pdu->rx_indication_rel8.ul_cqi=0;
else if (SNRtimes10 > 635) pdu->rx_indication_rel8.ul_cqi=255;
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",
// harq_pid,frame,slot_rx,SNRtimes10,pdu->rx_indication_rel8.ul_cqi,pdu->rx_indication_rel8.timing_advance,
// timing_advance_update);
// 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.rx_indication_body.number_of_pdus++;
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)
//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);
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,
#endif
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,
frame_tx,
slot_tx,
thread_id,
gNB_id);
......@@ -2498,13 +2500,15 @@ void phy_procedures_nrUE_TX(PHY_VARS_NR_UE *ue,
} // UE_mode==PUSCH
*/
nr_ue_pusch_common_procedures(ue,
//if(data_existing){
LOG_I(PHY, "Sending data \n");
nr_ue_pusch_common_procedures(ue,
harq_pid,
slot_tx,
thread_id,
gNB_id,
&ue->frame_parms);
//}
......
......@@ -945,6 +945,7 @@ rx_sdu(const module_id_t enb_mod_idP,
stop_meas(&mac->rx_ulsch_sdu);
}
//-----------------------------------------------------------------------------
/*
* 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,
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
/** @}*/
......@@ -37,6 +37,8 @@
#include "PHY/defs_nr_UE.h"
#include "common/utils/LOG/log.h"
#include "openair2/LAYER2/MAC/mac.h"
#include "openair2/LAYER2/RLC/rlc.h"
#include "SIMULATION/TOOLS/sim.h" // for taus
#include <stdio.h>
#include <math.h>
......@@ -2317,7 +2319,287 @@ unsigned char *parse_header(unsigned char *mac_header,
return (mac_header_ptr);
}
unsigned char
generate_ulsch_header(uint8_t *mac_header,
uint8_t num_sdus,
uint8_t short_padding,
uint16_t *sdu_lengths,
uint8_t *sdu_lcids,
POWER_HEADROOM_CMD *power_headroom,
uint16_t *crnti,
BSR_SHORT *truncated_bsr,
BSR_SHORT *short_bsr,
BSR_LONG *long_bsr, unsigned short post_padding) {
SCH_SUBHEADER_FIXED *mac_header_ptr =
(SCH_SUBHEADER_FIXED *) mac_header;
unsigned char first_element = 0, last_size = 0, i;
unsigned char mac_header_control_elements[16], *ce_ptr;
LOG_D(MAC, "[UE] Generate ULSCH : num_sdus %d\n", num_sdus);
#ifdef DEBUG_HEADER_PARSING
for (i = 0; i < num_sdus; i++) {
LOG_T(MAC, "[UE] sdu %d : lcid %d length %d", i, sdu_lcids[i],
sdu_lengths[i]);
}
LOG_T(MAC, "\n");
#endif
ce_ptr = &mac_header_control_elements[0];
if ((short_padding == 1) || (short_padding == 2)) {
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = SHORT_PADDING;
first_element = 1;
last_size = 1;
}
if (short_padding == 2) {
mac_header_ptr->E = 1;
mac_header_ptr++;
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = SHORT_PADDING;
last_size = 1;
}
if (power_headroom) {
if (first_element > 0) {
mac_header_ptr->E = 1;
mac_header_ptr++;
} else {
first_element = 1;
}
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = POWER_HEADROOM;
last_size = 1;
*((POWER_HEADROOM_CMD *) ce_ptr) = (*power_headroom);
ce_ptr += sizeof(POWER_HEADROOM_CMD);
LOG_D(MAC, "phr header size %zu\n", sizeof(POWER_HEADROOM_CMD));
}
if (crnti) {
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] CRNTI : %x (first_element %d)\n", *crnti,
first_element);
#endif
if (first_element > 0) {
mac_header_ptr->E = 1;
mac_header_ptr++;
} else {
first_element = 1;
}
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = CRNTI;
last_size = 1;
*((uint16_t *) ce_ptr) = (*crnti);
ce_ptr += sizeof(uint16_t);
// printf("offset %d\n",ce_ptr-mac_header_control_elements);
}
if (truncated_bsr) {
if (first_element > 0) {
mac_header_ptr->E = 1;
/*
printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
*/
mac_header_ptr++;
} else {
first_element = 1;
}
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] Scheduler Truncated BSR Header\n");
#endif
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = TRUNCATED_BSR;
last_size = 1;
*((BSR_TRUNCATED *) ce_ptr) = (*truncated_bsr);
ce_ptr += sizeof(BSR_TRUNCATED);
// printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
} else if (short_bsr) {
if (first_element > 0) {
mac_header_ptr->E = 1;
/*
printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
*/
mac_header_ptr++;
} else {
first_element = 1;
}
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] Scheduler SHORT BSR Header\n");
#endif
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = SHORT_BSR;
last_size = 1;
*((BSR_SHORT *) ce_ptr) = (*short_bsr);
ce_ptr += sizeof(BSR_SHORT);
// printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
} else if (long_bsr) {
if (first_element > 0) {
mac_header_ptr->E = 1;
/*
printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
*/
mac_header_ptr++;
} else {
first_element = 1;
}
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] Scheduler Long BSR Header\n");
#endif
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = LONG_BSR;
last_size = 1;
*(ce_ptr) =
(long_bsr->
Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4);
*(ce_ptr + 1) =
((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->
Buffer_size2 & 0x3C)
>> 2);
*(ce_ptr + 2) =
((long_bsr->
Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F);
ce_ptr += BSR_LONG_SIZE;
// printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
}
// printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
for (i = 0; i < num_sdus; i++) {
#ifdef DEBUG_HEADER_PARSING
LOG_T(MAC, "[UE] sdu subheader %d (lcid %d, %d bytes)\n", i,
sdu_lcids[i], sdu_lengths[i]);
#endif
if ((i == (num_sdus - 1))
&& ((short_padding) || (post_padding == 0))) {
if (first_element > 0) {
mac_header_ptr->E = 1;
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n",
*(unsigned char *) mac_header_ptr,
((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R,
((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E,
((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID);
#endif
mac_header_ptr += last_size;
}
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = sdu_lcids[i];
} else {
if ((first_element > 0)) {
mac_header_ptr->E = 1;
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n",
*(unsigned char *) mac_header_ptr,
((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R,
((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E,
((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID);
#endif
mac_header_ptr += last_size;
// printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
} else {
first_element = 1;
}
if (sdu_lengths[i] < 128) {
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; // 3
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0;
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0;
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID =
sdu_lcids[i];
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L =
(unsigned char) sdu_lengths[i];
last_size = 2;
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] short sdu\n");
LOG_T(MAC,
"[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n",
((uint16_t *) mac_header_ptr)[0],
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R,
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E,
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID,
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F,
((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L);
#endif
} else {
((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0;
((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0;
((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1;
((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID =
sdu_lcids[i];
((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB =
((unsigned short) sdu_lengths[i] >> 8) & 0x7f;
((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB =
(unsigned short) sdu_lengths[i] & 0xff;
((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00;
last_size = 3;
#ifdef DEBUG_HEADER_PARSING
LOG_D(MAC, "[UE] long sdu\n");
#endif
}
}
}
if (post_padding > 0) { // we have lots of padding at the end of the packet
mac_header_ptr->E = 1;
mac_header_ptr += last_size;
// add a padding element
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = SHORT_PADDING;
mac_header_ptr++;
} else { // no end of packet padding
// last SDU subhead is of fixed type (sdu length implicitly to be computed at UE)
mac_header_ptr++;
//mac_header_ptr=last_size; // FIXME: should be ++
}
if ((ce_ptr - mac_header_control_elements) > 0) {
memcpy((void *) mac_header_ptr, mac_header_control_elements,
ce_ptr - mac_header_control_elements);
mac_header_ptr +=
(unsigned char) (ce_ptr - mac_header_control_elements);
}
#ifdef DEBUG_HEADER_PARSING
LOG_T(MAC, " [UE] header : ");
for (i = 0; i < ((unsigned char *) mac_header_ptr - mac_header); i++) {
LOG_T(MAC, "%2x.", mac_header[i]);
}
LOG_T(MAC, "\n");
#endif
return ((unsigned char *) mac_header_ptr - mac_header);
}
/* LTE based function to be substituted once NR version is ready */
//------------------------------------------------------------------------------
void
nr_ue_send_sdu(module_id_t module_idP,
......@@ -2413,5 +2695,343 @@ nr_ue_send_sdu(module_id_t module_idP,
}
/* LTE based function to be substituted once NR version is ready */
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)
{
uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0;
uint16_t buflen_remain = 0;
uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0;
uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0;
uint8_t lcid = 0, lcid_rlc_pdu_count = 0;
boolean_t is_lcid_processed = FALSE;
boolean_t is_all_lcid_processed = FALSE;
uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
uint8_t payload_offset = 0, num_sdus = 0;
uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
uint16_t sdu_length_total = 0;
BSR_SHORT bsr_short, bsr_truncated;
BSR_LONG bsr_long;
BSR_SHORT *bsr_s = &bsr_short;
BSR_LONG *bsr_l = &bsr_long;
BSR_SHORT *bsr_t = &bsr_truncated;
POWER_HEADROOM_CMD phr;
POWER_HEADROOM_CMD *phr_p = &phr;
unsigned short short_padding = 0, post_padding = 0, padding_len = 0;
int j; // used for padding
// Compute header length
int lcg_id = 0;
int lcg_id_bsr_trunc = 0;
int highest_priority = 16;
int num_lcg_id_with_data = 0;
rlc_buffer_occupancy_t lcid_buffer_occupancy_old =
0, lcid_buffer_occupancy_new = 0;
NR_UE_MAC_INST_t *nr_ue_mac_inst = get_mac_inst(0);
LOG_D(MAC,
"[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n",
module_idP, frameP, subframe, buflen);
AssertFatal(CC_id == 0,
"Transmission on secondary CCs is not supported yet\n");
bsr_header_len = 0;
phr_header_len = 0; // 1; //sizeof(SCH_SUBHEADER_FIXED);
rlc_buffer_occupancy_t buffer_occupancy = mac_rlc_get_buffer_occupancy_ind( module_idP, 0x1234, eNB_index, frameP, subframe,ENB_FLAG_NO,DTCH);
// Check for DCCH first
// TO DO: Multiplex in the order defined by the logical channel prioritization
for (lcid = DTCH;
(lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE); lcid++) {
lcid_buffer_occupancy_old = mac_rlc_get_buffer_occupancy_ind( module_idP, 0x1234, eNB_index, frameP, subframe,ENB_FLAG_NO,lcid);
if (lcid_buffer_occupancy_old > 0) {
lcid_rlc_pdu_count = 0;
is_lcid_processed = FALSE;
lcid_buffer_occupancy_new = lcid_buffer_occupancy_old;
//Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data
//Adjust at the end of the loop
while ((!is_lcid_processed) && (lcid_buffer_occupancy_new)
&& (bsr_len + phr_len + total_rlc_pdu_header_len +
sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) {
buflen_remain =
buflen - (bsr_len + phr_len +
total_rlc_pdu_header_len + sdu_length_total +
1);
LOG_I(MAC,
"[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to "
"send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n",
module_idP, frameP, lcid, lcid_buffer_occupancy_new,
buflen, bsr_len, phr_len, sdu_length_total,
total_rlc_pdu_header_len);
sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
0x1234, eNB_index,
frameP,
ENB_FLAG_NO,
MBMS_FLAG_NO,
lcid,
buflen_remain,
(char *)&ulsch_buff[sdu_length_total],0,
0
);
AssertFatal(buflen_remain >= sdu_lengths[num_sdus],
"LCID=%d RLC has segmented %d bytes but MAC has max=%d\n",
lcid, sdu_lengths[num_sdus], buflen_remain);
if (sdu_lengths[num_sdus]) {
sdu_length_total += sdu_lengths[num_sdus];
sdu_lcids[num_sdus] = lcid;
LOG_I(MAC,
"[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n",
module_idP, sdu_lengths[num_sdus], lcid);
if (buflen ==
(bsr_len + phr_len + total_rlc_pdu_header_len +
sdu_length_total + 1)) {
//No more remaining TBS after this PDU
//exit the function
rlc_pdu_header_len_last = 1;
is_lcid_processed = TRUE;
is_all_lcid_processed = TRUE;
} else {
rlc_pdu_header_len_last =
(sdu_lengths[num_sdus] > 128) ? 3 : 2;
//Change to 1 byte if it does not fit in the TBS, ie last PDU
if (buflen <=
(bsr_len + phr_len + total_rlc_pdu_header_len +
rlc_pdu_header_len_last + sdu_length_total)) {
rlc_pdu_header_len_last = 1;
is_lcid_processed = TRUE;
is_all_lcid_processed = TRUE;
}
}
//Update number of SDU
num_sdus++;
//Update total MAC Header size for RLC PDUs and save last one
total_rlc_pdu_header_len += rlc_pdu_header_len_last;
lcid_rlc_pdu_count++;
} else {
/* avoid infinite loop ... */
is_lcid_processed = TRUE;
}
/* Get updated BO after multiplexing this PDU */
lcid_buffer_occupancy_new =
mac_rlc_get_buffer_occupancy_ind( module_idP,
0x1234,
eNB_index,
frameP,
subframe,
ENB_FLAG_NO,
lcid);
is_lcid_processed = (is_lcid_processed)
|| (lcid_buffer_occupancy_new <= 0);
}
//Update Buffer remain and BSR bytes after transmission
AssertFatal(lcid_buffer_occupancy_new <=
lcid_buffer_occupancy_old,
"MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n",
lcid_buffer_occupancy_new,
lcid_buffer_occupancy_old, lcid,
lcid_rlc_pdu_count, frameP, subframe);
}
}
// build PHR and update the timers
/*if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) {
if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
//Substitute with a static value for the MAC layer abstraction (phy_stub mode)
phr_p->PH = 40;
} else {
phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index);
}
phr_p->R = 0;
LOG_D(MAC,
"[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n",
module_idP, frameP, get_PHR(module_idP, CC_id, eNB_index),
phr_p->PH, POWER_HEADROOM);
update_phr(module_idP, CC_id);
} else {
phr_p = NULL;
}*/
// Check BSR padding: it is done after PHR according to Logical Channel Prioritization order
// Check for max padding size, ie MAC Hdr for last RLC PDU = 1
/* For Padding BSR:
- if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader:
- if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission;
- else report Short BSR.
- else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR.
*/
if (sdu_length_total) {
padding_len =
buflen - (bsr_len + phr_len + total_rlc_pdu_header_len -
rlc_pdu_header_len_last + sdu_length_total + 1);
} else {
padding_len = buflen - (bsr_len + phr_len);
}
/* if ((padding_len) && (bsr_len == 0)) {
// if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR
if (padding_len >= (1 + BSR_LONG_SIZE)) {
bsr_ce_len = BSR_LONG_SIZE;
bsr_header_len = 1;
// Trigger BSR Padding
UE_mac_inst[module_idP].BSR_reporting_active |=
BSR_TRIGGER_PADDING;
} else if (padding_len >= (1 + sizeof(BSR_SHORT))) {
bsr_ce_len = sizeof(BSR_SHORT);
bsr_header_len = 1;
if (num_lcg_id_with_data > 1) {
// REPORT TRUNCATED BSR
//Get LCGID of highest priority LCID with data
for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
if (UE_mac_inst[module_idP].
logicalChannelConfig[lcid] != NULL) {
lcg_id =
UE_mac_inst[module_idP].scheduling_info.
LCGID[lcid];
if ((lcg_id < MAX_NUM_LCGID)
&& (UE_mac_inst[module_idP].
scheduling_info.BSR_bytes[lcg_id])
&&
(UE_mac_inst[module_idP].logicalChannelConfig
[lcid]->ul_SpecificParameters->priority <=
highest_priority)) {
highest_priority =
UE_mac_inst[module_idP].
logicalChannelConfig[lcid]->
ul_SpecificParameters->priority;
lcg_id_bsr_trunc = lcg_id;
}
}
}
} else {
//Report SHORT BSR, clear bsr_t
bsr_t = NULL;
}
// Trigger BSR Padding
UE_mac_inst[module_idP].BSR_reporting_active |=
BSR_TRIGGER_PADDING;
}
bsr_len = bsr_header_len + bsr_ce_len;
}*/
//Fill BSR Infos
if (bsr_ce_len == 0) {
bsr_s = NULL;
bsr_l = NULL;
bsr_t = NULL;
}
else {
LOG_W(MAC, "BSR not null \n");
}
// 1-bit padding or 2-bit padding special padding subheader
// Check for max padding size, ie MAC Hdr for last RLC PDU = 1
if (sdu_length_total) {
padding_len =
buflen - (bsr_len + phr_len + total_rlc_pdu_header_len -
rlc_pdu_header_len_last + sdu_length_total + 1);
} else {
padding_len = buflen - (bsr_len + phr_len);
}
if (padding_len <= 2) {
short_padding = padding_len;
// only add padding header
post_padding = 0;
//update total MAC Hdr size for RLC data
if (sdu_length_total) {
total_rlc_pdu_header_len =
total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1;
rlc_pdu_header_len_last = 1;
}
} else if (sdu_length_total) {
post_padding =
buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
sdu_length_total + 1);
// If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding
if (post_padding == 0) {
total_rlc_pdu_header_len -= rlc_pdu_header_len_last;
padding_len =
buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
sdu_length_total + 1);
short_padding = padding_len;
total_rlc_pdu_header_len++;
}
} else {
if (padding_len == buflen) { // nona mac pdu
*access_mode = CANCELED_ACCESS;
}
short_padding = 0;
post_padding =
buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
sdu_length_total + 1);
}
// Generate header
// if (num_sdus>0) {
payload_offset = generate_ulsch_header(ulsch_buffer, // mac header
num_sdus, // num sdus
short_padding, // short pading
sdu_lengths, // sdu length
sdu_lcids, // sdu lcid
phr_p, // power headroom
NULL, // crnti
bsr_t, // truncated bsr
bsr_s, // short bsr
bsr_l, post_padding); // long_bsr
LOG_D(MAC,
"[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n",
module_idP, buflen, sdu_length_total, num_sdus, sdu_lengths[0],
sdu_lcids[0], payload_offset, total_rlc_pdu_header_len,
short_padding, post_padding, bsr_len, phr_len,
buflen - sdu_length_total - payload_offset);
// cycle through SDUs and place in ulsch_buffer
if (sdu_length_total) {
memcpy(&ulsch_buffer[payload_offset], ulsch_buff,
sdu_length_total);
}
else
return 0;
// fill remainder of DLSCH with random data
if (post_padding) {
for (j = 0; j < (buflen - sdu_length_total - payload_offset); j++) {
ulsch_buffer[payload_offset + sdu_length_total + j] =
(char) (taus() & 0xff);
}
}
return 1;
}
......@@ -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
}
}
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,
int cellBarred,
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__*/
......@@ -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 );
} else if (ENB_NAS_USE_TUN) {
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) {
memcpy(NLMSG_DATA(nas_nlh_tx), (uint8_t *) sdu_p->data, sizeToWrite);
nas_nlh_tx->nlmsg_len = sizeToWrite;
......
......@@ -65,6 +65,9 @@ void mac_rlc_data_ind (
nr_rlc_manager_lock(nr_rlc_ue_manager);
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) {
case 1 ... 2: rb = ue->srb[channel_idP - 1]; break;
case 3 ... 7: rb = ue->drb[channel_idP - 3]; break;
......@@ -72,12 +75,13 @@ void mac_rlc_data_ind (
}
if (rb != NULL) {
LOG_W(RLC, "RB found! (channel ID %d) \n", channel_idP);
rb->set_time(rb, nr_rlc_current_time);
rb->recv_pdu(rb, buffer_pP, tb_sizeP);
} else {
LOG_E(RLC, "%s:%d:%s: fatal: no RB found (channel ID %d)\n",
__FILE__, __LINE__, __FUNCTION__, channel_idP);
exit(1);
//exit(1);
}
nr_rlc_manager_unlock(nr_rlc_ue_manager);
......
......@@ -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
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,
NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
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) {
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);
} else {
LOG_D(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot);
rx_sdu(UL_info->module_id,
LOG_I(MAC,"Frame %d, Slot %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->slot);
nr_rx_sdu(UL_info->module_id,
UL_info->CC_id,
NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
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