CtSelectorRet CtSelector_RunOnce(CtSelector *thiz, uint32_t ms) { CtSelectorRet result = SELECTOR_RET_OK; int ret = 0; RETURN_VAL_IF_FAIL(thiz, SELECTOR_RET_ERROR); if (ms == 0) { ret = select(thiz->max_fd, &thiz->read_set, &thiz->write_set, NULL, NULL); } else { struct timeval tv; tv.tv_sec = ms / 1000; tv.tv_usec = ms % 1000; ret = select(thiz->max_fd, &thiz->read_set, &thiz->write_set, NULL, &tv); } if (ret == 0) { result = SELECTOR_RET_TIMEOUT; } else if (ret < 0) { LOG_D(TAG, "select failed"); result = SELECTOR_RET_ERROR; } else { result = SELECTOR_RET_OK; } return result; }
int get_opt(int argc, char *argv[]) { char opts; while((opts = getopt(argc, argv, "f:h")) != -1) { switch (opts) { case 'f' : strcpy(filename, optarg); LOG_D(OCG, "User specified configuration file is \"%s\"\n", filename); return MODULE_OK; case 'h' : LOG_I(OCG, "OCG command : OCG -f \"filename.xml\"\n"); return GET_HELP; default : LOG_E(OCG, "OCG command : OCG -f \"filename.xml\"\n"); return GET_HELP; } } return NO_FILE; }
int LsapiConn::readRespBody() { register HttpExtConnector * pHEC = getConnector(); int ret; size_t bufLen; if ( !pHEC ) return -1; int &respState = pHEC->getRespState(); while( m_iPacketLeft > 0 ) { char * pBuf = pHEC->getRespBuf( bufLen ); if ( !pBuf ) { return -1; } int toRead = m_iPacketLeft + sizeof( m_respHeader ); if ( toRead > (int)bufLen ) toRead = bufLen ; ret = read( pBuf, toRead ); if ( ret > 0 ) { int len, packetLen; if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process response stream %d bytes, packet left: %d", getLogId(), ret, m_iPacketLeft )); if ( ret >= m_iPacketLeft ) { packetLen = m_iPacketLeft; m_iPacketLeft = 0; } else { packetLen = ret; m_iPacketLeft -= ret; } if ( !(respState & 0xff) ) { len = pHEC->processRespData( pBuf, packetLen ); if ( respState & 0xff ) m_respState = LSAPI_CONN_READ_RESP_BODY; if ( len == -1 ) return len; } else { len = pHEC->respBodyRecv( pBuf, packetLen ); } if ( m_iPacketLeft <= 0 ) { m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; if ( ret > packetLen ) { if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process packet header %d bytes", getLogId(), ret - packetLen )); int len1 = processPacketHeader( pBuf + packetLen, ret - packetLen ); if ( len1 <= 0 ) return len1; if (( m_respHeader.m_type != LSAPI_RESP_STREAM )|| ( m_iPacketLeft <= 0 )) return 1; } else break; } if ( len == 1) return 0; if ( len ) return len; if ( ret < (int)toRead) { pHEC->flushResp(); return 0; } } else { return ret; } } return 1; }
int LsapiConn::processResp() { int ret; while( getState() == PROCESSING ) { if ( m_iPacketHeaderLeft > 0 ) { ret = read( ((char *)&m_respHeader) + sizeof( m_respHeader ) - m_iPacketHeaderLeft, m_iPacketHeaderLeft ); if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process packet header %d bytes", getLogId(), ret )); if ( ret > 0 ) { m_iPacketHeaderLeft -= ret; if ( m_iPacketHeaderLeft == 0 ) { m_iPacketLeft = verifyPacketHeader( &m_respHeader ) - LSAPI_PACKET_HEADER_LEN; if ( m_iPacketLeft < 0 ) { const char * p = (const char *)&m_respHeader; LOG_WARN(( "[%s] LSAPI Packet header is invalid," "('%c','%c','%c','%c','%c','%c','%c','%c')", getLogId(), *p, *(p+1), *(p+2), *(p+3), *(p+4), *(p+5), *(p+6), *(p+7) )); break; } // if ( m_iPacketLeft > LSAPI_MAX_HEADER_LEN ) // { // LOG_WARN(( "[%s] LSAPI Packet is too large: %d", // getLogId(), m_iPacketLeft )); // break; // } switch( m_respHeader.m_type ) { case LSAPI_RESP_END: m_respState = 0; incReqProcessed(); setInProcess( 0 ); getConnector()->endResponse( 0, 0 ); return 0; case LSAPI_RESP_HEADER: m_iCurRespHeader = 0; m_respState = LSAPI_CONN_READ_RESP_INFO; m_pRespHeaderProcess = (char *)&m_respInfo; setRespBuf( m_pRespHeaderProcess ); break; case LSAPI_REQ_RECEIVED: m_reqReceived = 1; break; } } } else { if (( m_respState == LSAPI_CONN_READ_RESP_BODY )&& ( getConnector())) getConnector()->flushResp(); return ret; } } if ( m_iPacketLeft > 0 ) { switch( m_respHeader.m_type ) { case LSAPI_RESP_HEADER: ret = processRespHeader(); if ( ret <= 0 ) return ret; break; case LSAPI_RESP_STREAM: ret = readRespBody(); if ( ret <= 0 ) { if (( m_respState == LSAPI_CONN_READ_RESP_BODY )&& ( getConnector())) getConnector()->flushResp(); return ret; } break; case LSAPI_STDERR_STREAM: ret = readStderrStream(); if ( ret <= 0 ) return ret; break; default: //error: protocol error LOG_NOTICE(( getLogger(), "[%s] Unknown Packet Type %c, LSAPI protcol is broken.", getLogId(), m_respHeader.m_type )); errno = EIO; return -1; } } else { m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; } } errno = EIO; return -1; }
int FcgiStarter::start( FcgiApp& app ) { int fd = app.getfd(); FcgiAppConfig& config = app.getConfig(); struct stat st; // if (( stat( config.getCommand(), &st ) == -1 )|| // ( access(config.getCommand(), X_OK) == -1 )) // { // LOG_ERR(("Start FCGI [%s]: invalid path to executable - %s," // " not exist or not executable ", // config.getName(),config.getCommand() )); // return -1; // } // if ( st.st_mode & S_ISUID ) // { // if ( D_ENABLED( DL_LESS )) // LOG_D(( "Fast CGI [%s]: Setuid bit is not allowed : %s\n", // config.getName(), config.getCommand() )); // return -1; // } if ( app.getfd() < 0 ) { fd = ExtWorker::startServerSock( &config, config.getBackLog() ); if ( fd != -1 ) { app.setfd( fd ); if ( config.getServerAddr().family() == PF_UNIX ) { nio_stat( config.getServerAddr().getUnix(), &st ); HttpGlobals::getServerInfo()->addUnixSocket( config.getServerAddr().getUnix(), &st ); } } else return -1; } int instances = config.getInstances(); int cur_instances = app.getCurInstances(); int new_instances = app.getConnPool().getTotalConns() + 2 - cur_instances; if ( new_instances <= 0 ) new_instances = 1; if ( instances < new_instances + cur_instances ) { new_instances = instances - cur_instances; } if ( new_instances <= 0 ) return 0; int i; for( i = 0; i < new_instances; ++i ) { int pid; pid = LocalWorker::workerExec( config, fd ); if ( pid > 0 ) { if ( D_ENABLED( DL_LESS ) ) LOG_D(( "[%s] add child process pid: %d", app.getName(), pid )); PidRegistry::add( pid, &app, 0 ); } else { LOG_ERR(("Start FCGI [%s]: failed to start the %d of %d instances.", config.getName(), i+1, instances )); break; } } return (i==0)?-1:0; }
// This function stores the downlink buffer for all the logical channels void store_dlsch_buffer (module_id_t Mod_id, frame_t frameP, sub_frame_t subframeP){ int UE_id,i; rnti_t rnti; mac_rlc_status_resp_t rlc_status; UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; UE_TEMPLATE *UE_template; for (UE_id=UE_list->head;UE_id>=0;UE_id=UE_list->next[UE_id]){ UE_template = &UE_list->UE_template[UE_PCCID(Mod_id,UE_id)][UE_id]; // clear logical channel interface variables UE_template->dl_buffer_total = 0; UE_template->dl_pdus_total = 0; for(i=0;i< MAX_NUM_LCID; i++) { UE_template->dl_buffer_info[i]=0; UE_template->dl_pdus_in_buffer[i]=0; UE_template->dl_buffer_head_sdu_creation_time[i]=0; UE_template->dl_buffer_head_sdu_remaining_size_to_send[i]=0; } rnti = UE_RNTI(Mod_id,UE_id); for(i=0;i< MAX_NUM_LCID; i++){ // loop over all the logical channels rlc_status = mac_rlc_status_ind(Mod_id,UE_id, frameP,ENB_FLAG_YES,MBMS_FLAG_NO,i,0 ); UE_template->dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel UE_template->dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; UE_template->dl_buffer_head_sdu_creation_time[i] = rlc_status.head_sdu_creation_time ; UE_template->dl_buffer_head_sdu_creation_time_max = cmax(UE_template->dl_buffer_head_sdu_creation_time_max, rlc_status.head_sdu_creation_time ); UE_template->dl_buffer_head_sdu_remaining_size_to_send[i] = rlc_status.head_sdu_remaining_size_to_send; UE_template->dl_buffer_head_sdu_is_segmented[i] = rlc_status.head_sdu_is_segmented; UE_template->dl_buffer_total += UE_template->dl_buffer_info[i];//storing the total dlsch buffer UE_template->dl_pdus_total += UE_template->dl_pdus_in_buffer[i]; #ifdef DEBUG_eNB_SCHEDULER /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent */ if (UE_template->dl_buffer_info[i]>0) LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and size %d, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", Mod_id, frameP, subframeP, UE_id, i, UE_template->dl_pdus_in_buffer[i],UE_template->dl_buffer_info[i], UE_template->dl_buffer_head_sdu_creation_time[i], UE_template->dl_buffer_head_sdu_remaining_size_to_send[i], UE_template->dl_buffer_head_sdu_is_segmented[i] ); #endif } //#ifdef DEBUG_eNB_SCHEDULER if ( UE_template->dl_buffer_total>0) LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", Mod_id, frameP, subframeP, UE_id, UE_template->dl_buffer_total, UE_template->dl_pdus_total ); //#endif } }
// This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done void dlsch_scheduler_pre_processor (module_id_t Mod_id, frame_t frameP, sub_frame_t subframeP, uint8_t dl_pow_off[MAX_NUM_CCs][NUMBER_OF_UE_MAX], uint16_t pre_nb_available_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX], int N_RBG[MAX_NUM_CCs], unsigned char rballoc_sub_UE[MAX_NUM_CCs][NUMBER_OF_UE_MAX][N_RBG_MAX], int *mbsfn_flag){ unsigned char rballoc_sub[MAX_NUM_CCs][N_RBG_MAX],harq_pid=0,harq_pid1=0,harq_pid2=0,round=0,round1=0,round2=0,total_ue_count; unsigned char MIMO_mode_indicator[MAX_NUM_CCs][N_RBG_MAX]; int UE_id, UE_id2, i; uint16_t ii,j; uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t nb_rbs_required_remaining[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t nb_rbs_required_remaining_1[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; uint16_t i1,i2,i3,r1=0; uint16_t average_rbs_per_user[MAX_NUM_CCs]; rnti_t rnti,rnti1,rnti2; LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; int min_rb_unit[MAX_NUM_CCs]; uint8_t CC_id; UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; int rrc_status = RRC_IDLE; int transmission_mode = 0; for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { if (mbsfn_flag[CC_id]>0) // If this CC is allocated for MBSFN skip it here continue; frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); min_rb_unit[CC_id]=get_min_rb_unit(Mod_id,CC_id); for (i=UE_list->head;i>=0;i=UE_list->next[i]) { UE_id = i; // Initialize scheduling information for all active UEs dlsch_scheduler_pre_processor_reset(UE_id, CC_id, N_RBG[CC_id], dl_pow_off, nb_rbs_required, pre_nb_available_rbs, nb_rbs_required_remaining, rballoc_sub_UE, rballoc_sub, MIMO_mode_indicator); } } // Store the DLSCH buffer for each logical channel store_dlsch_buffer (Mod_id,frameP,subframeP); // Calculate the number of RBs required by each UE on the basis of logical channel's buffer assign_rbs_required (Mod_id,frameP,subframeP,nb_rbs_required,min_rb_unit); // Sorts the user on the basis of dlsch logical channel buffer and CQI sort_UEs (Mod_id,frameP,subframeP); total_ue_count =0; // loop over all active UEs for (i=UE_list->head;i>=0;i=UE_list->next[i]) { rnti = UE_RNTI(Mod_id,i); if(rnti == 0) continue; UE_id = i; for (ii=0;ii<UE_num_active_CC(UE_list,UE_id);ii++) { CC_id = UE_list->ordered_CCids[ii][UE_id]; average_rbs_per_user[CC_id]=0; mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); if(round>0) nb_rbs_required[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb[harq_pid]; //nb_rbs_required_remaining[UE_id] = nb_rbs_required[UE_id]; if (nb_rbs_required[CC_id][UE_id] > 0) { total_ue_count = total_ue_count + 1; } // hypotetical assignement /* * If schedule is enabled and if the priority of the UEs is modified * The average rbs per logical channel per user will depend on the level of * priority. Concerning the hypothetical assignement, we should assign more * rbs to prioritized users. Maybe, we can do a mapping between the * average rbs per user and the level of priority or multiply the average rbs * per user by a coefficient which represents the degree of priority. */ if (total_ue_count == 0) average_rbs_per_user[CC_id] = 0; else if( (min_rb_unit[CC_id] * total_ue_count) <= (frame_parms[CC_id]->N_RB_DL) ) average_rbs_per_user[CC_id] = (uint16_t) floor(frame_parms[CC_id]->N_RB_DL/total_ue_count); else average_rbs_per_user[CC_id] = min_rb_unit[CC_id]; } } // note: nb_rbs_required is assigned according to total_buffer_dl // extend nb_rbs_required to capture per LCID RB required for(i=UE_list->head;i>=0;i=UE_list->next[i]){ for (ii=0;ii<UE_num_active_CC(UE_list,i);ii++) { CC_id = UE_list->ordered_CCids[ii][i]; // control channel if (mac_get_rrc_status(Mod_id,1,i) < RRC_RECONFIGURED) nb_rbs_required_remaining_1[CC_id][i] = nb_rbs_required[CC_id][i]; else nb_rbs_required_remaining_1[CC_id][i] = cmin(average_rbs_per_user[CC_id],nb_rbs_required[CC_id][i]); } } //Allocation to UEs is done in 2 rounds, // 1st round: average number of RBs allocated to each UE // 2nd round: remaining RBs are allocated to high priority UEs for(r1=0;r1<2;r1++){ for(i=UE_list->head; i>=0;i=UE_list->next[i]) { for (ii=0;ii<UE_num_active_CC(UE_list,i);ii++) { CC_id = UE_list->ordered_CCids[ii][i]; if(r1 == 0) nb_rbs_required_remaining[CC_id][i] = nb_rbs_required_remaining_1[CC_id][i]; else // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round nb_rbs_required_remaining[CC_id][i] = nb_rbs_required[CC_id][i]-nb_rbs_required_remaining_1[CC_id][i]+nb_rbs_required_remaining[CC_id][i]; LOG_D(MAC,"round %d : nb_rbs_required_remaining[%d][%d]= %d (remaining_1 %d, required %d, pre_nb_available_rbs %d, N_RBG %d, rb_unit %d)\n", r1, CC_id, i, nb_rbs_required_remaining[CC_id][i], nb_rbs_required_remaining_1[CC_id][i], nb_rbs_required[CC_id][i], pre_nb_available_rbs[CC_id][i], N_RBG[CC_id], min_rb_unit[CC_id]); } } if (total_ue_count > 0 ) { for(i=UE_list->head; i>=0;i=UE_list->next[i]) { UE_id = i; for (ii=0;ii<UE_num_active_CC(UE_list,UE_id);ii++) { CC_id = UE_list->ordered_CCids[ii][UE_id]; rnti = UE_RNTI(Mod_id,UE_id); // LOG_D(MAC,"UE %d rnti 0x\n", UE_id, rnti ); if(rnti == 0) continue; transmission_mode = mac_xface->get_transmission_mode(Mod_id,CC_id,rnti); mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti,frameP,subframeP,&harq_pid,&round,0); rrc_status = mac_get_rrc_status(Mod_id,1,UE_id); /* 1st allocate for the retx */ // retransmission in data channels // control channel in the 1st transmission // data channel for all TM LOG_D(MAC,"calling dlsch_scheduler_pre_processor_allocate .. \n "); dlsch_scheduler_pre_processor_allocate (Mod_id, UE_id, CC_id, N_RBG[CC_id], transmission_mode, min_rb_unit[CC_id], frame_parms[CC_id]->N_RB_DL, dl_pow_off, nb_rbs_required, pre_nb_available_rbs, nb_rbs_required_remaining, rballoc_sub_UE, rballoc_sub, MIMO_mode_indicator); #ifdef TM5 // data chanel TM5: to be revisted if ((round == 0 ) && (transmission_mode == 5) && (dl_pow_off[CC_id][UE_id] != 1)){ for(j=0;j<N_RBG[CC_id];j+=2) { if( (((j == (N_RBG[CC_id]-1))&& (rballoc_sub[CC_id][j] == 0) && (rballoc_sub_UE[CC_id][UE_id][j] == 0)) || ((j < (N_RBG[CC_id]-1)) && (rballoc_sub[CC_id][j+1] == 0) && (rballoc_sub_UE[CC_id][UE_id][j+1] == 0)) ) && (nb_rbs_required_remaining[CC_id][UE_id]>0)){ for (ii = UE_list->next[i+1];ii >=0;ii=UE_list->next[ii]) { UE_id2 = ii; rnti2 = UE_RNTI(Mod_id,UE_id2); if(rnti2 == 0) continue; eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti2); mac_xface->get_ue_active_harq_pid(Mod_id,CC_id,rnti2,frameP,subframeP,&harq_pid2,&round2,0); if ((mac_get_rrc_status(Mod_id,1,UE_id2) >= RRC_RECONFIGURED) && (round2==0) && (mac_xface->get_transmission_mode(Mod_id,CC_id,rnti2)==5) && (dl_pow_off[CC_id][UE_id2] != 1)) { if( (((j == (N_RBG[CC_id]-1)) && (rballoc_sub_UE[CC_id][UE_id2][j] == 0)) || ((j < (N_RBG[CC_id]-1)) && (rballoc_sub_UE[CC_id][UE_id2][j+1] == 0)) ) && (nb_rbs_required_remaining[CC_id][UE_id2]>0)){ if((((eNB_UE_stats2->DL_pmi_single^eNB_UE_stats1->DL_pmi_single)<<(14-j))&0xc000)== 0x4000){ //MU-MIMO only for 25 RBs configuration rballoc_sub[CC_id][j] = 1; rballoc_sub_UE[CC_id][UE_id][j] = 1; rballoc_sub_UE[CC_id][UE_id2][j] = 1; MIMO_mode_indicator[CC_id][j] = 0; if (j< N_RBG[CC_id]-1) { rballoc_sub[CC_id][j+1] = 1; rballoc_sub_UE[CC_id][UE_id][j+1] = 1; rballoc_sub_UE[CC_id][UE_id2][j+1] = 1; MIMO_mode_indicator[CC_id][j+1] = 0; } dl_pow_off[CC_id][UE_id] = 0; dl_pow_off[CC_id][UE_id2] = 0; if ((j == N_RBG[CC_id]-1) && ((PHY_vars_eNB_g[Mod_id][CC_id]->lte_frame_parms.N_RB_DL == 25) || (PHY_vars_eNB_g[Mod_id][CC_id]->lte_frame_parms.N_RB_DL == 50))){ nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - min_rb_unit[CC_id]+1; pre_nb_available_rbs[CC_id][UE_id] = pre_nb_available_rbs[CC_id][UE_id] + min_rb_unit[CC_id]-1; nb_rbs_required_remaining[CC_id][UE_id2] = nb_rbs_required_remaining[CC_id][UE_id2] - min_rb_unit[CC_id]+1; pre_nb_available_rbs[CC_id][UE_id2] = pre_nb_available_rbs[CC_id][UE_id2] + min_rb_unit[CC_id]-1; } else { nb_rbs_required_remaining[CC_id][UE_id] = nb_rbs_required_remaining[CC_id][UE_id] - 4; pre_nb_available_rbs[CC_id][UE_id] = pre_nb_available_rbs[CC_id][UE_id] + 4; nb_rbs_required_remaining[CC_id][UE_id2] = nb_rbs_required_remaining[CC_id][UE_id2] - 4; pre_nb_available_rbs[CC_id][UE_id2] = pre_nb_available_rbs[CC_id][UE_id2] + 4; } break; } } } } } } } #endif } } } // total_ue_count } // end of for for r1 and r2 #ifdef TM5 // This has to be revisited!!!! for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { i1=0; i2=0; i3=0; for (j=0;j<N_RBG[CC_id];j++){ if(MIMO_mode_indicator[CC_id][j] == 2) i1 = i1+1; else if(MIMO_mode_indicator[CC_id][j] == 1) i2 = i2+1; else if(MIMO_mode_indicator[CC_id][j] == 0) i3 = i3+1; } if((i1 < N_RBG[CC_id]) && (i2>0) && (i3==0)) PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_SUMIMO_transmissions + 1; if(i3 == N_RBG[CC_id] && i1==0 && i2==0) PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->FULL_MUMIMO_transmissions + 1; if((i1 < N_RBG[CC_id]) && (i3 > 0)) PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_MUMIMO_transmissions + 1; PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions = PHY_vars_eNB_g[Mod_id][CC_id]->check_for_total_transmissions + 1; } #endif for(i=UE_list->head; i>=0;i=UE_list->next[i]) { UE_id = i; for (ii=0;ii<UE_num_active_CC(UE_list,UE_id);ii++) { CC_id = UE_list->ordered_CCids[ii][UE_id]; //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; LOG_D(MAC,"******************DL Scheduling Information for UE%d ************************\n",UE_id); LOG_D(MAC,"dl power offset UE%d = %d \n",UE_id,dl_pow_off[CC_id][UE_id]); LOG_D(MAC,"***********RB Alloc for every subband for UE%d ***********\n",UE_id); for(j=0;j<N_RBG[CC_id];j++){ //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[CC_id][UE_id][i]; LOG_D(MAC,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,rballoc_sub_UE[CC_id][UE_id][j]); } //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[CC_id][UE_id]; LOG_D(MAC,"Total RBs allocated for UE%d = %d\n",UE_id,pre_nb_available_rbs[CC_id][UE_id]); } } }
/** * Checks if incoming PDU has a sequence number in accordance with the RX window * @return 1 if SN is okay, 0 otherwise * XXX Reordering window should also be handled here */ boolean_t pdcp_is_rx_seq_number_valid(uint16_t seq_num, pdcp_t* pdcp_entity,srb_flag_t srb_flagP) { uint16_t reordering_window = 0; #if 0 LOG_D(PDCP, "Incoming RX Sequence number is %04d\n", seq_num); #endif if (pdcp_is_seq_num_size_valid(pdcp_entity) == FALSE || pdcp_is_seq_num_valid(seq_num, pdcp_entity->seq_num_size) == FALSE) { return FALSE; } /* * Mark received sequence numbers to keep track of missing ones * (and to build PDCP Control PDU for PDCP status report) */ if (pdcp_mark_current_pdu_as_received(seq_num, pdcp_entity) == TRUE) { #if 0 LOG_I(PDCP, "Received sequence number successfuly marked\n"); #endif } else { LOG_W(PDCP, "Cannot mark received sequence number on the bitmap!\n"); } /* * RX Procedures for SRB and DRBs as described in sec 5.1.2 of 36.323 */ if (srb_flagP) { // SRB if (seq_num < pdcp_entity->next_pdcp_rx_sn) { // decipher and verify the integrity of the PDU (if applicable) using COUNT based on RX_HFN + 1 and the received PDCP SN pdcp_entity->rx_hfn++; pdcp_entity->rx_hfn_offset = 0; } else { // decipher and verify the integrity of the PDU (if applicable) using COUNT based using COUNT based on RX_HFN and the received PDCP SN pdcp_entity->rx_hfn_offset = 0; } // Assume that integrity verification is applicable and the integrity verification is passed successfully; // or assume that integrity verification is not applicable: // same the old next_pdcp_rx_sn to revert otherwise pdcp_entity->next_pdcp_rx_sn_before_integrity = pdcp_entity->next_pdcp_rx_sn; #if 0 if (seq_num != pdcp_entity->next_pdcp_rx_sn) { LOG_D(PDCP,"Re-adjusting the sequence number to %d\n", seq_num); } #endif //set Next_PDCP_RX_SN to the received PDCP SN +1 ; pdcp_entity->next_pdcp_rx_sn = seq_num; pdcp_advance_rx_window(pdcp_entity); // + 1, and check if it is larger than Maximum_PDCP_SN: } else { // DRB if (pdcp_entity->seq_num_size == PDCP_SN_7BIT) { reordering_window = REORDERING_WINDOW_SN_7BIT; } else { reordering_window = REORDERING_WINDOW_SN_12BIT; } switch (pdcp_entity->rlc_mode) { case RLC_MODE_AM: if ((seq_num - pdcp_entity->last_submitted_pdcp_rx_sn > reordering_window) || ((0 <= pdcp_entity->last_submitted_pdcp_rx_sn - seq_num) && (pdcp_entity->last_submitted_pdcp_rx_sn - seq_num < reordering_window) )) { if (seq_num > pdcp_entity->next_pdcp_rx_sn) { /* * decipher the PDCP PDU as specified in the subclause 5.6, using COUNT based on RX_HFN - 1 and the received PDCP SN; */ pdcp_entity->rx_hfn_offset = -1; } else { /* * decipher the PDCP PDU as specified in the subclause 5.6, using COUNT based on RX_HFN and the received PDCP SN; */ pdcp_entity->rx_hfn_offset = 0; } // discard this PDCP SDU; LOG_W(PDCP, "Out of the reordering window (Incoming SN:%d, Expected SN:%d): discard this PDCP SDU\n", seq_num, pdcp_entity->next_pdcp_rx_sn); return FALSE; } else if (pdcp_entity->next_pdcp_rx_sn - seq_num > reordering_window) { pdcp_entity->rx_hfn++; // use COUNT based on RX_HFN and the received PDCP SN for deciphering the PDCP PDU; pdcp_entity->rx_hfn_offset = 0; pdcp_entity->next_pdcp_rx_sn++; } else if (seq_num - pdcp_entity->next_pdcp_rx_sn >= reordering_window ) { // use COUNT based on RX_HFN – 1 and the received PDCP SN for deciphering the PDCP PDU; pdcp_entity->rx_hfn_offset = -1; } else if (seq_num >= pdcp_entity->next_pdcp_rx_sn ) { // use COUNT based on RX_HFN and the received PDCP SN for deciphering the PDCP PDU; pdcp_entity->rx_hfn_offset = 0; //set Next_PDCP_RX_SN to the received PDCP SN +1 ; pdcp_entity->next_pdcp_rx_sn = seq_num; pdcp_advance_rx_window(pdcp_entity); // + 1, anc check if it is larger than Maximum_PDCP_SN: #if 0 LOG_D(PDCP,"Re-adjusting the sequence number to %d\n", seq_num); #endif } else if (seq_num < pdcp_entity->next_pdcp_rx_sn) { // use COUNT based on RX_HFN and the received PDCP SN for deciphering the PDCP PDU; pdcp_entity->rx_hfn_offset = 0; } break; case RLC_MODE_UM : if (seq_num < pdcp_entity->next_pdcp_rx_sn) { pdcp_entity->rx_hfn++; } // decipher the PDCP Data PDU using COUNT based on RX_HFN and the received PDCP SN as specified in the subclause 5.6; //set Next_PDCP_RX_SN to the received PDCP SN +1 ; pdcp_entity->next_pdcp_rx_sn = seq_num; pdcp_advance_rx_window(pdcp_entity); // + 1, and check if it is larger than Maximum_PDCP_SN: break; case RLC_MODE_TM : default: LOG_W(PDCP,"RLC mode %d not supported\n",pdcp_entity->rlc_mode); return FALSE; } } /* if (seq_num == pdcp_entity->next_pdcp_rx_sn) { LOG_I(PDCP, "Next expected SN (%d) arrived, advancing RX window\n", seq_num); return pdcp_advance_rx_window(pdcp_entity); } else { LOG_E(PDCP, "Incoming SN is not the one we expected to receive! (Incoming:%d, Expected:%d)\n", \ seq_num, pdcp_entity->next_pdcp_rx_sn); // Update first missing PDU (used in PDCP Control PDU for PDCP status report, see 6.2.6) if (pdcp_entity->first_missing_pdu != -1) pdcp_entity->first_missing_pdu = pdcp_entity->next_pdcp_rx_sn; return FALSE; } */ return TRUE; }
void CollisionSystem::Update(float dt) { // Avoid warnings for not using dt. LOG_D("[CollisionSystem] Update: " << dt); CheckCollisions(); }
RRC_status_t rrc_rx_tx(uint8_t Mod_id, const frame_t frameP, const eNB_flag_t eNB_flagP,uint8_t index,int CC_id){ uint8_t UE_id; int32_t current_timestamp_ms, ref_timestamp_ms; struct timeval ts; if(eNB_flagP == 0) { // check timers if (UE_rrc_inst[Mod_id].Info[index].T300_active == 1) { if ((UE_rrc_inst[Mod_id].Info[index].T300_cnt % 10) == 0) LOG_D(RRC, "[UE %d][RAPROC] Frame %d T300 Count %d ms\n", Mod_id, frameP, UE_rrc_inst[Mod_id].Info[index].T300_cnt); if (UE_rrc_inst[Mod_id].Info[index].T300_cnt == T300[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t300]) { UE_rrc_inst[Mod_id].Info[index].T300_active = 0; // ALLOW CCCH to be used UE_rrc_inst[Mod_id].Srb0[index].Tx_buffer.payload_size = 0; rrc_ue_generate_RRCConnectionRequest (Mod_id, frameP, index); return (RRC_ConnSetup_failed); } UE_rrc_inst[Mod_id].Info[index].T300_cnt++; } if (UE_rrc_inst[Mod_id].sib2[index]) { if (UE_rrc_inst[Mod_id].Info[index].N310_cnt == N310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n310]) { UE_rrc_inst[Mod_id].Info[index].T310_active = 1; } } else { // in case we have not received SIB2 yet if (UE_rrc_inst[Mod_id].Info[index].N310_cnt == 100) { UE_rrc_inst[Mod_id].Info[index].N310_cnt = 0; return RRC_PHY_RESYNCH; } } if (UE_rrc_inst[Mod_id].Info[index].T310_active == 1) { if (UE_rrc_inst[Mod_id].Info[index].N311_cnt == N311[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.n311]) { UE_rrc_inst[Mod_id].Info[index].T310_active = 0; UE_rrc_inst[Mod_id].Info[index].N311_cnt = 0; } if ((UE_rrc_inst[Mod_id].Info[index].T310_cnt % 10) == 0) LOG_D(RRC, "[UE %d] Frame %d T310 Count %d ms\n", Mod_id, frameP, UE_rrc_inst[Mod_id].Info[index].T310_cnt); if (UE_rrc_inst[Mod_id].Info[index].T310_cnt == T310[UE_rrc_inst[Mod_id].sib2[index]->ue_TimersAndConstants.t310]) { UE_rrc_inst[Mod_id].Info[index].T310_active = 0; rrc_t310_expiration (frameP, Mod_id, index); return (RRC_PHY_RESYNCH); } UE_rrc_inst[Mod_id].Info[index].T310_cnt++; } if (UE_rrc_inst[Mod_id].Info[index].T304_active==1) { if ((UE_rrc_inst[Mod_id].Info[index].T304_cnt % 10) == 0) LOG_D(RRC,"[UE %d][RAPROC] Frame %d T304 Count %d ms\n",Mod_id,frameP, UE_rrc_inst[Mod_id].Info[index].T304_cnt); if (UE_rrc_inst[Mod_id].Info[index].T304_cnt == 0) { UE_rrc_inst[Mod_id].Info[index].T304_active = 0; UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag = 1; LOG_E(RRC,"[UE %d] Handover failure..initiating connection re-establishment procedure... \n"); //Implement 36.331, section 5.3.5.6 here return(RRC_Handover_failed); } UE_rrc_inst[Mod_id].Info[index].T304_cnt--; } // Layer 3 filtering of RRC measurements if (UE_rrc_inst[Mod_id].QuantityConfig[0] != NULL) { ue_meas_filtering(Mod_id,frameP,index); } ue_measurement_report_triggering(Mod_id,frameP,index); if (UE_rrc_inst[Mod_id].Info[0].handoverTarget > 0) LOG_I(RRC,"[UE %d] Frame %d : RRC handover initiated\n", Mod_id, frameP); if((UE_rrc_inst[Mod_id].Info[index].State == RRC_HO_EXECUTION) && (UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId != 0xFF)) { UE_rrc_inst[Mod_id].Info[index].State= RRC_IDLE; return(RRC_HO_STARTED); } } else { // eNB check_handovers(Mod_id,frameP); // counetr, and get the value and aggregate #ifdef LOCALIZATION /* for the localization, only primary CC_id might be relevant*/ gettimeofday(&ts, NULL); current_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; ref_timestamp_ms = eNB_rrc_inst[Mod_id].reference_timestamp_ms; for (UE_id=0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { if ((current_timestamp_ms - ref_timestamp_ms > eNB_rrc_inst[Mod_id].aggregation_period_ms) && rrc_get_estimated_ue_distance(Mod_id,frameP,UE_id, CC_id,eNB_rrc_inst[Mod_id].loc_type) != -1) { LOG_D(LOCALIZE, " RRC [UE/id %d -> eNB/id %d] timestamp %d frame %d estimated r = %f\n", UE_id, Mod_id, current_timestamp_ms, frameP, rrc_get_estimated_ue_distance(Mod_id,frameP,UE_id, CC_id,eNB_rrc_inst[Mod_id].loc_type)); LOG_D(LOCALIZE, " RRC status %d\n", eNB_rrc_inst[Mod_id].Info.UE[UE_id].Status); push_front(&eNB_rrc_inst[Mod_id].loc_list, rrc_get_estimated_ue_distance(Mod_id,frameP,UE_id, CC_id,eNB_rrc_inst[Mod_id].loc_type)); eNB_rrc_inst[Mod_id].reference_timestamp_ms = current_timestamp_ms; } } #endif } return (RRC_OK); }
/*------------------------------------------------------------------------------*/ void openair_rrc_top_init(int eMBMS_active, uint8_t cba_group_active,uint8_t HO_active){ /*-----------------------------------------------------------------------------*/ module_id_t module_id; OAI_UECapability_t *UECap = NULL; // uint8_t dummy_buffer[100]; LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST); if (NB_UE_INST > 0) { UE_rrc_inst = (UE_RRC_INST*) malloc16(NB_UE_INST*sizeof(UE_RRC_INST)); memset (UE_rrc_inst, 0, NB_UE_INST * sizeof(UE_RRC_INST)); LOG_D(RRC, "ALLOCATE %d Bytes for UE_RRC_INST @ %p\n", (unsigned int)(NB_UE_INST*sizeof(UE_RRC_INST)), UE_rrc_inst); // fill UE capability UECap = fill_ue_capability (); for (module_id = 0; module_id < NB_UE_INST; module_id++) { UE_rrc_inst[module_id].UECapability = UECap->sdu; UE_rrc_inst[module_id].UECapability_size = UECap->sdu_size; } /* do_UECapabilityEnquiry(0, dummy_buffer, 0, 0);*/ #ifdef Rel10 LOG_I(RRC,"[UE] eMBMS active state is %d \n", eMBMS_active); for (module_id=0;module_id<NB_UE_INST;module_id++) { UE_rrc_inst[module_id].MBMS_flag = (uint8_t)eMBMS_active; } #endif } else UE_rrc_inst = NULL; if (NB_eNB_INST > 0) { eNB_rrc_inst = (eNB_RRC_INST*) malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST)); memset (eNB_rrc_inst, 0, NB_eNB_INST * sizeof(eNB_RRC_INST)); LOG_I(RRC,"[eNB] handover active state is %d \n", HO_active); for (module_id=0;module_id<NB_eNB_INST;module_id++) { eNB_rrc_inst[module_id].HO_flag = (uint8_t)HO_active; } #ifdef Rel10 LOG_I(RRC,"[eNB] eMBMS active state is %d \n", eMBMS_active); for (module_id=0;module_id<NB_eNB_INST;module_id++) { eNB_rrc_inst[module_id].MBMS_flag = (uint8_t)eMBMS_active; } #endif #ifdef CBA for (module_id=0;module_id<NB_eNB_INST;module_id++) { eNB_rrc_inst[module_id].num_active_cba_groups = cba_group_active; } #endif #ifdef LOCALIZATION /* later set this from xml or enb.config file*/ struct timeval ts; // time struct gettimeofday(&ts, NULL); // get the current epoch timestamp for (module_id=0;module_id<NB_eNB_INST;module_id++) { eNB_rrc_inst[module_id].reference_timestamp_ms = ts.tv_sec * 1000 + ts.tv_usec / 1000; initialize(&eNB_rrc_inst[module_id].loc_list); eNB_rrc_inst[module_id].loc_type=0; eNB_rrc_inst[module_id].aggregation_period_ms = 5000; } #endif LOG_D(RRC, "ALLOCATE %d Bytes for eNB_RRC_INST @ %p\n", (unsigned int)(NB_eNB_INST*sizeof(eNB_RRC_INST)), eNB_rrc_inst); } else eNB_rrc_inst = NULL; #ifndef NO_RRM #ifndef USER_MODE Header_buf=(char*)malloc16(sizeof(msg_head_t)); Data=(char*)malloc16(2400); Header_read_idx=0; Data_read_idx=0; Header_size=sizeof(msg_head_t); #endif //NO_RRM Data_to_read = 0; #endif //USER_MODE }
static bool files_readdir(honggfuzz_t * hfuzz) { DIR *dir = opendir(hfuzz->inputDir); if (!dir) { PLOG_W("Couldn't open dir '%s'", hfuzz->inputDir); return false; } defer { closedir(dir); }; size_t maxSize = 0UL; unsigned count = 0; for (;;) { errno = 0; struct dirent *res = readdir(dir); if (res == NULL && errno != 0) { PLOG_W("Couldn't read the '%s' dir", hfuzz->inputDir); return false; } if (res == NULL) { break; } char path[PATH_MAX]; snprintf(path, sizeof(path), "%s/%s", hfuzz->inputDir, res->d_name); struct stat st; if (stat(path, &st) == -1) { LOG_W("Couldn't stat() the '%s' file", path); continue; } if (!S_ISREG(st.st_mode)) { LOG_D("'%s' is not a regular file, skipping", path); continue; } if (st.st_size == 0ULL) { LOG_D("'%s' is empty", path); continue; } if (hfuzz->maxFileSz != 0UL && st.st_size > (off_t) hfuzz->maxFileSz) { LOG_W("File '%s' is bigger than maximal defined file size (-F): %" PRId64 " > %" PRId64, path, (int64_t) st.st_size, (int64_t) hfuzz->maxFileSz); continue; } if (!(hfuzz->files = util_Realloc(hfuzz->files, sizeof(char *) * (count + 1)))) { PLOG_W("Couldn't allocate memory"); return false; } if ((size_t) st.st_size > maxSize) { maxSize = st.st_size; } hfuzz->files[count] = util_StrDup(path); hfuzz->fileCnt = ++count; LOG_D("Added '%s' to the list of input files", path); } if (count == 0) { LOG_W("Directory '%s' doesn't contain any regular files", hfuzz->inputDir); return false; } if (hfuzz->maxFileSz == 0UL) { hfuzz->maxFileSz = maxSize; } LOG_I("%zu input files have been added to the list. Max file size: %zu", hfuzz->fileCnt, hfuzz->maxFileSz); return true; }
void phy_adjust_gain (PHY_VARS_UE *phy_vars_ue, uint8_t eNB_id) { uint16_t rx_power_fil_dB; #ifdef EXMIMO exmimo_config_t *p_exmimo_config = openair0_exmimo_pci[card].exmimo_config_ptr; uint16_t i; #endif int rssi; rssi = dB_fixed(phy_vars_ue->PHY_measurements.rssi); if (rssi>0) rx_power_fil_dB = rssi; else rx_power_fil_dB = phy_vars_ue->PHY_measurements.rx_power_avg_dB[eNB_id]; LOG_D(PHY,"Gain control: rssi %d (%d,%d)\n", rssi, phy_vars_ue->PHY_measurements.rssi, phy_vars_ue->PHY_measurements.rx_power_avg_dB[eNB_id] ); // Gain control with hysterisis // Adjust gain in phy_vars_ue->rx_vars[0].rx_total_gain_dB if (rx_power_fil_dB < TARGET_RX_POWER - 5) //&& (phy_vars_ue->rx_total_gain_dB < MAX_RF_GAIN) ) phy_vars_ue->rx_total_gain_dB+=5; else if (rx_power_fil_dB > TARGET_RX_POWER + 5) //&& (phy_vars_ue->rx_total_gain_dB > MIN_RF_GAIN) ) phy_vars_ue->rx_total_gain_dB-=5; if (phy_vars_ue->rx_total_gain_dB>MAX_RF_GAIN) { /* if ((openair_daq_vars.rx_rf_mode==0) && (openair_daq_vars.mode == openair_NOT_SYNCHED)) { openair_daq_vars.rx_rf_mode=1; phy_vars_ue->rx_total_gain_dB = max(MIN_RF_GAIN,MAX_RF_GAIN-25); } else { */ phy_vars_ue->rx_total_gain_dB = MAX_RF_GAIN; } else if (phy_vars_ue->rx_total_gain_dB<MIN_RF_GAIN) { /* if ((openair_daq_vars.rx_rf_mode==1) && (openair_daq_vars.mode == openair_NOT_SYNCHED)) { openair_daq_vars.rx_rf_mode=0; phy_vars_ue->rx_total_gain_dB = min(MAX_RF_GAIN,MIN_RF_GAIN+25); } else { */ phy_vars_ue->rx_total_gain_dB = MIN_RF_GAIN; } LOG_D(PHY,"Gain control: rx_total_gain_dB = %d (max %d,rxpf %d)\n",phy_vars_ue->rx_total_gain_dB,MAX_RF_GAIN,rx_power_fil_dB); #ifdef EXMIMO if (phy_vars_ue->rx_total_gain_dB>phy_vars_ue->rx_gain_max[0]) { phy_vars_ue->rx_total_gain_dB = phy_vars_ue->rx_gain_max[0]; for (i=0; i<phy_vars_ue->lte_frame_parms.nb_antennas_rx; i++) { p_exmimo_config->rf.rx_gain[i][0] = 30; } } else if (phy_vars_ue->rx_total_gain_dB<(phy_vars_ue->rx_gain_max[0]-30)) { // for the moment we stay in max gain mode phy_vars_ue->rx_total_gain_dB = phy_vars_ue->rx_gain_max[0] - 30; for (i=0; i<phy_vars_ue->lte_frame_parms.nb_antennas_rx; i++) { p_exmimo_config->rf.rx_gain[i][0] = 0; } /* phy_vars_ue->rx_gain_mode[0] = byp; phy_vars_ue->rx_gain_mode[1] = byp; exmimo_pci_interface->rf.rf_mode0 = 22991; //bypass exmimo_pci_interface->rf.rf_mode1 = 22991; //bypass if (phy_vars_ue->rx_total_gain_dB<(phy_vars_ue->rx_gain_byp[0]-50)) { exmimo_pci_interface->rf.rx_gain00 = 0; exmimo_pci_interface->rf.rx_gain10 = 0; } */ } else { for (i=0; i<phy_vars_ue->lte_frame_parms.nb_antennas_rx; i++) { p_exmimo_config->rf.rx_gain[i][0] = 30 - phy_vars_ue->rx_gain_max[0] + phy_vars_ue->rx_total_gain_dB; } } /* break; case med_gain: case byp_gain: if (phy_vars_ue->rx_total_gain_dB>phy_vars_ue->rx_gain_byp[0]) { phy_vars_ue->rx_gain_mode[0] = max_gain; phy_vars_ue->rx_gain_mode[1] = max_gain; exmimo_pci_interface->rf.rf_mode0 = 55759; //max gain exmimo_pci_interface->rf.rf_mode1 = 55759; //max gain if (phy_vars_ue->rx_total_gain_dB>phy_vars_ue->rx_gain_max[0]) { exmimo_pci_interface->rf.rx_gain00 = 50; exmimo_pci_interface->rf.rx_gain10 = 50; } else { exmimo_pci_interface->rf.rx_gain00 = 50 - phy_vars_ue->rx_gain_max[0] + phy_vars_ue->rx_total_gain_dB; exmimo_pci_interface->rf.rx_gain10 = 50 - phy_vars_ue->rx_gain_max[1] + phy_vars_ue->rx_total_gain_dB; } } else if (phy_vars_ue->rx_total_gain_dB<(phy_vars_ue->rx_gain_byp[0]-50)) { exmimo_pci_interface->rf.rx_gain00 = 0; exmimo_pci_interface->rf.rx_gain10 = 0; } else { exmimo_pci_interface->rf.rx_gain00 = 50 - phy_vars_ue->rx_gain_byp[0] + phy_vars_ue->rx_total_gain_dB; exmimo_pci_interface->rf.rx_gain10 = 50 - phy_vars_ue->rx_gain_byp[1] + phy_vars_ue->rx_total_gain_dB; } break; default: exmimo_pci_interface->rf.rx_gain00 = 50; exmimo_pci_interface->rf.rx_gain10 = 50; break; } */ #endif #ifdef DEBUG_PHY /* if ((phy_vars_ue->frame%100==0) || (phy_vars_ue->frame < 10)) msg("[PHY][ADJUST_GAIN] frame %d, rx_power = %d, rx_power_fil = %d, rx_power_fil_dB = %d, coef=%d, ncoef=%d, rx_total_gain_dB = %d (%d,%d,%d)\n", phy_vars_ue->frame,rx_power,rx_power_fil,rx_power_fil_dB,coef,ncoef,phy_vars_ue->rx_total_gain_dB, TARGET_RX_POWER,MAX_RF_GAIN,MIN_RF_GAIN); */ #endif //DEBUG_PHY }
int main( int argc, char *argv[] ) { const char *libname = "libui.so"; int classBuf[ 100 ]; int r1[ 10 ]; int r2[ 10 ]; int r3[ 10 ]; int jellybean = 0; int ( *unflatten )( int *r0, int *r1, int *r2, int *r3 ) = NULL; printf( "hello world\n" ); fflush( stdout ); void *handle = dlopen( libname, RTLD_NOW | RTLD_GLOBAL ); if( !handle ) { LOG_D( "error opening %s: %s\n", libname, dlerror() ); return -1; } bzero( classBuf, sizeof( classBuf ) ); bzero( r1, sizeof( r1 ) ); bzero( r2, sizeof( r2 ) ); bzero( r3, sizeof( r3 ) ); int ( *constructor )( int *r0 ) = dlsym( handle, "_ZN7android13GraphicBufferC2Ev" ); if( !constructor ) { LOG_D( "missing android::GraphicBuffer::GraphicBuffer(void)\n" ); return -1; } unflatten = dlsym( handle, "_ZN7android13GraphicBuffer9unflattenERPKvRjRPKiS4_" ); if( !unflatten ) { unflatten = dlsym( handle, "_ZN7android13GraphicBuffer9unflattenEPKvjPij" ); if( !unflatten ) { LOG_D( "missing android::GraphicBuffer::unflatten\n" ); return -1; } jellybean = 1; } constructor( classBuf ); // setup bad values int r1Ref = (int)(&r1[0]); // this must match r1[0] = 0x47424652; // size must be > 0x1f r2[0] = 0x20; // attempt to overflow r1[8] = 0x1000; r1[9] = 0xFF5; // make sure we error out on unpatched libs before getting to the point where we corrupt the heap r1[6] = 0x20; r1[7] = 0x20; int ret = 0; if( !jellybean ) { ret = unflatten( classBuf, &r1Ref, r2, r3 ); } else { int * val = (int*)(r2[0]); ret = unflatten( classBuf, r1, val, r3 ); } // -12 = unpatched 4.4.2 // -22 = patches 5.1.1 switch( ret ) { case -ENOMEM: printf( "unpatched\n" ); break; case -EINVAL: printf( "patched\n" ); break; default: printf( "test is broken ret: %d (%08x)\n", ret, ret ); break; } return 0; }
int HttpListener::handleEvents( short event ) { static struct conn_data conns[CONN_BATCH_SIZE]; static struct conn_data * pEnd = &conns[CONN_BATCH_SIZE]; struct conn_data * pCur = conns; int allowed; int iCount = 0; ConnLimitCtrl * pCLC = HttpGlobals::getConnLimitCtrl(); int limitType = 1; allowed = pCLC->availConn(); if ( isSSL() ) { if ( allowed > pCLC->availSSLConn() ) { allowed = pCLC->availSSLConn(); limitType = 2; } } while( iCount < allowed ) { socklen_t len = 24; pCur->fd = accept( getfd(), (struct sockaddr *)(pCur->achPeerAddr), &len ); if ( pCur->fd == -1 ) { resetRevent( POLLIN ); if (( errno != EAGAIN )&&( errno != ECONNABORTED ) &&( errno != EINTR )) { LOG_ERR(( getLogger(), "HttpListener::acceptConnection(): [%s] can't accept:%s!", getAddrStr(), strerror( errno ) )); } break; } //++iCount; //addConnection( conns, &iCount ); ++pCur; if ( pCur == pEnd ) { iCount += CONN_BATCH_SIZE; batchAddConn( conns, pCur, &iCount ); pCur = conns; } } if ( pCur > conns ) { int n = pCur - conns; iCount += n; if ( n > 1 ) batchAddConn( conns, pCur, &iCount ); else addConnection( conns, &iCount ); } if ( iCount > 0 ) { m_pMapVHost->incRef( iCount ); pCLC->incConn( iCount ); } if ( iCount >= allowed ) { if ( limitType == 1 ) { if ( D_ENABLED( DL_MORE ) ) { LOG_D(( getLogger(), "[%s] max connections reached, suspend accepting!", getAddrStr() )); } pCLC->suspendAll(); } else { if ( D_ENABLED( DL_MORE ) ) { LOG_D(( getLogger(), "[%s] max SSL connections reached, suspend accepting!", getAddrStr() )); } pCLC->suspendSSL(); } } if ( D_ENABLED( DL_MORE ) ) { LOG_D(( getLogger(), "[%s] %d connections accepted!", getAddrStr(), iCount )); } return 0; }
void Texture::SetFilter(MipMap min, MipMap mag) { switch (mag) { case MM_LINEAR: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } break; case MM_NEAREST: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } break; default: { LOG_D("<!Texture.cpp> Warning: Mipmap mode for Magnify should be: GL_LINEAR or GL_NEAREST\n"); } break; } switch (min) { case MM_LINEAR: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } break; case MM_LINEAR_LINEAR: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glGenerateMipmap(GL_TEXTURE_2D); } break; case MM_LINEAR_NEAREST: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); glGenerateMipmap(GL_TEXTURE_2D); } break; case MM_NEAREST: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); } break; case MM_NEAREST_LINEAR: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR); glGenerateMipmap(GL_TEXTURE_2D); } break; case MM_NEAREST_NEAREST: { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glGenerateMipmap(GL_TEXTURE_2D); } break; default: break; } }
JNIEXPORT jint JNICALL Java_com_sina_sinavideo_coreplayer_splayer_SPlayer_initializeLibs( JNIEnv *env, jobject thiz, jstring libPath, jstring destDir, jstring prefix ) { LOG_D("%s: into.\n",__FUNCTION__); #define ARGC 6 const char *test_args [ARGC+1] = { "7za", "e", "-r", 0, //"-o/media", 0, //"/media/libsplayer.7z", 0, //"libneon.so", 0 }; const char *tmpPath = env->GetStringUTFChars(libPath, NULL); if (tmpPath == NULL) { // Out of memory LOG_E("%s: get libPath fail\n",__FUNCTION__); return -1; } const char *tmpDest = env->GetStringUTFChars(destDir, NULL); if (tmpDest == NULL) { // Out of memory LOG_E("%s: get destDir fail\n",__FUNCTION__); return -1; } const char *tmpPrefix = env->GetStringUTFChars(prefix, NULL); if (tmpDest == NULL) { // Out of memory LOG_E("%s: get prefix fail\n",__FUNCTION__); return -1; } LOG_D("%s: libPath=%s,destDir=%s,prefix=%s.\n",__FUNCTION__,tmpPath,tmpDest,tmpPrefix); char arg_out_path[1024]; memset(arg_out_path,0,sizeof(arg_out_path)); sprintf(arg_out_path,"-o%s",tmpDest); test_args[3] = arg_out_path; //char arg_src_file[1024]; //memset(arg_src_file,0,sizeof(arg_src_file)); //sprintf(arg_out_path,"%s",tmpPath); test_args[4] = tmpPath; char arg_extrat_file[100]; memset(arg_extrat_file,0,sizeof(arg_extrat_file)); sprintf(arg_extrat_file,"%s/*",tmpPrefix); test_args[5] = arg_extrat_file; jint ret = andro7za_main(ARGC, test_args); env->ReleaseStringUTFChars(libPath, tmpPath); tmpPath = NULL; env->ReleaseStringUTFChars(destDir, tmpDest); tmpDest = NULL; env->ReleaseStringUTFChars(prefix, tmpPrefix); tmpPrefix = NULL; LOG_D("%s: out. ret=%d\n",__FUNCTION__,ret); return ret; }
//----------------------------------------------------------------------------- void rlc_am_reassemble_pdu(rlc_am_entity_t* rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP) { //----------------------------------------------------------------------------- int i,j; rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tbP->data))->pdu_info; #ifdef TRACE_RLC_AM_REASSEMBLY LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU SN=%03d\n", frame, rlcP->module_id, rlcP->rb_id, pdu_info->sn); rlc_am_display_data_pdu_infos(rlcP, frame, pdu_info); #endif if (pdu_info->e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { switch (pdu_info->fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", frame, rlcP->module_id, rlcP->rb_id); #endif // one complete SDU rlc_am_send_sdu(rlcP,frame,eNB_flag); // may be not necessary rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); // may be not necessary //rlcP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", frame, rlcP->module_id, rlcP->rb_id); #endif // one beginning segment of SDU in PDU rlc_am_send_sdu(rlcP,frame,eNB_flag); // may be not necessary rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); //rlcP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", frame, rlcP->module_id, rlcP->rb_id); #endif // one last segment of SDU //if (rlcP->reassembly_missing_sn_detected == 0) { rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); //} // else { clear sdu already done //rlcP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", frame, rlcP->module_id, rlcP->rb_id); #endif //if (rlcP->reassembly_missing_sn_detected == 0) { // one whole segment of SDU in PDU rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); //} else { // rlcP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code //} break; #ifdef USER_MODE default: assert(0 != 0); #endif } } else { switch (pdu_info->fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=11 (00) Li=", frame, rlcP->module_id, rlcP->rb_id); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); } LOG_D(RLC, "\n"); //msg(" remaining size %d\n",size); #endif // N complete SDUs rlc_am_send_sdu(rlcP,frame,eNB_flag); j = 0; for (i = 0; i < pdu_info->num_li; i++) { rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); j = j + pdu_info->li_list[i]; } if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug // data is already ok, done by last loop above rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); } //rlcP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=10 (01) Li=", frame, rlcP->module_id, rlcP->rb_id); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); } LOG_D(RLC, "\n"); //msg(" remaining size %d\n",size); #endif // N complete SDUs + one segment of SDU in PDU rlc_am_send_sdu(rlcP,frame,eNB_flag); j = 0; for (i = 0; i < pdu_info->num_li; i++) { rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); j = j + pdu_info->li_list[i]; } if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug // data is already ok, done by last loop above rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP, frame); } //rlcP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=01 (10) Li=", frame, rlcP->module_id, rlcP->rb_id); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); } LOG_D(RLC, "\n"); //msg(" remaining size %d\n",size); #endif // one last segment of SDU + N complete SDUs in PDU j = 0; for (i = 0; i < pdu_info->num_li; i++) { rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); j = j + pdu_info->li_list[i]; } if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug // data is already ok, done by last loop above rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); } //rlcP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: #ifdef TRACE_RLC_AM_RX_DECODE LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=00 (11) Li=", frame, rlcP->module_id, rlcP->rb_id); for (i=0; i < pdu_info->num_li; i++) { LOG_D(RLC, "%d ",pdu_info->li_list[i]); } LOG_D(RLC, "\n"); //msg(" remaining size %d\n",size); #endif j = 0; for (i = 0; i < pdu_info->num_li; i++) { rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); rlc_am_send_sdu(rlcP,frame,eNB_flag); j = j + pdu_info->li_list[i]; } if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug // data is already ok, done by last loop above rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP,frame); } else { #ifdef USER_MODE //assert (5!=5); #endif } //rlcP->reassembly_missing_sn_detected = 0; break; #ifdef USER_MODE default: assert(1 != 1); #endif } } free_mem_block(tbP); }
// This function returns the estimated number of RBs required by each UE for downlink scheduling void assign_rbs_required (module_id_t Mod_id, frame_t frameP, sub_frame_t subframe, uint16_t nb_rbs_required[MAX_NUM_CCs][NUMBER_OF_UE_MAX], int min_rb_unit[MAX_NUM_CCs]){ rnti_t rnti; uint16_t TBS = 0; LTE_eNB_UE_stats *eNB_UE_stats[MAX_NUM_CCs]; int UE_id,n,i,j,CC_id,pCCid,tmp; UE_list_t *UE_list = &eNB_mac_inst[Mod_id].UE_list; UE_TEMPLATE *UE_template; LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]; // clear rb allocations across all CC_ids for (UE_id=UE_list->head;UE_id>=0;UE_id=UE_list->next[UE_id]){ pCCid = UE_PCCID(Mod_id,UE_id); rnti = UE_list->UE_template[pCCid][UE_id].rnti; //update CQI information across component carriers for (n=0;n<UE_list->numactiveCCs[UE_id];n++) { CC_id = UE_list->ordered_CCids[n][UE_id]; frame_parms[CC_id] = mac_xface->get_lte_frame_parms(Mod_id,CC_id); eNB_UE_stats[CC_id] = mac_xface->get_eNB_UE_stats(Mod_id,CC_id,rnti); /* DevCheck(((eNB_UE_stats[CC_id]->DL_cqi[0] < MIN_CQI_VALUE) || (eNB_UE_stats[CC_id]->DL_cqi[0] > MAX_CQI_VALUE)), eNB_UE_stats[CC_id]->DL_cqi[0], MIN_CQI_VALUE, MAX_CQI_VALUE); */ eNB_UE_stats[CC_id]->dlsch_mcs1=cqi_to_mcs[eNB_UE_stats[CC_id]->DL_cqi[0]]; eNB_UE_stats[CC_id]->dlsch_mcs1 = cmin(eNB_UE_stats[CC_id]->dlsch_mcs1,openair_daq_vars.target_ue_dl_mcs); } // provide the list of CCs sorted according to MCS for (i=0;i<UE_list->numactiveCCs[UE_id];i++) { for (j=i+1;j<UE_list->numactiveCCs[UE_id];j++) { if (eNB_UE_stats[UE_list->ordered_CCids[i][UE_id]]->dlsch_mcs1 > eNB_UE_stats[UE_list->ordered_CCids[j][UE_id]]->dlsch_mcs1) { tmp = UE_list->ordered_CCids[i][UE_id]; UE_list->ordered_CCids[i][UE_id] = UE_list->ordered_CCids[j][UE_id]; UE_list->ordered_CCids[j][UE_id] = tmp; } } } /* if ((mac_get_rrc_status(Mod_id,1,UE_id) < RRC_RECONFIGURED)){ // If we still don't have a default radio bearer nb_rbs_required[pCCid][UE_id] = PHY_vars_eNB_g[Mod_id][pCCid]->lte_frame_parms.N_RB_DL; continue; } */ /* NN --> RK * check the index of UE_template" */ // if (UE_list->UE_template[UE_id]->dl_buffer_total> 0) { if (UE_list->UE_template[pCCid][UE_id].dl_buffer_total> 0) { LOG_D(MAC,"[preprocessor] assign RB for UE %d\n",UE_id); for (i=0;i<UE_list->numactiveCCs[UE_id];i++) { CC_id = UE_list->ordered_CCids[i][UE_id]; if (eNB_UE_stats[CC_id]->dlsch_mcs1==0) nb_rbs_required[CC_id][UE_id] = 4; // don't let the TBS get too small else nb_rbs_required[CC_id][UE_id] = min_rb_unit[CC_id]; TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); LOG_D(MAC,"[preprocessor] start RB assignement for UE %d CC_id %d dl buffer %d (RB unit %d, MCS %d, TBS %d) \n", UE_id, CC_id, UE_list->UE_template[pCCid][UE_id].dl_buffer_total, nb_rbs_required[CC_id][UE_id],eNB_UE_stats[CC_id]->dlsch_mcs1,TBS); /* calculating required number of RBs for each UE */ while (TBS < UE_list->UE_template[pCCid][UE_id].dl_buffer_total) { nb_rbs_required[CC_id][UE_id] += min_rb_unit[CC_id]; if (nb_rbs_required[CC_id][UE_id] > frame_parms[CC_id]->N_RB_DL) { TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,frame_parms[CC_id]->N_RB_DL); nb_rbs_required[CC_id][UE_id] = frame_parms[CC_id]->N_RB_DL; break; } TBS = mac_xface->get_TBS_DL(eNB_UE_stats[CC_id]->dlsch_mcs1,nb_rbs_required[CC_id][UE_id]); } // end of while LOG_D(MAC,"[eNB %d] Frame %d: UE %d on CC %d: RB unit %d, nb_required RB %d (TBS %d, mcs %d)\n", Mod_id, frameP,UE_id, CC_id, min_rb_unit[CC_id], nb_rbs_required[CC_id][UE_id], TBS, eNB_UE_stats[CC_id]->dlsch_mcs1); } } } }
void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag, frame_t frameP, sub_frame_t subframeP) //, int calibration_flag) { { unsigned int nprb[MAX_NUM_CCs]; unsigned int nCCE[MAX_NUM_CCs]; int mbsfn_status[MAX_NUM_CCs]; uint32_t RBalloc[MAX_NUM_CCs]; protocol_ctxt_t ctxt; #ifdef EXMIMO int ret; #endif #if defined(ENABLE_ITTI) MessageDef *msg_p; const char *msg_name; instance_t instance; int result; #endif DCI_PDU *DCI_pdu[MAX_NUM_CCs]; int CC_id,i,next_i; UE_list_t *UE_list=&eNB_mac_inst[module_idP].UE_list; rnti_t rnti; LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler (UE_list->head %d)\n",module_idP, frameP, subframeP,UE_list->head); start_meas(&eNB_mac_inst[module_idP].eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_IN); for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { DCI_pdu[CC_id] = &eNB_mac_inst[module_idP].common_channels[CC_id].DCI_pdu; nCCE[CC_id]=0; nprb[CC_id]=0; RBalloc[CC_id]=0; mbsfn_status[CC_id]=0; } // refresh UE list based on UEs dropped by PHY in previous subframe i = UE_list->head; while (i>=0) { rnti = UE_RNTI(module_idP, i); CC_id = UE_PCCID(module_idP, i); LOG_D(MAC,"UE %d: rnti %x (%p)\n", i, rnti, mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)); next_i= UE_list->next[i]; if (mac_xface->get_eNB_UE_stats(module_idP, CC_id, rnti)==NULL) { mac_remove_ue(module_idP, i, frameP, subframeP); } i = next_i; } #if defined(ENABLE_ITTI) do { // Checks if a message has been sent to MAC sub-task itti_poll_msg (TASK_MAC_ENB, &msg_p); if (msg_p != NULL) { msg_name = ITTI_MSG_NAME (msg_p); instance = ITTI_MSG_INSTANCE (msg_p); switch (ITTI_MSG_ID(msg_p)) { case MESSAGE_TEST: LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p)); break; case RRC_MAC_BCCH_DATA_REQ: LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index); // TODO process BCCH data req. break; case RRC_MAC_CCCH_DATA_REQ: LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index); // TODO process CCCH data req. break; #ifdef Rel10 case RRC_MAC_MCCH_DATA_REQ: LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d, mbsfn_sync_area %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, RRC_MAC_MCCH_DATA_REQ (msg_p).frame, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area); // TODO process MCCH data req. break; #endif default: LOG_E(MAC, "Received unexpected message %s\n", msg_name); break; } result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); } } while(msg_p != NULL); #endif // clear DCI and BCCH contents before scheduling for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { DCI_pdu[CC_id]->Num_common_dci = 0; DCI_pdu[CC_id]->Num_ue_spec_dci = 0; eNB_mac_inst[module_idP].common_channels[CC_id].bcch_active = 0; #ifdef Rel10 eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0; #endif eNB_mac_inst[module_idP].frame = frameP; eNB_mac_inst[module_idP].subframe = subframeP; } //if (subframeP%5 == 0) //#ifdef EXMIMO PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP); pdcp_run(&ctxt); //#endif // check HO rrc_rx_tx(&ctxt, 0, // eNB index, unused in eNB CC_id); #ifdef Rel10 for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { if (eNB_mac_inst[module_idP].common_channels[CC_id].MBMS_flag >0) { start_meas(&eNB_mac_inst[module_idP].schedule_mch); mbsfn_status[CC_id] = schedule_MBMS(module_idP,CC_id,frameP,subframeP); stop_meas(&eNB_mac_inst[module_idP].schedule_mch); } } #endif // refresh UE list based on UEs dropped by PHY in previous subframe /* i=UE_list->head; while (i>=0) { next_i = UE_list->next[i]; LOG_T(MAC,"UE %d : rnti %x, stats %p\n",i,UE_RNTI(module_idP,i),mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))); if (mac_xface->get_eNB_UE_stats(module_idP,0,UE_RNTI(module_idP,i))==NULL) { mac_remove_ue(module_idP,i,frameP); } i=next_i; } */ switch (subframeP) { case 0: // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution) // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6) // Schedule Normal DLSCH schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE); if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD schedule_ulsch(module_idP,frameP,cooperation_flag,0,4,nCCE);//,calibration_flag); } else if ((mac_xface->lte_frame_parms->tdd_config == TDD) || //TDD (mac_xface->lte_frame_parms->tdd_config == 3) || (mac_xface->lte_frame_parms->tdd_config == 6)) { //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE);//,calibration_flag); } // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; case 1: // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6) // FDD, schedule normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD switch (mac_xface->lte_frame_parms->tdd_config) { case 0: case 1: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; case 6: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; default: break; } } else { //FDD schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); schedule_ulsch(module_idP,frameP,cooperation_flag,1,5,nCCE); } break; case 2: // TDD, nothing // FDD, normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); schedule_ulsch(module_idP,frameP,cooperation_flag,2,6,nCCE); } break; case 3: // TDD Config 2, ULSCH for subframeP 7 // TDD Config 2/5 normal DLSCH // FDD, normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { switch (mac_xface->lte_frame_parms->tdd_config) { case 2: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,nCCE); // no break here! case 5: schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; default: break; } } else { //FDD schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,nCCE); } break; case 4: // TDD Config 1, ULSCH for subframeP 8 // TDD Config 1/2/4/5 DLSCH // FDD UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD switch (mac_xface->lte_frame_parms->tdd_config) { case 1: // schedule_RA(module_idP,frameP,subframeP,nprb,nCCE); schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,nCCE); // no break here! case 2: // no break here! case 4: // no break here! case 5: schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; default: break; } } else { if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD // schedule_RA(module_idP,frameP, subframeP, 0, nprb, nCCE); // schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8, nCCE); schedule_ue_spec(module_idP, frameP, subframeP, nprb, nCCE, mbsfn_status); fill_DLSCH_dci(module_idP, frameP, subframeP, RBalloc, 1, mbsfn_status); } } break; case 5: // TDD/FDD Schedule SI // TDD Config 0,6 ULSCH for subframes 9,3 resp. // TDD normal DLSCH // FDD normal UL/DLSCH schedule_SI(module_idP,frameP,nprb,nCCE); //schedule_RA(module_idP,frameP,subframeP,5,nprb,nCCE); if (mac_xface->lte_frame_parms->frame_type == FDD) { schedule_RA(module_idP,frameP,subframeP,1,nprb,nCCE); // schedule_ulsch(module_idP,frameP,cooperation_flag,5,9,nCCE); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0 (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6 //schedule_ulsch(module_idP,cooperation_flag,subframeP,nCCE); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } else { //schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; case 6: // TDD Config 0,1,6 ULSCH for subframes 2,3 // TDD Config 3,4,5 Normal DLSCH // FDD normal ULSCH/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD switch (mac_xface->lte_frame_parms->tdd_config) { case 0: break; case 1: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE); // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; case 6: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE); // schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; case 5: schedule_RA(module_idP,frameP,subframeP,2,nprb,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; case 3: case 4: schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; default: break; } } else { //FDD // schedule_ulsch(module_idP,frameP,cooperation_flag,6,0,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; case 7: // TDD Config 3,4,5 Normal DLSCH // FDD Normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD switch (mac_xface->lte_frame_parms->tdd_config) { case 3: case 4: schedule_RA(module_idP,frameP,subframeP,3,nprb,nCCE); // 3 = Msg3 subframeP, not schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; case 5: schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; default: break; } } else { //FDD //schedule_ulsch(module_idP,frameP,cooperation_flag,7,1,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; case 8: // TDD Config 2,3,4,5 ULSCH for subframeP 2 // // FDD Normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD switch (mac_xface->lte_frame_parms->tdd_config) { case 2: case 3: case 4: case 5: // schedule_RA(module_idP,subframeP,nprb,nCCE); schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; default: break; } } else { //FDD //schedule_ulsch(module_idP,frameP,cooperation_flag,8,2,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; case 9: // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4 if (mac_xface->lte_frame_parms->frame_type == TDD) { switch (mac_xface->lte_frame_parms->tdd_config) { case 1: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE); schedule_RA(module_idP,frameP,subframeP,7,nprb,nCCE); // 7 = Msg3 subframeP, not schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; case 3: case 4: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; case 6: schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,nCCE); //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; case 2: case 5: //schedule_RA(module_idP,frameP,subframeP,nprb,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); break; default: break; } } else { //FDD // schedule_ulsch(module_idP,frameP,cooperation_flag,9,3,nCCE); schedule_ue_spec(module_idP,frameP,subframeP,nprb,nCCE,mbsfn_status); fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; } for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { DCI_pdu[CC_id]->nCCE = nCCE[CC_id]; } LOG_D(MAC,"frameP %d, subframeP %d nCCE %d\n",frameP,subframeP,nCCE[0]); stop_meas(&eNB_mac_inst[module_idP].eNB_scheduler); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,VCD_FUNCTION_OUT); }
void ulsch_scheduler_pre_processor(module_id_t module_idP, int frameP, sub_frame_t subframeP, uint16_t *first_rb, uint8_t aggregation, uint32_t *nCCE){ int16_t i; uint16_t UE_id,n,r; uint8_t CC_id, round, harq_pid; uint16_t nb_allocated_rbs[MAX_NUM_CCs][NUMBER_OF_UE_MAX],total_allocated_rbs[MAX_NUM_CCs],average_rbs_per_user[MAX_NUM_CCs]; int16_t total_remaining_rbs[MAX_NUM_CCs]; uint16_t max_num_ue_to_be_scheduled=0,total_ue_count=0; rnti_t rnti= -1; uint32_t nCCE_to_be_used[CC_id]; UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; UE_TEMPLATE *UE_template; LTE_DL_FRAME_PARMS *frame_parms; // LOG_I(MAC,"store ulsch buffers\n"); // convert BSR to bytes for comparison with tbs store_ulsch_buffer(module_idP,frameP, subframeP); //LOG_I(MAC,"assign max mcs min rb\n"); // maximize MCS and then allocate required RB according to the buffer occupancy with the limit of max available UL RB assign_max_mcs_min_rb(module_idP,frameP, subframeP, first_rb); //LOG_I(MAC,"sort ue \n"); // sort ues sort_ue_ul (module_idP,frameP, subframeP); // we need to distribute RBs among UEs // step1: reset the vars for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { nCCE_to_be_used[CC_id]= nCCE[CC_id]; total_allocated_rbs[CC_id]=0; total_remaining_rbs[CC_id]=0; average_rbs_per_user[CC_id]=0; for (i=UE_list->head_ul;i>=0;i=UE_list->next_ul[i]) { nb_allocated_rbs[CC_id][i]=0; } } //LOG_I(MAC,"step2 \n"); // step 2: calculate the average rb per UE total_ue_count =0; max_num_ue_to_be_scheduled=0; for (i=UE_list->head_ul;i>=0;i=UE_list->next_ul[i]) { rnti = UE_RNTI(module_idP,i); if (rnti==0) continue; UE_id = i; for (n=0;n<UE_list->numactiveULCCs[UE_id];n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; UE_template = &UE_list->UE_template[CC_id][UE_id]; average_rbs_per_user[CC_id]=0; frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); if (UE_template->pre_allocated_nb_rb_ul > 0) { total_ue_count+=1; } if((mac_xface->get_nCCE_max(module_idP,CC_id) - nCCE_to_be_used[CC_id]) > (1<<aggregation)){ nCCE_to_be_used[CC_id] = nCCE_to_be_used[CC_id] + (1<<aggregation); max_num_ue_to_be_scheduled+=1; } if (total_ue_count == 0) average_rbs_per_user[CC_id] = 0; else if (total_ue_count == 1 ) // increase the available RBs, special case, average_rbs_per_user[CC_id] = frame_parms->N_RB_UL-first_rb[CC_id]+1; else if( (total_ue_count <= (frame_parms->N_RB_DL-first_rb[CC_id])) && (total_ue_count <= max_num_ue_to_be_scheduled)) average_rbs_per_user[CC_id] = (uint16_t) floor((frame_parms->N_RB_UL-first_rb[CC_id])/total_ue_count); else if (max_num_ue_to_be_scheduled > 0 ) average_rbs_per_user[CC_id] = (uint16_t) floor((frame_parms->N_RB_UL-first_rb[CC_id])/max_num_ue_to_be_scheduled); else { average_rbs_per_user[CC_id]=1; LOG_W(MAC,"[eNB %d] frame %d subframe %d: UE %d CC %d: can't get average rb per user (should not be here)\n", module_idP,frameP,subframeP,UE_id,CC_id); } } } LOG_D(MAC,"[eNB %d] Frame %d subframe %d: total ue %d, max num ue to be scheduled %d\n", module_idP, frameP, subframeP,total_ue_count, max_num_ue_to_be_scheduled); //LOG_D(MAC,"step3\n"); // step 3: assigne RBS for (i=UE_list->head_ul;i>=0;i=UE_list->next_ul[i]) { rnti = UE_RNTI(module_idP,i); if (rnti==0) continue; UE_id = i; for (n=0;n<UE_list->numactiveULCCs[UE_id];n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; mac_xface->get_ue_active_harq_pid(module_idP,CC_id,rnti,frameP,subframeP,&harq_pid,&round,1); if(round>0) nb_allocated_rbs[CC_id][UE_id] = UE_list->UE_template[CC_id][UE_id].nb_rb_ul[harq_pid]; else nb_allocated_rbs[CC_id][UE_id] = cmin(UE_template->pre_allocated_nb_rb_ul, average_rbs_per_user[CC_id]); total_allocated_rbs[CC_id]+= nb_allocated_rbs[CC_id][UE_id]; } } // step 4: assigne the remaining RBs and set the pre_allocated rbs accordingly for(r=0;r<2;r++){ for (i=UE_list->head_ul;i>=0;i=UE_list->next_ul[i]) { rnti = UE_RNTI(module_idP,i); if (rnti==0) continue; UE_id = i; for (n=0;n<UE_list->numactiveULCCs[UE_id];n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; UE_template = &UE_list->UE_template[CC_id][UE_id]; frame_parms = mac_xface->get_lte_frame_parms(module_idP,CC_id); total_remaining_rbs[CC_id]=frame_parms->N_RB_UL - first_rb[CC_id] - total_allocated_rbs[CC_id]; if (total_ue_count == 1 ) total_remaining_rbs[CC_id]+=1; if ( r == 0 ) { while ( (UE_template->pre_allocated_nb_rb_ul > 0 ) && (nb_allocated_rbs[CC_id][UE_id] < UE_template->pre_allocated_nb_rb_ul) && (total_remaining_rbs[CC_id] > 0)){ nb_allocated_rbs[CC_id][UE_id] = cmin(nb_allocated_rbs[CC_id][UE_id]+1,UE_template->pre_allocated_nb_rb_ul); total_remaining_rbs[CC_id]--; total_allocated_rbs[CC_id]++; } } else { UE_template->pre_allocated_nb_rb_ul= nb_allocated_rbs[CC_id][UE_id]; LOG_D(MAC,"******************UL Scheduling Information for UE%d CC_id %d ************************\n",UE_id, CC_id); LOG_D(MAC,"[eNB %d] total RB allocated for UE%d CC_id %d = %d\n", module_idP, UE_id, CC_id, UE_template->pre_allocated_nb_rb_ul); } } } } for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) { frame_parms= mac_xface->get_lte_frame_parms(module_idP,CC_id); if (total_allocated_rbs[CC_id]>0) LOG_D(MAC,"[eNB %d] total RB allocated for all UEs = %d/%d\n", module_idP, total_allocated_rbs[CC_id], frame_parms->N_RB_UL - first_rb[CC_id]); } }
void LshttpdMain::applyChanges() { if ( D_ENABLED( DL_LESS ) ) LOG_D(( "Applying new configuration. " )); broadcastSig( SIGTERM, 1 ); }
void assign_max_mcs_min_rb(module_id_t module_idP,int frameP, sub_frame_t subframeP, uint16_t *first_rb){ int i; uint16_t n,UE_id; uint8_t CC_id; rnti_t rnti = -1; int mcs=cmin(16,openair_daq_vars.target_ue_ul_mcs); int rb_table_index=0,tbs,tx_power; UE_list_t *UE_list = &eNB_mac_inst[module_idP].UE_list; UE_TEMPLATE *UE_template; LTE_DL_FRAME_PARMS *frame_parms; for (i=UE_list->head_ul;i>=0;i=UE_list->next_ul[i]) { rnti = UE_RNTI(module_idP,i); if (rnti==0) continue; UE_id = i; for (n=0;n<UE_list->numactiveULCCs[UE_id];n++) { // This is the actual CC_id in the list CC_id = UE_list->ordered_ULCCids[n][UE_id]; frame_parms=mac_xface->get_lte_frame_parms(module_idP,CC_id); UE_template = &UE_list->UE_template[CC_id][UE_id]; // if this UE has UL traffic if (UE_template->ul_total_buffer > 0 ) { tbs = mac_xface->get_TBS_UL(mcs,1); // fixme: set use_srs flag tx_power= mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); while (((UE_template->phr_info - tx_power) < 0 ) && (mcs > 3)){ // LOG_I(MAC,"UE_template->phr_info %d tx_power %d mcs %d\n", UE_template->phr_info,tx_power, mcs); mcs--; tbs = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); tx_power = mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); // fixme: set use_srs } while ((tbs < UE_template->ul_total_buffer) && (rb_table[rb_table_index]<(frame_parms->N_RB_UL-first_rb[CC_id])) && ((UE_template->phr_info - tx_power) > 0) && (rb_table_index < 33 )){ // LOG_I(MAC,"tbs %d ul buffer %d rb table %d max ul rb %d\n", tbs, UE_template->ul_total_buffer, rb_table[rb_table_index], frame_parms->N_RB_UL-first_rb[CC_id]); rb_table_index++; tbs = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); tx_power = mac_xface->estimate_ue_tx_power(tbs,rb_table[rb_table_index],0,frame_parms->Ncp,0); } UE_template->ue_tx_power = tx_power; if (rb_table[rb_table_index]>(frame_parms->N_RB_UL-first_rb[CC_id]-1)) { rb_table_index--; } // 1 or 2 PRB with cqi enabled does not work well! if (rb_table[rb_table_index]<3) rb_table_index=2; //3PRB UE_template->pre_assigned_mcs_ul=mcs; UE_template->pre_allocated_rb_table_index_ul=rb_table_index; UE_template->pre_allocated_nb_rb_ul= rb_table[rb_table_index]; LOG_D(MAC,"[eNB %d] frame %d subframe %d: for UE %d CC %d: pre-assigned mcs %d, pre-allocated rb_table[%d]=%d RBs (phr %d, tx power %d)\n", module_idP, frameP, subframeP, UE_id, CC_id, UE_template->pre_assigned_mcs_ul, UE_template->pre_allocated_rb_table_index_ul, UE_template->pre_allocated_nb_rb_ul, UE_template->phr_info,tx_power); } else { UE_template->pre_allocated_rb_table_index_ul=-1; UE_template->pre_allocated_nb_rb_ul=0; } } } }
int LshttpdMain::init(int argc, char * argv[]) { int ret; if ( argc > 1 ) { parseOpt( argc, argv ); } if ( getServerRoot( argc, argv ) != 0 ) { //LOG_ERR(("Failed to determine the root directory of server!" )); fprintf( stderr, "Can't determine the Home of LiteSpeed Web Server, exit!\n" ); return 1; } mkdir( DEFAULT_TMP_DIR, 0755 ); if ( testRunningServer() != 0 ) return 2; if ( m_pServer->configServerBasics( 0, m_pBuilder->getRoot() ) ) return 1; LOG4CXX_NS::LogRotate::roll( HttpLog::getErrorLogger()->getAppender(), HttpGlobals::s_uid, HttpGlobals::s_gid, 1 ); if ( HttpGlobals::s_uid <= 10 || HttpGlobals::s_gid < 10 ) { MainServerConfig& MainServerConfigObj = MainServerConfig::getInstance(); LOG_ERR(( "It is not allowed to run LiteSpeed web server on behalf of a " "privileged user/group, user id must not be " "less than 50 and group id must not be less than 10." "UID of user '%s' is %d, GID of group '%s' is %d. " "Please fix above problem first!", MainServerConfigObj.getUser(), HttpGlobals::s_uid, MainServerConfigObj.getGroup(), HttpGlobals::s_gid )); return 1; } changeOwner(); plainconf::flushErrorLog(); LOG_NOTICE(( "Loading %s ...", HttpServerVersion::getVersion() )); #ifdef SSLEAY_VERSION LOG_NOTICE(( "Using [%s]", SSLeay_version( SSLEAY_VERSION ) )); #endif if ( !m_noDaemon ) { if ( Daemonize::daemonize( 1, 1 ) ) return 3; LOG_D(( "Daemonized!" )); #ifndef RUN_TEST Daemonize::close(); #endif } enableCoreDump(); if ( testRunningServer() != 0 ) return 2; m_pid = getpid(); if ( m_pidFile.writePid( m_pid ) ) return 2; startAdminSocket(); ret = config(); if ( ret ) { LOG_ERR(("Fatal error in configuration, exit!" )); fprintf( stderr, "[ERROR] Fatal error in configuration, shutdown!\n" ); return ret; } removeOldRtreport(); { char achBuf[8192]; if ( HttpGlobals::s_psChroot ) { PidFile pidfile; ConfigCtx::getCurConfigCtx()->getAbsolute( achBuf, PID_FILE, 0 ); pidfile.writePidFile( achBuf, m_pid); } } #if defined(__FreeBSD__) //setproctitle( "%s", "lshttpd" ); #else argv[1] = NULL; strcpy( argv[0], "openlitespeed (lshttpd - main)" ); #endif //if ( !m_noCrashGuard && ( m_pBuilder->getCrashGuard() )) s_iCpuCount = PCUtil::getNumProcessors(); //Server init done if ( LsiApiHooks::getServerHooks()->isEnabled( LSI_HKPT_MAIN_INITED) ) LsiApiHooks::getServerHooks()->runCallbackNoParam(LSI_HKPT_MAIN_INITED, NULL); if ( !m_noCrashGuard && ( MainServerConfig::getInstance().getCrashGuard() )) { if ( guardCrash() ) return 8; m_pidFile.closePidFile(); } else { HttpGlobals::s_iProcNo = 1; allocatePidTracker(); m_pServer->initAdns(); } //if ( fcntl( 5, F_GETFD, 0 ) > 0 ) // printf( "find it!\n" ); if ( getuid() == 0 ) { if ( m_pServer->changeUserChroot( ) == -1 ) return -1; if ( HttpGlobals::s_psChroot ) m_pServer->offsetChroot(); } if ( 1 == HttpGlobals::s_iProcNo ) { ExtAppRegistry::runOnStartUp(); } return 0; }
int LsapiConn::processRespBuffed() { int ret; int left; int len; m_pRespHeader = (char *)&m_respHeader; m_pRespHeaderBufEnd = &m_respBuf[1024]; ret = read( m_pRespHeader, m_pRespHeaderBufEnd - m_pRespHeader ); if ( ret <= 0 ) return ret; if ( ret < (int)sizeof( lsapi_packet_header ) ) { m_iPacketHeaderLeft = sizeof( lsapi_packet_header ) - ret; return ret; } m_pRespHeaderBufEnd = m_pRespHeader + ret; m_iPacketLeft = verifyPacketHeader( &m_respHeader ) - LSAPI_PACKET_HEADER_LEN; if ( m_iPacketLeft < 0 ) { errno = EIO; return -1; } if ( !m_iPacketLeft ) m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; else m_iPacketHeaderLeft = 0; if ( ret < (int)(sizeof( lsapi_packet_header ) + sizeof( lsapi_resp_info )) ) { m_pRespHeader += ret; switch( m_respHeader.m_type ) { case LSAPI_RESP_END: m_respState = LSAPI_CONN_IDLE; incReqProcessed(); setInProcess( 0 ); getConnector()->endResponse( 0, 0 ); return 0; case LSAPI_RESP_HEADER: m_iCurRespHeader = 0; m_respState = LSAPI_CONN_READ_RESP_INFO; m_pRespHeaderProcess = (char *)&m_respInfo; setRespBuf( m_pRespHeaderProcess ); return ret; case LSAPI_REQ_RECEIVED: m_reqReceived = 1; break; } m_pRespHeaderProcess = (char *)&m_respInfo; } else { m_iCurRespHeader = 0; m_respState = LSAPI_CONN_READ_HEADER_LEN; m_pRespHeaderProcess = m_respBuf; } while( (left = m_pRespHeaderBufEnd - m_pRespHeaderProcess) > 0 ) { if ( m_iPacketHeaderLeft > 0 ) { ret = processPacketHeader( m_pRespHeaderProcess, left ); if ( ret <= 0 ) return ret; m_pRespHeaderProcess += ret; left -= ret; } if ( m_iPacketLeft > 0 ) { register HttpExtConnector * pHEC = getConnector(); if ( !pHEC ) return -1; int &respState = pHEC->getRespState(); if ( m_iPacketLeft < left ) { len = m_iPacketLeft; m_iPacketLeft = 0; m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; } else { len = left; m_iPacketLeft -= left; left = 0; } switch( m_respHeader.m_type ) { case LSAPI_RESP_HEADER: ret = processRespHeader(m_pRespHeaderBufEnd, respState); if ( ret < 0 ) return ret; break; case LSAPI_RESP_STREAM: if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process response stream %d bytes", getLogId(), len )); ret = pHEC->processRespData( m_pRespHeaderProcess, len ); if ( respState & 0xff ) m_respState = LSAPI_CONN_READ_RESP_BODY; if ( ret == -1 ) return ret; m_pRespHeaderProcess += len; break; case LSAPI_STDERR_STREAM: if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process STDERR stream %d bytes", getLogId(), len )); ret = pHEC->processErrData( m_pRespHeaderProcess, len ); m_pRespHeaderProcess += len; break; default: LOG_NOTICE(( getLogger(), "[%s] Unknown Packet Type %c, LSAPI protcol is broken.", getLogId(), m_respHeader.m_type )); errno = EIO; return -1; } } else m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; } return 1; }
void LogSink::Subscribe(Emitter *em) { LOG_D("agi/log/emitter/subscribe") << "Subscribe: " << this; emitters.push_back(em); }
int LsapiConn::processRespHeader() { register HttpExtConnector * pHEC = getConnector(); int ret; int len = 0; if ( !pHEC ) return -1; int &respState = pHEC->getRespState(); if ( !(respState & 0xff) ) { while( m_iPacketLeft > 0 ) { len = ExtConn::read( m_pRespHeader, m_pRespHeaderBufEnd - m_pRespHeader ); if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process response header %d bytes", getLogId(), len )); if ( len > 0 ) { m_iPacketLeft -= len; ret = processRespHeader( m_pRespHeader + len, respState ); switch( ret ) { case -2: LOG_WARN(( getLogger(), "[%s] Invalid Http response header, retry!", getLogId() )); //debug code //::write( 1, pBuf, len ); errno = ECONNRESET; case -1: return -1; } if ( m_iPacketLeft > 0 ) { m_pRespHeader += len; if (( m_pRespHeader > m_pRespHeaderProcess )&& ( m_pRespHeader != &m_respBuf[ m_respInfo.m_cntHeaders * sizeof(short) ] )) { len = m_pRespHeader - m_pRespHeaderProcess; memmove( &m_respBuf[ m_respInfo.m_cntHeaders * sizeof(short) ], m_pRespHeaderProcess, m_pRespHeader - m_pRespHeaderProcess ); m_pRespHeaderProcess = &m_respBuf[ m_respInfo.m_cntHeaders * sizeof(short) ]; m_pRespHeader = m_pRespHeaderProcess + len; } else m_pRespHeader = m_pRespHeaderProcess = &m_respBuf[ m_respInfo.m_cntHeaders * sizeof(short) ]; setRespBuf( m_pRespHeader ); } } else return len; } if ( m_iPacketLeft == 0 ) { m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; len = 1; } return len; } else { //error: protocol error, header received already. errno = EIO; return -1; } }
void LogSink::Unsubscribe(Emitter *em) { emitters.erase(remove(emitters.begin(), emitters.end(), em), emitters.end()); delete em; LOG_D("agi/log/emitter/unsubscribe") << "Un-Subscribe: " << this; }
int LsapiConn::readStderrStream() { register HttpExtConnector * pHEC = getConnector(); int ret; size_t bufLen; char achBuf[2049]; while( m_iPacketLeft > 0 ) { char * pBuf = achBuf; bufLen = sizeof( achBuf ); int toRead = m_iPacketLeft + sizeof( m_respHeader ); if ( toRead > (int)bufLen ) toRead = bufLen ; ret = read( pBuf, toRead ); if ( ret > 0 ) { int len, packetLen; if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process STDERR stream %d bytes, packet left: %d", getLogId(), ret, m_iPacketLeft )); if ( ret >= m_iPacketLeft ) { packetLen = m_iPacketLeft; m_iPacketLeft = 0; } else { packetLen = ret; m_iPacketLeft -= ret; } if ( pHEC ) pHEC->processErrData( pBuf, packetLen ); else { char ch = pBuf[packetLen]; pBuf[ packetLen ] = 0; LOG_NOTICE(( getLogger(), "[%s] [LSAPI:STDERR]: %s", getLogId(), pBuf )); pBuf[ packetLen ] = ch; } if ( m_iPacketLeft <= 0 ) { m_iPacketHeaderLeft = LSAPI_PACKET_HEADER_LEN; if ( ret > packetLen ) { if ( D_ENABLED( DL_MEDIUM ) ) LOG_D(( getLogger(), "[%s] process packet header %d bytes", getLogId(), ret - packetLen )); len = processPacketHeader( pBuf + packetLen, ret - packetLen ); if ( len <= 0 ) return len; if (( m_respHeader.m_type != LSAPI_STDERR_STREAM )|| ( m_iPacketLeft <= 0 )) return 1; } else break; } } else { return ret; } } return 1; }
std::unique_ptr<AudioProvider> AudioProviderFactory::GetProvider(agi::fs::path const& filename, agi::BackgroundRunner *br) { auto preferred = OPT_GET("Audio/Provider")->GetString(); auto sorted = GetSorted(boost::make_iterator_range(std::begin(providers), std::end(providers)), preferred); std::unique_ptr<AudioProvider> provider; bool found_file = false; bool found_audio = false; std::string msg_all; // error messages from all attempted providers std::string msg_partial; // error messages from providers that could partially load the file (knows container, missing codec) for (auto const& factory : sorted) { try { provider = factory->create(filename, br); if (!provider) continue; LOG_I("audio_provider") << "Using audio provider: " << factory->name; break; } catch (agi::fs::FileNotFound const& err) { LOG_D("audio_provider") << err.GetChainedMessage(); msg_all += std::string(factory->name) + ": " + err.GetMessage() + " not found.\n"; } catch (agi::AudioDataNotFoundError const& err) { LOG_D("audio_provider") << err.GetChainedMessage(); found_file = true; msg_all += std::string(factory->name) + ": " + err.GetChainedMessage() + "\n"; } catch (agi::AudioOpenError const& err) { LOG_D("audio_provider") << err.GetChainedMessage(); found_audio = true; found_file = true; std::string thismsg = std::string(factory->name) + ": " + err.GetChainedMessage() + "\n"; msg_all += thismsg; msg_partial += thismsg; } } if (!provider) { if (found_audio) throw agi::AudioProviderOpenError(msg_partial, nullptr); if (found_file) throw agi::AudioDataNotFoundError(msg_all, nullptr); throw agi::fs::FileNotFound(filename); } bool needsCache = provider->NeedsCache(); // Give it a converter if needed if (provider->GetBytesPerSample() != 2 || provider->GetSampleRate() < 32000 || provider->GetChannels() != 1) provider = CreateConvertAudioProvider(std::move(provider)); // Change provider to RAM/HD cache if needed int cache = OPT_GET("Audio/Cache/Type")->GetInt(); if (!cache || !needsCache) return CreateLockAudioProvider(std::move(provider)); // Convert to RAM if (cache == 1) return CreateRAMAudioProvider(std::move(provider)); // Convert to HD if (cache == 2) return CreateHDAudioProvider(std::move(provider)); throw agi::AudioCacheOpenError("Unknown caching method", nullptr); }