remove global for frame/subframe, noS1 attach+ traffic ok, UE do not compile
This commit is contained in:
@@ -211,324 +211,7 @@ uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH) {
|
||||
return(crc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int ulsch_decoding_data_2thread0(td_params *tdp) {
|
||||
PHY_VARS_eNB *eNB = tdp->eNB;
|
||||
int UE_id = tdp->UE_id;
|
||||
int harq_pid = tdp->harq_pid;
|
||||
int llr8_flag = tdp->llr8_flag;
|
||||
unsigned int r,r_offset=0,Kr,Kr_bytes;
|
||||
uint8_t crc_type;
|
||||
int offset = 0;
|
||||
int ret = 1;
|
||||
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
|
||||
LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id];
|
||||
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
|
||||
int Q_m = ulsch_harq->Qm;
|
||||
int G = ulsch_harq->G;
|
||||
uint32_t E=0;
|
||||
uint32_t Gp,GpmodC,Nl=1;
|
||||
uint32_t C = ulsch_harq->C;
|
||||
decoder_if_t *tc;
|
||||
|
||||
if (llr8_flag == 0)
|
||||
tc = decoder16;
|
||||
else
|
||||
tc = decoder8;
|
||||
|
||||
// go through first half of segments to get r_offset
|
||||
for (r=0; r<(ulsch_harq->C/2); r++) {
|
||||
// Get Turbo interleaver parameters
|
||||
if (r<ulsch_harq->Cminus)
|
||||
Kr = ulsch_harq->Kminus;
|
||||
else
|
||||
Kr = ulsch_harq->Kplus;
|
||||
|
||||
Kr_bytes = Kr>>3;
|
||||
// This is stolen from rate-matching algorithm to get the value of E
|
||||
Gp = G/Nl/Q_m;
|
||||
GpmodC = Gp%C;
|
||||
|
||||
if (r < (C-(GpmodC)))
|
||||
E = Nl*Q_m * (Gp/C);
|
||||
else
|
||||
E = Nl*Q_m * ((GpmodC==0?0:1) + (Gp/C));
|
||||
|
||||
r_offset += E;
|
||||
|
||||
if (r==0) {
|
||||
offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
|
||||
} else {
|
||||
offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
|
||||
}
|
||||
}
|
||||
|
||||
// go through second half of segments
|
||||
for (; r<(ulsch_harq->C); r++) {
|
||||
// printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]);
|
||||
// Get Turbo interleaver parameters
|
||||
if (r<ulsch_harq->Cminus)
|
||||
Kr = ulsch_harq->Kminus;
|
||||
else
|
||||
Kr = ulsch_harq->Kplus;
|
||||
|
||||
Kr_bytes = Kr>>3;
|
||||
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
|
||||
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
|
||||
(uint8_t *)&dummy_w[r][0],
|
||||
(r==0) ? ulsch_harq->F : 0);
|
||||
|
||||
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
|
||||
G,
|
||||
ulsch_harq->w[r],
|
||||
(uint8_t *) &dummy_w[r][0],
|
||||
ulsch_harq->e+r_offset,
|
||||
ulsch_harq->C,
|
||||
NSOFT,
|
||||
0, //Uplink
|
||||
1,
|
||||
ulsch_harq->rvidx,
|
||||
(ulsch_harq->round==0)?1:0, // clear
|
||||
ulsch_harq->Qm,
|
||||
1,
|
||||
r,
|
||||
&E)==-1) {
|
||||
LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
r_offset += E;
|
||||
sub_block_deinterleaving_turbo(4+Kr,
|
||||
&ulsch_harq->d[r][96],
|
||||
ulsch_harq->w[r]);
|
||||
|
||||
if (ulsch_harq->C == 1)
|
||||
crc_type = CRC24_A;
|
||||
else
|
||||
crc_type = CRC24_B;
|
||||
|
||||
ret = tc(&ulsch_harq->d[r][96],
|
||||
NULL,
|
||||
ulsch_harq->c[r],
|
||||
NULL,
|
||||
Kr,
|
||||
ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
|
||||
crc_type,
|
||||
(r==0) ? ulsch_harq->F : 0,
|
||||
&eNB->ulsch_tc_init_stats,
|
||||
&eNB->ulsch_tc_alpha_stats,
|
||||
&eNB->ulsch_tc_beta_stats,
|
||||
&eNB->ulsch_tc_gamma_stats,
|
||||
&eNB->ulsch_tc_ext_stats,
|
||||
&eNB->ulsch_tc_intl1_stats,
|
||||
&eNB->ulsch_tc_intl2_stats);
|
||||
|
||||
// Reassembly of Transport block here
|
||||
|
||||
if (ret != (1+ulsch->max_turbo_iterations)) {
|
||||
if (r<ulsch_harq->Cminus)
|
||||
Kr = ulsch_harq->Kminus;
|
||||
else
|
||||
Kr = ulsch_harq->Kplus;
|
||||
|
||||
Kr_bytes = Kr>>3;
|
||||
memcpy(ulsch_harq->b+offset,
|
||||
ulsch_harq->c[r],
|
||||
Kr_bytes - ((ulsch_harq->C>1)?3:0));
|
||||
offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
extern int oai_exit;
|
||||
void *td_thread(void *param) {
|
||||
PHY_VARS_eNB *eNB = ((td_params *)param)->eNB;
|
||||
L1_proc_t *proc = &eNB->proc;
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
thread_top_init("td_thread",1,200000,250000,500000);
|
||||
pthread_setname_np( pthread_self(),"td processing");
|
||||
LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid));
|
||||
//wait_sync("td_thread");
|
||||
|
||||
while (!oai_exit) {
|
||||
if (wait_on_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread")<0) break;
|
||||
|
||||
if(oai_exit) break;
|
||||
|
||||
((td_params *)param)->ret = ulsch_decoding_data_2thread0((td_params *)param);
|
||||
|
||||
if (release_thread(&proc->mutex_td,&proc->instance_cnt_td,"td thread")<0) break;
|
||||
|
||||
if (pthread_cond_signal(&proc->cond_td) != 0) {
|
||||
printf("[eNB] ERROR pthread_cond_signal for td thread exit\n");
|
||||
exit_fun( "ERROR pthread_cond_signal" );
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) {
|
||||
L1_proc_t *proc = &eNB->proc;
|
||||
unsigned int r,r_offset=0,Kr,Kr_bytes;
|
||||
uint8_t crc_type;
|
||||
int offset = 0;
|
||||
int ret = 1;
|
||||
int16_t dummy_w[MAX_NUM_ULSCH_SEGMENTS][3*(6144+64)];
|
||||
LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id];
|
||||
LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid];
|
||||
int G = ulsch_harq->G;
|
||||
unsigned int E;
|
||||
int Cby2;
|
||||
decoder_if_t *tc;
|
||||
struct timespec wait;
|
||||
wait.tv_sec=0;
|
||||
wait.tv_nsec=5000000L;
|
||||
|
||||
if (llr8_flag == 0)
|
||||
tc = decoder16;
|
||||
else
|
||||
tc = decoder8;
|
||||
|
||||
if (ulsch_harq->C>1) { // wakeup worker if more than 1 segment
|
||||
if (pthread_mutex_timedlock(&proc->mutex_td,&wait) != 0) {
|
||||
printf("[eNB] ERROR pthread_mutex_lock for TD thread (IC %d)\n", proc->instance_cnt_td);
|
||||
exit_fun( "error locking mutex_fep" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (proc->instance_cnt_td==0) {
|
||||
printf("[eNB] TD thread busy\n");
|
||||
exit_fun("TD thread busy");
|
||||
pthread_mutex_unlock( &proc->mutex_td );
|
||||
return -1;
|
||||
}
|
||||
|
||||
++proc->instance_cnt_td;
|
||||
proc->tdp.eNB = eNB;
|
||||
proc->tdp.UE_id = UE_id;
|
||||
proc->tdp.harq_pid = harq_pid;
|
||||
proc->tdp.llr8_flag = llr8_flag;
|
||||
|
||||
// wakeup worker to do second half segments
|
||||
if (pthread_cond_signal(&proc->cond_td) != 0) {
|
||||
printf("[eNB] ERROR pthread_cond_signal for td thread exit\n");
|
||||
exit_fun( "ERROR pthread_cond_signal" );
|
||||
return (1+ulsch->max_turbo_iterations);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock( &proc->mutex_td );
|
||||
Cby2 = ulsch_harq->C/2;
|
||||
} else {
|
||||
Cby2 = 1;
|
||||
}
|
||||
|
||||
// go through first half of segments in main thread
|
||||
for (r=0; r<Cby2; r++) {
|
||||
// printf("before subblock deinterleaving c[%d] = %p\n",r,ulsch_harq->c[r]);
|
||||
// Get Turbo interleaver parameters
|
||||
if (r<ulsch_harq->Cminus)
|
||||
Kr = ulsch_harq->Kminus;
|
||||
else
|
||||
Kr = ulsch_harq->Kplus;
|
||||
|
||||
Kr_bytes = Kr>>3;
|
||||
memset(&dummy_w[r][0],0,3*(6144+64)*sizeof(short));
|
||||
ulsch_harq->RTC[r] = generate_dummy_w(4+(Kr_bytes*8),
|
||||
(uint8_t *)&dummy_w[r][0],
|
||||
(r==0) ? ulsch_harq->F : 0);
|
||||
start_meas(&eNB->ulsch_rate_unmatching_stats);
|
||||
|
||||
if (lte_rate_matching_turbo_rx(ulsch_harq->RTC[r],
|
||||
G,
|
||||
ulsch_harq->w[r],
|
||||
(uint8_t *) &dummy_w[r][0],
|
||||
ulsch_harq->e+r_offset,
|
||||
ulsch_harq->C,
|
||||
NSOFT,
|
||||
0, //Uplink
|
||||
1,
|
||||
ulsch_harq->rvidx,
|
||||
(ulsch_harq->round==0)?1:0, // clear
|
||||
ulsch_harq->Qm,
|
||||
1,
|
||||
r,
|
||||
&E)==-1) {
|
||||
LOG_E(PHY,"ulsch_decoding.c: Problem in rate matching\n");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
stop_meas(&eNB->ulsch_rate_unmatching_stats);
|
||||
r_offset += E;
|
||||
start_meas(&eNB->ulsch_deinterleaving_stats);
|
||||
sub_block_deinterleaving_turbo(4+Kr,
|
||||
&ulsch_harq->d[r][96],
|
||||
ulsch_harq->w[r]);
|
||||
stop_meas(&eNB->ulsch_deinterleaving_stats);
|
||||
|
||||
if (ulsch_harq->C == 1)
|
||||
crc_type = CRC24_A;
|
||||
else
|
||||
crc_type = CRC24_B;
|
||||
|
||||
start_meas(&eNB->ulsch_turbo_decoding_stats);
|
||||
ret = tc(&ulsch_harq->d[r][96],
|
||||
NULL,
|
||||
ulsch_harq->c[r],
|
||||
NULL,
|
||||
Kr,
|
||||
ulsch->max_turbo_iterations,//MAX_TURBO_ITERATIONS,
|
||||
crc_type,
|
||||
(r==0) ? ulsch_harq->F : 0,
|
||||
&eNB->ulsch_tc_init_stats,
|
||||
&eNB->ulsch_tc_alpha_stats,
|
||||
&eNB->ulsch_tc_beta_stats,
|
||||
&eNB->ulsch_tc_gamma_stats,
|
||||
&eNB->ulsch_tc_ext_stats,
|
||||
&eNB->ulsch_tc_intl1_stats,
|
||||
&eNB->ulsch_tc_intl2_stats);
|
||||
|
||||
// Reassembly of Transport block here
|
||||
|
||||
if (ret != (1+ulsch->max_turbo_iterations)) {
|
||||
if (r<ulsch_harq->Cminus)
|
||||
Kr = ulsch_harq->Kminus;
|
||||
else
|
||||
Kr = ulsch_harq->Kplus;
|
||||
|
||||
Kr_bytes = Kr>>3;
|
||||
|
||||
if (r==0) {
|
||||
memcpy(ulsch_harq->b,
|
||||
&ulsch_harq->c[0][(ulsch_harq->F>>3)],
|
||||
Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0));
|
||||
offset = Kr_bytes - (ulsch_harq->F>>3) - ((ulsch_harq->C>1)?3:0);
|
||||
} else {
|
||||
memcpy(ulsch_harq->b+offset,
|
||||
ulsch_harq->c[r],
|
||||
Kr_bytes - ((ulsch_harq->C>1)?3:0));
|
||||
offset += (Kr_bytes- ((ulsch_harq->C>1)?3:0));
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
||||
stop_meas(&eNB->ulsch_turbo_decoding_stats);
|
||||
//printf("/////////////////////////////////////////**************************loop for %d time in ulsch_decoding main\n",r);
|
||||
}
|
||||
|
||||
// wait for worker to finish
|
||||
wait_on_busy_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread");
|
||||
return( (ret>proc->tdp.ret) ? ret : proc->tdp.ret );
|
||||
}
|
||||
|
||||
int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) {
|
||||
unsigned int r,r_offset=0,Kr,Kr_bytes;
|
||||
|
||||
Reference in New Issue
Block a user