Commit 18d720f3 authored by Raymond Knopp's avatar Raymond Knopp

fixed issue with demux of SCI1/SCI2/SLSCH in SLSCH receiver. Added skeleton...

fixed issue with demux of SCI1/SCI2/SLSCH in SLSCH receiver. Added skeleton for MAC parsing on RX for SL.
parent ba6a8554
......@@ -50,7 +50,7 @@
#include <syscall.h>
#include "executables/nr-uesoftmodem.h"
//#define DEBUG_ULSCH_DECODING
#define DEBUG_ULSCH_DECODING
//#define gNB_DEBUG_TRACE
#define OAI_UL_LDPC_MAX_NUM_LLR 27000//26112 // NR_LDPC_NCOL_BG1*NR_LDPC_ZMAX = 68*384
......@@ -172,6 +172,7 @@ static void nr_processULSegment(void *arg)
nr_deinterleaving_ldpc(E, Qm, harq_e, ulsch_llr + r_offset);
// for (int i =0; i<16; i++)
// printf("rx output deinterleaving w[%d]= %d r_offset %d\n", i,ulsch_harq->w[r][i], r_offset);
......@@ -309,7 +310,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
// target_code_rate is in 0.1 units
float Coderate = (float) pusch_pdu->target_code_rate / 10240.0f;
LOG_D(PHY,"ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n",
LOG_I(PHY,"ULSCH Decoding, harq_pid %d rnti %x TBS %d G %d mcs %d Nl %d nb_rb %d, Qm %d, Coderate %f RV %d round %d new RX %d\n",
harq_pid, ulsch->rnti, A, G, mcs, n_layers, nb_rb, Qm, Coderate, pusch_pdu->pusch_data.rv_index, harq_process->round, harq_process->harq_to_be_cleared);
t_nrLDPC_dec_params decParams = {0};
decParams.BG = pusch_pdu->maintenance_parms_v3.ldpcBaseGraph;
......@@ -530,7 +531,7 @@ int nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
rdata->ulsch_id = ULSCH_id;
rdata->tbslbrm = pusch_pdu->maintenance_parms_v3.tbSizeLbrmBytes;
pushTpool(phy_vars_gNB ? &phy_vars_gNB->threadPool : &get_nrUE_params()->Tpool, req);
LOG_D(PHY, "Added a block to decode, in pipe: %d\n", r);
LOG_I(PHY, "Added a block to decode, in pipe: %d\n", r);
r_offset += E;
offset += (Kr_bytes - (harq_process->F >> 3) - ((harq_process->C > 1) ? 3 : 0));
//////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -2215,16 +2215,16 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
/*-----------------------------------------------------------------------------------------------------*/
if (gNB) start_meas(&gNB->ulsch_llr_stats);
int sci1_offset=0;
if (symbol <= pssch_pdu->pscch_numsym) {
pusch_vars->ul_valid_re_per_slot[symbol] -= sci1_re_per_symb;
sci1_offset=sci1_re_per_symb;
}
if (ml_rx == false || nrOfLayers == 1) {
if (pssch_pdu && sci2_left>0){
LOG_I(NR_PHY,"valid_re_per_slot[%d] %d\n",symbol,pusch_vars->ul_valid_re_per_slot[symbol]);
int available_sci2_res_in_symb = pusch_vars->ul_valid_re_per_slot[symbol];
int slsch_res_in_symbol;
if (symbol <= pssch_pdu->pscch_numsym) {
available_sci2_res_in_symb = pusch_vars->ul_valid_re_per_slot[symbol] - sci1_re_per_symb;
sci1_offset=sci1_re_per_symb;
LOG_I(NR_PHY,"available_sci2_res_in_symb[%d] %d (sci1_re %d)\n",symbol,available_sci2_res_in_symb,sci1_re_per_symb);
}
LOG_I(NR_PHY,"available_sci2_res_in_symb[%d] %d (sci1_re %d)\n",symbol,available_sci2_res_in_symb,sci1_re_per_symb);
int sci2_cnt_prev = sci2_cnt;
if (available_sci2_res_in_symb < sci2_left) {
sci2_cnt += available_sci2_res_in_symb; // take all of the PSSCH REs for SCI2
......@@ -2279,7 +2279,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
//
}
} // (not ML || nrOfLayers==1 ) AND pssch and sci2 REs to handle
if (pssch_pdu) LOG_D(NR_PHY,"symbol %d: PSSCH REs %d (sci1 %d,sci2 %d)\n",symbol,pusch_vars->ul_valid_re_per_slot[symbol],sci1_offset,sci2_cnt_thissymb);
if (pssch_pdu) LOG_I(NR_PHY,"symbol %d: PSSCH REs %d (sci1 %d,sci2 %d)\n",symbol,pusch_vars->ul_valid_re_per_slot[symbol],sci1_offset,sci2_cnt_thissymb);
for (aatx=0; aatx < nrOfLayers; aatx++) {
nr_ulsch_compute_llr(&pusch_vars->rxdataF_comp[aatx * frame_parms->nb_antennas_rx][symbol * (off + rb_size * NR_NB_SC_PER_RB)+sci1_offset+sci2_cnt_thissymb],
pusch_vars->ul_ch_mag0[aatx * frame_parms->nb_antennas_rx],
......
......@@ -70,6 +70,7 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
// target_code_rate is in 0.1 units
float Coderate = (float) (pscch_pssch_pdu == NULL ? ulsch->pusch_pdu.target_code_rate : pscch_pssch_pdu->target_coderate) / 10240.0f;
if (pscch_pssch_pdu) memcpy(harq_process->a,pscch_pssch_pdu->slsch_payload,A>>3);
///////////
/////////////////////////////////////////////////////////////////////////////////////////
......
......@@ -268,7 +268,8 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
// for (int i=0;i<(Gsci2>>5)+1;i++) LOG_I(NR_PHY,"sci2_encoded[%d] %x\n",i,sci2_encoded_output[i]);
// for (int g=0;g<G;g++) LOG_I(NR_PHY,"coded_output_f[%d] %d\n",g,harq_process_ul_ue->f[g]);
// LOG_I(NR_PHY,"Scrambling with Nid %x\n",phy_data->pscch_Nid);
nr_pusch_codeword_scrambling(harq_process_ul_ue->f,
G,
pscch_pssch_pdu==NULL ? ulsch_ue->Nid_cell : phy_data->pscch_Nid,
......@@ -305,7 +306,6 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE,
available_bits,
mod_order,
(int16_t *)d_mod2);
//for (int i=0;i<100;i+=2) LOG_D(NR_PHY,"SLSCH RE %d/%d: (%d,%d)\n",i/2,available_bits/2,((int16_t*)d_mod2)[i],((int16_t*)d_mod2)[i+1]);
LOG_D(NR_PHY,"SCI bits %d (sci2_re %d), PSSCH bits %d (PSCCH RE %d), max_re %d\n",Gsci2,sci2_re,available_bits,available_bits/mod_order,max_num_re);
memcpy(d_mod+sci2_re,d_mod2,available_bits*sizeof(int32_t)/mod_order);
}
......
......@@ -618,6 +618,7 @@ typedef struct {
nr_sci_pdu_t sci_pdu_rx;
nr_sci_pdu_t sci1_pdu;
nr_sci_pdu_t sci2_pdu;
uint8_t slsch_payload[16384];
} NR_UE_MAC_INST_t;
/*@}*/
......
......@@ -85,7 +85,7 @@ bool nr_schedule_slsch(nr_sci_pdu_t *sci_pdu,nr_sci_pdu_t *sci2_pdu,uint8_t *sls
// Set SLSCH
*slsch_pdu_length = 1024;
for (uint32_t n=0;n<*slsch_pdu_length;n++) slsch_pdu[n]=(uint8_t)(n&255);
return true;
}
......@@ -575,3 +575,62 @@ uint32_t sl_determine_num_sidelink_slots(uint8_t mod_id, uint16_t *N_SSB_16frame
return N_SL_SLOTS;
}
void nr_ue_process_mac_sl_pdu(int module_idP,
sl_nr_rx_indication_t *rx_ind,
int pdu_id)
{
uint8_t *pduP = (rx_ind->rx_indication_body + pdu_id)->rx_slsch_pdu.pdu;
int32_t pdu_len = (int32_t)(rx_ind->rx_indication_body + pdu_id)->rx_slsch_pdu.pdu_length;
uint8_t done = 0;
NR_UE_MAC_INST_t *mac = get_mac_inst(module_idP);
if (!pduP){
return;
}
LOG_I(NR_MAC, "In %s : processing PDU %d (with length %d) of %d total number of PDUs...\n", __FUNCTION__, pdu_id, pdu_len, rx_ind->number_pdus);
/*
while (!done && pdu_len > 0){
uint16_t mac_len = 0x0000;
uint16_t mac_subheader_len = 0x0001; // default to fixed-length subheader = 1-oct
uint8_t rx_lcid = ((NR_MAC_SUBHEADER_FIXED *)pduP)->LCID;
LOG_I(NR_MAC, "[UE] LCID %d, PDU length %d\n", rx_lcid, pdu_len);
bool ret;
switch(rx_lcid){
// MAC CE
case SL_SCH_LCID_CCCH:
// MSG4 RRC Setup 38.331
// variable length
ret=get_mac_len(pduP, pdu_len, &mac_len, &mac_subheader_len);
AssertFatal(ret, "The mac_len (%d) has an invalid size. PDU len = %d! \n",
mac_len, pdu_len);
// Check if it is a valid CCCH message, we get all 00's messages very often
int i = 0;
for(i=0; i<(mac_subheader_len+mac_len); i++) {
if(pduP[i] != 0) {
break;
}
}
if (i == (mac_subheader_len+mac_len)) {
LOG_D(NR_MAC, "%s() Invalid CCCH message!, pdu_len: %d\n", __func__, pdu_len);
done = 1;
break;
}
if ( mac_len > 0 ) {
LOG_D(NR_MAC,"DL_SCH_LCID_CCCH (e.g. RRCSetup) with payload len %d\n", mac_len);
for (int i = 0; i < mac_subheader_len; i++) {
LOG_D(NR_MAC, "MAC header %d: 0x%x\n", i, pduP[i]);
}
for (int i = 0; i < mac_len; i++) {
LOG_D(NR_MAC, "%d: 0x%x\n", i, pduP[mac_subheader_len + i]);
}
nr_mac_rrc_data_ind_ue(module_idP, CC_id, gNB_index, frameP, 0, mac->crnti, CCCH, pduP+mac_subheader_len, mac_len);
}
break;
case DL_SCH_LCID_TCI_STATE_ACT_UE_SPEC_PDSCH:
*/
}
......@@ -3263,9 +3263,10 @@ bool nr_ue_sl_pssch_scheduler(NR_UE_MAC_INST_t *mac,
if ((slot % 10) != 6) return false;
LOG_D(NR_MAC,"[UE%d] SL-PSSCH SCHEDULER: Frame:SLOT %d:%d, slot_type:%d\n",
sl_ind->module_id, frame, slot,sl_ind->slot_type);
sl_ind->module_id, frame, slot,sl_ind->slot_type);
uint16_t slsch_pdu_length;
tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload = mac->slsch_payload;
bool schedule_slsch = nr_schedule_slsch(&mac->sci1_pdu,&mac->sci2_pdu,tx_config->tx_config_list[0].tx_pscch_pssch_config_pdu.slsch_payload,NR_SL_SCI_FORMAT_2A,&slsch_pdu_length);
if (!schedule_slsch) return false;
......
......@@ -647,9 +647,47 @@ void config_pssch_slsch_pdu_rx(sl_nr_rx_config_pssch_pdu_t *nr_sl_pssch_pdu,
nr_sl_pssch_pdu->tbslbrm = nr_compute_tbslbrm(sci_pdu->additional_mcs.val,
NRRIV2BW(sl_bwp->sl_BWP_Generic_r16->sl_BWP_r16->locationAndBandwidth,273),
nr_sl_pssch_pdu->num_layers);
/* nr_sl_pssch_pdu->tb_size = nr_compute_tbs_sl(nr_sl_pssch_pdu->mod_order,
int num_psfch_symbols=0;
if (sl_res_pool->sl_PSFCH_Config_r16 && sl_res_pool->sl_PSFCH_Config_r16->choice.setup->sl_PSFCH_Period_r16 && *sl_res_pool->sl_PSFCH_Config_r16->choice.setup->sl_PSFCH_Period_r16>0) {
num_psfch_symbols = *sl_res_pool->sl_PSFCH_Config_r16->choice.setup->sl_PSFCH_Period_r16;
if (num_psfch_symbols == 3) num_psfch_symbols++;
}
int pssch_numsym=7+*sl_bwp->sl_BWP_Generic_r16->sl_LengthSymbols_r16-num_psfch_symbols-2;
int l_subch;
convNRFRIV(sci_pdu->frequency_resource_assignment.val,
*sl_res_pool->sl_NumSubchannel_r16,
*sl_res_pool->sl_UE_SelectedConfigRP_r16->sl_MaxNumPerReserve_r16,
&l_subch,
NULL,NULL);
int subchannel_size=subch_to_rb[*sl_res_pool->sl_SubchannelSize_r16];
int nohPRB = (sl_res_pool->sl_X_Overhead_r16) ? 3*(*sl_res_pool->sl_X_Overhead_r16) : 0;
int nREDMRS = get_nREDMRS(sl_res_pool);
int pscch_numsym = pscch_tda[*sl_res_pool->sl_PSCCH_Config_r16->choice.setup->sl_TimeResourcePSCCH_r16];
int pscch_numrbs = pscch_rb_table[*sl_res_pool->sl_PSCCH_Config_r16->choice.setup->sl_FreqResourcePSCCH_r16];
int N_REprime = 12*pssch_numsym - nohPRB - nREDMRS;
int N_REsci1 = 12*pscch_numrbs*pscch_numsym;
AssertFatal(*sl_res_pool->sl_PSSCH_Config_r16->choice.setup->sl_Scaling_r16 < 4, "Illegal index %d to alpha table\n",(int)*sl_res_pool->sl_PSSCH_Config_r16->choice.setup->sl_Scaling_r16);
int sci2_beta_offset = *sl_res_pool->sl_PSSCH_Config_r16->choice.setup->sl_BetaOffsets2ndSCI_r16->list.array[sci_pdu->beta_offset_indicator];
int sci2_alpha_times_100=0;
if (sl_res_pool->sl_PowerControl_r16) {
sci2_alpha_times_100=50 + (*sl_res_pool->sl_PowerControl_r16->sl_Alpha_PSSCH_PSCCH_r16)*15;
if (*sl_res_pool->sl_PowerControl_r16->sl_Alpha_PSSCH_PSCCH_r16 == 3) sci2_alpha_times_100=100;
} else sci2_alpha_times_100 = 100;
int sci2_payload_len = nr_sci_size(sl_res_pool,sci_pdu,format2);
int N_REsci2 = get_NREsci2(sci2_alpha_times_100,
sci2_payload_len,
sci2_beta_offset,
pssch_numsym,
pscch_numsym,
pscch_numrbs,
l_subch,
subchannel_size,
nr_sl_pssch_pdu->mcs,
nr_sl_pssch_pdu->mcs_table);
int N_RE = N_REprime*l_subch*subchannel_size - N_REsci1 - N_REsci2;
nr_sl_pssch_pdu->tb_size = nr_compute_tbs_sl(nr_sl_pssch_pdu->mod_order,
nr_sl_pssch_pdu->target_coderate,
N_RE,1+(sci_pdu->number_of_dmrs_port&1))>>3; */
N_RE,1+(sci_pdu->number_of_dmrs_port&1))>>3;
}
void config_pssch_sci_pdu_rx(sl_nr_rx_config_pssch_sci_pdu_t *nr_sl_pssch_sci_pdu,
......
......@@ -1443,6 +1443,12 @@ static void handle_sl_bch(module_id_t module_id,uint8_t *const sl_mib,
return ;
}
int8_t handle_slsch(int module_idP,sl_nr_rx_indication_t *rx_ind,int pdu_id)
{
nr_ue_process_mac_sl_pdu(module_idP,rx_ind,pdu_id);
return 0;
}
void handle_sl_sci1a(module_id_t module_id,uint32_t frame, uint32_t slot, sl_nr_sci_indication_pdu_t *const sci,void *phy_data) {
......@@ -1492,6 +1498,13 @@ void sl_nr_process_rx_ind(uint16_t mod_id,
break;
case SL_NR_RX_PDU_TYPE_SLSCH:
LOG_I(NR_MAC, "%s[UE%d]SL-MAC Received SLSCH: rx_slsch_pdu:%p, rx_slsch_len %d, ack_nack %d, harq_pid %d\n",KGRN,
mod_id,rx_ind->rx_indication_body[num_pdus - 1].rx_slsch_pdu.pdu,
rx_ind->rx_indication_body[num_pdus - 1].rx_slsch_pdu.pdu_length,
rx_ind->rx_indication_body[num_pdus - 1].rx_slsch_pdu.ack_nack,
rx_ind->rx_indication_body[num_pdus - 1].rx_slsch_pdu.harq_pid);
handle_slsch(mod_id,rx_ind,0);
break;
default :
......
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