fix bugs detected by ubsan
This commit is contained in:
@@ -372,9 +372,9 @@ void conv_rballoc(uint8_t ra_header,uint32_t rb_alloc,uint32_t N_RB_DL,uint32_t
|
||||
if (ra_header==0) {
|
||||
for (i=0; i<25; i++) {
|
||||
if ((rb_alloc&(1<<(24-i))) != 0)
|
||||
rb_alloc2[(4*i)>>5] |= (0xf<<((4*i)%32));
|
||||
rb_alloc2[(4 * i) >> 5] |= (0xfU << ((4 * i) % 32));
|
||||
|
||||
// printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<<i));
|
||||
// printf("rb_alloc2[%d] (type 0) %x (%d)\n",(4*i)>>5,rb_alloc2[(4*i)>>5],rb_alloc&(1<<i));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -4706,7 +4706,11 @@ unsigned short dlsch_extract_rbs_single(int **rxdataF,
|
||||
}
|
||||
|
||||
if (rb_alloc_ind==1) {
|
||||
*pmi_ext = (pmi>>((rb>>2)<<1))&3;
|
||||
int tmp = (rb >> 2) << 1;
|
||||
if (tmp >= 16)
|
||||
*pmi_ext = 0;
|
||||
else
|
||||
*pmi_ext = (pmi >> tmp) & 3;
|
||||
memcpy(dl_ch0_ext,dl_ch0,12*sizeof(int));
|
||||
|
||||
/*
|
||||
|
||||
@@ -72,7 +72,11 @@ void nr_chest_time_domain_avg(NR_DL_FRAME_PARMS *frame_parms,
|
||||
uint16_t dmrs_bitmap,
|
||||
uint16_t num_rbs);
|
||||
|
||||
static inline uint8_t is_dmrs_symbol(uint8_t l, uint16_t dmrsSymbMask ) { return ((dmrsSymbMask >> l) & 0x1); }
|
||||
static inline uint8_t is_dmrs_symbol(uint8_t l, uint16_t dmrsSymbMask)
|
||||
{
|
||||
DevAssert(l < 32);
|
||||
return ((dmrsSymbMask >> l) & 0x1);
|
||||
}
|
||||
#undef EXTERN
|
||||
|
||||
#endif /* DMRS_NR_H */
|
||||
|
||||
@@ -373,7 +373,7 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
|
||||
}
|
||||
/* check for left side first */
|
||||
/* right side a DMRS symbol then we need to left extrapolate */
|
||||
if(is_dmrs_symbol(rightRef,dmrsSymbPos)) {
|
||||
if (rightRef != -1 && is_dmrs_symbol(rightRef, dmrsSymbPos)) {
|
||||
/* calculate slope from next valid estimates*/
|
||||
tmp = get_next_estimate_in_slot(ptrsSymbPos,dmrsSymbPos,rightRef+1,symbInSlot);
|
||||
/* Special case when DMRS is not followed by PTRS symbol then reuse old slope */
|
||||
@@ -382,22 +382,19 @@ int8_t nr_ptrs_process_slot(uint16_t dmrsSymbPos,
|
||||
}
|
||||
ptrs_estimate_from_slope(estPerSymb,slope_p,leftRef, rightRef);
|
||||
symb = rightRef -1;
|
||||
}
|
||||
else if(is_ptrs_symbol(rightRef,ptrsSymbPos)) {
|
||||
} else if (rightRef != -1 && is_ptrs_symbol(rightRef, ptrsSymbPos)) {
|
||||
/* calculate slope from next valid estimates */
|
||||
get_slope_from_estimates(leftRef,rightRef,estPerSymb, slope_p);
|
||||
ptrs_estimate_from_slope(estPerSymb,slope_p,leftRef, rightRef);
|
||||
symb = rightRef -1;
|
||||
}
|
||||
else if((rightRef ==-1) && (symb <symbInSlot)) {
|
||||
} else if ((rightRef == -1) && (symb < symbInSlot)) {
|
||||
// in right extrapolation use the last slope
|
||||
#ifdef DEBUG_PTRS
|
||||
printf("[PHY][PTRS]: Last Slop Reused :(%4f %4f)\n", slope_p[0],slope_p[1]);
|
||||
#endif
|
||||
ptrs_estimate_from_slope(estPerSymb,slope_p,symb-1,symbInSlot);
|
||||
symb = symbInSlot;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
printf("Wrong PTRS Setup, PTRS compensation will be skipped !");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -404,13 +404,14 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
}
|
||||
}
|
||||
else {
|
||||
__m64 *txF=(__m64*)&txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size+start_sc)<<1)];
|
||||
__m128i *txF = (__m128i *)&txdataF_precoding[nl][((l * frame_parms->ofdm_symbol_size + start_sc) << 1)];
|
||||
|
||||
__m64 *txl = (__m64*)&tx_layers[nl][m<<1];
|
||||
__m64 amp64=_mm_set1_pi16(amp);
|
||||
for (int i=0; i<(upper_limit>>1); i++) {
|
||||
|
||||
txF[i] = _mm_mulhrs_pi16(amp64,txl[i]);
|
||||
__m128i *txl = (__m128i *)&tx_layers[nl][m << 1];
|
||||
__m128i amp64 = _mm_set1_epi16(amp);
|
||||
DevAssert(upper_limit % 4 == 0);
|
||||
for (int i = 0; i < (upper_limit >> 2); i++) {
|
||||
const __m128i txL = _mm_loadu_si128(txl + i);
|
||||
_mm_storeu_si128(txF + i, _mm_mulhrs_epi16(amp64, txL));
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
if ((i&1) > 0)
|
||||
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
|
||||
@@ -422,13 +423,15 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = 0;
|
||||
txdataF_precoding[anl][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = 0;
|
||||
}*/
|
||||
} //RE loop, first part
|
||||
} // RE loop, first part
|
||||
m+=upper_limit;
|
||||
if (remaining_re > 0) {
|
||||
txF = (__m64*)&txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size)<<1)];
|
||||
txl = (__m64*)&tx_layers[nl][m<<1];
|
||||
for (int i=0; i<(remaining_re>>1); i++) {
|
||||
txF[i] = _mm_mulhrs_pi16(amp64,txl[i]);
|
||||
txF = (__m128i *)&txdataF_precoding[nl][((l * frame_parms->ofdm_symbol_size) << 1)];
|
||||
txl = (__m128i *)&tx_layers[nl][m << 1];
|
||||
DevAssert(remaining_re % 4 == 0);
|
||||
for (int i = 0; i < (remaining_re >> 2); i++) {
|
||||
const __m128i txL = _mm_loadu_si128(txl + i);
|
||||
_mm_storeu_si128(txF + i, _mm_mulhrs_epi16(amp64, txL));
|
||||
#ifdef DEBUG_DLSCH_MAPPING
|
||||
if ((i&1) > 0)
|
||||
printf("m %d\t l %d \t k %d \t txdataF: %d %d\n",
|
||||
@@ -440,7 +443,7 @@ void nr_generate_pdsch(processingData_L1tx_t *msgTx,
|
||||
txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) ] = 0;
|
||||
txdataF_precoding[nl][((l*frame_parms->ofdm_symbol_size + k)<<1) + 1] = 0;
|
||||
}*/
|
||||
} //RE loop, second part
|
||||
} // RE loop, second part
|
||||
} //
|
||||
m+=remaining_re;
|
||||
} // N_RB_DL even
|
||||
|
||||
@@ -1773,6 +1773,7 @@ static inline void nr_element_sign(c16_t *a, // a
|
||||
* Compute the matrix determinant for 4x4 Matrix
|
||||
*
|
||||
* */
|
||||
<<<<<<< HEAD
|
||||
static void nr_determin(int size,
|
||||
c16_t *a44[][size], //
|
||||
c16_t *ad_bc, // ad-bc
|
||||
|
||||
@@ -2080,9 +2080,7 @@ int main(int argc, char **argv) {
|
||||
squareRoot(&UE->dlsch_demodulation_stats),
|
||||
median(table_rx_demod), q1(table_rx_demod), q3(table_rx_demod));
|
||||
//fprintf(time_meas_fd,"DEC;\n");
|
||||
fprintf(time_meas_fd,"%f;%f;%f;%f\n",
|
||||
squareRoot(&UE->dlsch_decoding_stats[subframe]),
|
||||
median(table_rx_dec), q1(table_rx_dec), q3(table_rx_dec));
|
||||
fprintf(time_meas_fd, "%f;%f;%f;%f\n", squareRoot(&UE->dlsch_decoding_stats[UE->current_thread_id[subframe]]), median(table_rx_dec), q1(table_rx_dec), q3(table_rx_dec));
|
||||
printf("[passed] effective rate : %f (%2.1f%%,%f)): log and break \n",rate*effective_rate, 100*effective_rate, rate );
|
||||
test_passed = 1;
|
||||
break;
|
||||
|
||||
@@ -1372,16 +1372,11 @@ int main(int argc, char **argv)
|
||||
void update_ptrs_config(NR_CellGroupConfig_t *secondaryCellGroup, uint16_t *rbSize, uint8_t *mcsIndex, int8_t *ptrs_arg)
|
||||
{
|
||||
NR_BWP_Downlink_t *bwp=secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[0];
|
||||
int *ptrsFreqDenst = calloc(2, sizeof(long));
|
||||
ptrsFreqDenst[0]= 25;
|
||||
ptrsFreqDenst[1]= 115;
|
||||
int *ptrsTimeDenst = calloc(3, sizeof(long));
|
||||
ptrsTimeDenst[0]= 2;
|
||||
ptrsTimeDenst[1]= 4;
|
||||
ptrsTimeDenst[2]= 10;
|
||||
long ptrsFreqDenst[] = {25, 115};
|
||||
long ptrsTimeDenst[] = {2, 4, 10};
|
||||
|
||||
int epre_Ratio = 0;
|
||||
int reOffset = 0;
|
||||
long epre_Ratio = 0;
|
||||
long reOffset = 0;
|
||||
|
||||
if(ptrs_arg[0] ==0) {
|
||||
ptrsTimeDenst[2]= *mcsIndex -1;
|
||||
|
||||
@@ -2764,8 +2764,8 @@ uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint
|
||||
*
|
||||
*********************************************************************/
|
||||
|
||||
uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB) {
|
||||
|
||||
uint8_t get_K_ptrs(uint32_t nrb0, uint32_t nrb1, uint32_t N_RB)
|
||||
{
|
||||
if (N_RB < nrb0) {
|
||||
LOG_D(PHY,"PUSH PT-RS is not present.\n");
|
||||
return -1;
|
||||
|
||||
@@ -176,7 +176,7 @@ uint8_t get_l0_ul(uint8_t mapping_type, uint8_t dmrs_typeA_position);
|
||||
int32_t get_l_prime(uint8_t duration_in_symbols, uint8_t mapping_type, pusch_dmrs_AdditionalPosition_t additional_pos, pusch_maxLength_t pusch_maxLength, uint8_t start_symbolt, uint8_t dmrs_typeA_position);
|
||||
|
||||
uint8_t get_L_ptrs(uint8_t mcs1, uint8_t mcs2, uint8_t mcs3, uint8_t I_mcs, uint8_t mcs_table);
|
||||
uint8_t get_K_ptrs(uint16_t nrb0, uint16_t nrb1, uint16_t N_RB);
|
||||
uint8_t get_K_ptrs(uint32_t nrb0, uint32_t nrb1, uint32_t N_RB);
|
||||
|
||||
uint32_t nr_compute_tbs(uint16_t Qm,
|
||||
uint16_t R,
|
||||
|
||||
@@ -121,7 +121,7 @@ void nr_rrc_trigger(protocol_ctxt_t *ctxt, int CC_id, int frame, int subframe);
|
||||
\ *ptrsMcs Pointer to L_ptrs MCS related parameters
|
||||
\ *epre_Ratio Pointer to ep_ratio
|
||||
\ *reOffset Pointer to RE Offset Value */
|
||||
void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, int *ptrsNrb, int *ptrsMcs, int *epre_Ratio, int * reOffset);
|
||||
void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, long *ptrsNrb, long *ptrsMcs, long *epre_Ratio, long *reOffset);
|
||||
|
||||
void nr_rrc_mac_remove_ue(rnti_t rntiP);
|
||||
void nr_rrc_mac_update_cellgroup(rnti_t rntiMaybeUEid, NR_CellGroupConfig_t *cgc);
|
||||
|
||||
@@ -77,36 +77,39 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon
|
||||
}
|
||||
|
||||
/* Function to set or overwrite PTRS DL RRC parameters */
|
||||
void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, int *ptrsNrb, int *ptrsMcs, int *epre_Ratio, int * reOffset)
|
||||
void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, long *ptrsNrb, long *ptrsMcs, long *epre_Ratio, long *reOffset)
|
||||
{
|
||||
int i=0;
|
||||
NR_DMRS_DownlinkConfig_t *tmp = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup;
|
||||
// struct NR_SetupRelease_PTRS_DownlinkConfig *tmp=bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS;
|
||||
/* check for memory allocation */
|
||||
if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS == NULL) {
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS));
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->present = NR_SetupRelease_PTRS_DownlinkConfig_PR_setup;
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup= calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup));
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity));
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity));
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio = calloc(1,sizeof(long));
|
||||
bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset = calloc(1,sizeof(long));
|
||||
if (tmp->phaseTrackingRS == NULL) {
|
||||
asn1cCalloc(tmp->phaseTrackingRS, TrackingRS);
|
||||
TrackingRS->present = NR_SetupRelease_PTRS_DownlinkConfig_PR_setup;
|
||||
asn1cCalloc(TrackingRS->choice.setup, setup);
|
||||
asn1cCalloc(setup->frequencyDensity, freqD);
|
||||
/* Fill the given values */
|
||||
for(i = 0; i < 2; i++) {
|
||||
asn1cSeqAdd(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list,&ptrsNrb[i]);
|
||||
asn1cSequenceAdd(freqD->list, long, nbr);
|
||||
*nbr = ptrsNrb[i];
|
||||
}
|
||||
asn1cCalloc(setup->timeDensity, timeD);
|
||||
for(i = 0; i < 3; i++) {
|
||||
asn1cSeqAdd(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list,&ptrsMcs[i]);
|
||||
asn1cSequenceAdd(timeD->list, long, mcs);
|
||||
*mcs = ptrsMcs[i];
|
||||
}
|
||||
}// if memory exist then over write the old values
|
||||
else {
|
||||
asn1cCallocOne(setup->epre_Ratio, epre_Ratio[0]);
|
||||
asn1cCallocOne(setup->resourceElementOffset, reOffset[0]);
|
||||
} else {
|
||||
NR_PTRS_DownlinkConfig_t *TrackingRS = tmp->phaseTrackingRS->choice.setup;
|
||||
for(i = 0; i < 2; i++) {
|
||||
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] = ptrsNrb[i];
|
||||
*TrackingRS->frequencyDensity->list.array[i] = ptrsNrb[i];
|
||||
}
|
||||
for(i = 0; i < 3; i++) {
|
||||
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list.array[i] = ptrsMcs[i];
|
||||
*TrackingRS->timeDensity->list.array[i] = ptrsMcs[i];
|
||||
}
|
||||
*TrackingRS->epre_Ratio = epre_Ratio[0];
|
||||
*TrackingRS->resourceElementOffset = reOffset[0];
|
||||
}
|
||||
|
||||
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio = *epre_Ratio;
|
||||
*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset = *reOffset;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user