//函数能够将bsr的大小和物理层上传的数据,增加到S_UEinfo的队列中。 void Add_sueinfo_Node(PHYtoMAC_Info *temp, int m_bsr, int type_bsr) { struct S_UEinfo * p_ul_UEinfo; FIN(Add_sueinfo_Node()); SV_PTR_GET(mac_sv); p_ul_UEinfo=(S_UEinfo *)fsm_mem_alloc(sizeof(S_UEinfo)); while(p_ul_UEinfo==NULL)//申请内存失败 p_ul_UEinfo=(S_UEinfo *)fsm_mem_alloc(sizeof(S_UEinfo)); p_ul_UEinfo->datasizeof_bsr =cal_bsrsize(m_bsr,type_bsr); p_ul_UEinfo->rnti =temp->rnti; p_ul_UEinfo->cqi =temp->cqi; p_ul_UEinfo->crc =temp->crc; p_ul_UEinfo->harqindex =temp->harqindex; //p_ul_UEinfo->pgtype =temp->pgtype; p_ul_UEinfo->pmi =temp->pmi; p_ul_UEinfo->sfn =temp->sfn; p_ul_UEinfo->sr =temp->sr; p_ul_UEinfo->subframeN =temp->subframeN; p_ul_UEinfo->ta =temp->ta; fsm_printf("###BSR_SIZE is:%d",p_ul_UEinfo->datasizeof_bsr); insert_ULschedQue(SV(ULschedQue_p), p_ul_UEinfo); //test_code Geng fsm_printf("\n###finsh inser node!\n"); FOUT; }
//GENG 2014/9/11更改 int Do_judge_rnti(u16 receive_rnti) { FIN(Do_judge_rnti()); SV_PTR_GET(mac_sv); if( C_RNTI == find_type_rnti(receive_rnti) )//C-RNTI { FRET(2); } if( TC_RNTI==find_type_rnti(receive_rnti) )//TC-RNTI { if( 1==SV(RAR_receive_crnti) )//同时,如果MAC控制单元中存在C-RNTI { recall_rnti(receive_rnti);//将该receive_rnti(即TC-RNTI收回) SV(RAR_receive_crnti)=0;// } else { fsm_printf("[xxx]: This UE is first access!\n"); } FRET(1); } if( 0==find_type_rnti(receive_rnti)) { fsm_printf("##error: system hasn't allocated the rnti\n"); FRET(0); } }
/* 输入:随机接入队列,当前节点的指针 输出:随机接入调度完成后,剩余的资源 如果没有资源,则返回0 */ static unsigned int Do_DL_RIV(u16 rapid) { int Nprb,lcrbs; int RBstart,RIV; int i; u16 rnti; FIN(Do_DL_RIV()); SV_PTR_GET(mac_sv); Nprb=GetNprb(); lcrbs=Nprb/DL_SCHEDULE_NUM; lcrbs=lcrbs/4;//decrease the value of RIV to send; rnti=convert_rapid_rnti(rapid); switch(rnti)//5个用户中的第几个,0:0-19PRB 1:20-39prb,以此类推 { case RNTI_A: RBstart=0;break; case RNTI_B : RBstart=20;break; case RNTI_C : RBstart=40;break; case RNTI_D : RBstart=60;break; case RNTI_E : RBstart=80;break; default: fsm_printf("Do_DL_RIV function sth is wrong!");break; } //note:the length of RIV->RAR_DCI,is 9bit----means the biggest value is:2^9-1=511 if(lcrbs <= 1 + Nprb/2) //down limit { RIV=Nprb*(lcrbs-1)+RBstart;//420 } else { RIV=Nprb*(Nprb-lcrbs+1)+(Nprb-1-RBstart); } //test code Geng 20141027 fsm_printf("\nIn the function DL_RIV the value of RIV is:%d\n",RIV); FRET(RIV); }
//此函数生成的是整个RAR下行数据包的DCI,由于RA-RNTI相同,多个UE可能仅RAPID不同; //但是在目前最简系统中,我们随机选择一个正在进行随机接入的UE的下行资源用来发送RAR, //就不会发生冲突(因为其还处于随机接入过程,没有下行数据发送,信道没有被占用) int Do_RAR_DCI1C(struct S_RAinfo *ra_UEinfo) { ENBMAC_TO_PHY_Rardci * p_rar_ici_dci; FIN(Do_RAR_DCI()); p_rar_ici_dci=(ENBMAC_TO_PHY_Rardci *)fsm_mem_alloc(sizeof(ENBMAC_TO_PHY_Rardci)); p_rar_ici_dci->m_rnti =ra_UEinfo->ra_rnti; p_rar_ici_dci->m_tbsize =Get_Format1C_TbSize(ra_UEinfo->cqi);//这个为什么是这样的,与RIV是对应的吗? p_rar_ici_dci->dci_format=4;//format 1C p_rar_ici_dci->cfi=Do_DlDci_cfi(); p_rar_ici_dci->rar_dci.m_gap =1;//还未找到出处,暂时使用Gap2(频域距离) //20141022由于为下行数据,下行用户是固定的,所以最简系统目前的RIV是与bitmap相对应的 //由于在随机接入前,UE并未获取C-RNTI,所以为了让下行静态调度结果与随机分配相结合,宏定义任意5个中的一个RNTI,得到RIV值(5个值是相同的) p_rar_ici_dci->rar_dci.RIV =Do_DL_RIV(ra_UEinfo->rapid); //此处还没有更改完全,RIV的资源分配应该和下行调度有关系 p_rar_ici_dci->rar_dci.I_TBS =Get_ITbSize(ra_UEinfo->cqi); p_rar_ici_dci->rar_dci.emptybits =0; //Test code Geng 20141027 fsm_printf("\n##After Test Do_RAR_DCI1C:"); fsm_printf("\nSome important paramters are:"); fsm_printf(" RA-RNTI:%d",p_rar_ici_dci->m_rnti); fsm_printf(" dci_format:%d",p_rar_ici_dci->dci_format); fsm_printf(" m_tbsize:%d",p_rar_ici_dci->m_tbsize); fsm_printf(" CFI:%d",p_rar_ici_dci->cfi); fsm_printf(" RIV:%d",p_rar_ici_dci->rar_dci.RIV); fsm_printf(" m_gap:%d",p_rar_ici_dci->rar_dci.m_gap); fsm_printf(" I_TBS:%d\n",p_rar_ici_dci->rar_dci.I_TBS); fsm_do_ioctrl(STRM_TO_SRIO, IOCCMD_MACTOPHY_RAR_DCI, (void *) p_rar_ici_dci, sizeof(ENBMAC_TO_PHY_Rardci)); fsm_mem_free(p_rar_ici_dci); FRET(Cal_usable_ResOfBitmap(ra_UEinfo->cqi,ra_UEinfo->subframeN)); }
/************************************************************************************************************************************************ **Function name:send_rrc_connection_release_msg_to_ue **Desciption:use for testing ,generated rrcConnectionRelease info **Input : **Output:generated rrcConnectionRelease info ,and stored in the global variable. **Created by:zhou yang **Created Date:2014/09/08 **-------------------------------------------------------------------------------------------------- **Modified by:zhou yang **Modified Date:2014/10/07 **Descriptions:modified format **-------------------------------------------------------------------------------------------------- *************************************************************************************************************************************************/ void send_rrc_connection_release_msg_to_ue() { SV_PTR_GET(rrc_sv_enb_ue); char *msg=NULL; int msg_len; int message_type; struct RRCConnectionRelease rrcConnectionRelease ; struct DL_DCCH_Message *dl_dcch_message; FIN(send_rrc_connection_release_msg_to_ue()); fsm_printf("[rrc] [conn_release] send_rrc_connection_release_msg_to_ue().\n"); dl_dcch_message=(struct DL_DCCH_Message *)fsm_mem_alloc(sizeof(struct DL_DCCH_Message )); rrcConnectionRelease.rrcTransactionIdentifier=1; rrcConnectionRelease.haveIdleModeMobilityControlInfo=true; rrcConnectionRelease.releaseCause=other; rrcConnectionRelease.idleModeMobilityControlInfo.have_t320=true; rrcConnectionRelease.idleModeMobilityControlInfo.t320_Value=min5; rrcConnectionRelease.idleModeMobilityControlInfo.haveCellReselectionPriorityInfo=false; dl_dcch_message->msg.rrcConnectionRelease=rrcConnectionRelease; dl_dcch_message->type=2; msg=(char*)dl_dcch_message; msg_len=sizeof(struct RRCConnectionRelease); message_type=4; //fsm_octets_print(msg, msg_len); packet_send_to_rlc(msg, msg_len, message_type, SV(crnti)); //fsm_mem_free(rrcConnectionRelease); //rrcConnectionRelease=NULL; FOUT; }
//根据rnti的值,返回该rnti值对应的bitmap,以产生DCI static unsigned int Do_DlDci_bitmap(u16 rnti) { int i; u32 temp_bitmap; FIN(Do_DlDci_bitmap()); SV_PTR_GET(mac_sv); fsm_printf("[XXX]DO DL BITMAP:%d\n",rnti); for(i=0;i<DL_SCHEDULE_NUM;i++) { fsm_printf("[XXX]SCHEDULE SCHEME RNTI:%d\n",SV(schedule_scheme[i]).m_rnti); if(SV(schedule_scheme[i]).m_rnti==rnti){ fsm_printf("[XXX]DO DL BITMAP m_rbBitmap:0x%.8x\n",SV(schedule_scheme[i]).m_bitmap); temp_bitmap=(SV(schedule_scheme[i]).m_bitmap>>7);//phsical demand high->low(prb) so in order finsh 32bit->25bit,>>7 FRET(temp_bitmap); } }
/************************************************************************************************************************************************ **Function name:stop_timer **Desciption:stop all timer except t320 **Input : **Output: **Created by:zhou yang **Created Date:2014/09/08 **-------------------------------------------------------------------------------------------------- **Modified by:zhou yang **Modified Date:2014/09/30 **Descriptions:modified format **-------------------------------------------------------------------------------------------------- *************************************************************************************************************************************************/ void stop_timer(void) { FIN(stop_timer()); SV_PTR_GET(rrc_sv_enb_ue); fsm_printf("[rrc] [conn_release] stop_timer().\n"); // cancleTimer(0); // cancleTimer(1); // cancleTimer(2); // cancleTimer(5); // cancleTimer(11); // cancleTimer(21); FOUT; }
static unsigned int GetNprb() { int nprb; FIN(GetNprb()); switch((int)(CHANNEL_BANDWIDTH)) { case 1 : nprb=6 ;break; case 3 : nprb=15;break; case 5 : nprb=25;break; case 10 : nprb=50;break; case 15 : nprb=75;break; case 20 : nprb=100;break; default :fsm_printf("the channel bandwidth isn't at the correct scope\n");break; } FRET(nprb); }
int Do_RAR_DCI0(struct S_RAinfo *ra_UEinfo) { //UL_ICI_DCI * p_ul_ici_dci;//LHL 20141011 ENBMAC_TO_PHY_ULscheduleDCI *p_ul_rar_dci;//LHL 20141011 FIN(Do_RAR_DCI0()); p_ul_rar_dci=(ENBMAC_TO_PHY_ULscheduleDCI *)fsm_mem_alloc(sizeof(ENBMAC_TO_PHY_ULscheduleDCI)); p_ul_rar_dci->m_rnti=ra_UEinfo->ra_rnti; p_ul_rar_dci->m_tbsize=Do_Ul_TbSize(ra_UEinfo->cqi,cal_ul_abs(SIZE_MSG3,Get_Ul_PerPrb_Datasize(ra_UEinfo->cqi)));//LHL 20141011,需要和耿讨论 p_ul_rar_dci->dci_format=0; p_ul_rar_dci->s_ul_dci.m_format =Do_UlDci_format();//区分format0和format1A p_ul_rar_dci->s_ul_dci.m_hopping =Do_UlDci_hopping(); p_ul_rar_dci->s_ul_dci.RIV =Do_ulgrant_rb_assignment(ra_UEinfo->subframeN, ra_UEinfo->cqi);//与ulgrant中的资源分配结果应该是保持一致的 p_ul_rar_dci->s_ul_dci.m_ndi =Do_UlDci_ndi(); p_ul_rar_dci->s_ul_dci.m_mcs =Do_UlDci_mcs(ra_UEinfo->cqi); p_ul_rar_dci->s_ul_dci.m_tpc =Do_UlDci_tpc(); p_ul_rar_dci->s_ul_dci.m_cqiRequest =Do_UlDci_cqirequest(); p_ul_rar_dci->s_ul_dci.Cyclic_shift =Do_UlDci_Cyclic_shift(); p_ul_rar_dci->s_ul_dci.m_dai =Do_UlDci_dai(); p_ul_rar_dci->s_ul_dci.padding =0; p_ul_rar_dci->s_ul_dci.emptybits =0; //Test code Geng 20141027 fsm_printf("\n##After Test Do_RAR_DCI0:"); fsm_printf("\nSome important paramters are:"); fsm_printf(" RA-RNTI:%d",p_ul_rar_dci->m_rnti); fsm_printf(" dci_format:%d",p_ul_rar_dci->dci_format); fsm_printf(" m_tbsize:%d",p_ul_rar_dci->m_tbsize); fsm_printf(" m_mcs:%d",p_ul_rar_dci->s_ul_dci.m_mcs); fsm_printf(" RIV:%d",p_ul_rar_dci->s_ul_dci.RIV); fsm_printf(" m_dai:%d",p_ul_rar_dci->s_ul_dci.m_dai); fsm_do_ioctrl(STRM_TO_SRIO, IOCCMD_MACTOPHY_UL_DCI, (void *) p_ul_rar_dci, sizeof(ENBMAC_TO_PHY_ULscheduleDCI)); fsm_mem_free(p_ul_rar_dci); FRET(Cal_usable_ResOfBitmap(ra_UEinfo->cqi,ra_UEinfo->subframeN)); }
void Do_Data_of_MacRarPdu_ulgrant(DATA_RAR_PDU * p_rar_pdu, struct S_RAinfo *p_ra_UEinfo,int index)//函数有问题rapid是数组? { u8 temp_prb_bitmap2[100]; u8 temp_prb_bitmap7[100]; int temp_i; FIN(Do_Data_of_MacRarPdu_ulgrant()); SV_PTR_GET(mac_sv); for(temp_i=0;temp_i<100;temp_i++) temp_prb_bitmap7[temp_i]=SV(prb_bitmap7[temp_i]); for(temp_i=0;temp_i<100;temp_i++) temp_prb_bitmap2[temp_i]=SV(next_prb_bitmap2[temp_i]); // //temp_prb_bitmap7[100]=SV(prb_bitmap7[100]);//这句话有问题,不能这么用????????????????????? //temp_prb_bitmap2[100]=SV(prb_bitmap2[100]);//20140928由于处在随机接入过程中,保存资源分配前的资源分配情况,以给多个竞争用户分配同一个资源起点的资源 p_rar_pdu->s_ulgrant.m_mcs=Do_ulgrant_mcs(p_ra_UEinfo->cqi); p_rar_pdu->s_ulgrant.m_hoppingflag=Do_ulgrant_hoppingflag(); p_rar_pdu->s_ulgrant.rb_assignment=Do_ulgrant_rb_assignment(p_ra_UEinfo->subframeN,p_ra_UEinfo->cqi); if(index != 1) { for(temp_i=0;temp_i<100;temp_i++) SV(prb_bitmap7[temp_i])=temp_prb_bitmap7[temp_i]; for(temp_i=0;temp_i<100;temp_i++) SV(next_prb_bitmap2[temp_i])=temp_prb_bitmap2[temp_i]; } p_rar_pdu->s_ulgrant.m_tpc=Do_UlDci_ndi(); p_rar_pdu->s_ulgrant.m_cqiRequest=Do_ulgrant_tpc(); p_rar_pdu->s_ulgrant.m_ulDelay=Do_ulgrant_ulDelay(p_ra_UEinfo->subframeN,p_ra_UEinfo->cqi); p_rar_pdu->s_ulgrant.emptybits=0; p_rar_pdu->m_bi=Do_Data_of_MacRarPdu_BI(p_ra_UEinfo->subframeN,p_ra_UEinfo->cqi); p_rar_pdu->m_rapid=Do_Data_of_MacRarPdu_RAPID(p_ra_UEinfo->rapid); p_rar_pdu->m_ta=Do_Data_of_MacRarPdu_TA(p_ra_UEinfo->ta); p_rar_pdu->m_tcrnti=Do_Data_of_MacRarPdu_tcrnti(p_ra_UEinfo->rapid); fsm_printf("\n[xxx]In the function Do_Data_of_MacRarPdu_ulgrant the value of TC-RNTI is:%d\n",p_rar_pdu->m_tcrnti); FOUT; }
/************************************************************************************************************************************************ **Function name:release_radio_resource **Desciption:release all radio resource¡£ **Input : **Output:release srb drb **Created by:zhou yang **Created Date:2014/09/08 **-------------------------------------------------------------------------------------------------- **Modified by:zhou yang **Modified Date:2014/09/30 **Descriptions:modified format **-------------------------------------------------------------------------------------------------- *************************************************************************************************************************************************/ void release_radio_resource(void) { FIN(release_radio_resource()); int i; int numIndex=0; struct DrbToReleaseList drb; SV_PTR_GET(rrc_sv_enb_ue); fsm_printf("[rrc] [conn_release] release_radio_resource().\n"); for(i=0; i<maxDRB; i++) { if(enbDRBConfig[SV(uefsmid)][i]!=NULL) { drb.drbToRelease[numIndex]=enbDRBConfig[SV(uefsmid)][i]->drbIdentity; numIndex++; } } drb.num=numIndex; ApplySrbToRelease();//release SRB ApplyDrbToRelease(drb) ;//release DRB FOUT; }
//上行调度指令:执行后返回剩余资源量大小 int Order_Ul_Sched(struct S_UEinfo *p_ul_UEinfo) { //UL_ICI_DCI * p_ul_ici_dci;//LHL 20141011 ENBMAC_TO_PHY_ULscheduleDCI *p_ul_ici_dci;//LHL 20141011 FIN(Order_Ul_Sched()); p_ul_ici_dci=(ENBMAC_TO_PHY_ULscheduleDCI *)fsm_mem_alloc(sizeof(ENBMAC_TO_PHY_ULscheduleDCI)); p_ul_ici_dci->m_rnti=p_ul_UEinfo->rnti; p_ul_ici_dci->m_tbsize=Do_Ul_TbSize(p_ul_UEinfo->cqi,cal_ul_abs(p_ul_UEinfo->datasizeof_bsr,Get_Ul_PerPrb_Datasize(p_ul_UEinfo->cqi)));//LHL 20141011,需要和耿讨论 p_ul_ici_dci->dci_format=0; p_ul_ici_dci->s_ul_dci.m_format =Do_UlDci_format(); p_ul_ici_dci->s_ul_dci.m_hopping =Do_UlDci_hopping(); p_ul_ici_dci->s_ul_dci.RIV =Do_UlDci_RIV(p_ul_UEinfo->subframeN, p_ul_UEinfo->cqi, p_ul_UEinfo->datasizeof_bsr); p_ul_ici_dci->s_ul_dci.m_ndi =Do_UlDci_ndi(); p_ul_ici_dci->s_ul_dci.m_mcs =Do_UlDci_mcs(p_ul_UEinfo->cqi); p_ul_ici_dci->s_ul_dci.m_tpc =Do_UlDci_tpc(); p_ul_ici_dci->s_ul_dci.m_cqiRequest =Do_UlDci_cqirequest(); p_ul_ici_dci->s_ul_dci.Cyclic_shift =Do_UlDci_Cyclic_shift(); p_ul_ici_dci->s_ul_dci.m_dai =Do_UlDci_dai(); p_ul_ici_dci->s_ul_dci.padding =0; p_ul_ici_dci->s_ul_dci.emptybits =0; //Test code Geng 20141027 fsm_printf("\n##After Test Order_Ul_Sched:"); fsm_printf("\nSome important paramters are:"); fsm_printf(" RNTI:%u",p_ul_ici_dci->m_rnti); fsm_printf(" dci_format:%u",p_ul_ici_dci->dci_format); fsm_printf(" m_tbsize:%u",p_ul_ici_dci->m_tbsize); fsm_printf(" m_mcs:%u",p_ul_ici_dci->s_ul_dci.m_mcs); fsm_printf(" RIV:%u",p_ul_ici_dci->s_ul_dci.RIV); fsm_printf(" m_dai:%u",p_ul_ici_dci->s_ul_dci.m_dai); fsm_do_ioctrl(STRM_TO_SRIO, IOCCMD_MACTOPHY_UL_DCI, (void *) p_ul_ici_dci, sizeof(ENBMAC_TO_PHY_ULscheduleDCI)); fsm_mem_free(p_ul_ici_dci); FRET(Cal_usable_ResOfBitmap(p_ul_UEinfo->cqi,p_ul_UEinfo->subframeN)); }
//输入:需要分配的RNTI的类型,输出:函数分配的RNTI的值.目前,只分配TC-RNTI,故而m_type_rnti取值为1. static unsigned short Simple_System_Allocate_Rnti(int m_type_rnti,u16 RAPID) { int i,rnti; FIN(Simple_System_Allocate_Rnti()); SV_PTR_GET(mac_sv); switch(convert_rapid_rnti(RAPID)) { case RNTI_A: { if(UNALLOCATED_RNTI==find_type_rnti(RNTI_A)) { SV(rntiarray[0]).Type_rnti=m_type_rnti; rnti=RNTI_A; } else rnti=DoAllocate_Rnti(m_type_rnti); } break; case RNTI_B: { if(UNALLOCATED_RNTI==find_type_rnti(RNTI_B)) { SV(rntiarray[1]).Type_rnti=m_type_rnti; rnti=RNTI_B; } else rnti=DoAllocate_Rnti(m_type_rnti); } break; case RNTI_C: { if(UNALLOCATED_RNTI==find_type_rnti(RNTI_C)) { SV(rntiarray[2]).Type_rnti=m_type_rnti; rnti=RNTI_C; } else rnti=DoAllocate_Rnti(m_type_rnti); } break; case RNTI_D: { if(UNALLOCATED_RNTI==find_type_rnti(RNTI_D)) { SV(rntiarray[3]).Type_rnti=m_type_rnti; rnti=RNTI_D; } else rnti=DoAllocate_Rnti(m_type_rnti); } break; case RNTI_E: { if(UNALLOCATED_RNTI==find_type_rnti(RNTI_E)) { SV(rntiarray[4]).Type_rnti=m_type_rnti; rnti=RNTI_E; } else rnti=DoAllocate_Rnti(m_type_rnti); } break; default: { rnti=DoAllocate_Rnti(m_type_rnti); } break; } fsm_printf("[XXX] In Simple_System_Allocate_Rnti function TC-RNTI:%d\n",rnti); FRET(rnti); }
//下行调度算法,得到被调度的用户及其优先级,同时给出资源分配方案。 //目前最简系统,使用固定分配的方式。5个下行用户 //schedule_scheme数组为全局变量,他代表了目前的静态调度方案。 //bitmap:32bit,取前面25bit为有效位。现在全部分配了25bit,每个用户占bitmap的5个bit void Do_sched_algorithm() { int i; FIN(Do_Dl_Schedule_algorithm()); SV_PTR_GET(mac_sv); if (0==SCHEDULE_MODE) { u32 bitmap[]={0xf8000000,0x07c00000,0x003e0000,0x0001f000,0x00000f80};//PRB0-19 20-39 40-59 60-79 80-99 // for(i=0;i<DL_SCHEDULE_NUM;i++) { //由于特殊子帧的TBSIZE还有待商榷,所以目前全部查表nprb=20 5736 SV(schedule_scheme[i]).tbsize=Get_Dl_TbSize(DL_CQI,GetNprb()/DL_SCHEDULE_NUM); //提前两个子帧 if(SV(phy_to_mac_frame).subframeN!=0 && SV(phy_to_mac_frame).subframeN != 5 &&SV(phy_to_mac_frame).subframeN <=7) { SV(schedule_scheme[i]).sfn=SV(phy_to_mac_frame).sfn; SV(schedule_scheme[i]).subframeN=SV(phy_to_mac_frame).subframeN+DL_TA; } else if(SV(phy_to_mac_frame).subframeN>7) { SV(schedule_scheme[i]).sfn=SV(phy_to_mac_frame).sfn+1; SV(schedule_scheme[i]).subframeN=SV(phy_to_mac_frame).subframeN+DL_TA-10; } else { SV(schedule_scheme[i]).sfn=SV(phy_to_mac_frame).sfn; SV(schedule_scheme[i]).subframeN=SV(phy_to_mac_frame).subframeN+1+DL_TA; } if(i != 2)//UE1UE2UE4UE5 { SV(schedule_scheme[i]).m_bitmap=bitmap[i]; SV(schedule_scheme[i]).m_rnti=i+61;//20141017耿灿锡改:符合物理层要求5用户rnti为61-65 SV(schedule_scheme[i]).m_data_size=((5*4)*Get_Dl_PerPrb_Datasize(DL_CQI,SV(schedule_scheme[i]).subframeN)/8);//1060,1530 } else//UE3在PRB47-52中PBCH和PSCH信道占用了信道资源,需要将其减去 { if(SV(schedule_scheme[i]).subframeN == 0) SV(schedule_scheme[i]).m_data_size=(((5*4)*Get_Dl_PerPrb_Datasize(DL_CQI,SV(schedule_scheme[i]).subframeN)-PBCH_OFDM-SSCH_OFDM)/8);//1488 else if(SV(schedule_scheme[i]).subframeN == 1 &&SV(schedule_scheme[i]).subframeN == 6) SV(schedule_scheme[i]).m_data_size=(((5*4)*Get_Dl_PerPrb_Datasize(DL_CQI,SV(schedule_scheme[i]).subframeN)-PSCH_OFDM)/8);//1051 else if(SV(schedule_scheme[i]).subframeN == 5) SV(schedule_scheme[i]).m_data_size=(((5*4)*Get_Dl_PerPrb_Datasize(DL_CQI,SV(schedule_scheme[i]).subframeN)-SSCH_OFDM)/8);//1521 else SV(schedule_scheme[i]).m_data_size=((5*4)*Get_Dl_PerPrb_Datasize(DL_CQI,SV(schedule_scheme[i]).subframeN)/8);//1060 SV(schedule_scheme[i]).m_bitmap=bitmap[i]; SV(schedule_scheme[i]).m_rnti=i+61;//20141017耿灿锡改:符合物理层要求5用户rnti为61-65 } } } //Semi_Persistent if(1==SCHEDULE_MODE) { fsm_printf("Do not consider the semi-persistent at present!\n"); } // dynamic if(2==SCHEDULE_MODE) { fsm_printf("Do not consider the dynamic at present!\n"); } FOUT; }
static unsigned short Do_UlDci_RIV(u16 subframe,u16 cqi,unsigned int bsr) { int PerPrb_Datasize,lcrbs,RBstart,Nprb; int i,a; u16 RIV; FIN(Do_UlDci_RIV()); SV_PTR_GET(mac_sv); PerPrb_Datasize=Get_Ul_PerPrb_Datasize(cqi); lcrbs=cal_ul_abs(bsr,PerPrb_Datasize);//根据BSR的数据量大小,计算prb的个数上绝对值 for(a=1;a<3;a++) { if(2==subframe) { for(i=0;i<100-lcrbs;i++) { if(0==SV(prb_bitmap7[i])) { RBstart=i; for(;i<RBstart+lcrbs;i++) { SV(prb_bitmap7[i])=1; } a=3; break; } } if(i==100-lcrbs) subframe=7; } if(7==subframe) { for(i=0;i<100-lcrbs;i++) { if(0==SV(next_prb_bitmap2[i])) { RBstart=i; for(;i<RBstart+lcrbs;i++) { SV(next_prb_bitmap2[i])=1; } a=3; break; } } if(i==100-lcrbs) subframe=2; } } Nprb=GetNprb(); if(lcrbs <= 1 + Nprb/2) { RIV=Nprb*(lcrbs-1)+RBstart; } else { RIV=Nprb*(Nprb-lcrbs+1)+(Nprb-1-RBstart); } if(Do_UlDci_hopping()==1) { //如果需要考虑调频,那么需要在资源分配的数据域的前两个bit,设置跳频指示。 fsm_printf("We need take of the hopping,and change the resource 'bit' allocate"); } FRET(RIV); }
/****************************************************************** **Function name:struct DL_CCCH_Message *gen_dl_ccch_send_rrcsetup **Description:generate DL_CCCH_Message meaasge pointer ues for RRC connection process ,the meaasge include RRCConnectionSetup message **Input:void **Output:void **Return:dl_ccch_rrcsetup **Created by:Xu Shangfei **Created date:2014/09/06 **----------------------------------- **Modified by: Xu Shangfei **Modified date:2014.10.9 ****************************************************************/ struct DL_CCCH_Message *gen_dl_ccch_send_rrcsetup(void) { //srb-ToAddModList struct T_PollRetransmit t_pollretransmit1={ .t_PollRetransmittype = ms120, }; struct PollPDU pollpdu1={ .pollPDUtype = p8, }; struct PollByte pollbyte1={ .pollByte = kB1000, }; struct UL_AM_RLC ul_amrlc1={ .t_PollRetransmit = t_pollretransmit1, .pollPDU = pollpdu1, .pollByte = pollbyte1, .maxRetxThreshold = t2, }; struct T_Reordering t_reordering1={ .t_Reordering = t_Reordering_ms20, }; struct T_StatusProhibit t_statusprohibit1={ .t_StatusProhibit = t_StatusProhibit_ms20, }; struct DL_AM_RLC dl_am_rlc1={ .t_Reordering = t_reordering1, .t_StatusProhibit = t_statusprohibit1, }; struct RLC_Config_am rlc_config_am1={ .ul_AM_RLC = ul_amrlc1, .dl_AM_RLC = dl_am_rlc1, }; struct RlcConfig rlcconfig1={ //RLC configuration of SRB and DRB .type = 1, .rlcConfigType.am = rlc_config_am1, }; struct Ul_SpecificParameters ul_specificparameters1={ .priority = 1, //INTEGER (1..16) .prioritisedBitRate = kBps32, .bucketSizeDuration = bucketSizeDuration_ms100, .logicalChannelGroup = 1, //INTEGER (0..3) }; struct LogicalChannelConfig logicalchannelconfig1 = { .haveUl_SpecificParameters = true, .ul_SpecificParameters = ul_specificparameters1, }; struct SrbToAddMod srbtoaddmod1={ .srbIdentity = 1, //INTEGER (1..2) .haveRlcConfig = true, .rlcConfig = rlcconfig1, //rlcConfig==null means use default config .haveLogicalChannelConfig = true, .logicalChannelConfig = logicalchannelconfig1, //nullmeans use default config }; struct SrbToAddMod srbtoaddmod2={ .srbIdentity = 2, //INTEGER (1..2) .haveRlcConfig = true, .rlcConfig = rlcconfig1, //rlcConfig==nullmeans use default config .haveLogicalChannelConfig = true, .logicalChannelConfig = logicalchannelconfig1, //nullmeans use default config }; /**srb-ToAddModList**/ struct SrbToAddModList srb_toaddmodlist1={ .num = 2, //number of SrbToAddMod in SrbToAddModList .srbList[0] = srbtoaddmod1, .srbList[1] = srbtoaddmod2, }; struct DrbToAddMod drb_toaddmod1={ .eps_BearerIdentity = 1,//INTEGER (0..15) .drb_Identity = 1, .haveRlcConfig = true, .rlcConfig = rlcconfig1, .logicalChannelIdentity = 7,//INTEGER (3..10) .haveLogicalChannelConfig = true, .logicalChannelConfig = logicalchannelconfig1, }; /**DrbToAddModList**/ struct DrbToAddModList drb_toaddmodlist1={ .num = 1, .drbList[0] = drb_toaddmod1, }; /**DrbToReleaseList**/ struct DrbToReleaseList drb_toreleaseliast={ .num = 1, .drbToRelease[0] = 4, }; /**mac-MainConfig**/ struct Ul_SCH_Config ul_schconfig1={ .maxHARQ_Tx = maxHARQ_Tx_n2, .periodicBSR_Timer = periodicBSR_Timer_sf40, .retxBSR_Timer = retxBSR_Timer_sf640, .ttiBundling = true, }; struct ShortDRX shortdrx1={ .shortDRX_Cycle = shortDRX_Cycle_sf64 , .drxShortCycleTimer = 4, //INTEGER (1..16) }; struct DRX_Config_setup drx_config_setup1={ .onDurationTimer = psf60, .drx_InactivityTimer = drx_InactivityTimer_psf100, .drx_RetransmissionTimer = drx_RetransmissionTimer_psf8, .type = 3, //1:sf10...... .longDRX_CycleStartOffset.sf32 = 30, .haveShortDRX = true, .shortDRX = shortdrx1, }; struct DRX_Config drx_config1={ .type = 2, //1:release, 2:setup .choice.setup = drx_config_setup1, }; struct Phr_Config_Setup phr_configsetup1={ .periodicPHR_Timer = periodicPHR_Timer_sf100, .prohibitPHR_Timer = prohibitPHR_Timer_sf100, .dl_PathlossChange = dl_PathlossChange_dB1, }; struct TimeAlignmentTimer time_alignmenttimer1={ .timeAlignmentTimertype = timeAlignmentTimertype_sf1920, }; struct MAC_MainConfig mac_mainconfig1={ //descripe Macmainconfig .haveUl_SCH_Config = true, .ul_SCH_Config = ul_schconfig1, .haveDRX_Config = true, .drx_Config = drx_config1, .timeAlignmentTimerDedicated = time_alignmenttimer1, .type = 2, //1:release, 2:setup .phr_Config.setup = phr_configsetup1, }; /****SPS-Config****/ struct C_RNTI c_rnti1={ //bitstring datetype .c_rnti = 4, }; struct N1_PUCCH_AN_PersistentList n1_pucch_an_persistentlist1={ //parameters not understand need to refer to 36.213 .num[0] = 1, .num[1] = 2, .num[2] = 3, .num[3] = 4, }; struct SPS_ConfigDL_setup sps_configdl_setup1={ .semiPersistSchedIntervalDL = semiPersistSchedIntervalDL_sf40, .numberOfConfSPS_Processes = 4, //INTEGER (1..8) .n1_PUCCH_AN_PersistentList = n1_pucch_an_persistentlist1, }; struct SPS_ConfigDL sps_configdl1={ .type = 2, //1:release, 2:setup .choice.setup = sps_configdl_setup1, }; struct P0_Persistent p0_persistent1={ .p0_NominalPUSCH_Persistent = 1,//INTEGER (-126..24) .p0_UE_PUSCH_Persistent = 1, //INTEGER (-8..7) }; struct SPS_ConfigUL_setup sps_config_setup1={ .semiPersistSchedIntervalUL = semiPersistSchedIntervalUL_sf64, .implicitReleaseAfter = e2, .haveP0_Persistent = true, .p0_Persistent = p0_persistent1, .twoIntervalsConfig = true, }; struct SPS_ConfigUL sps_configul1={ .type = 2, //1:release, 2:setup .choice.setup = sps_config_setup1, }; struct SPS_Config sps_config1={ //descripe SPS_Config .haveC_RNTI = true, .semiPersistSchedC_RNTI = c_rnti1, .haveSPS_ConfigDL = true, .sps_ConfigDL = sps_configdl1, .haveSPS_ConfigUL = true, .sps_ConfigUL = sps_configul1, }; /****PhysicalConfigDedicated****/ struct PDSCH_ConfigDedicated pdsch_configdedicated1={ //descripe PDSCH_ConfigDedicated .p_a = p_a_dB1, }; struct AckNackRepetition_setup acknacrepetition_setup1={ .repetitionFactor = repetitionFactor_n2, .n1PUCCH_AN_Rep = 4, }; struct PUCCH_ConfigDedicated pucch_configdedicate1={ //descripe PUCCH_ConfigDedicated .type = 2, //1:release, 2:setup, 3:tddAckNackFeedbackMode .ackNackRepetition.setup = acknacrepetition_setup1, }; struct PUSCH_ConfigDedicated pusch_configdicated1={ //descripe PUSCH_ConfigDedicated .betaOffset_ACK_Index = 2, //INTEGER (0..15) .betaOffset_RI_Index = 2, //INTEGER (0..15) .betaOffset_CQI_Index = 2, //INTEGER (0..15) }; struct FilterCoefficient filtercoefficient1={ .filterCoefficienttype = fc6, }; struct UplinkPowerControlDedicated uplinkpowercontroldedicated1={ //descripe UplinkPowerControlDedicated .p0_UE_PUSCH = 2, //INTEGER (-8..7) .deltaMCS_Enabled = en1, //en1 对应值1.25 .accumulationEnabled = true, .p0_uE_PUCCH = 2, //INTEGER (-8..7) .pSRS_Offset = 2, //INTEGER (0..15) .filterCoefficient = filtercoefficient1, }; struct TPC_PDCCH_Config_setup tpc_pdcch_config_setup1={ .indexOfFormat3 = 2, //INTEGER (1..15) .indexOfFormat3A = 2, //INTEGER (1..31) }; struct TPC_PDCCH_Config tpc_pdcch_config1={ .type = 2, //1:release, 2:setup .choice.setup = tpc_pdcch_config_setup1, }; struct SubbandCQI subbandcqi1={ .k = 2, //INTEGER (1..4) }; struct CQI_ReportPeriodic_setup cqi_reportperioid1={ .cqi_PUCCH_ResourceIndex = 100,//INTEGER (0.. 1185) .cqi_pmi_ConfigIndex = 100, //INTEGER (0..1023) .type = 3, //1:widebandCQI...... .cqi_FormatIndicatorPeriodic.ri_ConfigIndex = 100, }; struct CQI_ReportPeriodic cqi_reportperodic1={ .type = 2, //1:release, 2:setup, 3:ri_ConfigIndex, 4:simultaneousAckNackAndCQI .choice.setup = cqi_reportperioid1, }; struct CQI_ReportConfig cqi_reportconfig1={ //descripe CQI_ReportConfig .cqi_ReportModeAperiodic = rm20, .nomPDSCH_RS_EPRE_Offset = 2, //INTEGER (-1..6) .haveCQI_ReportPeriodic = true, .cqi_ReportPeriodic = cqi_reportperodic1, }; struct SoundingRS_UL_ConfigDedicated_setup soundrs_ul_configdedicate_setup1={ .srs_Bandwidth = srs_Bandwidth_bw0, .srs_HoppingBandwidth = hbw0, .FreqDomainPosition = 2, //INTEGER (0..23) .duration = true, .srs_ConfigIndex = 2, //INTEGER (0..1023) .transmissionComb = 1, //INTEGER (0..1) .cyclicShift = cs1, }; struct SoundingRS_UL_ConfigDedicated soundrs_ul_configdedicated1={ //descripe SoundingRS_UL_ConfigDedicated .type = 2, //1:release, 2:setup .choice.setup = soundrs_ul_configdedicate_setup1, }; struct SchedulingRequestConfig_setup schedulingrequestconfig_setup1={ .sr_PUCCH_ResourceIndex = 100, //INTEGER (0..2047) .sr_ConfigIndex = 100, //INTEGER (0..157) .dsr_TransMax = dsr_TransMax_n4, }; struct SchedulingRequestConfig schedulingrequestconfig1={ //descripe SchedulingRequestConfig .type = 2, //1:release, 2:setup .choice.setup = schedulingrequestconfig_setup1, }; struct AntennaInformationDedicated antennainformationdedicated1={ .transmissionMode = tm3, .type_codebookSubsetRestriction = 2, //1:n2TxAntenna_tm3...... .codebookSubsetRestriction.n4TxAntenna_tm3 = 2, .type_ue_TransmitAntennaSelection = 2, .ue_TransmitAntennaSelection.setup = openLoop, }; struct PhysicalConfigDedicated physicalconfigdedicateed1={ .havePDSCH_ConfigDedicated = true, .pdsch_ConfigDedicated = pdsch_configdedicated1, .havePUCCH_ConfigDedicated = true, .pucch_ConfigDedicated = pucch_configdedicate1, .havePUSCH_ConfigDedicated =true, .pusch_ConfigDedicated = pusch_configdicated1, .haveUplinkPowerControlDedicated =true, .uplinkPowerControlDedicated = uplinkpowercontroldedicated1, .haveTPC_PDCCH_Config =true, .tpc_PDCCH_ConfigPUCCH = tpc_pdcch_config1, .tpc_PDCCH_ConfigPUSCH = tpc_pdcch_config1, .haveCQI_ReportConfig = true, .cqi_ReportConfig = cqi_reportconfig1, .haveSoundingRS_UL_ConfigDedicated =true, .soundingRS_UL_ConfigDedicated = soundrs_ul_configdedicated1, .haveAntennaInformationDedicated = true, .antennaInfo = antennainformationdedicated1, .haveSchedulingRequestConfig = true, .schedulingRequestConfig = schedulingrequestconfig1, }; /****RadioResourceConfigDedicated****/ struct RadioResourceConfigDedicated set_radioresourcemsg={ .haveSrbToAddModList = true, .srbToAddModList = srb_toaddmodlist1, .haveDrbToAddModList = false, .drbToAddModList = drb_toaddmodlist1, .haveDrbToReleaseList = true, .drbToReleaseList = drb_toreleaseliast, .haveMAC_MainConfig = true, .mac_MainConfig = mac_mainconfig1, .haveSPS_Config = true, .sps_Config = sps_config1, .havePhysicalConfigDedicated = true, .physicalConfigDedicated = physicalconfigdedicateed1, }; struct RRCConnectionSetup rrcConnectionSetupmsg1 ={ .rrcTransactionIdentifier = 2, //random value .radioResourceConfigDedicated = set_radioresourcemsg, }; struct DL_CCCH_Message *dl_ccch_rrcsetup = fsm_mem_alloc(sizeof(struct DL_CCCH_Message)); dl_ccch_rrcsetup->type = 4; dl_ccch_rrcsetup->msg.rrcConnectionSetup = rrcConnectionSetupmsg1; // fsm_mem_cpy(&(dl_ccch_rrcsetup->msg.rrcConnectionSetup), &rrcConnectionSetupmsg1, sizeof(struct RRCConnectionSetup)); return dl_ccch_rrcsetup; } /****************************************************************** **Filename:impl_rrc_conn_establish.c **Copyright:uestc **Description:RRC reject data struct,use for rrcreject msg **V1.0,2014/10/16,Xu Shangfei written **----------------------------------- **modification history: **Modified by: Xu Shangfei **Modified date:2014.10.9 **Description:modified note ****************************************************************/ struct DL_CCCH_Message *gen_dl_ccch_send_rrcreject(void) { struct RRCConnectionReject rrcrejct = { .waitTime = 4, }; struct DL_CCCH_Message *dl_ccch_rrcrejct = fsm_mem_alloc(sizeof(struct DL_CCCH_Message)); dl_ccch_rrcrejct->type = 3; fsm_mem_cpy(&(dl_ccch_rrcrejct->msg.rrcConnectionSetup), &rrcrejct, sizeof(struct RRCConnectionReject)); return dl_ccch_rrcrejct; } /****************************************************************** **Function name:void send_RRCConnectionSetup **Description:struct DL_CCCH_Message *dlccchRRCremsg,use packet_send_to_pdcp send RRCconsetup msg to UE **Input:struct DL_CCCH_Message *dlccchRRCremsg **Output:void **Return:void **Created by:Xu Shangfei **Created date:2014.10.9 **----------------------------------- **Modified by: Xu Shangfei **Modified date: ****************************************************************/ void send_RRCConnectionSetup(struct DL_CCCH_Message *dlccchRRCremsg) { SV_PTR_GET(rrc_sv_enb_ue); FIN(send_RRCConnectionSetup()); char *msg = (char *)(&(*dlccchRRCremsg)); int msg_len = sizeof(struct DL_CCCH_Message); int message_type = 3; packet_send_to_rlc(msg, msg_len, message_type, SV(crnti)); fsm_printf("[rrc] [conn_establish] <-- message RRCConnectionSetup sends successfully.\n"); FOUT; } /****************************************************************** **Function name:void send_RRCConnectionRejct **Description:struct DL_CCCH_Message *dlccchRRCremsg,use packet_send_to_pdcp send RRCconsetup msg to UE **Input:struct DL_CCCH_Message *dlccchRRCremsg **Output:void **Return:void **Created by:Xu Shangfei **Created date:2014.10.9 **----------------------------------- **Modified by: Xu Shangfei **Modified date: ****************************************************************/ void send_RRCConnectionRejct(struct DL_CCCH_Message *dlccchRRCremsg) { FIN(send_RRCConnectionSetup()); SV_PTR_GET(rrc_sv_enb_ue); char *msg = (char *)(&(*dlccchRRCremsg)); int msg_len = sizeof(struct DL_CCCH_Message); int message_type = 3; packet_send_to_rlc(msg, msg_len, message_type, SV(crnti)); fsm_printf("[rrc] [conn_establish] <-- message RRCConnectionRejct sends successfully.\n"); FOUT; } //ues for test in-->static void rcv_rrc_conn_setup_complete(void) struct UL_DCCH_Message *gen_ul_dcch_rrccomplete(void) { struct PLMN_Identity plmn_identity1={ .MCC[0] = 2, .MNC[0] = 2, }; struct RegisteredMME registeredmme1={ .plmn_Identity = plmn_identity1, .mmegi = 1, .mmec= 1, }; struct RRCConnectionSetupComplete rrcconnectionsetup_complete1={ .rrcTransactionIdentifier = 1, .selectedPLMN_Identity = 1, //INTEGER (1..6), .registeredMME = registeredmme1, //struct DedicatedInfoNAS dedicatedInfoNAS; //协议里有,暂时不用 }; struct UL_DCCH_Message *ul_dcchmsg1 = fsm_mem_alloc(sizeof(struct UL_DCCH_Message)); ul_dcchmsg1->type = 4; ul_dcchmsg1->msg.rrcConnectionSetupComplete = rrcconnectionsetup_complete1; fsm_printf("[rrc] [conn_establish] <--send rrcsetupcompletemsg message !\n"); return ul_dcchmsg1; }