dlsch[ii][0];
+
+ if((dlsch != NULL) && (dlsch->rnti == rnti)) {
void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch);
- LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti);
- clean_eNb_dlsch(dlsch);
- }
- }
-
- for(int j = 0; j < 10; j++){
- nfapi_ul_config_request_body_t *ul_req_tmp = NULL;
- ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body;
- if(ul_req_tmp){
- int pdu_number = ul_req_tmp->number_of_pdus;
- for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--){
- if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti){
- LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number);
- if(pdu_index < pdu_number -1){
- memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
- }
- ul_req_tmp->number_of_pdus--;
- }
- }
- }
- }
- rrc_mac_remove_ue(module_idP,rnti);
- }
+ LOG_I(MAC, "clean_eNb_dlsch UE %x \n", rnti);
+ clean_eNb_dlsch(dlsch);
+ }
+ }
+
+ for(int j = 0; j < 10; j++) {
+ nfapi_ul_config_request_body_t *ul_req_tmp = NULL;
+ ul_req_tmp = &RC.mac[module_idP]->UL_req_tmp[CC_id][j].ul_config_request_body;
+
+ if(ul_req_tmp) {
+ int pdu_number = ul_req_tmp->number_of_pdus;
+
+ for(int pdu_index = pdu_number-1; pdu_index >= 0; pdu_index--) {
+ if(ul_req_tmp->ul_config_pdu_list[pdu_index].ulsch_pdu.ulsch_pdu_rel8.rnti == rnti) {
+ LOG_I(MAC, "remove UE %x from ul_config_pdu_list %d/%d\n", rnti, pdu_index, pdu_number);
+
+ if(pdu_index < pdu_number -1) {
+ memcpy(&ul_req_tmp->ul_config_pdu_list[pdu_index], &ul_req_tmp->ul_config_pdu_list[pdu_index+1], (pdu_number-1-pdu_index) * sizeof(nfapi_ul_config_request_pdu_t));
+ }
+
+ ul_req_tmp->number_of_pdus--;
+ }
+ }
+ }
+ }
+
+ rrc_mac_remove_ue(module_idP,rnti);
+ }
}
}
}
#if (!defined(PRE_SCD_THREAD))
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES,
- NOT_A_RNTI, frameP, subframeP,
- module_idP);
+ NOT_A_RNTI, frameP, subframeP,
+ module_idP);
pdcp_run(&ctxt);
-
rrc_rx_tx(&ctxt, CC_id);
#endif
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
@@ -640,27 +625,29 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
}
#endif
-
static int debug_flag=0;
void (*schedule_ulsch_p)(module_id_t module_idP, frame_t frameP, sub_frame_t subframe)=NULL;
void (*schedule_ue_spec_p)(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, int *mbsfn_flag)=NULL;
- if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_DEFAULT){
+
+ if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_DEFAULT) {
schedule_ulsch_p = schedule_ulsch;
schedule_ue_spec_p = schedule_dlsch;
- }else if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){
+ } else if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) {
memset(dlsch_ue_select, 0, sizeof(dlsch_ue_select));
schedule_ulsch_p = schedule_ulsch_fairRR;
schedule_ue_spec_p = schedule_ue_spec_fairRR;
}
- if(debug_flag==0){
+
+ if(debug_flag==0) {
LOG_E(MAC,"SCHED_MODE=%d\n",RC.mac[module_idP]->scheduler_mode);
debug_flag=1;
}
// This schedules MIB
if ((subframeP == 0) && (frameP & 3) == 0)
- schedule_mib(module_idP, frameP, subframeP);
- if (get_softmodem_params()->phy_test == 0){
+ schedule_mib(module_idP, frameP, subframeP);
+
+ if (get_softmodem_params()->phy_test == 0) {
// This schedules SI for legacy LTE and eMTC starting in subframeP
schedule_SI(module_idP, frameP, subframeP);
// This schedules Paging in subframeP
@@ -671,12 +658,14 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
copy_ulreq(module_idP, frameP, subframeP);
// This schedules SRS in subframeP
schedule_SRS(module_idP, frameP, subframeP);
+
// This schedules ULSCH in subframeP (dci0)
if (schedule_ulsch_p != NULL) {
- schedule_ulsch_p(module_idP, frameP, subframeP);
+ schedule_ulsch_p(module_idP, frameP, subframeP);
} else {
- LOG_E(MAC," %s %d: schedule_ulsch_p is NULL, function not called\n",__FILE__,__LINE__);
+ LOG_E(MAC," %s %d: schedule_ulsch_p is NULL, function not called\n",__FILE__,__LINE__);
}
+
// This schedules UCI_SR in subframeP
schedule_SR(module_idP, frameP, subframeP);
// This schedules UCI_CSI in subframeP
@@ -685,15 +674,14 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
// This schedules DLSCH in subframeP
schedule_ue_spec_br(module_idP, frameP, subframeP);
#endif
+
// This schedules DLSCH in subframeP
if (schedule_ue_spec_p != NULL) {
- schedule_ue_spec_p(module_idP, frameP, subframeP, mbsfn_status);
+ schedule_ue_spec_p(module_idP, frameP, subframeP, mbsfn_status);
} else {
- LOG_E(MAC," %s %d: schedule_ue_spec_p is NULL, function not called\n",__FILE__,__LINE__);
+ LOG_E(MAC," %s %d: schedule_ue_spec_p is NULL, function not called\n",__FILE__,__LINE__);
}
-
- }
- else{
+ } else {
schedule_ulsch_phy_test(module_idP,frameP,subframeP);
schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status);
}
@@ -709,8 +697,7 @@ eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP,
}
stop_meas(&RC.mac[module_idP]->eNB_scheduler);
-
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,
- VCD_FUNCTION_OUT);
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,
+ VCD_FUNCTION_OUT);
}
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
index 79d791c558..fa0aaec3f0 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c
@@ -41,6 +41,7 @@
#include "LAYER2/MAC/mac_proto.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
@@ -55,10 +56,10 @@
#include "pdcp.h"
#if defined(ENABLE_ITTI)
-#include "intertask_interface.h"
+ #include "intertask_interface.h"
#endif
-#include "SIMULATION/TOOLS/sim.h" // for taus
+#include "SIMULATION/TOOLS/sim.h" // for taus
#include "T.h"
@@ -67,68 +68,58 @@
extern RAN_CONTEXT_t RC;
-extern uint8_t nfapi_mode;
+
extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req);
-void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset)
-{
- *frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024;
-
- *subframeP = ((*subframeP + offset) % 10);
+void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) {
+ *frameP = (*frameP + ((*subframeP + offset) / 10)) % 1024;
+ *subframeP = ((*subframeP + offset) % 10);
}
-uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset)
-{
+uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset) {
add_subframe(&frameP, &subframeP, offset);
return frameP<<4|subframeP;
}
-void subtract_subframe(uint16_t *frameP, uint16_t *subframeP, int offset)
-{
- if (*subframeP < offset)
- {
+void subtract_subframe(uint16_t *frameP, uint16_t *subframeP, int offset) {
+ if (*subframeP < offset) {
*frameP = (*frameP+1024-1)%1024;
}
+
*subframeP = (*subframeP+10-offset)%10;
}
-uint16_t sfnsf_subtract_subframe(uint16_t frameP, uint16_t subframeP, int offset)
-{
+uint16_t sfnsf_subtract_subframe(uint16_t frameP, uint16_t subframeP, int offset) {
subtract_subframe(&frameP, &subframeP, offset);
return frameP<<4|subframeP;
}
void
-add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP,
- sub_frame_t subframeP)
-{
- eNB_MAC_INST *mac = RC.mac[module_idP];
- COMMON_channels_t *cc = &mac->common_channels[CC_id];
- uint8_t j;
- nfapi_ul_config_request_t *ul_req;
- nfapi_ul_config_request_body_t *ul_req_body;
- nfapi_ul_config_request_pdu_t *ul_config_pdu;
- nfapi_hi_dci0_request_t *hi_dci0_req;
- nfapi_hi_dci0_request_body_t *hi_dci0_req_body;
- nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu;
- uint8_t sf_ahead_dl;
- uint8_t rvseq[4] = {0, 2, 3, 1};
-
-
- ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe];
- ul_req_body = &ul_req->ul_config_request_body;
- AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n",
- ra->rnti);
-
+add_msg3(module_id_t module_idP, int CC_id, RA_t *ra, frame_t frameP,
+ sub_frame_t subframeP) {
+ eNB_MAC_INST *mac = RC.mac[module_idP];
+ COMMON_channels_t *cc = &mac->common_channels[CC_id];
+ uint8_t j;
+ nfapi_ul_config_request_t *ul_req;
+ nfapi_ul_config_request_body_t *ul_req_body;
+ nfapi_ul_config_request_pdu_t *ul_config_pdu;
+ nfapi_hi_dci0_request_t *hi_dci0_req;
+ nfapi_hi_dci0_request_body_t *hi_dci0_req_body;
+ nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu;
+ uint8_t sf_ahead_dl;
+ uint8_t rvseq[4] = {0, 2, 3, 1};
+ ul_req = &mac->UL_req_tmp[CC_id][ra->Msg3_subframe];
+ ul_req_body = &ul_req->ul_config_request_body;
+ AssertFatal(ra->state != IDLE, "RA is not active for RA %X\n",
+ ra->rnti);
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+
if (ra->rach_resource_type > 0) {
LOG_D (MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d CE level %d is active, Msg3 in (%d,%d)\n",
module_idP, frameP, subframeP, CC_id, ra->rach_resource_type - 1, ra->Msg3_frame, ra->Msg3_subframe);
LOG_D (MAC, "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d)\n",
frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe, ra->msg3_nb_rb, ra->msg3_round);
-
ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
-
memset ((void *) ul_config_pdu, 0, sizeof (nfapi_ul_config_request_pdu_t));
ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_ulsch_pdu));
@@ -156,127 +147,117 @@ add_msg3(module_id_t module_idP, int CC_id, RA_t * ra, frame_t frameP,
} // if (ra->rach_resource_type>0) {
else
#endif
- {
- LOG_D(MAC,
- "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n",
- module_idP, frameP, subframeP, CC_id, ra->Msg3_frame,
- ra->Msg3_subframe);
+ {
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] Frame %d, Subframe %d : CC_id %d RA is active, Msg3 in (%d,%d)\n",
+ module_idP, frameP, subframeP, CC_id, ra->Msg3_frame,
+ ra->Msg3_subframe);
+ LOG_D(MAC,
+ "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n",
+ frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe,
+ ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round, ra->rnti);
+ ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
+ memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t));
+ ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
+ ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu));
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = ra->msg3_first_rb;
+ AssertFatal(ra->msg3_nb_rb > 0, "nb_rb = 0\n");
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = ra->msg3_nb_rb;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[ra->msg3_round];
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = subframe2harqpid(cc, ra->Msg3_frame, ra->Msg3_subframe);
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1;
+ ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL(10, ra->msg3_nb_rb);
+ ul_req_body->number_of_pdus++;
+ ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
+ ul_req->sfn_sf = ra->Msg3_frame<<4|ra->Msg3_subframe;
+ ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
- LOG_D(MAC,
- "Frame %d, Subframe %d Adding Msg3 UL Config Request for (%d,%d) : (%d,%d,%d) for rnti: %d\n",
- frameP, subframeP, ra->Msg3_frame, ra->Msg3_subframe,
- ra->msg3_nb_rb, ra->msg3_first_rb, ra->msg3_round, ra->rnti);
+ // save UL scheduling information for preprocessor
+ for (j = 0; j < ra->msg3_nb_rb; j++)
+ cc->vrb_map_UL[ra->msg3_first_rb + j] = 1;
- ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
+ LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d ra->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, ra->msg3_round);
- memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t));
- ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
- ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu));
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_PDU_REL8_TAG;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.handle = mac->ul_handle++;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti = ra->rnti;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.resource_block_start = ra->msg3_first_rb;
- AssertFatal(ra->msg3_nb_rb > 0, "nb_rb = 0\n");
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.number_of_resource_blocks = ra->msg3_nb_rb;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.modulation_type = 2;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.cyclic_shift_2_for_drms = 0;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_enabled_flag = 0;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.frequency_hopping_bits = 0;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.new_data_indication = 0;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.redundancy_version = rvseq[ra->msg3_round];
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.harq_process_number = subframe2harqpid(cc, ra->Msg3_frame, ra->Msg3_subframe);
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.ul_tx_mode = 0;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.current_tx_nb = 0;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.n_srs = 1;
- ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.size = get_TBS_UL(10, ra->msg3_nb_rb);
- ul_req_body->number_of_pdus++;
- ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
- ul_req->sfn_sf = ra->Msg3_frame<<4|ra->Msg3_subframe;
- ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
- // save UL scheduling information for preprocessor
- for (j = 0; j < ra->msg3_nb_rb; j++)
- cc->vrb_map_UL[ra->msg3_first_rb + j] = 1;
+ if (ra->msg3_round != 0) { // program HI too
+ sf_ahead_dl = ul_subframe2_k_phich(cc, subframeP);
+ hi_dci0_req = &mac->HI_DCI0_req[CC_id][(subframeP+sf_ahead_dl)%10];
+ hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body;
+ hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi];
+ memset((void *) hi_dci0_pdu, 0,
+ sizeof(nfapi_hi_dci0_request_pdu_t));
+ hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
+ hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu);
+ hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
+ hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ra->msg3_first_rb;
+ hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0;
+ hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0;
+ hi_dci0_req_body->number_of_hi++;
+ hi_dci0_req_body->sfnsf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 0);
+ hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG;
+ hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP, subframeP, sf_ahead_dl);
+ hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
- LOG_D(MAC, "MSG3: UL_CONFIG SFN/SF:%d number_of_pdus:%d ra->msg3_round:%d\n", NFAPI_SFNSF2DEC(ul_req->sfn_sf), ul_req_body->number_of_pdus, ra->msg3_round);
+ if (NFAPI_MODE != NFAPI_MONOLITHIC) {
+ oai_nfapi_hi_dci0_req(hi_dci0_req);
+ hi_dci0_req_body->number_of_hi=0;
+ }
- if (ra->msg3_round != 0) { // program HI too
- sf_ahead_dl = ul_subframe2_k_phich(cc, subframeP);
- hi_dci0_req = &mac->HI_DCI0_req[CC_id][(subframeP+sf_ahead_dl)%10];
- hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body;
- hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi];
- memset((void *) hi_dci0_pdu, 0,
- sizeof(nfapi_hi_dci0_request_pdu_t));
- hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
- hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu);
- hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
- hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = ra->msg3_first_rb;
- hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0;
- hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0;
- hi_dci0_req_body->number_of_hi++;
+ LOG_D(MAC, "MSG3: HI_DCI0 SFN/SF:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req_body->number_of_dci, hi_dci0_req_body->number_of_hi);
- hi_dci0_req_body->sfnsf = sfnsf_add_subframe(ra->Msg3_frame, ra->Msg3_subframe, 0);
- hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG;
+ // save UL scheduling information for preprocessor
+ for (j = 0; j < ra->msg3_nb_rb; j++)
+ cc->vrb_map_UL[ra->msg3_first_rb + j] = 1;
- hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP, subframeP, sf_ahead_dl);
- hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
-
- if (nfapi_mode) {
- oai_nfapi_hi_dci0_req(hi_dci0_req);
- hi_dci0_req_body->number_of_hi=0;
- }
-
- LOG_D(MAC, "MSG3: HI_DCI0 SFN/SF:%d number_of_dci:%d number_of_hi:%d\n", NFAPI_SFNSF2DEC(hi_dci0_req->sfn_sf), hi_dci0_req_body->number_of_dci, hi_dci0_req_body->number_of_hi);
-
- // save UL scheduling information for preprocessor
- for (j = 0; j < ra->msg3_nb_rb; j++)
- cc->vrb_map_UL[ra->msg3_first_rb + j] = 1;
-
- LOG_D(MAC,
- "[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n",
- module_idP, ra->rnti, CC_id, frameP, subframeP, 10, 1, 1,
- ra->msg3_round - 1);
- } // if (ra->msg3_round != 0) { // program HI too
- } // non-BL/CE UE case
+ LOG_D(MAC,
+ "[eNB %d][PUSCH-RA %x] CC_id %d Frame %d subframeP %d Scheduled (PHICH) RA (mcs %d, first rb %d, nb_rb %d,round %d)\n",
+ module_idP, ra->rnti, CC_id, frameP, subframeP, 10, 1, 1,
+ ra->msg3_round - 1);
+ } // if (ra->msg3_round != 0) { // program HI too
+ } // non-BL/CE UE case
}
//------------------------------------------------------------------------------
/*
* Generate the RAR (message2)
*/
-void generate_Msg2(module_id_t module_idP,
- int CC_idP,
- frame_t frameP,
- sub_frame_t subframeP,
- RA_t *ra)
+void generate_Msg2(module_id_t module_idP,
+ int CC_idP,
+ frame_t frameP,
+ sub_frame_t subframeP,
+ RA_t *ra)
//------------------------------------------------------------------------------
{
eNB_MAC_INST *mac = RC.mac[module_idP];
COMMON_channels_t *cc = mac->common_channels;
-
uint8_t *vrb_map = NULL;
int first_rb = 0;
int N_RB_DL = 0;
-
nfapi_dl_config_request_pdu_t *dl_config_pdu = NULL;
nfapi_tx_request_pdu_t *TX_req = NULL;
nfapi_dl_config_request_body_t *dl_req_body = NULL;
-
vrb_map = cc[CC_idP].vrb_map;
dl_req_body = &mac->DL_req[CC_idP].dl_config_request_body;
dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
int rmax = 0;
int rep = 0;
int reps = 0;
int num_nb = 0;
-
first_rb = 0;
struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL;
LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL;
LTE_PRACH_ParametersCE_r13_t *p[4] = { NULL, NULL, NULL, NULL };
-
uint16_t absSF = (10 * frameP) + subframeP;
uint16_t absSF_Msg2 = (10 * ra->Msg2_frame) + ra->Msg2_subframe;
@@ -289,18 +270,22 @@ void generate_Msg2(module_id_t module_idP,
prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
switch (prach_ParametersListCE_r13->list.count) {
- case 4:
- p[3] = prach_ParametersListCE_r13->list.array[3];
- case 3:
- p[2] = prach_ParametersListCE_r13->list.array[2];
- case 2:
- p[1] = prach_ParametersListCE_r13->list.array[1];
- case 1:
- p[0] = prach_ParametersListCE_r13->list.array[0];
- break;
- default:
- AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", (int) prach_ParametersListCE_r13->list.count);
- break;
+ case 4:
+ p[3] = prach_ParametersListCE_r13->list.array[3];
+
+ case 3:
+ p[2] = prach_ParametersListCE_r13->list.array[2];
+
+ case 2:
+ p[1] = prach_ParametersListCE_r13->list.array[1];
+
+ case 1:
+ p[0] = prach_ParametersListCE_r13->list.array[0];
+ break;
+
+ default:
+ AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", (int) prach_ParametersListCE_r13->list.count);
+ break;
}
}
@@ -313,17 +298,13 @@ void generate_Msg2(module_id_t module_idP,
* if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates
* distributed transmission
*/
-
/* rmax from SIB2 information */
AssertFatal (rmax < 9, "rmax > 8!\n"); // not sure of this assertion
rmax = 1 << p[ra->rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13;
-
/* Choose r1 by default for RAR (Table 9.1.5-5) */
rep = 0;
-
/* Get actual repetition count from Table 9.1.5-3 */
reps = (rmax <= 8) ? (1 << rep) : (rmax >> (3 - rep));
-
/* Get narrowband according to higher-layer config */
num_nb = p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.count;
ra->msg2_narrowband = *p[ra->rach_resource_type - 1]->mpdcch_NarrowbandsToMonitor_r13.list.array[ra->preamble_index % num_nb] - 1;
@@ -331,17 +312,14 @@ void generate_Msg2(module_id_t module_idP,
if ((ra->msg2_mpdcch_repetition_cnt == 0) && (mpdcch_sf_condition(mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) {
ra->msg2_mpdcch_done = 0;
-
/* MPDCCH configuration for RAR */
- LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2 for CE Level %d, Programming MPDCCH %d repetitions\n",
- module_idP,
- frameP,
- subframeP,
+ LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2 for CE Level %d, Programming MPDCCH %d repetitions\n",
+ module_idP,
+ frameP,
+ subframeP,
ra->rach_resource_type - 1,
reps);
-
memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
-
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (ra->rach_resource_type > 1) ? 11 : 10;
@@ -349,9 +327,7 @@ void generate_Msg2(module_id_t module_idP,
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = 1; // imposed (9.1.5 in 213) for Type 2 Common search space
-
AssertFatal (cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 != NULL, "cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13 is null\n");
-
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
@@ -361,7 +337,7 @@ void generate_Msg2(module_id_t module_idP,
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = cc[CC_idP].physCellId;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6) | (ra->msg2_narrowband<<5);
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV(6, 0, 6) | (ra->msg2_narrowband<<5);
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = 0; // adjust according to size of RAR, 208 bits with N1A_PRB=3
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0; // fix to 4 for now
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = 0;
@@ -388,7 +364,6 @@ void generate_Msg2(module_id_t module_idP,
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
-
ra->msg2_mpdcch_repetition_cnt++;
dl_req_body->number_pdu++;
ra->Msg2_subframe = (ra->Msg2_subframe + 9) % 10;
@@ -396,7 +371,7 @@ void generate_Msg2(module_id_t module_idP,
if (ra->msg2_mpdcch_repetition_cnt > 0) { // we're in a stream of repetitions
if ((ra->msg2_mpdcch_repetition_cnt == reps) && (ra->msg2_mpdcch_done == 0)) { // this is the last mpdcch repetition
- ra->msg2_mpdcch_done = 1;
+ ra->msg2_mpdcch_done = 1;
if (cc[CC_idP].tdd_Config == NULL) { // FDD case
// wait 2 subframes for PDSCH transmission
@@ -404,38 +379,34 @@ void generate_Msg2(module_id_t module_idP,
ra->Msg2_frame = (frameP + 1) & 1023;
else
ra->Msg2_frame = frameP;
+
ra->Msg2_subframe = (subframeP + 2) % 10; // +2 is the "n+x" from Section 7.1.11 in 36.213
-
- LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, programmed Msg2 for %d.%d\n",
- module_idP,
- frameP,
- subframeP,
+ LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, programmed Msg2 for %d.%d\n",
+ module_idP,
+ frameP,
+ subframeP,
ra->Msg2_frame,
- ra->Msg2_subframe);
+ ra->Msg2_subframe);
} else {
AssertFatal(1 == 0, "TDD case not done yet\n");
}
} else if (ra->msg2_mpdcch_done == 0) { // mpdcch_repetition_count != reps
- LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n",
- module_idP,
- frameP,
- subframeP,
- ra->msg2_mpdcch_repetition_cnt);
-
+ LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, MPDCCH repetition %d\n",
+ module_idP,
+ frameP,
+ subframeP,
+ ra->msg2_mpdcch_repetition_cnt);
ra->msg2_mpdcch_repetition_cnt++;
}
if((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) {
/* Program PDSCH */
- LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n",
- module_idP,
- frameP,
+ LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming PDSCH\n",
+ module_idP,
+ frameP,
subframeP);
-
dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
-
memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
-
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu));
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP];
@@ -460,31 +431,24 @@ void generate_Msg2(module_id_t module_idP,
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
// dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ;
-
/* Rel10 fields */
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-
/* Rel13 fields */
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
dl_req_body->number_pdu++;
-
- fill_rar_br(mac, CC_idP, ra, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, ra->rach_resource_type - 1);
-
+ fill_rar_br(mac, CC_idP, ra, frameP, subframeP, cc[CC_idP].RAR_pdu.payload, ra->rach_resource_type - 1);
/* Program UL processing for Msg3, same as regular LTE */
get_Msg3alloc (&cc[CC_idP], subframeP, frameP, &ra->Msg3_frame, &ra->Msg3_subframe);
add_msg3 (module_idP, CC_idP, ra, frameP, subframeP);
-
- ra->state = WAITMSG3;
-
+ ra->state = WAITMSG3;
/* DL request */
- LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming TX Req\n",
- module_idP,
- frameP,
+ LOG_D(MAC, "[eNB %d][RAPROC] Frame %d, Subframe %d : In generate_Msg2, Programming TX Req\n",
+ module_idP,
+ frameP,
subframeP);
-
mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
TX_req = &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
@@ -496,115 +460,104 @@ void generate_Msg2(module_id_t module_idP,
}
}
} else
-
#endif
- {
+ {
+ if ((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) {
+ LOG_D(MAC,
+ "[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, state %d\n",
+ module_idP, CC_idP, frameP, subframeP, ra->state);
+ // Allocate 4 PRBS starting in RB 0
+ first_rb = 0;
+ vrb_map[first_rb] = 1;
+ vrb_map[first_rb + 1] = 1;
+ vrb_map[first_rb + 2] = 1;
+ vrb_map[first_rb + 3] = 1;
+ memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+ dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
+ dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu));
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = ra->RA_rnti;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : see Table 4-10 from SCF082 - nFAPI specifications
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0;
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4);
- if ((ra->Msg2_frame == frameP) && (ra->Msg2_subframe == subframeP)) {
- LOG_D(MAC,
- "[eNB %d] CC_id %d Frame %d, subframeP %d: Generating RAR DCI, state %d\n",
- module_idP, CC_idP, frameP, subframeP, ra->state);
+ // This checks if the above DCI allocation is feasible in current subframe
+ if (!CCE_allocation_infeasible(module_idP, CC_idP, 0, subframeP,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->RA_rnti)) {
+ LOG_D(MAC,
+ "Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n",
+ frameP, subframeP, ra->RA_rnti);
+ dl_req_body->number_dci++;
+ dl_req_body->number_pdu++;
+ dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
+ memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
+ dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
+ dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP];
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4);
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
+ // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
+ dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
+ // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ;
+ dl_req_body->number_pdu++;
+ mac->DL_req[CC_idP].sfn_sf = frameP<<4 | subframeP;
+ // Program UL processing for Msg3
+ get_Msg3alloc(&cc[CC_idP], subframeP, frameP,&ra->Msg3_frame, &ra->Msg3_subframe);
+ LOG_D(MAC,
+ "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n",
+ frameP, subframeP, ra->Msg3_frame,
+ ra->Msg3_subframe);
+ fill_rar(module_idP, CC_idP, ra, frameP, cc[CC_idP].RAR_pdu.payload, N_RB_DL, 7);
+ add_msg3(module_idP, CC_idP, ra, frameP, subframeP);
+ ra->state = WAITMSG3;
+ LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP);
+ T(T_ENB_MAC_UE_DL_RAR_PDU_WITH_DATA, T_INT(module_idP),
+ T_INT(CC_idP), T_INT(ra->RA_rnti), T_INT(frameP),
+ T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ),
+ T_BUFFER(cc[CC_idP].RAR_pdu.payload, 7));
+ // DL request
+ mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
+ TX_req =
+ &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
+ TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
+ TX_req->pdu_index = mac->pdu_index[CC_idP]++;
+ TX_req->num_segments = 1;
+ TX_req->segments[0].segment_length = 7;
+ TX_req->segments[0].segment_data =
+ cc[CC_idP].RAR_pdu.payload;
+ mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
- // Allocate 4 PRBS starting in RB 0
- first_rb = 0;
- vrb_map[first_rb] = 1;
- vrb_map[first_rb + 1] = 1;
- vrb_map[first_rb + 2] = 1;
- vrb_map[first_rb + 3] = 1;
-
- memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
- dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
- dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu));
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1A;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = ra->RA_rnti;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 2; // RA-RNTI : see Table 4-10 from SCF082 - nFAPI specifications
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power
-
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = 0;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = 1; // no TPC
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = 0;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0;
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0;
-
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4);
-
- // This checks if the above DCI allocation is feasible in current subframe
- if (!CCE_allocation_infeasible(module_idP, CC_idP, 0, subframeP,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->RA_rnti)) {
- LOG_D(MAC,
- "Frame %d: Subframe %d : Adding common DCI for RA_RNTI %x\n",
- frameP, subframeP, ra->RA_rnti);
- dl_req_body->number_dci++;
- dl_req_body->number_pdu++;
-
- dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
- memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
- dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
- dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_idP];
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti = ra->RA_rnti;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(N_RB_DL, first_rb, 4);
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.redundancy_version = 0;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_blocks = 1; // first block
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transport_block_to_codeword_swap_flag = 0;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_scheme = (cc->p_eNB == 1) ? 0 : 1;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_layers = 1;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.number_of_subbands = 1;
- // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.codebook_index = ;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ue_category_capacity = 1;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pa = 4; // 0 dB
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.delta_power_offset_index = 0;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.ngap = 0;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.nprb = get_subbandsize(cc->mib->message.dl_Bandwidth); // ignored
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = (cc->p_eNB == 1) ? 1 : 2;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
- dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
- // dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ;
- dl_req_body->number_pdu++;
- mac->DL_req[CC_idP].sfn_sf = frameP<<4 | subframeP;
-
- // Program UL processing for Msg3
- get_Msg3alloc(&cc[CC_idP], subframeP, frameP,&ra->Msg3_frame, &ra->Msg3_subframe);
-
- LOG_D(MAC,
- "Frame %d, Subframe %d: Setting Msg3 reception for Frame %d Subframe %d\n",
- frameP, subframeP, ra->Msg3_frame,
- ra->Msg3_subframe);
-
- fill_rar(module_idP, CC_idP, ra, frameP, cc[CC_idP].RAR_pdu.payload, N_RB_DL, 7);
- add_msg3(module_idP, CC_idP, ra, frameP, subframeP);
- ra->state = WAITMSG3;
- LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG3\n", module_idP, frameP, subframeP);
-
- T(T_ENB_MAC_UE_DL_RAR_PDU_WITH_DATA, T_INT(module_idP),
- T_INT(CC_idP), T_INT(ra->RA_rnti), T_INT(frameP),
- T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ),
- T_BUFFER(cc[CC_idP].RAR_pdu.payload, 7));
-
- // DL request
- mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
- TX_req =
- &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
- TX_req->pdu_length = 7; // This should be changed if we have more than 1 preamble
- TX_req->pdu_index = mac->pdu_index[CC_idP]++;
- TX_req->num_segments = 1;
- TX_req->segments[0].segment_length = 7;
- TX_req->segments[0].segment_data =
- cc[CC_idP].RAR_pdu.payload;
- mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
- if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){
- set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti);
- }
- } // PDCCH CCE allocation is feasible
- } // Msg2 frame/subframe condition
- } // else BL/CE
+ if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) {
+ set_dl_ue_select_msg2(CC_idP, 4, -1, ra->rnti);
+ }
+ } // PDCCH CCE allocation is feasible
+ } // Msg2 frame/subframe condition
+ } // else BL/CE
}
//------------------------------------------------------------------------------
@@ -612,17 +565,16 @@ void generate_Msg2(module_id_t module_idP,
* Generate message 4 of RA procedure (RRC connection setup)
*/
void
-generate_Msg4(module_id_t module_idP,
- int CC_idP,
+generate_Msg4(module_id_t module_idP,
+ int CC_idP,
frame_t frameP,
- sub_frame_t subframeP,
- RA_t * ra)
+ sub_frame_t subframeP,
+ RA_t *ra)
//------------------------------------------------------------------------------
{
eNB_MAC_INST *mac = RC.mac[module_idP];
COMMON_channels_t *cc = mac->common_channels;
UE_list_t *UE_list = &(mac->UE_list);
-
int16_t rrc_sdu_length = 0;
uint16_t msg4_padding = 0;
uint16_t msg4_post_padding = 0;
@@ -633,22 +585,17 @@ generate_Msg4(module_id_t module_idP,
uint8_t lcid = 0;
uint8_t offset = 0;
uint8_t *vrb_map = NULL;
-
nfapi_dl_config_request_pdu_t *dl_config_pdu = NULL;
nfapi_ul_config_request_pdu_t *ul_config_pdu = NULL;
nfapi_tx_request_pdu_t *TX_req = NULL;
-
nfapi_dl_config_request_t *dl_req = NULL;
nfapi_dl_config_request_body_t *dl_req_body = NULL;
nfapi_ul_config_request_body_t *ul_req_body = NULL;
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
int rmax = 0;
int rep = 0;
int reps = 0;
-
first_rb = 0;
-
struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL;
struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch = NULL;
LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL;
@@ -658,90 +605,80 @@ generate_Msg4(module_id_t module_idP,
int n1pucchan[4] = { 0, 0, 0, 0 };
if (cc[CC_idP].mib->message.schedulingInfoSIB1_BR_r13 > 0 && cc[CC_idP].radioResourceConfigCommon_BR) {
-
ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
-
ext4_pucch = cc[CC_idP].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310;
pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13;
-
AssertFatal (prach_ParametersListCE_r13 != NULL, "prach_ParametersListCE_r13 is null\n");
AssertFatal (pucch_N1PUCCH_AN_InfoList_r13 != NULL, "pucch_N1PUCCH_AN_InfoList_r13 is null\n");
-
/* Check to verify CE-Level compatibility in SIB2_BR */
AssertFatal (prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n");
switch (prach_ParametersListCE_r13->list.count) {
- case 4:
- p[3] = prach_ParametersListCE_r13->list.array[3];
- n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
+ case 4:
+ p[3] = prach_ParametersListCE_r13->list.array[3];
+ n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n");
- pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
+ pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
- case 3:
- p[2] = prach_ParametersListCE_r13->list.array[2];
- n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
+ case 3:
+ p[2] = prach_ParametersListCE_r13->list.array[2];
+ n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n");
- pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
- case 2:
- p[1] = prach_ParametersListCE_r13->list.array[1];
- n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
+ pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
+
+ case 2:
+ p[1] = prach_ParametersListCE_r13->list.array[1];
+ n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n");
- pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
- case 1:
- p[0] = prach_ParametersListCE_r13->list.array[0];
- n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
+ pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
+
+ case 1:
+ p[0] = prach_ParametersListCE_r13->list.array[0];
+ n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
AssertFatal(ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n");
- pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
- break;
- default:
+ pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
+ break;
+
+ default:
AssertFatal(1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count);
}
}
#endif
+ vrb_map = cc[CC_idP].vrb_map;
+ dl_req = &mac->DL_req[CC_idP];
+ dl_req_body = &dl_req->dl_config_request_body;
+ dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
+ N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
+ UE_id = find_UE_id(module_idP, ra->rnti);
- vrb_map = cc[CC_idP].vrb_map;
+ if (UE_id < 0) {
+ LOG_E(MAC, "Can't find UE for t-crnti %x, kill RA procedure for this UE\n",
+ ra->rnti);
+ cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
+ return;
+ }
- dl_req = &mac->DL_req[CC_idP];
- dl_req_body = &dl_req->dl_config_request_body;
- dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
-
- N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
-
- UE_id = find_UE_id(module_idP, ra->rnti);
-
- if (UE_id < 0) {
- LOG_E(MAC, "Can't find UE for t-crnti %x, kill RA procedure for this UE\n",
- ra->rnti);
-
- cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
- return;
- }
-
- // set HARQ process round to 0 for this UE
-
- ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP);
-
- /* // Get RRCConnectionSetup for Piggyback
- rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block
- &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case
- if(rrc_sdu_length <= 0) {
- LOG_D(MAC,"[MAC][eNB Scheduler] CCCH not allocated (%d)\n",rrc_sdu_length);
- return;
- }
- //AssertFatal(rrc_sdu_length > 0,
- //"[MAC][eNB Scheduler] CCCH not allocated\n");
-
-
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n",
- module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);*/
+ // set HARQ process round to 0 for this UE
+ ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP);
+ /* // Get RRCConnectionSetup for Piggyback
+ rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block
+ &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case
+ if(rrc_sdu_length <= 0) {
+ LOG_D(MAC,"[MAC][eNB Scheduler] CCCH not allocated (%d)\n",rrc_sdu_length);
+ return;
+ }
+ //AssertFatal(rrc_sdu_length > 0,
+ //"[MAC][eNB Scheduler] CCCH not allocated\n");
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n",
+ module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);*/
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- if (ra->rach_resource_type > 0) {
+ if (ra->rach_resource_type > 0) {
ra->harq_pid = 0;
// Generate DCI + repetitions first
// This uses an MPDCCH Type 2 allocation according to Section 9.1.5 36-213, Type2 common allocation according to Table 7.1-8 (36-213)
@@ -751,11 +688,8 @@ generate_Msg4(module_id_t module_idP,
// if CELevel = 0,1 => Table 9.1.5-1b for MPDCCH candidates
// if CELevel = 2,3 => Table 9.1.5-2b for MPDCCH candidates
// distributed transmission
-
// rmax from SIB2 information
rmax = 1<rach_resource_type - 1]->mpdcch_NumRepetition_RA_r13;
-
-
// choose r3 by default for Msg4 (this is ok from table 9.1.5-3 for rmax = >=4, if we choose rmax <4 it has to be less
rep = 0;
// get actual repetition count from Table 9.1.5-3
@@ -766,14 +700,11 @@ generate_Msg4(module_id_t module_idP,
if ((ra->msg4_mpdcch_repetition_cnt == 0) && (mpdcch_sf_condition (mac, CC_idP, frameP, subframeP, rmax, TYPE2, -1) > 0)) {
// Get RRCConnectionSetup for Piggyback
ra->msg4_rrc_sdu_length = mac_rrc_data_req (module_idP, CC_idP, frameP, CCCH,
- UE_RNTI(module_idP, UE_id), 1, // 1 transport block
- &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case
-
+ UE_RNTI(module_idP, UE_id), 1, // 1 transport block
+ &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case
AssertFatal (ra->msg4_rrc_sdu_length > 0, "[MAC][eNB Scheduler] CCCH not allocated\n");
-
-
- LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d, dl_req->num_pdu %d\n", module_idP, CC_idP, frameP, subframeP, UE_id, ra->msg4_rrc_sdu_length,dl_req_body->number_pdu);
-
+ LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d, dl_req->num_pdu %d\n", module_idP, CC_idP, frameP, subframeP, UE_id, ra->msg4_rrc_sdu_length,
+ dl_req_body->number_pdu);
// MPDCCH configuration for Msg4
ra->msg4_mpdcch_done=0;
memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
@@ -821,44 +752,41 @@ generate_Msg4(module_id_t module_idP,
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
-
ra->msg4_mpdcch_repetition_cnt++;
dl_req_body->number_pdu++;
ra->msg4_TBsize = get_TBS_DL(dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs,
- 6);
+ 6);
} //repetition_count==0 && SF condition met
if ((ra->msg4_mpdcch_repetition_cnt > 0)&&
- (ra->msg4_mpdcch_done==0)) { // we're in a stream of repetitions
+ (ra->msg4_mpdcch_done==0)) { // we're in a stream of repetitions
LOG_D(MAC,"SFN.SF %d.%d : msg4 mpdcch repetition number %d/%d\n",
- frameP,subframeP,ra->msg4_mpdcch_repetition_cnt,reps);
+ frameP,subframeP,ra->msg4_mpdcch_repetition_cnt,reps);
+
if (ra->msg4_mpdcch_repetition_cnt == reps) { // this is the last mpdcch repetition
ra->msg4_mpdcch_done = 1;
- if (cc[CC_idP].tdd_Config == NULL) { // FDD case
+
+ if (cc[CC_idP].tdd_Config == NULL) { // FDD case
// wait 2 subframes for PDSCH transmission
if (subframeP > 7)
ra->Msg4_frame = (frameP + 1) & 1023;
else
ra->Msg4_frame = frameP;
+
ra->Msg4_subframe = (subframeP + 2) % 10;
- LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Set Msg4 PDSCH in %d.%d\n",
- module_idP, CC_idP, frameP, subframeP, ra->Msg4_frame,ra->Msg4_subframe);
+ LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Set Msg4 PDSCH in %d.%d\n",
+ module_idP, CC_idP, frameP, subframeP, ra->Msg4_frame,ra->Msg4_subframe);
} else {
AssertFatal (1 == 0, "TDD case not done yet\n");
}
- }
- else if (ra->msg4_mpdcch_done==0)
- ra->msg4_mpdcch_repetition_cnt++;
+ } else if (ra->msg4_mpdcch_done==0)
+ ra->msg4_mpdcch_repetition_cnt++;
}
-// mpdcch_repetition_count == reps
+ // mpdcch_repetition_count == reps
else if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) {
-
// Program PDSCH
-
LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 BR with RRC Piggyback (ce_level %d RNTI %x)\n",
- module_idP, CC_idP, frameP, subframeP, ra->rach_resource_type - 1, ra->rnti);
-
-
+ module_idP, CC_idP, frameP, subframeP, ra->rach_resource_type - 1, ra->rnti);
dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
@@ -885,47 +813,40 @@ generate_Msg4(module_id_t module_idP,
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = 1;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = 1;
// dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.bf_vector = ;
-
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel10.pdsch_start = cc[CC_idP].sib1_v13ext->bandwidthReducedAccessRelatedInfo_r13->startSymbolBR_r13;
-
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.ue_type = (ra->rach_resource_type < 3) ? 1 : 2;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.pdsch_payload_type = 2; // not SI message
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
dl_req_body->number_pdu++;
-
-
ra->state = WAITMSG4ACK;
-
lcid = 0;
-
UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0;
msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header
AssertFatal((ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header)>=0,
- "msg4_TBS %d is too small, change mcs to increase by %d bytes\n",ra->msg4_TBsize,ra->msg4_rrc_sdu_length+msg4_header-ra->msg4_TBsize);
+ "msg4_TBS %d is too small, change mcs to increase by %d bytes\n",ra->msg4_TBsize,ra->msg4_rrc_sdu_length+msg4_header-ra->msg4_TBsize);
+
if ((ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header) <= 2) {
- msg4_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header;
- msg4_post_padding = 0;
+ msg4_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header;
+ msg4_post_padding = 0;
} else {
- msg4_padding = 0;
- msg4_post_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header - 1;
+ msg4_padding = 0;
+ msg4_post_padding = ra->msg4_TBsize - ra->msg4_rrc_sdu_length - msg4_header - 1;
}
LOG_D (MAC, "[eNB %d][RAPROC] CC_id %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n",
- module_idP, CC_idP, frameP, subframeP, ra->msg4_TBsize, ra->msg4_rrc_sdu_length, msg4_header, msg4_padding, msg4_post_padding);
+ module_idP, CC_idP, frameP, subframeP, ra->msg4_TBsize, ra->msg4_rrc_sdu_length, msg4_header, msg4_padding, msg4_post_padding);
DevAssert (UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return
// CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0]
offset = generate_dlsch_header ((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], 1, //num_sdus
- (unsigned short *) &ra->msg4_rrc_sdu_length, //
- &lcid, // sdu_lcid
- 255, // no drx
- 31, // no timing advance
- ra->cont_res_id, // contention res id
- msg4_padding, // no padding
- msg4_post_padding);
-
+ (unsigned short *) &ra->msg4_rrc_sdu_length, //
+ &lcid, // sdu_lcid
+ 255, // no drx
+ 31, // no timing advance
+ ra->cont_res_id, // contention res id
+ msg4_padding, // no padding
+ msg4_post_padding);
memcpy ((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0][(unsigned char) offset], &cc[CC_idP].CCCH_pdu.payload[0], ra->msg4_rrc_sdu_length);
-
// DL request
mac->TX_req[CC_idP].sfn_sf = (frameP << 4) + subframeP;
TX_req = &mac->TX_req[CC_idP].tx_request_body.tx_pdu_list[mac->TX_req[CC_idP].tx_request_body.number_of_pdus];
@@ -935,7 +856,6 @@ generate_Msg4(module_id_t module_idP,
TX_req->segments[0].segment_length = ra->msg4_TBsize;
TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0];
mac->TX_req[CC_idP].tx_request_body.number_of_pdus++;
-
// Program ACK/NAK for Msg4 PDSCH
int absSF = (frameP * 10) + subframeP;
// see Section 10.2 from 36.213
@@ -943,7 +863,6 @@ generate_Msg4(module_id_t module_idP,
AssertFatal (reps == 1, "Have to handle programming of ACK when PDSCH repetitions is > 1\n");
ul_req_body = &mac->UL_req_tmp[CC_idP][ackNAK_absSF % 10].ul_config_request_body;
ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
-
ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_uci_harq_pdu));
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this
@@ -952,671 +871,614 @@ generate_Msg4(module_id_t module_idP,
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.empty_symbols = 0;
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.total_number_of_repetitions = pucchreps[ra->rach_resource_type - 1];
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0;
+
// Note need to keep sending this across reptitions!!!! Not really for PUCCH, to ask small-cell forum, we'll see for the other messages, maybe parameters change across repetitions and FAPI has to provide for that
if (cc[CC_idP].tdd_Config == NULL) { // FDD case
- ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[ra->rach_resource_type - 1];
- // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
- // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
- // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
- // Delta_ARO = 0 from Table 10.1.2.1-1
- ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK
- ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1;
+ ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[ra->rach_resource_type - 1];
+ // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
+ // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
+ // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
+ // Delta_ARO = 0 from Table 10.1.2.1-1
+ ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK
+ ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1;
} else {
- AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
+ AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
}
+
ul_req_body->number_of_pdus++;
T (T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT (module_idP), T_INT (CC_idP), T_INT (ra->rnti), T_INT (frameP), T_INT (subframeP),
- T_INT (0 /*harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], ra->msg4_TBsize));
+ T_INT (0 /*harq_pid always 0? */ ), T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].payload[0], ra->msg4_TBsize));
if (opt_enabled == 1) {
- trace_pdu (1, (uint8_t *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], ra->msg4_rrc_sdu_length, UE_id, 3, UE_RNTI (module_idP, UE_id), mac->frame, mac->subframe, 0, 0);
- LOG_D (OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_idP, frameP, UE_RNTI (module_idP, UE_id), ra->msg4_rrc_sdu_length);
+ trace_pdu (1, (uint8_t *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0], ra->msg4_rrc_sdu_length, UE_id, 3, UE_RNTI (module_idP, UE_id), mac->frame, mac->subframe, 0, 0);
+ LOG_D (OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n", module_idP, CC_idP, frameP, UE_RNTI (module_idP, UE_id), ra->msg4_rrc_sdu_length);
}
} // Msg4 frame/subframe
} // rach_resource_type > 0
else
#endif
- {
+ {
// This is normal LTE case
- LOG_I(MAC, "generate_Msg4 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP);
- if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) {
+ LOG_I(MAC, "generate_Msg4 ra->Msg4_frame SFN/SF: %d.%d, frameP SFN/SF: %d.%d FOR eNB_Mod: %d \n", ra->Msg4_frame, ra->Msg4_subframe, frameP, subframeP, module_idP);
- // Get RRCConnectionSetup for Piggyback
- /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block
- &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/
+ if ((ra->Msg4_frame == frameP) && (ra->Msg4_subframe == subframeP)) {
+ // Get RRCConnectionSetup for Piggyback
+ /*rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH, 1, // 1 transport block
+ &cc[CC_idP].CCCH_pdu.payload[0], ENB_FLAG_YES, module_idP, 0); // not used in this case*/
+ // check if there's data on the CCCH to send with Msg4
+ rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH,
+ UE_RNTI(module_idP,UE_id),1, // 1 transport block
+ &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case
- // check if there's data on the CCCH to send with Msg4
- rrc_sdu_length = mac_rrc_data_req(module_idP, CC_idP, frameP, CCCH,
- UE_RNTI(module_idP,UE_id),1, // 1 transport block
- &cc[CC_idP].CCCH_pdu.payload[0], 0); // not used in this case
+ if (rrc_sdu_length > 0) {
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n",
+ module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);
+ // AssertFatal(rrc_sdu_length > 0,
+ // "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length);
+ LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n",
+ module_idP, CC_idP, frameP, subframeP, ra->rnti);
+ /// Choose first 4 RBs for Msg4, should really check that these are free!
+ first_rb = 0;
+ vrb_map[first_rb] = 1;
+ vrb_map[first_rb + 1] = 1;
+ vrb_map[first_rb + 2] = 1;
+ vrb_map[first_rb + 3] = 1;
+ // Compute MCS/TBS for 3 PRB (coded on 4 vrb)
+ msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header
- if (rrc_sdu_length > 0) {
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: UE_id %d, rrc_sdu_length %d\n",
- module_idP, CC_idP, frameP, subframeP, UE_id, rrc_sdu_length);
-
- // AssertFatal(rrc_sdu_length > 0,
- // "[MAC][eNB Scheduler] CCCH not allocated, rrc_sdu_length: %d\n", rrc_sdu_length);
-
-
-
- LOG_I(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RNTI %x)\n",
- module_idP, CC_idP, frameP, subframeP, ra->rnti);
-
- /// Choose first 4 RBs for Msg4, should really check that these are free!
- first_rb = 0;
-
- vrb_map[first_rb] = 1;
- vrb_map[first_rb + 1] = 1;
- vrb_map[first_rb + 2] = 1;
- vrb_map[first_rb + 3] = 1;
-
-
- // Compute MCS/TBS for 3 PRB (coded on 4 vrb)
- msg4_header = 1 + 6 + 1; // CR header, CR CE, SDU header
-
- if ((rrc_sdu_length + msg4_header) <= 22) {
- ra->msg4_mcs = 4;
- ra->msg4_TBsize = 22;
- } else if ((rrc_sdu_length + msg4_header) <= 28) {
- ra->msg4_mcs = 5;
- ra->msg4_TBsize = 28;
- } else if ((rrc_sdu_length + msg4_header) <= 32) {
- ra->msg4_mcs = 6;
- ra->msg4_TBsize = 32;
- } else if ((rrc_sdu_length + msg4_header) <= 41) {
- ra->msg4_mcs = 7;
- ra->msg4_TBsize = 41;
- } else if ((rrc_sdu_length + msg4_header) <= 49) {
- ra->msg4_mcs = 8;
- ra->msg4_TBsize = 49;
- } else if ((rrc_sdu_length + msg4_header) <= 57) {
- ra->msg4_mcs = 9;
- ra->msg4_TBsize = 57;
- }
-
- fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level
- ra->rnti, // rnti
- 1, // rnti_type, CRNTI
- ra->harq_pid, // harq_process
- 1, // tpc, none
- getRIV(N_RB_DL, first_rb, 4), // resource_block_coding
- ra->msg4_mcs, // mcs
- 1, // ndi
- 0, // rv
- 0); // vrb_flag
-
- LOG_D(MAC,
- "Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n",
- frameP, subframeP, dl_req_body->number_pdu,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process,
- &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding);
- AssertFatal(dl_config_pdu->dci_dl_pdu.
- dci_dl_pdu_rel8.resource_block_coding < 8192,
- "resource_block_coding %u < 8192\n",
- dl_config_pdu->dci_dl_pdu.
- dci_dl_pdu_rel8.resource_block_coding);
- if (!CCE_allocation_infeasible(module_idP, CC_idP, 1, subframeP,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->rnti)) {
- dl_req_body->number_dci++;
- dl_req_body->number_pdu++;
+ if ((rrc_sdu_length + msg4_header) <= 22) {
+ ra->msg4_mcs = 4;
+ ra->msg4_TBsize = 22;
+ } else if ((rrc_sdu_length + msg4_header) <= 28) {
+ ra->msg4_mcs = 5;
+ ra->msg4_TBsize = 28;
+ } else if ((rrc_sdu_length + msg4_header) <= 32) {
+ ra->msg4_mcs = 6;
+ ra->msg4_TBsize = 32;
+ } else if ((rrc_sdu_length + msg4_header) <= 41) {
+ ra->msg4_mcs = 7;
+ ra->msg4_TBsize = 41;
+ } else if ((rrc_sdu_length + msg4_header) <= 49) {
+ ra->msg4_mcs = 8;
+ ra->msg4_TBsize = 49;
+ } else if ((rrc_sdu_length + msg4_header) <= 57) {
+ ra->msg4_mcs = 9;
+ ra->msg4_TBsize = 57;
+ }
- ra->state = WAITMSG4ACK;
- LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP);
+ fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level
+ ra->rnti, // rnti
+ 1, // rnti_type, CRNTI
+ ra->harq_pid, // harq_process
+ 1, // tpc, none
+ getRIV(N_RB_DL, first_rb, 4), // resource_block_coding
+ ra->msg4_mcs, // mcs
+ 1, // ndi
+ 0, // rv
+ 0); // vrb_flag
+ LOG_D(MAC,
+ "Frame %d, subframe %d: Msg4 DCI pdu_num %d (rnti %x,rnti_type %d,harq_pid %d, resource_block_coding (%p) %d\n",
+ frameP, subframeP, dl_req_body->number_pdu,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process,
+ &dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding);
+ AssertFatal(dl_config_pdu->dci_dl_pdu.
+ dci_dl_pdu_rel8.resource_block_coding < 8192,
+ "resource_block_coding %u < 8192\n",
+ dl_config_pdu->dci_dl_pdu.
+ dci_dl_pdu_rel8.resource_block_coding);
- // increment Absolute subframe by 8 for Msg4 retransmission
- LOG_D(MAC,
- "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n",
- frameP, subframeP, ra->Msg4_frame,
- ra->Msg4_subframe);
- get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe);
+ if (!CCE_allocation_infeasible(module_idP, CC_idP, 1, subframeP,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level, ra->rnti)) {
+ dl_req_body->number_dci++;
+ dl_req_body->number_pdu++;
+ ra->state = WAITMSG4ACK;
+ LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:WAITMSG4ACK\n", module_idP, frameP, subframeP);
+ // increment Absolute subframe by 8 for Msg4 retransmission
+ LOG_D(MAC,
+ "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n",
+ frameP, subframeP, ra->Msg4_frame,
+ ra->Msg4_subframe);
+ get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe);
+ LOG_D(MAC,
+ "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n",
+ frameP, subframeP, ra->Msg4_frame,
+ ra->Msg4_subframe);
+ lcid = 0;
+ // put HARQ process round to 0
+ ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP,subframeP);
+ UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0;
- LOG_D(MAC,
- "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n",
- frameP, subframeP, ra->Msg4_frame,
- ra->Msg4_subframe);
- lcid = 0;
+ if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) {
+ msg4_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header;
+ msg4_post_padding = 0;
+ } else {
+ msg4_padding = 0;
+ msg4_post_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1;
+ }
- // put HARQ process round to 0
- ra->harq_pid = frame_subframe2_dl_harq_pid(cc->tdd_Config,frameP ,subframeP);
- UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid] = 0;
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_idP %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n",
+ module_idP, CC_idP, frameP, subframeP,
+ ra->msg4_TBsize, rrc_sdu_length, msg4_header,
+ msg4_padding, msg4_post_padding);
+ DevAssert(UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return
+ // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0]
+ int num_sdus = rrc_sdu_length > 0 ? 1 : 0;
+ offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0],
+ num_sdus, //num_sdus
+ (unsigned short *) &rrc_sdu_length, //
+ &lcid, // sdu_lcid
+ 255, // no drx
+ 31, // no timing advance
+ ra->cont_res_id, // contention res id
+ msg4_padding, // no padding
+ msg4_post_padding);
+ memcpy((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset],
+ &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length);
+ // DLSCH Config
+ fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, mac->pdu_index[CC_idP], ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D
+ 0, // virtual_resource_block_assignment_flag : localized
+ getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB
+ 2, // modulation: QPSK
+ 0, // redundancy version
+ 1, // transport_blocks
+ 0, // transport_block_to_codeword_swap_flag (0)
+ (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme
+ 1, // number of layers
+ 1, // number of subbands
+ //0, // codebook index
+ 1, // ue_category_capacity
+ 4, // pa: 0 dB
+ 0, // delta_power_offset_index
+ 0, // ngap
+ 1, // NPRB = 3 like in DCI
+ (cc->p_eNB == 1) ? 1 : 2, // transmission mode
+ 1, // num_bf_prb_per_subband
+ 1); // num_bf_vector
+ LOG_D(MAC,
+ "Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",
+ dl_req_body->number_pdu, mac->pdu_index[CC_idP]);
+ // Tx request
+ mac->TX_req[CC_idP].sfn_sf =
+ fill_nfapi_tx_req(&mac->TX_req[CC_idP].tx_request_body,
+ (frameP * 10) + subframeP,
+ rrc_sdu_length,
+ mac->pdu_index[CC_idP],
+ mac->UE_list.
+ DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0]);
+ mac->pdu_index[CC_idP]++;
+ dl_req->sfn_sf = mac->TX_req[CC_idP].sfn_sf;
+ LOG_D(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n",
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx);
+ // Program PUCCH1a for ACK/NAK
+ // Program ACK/NAK for Msg4 PDSCH
+ fill_nfapi_uci_acknak(module_idP,
+ CC_idP,
+ ra->rnti,
+ (frameP * 10) + subframeP,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx);
+ T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP),
+ T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP),
+ T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ),
+ T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].
+ payload[0], ra->msg4_TBsize));
- if ((ra->msg4_TBsize - rrc_sdu_length - msg4_header) <= 2) {
- msg4_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header;
- msg4_post_padding = 0;
- } else {
- msg4_padding = 0;
- msg4_post_padding = ra->msg4_TBsize - rrc_sdu_length - msg4_header - 1;
- }
+ if (opt_enabled == 1) {
+ trace_pdu(DIRECTION_DOWNLINK,
+ (uint8_t *) mac->
+ UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0],
+ rrc_sdu_length, UE_id, WS_C_RNTI,
+ UE_RNTI(module_idP, UE_id), mac->frame,
+ mac->subframe, 0, 0);
+ LOG_D(OPT,
+ "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n",
+ module_idP, CC_idP, frameP, UE_RNTI(module_idP,
+ UE_id),
+ rrc_sdu_length);
+ }
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_idP %d Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n",
- module_idP, CC_idP, frameP, subframeP,
- ra->msg4_TBsize, rrc_sdu_length, msg4_header,
- msg4_padding, msg4_post_padding);
- DevAssert(UE_id != UE_INDEX_INVALID); // FIXME not sure how to gracefully return
- // CHECK THIS: &cc[CC_idP].CCCH_pdu.payload[0]
- int num_sdus = rrc_sdu_length > 0 ? 1 : 0;
- offset = generate_dlsch_header((unsigned char *) mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char) UE_id].payload[0],
- num_sdus, //num_sdus
- (unsigned short *) &rrc_sdu_length, //
- &lcid, // sdu_lcid
- 255, // no drx
- 31, // no timing advance
- ra->cont_res_id, // contention res id
- msg4_padding, // no padding
- msg4_post_padding);
+ if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) {
+ set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti);
+ }
+ } // CCE Allocation feasible
+ } else {
+ LOG_I(MAC,
+ "eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Delaying Msg4 for RRC Piggyback (RNTI %x)\n",
+ module_idP, CC_idP, frameP, subframeP, ra->rnti);
+ ra->Msg4_subframe ++;
+ ra->Msg4_delay_cnt++;
- memcpy((void *) &mac->UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0][(unsigned char)offset],
- &cc[CC_idP].CCCH_pdu.payload[0], rrc_sdu_length);
+ if (ra->Msg4_delay_cnt==10) cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
- // DLSCH Config
- fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize, mac->pdu_index[CC_idP], ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D
- 0, // virtual_resource_block_assignment_flag : localized
- getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB
- 2, // modulation: QPSK
- 0, // redundancy version
- 1, // transport_blocks
- 0, // transport_block_to_codeword_swap_flag (0)
- (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme
- 1, // number of layers
- 1, // number of subbands
- //0, // codebook index
- 1, // ue_category_capacity
- 4, // pa: 0 dB
- 0, // delta_power_offset_index
- 0, // ngap
- 1, // NPRB = 3 like in DCI
- (cc->p_eNB == 1) ? 1 : 2, // transmission mode
- 1, // num_bf_prb_per_subband
- 1); // num_bf_vector
- LOG_D(MAC,
- "Filled DLSCH config, pdu number %d, non-dci pdu_index %d\n",
- dl_req_body->number_pdu, mac->pdu_index[CC_idP]);
-
- // Tx request
- mac->TX_req[CC_idP].sfn_sf =
- fill_nfapi_tx_req(&mac->TX_req[CC_idP].tx_request_body,
- (frameP * 10) + subframeP,
- rrc_sdu_length,
- mac->pdu_index[CC_idP],
- mac->UE_list.
- DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0]);
- mac->pdu_index[CC_idP]++;
-
- dl_req->sfn_sf = mac->TX_req[CC_idP].sfn_sf;
-
- LOG_D(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n",
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx);
- // Program PUCCH1a for ACK/NAK
- // Program ACK/NAK for Msg4 PDSCH
- fill_nfapi_uci_acknak(module_idP,
- CC_idP,
- ra->rnti,
- (frameP * 10) + subframeP,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx);
-
-
- T(T_ENB_MAC_UE_DL_PDU_WITH_DATA, T_INT(module_idP),
- T_INT(CC_idP), T_INT(ra->rnti), T_INT(frameP),
- T_INT(subframeP), T_INT(0 /*harq_pid always 0? */ ),
- T_BUFFER(&mac->UE_list.DLSCH_pdu[CC_idP][0][UE_id].
- payload[0], ra->msg4_TBsize));
-
- if (opt_enabled == 1) {
- trace_pdu(DIRECTION_DOWNLINK,
- (uint8_t *) mac->
- UE_list.DLSCH_pdu[CC_idP][0][(unsigned char)UE_id].payload[0],
- rrc_sdu_length, UE_id, WS_C_RNTI,
- UE_RNTI(module_idP, UE_id), mac->frame,
- mac->subframe, 0, 0);
- LOG_D(OPT,
- "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n",
- module_idP, CC_idP, frameP, UE_RNTI(module_idP,
- UE_id),
- rrc_sdu_length);
- }
- if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){
- set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti);
- }
- } // CCE Allocation feasible
- }
- else {
- LOG_I(MAC,
- "eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Delaying Msg4 for RRC Piggyback (RNTI %x)\n",
- module_idP, CC_idP, frameP, subframeP, ra->rnti);
- ra->Msg4_subframe ++;
- ra->Msg4_delay_cnt++;
- if (ra->Msg4_delay_cnt==10) cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
-
- if (ra->Msg4_subframe == 10) {
- ra->Msg4_frame++;
- ra->Msg4_frame&=1023;
- ra->Msg4_subframe = 0;
- }
- }
- } // msg4 frame/subframe
- } // else rach_resource_type
+ if (ra->Msg4_subframe == 10) {
+ ra->Msg4_frame++;
+ ra->Msg4_frame&=1023;
+ ra->Msg4_subframe = 0;
+ }
+ }
+ } // msg4 frame/subframe
+ } // else rach_resource_type
}
void
check_Msg4_retransmission(module_id_t module_idP, int CC_idP,
- frame_t frameP, sub_frame_t subframeP, RA_t * ra)
-{
+ frame_t frameP, sub_frame_t subframeP, RA_t *ra) {
+ eNB_MAC_INST *mac = RC.mac[module_idP];
+ COMMON_channels_t *cc = mac->common_channels;
+ int UE_id = -1;
+ uint8_t *vrb_map;
+ int first_rb;
+ int N_RB_DL;
+ nfapi_dl_config_request_pdu_t *dl_config_pdu;
+ UE_list_t *UE_list = &mac->UE_list;
+ nfapi_dl_config_request_t *dl_req;
+ nfapi_dl_config_request_body_t *dl_req_body;
+ int round;
+ /*
+ #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+ COMMON_channels_t *cc = mac->common_channels;
- eNB_MAC_INST *mac = RC.mac[module_idP];
- COMMON_channels_t *cc = mac->common_channels;
- int UE_id = -1;
- uint8_t *vrb_map;
- int first_rb;
- int N_RB_DL;
- nfapi_dl_config_request_pdu_t *dl_config_pdu;
- UE_list_t *UE_list = &mac->UE_list;
- nfapi_dl_config_request_t *dl_req;
- nfapi_dl_config_request_body_t *dl_req_body;
+ int rmax = 0;
+ int rep = 0;
+ int reps = 0;
- int round;
- /*
- #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- COMMON_channels_t *cc = mac->common_channels;
+ first_rb = 0;
+ struct PRACH_ConfigSIB_v1310 *ext4_prach;
+ PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
+ PRACH_ParametersCE_r13_t *p[4];
- int rmax = 0;
- int rep = 0;
- int reps = 0;
+ if (cc[CC_idP].radioResourceConfigCommon_BR) {
- first_rb = 0;
- struct PRACH_ConfigSIB_v1310 *ext4_prach;
- PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13;
- PRACH_ParametersCE_r13_t *p[4];
+ ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
+ prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
- if (cc[CC_idP].radioResourceConfigCommon_BR) {
-
- ext4_prach = cc[CC_idP].radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
- prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
-
- switch (prach_ParametersListCE_r13->list.count) {
- case 4:
- p[3]=prach_ParametersListCE_r13->list.array[3];
- case 3:
- p[2]=prach_ParametersListCE_r13->list.array[2];
- case 2:
- p[1]=prach_ParametersListCE_r13->list.array[1];
- case 1:
- p[0]=prach_ParametersListCE_r13->list.array[0];
- default:
- AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count);
- }
- }
- #endif
- */
-
- // check HARQ status and retransmit if necessary
-
-
- UE_id = find_UE_id(module_idP, ra->rnti);
- AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n");
-
- round = UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid];
- vrb_map = cc[CC_idP].vrb_map;
-
- dl_req = &mac->DL_req[CC_idP];
- dl_req_body = &dl_req->dl_config_request_body;
- dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
- N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
-
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d), UE_id: %d \n",
- module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round, UE_id);
-
- if (round != 8) {
+ switch (prach_ParametersListCE_r13->list.count) {
+ case 4:
+ p[3]=prach_ParametersListCE_r13->list.array[3];
+ case 3:
+ p[2]=prach_ParametersListCE_r13->list.array[2];
+ case 2:
+ p[1]=prach_ParametersListCE_r13->list.array[1];
+ case 1:
+ p[0]=prach_ParametersListCE_r13->list.array[0];
+ default:
+ AssertFatal(1==0,"Illegal count for prach_ParametersListCE_r13 %d\n",prach_ParametersListCE_r13->list.count);
+ }
+ }
+ #endif
+ */
+ // check HARQ status and retransmit if necessary
+ UE_id = find_UE_id(module_idP, ra->rnti);
+ AssertFatal(UE_id >= 0, "Can't find UE for t-crnti\n");
+ round = UE_list->UE_sched_ctrl[UE_id].round[CC_idP][ra->harq_pid];
+ vrb_map = cc[CC_idP].vrb_map;
+ dl_req = &mac->DL_req[CC_idP];
+ dl_req_body = &dl_req->dl_config_request_body;
+ dl_config_pdu = &dl_req_body->dl_config_pdu_list[dl_req_body->number_pdu];
+ N_RB_DL = to_prb(cc[CC_idP].mib->message.dl_Bandwidth);
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Checking if Msg4 for harq_pid %d was acknowledged (round %d), UE_id: %d \n",
+ module_idP, CC_idP, frameP, subframeP, ra->harq_pid, round, UE_id);
+ if (round != 8) {
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- if (ra->rach_resource_type > 0 && round > 0) {
- AssertFatal(1 == 0,
- "Msg4 Retransmissions not handled yet for BL/CE UEs, Frame %d, subframeP %d harq_pid %d round %d, UE_id: %d \n",
- frameP, subframeP, ra->harq_pid, round, UE_id);
- } else
+
+ if (ra->rach_resource_type > 0 && round > 0) {
+ AssertFatal(1 == 0,
+ "Msg4 Retransmissions not handled yet for BL/CE UEs, Frame %d, subframeP %d harq_pid %d round %d, UE_id: %d \n",
+ frameP, subframeP, ra->harq_pid, round, UE_id);
+ } else
#endif
- {
- if ((ra->Msg4_frame == frameP)
- && (ra->Msg4_subframe == subframeP)) {
+ {
+ if ((ra->Msg4_frame == frameP)
+ && (ra->Msg4_subframe == subframeP)) {
+ //ra->wait_ack_Msg4++;
+ // we have to schedule a retransmission
+ dl_req->sfn_sf = frameP<<4 | subframeP;
+ first_rb = 0;
+ vrb_map[first_rb] = 1;
+ vrb_map[first_rb + 1] = 1;
+ vrb_map[first_rb + 2] = 1;
+ vrb_map[first_rb + 3] = 1;
+ fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level
+ ra->rnti, // rnti
+ 1, // rnti_type, CRNTI
+ ra->harq_pid, // harq_process
+ 1, // tpc, none
+ getRIV(N_RB_DL, first_rb, 4), // resource_block_coding
+ ra->msg4_mcs, // mcs
+ 1, // ndi
+ round & 3, // rv
+ 0); // vrb_flag
- //ra->wait_ack_Msg4++;
- // we have to schedule a retransmission
+ if (!CCE_allocation_infeasible
+ (module_idP, CC_idP, 1, subframeP,
+ dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.
+ aggregation_level, ra->rnti)) {
+ dl_req_body->number_dci++;
+ dl_req_body->number_pdu++;
+ dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
+ LOG_D(MAC,
+ "msg4 retransmission for rnti %x (round %d) fsf %d/%d\n",
+ ra->rnti, round, frameP, subframeP);
+ // DLSCH Config
+ //DJP - fix this pdu_index = -1
+ LOG_D(MAC, "check_Msg4_retransmission() before fill_nfapi_dlsch_config() with pdu_index = -1 \n");
+ fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize,
+ -1
+ /* retransmission, no pdu_index */
+ , ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D
+ 0, // virtual_resource_block_assignment_flag : localized
+ getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB
+ 2, // modulation: QPSK
+ round & 3, // redundancy version
+ 1, // transport_blocks
+ 0, // transport_block_to_codeword_swap_flag (0)
+ (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme
+ 1, // number of layers
+ 1, // number of subbands
+ //0, // codebook index
+ 1, // ue_category_capacity
+ 4, // pa: 0 dB
+ 0, // delta_power_offset_index
+ 0, // ngap
+ 1, // NPRB = 3 like in DCI
+ (cc->p_eNB == 1) ? 1 : 2, // transmission mode
+ 1, // num_bf_prb_per_subband
+ 1); // num_bf_vector
- dl_req->sfn_sf = frameP<<4 | subframeP;
+ if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR) {
+ set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti);
+ }
+ } else
+ LOG_D(MAC,
+ "msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n",
+ ra->rnti, round, frameP, subframeP);
- first_rb = 0;
- vrb_map[first_rb] = 1;
- vrb_map[first_rb + 1] = 1;
- vrb_map[first_rb + 2] = 1;
- vrb_map[first_rb + 3] = 1;
-
- fill_nfapi_dl_dci_1A(dl_config_pdu, 4, // aggregation_level
- ra->rnti, // rnti
- 1, // rnti_type, CRNTI
- ra->harq_pid, // harq_process
- 1, // tpc, none
- getRIV(N_RB_DL, first_rb, 4), // resource_block_coding
- ra->msg4_mcs, // mcs
- 1, // ndi
- round & 3, // rv
- 0); // vrb_flag
-
- if (!CCE_allocation_infeasible
- (module_idP, CC_idP, 1, subframeP,
- dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.
- aggregation_level, ra->rnti)) {
- dl_req_body->number_dci++;
- dl_req_body->number_pdu++;
- dl_req_body->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
-
- LOG_D(MAC,
- "msg4 retransmission for rnti %x (round %d) fsf %d/%d\n",
- ra->rnti, round, frameP, subframeP);
- // DLSCH Config
- //DJP - fix this pdu_index = -1
- LOG_D(MAC, "check_Msg4_retransmission() before fill_nfapi_dlsch_config() with pdu_index = -1 \n");
- fill_nfapi_dlsch_config(mac, dl_req_body, ra->msg4_TBsize,
- -1
- /* retransmission, no pdu_index */
- , ra->rnti, 2, // resource_allocation_type : format 1A/1B/1D
- 0, // virtual_resource_block_assignment_flag : localized
- getRIV(N_RB_DL, first_rb, 4), // resource_block_coding : RIV, 4 PRB
- 2, // modulation: QPSK
- round & 3, // redundancy version
- 1, // transport_blocks
- 0, // transport_block_to_codeword_swap_flag (0)
- (cc->p_eNB == 1) ? 0 : 1, // transmission_scheme
- 1, // number of layers
- 1, // number of subbands
- //0, // codebook index
- 1, // ue_category_capacity
- 4, // pa: 0 dB
- 0, // delta_power_offset_index
- 0, // ngap
- 1, // NPRB = 3 like in DCI
- (cc->p_eNB == 1) ? 1 : 2, // transmission mode
- 1, // num_bf_prb_per_subband
- 1); // num_bf_vector
- if(RC.mac[module_idP]->scheduler_mode == SCHED_MODE_FAIR_RR){
- set_dl_ue_select_msg4(CC_idP, 4, UE_id, ra->rnti);
- }
- } else
- LOG_D(MAC,
- "msg4 retransmission for rnti %x (round %d) fsf %d/%d CCE allocation failed!\n",
- ra->rnti, round, frameP, subframeP);
-
-
- // Program PUCCH1a for ACK/NAK
-
-
- fill_nfapi_uci_acknak(module_idP, CC_idP,
- ra->rnti,
- (frameP * 10) + subframeP,
- dl_config_pdu->dci_dl_pdu.
- dci_dl_pdu_rel8.cce_idx);
-
- // prepare frame for retransmission
- get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe);
-
- LOG_W(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n",
- module_idP, CC_idP, frameP, subframeP, ra->rnti,
- round, ra->Msg4_frame, ra->Msg4_subframe);
-
- } // Msg4 frame/subframe
- } // regular LTE case
- } else {
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n",
- module_idP, CC_idP, frameP, subframeP);
- ra->state = IDLE;
- LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:IDLE\n", module_idP, frameP, subframeP);
- UE_id = find_UE_id(module_idP, ra->rnti);
- DevAssert(UE_id != -1);
- mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured = TRUE;
- cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
- }
+ // Program PUCCH1a for ACK/NAK
+ fill_nfapi_uci_acknak(module_idP, CC_idP,
+ ra->rnti,
+ (frameP * 10) + subframeP,
+ dl_config_pdu->dci_dl_pdu.
+ dci_dl_pdu_rel8.cce_idx);
+ // prepare frame for retransmission
+ get_retransmission_timing(mac->common_channels[CC_idP].tdd_Config,&ra->Msg4_frame,&ra->Msg4_subframe);
+ LOG_W(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n",
+ module_idP, CC_idP, frameP, subframeP, ra->rnti,
+ round, ra->Msg4_frame, ra->Msg4_subframe);
+ } // Msg4 frame/subframe
+ } // regular LTE case
+ } else {
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n",
+ module_idP, CC_idP, frameP, subframeP);
+ ra->state = IDLE;
+ LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, Subframe %d: state:IDLE\n", module_idP, frameP, subframeP);
+ UE_id = find_UE_id(module_idP, ra->rnti);
+ DevAssert(UE_id != -1);
+ mac->UE_list.UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured = TRUE;
+ cancel_ra_proc(module_idP, CC_idP, frameP, ra->rnti);
+ }
}
void
-schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
-{
+schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) {
+ int CC_id;
+ eNB_MAC_INST *mac = RC.mac[module_idP];
+ COMMON_channels_t *cc = mac->common_channels;
+ RA_t *ra;
+ uint8_t i;
+ start_meas(&mac->schedule_ra);
- int CC_id;
- eNB_MAC_INST *mac = RC.mac[module_idP];
- COMMON_channels_t *cc = mac->common_channels;
- RA_t *ra;
- uint8_t i;
+ for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
+ // skip UL component carriers if TDD
+ if (is_UL_sf(&cc[CC_id], subframeP) == 1)
+ continue;
+ for (i = 0; i < NB_RA_PROC_MAX; i++) {
+ ra = (RA_t *) & cc[CC_id].ra[i];
- start_meas(&mac->schedule_ra);
+ //LOG_D(MAC,"RA[state:%d]\n",ra->state);
- for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
- // skip UL component carriers if TDD
- if (is_UL_sf(&cc[CC_id], subframeP) == 1)
- continue;
-
- for (i = 0; i < NB_RA_PROC_MAX; i++) {
-
- ra = (RA_t *) & cc[CC_id].ra[i];
-
- //LOG_D(MAC,"RA[state:%d]\n",ra->state);
-
- if (ra->state == MSG2)
- generate_Msg2(module_idP, CC_id, frameP, subframeP, ra);
- else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP )
- generate_Msg4(module_idP, CC_id, frameP, subframeP, ra);
- else if (ra->state == WAITMSG4ACK)
- check_Msg4_retransmission(module_idP, CC_id, frameP,
- subframeP, ra);
-
- } // for i=0 .. N_RA_PROC-1
- } // CC_id
-
- stop_meas(&mac->schedule_ra);
+ if (ra->state == MSG2)
+ generate_Msg2(module_idP, CC_id, frameP, subframeP, ra);
+ else if (ra->state == MSG4 && ra->Msg4_frame == frameP && ra->Msg4_subframe == subframeP )
+ generate_Msg4(module_idP, CC_id, frameP, subframeP, ra);
+ else if (ra->state == WAITMSG4ACK)
+ check_Msg4_retransmission(module_idP, CC_id, frameP,
+ subframeP, ra);
+ } // for i=0 .. N_RA_PROC-1
+ } // CC_id
+ stop_meas(&mac->schedule_ra);
}
// handles the event of MSG1 reception
void
initiate_ra_proc(module_id_t module_idP,
- int CC_id,
- frame_t frameP,
- sub_frame_t subframeP,
- uint16_t preamble_index,
- int16_t timing_offset, uint16_t ra_rnti
+ int CC_id,
+ frame_t frameP,
+ sub_frame_t subframeP,
+ uint16_t preamble_index,
+ int16_t timing_offset, uint16_t ra_rnti
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- , uint8_t rach_resource_type
+ , uint8_t rach_resource_type
#endif
- )
-{
-
- uint8_t i;
-
- COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id];
- RA_t *ra = &cc->ra[0];
+ ) {
+ uint8_t i;
+ COMMON_channels_t *cc = &RC.mac[module_idP]->common_channels[CC_id];
+ RA_t *ra = &cc->ra[0];
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+ struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL;
+ LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL;
-
- struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL;
- LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL;
-
-
-
- if (cc->mib->message.schedulingInfoSIB1_BR_r13>0) {
- AssertFatal(cc->radioResourceConfigCommon_BR != NULL,"radioResourceConfigCommon_BR is null\n");
- AssertFatal(cc->radioResourceConfigCommon_BR->ext4 != NULL, "radioResourceConfigCommon_BR->ext4 is null\n");
- ext4_prach = cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
- AssertFatal(ext4_prach!=NULL,"ext4_prach is null\n");
- prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
- }
+ if (cc->mib->message.schedulingInfoSIB1_BR_r13>0) {
+ AssertFatal(cc->radioResourceConfigCommon_BR != NULL,"radioResourceConfigCommon_BR is null\n");
+ AssertFatal(cc->radioResourceConfigCommon_BR->ext4 != NULL, "radioResourceConfigCommon_BR->ext4 is null\n");
+ ext4_prach = cc->radioResourceConfigCommon_BR->ext4->prach_ConfigCommon_v1310;
+ AssertFatal(ext4_prach!=NULL,"ext4_prach is null\n");
+ prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
+ }
#endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */
-
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n",
- module_idP, CC_id, frameP, subframeP, preamble_index);
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d Initiating RA procedure for preamble index %d\n",
+ module_idP, CC_id, frameP, subframeP, preamble_index);
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n",
- module_idP, CC_id, frameP, subframeP, rach_resource_type);
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d, Subframe %d PRACH resource type %d\n",
+ module_idP, CC_id, frameP, subframeP, rach_resource_type);
#endif
-
- uint16_t msg2_frame = frameP;
- uint16_t msg2_subframe = subframeP;
- int offset;
-
- static uint8_t failure_cnt = 0 ;
-
+ uint16_t msg2_frame = frameP;
+ uint16_t msg2_subframe = subframeP;
+ int offset;
+ static uint8_t failure_cnt = 0 ;
#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
- if (prach_ParametersListCE_r13 &&
- prach_ParametersListCE_r13->list.count < rach_resource_type) {
- LOG_E(MAC,
- "[eNB %d][RAPROC] CC_id %d Received impossible PRACH resource type %d, only %d CE levels configured\n",
- module_idP, CC_id, rach_resource_type,
- (int) prach_ParametersListCE_r13->list.count);
- return;
- }
+ if (prach_ParametersListCE_r13 &&
+ prach_ParametersListCE_r13->list.count < rach_resource_type) {
+ LOG_E(MAC,
+ "[eNB %d][RAPROC] CC_id %d Received impossible PRACH resource type %d, only %d CE levels configured\n",
+ module_idP, CC_id, rach_resource_type,
+ (int) prach_ParametersListCE_r13->list.count);
+ return;
+ }
#endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) */
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 1);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_INITIATE_RA_PROC, 0);
-
- for (i = 0; i < NB_RA_PROC_MAX; i++) {
- if (ra[i].state == IDLE) {
- int loop = 0;
- LOG_D(MAC, "Frame %d, Subframe %d: Activating RA process %d\n",
- frameP, subframeP, i);
- ra[i].state = MSG2;
- ra[i].Msg4_delay_cnt=0;
- ra[i].timing_offset = timing_offset;
- ra[i].preamble_subframe = subframeP;
+ for (i = 0; i < NB_RA_PROC_MAX; i++) {
+ if (ra[i].state == IDLE) {
+ int loop = 0;
+ LOG_D(MAC, "Frame %d, Subframe %d: Activating RA process %d\n",
+ frameP, subframeP, i);
+ ra[i].state = MSG2;
+ ra[i].Msg4_delay_cnt=0;
+ ra[i].timing_offset = timing_offset;
+ ra[i].preamble_subframe = subframeP;
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ra[i].rach_resource_type = rach_resource_type;
- ra[i].msg2_mpdcch_repetition_cnt = 0;
- ra[i].msg4_mpdcch_repetition_cnt = 0;
+ ra[i].rach_resource_type = rach_resource_type;
+ ra[i].msg2_mpdcch_repetition_cnt = 0;
+ ra[i].msg4_mpdcch_repetition_cnt = 0;
#endif
+ //TODO Fill in other TDD config. What about nfapi_mode?
+ if(cc->tdd_Config!=NULL) {
+ switch(cc->tdd_Config->subframeAssignment) {
+ default:
+ printf("%s:%d: TODO\n", __FILE__, __LINE__);
+ abort();
+ case 1 :
+ offset = 6;
+ break;
+ }
+ } else { //FDD
+ // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes
+ if (NFAPI_MODE != NFAPI_MONOLITHIC)
+ offset = 7;
+ else
+ offset = 5;
+ }
- //TODO Fill in other TDD config. What about nfapi_mode?
- if(cc->tdd_Config!=NULL){
- switch(cc->tdd_Config->subframeAssignment){
- default: printf("%s:%d: TODO\n", __FILE__, __LINE__); abort();
- case 1 :
- offset = 6;
- break;
- }
- }else{//FDD
- // DJP - this is because VNF is 2 subframes ahead of PNF and TX needs 4 subframes
- if (nfapi_mode)
- offset = 7;
- else
- offset = 5;
- }
+ add_subframe(&msg2_frame, &msg2_subframe, offset);
+ ra[i].Msg2_frame = msg2_frame;
+ ra[i].Msg2_subframe = msg2_subframe;
+ LOG_D(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,ra[i].Msg2_frame,ra[i].Msg2_subframe,frameP,subframeP,offset);
+ ra[i].Msg2_subframe = (subframeP + offset) % 10;
- add_subframe(&msg2_frame, &msg2_subframe, offset);
-
- ra[i].Msg2_frame = msg2_frame;
- ra[i].Msg2_subframe = msg2_subframe;
-
- LOG_D(MAC,"%s() Msg2[%04d%d] SFN/SF:%04d%d offset:%d\n", __FUNCTION__,ra[i].Msg2_frame,ra[i].Msg2_subframe,frameP,subframeP,offset);
-
- ra[i].Msg2_subframe = (subframeP + offset) % 10;
- /* TODO: find better procedure to allocate RNTI */
- do {
+ /* TODO: find better procedure to allocate RNTI */
+ do {
#if defined(USRP_REC_PLAY) // deterministic rnti in usrp record/playback mode
- static int drnti[MAX_MOBILES_PER_ENB] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 };
- int j = 0;
- int nb_ue = 0;
- for (j = 0; j < MAX_MOBILES_PER_ENB; j++) {
- if (UE_RNTI(module_idP, j) > 0) {
- nb_ue++;
- } else {
- break;
- }
- }
- if (nb_ue >= MAX_MOBILES_PER_ENB) {
- printf("No more free RNTI available, increase MAX_MOBILES_PER_ENB\n");
- abort();
- }
- ra[i].rnti = drnti[nb_ue];
-#else
- ra[i].rnti = taus();
+ static int drnti[MAX_MOBILES_PER_ENB] = { 0xbda7, 0x71da, 0x9c40, 0xc350, 0x2710, 0x4e20, 0x7530, 0x1388, 0x3a98, 0x61a8, 0x88b8, 0xafc8, 0xd6d8, 0x1b58, 0x4268, 0x6978 };
+ int j = 0;
+ int nb_ue = 0;
+
+ for (j = 0; j < MAX_MOBILES_PER_ENB; j++) {
+ if (UE_RNTI(module_idP, j) > 0) {
+ nb_ue++;
+ } else {
+ break;
+ }
+ }
+
+ if (nb_ue >= MAX_MOBILES_PER_ENB) {
+ printf("No more free RNTI available, increase MAX_MOBILES_PER_ENB\n");
+ abort();
+ }
+
+ ra[i].rnti = drnti[nb_ue];
+#else
+ ra[i].rnti = taus();
#endif
- loop++;
- }
- while (loop != 100 &&
- /* TODO: this is not correct, the rnti may be in use without
- * being in the MAC yet. To be refined.
- */
- !(find_UE_id(module_idP, ra[i].rnti) == -1 &&
- /* 1024 and 60000 arbirarily chosen, not coming from standard */
- ra[i].rnti >= 1024 && ra[i].rnti < 60000));
- if (loop == 100) {
- printf("%s:%d:%s: FATAL ERROR! contact the authors\n",
- __FILE__, __LINE__, __FUNCTION__);
- abort();
- }
- ra[i].RA_rnti = ra_rnti;
- ra[i].preamble_index = preamble_index;
- failure_cnt = 0;
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, state %d\n",
- module_idP, CC_id, frameP, ra[i].Msg2_frame,
- ra[i].Msg2_subframe, i, ra[i].rnti, ra[i].state);
+ loop++;
+ } while (loop != 100 &&
+ /* TODO: this is not correct, the rnti may be in use without
+ * being in the MAC yet. To be refined.
+ */
+ !(find_UE_id(module_idP, ra[i].rnti) == -1 &&
+ /* 1024 and 60000 arbirarily chosen, not coming from standard */
+ ra[i].rnti >= 1024 && ra[i].rnti < 60000));
- return;
- }
- }
+ if (loop == 100) {
+ printf("%s:%d:%s: FATAL ERROR! contact the authors\n",
+ __FILE__, __LINE__, __FUNCTION__);
+ abort();
+ }
- LOG_E(MAC,
- "[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",
- module_idP, CC_id, frameP, preamble_index);
-
- failure_cnt++;
- if(failure_cnt > 20) {
- LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Clear Random access information\n", module_idP, CC_id, frameP);
- clear_ra_proc(module_idP, CC_id, frameP);
+ ra[i].RA_rnti = ra_rnti;
+ ra[i].preamble_index = preamble_index;
+ failure_cnt = 0;
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d Activating RAR generation in Frame %d, subframe %d for process %d, rnti %x, state %d\n",
+ module_idP, CC_id, frameP, ra[i].Msg2_frame,
+ ra[i].Msg2_subframe, i, ra[i].rnti, ra[i].state);
+ return;
}
-
+ }
+
+ LOG_E(MAC,
+ "[eNB %d][RAPROC] FAILURE: CC_id %d Frame %d Initiating RA procedure for preamble index %d\n",
+ module_idP, CC_id, frameP, preamble_index);
+ failure_cnt++;
+
+ if(failure_cnt > 20) {
+ LOG_E(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Clear Random access information\n", module_idP, CC_id, frameP);
+ clear_ra_proc(module_idP, CC_id, frameP);
+ }
}
void
cancel_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP,
- rnti_t rnti)
-{
- unsigned char i;
- RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0];
+ rnti_t rnti) {
+ unsigned char i;
+ RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0];
+ MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %" PRIx16 " ",
+ rnti);
+ LOG_D(MAC,
+ "[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n",
+ module_idP, CC_id, frameP, rnti);
- MSC_LOG_EVENT(MSC_PHY_ENB, "RA Cancelling procedure ue %" PRIx16 " ",
- rnti);
- LOG_D(MAC,
- "[eNB %d][RAPROC] CC_id %d Frame %d Cancelling RA procedure for UE rnti %x\n",
- module_idP, CC_id, frameP, rnti);
-
- for (i = 0; i < NB_RA_PROC_MAX; i++) {
- if (rnti == ra[i].rnti) {
- ra[i].state = IDLE;
- ra[i].timing_offset = 0;
- ra[i].RRC_timer = 20;
- ra[i].rnti = 0;
- ra[i].msg3_round = 0;
- LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Canceled RA procedure for UE rnti %x\n", module_idP, CC_id, frameP, rnti);
- }
+ for (i = 0; i < NB_RA_PROC_MAX; i++) {
+ if (rnti == ra[i].rnti) {
+ ra[i].state = IDLE;
+ ra[i].timing_offset = 0;
+ ra[i].RRC_timer = 20;
+ ra[i].rnti = 0;
+ ra[i].msg3_round = 0;
+ LOG_D(MAC,"[eNB %d][RAPROC] CC_id %d Frame %d Canceled RA procedure for UE rnti %x\n", module_idP, CC_id, frameP, rnti);
}
+ }
}
-void clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP)
-{
+void clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP) {
unsigned char i;
RA_t *ra = (RA_t *) & RC.mac[module_idP]->common_channels[CC_id].ra[0];
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
index d49ebbb264..38195676d7 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
@@ -672,8 +672,10 @@ schedule_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP)
mcs = 7;
} else if (bcch_sdu_length <= 49) {
mcs = 8;
- }
-
+ } else if (bcch_sdu_length <= 59) {
+ mcs = 9;
+ }
+ else AssertFatal(1==0,"Cannot Assign mcs for bcch_sdu_length %d (max mcs 9)\n",bcch_sdu_length);
dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
memset((void *) dl_config_pdu, 0,
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
index 274b169bf6..bf5cfef0c3 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c
@@ -35,6 +35,7 @@
#include "LAYER2/MAC/mac_proto.h"
#include "LAYER2/MAC/mac_extern.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
@@ -64,7 +65,7 @@
#include "common/ran_context.h"
extern RAN_CONTEXT_t RC;
-extern uint8_t nfapi_mode;
+
//------------------------------------------------------------------------------
void
@@ -155,6 +156,7 @@ generate_dlsch_header(unsigned char *mac_header,
} else {
first_element = 1;
}
+
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = DRX_CMD;
@@ -168,6 +170,7 @@ generate_dlsch_header(unsigned char *mac_header,
} else {
first_element = 1;
}
+
mac_header_ptr->R = 0;
mac_header_ptr->E = 0;
mac_header_ptr->LCID = TIMING_ADV_CMD;
@@ -435,25 +438,15 @@ schedule_dlsch(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP, in
// changes to pre-processor for eMTC
//------------------------------------------------------------------------------
-void getRepetition(UE_TEMPLATE * pue_template,unsigned int *maxRep , unsigned int *narrowBandindex){
- LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11;
-
- AssertFatal(pue_template->physicalConfigDedicated !=NULL, "no RRC physical configuration for this UE ") ;
- AssertFatal(pue_template->physicalConfigDedicated->ext4 !=NULL, "no RRC physical configuration for this UE ") ;
-
- AssertFatal(pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.count > 0 ,"epdcch config list is empty") ;
-
- epdcch_setconfig_r11 = pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0] ;
-
- AssertFatal(epdcch_setconfig_r11->ext2 !=NULL && epdcch_setconfig_r11->ext2->mpdcch_config_r13 !=NULL," mpdcch config not found") ;
-
-*maxRep = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_NumRepetition_r13 ;
-
- *narrowBandindex = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 ;
-
-
-
-
+void getRepetition(UE_TEMPLATE *pue_template,unsigned int *maxRep, unsigned int *narrowBandindex) {
+ LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11;
+ AssertFatal(pue_template->physicalConfigDedicated !=NULL, "no RRC physical configuration for this UE ") ;
+ AssertFatal(pue_template->physicalConfigDedicated->ext4 !=NULL, "no RRC physical configuration for this UE ") ;
+ AssertFatal(pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.count > 0,"epdcch config list is empty") ;
+ epdcch_setconfig_r11 = pue_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0] ;
+ AssertFatal(epdcch_setconfig_r11->ext2 !=NULL && epdcch_setconfig_r11->ext2->mpdcch_config_r13 !=NULL," mpdcch config not found") ;
+ *maxRep = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_NumRepetition_r13 ;
+ *narrowBandindex = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 ;
}
//------------------------------------------------------------------------------
@@ -510,7 +503,6 @@ schedule_ue_spec(module_id_t module_idP,
rrc_eNB_ue_context_t *ue_contextP = NULL;
int nb_mac_CC = RC.nb_mac_CC[module_idP];
long dl_Bandwidth;
-
start_meas(&eNB->schedule_dlsch);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH,
VCD_FUNCTION_IN);
@@ -658,14 +650,14 @@ schedule_ue_spec(module_id_t module_idP,
case 2:
case 7:
aggregation = get_aggregation(get_bw_index(module_idP,
- CC_id),
+ CC_id),
ue_sched_ctrl->dl_cqi[CC_id],
format1);
break;
case 3:
aggregation = get_aggregation(get_bw_index(module_idP,
- CC_id),
+ CC_id),
ue_sched_ctrl->dl_cqi[CC_id],
format2A);
break;
@@ -743,7 +735,7 @@ schedule_ue_spec(module_id_t module_idP,
(eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)),
eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE);
*/
- if (nfapi_mode) {
+ if (NFAPI_MODE != NFAPI_MONOLITHIC) {
eNB_UE_stats->dlsch_mcs1 = 10; // cqi_to_mcs[ue_sched_ctrl->dl_cqi[CC_id]];
} else { // this operation is also done in the preprocessor
eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1,
@@ -764,7 +756,7 @@ schedule_ue_spec(module_id_t module_idP,
CC_id,
rnti,
harq_pid,
- round,
+ round,
nb_available_rb,
ue_sched_ctrl->dl_cqi[CC_id],
eNB_UE_stats->dlsch_mcs1,
@@ -806,11 +798,12 @@ schedule_ue_spec(module_id_t module_idP,
LOG_W(MAC, "WARN: rballoc_subband not free for retrans?\n");
ue_template->rballoc_subband[harq_pid][j] = ue_sched_ctrl->rballoc_sub_UE[CC_id][j];
-
nb_rb_temp -= min_rb_unit[CC_id];
+
if ((j == N_RBG[CC_id] - 1) && (N_RB_DL[CC_id] == 25 || N_RB_DL[CC_id] == 50))
nb_rb_temp++;
}
+
j++;
}
}
@@ -908,7 +901,6 @@ schedule_ue_spec(module_id_t module_idP,
cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode
0, //number of PRBs treated as one subband, not used here
0); // number of beamforming vectors, not used here
-
LOG_D(MAC, "Filled NFAPI configuration for DCI/DLSCH %d, retransmission round %d\n",
eNB->pdu_index[CC_id],
round);
@@ -962,6 +954,7 @@ schedule_ue_spec(module_id_t module_idP,
if (ta_update != 31) {
ue_sched_ctrl->ta_timer = 20;
}
+
/* reset ta_update */
ue_sched_ctrl->ta_update = 31;
} else {
@@ -1008,7 +1001,7 @@ schedule_ue_spec(module_id_t module_idP,
, 0
, 0
#endif
- );
+ );
pthread_mutex_lock(&rrc_release_freelist);
if((rrc_release_info.num_UEs > 0) && (rlc_am_mui.rrc_mui_num > 0)) {
@@ -1101,10 +1094,12 @@ schedule_ue_spec(module_id_t module_idP,
module_idP,
CC_id,
sdu_lengths[0]);
+
for (j = 0; j < sdu_lengths[0]; ++j) {
LOG_T(MAC, "%x ",
dlsch_buffer[j]);
}
+
LOG_T(MAC, "\n");
#endif
}
@@ -1125,7 +1120,7 @@ schedule_ue_spec(module_id_t module_idP,
, 0
, 0
#endif
- );
+ );
// DCCH SDU
sdu_lengths[num_sdus] = 0;
@@ -1134,18 +1129,18 @@ schedule_ue_spec(module_id_t module_idP,
module_idP, frameP, CC_id,
TBS - ta_len - header_length_total - sdu_length_total - 3);
sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP,
- rnti,
- module_idP,
- frameP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO, DCCH + 1,
- TBS, //not used
- (char *) &dlsch_buffer[sdu_length_total]
+ rnti,
+ module_idP,
+ frameP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO, DCCH + 1,
+ TBS, //not used
+ (char *) &dlsch_buffer[sdu_length_total]
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- , 0
- , 0
+ , 0
+ , 0
#endif
- );
+ );
T(T_ENB_MAC_UE_DL_SDU,
T_INT(module_idP),
T_INT(CC_id),
@@ -1169,10 +1164,12 @@ schedule_ue_spec(module_id_t module_idP,
module_idP,
CC_id,
sdu_lengths[num_sdus]);
+
for (j = 0; j < sdu_lengths[num_sdus]; ++j) {
LOG_T(MAC, "%x ",
dlsch_buffer[j]);
}
+
LOG_T(MAC, "\n");
#endif
}
@@ -1202,7 +1199,7 @@ schedule_ue_spec(module_id_t module_idP,
, 0
, 0
#endif
- );
+ );
if (rlc_status.bytes_in_buffer > 0) {
LOG_D(MAC, "[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n",
@@ -1212,19 +1209,19 @@ schedule_ue_spec(module_id_t module_idP,
lcid,
header_length_total);
sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
- rnti,
- module_idP,
- frameP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
- lcid,
- TBS, //not used
- (char *) &dlsch_buffer[sdu_length_total]
+ rnti,
+ module_idP,
+ frameP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ lcid,
+ TBS, //not used
+ (char *) &dlsch_buffer[sdu_length_total]
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- , 0
- , 0
+ , 0
+ , 0
#endif
- );
+ );
T(T_ENB_MAC_UE_DL_SDU,
T_INT(module_idP),
T_INT(CC_id),
@@ -1395,10 +1392,12 @@ schedule_ue_spec(module_id_t module_idP,
//#endif
#ifdef DEBUG_eNB_SCHEDULER
LOG_T(MAC, "[eNB %d] First 16 bytes of DLSCH : \n");
+
for (i = 0; i < 16; i++) {
LOG_T(MAC, "%x.",
dlsch_buffer[i]);
}
+
LOG_T(MAC, "\n");
#endif
// cycle through SDUs and place in dlsch_buffer
@@ -1522,7 +1521,7 @@ schedule_ue_spec(module_id_t module_idP,
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1;
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level =
get_aggregation(get_bw_index(module_idP,
- CC_id),
+ CC_id),
ue_sched_ctrl->dl_cqi[CC_id],
format1);
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
@@ -1608,12 +1607,11 @@ schedule_ue_spec(module_id_t module_idP,
cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode
0, //number of PRBs treated as one subband, not used here
0); // number of beamforming vectors, not used here
-
eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body,
- (frameP * 10) + subframeP,
- TBS,
- eNB->pdu_index[CC_id],
- dlsch_pdu->payload[0]);
+ (frameP * 10) + subframeP,
+ TBS,
+ eNB->pdu_index[CC_id],
+ dlsch_pdu->payload[0]);
LOG_D(MAC, "Filled NFAPI configuration for DCI/DLSCH/TXREQ %d, new SDU\n",
eNB->pdu_index[CC_id]);
eNB->pdu_index[CC_id]++;
@@ -1818,6 +1816,7 @@ dlsch_scheduler_interslice_multiplexing(module_id_t Mod_id,
}
}
}
+
return;
}
@@ -1858,12 +1857,12 @@ void dlsch_scheduler_qos_multiplexing(module_id_t Mod_id, int frameP, sub_frame_
*/
void
schedule_ue_spec_br(module_id_t module_idP,
- frame_t frameP,
- sub_frame_t subframeP)
-//------------------------------------------------------------------------------
+ frame_t frameP,
+ sub_frame_t subframeP)
+//------------------------------------------------------------------------------
{
int CC_id = 0;
- int UE_id = -1;
+ int UE_id = -1;
int rvseq[4] = {0,2,3,1};
int mcs = 0;
int round_DL = 0;
@@ -1878,13 +1877,11 @@ schedule_ue_spec_br(module_id_t module_idP,
uint16_t padding = 0;
uint16_t post_padding = 0;
uint16_t sdu_length_total = 0;
-
mac_rlc_status_resp_t rlc_status;
rrc_eNB_ue_context_t *ue_contextP = NULL;
-
unsigned char header_len_dcch = 0;
unsigned char header_len_dcch_tmp = 0;
- unsigned char header_len_dtch = 0;
+ unsigned char header_len_dtch = 0;
unsigned char header_len_dtch_tmp = 0;
unsigned char header_len_dtch_last = 0;
unsigned char ta_len = 0;
@@ -1892,19 +1889,16 @@ schedule_ue_spec_br(module_id_t module_idP,
unsigned char lcid = 0;
unsigned char offset,num_sdus=0;
unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES];
-
eNB_MAC_INST *mac = RC.mac[module_idP];
COMMON_channels_t *cc = mac->common_channels;
UE_list_t *UE_list = &mac->UE_list;
UE_TEMPLATE *UE_template = NULL;
UE_sched_ctrl *ue_sched_ctl = NULL;
-
nfapi_dl_config_request_pdu_t *dl_config_pdu = NULL;
nfapi_ul_config_request_pdu_t *ul_config_pdu = NULL;
nfapi_tx_request_pdu_t *TX_req = NULL;
nfapi_dl_config_request_body_t *dl_req = NULL;
nfapi_ul_config_request_body_t *ul_req = NULL;
-
struct LTE_PRACH_ConfigSIB_v1310 *ext4_prach = NULL;
struct LTE_PUCCH_ConfigCommon_v1310 *ext4_pucch = NULL;
LTE_PRACH_ParametersListCE_r13_t *prach_ParametersListCE_r13 = NULL;
@@ -1913,7 +1907,6 @@ schedule_ue_spec_br(module_id_t module_idP,
int n1pucchan[4] = { 0, 0, 0, 0 };
uint32_t ackNAK_absSF;
int first_rb;
-
dl_req = &(mac->DL_req[CC_id].dl_config_request_body);
dl_config_pdu = &(dl_req->dl_config_pdu_list[dl_req->number_pdu]);
@@ -1931,39 +1924,40 @@ schedule_ue_spec_br(module_id_t module_idP,
ext4_pucch = cc[CC_id].radioResourceConfigCommon_BR->ext4->pucch_ConfigCommon_v1310;
prach_ParametersListCE_r13 = &ext4_prach->prach_ParametersListCE_r13;
pucch_N1PUCCH_AN_InfoList_r13 = ext4_pucch->n1PUCCH_AN_InfoList_r13;
-
AssertFatal (prach_ParametersListCE_r13 != NULL, "prach_ParametersListCE_r13 is null\n");
AssertFatal (pucch_N1PUCCH_AN_InfoList_r13 != NULL, "pucch_N1PUCCH_AN_InfoList_r13 is null\n");
/* Check to verify CE-Level compatibility in SIB2_BR */
AssertFatal (prach_ParametersListCE_r13->list.count == pucch_N1PUCCH_AN_InfoList_r13->list.count, "prach_ParametersListCE_r13->list.count!= pucch_N1PUCCH_AN_InfoList_r13->list.count\n");
switch (prach_ParametersListCE_r13->list.count) {
- case 4:
- n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
- AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n");
- pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
+ case 4:
+ n1pucchan[3] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[3];
+ AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level3 shouldn't be NULL\n");
+ pucchreps[3] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level3_r13);
- case 3:
- n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
- AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n");
- pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
- case 2:
- n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
- AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n");
- pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
- case 1:
- n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
- AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n");
- pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
- break;
- default:
- AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count);
+ case 3:
+ n1pucchan[2] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[2];
+ AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level2 shouldn't be NULL\n");
+ pucchreps[2] = (int) (4 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level2_r13);
+
+ case 2:
+ n1pucchan[1] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[1];
+ AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level1 shouldn't be NULL\n");
+ pucchreps[1] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level1_r13);
+
+ case 1:
+ n1pucchan[0] = *pucch_N1PUCCH_AN_InfoList_r13->list.array[0];
+ AssertFatal (ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13 != NULL, "pucch_NumRepetitionCE_Msg4_Level0 shouldn't be NULL\n");
+ pucchreps[0] = (int) (1 << *ext4_pucch->pucch_NumRepetitionCE_Msg4_Level0_r13);
+ break;
+
+ default:
+ AssertFatal (1 == 0, "Illegal count for prach_ParametersListCE_r13 %d\n", prach_ParametersListCE_r13->list.count);
}
}
for (UE_id = UE_list->head; UE_id >= 0; UE_id = UE_list->next[UE_id]) {
int harq_pid = 0;
-
rnti = UE_RNTI(module_idP, UE_id);
if (rnti==NOT_A_RNTI) {
@@ -1984,26 +1978,23 @@ schedule_ue_spec_br(module_id_t module_idP,
}
round_DL = ue_sched_ctl->round[CC_id][harq_pid];
-
AssertFatal (UE_template->physicalConfigDedicated != NULL, "UE_template->physicalConfigDedicated is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, "UE_template->physicalConfigDedicated->ext4 is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
-
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
-
AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
AssertFatal(epdcch_setconfig_r11->ext2 != NULL, "epdcch_setconfig_r11->ext2 is null\n");
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
- AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup,
- "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
+ AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup,
+ "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 != NULL, "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null");
- AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup,
- "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
+ AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup,
+ "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
/* Simple scheduler for 1 repetition, 1 HARQ */
if (subframeP == 5) { // MPDCCH
@@ -2011,21 +2002,21 @@ schedule_ue_spec_br(module_id_t module_idP,
if (round_DL == 8) {
rlc_status.bytes_in_buffer = 0;
-
/* Now check RLC information to compute number of required RBs */
-
/* Get maximum TBS size for RLC request */
TBS = get_TBS_DL(9,6);
-
+
/* Check first for RLC data on DCCH */
-
+
/* Add the length for all the control elements (timing adv, drx, etc) : header + payload */
if (ue_sched_ctl->ta_timer == 0) {
ta_update = ue_sched_ctl->ta_update;
+
/* If we send TA then set timer to not send it for a while */
if (ta_update != 31)
ue_sched_ctl->ta_timer = 20;
+
/* Reset ta_update */
ue_sched_ctl->ta_update = 31;
} else {
@@ -2033,60 +2024,53 @@ schedule_ue_spec_br(module_id_t module_idP,
}
ta_len = (ta_update != 31) ? 2 : 0;
-
header_len_dcch = 2; // 2 bytes DCCH SDU subheader
if (TBS - ta_len-header_len_dcch > 0 ) {
LOG_D(MAC, "Calling mac_rlc_status_ind for DCCH\n");
-
rlc_status = mac_rlc_status_ind(module_idP,
- rnti,
- module_idP,
- frameP,
- subframeP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
- DCCH,
+ rnti,
+ module_idP,
+ frameP,
+ subframeP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ DCCH,
(TBS-ta_len-header_len_dcch),
0,
0); // transport block set size
-
sdu_lengths[0] = 0;
if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit
LOG_D(MAC, "[eNB %d] Frame %d, DL-DCCH->DLSCH CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
- module_idP,
+ module_idP,
frameP,
CC_id,
TBS-header_len_dcch);
-
sdu_lengths[0] = mac_rlc_data_req(module_idP,
- rnti,
- module_idP,
- frameP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
- DCCH,
- TBS, //not used
+ rnti,
+ module_idP,
+ frameP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ DCCH,
+ TBS, //not used
(char *)&dlsch_buffer[0],
0,
0);
-
- T(T_ENB_MAC_UE_DL_SDU,
- T_INT(module_idP),
- T_INT(CC_id),
- T_INT(rnti),
- T_INT(frameP),
+ T(T_ENB_MAC_UE_DL_SDU,
+ T_INT(module_idP),
+ T_INT(CC_id),
+ T_INT(rnti),
+ T_INT(frameP),
T_INT(subframeP),
- T_INT(harq_pid),
- T_INT(DCCH),
+ T_INT(harq_pid),
+ T_INT(DCCH),
T_INT(sdu_lengths[0]));
-
LOG_D(MAC,"[eNB %d][DCCH] CC_id %d Got %d bytes from RLC\n",
module_idP,
CC_id,
sdu_lengths[0]);
-
sdu_length_total = sdu_lengths[0];
sdu_lcids[0] = DCCH;
UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH]+=1;
@@ -2101,192 +2085,183 @@ schedule_ue_spec_br(module_id_t module_idP,
/* Check for DCCH1 and update header information (assume 2 byte sub-header) */
if (TBS - ta_len-header_len_dcch - sdu_length_total > 0) {
rlc_status = mac_rlc_status_ind(module_idP,
- rnti,
- module_idP,
- frameP,
- subframeP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
+ rnti,
+ module_idP,
+ frameP,
+ subframeP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
DCCH + 1,
(TBS-ta_len-header_len_dcch-sdu_length_total),
- 0,
+ 0,
0); // transport block set size less allocations for timing advance and DCCH SDU
-
- sdu_lengths[num_sdus] = 0;
+ sdu_lengths[num_sdus] = 0;
if (rlc_status.bytes_in_buffer > 0) {
LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, CC_id %d, Requesting %d bytes from RLC (RRC message)\n",
- module_idP,
+ module_idP,
frameP,
CC_id,
TBS-header_len_dcch - sdu_length_total);
-
sdu_lengths[num_sdus] += mac_rlc_data_req(module_idP,
- rnti,
- module_idP,
- frameP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
- DCCH+1,
- TBS, //not used
- (char *)&dlsch_buffer[sdu_length_total],
- 0,
- 0);
-
- T(T_ENB_MAC_UE_DL_SDU,
- T_INT(module_idP),
- T_INT(CC_id),
- T_INT(rnti),
- T_INT(frameP),
+ rnti,
+ module_idP,
+ frameP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ DCCH+1,
+ TBS, //not used
+ (char *)&dlsch_buffer[sdu_length_total],
+ 0,
+ 0);
+ T(T_ENB_MAC_UE_DL_SDU,
+ T_INT(module_idP),
+ T_INT(CC_id),
+ T_INT(rnti),
+ T_INT(frameP),
T_INT(subframeP),
- T_INT(harq_pid),
- T_INT(DCCH+1),
+ T_INT(harq_pid),
+ T_INT(DCCH+1),
T_INT(sdu_lengths[num_sdus]));
-
sdu_lcids[num_sdus] = DCCH1;
sdu_length_total += sdu_lengths[num_sdus];
header_len_dcch += 2;
UE_list->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1;
UE_list->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus];
- num_sdus++;
- }
+ num_sdus++;
+ }
}
- /* Assume the max dtch header size, and adjust it later */
- header_len_dtch = 0;
- header_len_dtch_last = 0; // the header length of the last mac sdu
-
- /* lcid has to be sorted before the actual allocation (similar struct as ue_list) */
- for (lcid = NB_RB_MAX-1; lcid >= DTCH ; lcid--){
- /* TBD: check if the lcid is active */
- header_len_dtch += 3;
- header_len_dtch_last = 3;
+ /* Assume the max dtch header size, and adjust it later */
+ header_len_dtch = 0;
+ header_len_dtch_last = 0; // the header length of the last mac sdu
- LOG_D(MAC,"[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n",
- module_idP,
- frameP,
- lcid,
- TBS,
- TBS - ta_len-header_len_dcch - sdu_length_total - header_len_dtch);
+ /* lcid has to be sorted before the actual allocation (similar struct as ue_list) */
+ for (lcid = NB_RB_MAX-1; lcid >= DTCH ; lcid--) {
+ /* TBD: check if the lcid is active */
+ header_len_dtch += 3;
+ header_len_dtch_last = 3;
+ LOG_D(MAC,"[eNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (tbs %d, len %d)\n",
+ module_idP,
+ frameP,
+ lcid,
+ TBS,
+ TBS - ta_len-header_len_dcch - sdu_length_total - header_len_dtch);
- if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ?
- rlc_status = mac_rlc_status_ind(module_idP,
- rnti,
- module_idP,
- frameP,
- subframeP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
- lcid,
- TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch,
- 0,
- 0);
+ if (TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch > 0) { // NN: > 2 ?
+ rlc_status = mac_rlc_status_ind(module_idP,
+ rnti,
+ module_idP,
+ frameP,
+ subframeP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ lcid,
+ TBS - ta_len - header_len_dcch - sdu_length_total - header_len_dtch,
+ 0,
+ 0);
- if (rlc_status.bytes_in_buffer > 0) {
- /* RRC inactivity LTE-M */
- /* Reset RRC inactivity timer after uplane activity */
- ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti);
+ if (rlc_status.bytes_in_buffer > 0) {
+ /* RRC inactivity LTE-M */
+ /* Reset RRC inactivity timer after uplane activity */
+ ue_contextP = rrc_eNB_get_ue_context(RC.rrc[module_idP], rnti);
- if (ue_contextP != NULL) {
- ue_contextP->ue_context.ue_rrc_inactivity_timer = 1;
- } else {
- LOG_E(MAC, "[eNB %d] CC_id %d Couldn't find the context associated to UE (RNTI %d) and reset RRC inactivity timer\n",
- module_idP,
- CC_id,
- rnti);
- }
-
- LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n",
+ if (ue_contextP != NULL) {
+ ue_contextP->ue_context.ue_rrc_inactivity_timer = 1;
+ } else {
+ LOG_E(MAC, "[eNB %d] CC_id %d Couldn't find the context associated to UE (RNTI %d) and reset RRC inactivity timer\n",
module_idP,
- frameP,
- TBS - header_len_dcch - sdu_length_total - header_len_dtch,
- lcid,
- header_len_dtch);
+ CC_id,
+ rnti);
+ }
- sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
- rnti,
- module_idP,
- frameP,
- ENB_FLAG_YES,
- MBMS_FLAG_NO,
- lcid,
- TBS, //not used
- (char*) &dlsch_buffer[sdu_length_total],
- 0,
- 0);
+ LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d)\n",
+ module_idP,
+ frameP,
+ TBS - header_len_dcch - sdu_length_total - header_len_dtch,
+ lcid,
+ header_len_dtch);
+ sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
+ rnti,
+ module_idP,
+ frameP,
+ ENB_FLAG_YES,
+ MBMS_FLAG_NO,
+ lcid,
+ TBS, //not used
+ (char *) &dlsch_buffer[sdu_length_total],
+ 0,
+ 0);
+ T(T_ENB_MAC_UE_DL_SDU,
+ T_INT(module_idP),
+ T_INT(CC_id),
+ T_INT(rnti),
+ T_INT(frameP),
+ T_INT(subframeP),
+ T_INT(harq_pid),
+ T_INT(lcid),
+ T_INT(sdu_lengths[num_sdus]));
+ LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",
+ module_idP,
+ sdu_lengths[num_sdus],
+ lcid);
+ sdu_lcids[num_sdus] = lcid;
+ sdu_length_total += sdu_lengths[num_sdus];
- T(T_ENB_MAC_UE_DL_SDU,
- T_INT(module_idP),
- T_INT(CC_id),
- T_INT(rnti),
- T_INT(frameP),
- T_INT(subframeP),
- T_INT(harq_pid),
- T_INT(lcid),
- T_INT(sdu_lengths[num_sdus]));
+ if (sdu_lengths[num_sdus] < 128) {
+ header_len_dtch--;
+ header_len_dtch_last--;
+ }
- LOG_D(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",
- module_idP,
- sdu_lengths[num_sdus],
- lcid);
-
- sdu_lcids[num_sdus] = lcid;
- sdu_length_total += sdu_lengths[num_sdus];
-
- if (sdu_lengths[num_sdus] < 128) {
- header_len_dtch--;
- header_len_dtch_last--;
- }
-
- num_sdus++;
- } else { // no data for this LCID
+ num_sdus++;
+ } else { // no data for this LCID
+ header_len_dtch -= 3;
+ }
+ } else { // no TBS left
header_len_dtch -= 3;
- }
- } else { // no TBS left
- header_len_dtch -= 3;
- break;
- }
- } // for loop LCID
+ break;
+ }
+ } // for loop LCID
- if (header_len_dtch == 0) {
- header_len_dtch_last = 0;
- }
+ if (header_len_dtch == 0) {
+ header_len_dtch_last = 0;
+ }
- /* There is at least one SDU */
- if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) {
- /* Now compute number of required RBs for total sdu length */
- /* Assume RAH format 2 */
- /* Adjust header lengths */
- header_len_dcch_tmp = header_len_dcch;
- header_len_dtch_tmp = header_len_dtch;
-
- if (header_len_dtch == 0) {
- header_len_dcch = (header_len_dcch > 0) ? 1 : 0; // remove length field
- } else {
- header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU
- header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU
- }
+ /* There is at least one SDU */
+ if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0) {
+ /* Now compute number of required RBs for total sdu length */
+ /* Assume RAH format 2 */
+ /* Adjust header lengths */
+ header_len_dcch_tmp = header_len_dcch;
+ header_len_dtch_tmp = header_len_dtch;
+
+ if (header_len_dtch == 0) {
+ header_len_dcch = (header_len_dcch > 0) ? 1 : 0; // remove length field
+ } else {
+ header_len_dtch_last -= 1; // now use it to find how many bytes has to be removed for the last MAC SDU
+ header_len_dtch = (header_len_dtch > 0) ? header_len_dtch - header_len_dtch_last : header_len_dtch; // remove length field for the last SDU
+ }
mcs = 9;
- /* Decrease mcs until TBS falls below required length */
+ /* Decrease mcs until TBS falls below required length */
while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) {
mcs--;
TBS = get_TBS_DL(mcs,6);
}
- /* If we have decreased too much or we don't have enough RBs, increase MCS */
+ /* If we have decreased too much or we don't have enough RBs, increase MCS */
while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) {
mcs++;
TBS = get_TBS_DL(mcs,6);
}
- LOG_D(MAC, "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n",
- module_idP,
- CC_id,
- mcs,
- TBS,
- 6);
+ LOG_D(MAC, "[eNB %d] CC_id %d Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n",
+ module_idP,
+ CC_id,
+ mcs,
+ TBS,
+ 6);
if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) {
padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len);
@@ -2294,17 +2269,17 @@ schedule_ue_spec_br(module_id_t module_idP,
} else {
padding = 0;
- /* Adjust the header len */
- if (header_len_dtch == 0) {
+ /* Adjust the header len */
+ if (header_len_dtch == 0) {
header_len_dcch = header_len_dcch_tmp;
- } else { // if ((header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2)))
+ } else { // if ((header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2)))
header_len_dtch = header_len_dtch_tmp;
}
- post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header
+ post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len; // 1 is for the postpadding header
}
- offset = generate_dlsch_header((unsigned char*)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
+ offset = generate_dlsch_header((unsigned char *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
num_sdus, //num_sdus
sdu_lengths, //
sdu_lcids,
@@ -2314,188 +2289,175 @@ schedule_ue_spec_br(module_id_t module_idP,
padding,
post_padding);
-
if (ta_update != 31) {
- LOG_D(MAC,"[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n",
- module_idP,
- frameP,
- UE_id,
- CC_id,
- sdu_length_total,
- num_sdus,
- sdu_lengths[0],
- sdu_lcids[0],
- offset,
- ta_update,
- padding,
- post_padding,
- mcs,
- TBS,
- 6,
- header_len_dcch,
- header_len_dtch);
- }
+ LOG_D(MAC,
+ "[eNB %d][DLSCH] Frame %d Generate header for UE_id %d on CC_id %d: sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n",
+ module_idP,
+ frameP,
+ UE_id,
+ CC_id,
+ sdu_length_total,
+ num_sdus,
+ sdu_lengths[0],
+ sdu_lcids[0],
+ offset,
+ ta_update,
+ padding,
+ post_padding,
+ mcs,
+ TBS,
+ 6,
+ header_len_dcch,
+ header_len_dtch);
+ }
- /* Cycle through SDUs and place in dlsch_buffer */
- memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total);
+ /* Cycle through SDUs and place in dlsch_buffer */
+ memcpy(&UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset], dlsch_buffer, sdu_length_total);
- /* Fill remainder of DLSCH with random data */
- for (j = 0; j < (TBS - sdu_length_total - offset); j++) {
- UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = (char)(taus()&0xff);
+ /* Fill remainder of DLSCH with random data */
+ for (j = 0; j < (TBS - sdu_length_total - offset); j++) {
+ UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0][offset + sdu_length_total + j] = (char)(taus()&0xff);
}
if (opt_enabled == 1) {
- trace_pdu(1,
- (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
- TBS,
- module_idP,
- 3,
- UE_RNTI(module_idP,UE_id),
- mac->frame,
- mac->subframe,
- 0,
- 0);
-
+ trace_pdu(1,
+ (uint8_t *)UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0],
+ TBS,
+ module_idP,
+ 3,
+ UE_RNTI(module_idP,UE_id),
+ mac->frame,
+ mac->subframe,
+ 0,
+ 0);
LOG_D(OPT,"[eNB %d][DLSCH] CC_id %d Frame %d rnti %x with size %d\n",
- module_idP,
- CC_id,
- frameP,
- UE_RNTI(module_idP, UE_id),
- TBS);
+ module_idP,
+ CC_id,
+ frameP,
+ UE_RNTI(module_idP, UE_id),
+ TBS);
}
- T(T_ENB_MAC_UE_DL_PDU_WITH_DATA,
- T_INT(module_idP),
- T_INT(CC_id),
- T_INT(rnti),
- T_INT(frameP),
- T_INT(subframeP),
- T_INT(harq_pid),
- T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS));
-
- /* Do PUCCH power control */
- /* This is the normalized RX power */
+ T(T_ENB_MAC_UE_DL_PDU_WITH_DATA,
+ T_INT(module_idP),
+ T_INT(CC_id),
+ T_INT(rnti),
+ T_INT(frameP),
+ T_INT(subframeP),
+ T_INT(harq_pid),
+ T_BUFFER(UE_list->DLSCH_pdu[CC_id][0][UE_id].payload[0], TBS));
+ /* Do PUCCH power control */
+ /* This is the normalized RX power */
/* TODO: fix how we deal with power, unit is not dBm, it's special from nfapi */
- normalized_rx_power = (5 * ue_sched_ctl->pucch1_snr[CC_id]-640) / 10 + 30;
- target_rx_power = mac->puCch10xSnr / 10 + 30;
+ normalized_rx_power = (5 * ue_sched_ctl->pucch1_snr[CC_id]-640) / 10 + 30;
+ target_rx_power = mac->puCch10xSnr / 10 + 30;
+ /* This assumes accumulated tpc */
+ /* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out */
+ int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe;
- /* This assumes accumulated tpc */
- /* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out */
- int32_t framex10psubframe = UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame * 10 + UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe;
-
- if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case
- ((framex10psubframe > (frameP * 10 + subframeP)) &&
- (((10240 - framex10psubframe +frameP * 10 + subframeP) >= 10)))) { // frame wrap-around
- if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) {
- ue_sched_ctl->pucch1_cqi_update[CC_id] = 0;
+ if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case
+ ((framex10psubframe > (frameP * 10 + subframeP)) &&
+ (((10240 - framex10psubframe +frameP * 10 + subframeP) >= 10)))) { // frame wrap-around
+ if (ue_sched_ctl->pucch1_cqi_update[CC_id] == 1) {
+ ue_sched_ctl->pucch1_cqi_update[CC_id] = 0;
+ UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP;
+ UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP;
- UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_frame = frameP;
- UE_list->UE_template[CC_id][UE_id].pucch_tpc_tx_subframe = subframeP;
+ if (normalized_rx_power > (target_rx_power + 4)) {
+ tpc = 0; //-1
+ } else if (normalized_rx_power<(target_rx_power - 4)) {
+ tpc = 2; //+1
+ } else {
+ tpc = 1; //0
+ }
- if (normalized_rx_power > (target_rx_power + 4)) {
- tpc = 0; //-1
- } else if (normalized_rx_power<(target_rx_power - 4)) {
- tpc = 2; //+1
- } else {
- tpc = 1; //0
- }
+ LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n",
+ module_idP,
+ frameP,
+ subframeP,
+ harq_pid,
+ tpc,
+ normalized_rx_power,
+ target_rx_power);
+ } else { // Po_PUCCH has been updated
+ tpc = 1; // 0
+ }
+ } else { // time to do TPC update
+ tpc = 1; //0
+ }
- LOG_D(MAC,"[eNB %d] DLSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, normalized/target rx power %d/%d\n",
- module_idP,
- frameP,
- subframeP,
- harq_pid,
- tpc,
- normalized_rx_power,
- target_rx_power);
- } else { // Po_PUCCH has been updated
- tpc = 1; // 0
- }
- } else { // time to do TPC update
- tpc = 1; //0
- }
-
- // Toggle NDI in first round
- UE_template->oldNDI[harq_pid] = 1 - UE_template->oldNDI[harq_pid];
- ue_sched_ctl->round[CC_id][harq_pid] = 0;
- round_DL = 0;
- } // if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0)
- }
-
- if (round_DL < 8) {
- /* Fill in MDPDCCH */
- memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
-
- dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
- dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 11 : 10;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = epdcch_setconfig_r11->transmissionType_r11;
-
- AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
-
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4; // t-CRNTI
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | ((epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1)<<5);
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = mcs; // adjust according to size of RAR, 208 bits with N1A_PRB=3
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0; // fix to 4 for now
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rvseq[round_DL&3];
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_template->oldNDI[harq_pid];
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 3;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
- dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
- dl_req->number_pdu++;
- UE_template->mcs[harq_pid] = dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs;
+ // Toggle NDI in first round
+ UE_template->oldNDI[harq_pid] = 1 - UE_template->oldNDI[harq_pid];
+ ue_sched_ctl->round[CC_id][harq_pid] = 0;
+ round_DL = 0;
+ } // if ((sdu_length_total + header_len_dcch + header_len_dtch) > 0)
}
- } else if ((subframeP == 7) && (round_DL < 8)) { // DLSCH
- LOG_D(MAC, "DLSCH round_DL = %d in frame %d subframe %d\n", round_DL, frameP, subframeP);
- int absSF = (frameP * 10) + subframeP;
-
- /* Have to check that MPDCCH was generated */
- LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating DLSCH (ce_level %d RNTI %x)\n",
- module_idP,
- CC_id,
- frameP,
- subframeP,
- UE_template->rach_resource_type - 1,
- rnti);
-
- first_rb = narrowband_to_first_rb(&cc[CC_id], epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
-
- dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
-
- memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
-
+ if (round_DL < 8) {
+ /* Fill in MDPDCCH */
+ memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
+ dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE;
+ dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 11 : 10;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_narrow_band = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_prb_pairs = 6;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mpdcch_tansmission_type = epdcch_setconfig_r11->transmissionType_r11;
+ AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL,
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.aggregation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti_type = 4; // t-CRNTI
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.rnti = rnti;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.transmission_power = 6000; // 0dB
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.resource_block_coding = getRIV (6, 0, 6) | ((epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1)<<5);
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs = mcs; // adjust according to size of RAR, 208 bits with N1A_PRB=3
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pdsch_reptition_levels = 0; // fix to 4 for now
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.redundancy_version = rvseq[round_DL&3];
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.new_data_indicator = UE_template->oldNDI[harq_pid];
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_process = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi_length = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpmi = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi_flag = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.pmi = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.harq_resource_offset = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.dci_subframe_repetition_number = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.tpc = 3;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index_length = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.downlink_assignment_index = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.allocate_prach_flag = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.preamble_index = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.prach_mask_index = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.starting_ce_level = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.srs_request = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity_flag = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.antenna_ports_and_scrambling_identity = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.frequency_hopping_enabled_flag = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.paging_direct_indication_differentiation_flag = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.direct_indication = 0;
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.total_dci_length_including_padding = 0; // this is not needed by OAI L1, but should be filled in
+ dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.number_of_tx_antenna_ports = 1;
+ dl_req->number_pdu++;
+ UE_template->mcs[harq_pid] = dl_config_pdu->mpdcch_pdu.mpdcch_pdu_rel13.mcs;
+ }
+ } else if ((subframeP == 7) && (round_DL < 8)) { // DLSCH
+ LOG_D(MAC, "DLSCH round_DL = %d in frame %d subframe %d\n", round_DL, frameP, subframeP);
+ int absSF = (frameP * 10) + subframeP;
+ /* Have to check that MPDCCH was generated */
+ LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Generating DLSCH (ce_level %d RNTI %x)\n",
+ module_idP,
+ CC_id,
+ frameP,
+ subframeP,
+ UE_template->rach_resource_type - 1,
+ rnti);
+ first_rb = narrowband_to_first_rb(&cc[CC_id], epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
+ dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
+ memset ((void *) dl_config_pdu, 0, sizeof (nfapi_dl_config_request_pdu_t));
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_dlsch_pdu));
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index = mac->pdu_index[CC_id];
@@ -2526,21 +2488,18 @@ schedule_ue_spec_br(module_id_t module_idP,
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.initial_transmission_sf_io = (10 * frameP) + subframeP;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel13.drms_table_flag = 0;
dl_req->number_pdu++;
-
// DL request
mac->TX_req[CC_id].sfn_sf = (frameP << 4) + subframeP;
TX_req = &mac->TX_req[CC_id].tx_request_body.tx_pdu_list[mac->TX_req[CC_id].tx_request_body.number_of_pdus];
- TX_req->pdu_length = get_TBS_DL(UE_template->mcs[harq_pid], 6);
+ TX_req->pdu_length = get_TBS_DL(UE_template->mcs[harq_pid], 6);
TX_req->pdu_index = mac->pdu_index[CC_id]++;
TX_req->num_segments = 1;
TX_req->segments[0].segment_length = TX_req->pdu_length;
TX_req->segments[0].segment_data = mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0];
mac->TX_req[CC_id].tx_request_body.number_of_pdus++;
-
ackNAK_absSF = absSF + 4;
ul_req = &mac->UL_req_tmp[CC_id][ackNAK_absSF % 10].ul_config_request_body;
ul_config_pdu = &ul_req->ul_config_pdu_list[ul_req->number_of_pdus];
-
ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_ul_config_uci_harq_pdu));
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this
@@ -2551,47 +2510,45 @@ schedule_ue_spec_br(module_id_t module_idP,
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel13.repetition_number = 0;
if (cc[CC_id].tdd_Config == NULL) { // FDD case
- ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[UE_template->rach_resource_type - 1];
- // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
- // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
- // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
- // Delta_ARO = 0 from Table 10.1.2.1-1
- ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK
- ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1;
+ ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0 = n1pucchan[UE_template->rach_resource_type - 1];
+ // NOTE: How to fill in the rest of the n_pucch_1_0 information 213 Section 10.1.2.1 in the general case
+ // = N_ECCE_q + Delta_ARO + n1pucchan[ce_level]
+ // higher in the MPDCCH configuration, N_ECCE_q is hard-coded to 0, and harq resource offset to 0 =>
+ // Delta_ARO = 0 from Table 10.1.2.1-1
+ ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.harq_size = 1; // 1-bit ACK/NAK
+ ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.number_of_pucch_resources = 1;
} else {
- AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
+ AssertFatal (1 == 0, "PUCCH configuration for ACK/NAK not handled yet for TDD BL/CE case\n");
}
ul_req->number_of_pdus++;
-
- T(T_ENB_MAC_UE_DL_PDU_WITH_DATA,
- T_INT (module_idP),
- T_INT (CC_id),
- T_INT (rnti),
- T_INT (frameP),
+ T(T_ENB_MAC_UE_DL_PDU_WITH_DATA,
+ T_INT (module_idP),
+ T_INT (CC_id),
+ T_INT (rnti),
+ T_INT (frameP),
T_INT (subframeP),
- T_INT (0 /* harq_pid always 0? */ ),
+ T_INT (0 /* harq_pid always 0? */ ),
T_BUFFER (&mac->UE_list.DLSCH_pdu[CC_id][0][UE_id].payload[0], TX_req->pdu_length));
if (opt_enabled == 1) {
- trace_pdu(1,
- (uint8_t *) mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0],
- TX_req->pdu_length,
- UE_id,
- 3,
- rnti,
- frameP,
- subframeP,
- 0,
+ trace_pdu(1,
+ (uint8_t *) mac->UE_list.DLSCH_pdu[CC_id][0][(unsigned char) UE_id].payload[0],
+ TX_req->pdu_length,
+ UE_id,
+ 3,
+ rnti,
+ frameP,
+ subframeP,
+ 0,
0);
-
- LOG_D(OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n",
- module_idP,
- CC_id,
- frameP,
- rnti,
+ LOG_D(OPT, "[eNB %d][DLSCH] CC_id %d Frame %d trace pdu for rnti %x with size %d\n",
+ module_idP,
+ CC_id,
+ frameP,
+ rnti,
TX_req->pdu_length);
- }
+ }
} // end else if ((subframeP == 7) && (round_DL < 8))
} // end loop on UE_id
}
@@ -2623,7 +2580,6 @@ fill_DLSCH_dci(module_id_t module_idP,
COMMON_channels_t *cc;
eNB_DLSCH_INFO *dlsch_info;
UE_TEMPLATE *ue_template;
-
start_meas(&eNB->fill_DLSCH_dci);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_FILL_DLSCH_DCI,
VCD_FUNCTION_IN);
@@ -2671,17 +2627,17 @@ fill_DLSCH_dci(module_id_t module_idP,
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti == rnti &&
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format != 1) {
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,
- N_RB_DL,
- N_RBG,
- rballoc_sub);
+ N_RB_DL,
+ N_RBG,
+ rballoc_sub);
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0;
} else if (dl_config_pdu->pdu_type == NFAPI_DL_CONFIG_DLSCH_PDU_TYPE &&
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.rnti == rnti &&
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type == 0) {
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = allocate_prbs_sub(nb_rb,
- N_RB_DL,
- N_RBG,
- rballoc_sub);
+ N_RB_DL,
+ N_RBG,
+ rballoc_sub);
}
}
}
@@ -2757,11 +2713,13 @@ update_ul_dci(module_id_t module_idP,
nfapi_hi_dci0_request_t *HI_DCI0_req = &eNB->HI_DCI0_req[CC_idP][subframe];
nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &HI_DCI0_req->hi_dci0_request_body.hi_dci0_pdu_list[0];
int limit = HI_DCI0_req->hi_dci0_request_body.number_of_dci + HI_DCI0_req->hi_dci0_request_body.number_of_hi;
+
for (int i = 0; i < limit; i++, hi_dci0_pdu++) {
if (hi_dci0_pdu->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE && hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti == rntiP)
hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = (daiP - 1) & 3;
}
}
+
return;
}
@@ -2838,8 +2796,7 @@ set_ue_dai(sub_frame_t subframeP,
void
schedule_PCH(module_id_t module_idP,
frame_t frameP,
- sub_frame_t subframeP)
-{
+ sub_frame_t subframeP) {
/* DCI:format 1A/1C P-RNTI:0xFFFE */
/* PDU:eNB_rrc_inst[Mod_idP].common_channels[CC_id].PCCH_pdu.payload */
uint16_t pcch_sdu_length;
@@ -2873,7 +2830,6 @@ schedule_PCH(module_id_t module_idP,
uint8_t Lcrbs = 0;
uint16_t rb_bit = 168; /* RB bit number value is unsure */
#endif
-
start_meas(&eNB->schedule_pch);
for (CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++) {
@@ -2884,6 +2840,7 @@ schedule_PCH(module_id_t module_idP,
for (uint16_t i = 0; i < MAX_MOBILES_PER_ENB; i++) {
ue_pf_po = &UE_PF_PO[CC_id][i];
+
if (ue_pf_po->enable_flag != TRUE) {
continue;
}
@@ -2913,8 +2870,8 @@ schedule_PCH(module_id_t module_idP,
CC_id,
i,
pcch_sdu_length);
-
#ifdef FORMAT1C
+
//NO SIB
if ((subframeP == 0 || subframeP == 1 || subframeP == 2 || subframeP == 4 || subframeP == 6 || subframeP == 9) ||
(subframeP == 5 && ((frameP % 2) != 0 && (frameP % 8) != 1))) {
@@ -3109,8 +3066,8 @@ schedule_PCH(module_id_t module_idP,
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = 1;
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 1;
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = getRIV(n_rb_dl,
- first_rb,
- 4);
+ first_rb,
+ 4);
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0;
#endif
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = 4;
@@ -3133,7 +3090,6 @@ schedule_PCH(module_id_t module_idP,
dl_req->tl.tag = NFAPI_DL_CONFIG_REQUEST_BODY_TAG;
eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP;
eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST;
-
dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
memset((void *)dl_config_pdu,
0,
@@ -3145,13 +3101,13 @@ schedule_PCH(module_id_t module_idP,
#ifdef FORMAT1C
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 3; // format 1C
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_vrb_dl / n_rb_step,
- first_rb / n_rb_step,
- Lcrbs / n_rb_step);
+ first_rb / n_rb_step,
+ Lcrbs / n_rb_step);
#else
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_allocation_type = 2; // format 1A/1B/1D
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.resource_block_coding = getRIV(n_rb_dl,
- first_rb,
- 4);
+ first_rb,
+ 4);
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.virtual_resource_block_assignment_flag = 0; // localized
#endif
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.modulation = 2; //QPSK
@@ -3249,8 +3205,7 @@ schedule_PCH(module_id_t module_idP,
static int
slice_priority_compare(const void *_a,
const void *_b,
- void *_c)
-{
+ void *_c) {
const int slice_id1 = *(const int *) _a;
const int slice_id2 = *(const int *) _b;
const module_id_t Mod_id = *(int *) _c;
@@ -3265,10 +3220,10 @@ slice_priority_compare(const void *_a,
void
slice_priority_sort(module_id_t Mod_id,
- int slice_list[MAX_NUM_SLICES])
-{
+ int slice_list[MAX_NUM_SLICES]) {
int i;
int n_dl = RC.mac[Mod_id]->slice_info.n_dl;
+
for (i = 0; i < n_dl; i++) {
slice_list[i] = i;
}
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c
index 4657493e59..724710b370 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_fairRR.c
@@ -40,6 +40,7 @@
#include "LAYER2/MAC/mac_extern.h"
#include "LAYER2/MAC/eNB_scheduler_fairRR.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
@@ -49,7 +50,7 @@
#include "T.h"
-extern uint8_t nfapi_mode;
+
#ifdef PHY_TX_THREAD
extern volatile int16_t phy_tx_txdataF_end;
extern int oai_exit;
@@ -841,7 +842,6 @@ schedule_ue_spec_fairRR(module_id_t module_idP,
#ifdef DEBUG_eNB_SCHEDULER
int k;
#endif
-
start_meas(&eNB->schedule_dlsch);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
(VCD_SIGNAL_DUMPER_FUNCTIONS_SCHEDULE_DLSCH, VCD_FUNCTION_IN);
@@ -1012,7 +1012,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP,
DevCheck(((eNB_UE_stats->dl_cqi < MIN_CQI_VALUE) || (eNB_UE_stats->dl_cqi > MAX_CQI_VALUE)),
eNB_UE_stats->dl_cqi, MIN_CQI_VALUE, MAX_CQI_VALUE);
*/
- if (nfapi_mode) {
+ if (NFAPI_MODE != NFAPI_MONOLITHIC) {
eNB_UE_stats->dlsch_mcs1 = 10;//cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]];
} else {
eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[ue_sched_ctl->dl_cqi[CC_id]];
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 1488209dd7..0d6b319f9b 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -36,6 +36,7 @@
#include "LAYER2/MAC/mac_proto.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
@@ -61,7 +62,7 @@ extern uint16_t frame_cnt;
#include "SCHED/sched_common.h"
extern RAN_CONTEXT_t RC;
-extern uint8_t nfapi_mode;
+
//------------------------------------------------------------------------------
int
@@ -165,6 +166,7 @@ mac_computeRIV(uint16_t N_RB_DL,
if (Lcrbs <= (1 + (N_RB_DL >> 1))) {
return (N_RB_DL * (Lcrbs - 1)) + RBstart;
}
+
return (N_RB_DL * (N_RB_DL + 1 - Lcrbs)) + (N_RB_DL - 1 - RBstart);
}
@@ -175,6 +177,7 @@ getQm(uint8_t mcs)
{
if (mcs < 10) return (2);
else if (mcs < 17) return (4);
+
return (6);
}
@@ -201,6 +204,7 @@ get_Msg3alloc(COMMON_channels_t *cc,
}
} else { // TDD
subframeAssignment = (int) cc->tdd_Config->subframeAssignment;
+
if (subframeAssignment == 1) {
switch (current_subframe) {
case 0:
@@ -287,6 +291,7 @@ get_Msg3alloc(COMMON_channels_t *cc,
}
}
}
+
return;
}
@@ -313,6 +318,7 @@ get_Msg3allocret(COMMON_channels_t *cc,
}
} else {
subframeAssignment = (int) cc->tdd_Config->subframeAssignment;
+
if (subframeAssignment == 1) {
// original PUSCH in 2, PHICH in 6 (S), ret in 2
// original PUSCH in 3, PHICH in 9, ret in 3
@@ -333,6 +339,7 @@ get_Msg3allocret(COMMON_channels_t *cc,
*frame = (current_frame + 1) & 1023;
}
}
+
return;
}
@@ -370,6 +377,7 @@ subframe2harqpid(COMMON_channels_t *cc,
break;
}
}
+
break;
case 2:
@@ -519,11 +527,11 @@ pdcchalloc2ulframe(COMMON_channels_t *ccP,
}
}
}
+
LOG_D(PHY, "frame %d subframe %d: PUSCH frame = %d\n",
frame,
n,
ul_frame);
-
return ul_frame;
}
@@ -617,6 +625,7 @@ is_UL_sf(COMMON_channels_t *ccP,
subframeP, (int) ccP->tdd_Config->subframeAssignment);
break;
}
+
return 0;
}
@@ -664,6 +673,7 @@ ul_subframe2_k_phich(COMMON_channels_t *cc,
return 4;
else if(ul_subframe == 3 || ul_subframe == 8)
return 6;
+
return 255;
case 2:
@@ -698,8 +708,10 @@ get_pucch1_absSF(COMMON_channels_t *cc,
case 0:
if (sf == 0 || sf == 5)
return ((10 * f) + sf + 4) % 10240; // ACK/NAK in SF 4,9 same frame
+
if (sf == 6)
return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 2 next frame
+
if (sf == 1)
return ((10 * f) + 7) % 10240; // ACK/NAK in SF 7 same frame
@@ -708,10 +720,13 @@ get_pucch1_absSF(COMMON_channels_t *cc,
case 1:
if (sf == 5 || sf == 6)
return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 2 next frame
+
if (sf == 9)
return ((10 * nextf) + 3) % 10240; // ACK/NAK in SF 3 next frame
+
if ((sf == 0) || (sf == 1))
return ((10 * f) + 7) % 10240; // ACK/NAK in SF 7 same frame
+
if (sf == 4)
return ((10 * f) + 8) % 10240; // ACK/NAK in SF 8 same frame
@@ -720,8 +735,10 @@ get_pucch1_absSF(COMMON_channels_t *cc,
case 2:
if (sf == 4 || sf == 5 || sf == 6 || sf == 8)
return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 2 next frame
+
if (sf == 9)
return ((10 * nextf) + 7) % 10240; // ACK/NAK in SF 7 next frame
+
if (sf == 0 || sf == 1 || sf == 3)
return ((10 * f) + 7)% 10240; // ACK/NAK in SF 7 same frame
@@ -730,8 +747,10 @@ get_pucch1_absSF(COMMON_channels_t *cc,
case 3:
if (sf == 5 || sf == 6 || sf == 7 || sf == 8 || sf == 9)
return ((10 * nextf) + ((sf - 1) >> 1)) % 10240; // ACK/NAK in 2,3,4 resp. next frame
+
if (sf == 1)
return ((10 * nextf) + 2) % 10240; // ACK/NAK in 2 next frame
+
if (sf == 0)
return ((10 * f) + 4) % 10240; // ACK/NAK in 4 same frame
@@ -748,6 +767,7 @@ get_pucch1_absSF(COMMON_channels_t *cc,
case 5:
if (sf == 0 || sf == 1 || sf == 3 || sf == 4 || sf == 5 || sf == 6 || sf == 7 || sf == 8)
return ((10 * nextf) + 2) % 10240; // ACK/NAK in SF 3 next frame
+
if (sf == 9)
return ((10 * (1 + nextf)) + 2) % 10240; // ACK/NAK in SF 2 next frame
@@ -756,8 +776,10 @@ get_pucch1_absSF(COMMON_channels_t *cc,
case 6:
if (sf == 5 || sf == 6)
return ((10 * f) + sf + 7) % 10240; // ACK/NAK in SF 2,3 next frame
+
if (sf == 9)
return ((10 * nextf) + 4) % 10240; // ACK/NAK in SF 4 next frame
+
if (sf == 1 || sf == 0)
return ((10 * f) + sf + 7) % 10240; // ACK/NAK in SF 7 same frame
@@ -837,6 +859,7 @@ get_srs_pos(COMMON_channels_t *cc,
AssertFatal(isrs <= 636, "Isrs out of range %d>636\n", isrs);
}
+
return;
}
@@ -850,7 +873,6 @@ get_csi_params(COMMON_channels_t *cc,
//------------------------------------------------------------------------------
{
AssertFatal(cqi_ReportPeriodic != NULL, "cqi_ReportPeriodic is null!\n");
-
uint16_t cqi_PMI_ConfigIndex = cqi_ReportPeriodic->choice.setup.cqi_pmi_ConfigIndex;
uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 };
@@ -919,6 +941,7 @@ get_csi_params(COMMON_channels_t *cc,
} else {
*H = 1;
}
+
return;
}
@@ -934,7 +957,6 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,
int N = Ntab[cc->mib->message.dl_Bandwidth];
int Ltab_uesel[6] = { 0, 6, 9, 13, 15, 18 };
int L = Ltab_uesel[cc->mib->message.dl_Bandwidth];
-
AssertFatal(cqi_ReportModeAperiodic != NULL, "cqi_ReportPeriodic is null!\n");
switch (*cqi_ReportModeAperiodic) {
@@ -945,10 +967,13 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,
if (ri == 1 && cc->p_eNB == 2)
return (4 + (N << 1));
+
if (ri == 2 && cc->p_eNB == 2)
return (8 + N);
+
if (ri == 1 && cc->p_eNB == 4)
return (4 + (N << 2));
+
if (ri > 1 && cc->p_eNB == 4)
return (8 + (N << 2));
@@ -997,16 +1022,19 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,
if (ri == 1 && cc->p_eNB == 2)
return (4 + (N << 1) + 0 + 0 + 2);
+
if (ri == 2 && cc->p_eNB == 2)
return (4 + (N << 1) + 4 + (N << 1) + 1);
+
if (ri == 1 && cc->p_eNB == 4)
return (4 + (N << 1) + 0 + 0 + 4);
+
if (ri >= 2 && cc->p_eNB == 4)
return (4 + (N << 1) + 4 + (N << 1) + 4);
break;
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(12, 5, 0))
+
case LTE_CQI_ReportModeAperiodic_rm32_v1250:
AssertFatal(tmode == 4 || tmode == 6 || tmode == 8 || tmode == 9 || tmode == 10, "Illegal TM (%d) for CQI_ReportModeAperiodic_rm32\n",
tmode);
@@ -1018,6 +1046,7 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,
// Table 5.2.2.6.1-1F/G (36.212)
if (ri == 1)
return 4; // F
+
return 7; // G
case LTE_CQI_ReportModeAperiodic_rm11_v1310:
@@ -1028,16 +1057,18 @@ get_dl_cqi_pmi_size_pusch(COMMON_channels_t *cc,
if (ri == 1 && cc->p_eNB == 2)
return (4 + 0 + 2);
+
if (ri == 2 && cc->p_eNB == 2)
return (4 + 4 + 1);
+
if (ri == 1 && cc->p_eNB == 4)
return (4 + 0 + 4);
+
if (ri > 1 && cc->p_eNB == 4)
return (4 + 4 + 4);
break;
#endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(12, 5, 0)) */
-
}
AssertFatal(1 == 0, "Shouldn't get here\n");
@@ -1057,7 +1088,6 @@ get_rel8_dl_cqi_pmi_size(UE_sched_ctrl *sched_ctl,
// Ltab[6] = {0,log2(15/4/2),log2(25/4/2),log2(50/6/3),log2(75/8/4),log2(100/8/4)};
uint8_t Ltab[6] = { 0, 1, 2, 2, 2, 2 };
uint8_t ri = sched_ctl->periodic_ri_received[CC_idP];
-
AssertFatal(cqi_ReportPeriodic != NULL, "cqi_ReportPeriodic is null!\n");
AssertFatal(cqi_ReportPeriodic->present != LTE_CQI_ReportPeriodic_PR_NOTHING, "cqi_ReportPeriodic->present == CQI_ReportPeriodic_PR_NOTHING!\n");
AssertFatal(cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present != LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING,
@@ -1081,16 +1111,22 @@ get_rel8_dl_cqi_pmi_size(UE_sched_ctrl *sched_ctl,
sched_ctl->feedback_cnt[CC_idP] == 0) {
// send wideband report every opportunity if wideband reporting mode is selected, else every H opportunities
if (no_pmi == 1) return 4;
+
if (cc->p_eNB == 2 && ri == 1) return 6;
+
if (cc->p_eNB == 2 && ri == 2) return 8;
+
if (cc->p_eNB == 4 && ri == 1) return 8;
+
if (cc->p_eNB == 4 && ri == 2) return 11;
+
AssertFatal(1 == 0, "illegal combination p %d, ri %d, no_pmi %d\n",
cc->p_eNB,
ri,
no_pmi);
} else if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_subbandCQI) {
if (no_pmi == 1 || ri == 1) return (4 + Ltab[cc->mib->message.dl_Bandwidth]);
+
return (7 + Ltab[cc->mib->message.dl_Bandwidth]);
}
@@ -1115,7 +1151,6 @@ fill_nfapi_dl_dci_1A(nfapi_dl_config_request_pdu_t *dl_config_pdu,
//------------------------------------------------------------------------------
{
memset((void *) dl_config_pdu, 0,sizeof(nfapi_dl_config_request_pdu_t));
-
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dci_dl_pdu));
dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DCI_DL_PDU_REL8_TAG;
@@ -1155,6 +1190,7 @@ program_dlsch_acknak(module_id_t module_idP,
nfapi_ul_config_harq_information *harq_information = NULL;
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 2, 0))
struct LTE_PhysicalConfigDedicated__ext2 *ext2 = UE_list->UE_template[CC_idP][UE_idP].physicalConfigDedicated->ext2;
+
if (ext2 &&
ext2->pucch_ConfigDedicated_v1020 &&
ext2->pucch_ConfigDedicated_v1020->simultaneousPUCCH_PUSCH_r10 &&
@@ -1297,6 +1333,7 @@ program_dlsch_acknak(module_id_t module_idP,
ulsch_harq_information,
subframeP);
}
+
if (harq_information) {
fill_nfapi_harq_information(module_idP,
CC_idP,
@@ -1304,6 +1341,7 @@ program_dlsch_acknak(module_id_t module_idP,
harq_information,
cce_idx);
}
+
return;
}
@@ -1341,19 +1379,15 @@ fill_nfapi_ulsch_harq_information(module_id_t module_
COMMON_channels_t *cc = &eNB->common_channels[CC_idP];
UE_list_t *UE_list = &eNB->UE_list;
int UE_id = find_UE_id(module_idP, rntiP);
- nfapi_ul_config_ulsch_harq_information_rel10_t* harq_information_rel10 = &harq_information->harq_information_rel10;
-
+ nfapi_ul_config_ulsch_harq_information_rel10_t *harq_information_rel10 = &harq_information->harq_information_rel10;
AssertFatal(UE_id >= 0, "UE_id cannot be found, impossible\n");
AssertFatal(UE_list != NULL, "UE_list is null\n");
-
LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated;
AssertFatal(physicalConfigDedicated != NULL, "physicalConfigDedicated for rnti %x is null\n",
rntiP);
-
struct LTE_PUSCH_ConfigDedicated *puschConfigDedicated = physicalConfigDedicated->pusch_ConfigDedicated;
AssertFatal(puschConfigDedicated != NULL, "physicalConfigDedicated->puschConfigDedicated for rnti %x is null\n",
rntiP);
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 2, 0))
/* if (UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2) puschConfigDedicated_v1020 = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->ext2->pusch_ConfigDedicated_v1020;
#endif
@@ -1365,10 +1399,8 @@ fill_nfapi_ulsch_harq_information(module_id_t module_
#endif
*/
#endif
-
harq_information_rel10->delta_offset_harq = puschConfigDedicated->betaOffset_ACK_Index;
harq_information_rel10->tl.tag = NFAPI_UL_CONFIG_REQUEST_ULSCH_HARQ_INFORMATION_REL10_TAG;
-
struct LTE_PUCCH_ConfigDedicated *pucch_ConfigDedicated = physicalConfigDedicated->pucch_ConfigDedicated;
AssertFatal(pucch_ConfigDedicated != NULL, "pucch_ConfigDedicated is null!\n");
@@ -1389,9 +1421,9 @@ fill_nfapi_ulsch_harq_information(module_id_t module_
else {
if (harq_information_rel10->ack_nack_mode == 1)
harq_information_rel10->harq_size = get_V_UL_DAI(module_idP,
- CC_idP,
- rntiP,
- subframeP);
+ CC_idP,
+ rntiP,
+ subframeP);
else
harq_information_rel10->harq_size = 1;
}
@@ -1404,15 +1436,16 @@ fill_nfapi_ulsch_harq_information(module_id_t module_
} else {
if (harq_information_rel10->ack_nack_mode == 1)
harq_information_rel10->harq_size = get_V_UL_DAI(module_idP,
- CC_idP,
- rntiP,
- subframeP);
+ CC_idP,
+ rntiP,
+ subframeP);
else
harq_information_rel10->harq_size = 2;
}
break;
} // get Tmode
+
return;
}
@@ -1439,11 +1472,13 @@ getNp(int dl_Bandwidth,
AssertFatal(dl_Bandwidth < 6, "dl_Bandwidth %d>5\n", dl_Bandwidth);
if (nCCE >= Np[dl_Bandwidth][2]) {
- return(Np[dl_Bandwidth][2+plus1]);
+ return(Np[dl_Bandwidth][2+plus1]);
}
- if (nCCE >= Np[dl_Bandwidth][1]) {
+
+ if (nCCE >= Np[dl_Bandwidth][1]) {
return(Np[dl_Bandwidth][1+plus1]);
}
+
return(Np[dl_Bandwidth][0+plus1]);
}
@@ -1459,17 +1494,15 @@ fill_nfapi_harq_information(module_id_t module_idP,
eNB_MAC_INST *eNB = RC.mac[module_idP];
COMMON_channels_t *cc = &eNB->common_channels[CC_idP];
UE_list_t *UE_list = &eNB->UE_list;
-
int UE_id = find_UE_id(module_idP,
rntiP);
-
AssertFatal(UE_id >= 0, "UE_id cannot be found, impossible\n");
AssertFatal(UE_list != NULL, "UE_list is null\n");
harq_information->harq_information_rel11.tl.tag = NFAPI_UL_CONFIG_REQUEST_HARQ_INFORMATION_REL11_TAG;
harq_information->harq_information_rel11.num_ant_ports = 1;
-
LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated;
struct LTE_PUCCH_ConfigDedicated *pucch_ConfigDedicated = NULL;
+
if (physicalConfigDedicated != NULL) pucch_ConfigDedicated = physicalConfigDedicated->pucch_ConfigDedicated;
switch (get_tmode(module_idP,
@@ -1531,6 +1564,7 @@ fill_nfapi_harq_information(module_id_t module_idP,
break;
} // get Tmode
+
return;
}
@@ -1550,13 +1584,11 @@ fill_nfapi_uci_acknak(module_id_t module_idP,
nfapi_ul_config_request_body_t *ul_req_body = &ul_req->ul_config_request_body;
nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req_body->ul_config_pdu_list[ul_req_body->number_of_pdus];
memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t));
-
ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE;
ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_uci_harq_pdu));
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_UE_INFORMATION_REL8_TAG;
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.handle = 0; // don't know how to use this
ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti = rntiP;
-
fill_nfapi_harq_information(module_idP,
CC_idP,
rntiP,
@@ -1570,7 +1602,6 @@ fill_nfapi_uci_acknak(module_id_t module_idP,
ackNAK_absSF % 10,
cce_idxP,
ul_config_pdu->uci_harq_pdu.harq_information.harq_information_rel9_fdd.n_pucch_1_0);
-
ul_req_body->number_of_pdus++;
ul_req_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
ul_req->header.message_id = NFAPI_UL_CONFIG_REQUEST;
@@ -1609,7 +1640,6 @@ fill_nfapi_dlsch_config(eNB_MAC_INST *eNB,
{
nfapi_dl_config_request_pdu_t *dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu];
memset((void *) dl_config_pdu, 0, sizeof(nfapi_dl_config_request_pdu_t));
-
dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DLSCH_PDU_TYPE;
dl_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_dl_config_dlsch_pdu));
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.tl.tag = NFAPI_DL_CONFIG_REQUEST_DLSCH_PDU_REL8_TAG;
@@ -1635,7 +1665,6 @@ fill_nfapi_dlsch_config(eNB_MAC_INST *eNB,
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.transmission_mode = transmission_mode;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_prb_per_subband = num_bf_prb_per_subband;
dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.num_bf_vector = num_bf_vector;
-
dl_req->number_pdu++;
return;
}
@@ -1650,11 +1679,9 @@ fill_nfapi_tx_req(nfapi_tx_request_body_t *tx_req_body,
//------------------------------------------------------------------------------
{
nfapi_tx_request_pdu_t *TX_req = &tx_req_body->tx_pdu_list[tx_req_body->number_of_pdus];
-
LOG_D(MAC, "Filling TX_req %d for pdu length %d\n",
tx_req_body->number_of_pdus,
pdu_length);
-
TX_req->pdu_length = pdu_length;
TX_req->pdu_index = pdu_index;
TX_req->num_segments = 1;
@@ -1686,10 +1713,8 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd
uint8_t ul_tx_mode,
uint8_t current_tx_nb,
uint8_t n_srs,
- uint16_t size)
-{
+ uint16_t size) {
uint8_t ri_size = 0;
-
memset((void *) ul_config_pdu, 0, sizeof(nfapi_ul_config_request_pdu_t));
ul_config_pdu->pdu_type = NFAPI_UL_CONFIG_ULSCH_PDU_TYPE;
ul_config_pdu->pdu_size = (uint8_t) (2 + sizeof(nfapi_ul_config_ulsch_pdu));
@@ -1728,14 +1753,14 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd
if (cc->p_eNB <= 2 && (tmode == 3 || tmode == 4 || tmode == 8 || tmode == 9 || tmode == 10)) ri_size = 1;
else if (cc->p_eNB <= 2) ri_size = 0;
else if (cc->p_eNB == 4) ri_size = 2;
- ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = ri_size;
+ ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9.aperiodic_cqi_pmi_ri_report.cc[0].ri_size = ri_size;
AssertFatal(physicalConfigDedicated->cqi_ReportConfig != NULL,"physicalConfigDedicated->cqi_ReportConfig is null!\n");
AssertFatal(physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic != NULL,"physicalConfigDedicated->cqi_ReportModeAperiodic is null!\n");
AssertFatal(physicalConfigDedicated->pusch_ConfigDedicated != NULL,"physicalConfigDedicated->puschConfigDedicated is null!\n");
-
nfapi_ul_config_cqi_ri_information_rel9_t *ri_information = &ul_config_pdu->ulsch_cqi_ri_pdu.cqi_ri_information.cqi_ri_information_rel9;
int max_ri = (1 << ri_information->aperiodic_cqi_pmi_ri_report.cc[0].ri_size);
+
for (int ri = 0; ri < max_ri; ri++) {
ri_information->aperiodic_cqi_pmi_ri_report.cc[0].dl_cqi_pmi_size[ri]
= get_dl_cqi_pmi_size_pusch(cc,
@@ -1743,9 +1768,11 @@ fill_nfapi_ulsch_config_request_rel8(nfapi_ul_config_request_pdu_t *ul_config_pd
1 + ri,
physicalConfigDedicated->cqi_ReportConfig->cqi_ReportModeAperiodic);
}
+
ri_information->delta_offset_cqi = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_CQI_Index;
ri_information->delta_offset_ri = physicalConfigDedicated->pusch_ConfigDedicated->betaOffset_RI_Index;
}
+
return;
}
@@ -1862,6 +1889,7 @@ mpdcch_sf_condition(eNB_MAC_INST *eNB,
AssertFatal(T > 0, "T is 0!\n");
if (((10 * frameP) + subframeP) % T == 0) return 1;
+
return 0;
}
@@ -1884,16 +1912,19 @@ narrowband_to_first_rb(COMMON_channels_t *cc,
case 1: // 15 PRBs N_NB=2, i_0=1
if (nb_index > 0)
return 1;
+
return 0;
case 2: // 25 PRBs, N_NB=4, i_0=0
if (nb_index > 1)
return (1 + (6 * nb_index));
+
return ((6 * nb_index));
case 4: // 75 PRBs, N_NB=12, i_0=1
if (nb_index > 5)
return (2 + (6 * nb_index));
+
return (1 + (6 * nb_index));
default:
@@ -1901,6 +1932,7 @@ narrowband_to_first_rb(COMMON_channels_t *cc,
(int) cc->mib->message.dl_Bandwidth);
break;
}
+
return 0;
}
#endif
@@ -1927,6 +1959,7 @@ init_ue_sched_info(void)
}
}
}
+
return;
}
@@ -2011,7 +2044,7 @@ UE_RNTI(module_id_t mod_idP,
if (!RC.mac || !RC.mac[mod_idP]) return 0;
rnti_t rnti = RC.mac[mod_idP]->UE_list.UE_template[UE_PCCID(mod_idP,
- ue_idP)][ue_idP].rnti;
+ ue_idP)][ue_idP].rnti;
if (rnti > 0) {
return (rnti);
@@ -2076,7 +2109,6 @@ get_aggregation(uint8_t bw_index,
cqi,
bw_index,
dci_fmt);
-
return 1 << aggregation;
}
@@ -2101,6 +2133,7 @@ dump_ue_list(UE_list_t *listP,
listP->next_ul[j]);
}
}
+
return;
}
@@ -2111,22 +2144,20 @@ add_new_ue(module_id_t mod_idP,
rnti_t rntiP,
int harq_pidP
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- , uint8_t rach_resource_type
+ , uint8_t rach_resource_type
#endif
- )
+ )
//------------------------------------------------------------------------------
{
int UE_id;
int i, j;
UE_list_t *UE_list = &RC.mac[mod_idP]->UE_list;
-
LOG_D(MAC, "[eNB %d, CC_id %d] Adding UE with rnti %x (next avail %d, num_UEs %d)\n",
mod_idP,
cc_idP,
rntiP,
UE_list->avail,
UE_list->num_UEs);
-
dump_ue_list(UE_list, 0);
for (i = 0; i < MAX_MOBILES_PER_ENB; i++) {
@@ -2135,7 +2166,6 @@ add_new_ue(module_id_t mod_idP,
UE_id = i;
memset(&UE_list->UE_template[cc_idP][UE_id], 0, sizeof(UE_TEMPLATE));
-
UE_list->UE_template[cc_idP][UE_id].rnti = rntiP;
UE_list->UE_template[cc_idP][UE_id].configured = FALSE;
UE_list->numactiveCCs[UE_id] = 1;
@@ -2145,14 +2175,12 @@ add_new_ue(module_id_t mod_idP,
UE_list->ordered_ULCCids[0][UE_id] = cc_idP;
UE_list->num_UEs++;
UE_list->active[UE_id] = TRUE;
-
#if defined(USRP_REC_PLAY) // not specific to record/playback ?
UE_list->UE_template[cc_idP][UE_id].pre_assigned_mcs_ul = 0;
#endif
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
UE_list->UE_template[cc_idP][UE_id].rach_resource_type = rach_resource_type;
#endif
-
memset((void *) &UE_list->UE_sched_ctrl[UE_id],
0,
sizeof(UE_sched_ctrl));
@@ -2223,13 +2251,13 @@ rrc_mac_remove_ue(module_id_t mod_idP,
if (UE_list->head == UE_id) UE_list->head = UE_list->next[UE_id];
else UE_list->next[prev(UE_list,
- UE_id,
- 0)] = UE_list->next[UE_id];
+ UE_id,
+ 0)] = UE_list->next[UE_id];
if (UE_list->head_ul == UE_id) UE_list->head_ul = UE_list->next_ul[UE_id];
else UE_list->next_ul[prev(UE_list,
- UE_id,
- 0)] = UE_list->next_ul[UE_id];
+ UE_id,
+ 0)] = UE_list->next_ul[UE_id];
// clear all remaining pending transmissions
/* UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID0] = 0;
@@ -2244,7 +2272,6 @@ rrc_mac_remove_ue(module_id_t mod_idP,
memset (&UE_list->UE_template[pCC_id][UE_id],
0,
sizeof(UE_TEMPLATE));
-
ue_stats = &UE_list->eNB_UE_stats[pCC_id][UE_id];
ue_stats->total_rbs_used = 0;
ue_stats->total_rbs_used_retx = 0;
@@ -2513,6 +2540,7 @@ UE_is_to_be_scheduled(module_id_t module_idP,
UE_template->ul_buffer_info[LCGID0], UE_template->ul_SR);
return 1;
}
+
return 0;
}
@@ -2537,9 +2565,8 @@ get_tmode(module_id_t module_idP,
"antennaInfo (mod_id %d) is null for CCId %d, UEid %d, physicalConfigDedicated %p\n",
module_idP,
CC_idP,
- UE_idP,
+ UE_idP,
physicalConfigDedicated);
-
AssertFatal(physicalConfigDedicated->antennaInfo->present != LTE_PhysicalConfigDedicated__antennaInfo_PR_NOTHING,
"antennaInfo (mod_id %d, CC_id %d) is set to NOTHING\n",
module_idP,
@@ -2799,6 +2826,7 @@ allocate_prbs_sub(int nb_rb,
} else {
nb_rb -= 2;
}
+
break;
case 50:
@@ -2807,6 +2835,7 @@ allocate_prbs_sub(int nb_rb,
} else {
nb_rb -= 3;
}
+
break;
case 100:
@@ -2888,8 +2917,7 @@ init_CCE_table(int module_idP,
}
*/
void
-init_CCE_table(int *CCE_table)
-{
+init_CCE_table(int *CCE_table) {
memset(CCE_table, 0, 800 * sizeof(int));
}
@@ -2935,12 +2963,14 @@ get_nCCE_offset(int *CCE_table,
for (l = 0; l < L; l++) {
CCE_table[(m * L) + l] = 1;
}
+
return (m * L);
}
}
return -1;
}
+
// Find first available in ue specific search space
// according to procedure in Section 9.1.1 of 36.213 (v. 8.6)
// compute Yk
@@ -2949,6 +2979,7 @@ get_nCCE_offset(int *CCE_table,
for (i = 0; i <= subframe; i++) {
Yk = (Yk * 39827) % 65537;
}
+
Yk = Yk % (nCCE / L);
switch (L) {
@@ -2992,6 +3023,7 @@ get_nCCE_offset(int *CCE_table,
for (l = 0; l < L; l++) {
CCE_table[(((Yk + m) % (nCCE / L)) * L) + l] = 1;
}
+
return (((Yk + m) % (nCCE / L)) * L);
}
}
@@ -3025,6 +3057,7 @@ dump_CCE_table(int *CCE_table,
for (i = 0; i <= subframe; i++) {
Yk = (Yk * 39827) % 65537;
}
+
Yk = Yk % (nCCE / L);
switch (L) {
@@ -3044,11 +3077,11 @@ dump_CCE_table(int *CCE_table,
}
LOG_I(PHY, "rnti %x, Yk*L = %u, nCCE %d (nCCE/L %d),nb_cand*L %d\n",
- rnti,
- Yk * L,
- nCCE,
- nCCE / L,
- nb_candidates * L);
+ rnti,
+ Yk * L,
+ nCCE,
+ nCCE / L,
+ nb_candidates * L);
}
//------------------------------------------------------------------------------
@@ -3068,6 +3101,7 @@ getnquad(COMMON_channels_t *cc,
if (((phich_resource * N_RB_DL) % 48) > 0) {
Ngroup_PHICH++;
}
+
if (cc->Ncp == 1) {
Ngroup_PHICH <<= 1;
}
@@ -3131,36 +3165,42 @@ getmi(COMMON_channels_t *cc,
if (subframe == 0 || subframe == 5) {
return 2;
}
+
return 1;
case 1:
if (subframe == 0 || subframe == 5) {
return 0;
}
+
return 1;
case 2:
if (subframe == 3 || subframe == 8) {
return 0;
}
+
return 1;
case 3:
if (subframe == 0 || subframe == 8 || subframe == 9) {
return 1;
}
+
return 0;
case 4:
if (subframe == 8 || subframe == 9) {
return 1;
}
+
return 0;
case 5:
if (subframe == 8) {
return 1;
}
+
return 0;
case 6:
@@ -3169,6 +3209,7 @@ getmi(COMMON_channels_t *cc,
default:
break;
}
+
return 0;
}
@@ -3225,14 +3266,13 @@ allocate_CCEs(int module_idP,
DL_req->number_dci,
HI_DCI0_req->number_of_dci);
DL_req->number_pdcch_ofdm_symbols = 1;
-
try_again:
-
init_CCE_table(CCE_table);
nCCE = 0;
for (i = 0, idci = 0; i < DL_req->number_pdu; i++) {
dl_config_pduLoop = &dl_config_pdu[i];
+
// allocate DL common DCIs first
if (dl_config_pduLoop->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE &&
dl_config_pduLoop->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 2) {
@@ -3274,6 +3314,7 @@ try_again:
for (j = 0; j <= i; j++) {
dl_config_pduLoop = &dl_config_pdu[j];
+
if (dl_config_pduLoop->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
j,
@@ -3285,6 +3326,7 @@ try_again:
dl_config_pduLoop->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,
nCCE, nCCE_max, DL_req->number_pdcch_ofdm_symbols);
}
+
//dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<L);
return -1;
}
@@ -3316,6 +3358,7 @@ try_again:
// no try to allocate UL DCIs
for (i = 0; i < HI_DCI0_req->number_of_dci + HI_DCI0_req->number_of_hi; i++) {
hi_dci0_pduLoop = &hi_dci0_pdu[i];
+
// allocate UL DCIs
if (hi_dci0_pdu[i].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) {
LOG_D(MAC, "Trying to allocate format 0 DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
@@ -3355,6 +3398,7 @@ try_again:
for (j = 0; j <= i; j++) {
hi_dci0_pduLoop = &hi_dci0_pdu[j];
+
if (hi_dci0_pdu[j].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE)
LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
j,
@@ -3366,6 +3410,7 @@ try_again:
hi_dci0_pduLoop->dci_pdu.dci_pdu_rel8.aggregation_level,
nCCE, nCCE_max, DL_req->number_pdcch_ofdm_symbols);
}
+
//dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<L);
return -1;
}
@@ -3395,6 +3440,7 @@ try_again:
for (i = 0; i < DL_req->number_pdu; i++) {
dl_config_pduLoop = &dl_config_pdu[i];
+
// allocate DL UE specific DCIs
if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
&& (dl_config_pduLoop->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type == 1)) {
@@ -3435,6 +3481,7 @@ try_again:
for (j = 0; j <= i; j++) {
dl_config_pduLoop = &dl_config_pdu[j];
+
if (dl_config_pduLoop->pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
LOG_D(MAC, "DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
j,
@@ -3448,6 +3495,7 @@ try_again:
nCCE_max,
DL_req->number_pdcch_ofdm_symbols);
}
+
//dump_CCE_table(CCE_table,nCCE_max,subframeP,dci_alloc->rnti,1<L);
return -1;
}
@@ -3489,6 +3537,7 @@ try_again:
idci++;
}
} // for i = 0 ... num_DL_DCIs
+
return 0;
}
@@ -3503,7 +3552,6 @@ has_ul_grant(module_id_t module_idP,
nfapi_ul_config_request_body_t *ul_req = &RC.mac[module_idP]->UL_req_tmp[CC_idP][absSFP % 10].ul_config_request_body;
nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req->ul_config_pdu_list[0];
uint8_t pdu_type;
-
LOG_D(MAC, "Checking for rnti %x UL grant in subframeP %d (num pdu %d)\n",
rnti,
absSFP % 10,
@@ -3593,6 +3641,7 @@ CCE_allocation_infeasible(int module_idP,
if (allocate_CCEs(module_idP, CC_idP, 0, subframe, 0) != -1)
res = FALSE;
+
DL_req->number_pdu--;
}
} else { // ue-specific UL DCI
@@ -3607,6 +3656,7 @@ CCE_allocation_infeasible(int module_idP,
if (allocate_CCEs(module_idP, CC_idP, 0, subframe, 0) != -1)
res = FALSE;
+
HI_DCI0_req->number_of_dci--;
}
}
@@ -3625,6 +3675,7 @@ get_retransmission_timing(LTE_TDD_Config_t *tdd_Config,
if (*subframeP > 1) {
*frameP = (*frameP + 1) % 1024;
}
+
*subframeP = (*subframeP + 8) % 10;
} else {
switch (tdd_Config->subframeAssignment) { //TODO fill in other TDD configs
@@ -3649,9 +3700,11 @@ get_retransmission_timing(LTE_TDD_Config_t *tdd_Config,
*subframeP,
tdd_Config->subframeAssignment);
}
+
break;
}
}
+
return;
}
@@ -3717,34 +3770,39 @@ ul_ACK_subframe2M(LTE_TDD_Config_t *tdd_Config,
if (tdd_Config == NULL) {
return 1;
}
+
switch (tdd_Config->subframeAssignment) {
case 1:
return 1; // don't ACK special subframe for now
- /*
- if (subframe == 2) { // ACK subframes 5 and 6
- return(2);
- } else if (subframe == 3) { // ACK subframe 9
- return(1); // To be updated
- } else if (subframe == 7) { // ACK subframes 0 and 1
- return(2); // To be updated
- } else if (subframe == 8) { // ACK subframe 4
- return(1); // To be updated
- } else {
- AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n",
- subframe,tdd_Config->subframeAssignment);
- }
- break;
- */
+
+ /*
+ if (subframe == 2) { // ACK subframes 5 and 6
+ return(2);
+ } else if (subframe == 3) { // ACK subframe 9
+ return(1); // To be updated
+ } else if (subframe == 7) { // ACK subframes 0 and 1
+ return(2); // To be updated
+ } else if (subframe == 8) { // ACK subframe 4
+ return(1); // To be updated
+ } else {
+ AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n",
+ subframe,tdd_Config->subframeAssignment);
+ }
+ break;
+ */
case 3:
if (subframe == 2) { // ACK subframes 5 and 6
return 2; // should be 3
}
+
if (subframe == 3) { // ACK subframes 7 and 8
return 2; // To be updated
}
+
if (subframe == 4) { // ACK subframes 9 and 0
return 2;
}
+
AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n",
subframe,
tdd_Config->subframeAssignment);
@@ -3754,9 +3812,11 @@ ul_ACK_subframe2M(LTE_TDD_Config_t *tdd_Config,
if (subframe == 2) { // ACK subframes 0,4 and 5
return 3; // should be 4
}
+
if (subframe == 3) { // ACK subframes 6,7,8 and 9
return 4;
}
+
AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n",
subframe,
tdd_Config->subframeAssignment);
@@ -3766,6 +3826,7 @@ ul_ACK_subframe2M(LTE_TDD_Config_t *tdd_Config,
if (subframe == 2) { // ACK subframes 0,3,4,5,6,7,8 and 9
return 8; // should be 3
}
+
AssertFatal(1==0,"illegal subframe %d for tdd_config %ld\n",
subframe,
tdd_Config->subframeAssignment);
@@ -3790,14 +3851,18 @@ ul_ACK_subframe2dl_subframe(LTE_TDD_Config_t *tdd_Config,
case 3:
if (subframe == 2) { // ACK subframes 5 and 6
if (ACK_index == 2) return 1;
+
return (5 + ACK_index);
}
+
if (subframe == 3) { // ACK subframes 7 and 8
return (7 + ACK_index); // To be updated
}
+
if (subframe == 4) { // ACK subframes 9 and 0
return ((9 + ACK_index) % 10);
}
+
AssertFatal(1==0, "illegal subframe %d for tdd_config->subframeAssignment %ld\n",
subframe,
tdd_Config->subframeAssignment);
@@ -3808,11 +3873,14 @@ ul_ACK_subframe2dl_subframe(LTE_TDD_Config_t *tdd_Config,
//if (ACK_index==2)
// return(1); TBC
if (ACK_index == 2) return 0;
+
return (4 + ACK_index);
}
+
if (subframe == 3) { // ACK subframes 6, 7 8 and 9
return (6 + ACK_index); // To be updated
}
+
AssertFatal(1 == 0, "illegal subframe %d for tdd_config %ld\n",
subframe,
tdd_Config->subframeAssignment);
@@ -3822,20 +3890,25 @@ ul_ACK_subframe2dl_subframe(LTE_TDD_Config_t *tdd_Config,
if (subframe == 2) { // ACK subframes 5 and 6
return (5 + ACK_index);
}
+
if (subframe == 3) { // ACK subframe 9
return 9; // To be updated
}
+
if (subframe == 7) { // ACK subframes 0 and 1
return ACK_index; // To be updated
}
+
if (subframe == 8) { // ACK subframe 4
return 4; // To be updated
}
+
AssertFatal(1 == 0, "illegal subframe %d for tdd_config %ld\n",
subframe,
tdd_Config->subframeAssignment);
break;
}
+
return 0;
}
@@ -3867,15 +3940,16 @@ extract_harq(module_id_t mod_idP,
sub_frame_t subframe_tx;
int frame_tx;
uint8_t harq_pid;
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 0, 0))
LTE_PhysicalConfigDedicated_t *physicalConfigDedicated = UE_list->UE_template[pCCid][UE_id].physicalConfigDedicated;
+
if (physicalConfigDedicated != NULL && physicalConfigDedicated->pucch_ConfigDedicated != NULL &&
physicalConfigDedicated->ext7 != NULL && physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13 != NULL &&
((physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13->spatialBundlingPUCCH_r13 && format == 0) ||
(physicalConfigDedicated->ext7->pucch_ConfigDedicated_r13->spatialBundlingPUSCH_r13 && format == 1))) {
spatial_bundling = 1;
}
+
#endif
for (i = 0; i < numCC; i++) {
@@ -3883,6 +3957,7 @@ extract_harq(module_id_t mod_idP,
i,
UE_id);
}
+
if (cc->tdd_Config) {
harq_indication_tdd = (nfapi_harq_indication_tdd_rel13_t *) harq_indication;
// pdu = &harq_indication_tdd->harq_tb_n[0];
@@ -3897,8 +3972,8 @@ extract_harq(module_id_t mod_idP,
for (m=0; mtdd_Config,
- subframeP,
- m);
+ subframeP,
+ m);
if (frameP==1023&&subframeP>5) frame_tx=-1;
else frame_tx = subframeP < 4 ? frameP -1 : frameP;
@@ -3943,8 +4018,8 @@ extract_harq(module_id_t mod_idP,
LOG_I(RRC, "put UE %x into freeList\n",
rnti);
put_UE_in_freelist(mod_idP,
- rnti,
- 1);
+ rnti,
+ 1);
}
}
}
@@ -3973,6 +4048,7 @@ extract_harq(module_id_t mod_idP,
ra[ra_i].rnti);
}
}
+
break;
}
}
@@ -4017,7 +4093,7 @@ extract_harq(module_id_t mod_idP,
// In case of nFAPI, sometimes timing of eNB and UE become different.
// So if nfapi_mode == 2(VNF), this function don't check assertion to avoid process exit.
- if (nfapi_mode != 2) {
+ if (NFAPI_MODE != NFAPI_MODE_VNF) {
AssertFatal(sched_ctl->round[CC_idP][harq_pid] < 8, "Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n",
harq_pid,
UE_id,
@@ -4037,11 +4113,9 @@ extract_harq(module_id_t mod_idP,
harq_pid,
UE_id,
rnti);
-
LOG_D(MAC, "Received %d for harq_pid %d\n",
pdu[0],
harq_pid);
-
RA_t *ra = &eNB->common_channels[CC_idP].ra[0];
for (uint8_t ra_i = 0; ra_i < NB_RA_PROC_MAX; ra_i++) {
@@ -4066,6 +4140,7 @@ extract_harq(module_id_t mod_idP,
ra[ra_i].rnti);
}
}
+
break;
}
}
@@ -4441,6 +4516,7 @@ extract_harq(module_id_t mod_idP,
UE_id,
rnti);
}
+
j++;
} else {
AssertFatal(1 == 0, "Illegal value for spatial_bundling %d\n",
@@ -4460,6 +4536,7 @@ extract_harq(module_id_t mod_idP,
break;
}
}
+
return;
}
@@ -4481,7 +4558,6 @@ extract_pucch_csi(module_id_t mod_idP,
uint8_t Ltab[6] = { 0, 2, 4, 4, 4, 4 };
uint8_t Jtab[6] = { 0, 2, 2, 3, 4, 4 };
int feedback_cnt;
-
AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated != NULL, "physicalConfigDedicated is null for UE %d\n",
UE_id);
AssertFatal(UE_list->UE_template[CC_idP][UE_id].physicalConfigDedicated->cqi_ReportConfig != NULL, "cqi_ReportConfig is null for UE %d\n",
@@ -4496,7 +4572,6 @@ extract_pucch_csi(module_id_t mod_idP,
uint16_t Npd, N_OFFSET_CQI;
int H, K, bandwidth_part, L, Lmask;
int ri = sched_ctl->periodic_ri_received[CC_idP];
-
get_csi_params(cc,
cqi_ReportPeriodic,
&Npd,
@@ -4530,7 +4605,7 @@ extract_pucch_csi(module_id_t mod_idP,
// note: need to check TM8-10 without PMI/RI or with 1 antenna port (see Section 5.2.3.3.1 from 36.213)
no_pmi = 0;
break;
-}
+ }
if (cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present == LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_widebandCQI ||
feedback_cnt == 0) {
@@ -4572,6 +4647,7 @@ extract_pucch_csi(module_id_t mod_idP,
sched_ctl->periodic_subband_cqi[CC_idP][(bandwidth_part * L) + ((pdu[0] >> 7) & Lmask)] = pdu[0] & 0xF;
}
}
+
return;
}
@@ -4760,7 +4836,6 @@ extract_pusch_csi(module_id_t mod_idP,
}
sched_ctl->dl_cqi[CC_idP] = sched_ctl->aperiodic_wideband_cqi0[CC_idP];
-
break;
case LTE_CQI_ReportModeAperiodic_rm31:
@@ -4835,8 +4910,8 @@ extract_pusch_csi(module_id_t mod_idP,
}
break;
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(12, 5, 0))
+
case LTE_CQI_ReportModeAperiodic_rm32_v1250:
AssertFatal(tmode == 4 || tmode == 5 || tmode == 6 || tmode == 8 || tmode == 9 || tmode == 10,
"Illegal transmission mode %d for CQI_ReportModeAperiodic_rm32\n",
@@ -4844,8 +4919,8 @@ extract_pusch_csi(module_id_t mod_idP,
AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm32 to be done\n");
break;
#endif
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(13, 1, 0))
+
case LTE_CQI_ReportModeAperiodic_rm10_v1310:
AssertFatal(tmode == 1 || tmode == 2 || tmode == 3 || tmode == 7, "Illegal transmission mode %d for CQI_ReportModeAperiodic_rm10\n",
tmode);
@@ -4859,8 +4934,8 @@ extract_pusch_csi(module_id_t mod_idP,
AssertFatal(1 == 0, "CQI_ReportModeAperiodic_rm11 to be done\n");
break;
#endif /* #if (LTE_RRC_VERSION >= MAKE_VERSION(13, 1, 0)) */
-
}
+
return;
}
@@ -4929,6 +5004,7 @@ cqi_indication(module_id_t mod_idP,
sched_ctl->timing_advance = rel9->timing_advance;
sched_ctl->timing_advance_r9 = rel9->timing_advance_r9;
}
+
return;
}
@@ -4961,6 +5037,7 @@ SR_indication(module_id_t mod_idP,
UE_id,
cc_idP);
}
+
UE_list->UE_template[cc_idP][UE_id].ul_SR = 1;
UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION, 1);
@@ -4976,6 +5053,7 @@ SR_indication(module_id_t mod_idP,
UE_id,
cc_idP);
}
+
return;
}
@@ -5031,14 +5109,17 @@ nack_or_dtx_reported(COMMON_channels_t *cc,
if (hi->harq_data[0].bundling.value_0 != 1) //only bundling is used for tdd for now
return 1;
}
+
return 0;
}
nfapi_harq_indication_fdd_rel13_t *hi = &harq_pdu->harq_indication_fdd_rel13;
+
for (i = 0; i < hi->number_of_ack_nack; hi++) {
if (hi->harq_tb_n[i] != 1)
return 1;
}
+
return 0;
}
@@ -5082,8 +5163,7 @@ harq_indication(module_id_t mod_idP,
subframeP,
(void *) &harq_pdu->harq_indication_tdd_rel13,
channel);
- }
- else {
+ } else {
extract_harq(mod_idP,
CC_idP,
UE_id,
@@ -5092,12 +5172,14 @@ harq_indication(module_id_t mod_idP,
(void *) &harq_pdu->harq_indication_fdd_rel13,
channel);
}
+
/* don't care about cqi reporting if NACK/DTX is there */
if (channel == 0 && !nack_or_dtx_reported(cc,
- harq_pdu)) {
+ harq_pdu)) {
sched_ctl->pucch1_snr[CC_idP] = ul_cqi;
sched_ctl->pucch1_cqi_update[CC_idP] = 1;
}
+
return;
}
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
index efe60be84f..7d24cc2494 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c
@@ -36,6 +36,7 @@
#include "LAYER2/MAC/mac_extern.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
#include "OCG_extern.h"
@@ -70,7 +71,7 @@ extern int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req);
extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset);
extern uint16_t sfnsf_add_subframe(uint16_t frameP, uint16_t subframeP, int offset);
extern int oai_nfapi_ul_config_req(nfapi_ul_config_request_t *ul_config_req);
-extern uint8_t nfapi_mode;
+
// This table holds the allowable PRB sizes for ULSCH transmissions
uint8_t rb_table[34] = {
@@ -120,7 +121,6 @@ rx_sdu(const module_id_t enb_mod_idP,
eNB_MAC_INST *mac = NULL;
UE_list_t *UE_list = NULL;
rrc_eNB_ue_context_t *ue_contextP = NULL;
-
/* Init */
current_rnti = rntiP;
UE_id = find_UE_id(enb_mod_idP, current_rnti);
@@ -130,19 +130,16 @@ rx_sdu(const module_id_t enb_mod_idP,
memset(rx_ces, 0, MAX_NUM_CE * sizeof(unsigned char));
memset(rx_lcids, 0, NB_RB_MAX * sizeof(unsigned char));
memset(rx_lengths, 0, NB_RB_MAX * sizeof(unsigned short));
-
start_meas(&mac->rx_ulsch_sdu);
-
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU, 1);
if (opt_enabled == 1) {
trace_pdu(DIRECTION_UPLINK, sduP, sdu_lenP, 0, WS_C_RNTI, current_rnti, frameP, subframeP, 0, 0);
-
LOG_D(OPT, "[eNB %d][ULSCH] Frame %d rnti %x with size %d\n",
- enb_mod_idP,
- frameP,
- current_rnti,
- sdu_lenP);
+ enb_mod_idP,
+ frameP,
+ current_rnti,
+ sdu_lenP);
}
if (UE_id != -1) {
@@ -156,7 +153,6 @@ rx_sdu(const module_id_t enb_mod_idP,
current_rnti,
UE_id,
ul_cqi);
-
AssertFatal(UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] < 8, "round >= 8\n");
if (sduP != NULL) {
@@ -171,7 +167,6 @@ rx_sdu(const module_id_t enb_mod_idP,
UE_list->UE_sched_ctrl[UE_id].ta_update = (UE_list->UE_sched_ctrl[UE_id].ta_update * 3 + timing_advance) / 4;
UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi;
UE_list->UE_sched_ctrl[UE_id].ul_consecutive_errors = 0;
-
first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid];
if (UE_list->UE_sched_ctrl[UE_id].ul_out_of_sync > 0) {
@@ -185,18 +180,17 @@ rx_sdu(const module_id_t enb_mod_idP,
if (UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes < 0) {
UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0;
}
-
} else { // sduP == NULL => error
LOG_W(MAC, "[eNB %d][PUSCH %d] CC_id %d %d.%d ULSCH in error in round %d, ul_cqi %d, UE_id %d, RNTI %x\n",
- enb_mod_idP,
- harq_pid,
- CC_idP,
- frameP,
- subframeP,
- UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid],
- ul_cqi,
- UE_id,
- current_rnti);
+ enb_mod_idP,
+ harq_pid,
+ CC_idP,
+ frameP,
+ subframeP,
+ UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid],
+ ul_cqi,
+ UE_id,
+ current_rnti);
if (ul_cqi > 200) { // too high energy pattern
UE_list->UE_sched_ctrl[UE_id].pusch_snr[CC_idP] = ul_cqi;
@@ -221,28 +215,22 @@ rx_sdu(const module_id_t enb_mod_idP,
if (find_RA_id(enb_mod_idP, CC_idP, current_rnti) != -1) {
cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti);
}
-
} else {
UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++;
}
first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid];
-
/* Program NACK for PHICH */
LOG_D(MAC, "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n",
- current_rnti,
- harq_pid,
- first_rb);
-
+ current_rnti,
+ harq_pid,
+ first_rb);
nfapi_hi_dci0_request_t *hi_dci0_req = NULL;
uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP);
hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP + sf_ahead_dl) % 10];
-
nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body;
nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi];
-
memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
-
hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu);
hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
@@ -256,46 +244,43 @@ rx_sdu(const module_id_t enb_mod_idP,
hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
return;
}
- // if UE_id == -1
+
+ // if UE_id == -1
} else if ((RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti)) != -1) { // Check if this is an RA process for the rnti
-
RA_t *ra = (RA_t *) &(mac->common_channels[CC_idP].ra[RA_id]);
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+
if (ra->rach_resource_type > 0) {
harq_pid = 0;
}
-#endif
+#endif
AssertFatal(mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx > 1,
"maxHARQ %d should be greater than 1\n",
(int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
-
LOG_D(MAC, "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n",
- enb_mod_idP,
- harq_pid,
- CC_idP,
- ra->msg3_round,
- current_rnti,
- RA_id,
- ul_cqi);
-
+ enb_mod_idP,
+ harq_pid,
+ CC_idP,
+ ra->msg3_round,
+ current_rnti,
+ RA_id,
+ ul_cqi);
first_rb = ra->msg3_first_rb;
if (sduP == NULL) { // we've got an error on Msg3
LOG_D(MAC, "[eNB %d] CC_id %d, RA %d ULSCH in error in round %d/%d\n",
- enb_mod_idP,
- CC_idP,
- RA_id,
- ra->msg3_round,
- (int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
+ enb_mod_idP,
+ CC_idP,
+ RA_id,
+ ra->msg3_round,
+ (int) mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx);
if (ra->msg3_round >= mac->common_channels[CC_idP].radioResourceConfigCommon->rach_ConfigCommon.maxHARQ_Msg3Tx - 1) {
cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti);
} else {
// first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; // UE_id = -1 !!!!
ra->msg3_round++;
-
/* Prepare handling of retransmission */
get_Msg3allocret(&mac->common_channels[CC_idP],
ra->Msg3_subframe,
@@ -303,7 +288,6 @@ rx_sdu(const module_id_t enb_mod_idP,
&ra->Msg3_frame,
&ra->Msg3_subframe);
// prepare handling of retransmission
-
add_msg3(enb_mod_idP, CC_idP, ra, frameP, subframeP);
}
@@ -312,7 +296,6 @@ rx_sdu(const module_id_t enb_mod_idP,
}
} else {
LOG_W(MAC, "Cannot find UE or RA corresponding to ULSCH rnti %x, dropping it\n", current_rnti);
-
return;
}
@@ -320,12 +303,11 @@ rx_sdu(const module_id_t enb_mod_idP,
if (payload_ptr == NULL) {
LOG_E(MAC,"[eNB %d][PUSCH %d] CC_id %d ulsch header unknown lcid(rnti %x, UE_id %d)\n",
- enb_mod_idP,
- harq_pid,
- CC_idP,
- current_rnti,
- UE_id);
-
+ enb_mod_idP,
+ harq_pid,
+ CC_idP,
+ current_rnti,
+ UE_id);
return;
}
@@ -339,7 +321,6 @@ rx_sdu(const module_id_t enb_mod_idP,
T_INT(sdu_lenP),
T_INT(num_ce),
T_INT(num_sdu));
-
T(T_ENB_MAC_UE_UL_PDU_WITH_DATA,
T_INT(enb_mod_idP),
T_INT(CC_idP),
@@ -351,10 +332,10 @@ rx_sdu(const module_id_t enb_mod_idP,
T_INT(num_ce),
T_INT(num_sdu),
T_BUFFER(sduP, sdu_lenP));
-
mac->eNB_stats[CC_idP].ulsch_bytes_rx = sdu_lenP;
mac->eNB_stats[CC_idP].total_ulsch_bytes_rx += sdu_lenP;
mac->eNB_stats[CC_idP].total_ulsch_pdus_rx += 1;
+
if (UE_id != -1) {
UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid] = 0;
}
@@ -379,33 +360,30 @@ rx_sdu(const module_id_t enb_mod_idP,
}
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received PHR PH = %d (db)\n",
- enb_mod_idP,
- CC_idP,
- rx_ces[i],
- UE_list->UE_template[CC_idP][UE_id].phr_info);
-
+ enb_mod_idP,
+ CC_idP,
+ rx_ces[i],
+ UE_list->UE_template[CC_idP][UE_id].phr_info);
UE_list->UE_template[CC_idP][UE_id].phr_info_configured = 1;
UE_list->UE_sched_ctrl[UE_id].phr_received = 1;
}
payload_ptr += sizeof(POWER_HEADROOM_CMD);
-
break;
case CRNTI:
old_rnti = (((uint16_t) payload_ptr[0]) << 8) + payload_ptr[1];
old_UE_id = find_UE_id(enb_mod_idP, old_rnti);
-
LOG_D(MAC, "[eNB %d] Frame %d, Subframe %d CC_id %d MAC CE_LCID %d (ce %d/%d): CRNTI %x (UE_id %d) in Msg3\n",
- enb_mod_idP,
- frameP,
- subframeP,
- CC_idP,
- rx_ces[i],
- i,
- num_ce,
- old_rnti,
- old_UE_id);
+ enb_mod_idP,
+ frameP,
+ subframeP,
+ CC_idP,
+ rx_ces[i],
+ i,
+ num_ce,
+ old_rnti,
+ old_UE_id);
/* Receiving CRNTI means that the current rnti has to go away */
if (old_UE_id != -1) {
@@ -496,27 +474,22 @@ rx_sdu(const module_id_t enb_mod_idP,
crnti_rx = 1;
payload_ptr += 2; // sizeof(CRNTI)
-
break;
case TRUNCATED_BSR:
-
case SHORT_BSR:
lcgid = (payload_ptr[0] >> 6);
-
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n",
- enb_mod_idP,
- CC_idP,
- rx_ces[i],
- lcgid,
- payload_ptr[0] & 0x3f);
+ enb_mod_idP,
+ CC_idP,
+ rx_ces[i],
+ lcgid,
+ payload_ptr[0] & 0x3f);
if (UE_id != -1) {
int bsr = 0;
-
bsr = payload_ptr[0] & 0x3f;
lcgid_updated[lcgid] = 1;
-
/* Update buffer info */
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid] = BSR_TABLE[bsr];
UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer =
@@ -524,7 +497,6 @@ rx_sdu(const module_id_t enb_mod_idP,
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] +
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] +
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3];
-
RC.eNB[enb_mod_idP][CC_idP]->pusch_stats_bsr[UE_id][(frameP * 10) + subframeP] = (payload_ptr[0] & 0x3f);
if (UE_id == UE_list->head) {
@@ -537,19 +509,17 @@ rx_sdu(const module_id_t enb_mod_idP,
if (mac_eNB_get_rrc_status(enb_mod_idP,UE_RNTI(enb_mod_idP, UE_id)) < RRC_CONNECTED) {
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d : estimated_ul_buffer = %d (lcg increment %d)\n",
- enb_mod_idP,
- CC_idP,
- rx_ces[i],
- UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer,
- UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]);
+ enb_mod_idP,
+ CC_idP,
+ rx_ces[i],
+ UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer,
+ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[lcgid]);
}
-
} else {
/* Need error message */
}
payload_ptr += 1; // sizeof(SHORT_BSR)
-
break;
case LONG_BSR:
@@ -558,38 +528,34 @@ rx_sdu(const module_id_t enb_mod_idP,
int bsr1 = ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4);
int bsr2 = ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6);
int bsr3 = payload_ptr[2] & 0x3F;
-
lcgid_updated[LCGID0] = 1;
lcgid_updated[LCGID1] = 1;
lcgid_updated[LCGID2] = 1;
lcgid_updated[LCGID3] = 1;
-
/* Update buffer info */
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] = BSR_TABLE[bsr0];
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] = BSR_TABLE[bsr1];
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] = BSR_TABLE[bsr2];
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3] = BSR_TABLE[bsr3];
-
UE_list->UE_template[CC_idP][UE_id].estimated_ul_buffer =
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0] +
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1] +
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2] +
UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3];
-
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received long BSR. Size is LCGID0 = %u LCGID1 = %u LCGID2 = %u LCGID3 = %u\n",
- enb_mod_idP,
- CC_idP,
- rx_ces[i],
- UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0],
- UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1],
- UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2],
- UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]);
+ enb_mod_idP,
+ CC_idP,
+ rx_ces[i],
+ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID0],
+ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID1],
+ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID2],
+ UE_list->UE_template[CC_idP][UE_id].ul_buffer_info[LCGID3]);
if (crnti_rx == 1) {
LOG_D(MAC, "[eNB %d] CC_id %d MAC CE_LCID %d: Received CRNTI.\n",
- enb_mod_idP,
- CC_idP,
- rx_ces[i]);
+ enb_mod_idP,
+ CC_idP,
+ rx_ces[i]);
}
for(int lcgid = 0; lcgid <= LCGID3; lcgid++) {
@@ -606,21 +572,18 @@ rx_sdu(const module_id_t enb_mod_idP,
default:
LOG_E(MAC, "[eNB %d] CC_id %d Received unknown MAC header (0x%02x)\n",
- enb_mod_idP,
- CC_idP,
- rx_ces[i]);
-
+ enb_mod_idP,
+ CC_idP,
+ rx_ces[i]);
break;
-
} // end switch on control element
} // end for loop on control element
for (int i = 0; i < num_sdu; i++) {
LOG_D(MAC, "SDU Number %d MAC Subheader SDU_LCID %d, length %d\n",
- i,
- rx_lcids[i],
- rx_lengths[i]);
-
+ i,
+ rx_lcids[i],
+ rx_lengths[i]);
T(T_ENB_MAC_UE_UL_SDU,
T_INT(enb_mod_idP),
T_INT(CC_idP),
@@ -629,7 +592,6 @@ rx_sdu(const module_id_t enb_mod_idP,
T_INT(subframeP),
T_INT(rx_lcids[i]),
T_INT(rx_lengths[i]));
-
T(T_ENB_MAC_UE_UL_SDU_WITH_DATA,
T_INT(enb_mod_idP),
T_INT(CC_idP),
@@ -644,58 +606,51 @@ rx_sdu(const module_id_t enb_mod_idP,
case CCCH:
if (rx_lengths[i] > CCCH_PAYLOAD_SIZE_MAX) {
LOG_E(MAC, "[eNB %d/%d] frame %d received CCCH of size %d (too big, maximum allowed is %d, sdu_len %d), dropping packet\n",
- enb_mod_idP,
- CC_idP,
- frameP,
- rx_lengths[i],
- CCCH_PAYLOAD_SIZE_MAX,
- sdu_lenP);
-
+ enb_mod_idP,
+ CC_idP,
+ frameP,
+ rx_lengths[i],
+ CCCH_PAYLOAD_SIZE_MAX,
+ sdu_lenP);
break;
}
LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, Received CCCH: %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n",
- enb_mod_idP,
- CC_idP,
- frameP,
- payload_ptr[0], payload_ptr[1], payload_ptr[2], payload_ptr[3], payload_ptr[4], payload_ptr[5],
- current_rnti);
-
+ enb_mod_idP,
+ CC_idP,
+ frameP,
+ payload_ptr[0], payload_ptr[1], payload_ptr[2], payload_ptr[3], payload_ptr[4], payload_ptr[5],
+ current_rnti);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 1);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TERMINATE_RA_PROC, 0);
-
RA_id = find_RA_id(enb_mod_idP, CC_idP, current_rnti);
if (RA_id != -1) {
RA_t *ra = &(mac->common_channels[CC_idP].ra[RA_id]);
-
LOG_D(MAC, "[mac %d][RAPROC] CC_id %d Checking proc %d : rnti (%x, %x), state %d\n",
- enb_mod_idP,
- CC_idP,
- RA_id,
- ra->rnti,
- current_rnti,
- ra->state);
+ enb_mod_idP,
+ CC_idP,
+ RA_id,
+ ra->rnti,
+ current_rnti,
+ ra->state);
if (UE_id < 0) {
memcpy(&(ra->cont_res_id[0]), payload_ptr, 6);
-
LOG_D(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d CCCH: Received Msg3: length %d, offset %ld\n",
- enb_mod_idP,
- CC_idP,
- frameP,
- rx_lengths[i],
- payload_ptr - sduP);
+ enb_mod_idP,
+ CC_idP,
+ frameP,
+ rx_lengths[i],
+ payload_ptr - sduP);
if ((UE_id = add_new_ue(enb_mod_idP, CC_idP, ra->rnti, harq_pid
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
, ra->rach_resource_type
#endif
- )) == -1) {
+ )) == -1) {
LOG_E(MAC,"[MAC][eNB] Max user count reached\n");
-
cancel_ra_proc(enb_mod_idP, CC_idP, frameP, current_rnti); // send Connection Reject ???
-
break;
// kill RA proc
} else {
@@ -718,18 +673,18 @@ rx_sdu(const module_id_t enb_mod_idP,
}
mac_rrc_data_ind(enb_mod_idP,
- CC_idP,
- frameP, subframeP,
- UE_id,
- current_rnti,
- CCCH,
- (uint8_t *) payload_ptr,
- rx_lengths[i],
- 0
+ CC_idP,
+ frameP, subframeP,
+ UE_id,
+ current_rnti,
+ CCCH,
+ (uint8_t *) payload_ptr,
+ rx_lengths[i],
+ 0
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,ra->rach_resource_type > 0
+ ,ra->rach_resource_type > 0
#endif
- );
+ );
if (num_ce > 0) { // handle msg3 which is not RRCConnectionRequest
// process_ra_message(msg3,num_ce,rx_lcids,rx_ces);
@@ -764,9 +719,7 @@ rx_sdu(const module_id_t enb_mod_idP,
break;
case DCCH:
-
case DCCH1:
-
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
LOG_T(MAC, "offset: %d\n", (unsigned char) ((unsigned char *) payload_ptr - sduP));
@@ -857,12 +810,11 @@ rx_sdu(const module_id_t enb_mod_idP,
mac_rlc_data_ind(enb_mod_idP, current_rnti, enb_mod_idP, frameP, ENB_FLAG_YES, MBMS_FLAG_NO, rx_lcids[i], (char *) payload_ptr, rx_lengths[i], 1, NULL);
UE_list->eNB_UE_stats[CC_idP][UE_id].num_pdu_rx[rx_lcids[i]] += 1;
UE_list->eNB_UE_stats[CC_idP][UE_id].num_bytes_rx[rx_lcids[i]] += rx_lengths[i];
-
/* Clear uplane_inactivity_timer */
UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0;
-
/* Reset RRC inactivity timer after uplane activity */
ue_contextP = rrc_eNB_get_ue_context(RC.rrc[enb_mod_idP], current_rnti);
+
if (ue_contextP != NULL) {
ue_contextP->ue_context.ue_rrc_inactivity_timer = 1;
} else {
@@ -871,10 +823,8 @@ rx_sdu(const module_id_t enb_mod_idP,
CC_idP,
current_rnti);
}
-
} else { /* rx_length[i] Max size */
UE_list->eNB_UE_stats[CC_idP][UE_id].num_errors_rx += 1;
-
LOG_E(MAC, "[eNB %d] CC_id %d Frame %d : Max size of transport block reached LCID %d from UE %d ",
enb_mod_idP,
CC_idP,
@@ -891,6 +841,7 @@ rx_sdu(const module_id_t enb_mod_idP,
UE_id);
}
}
+
break;
}
@@ -899,21 +850,16 @@ rx_sdu(const module_id_t enb_mod_idP,
/* Program ACK for PHICH */
LOG_D(MAC, "Programming PHICH ACK for rnti %x harq_pid %d (first_rb %d)\n",
- current_rnti,
- harq_pid,
- first_rb);
-
+ current_rnti,
+ harq_pid,
+ first_rb);
nfapi_hi_dci0_request_t *hi_dci0_req;
-
uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_idP], subframeP);
-
hi_dci0_req = &mac->HI_DCI0_req[CC_idP][(subframeP+sf_ahead_dl)%10];
nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body;
nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci +
- hi_dci0_req_body->number_of_hi];
-
+ hi_dci0_req_body->number_of_hi];
memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
-
hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_HI_PDU_TYPE;
hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu);
hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG;
@@ -930,7 +876,6 @@ rx_sdu(const module_id_t enb_mod_idP,
if ((num_sdu == 0) && (num_ce == 0)) {
if (UE_id != -1)
UE_list->eNB_UE_stats[CC_idP][UE_id].total_num_errors_rx += 1;
-
} else {
if (UE_id != -1) {
UE_list->eNB_UE_stats[CC_idP][UE_id].pdu_bytes_rx = sdu_lenP;
@@ -970,10 +915,10 @@ bytes_to_bsr_index(int32_t nbytes)
*/
void
add_ue_ulsch_info(module_id_t module_idP,
- int CC_id,
- int UE_id,
- sub_frame_t subframeP,
- UE_ULSCH_STATUS status)
+ int CC_id,
+ int UE_id,
+ sub_frame_t subframeP,
+ UE_ULSCH_STATUS status)
//-----------------------------------------------------------------------------
{
eNB_ulsch_info[module_idP][CC_id][UE_id].rnti = UE_RNTI(module_idP, UE_id);
@@ -988,12 +933,12 @@ add_ue_ulsch_info(module_id_t module_idP,
*/
unsigned char *
parse_ulsch_header(unsigned char *mac_header,
- unsigned char *num_ce,
- unsigned char *num_sdu,
- unsigned char *rx_ces,
- unsigned char *rx_lcids,
- unsigned short *rx_lengths,
- unsigned short tb_length)
+ unsigned char *num_ce,
+ unsigned char *num_sdu,
+ unsigned char *rx_ces,
+ unsigned char *rx_lcids,
+ unsigned short *rx_lengths,
+ unsigned short tb_length)
//-----------------------------------------------------------------------------
{
unsigned char not_done = 1;
@@ -1003,7 +948,6 @@ parse_ulsch_header(unsigned char *mac_header,
unsigned char num_sdu_cnt = 0;
unsigned char *mac_header_ptr = NULL;
unsigned short length, ce_len = 0;
-
/* Init */
mac_header_ptr = mac_header;
@@ -1028,22 +972,20 @@ parse_ulsch_header(unsigned char *mac_header,
mac_header_ptr += 2; //sizeof(SCH_SUBHEADER_SHORT);
} else { // F = 1
length = ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB & 0x7f) << 8) |
- (((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB & 0xff);
+ (((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB & 0xff);
mac_header_ptr += 3; //sizeof(SCH_SUBHEADER_LONG);
}
}
LOG_D(MAC, "[eNB] sdu %d lcid %d tb_length %d length %d (offset now %ld)\n",
- num_sdus,
- lcid,
- tb_length,
- length,
- mac_header_ptr - mac_header);
-
+ num_sdus,
+ lcid,
+ tb_length,
+ length,
+ mac_header_ptr - mac_header);
rx_lcids[num_sdus] = lcid;
rx_lengths[num_sdus] = length;
num_sdus++;
-
} else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI
if (lcid == SHORT_PADDING) {
mac_header_ptr++;
@@ -1081,16 +1023,15 @@ parse_ulsch_header(unsigned char *mac_header,
*/
void
set_msg3_subframe(module_id_t mod_id,
- int CC_id,
- int frame, // Not used, remove?
- int subframe, // Not used, remove?
- int rnti,
- int Msg3_frame, // Not used, remove?
- int Msg3_subframe)
+ int CC_id,
+ int frame, // Not used, remove?
+ int subframe, // Not used, remove?
+ int rnti,
+ int Msg3_frame, // Not used, remove?
+ int Msg3_subframe)
//-----------------------------------------------------------------------------
{
int RA_id = 0;
-
/* Init */
RA_id = find_RA_id(mod_id, CC_id, rnti); // state == WAITMSG3 instead of state != IDLE (?)
@@ -1109,26 +1050,22 @@ set_msg3_subframe(module_id_t mod_id,
*/
void
schedule_ulsch(module_id_t module_idP,
- frame_t frameP,
- sub_frame_t subframeP)
+ frame_t frameP,
+ sub_frame_t subframeP)
//-----------------------------------------------------------------------------
{
uint16_t first_rb[NFAPI_CC_MAX];
eNB_MAC_INST *mac = NULL;
slice_info_t *sli = NULL;
COMMON_channels_t *cc = NULL;
-
/* Init */
mac = RC.mac[module_idP];
sli = &(mac->slice_info);
memset(first_rb, 0, NFAPI_CC_MAX * sizeof(uint16_t));
-
start_meas(&(mac->schedule_ulsch));
-
/* Second setup step */
int sched_subframe = 0;
int sched_frame = 0;
-
/* Second init step */
sched_subframe = (subframeP + 4) % 10;
sched_frame = frameP;
@@ -1237,13 +1174,11 @@ schedule_ulsch(module_id_t module_idP,
/* Note: RC.nb_mac_CC[module_idP] should be lower than or equal to NFAPI_CC_MAX */
for (int CC_id = 0; CC_id < RC.nb_mac_CC[module_idP]; CC_id++, cc++) {
first_rb[CC_id] = 1; // leave out first RB for PUCCH
-
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
first_rb[CC_id] = (emtc_active[CC_id] == 1) ? 7 : 1;
#else
first_rb[CC_id] = 1;
#endif
-
RA_t *ra_ptr = cc->ra;
/* From Louis-Adrien to François:
@@ -1282,6 +1217,7 @@ schedule_ulsch(module_id_t module_idP,
if (first_rb[CC_id] < ra_ptr->msg3_first_rb + ra_ptr->msg3_nb_rb) {
first_rb[CC_id] = ra_ptr->msg3_first_rb + ra_ptr->msg3_nb_rb;
}
+
/* Louis-Adrien: I couldn't find an interdiction of multiple Msg3 scheduling
* on the same time resources. Also the performance improvement of breaking is low,
* since we will loop until the end, most of the time.
@@ -1307,11 +1243,11 @@ schedule_ulsch(module_id_t module_idP,
*/
void
schedule_ulsch_rnti(module_id_t module_idP,
- int slice_idx,
- frame_t frameP,
- sub_frame_t subframeP,
- unsigned char sched_subframeP,
- uint16_t *first_rb)
+ int slice_idx,
+ frame_t frameP,
+ sub_frame_t subframeP,
+ unsigned char sched_subframeP,
+ uint16_t *first_rb)
//-----------------------------------------------------------------------------
{
rnti_t rnti = -1;
@@ -1341,7 +1277,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
int rvidx_tab[4] = {0, 2, 3, 1};
int first_rb_slice[NFAPI_CC_MAX];
int n_rb_ul_tab[NFAPI_CC_MAX];
-
/* Init */
mac = RC.mac[module_idP];
cc = mac->common_channels;
@@ -1362,7 +1297,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
nfapi_ul_config_request_t *ul_req_tmp = &(mac->UL_req_tmp[CC_id][sched_subframeP]);
nfapi_ul_config_request_body_t *ul_req_tmp_body = &(ul_req_tmp->ul_config_request_body);
nfapi_ul_config_ulsch_harq_information *ulsch_harq_information;
-
hi_dci0_req->sfn_sf = (frameP << 4) + subframeP;
/* Note: RC.nb_mac_CC[module_idP] should be lower than or equal to NFAPI_CC_MAX */
@@ -1387,16 +1321,16 @@ schedule_ulsch_rnti(module_id_t module_idP,
if (!ue_ul_slice_membership(module_idP, UE_id, slice_idx)) {
continue;
}
+
if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id].rach_resource_type > 0) continue;
// don't schedule if Msg5 is not received yet
if (UE_list->UE_template[UE_PCCID(module_idP, UE_id)][UE_id].configured == FALSE) {
LOG_D(MAC, "[eNB %d] frame %d, subframe %d, UE %d: not configured, skipping UE scheduling \n",
- module_idP,
- frameP,
- subframeP,
- UE_id);
-
+ module_idP,
+ frameP,
+ subframeP,
+ UE_id);
continue;
}
@@ -1404,11 +1338,10 @@ schedule_ulsch_rnti(module_id_t module_idP,
if (rnti == NOT_A_RNTI) {
LOG_W(MAC, "[eNB %d] frame %d, subframe %d, UE %d: no RNTI \n",
- module_idP,
- frameP,
- subframeP,
- UE_id);
-
+ module_idP,
+ frameP,
+ subframeP,
+ UE_id);
continue;
}
@@ -1420,13 +1353,12 @@ schedule_ulsch_rnti(module_id_t module_idP,
/* Be sure that there are some free RBs */
if (first_rb_slice[CC_id] >= n_rb_ul_tab[CC_id] - 1) {
LOG_W(MAC, "[eNB %d] frame %d, subframe %d, UE %d/%x CC %d: dropping, not enough RBs\n",
- module_idP,
- frameP,
- subframeP,
- UE_id,
- rnti,
- CC_id);
-
+ module_idP,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ CC_id);
continue;
}
@@ -1434,13 +1366,12 @@ schedule_ulsch_rnti(module_id_t module_idP,
/* This test seems to be way too long, can we provide an optimization? */
if (CCE_allocation_infeasible(module_idP, CC_id, 1, subframeP, aggregation, rnti)) {
LOG_W(MAC, "[eNB %d] frame %d, subframe %d, UE %d/%x CC %d: not enough CCE\n",
- module_idP,
- frameP,
- subframeP,
- UE_id,
- rnti,
- CC_id);
-
+ module_idP,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ CC_id);
continue;
}
@@ -1449,25 +1380,22 @@ schedule_ulsch_rnti(module_id_t module_idP,
UE_sched_ctrl_ptr = &(UE_list->UE_sched_ctrl[UE_id]);
harq_pid = subframe2harqpid(&cc[CC_id], sched_frame, sched_subframeP);
round_index = UE_sched_ctrl_ptr->round_UL[CC_id][harq_pid];
-
AssertFatal(round_index < 8, "round %d > 7 for UE %d/%x\n",
- round_index,
- UE_id,
- rnti);
-
+ round_index,
+ UE_id,
+ rnti);
LOG_D(MAC, "[eNB %d] frame %d subframe %d (sched_frame %d, sched_subframe %d), Checking PUSCH %d for UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n",
- module_idP,
- frameP,
- subframeP,
- sched_frame,
- sched_subframeP,
- harq_pid,
- UE_id,
- rnti,
- CC_id,
- aggregation,
- n_rb_ul_tab[CC_id]);
-
+ module_idP,
+ frameP,
+ subframeP,
+ sched_frame,
+ sched_subframeP,
+ harq_pid,
+ UE_id,
+ rnti,
+ CC_id,
+ aggregation,
+ n_rb_ul_tab[CC_id]);
/* Seems unused, only for debug */
RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP * 10) + subframeP] = UE_template_ptr->estimated_ul_buffer;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, UE_template_ptr->estimated_ul_buffer);
@@ -1479,18 +1407,17 @@ schedule_ulsch_rnti(module_id_t module_idP,
/* Shouldn't this test be done earlier?? */
if (UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0 || round_index > 0) {
LOG_D(MAC, "[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n",
- module_idP,
- harq_pid,
- frameP,
- subframeP,
- UE_id,
- rnti,
- round_index,
- UE_template_ptr->ul_SR,
- UE_sched_ctrl_ptr->ul_inactivity_timer,
- UE_sched_ctrl_ptr->ul_failure_timer,
- UE_sched_ctrl_ptr->cqi_req_timer);
-
+ module_idP,
+ harq_pid,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ round_index,
+ UE_template_ptr->ul_SR,
+ UE_sched_ctrl_ptr->ul_inactivity_timer,
+ UE_sched_ctrl_ptr->ul_failure_timer,
+ UE_sched_ctrl_ptr->cqi_req_timer);
// reset the scheduling request
UE_template_ptr->ul_SR = 0;
status = mac_eNB_get_rrc_status(module_idP, rnti);
@@ -1500,7 +1427,7 @@ schedule_ulsch_rnti(module_id_t module_idP,
/* These aperiodic reports behave as periodic ones... */
if (status >= RRC_CONNECTED && UE_sched_ctrl_ptr->cqi_req_timer > 30) {
if (UE_sched_ctrl_ptr->cqi_received == 0) {
- if (nfapi_mode) {
+ if (NFAPI_MODE != NFAPI_MONOLITHIC) {
cqi_req = 0;
} else {
cqi_req = 1;
@@ -1512,12 +1439,14 @@ schedule_ulsch_rnti(module_id_t module_idP,
if(subframeP == 1 || subframeP == 6) {
cqi_req=0;
}
+
break;
case 3:
if(subframeP == 1) {
cqi_req=0;
}
+
break;
default:
@@ -1546,7 +1475,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
*/
normalized_rx_power = ((5 * UE_sched_ctrl_ptr->pusch_snr[CC_id] - 640) / 10) + 30;
target_rx_power = (mac->puSch10xSnr / 10) + 30;
-
/*
* This assumes accumulated tpc
* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out
@@ -1555,7 +1483,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case
((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) { //frame wrap-around
-
UE_template_ptr->pusch_tpc_tx_frame = frameP;
UE_template_ptr->pusch_tpc_tx_subframe = subframeP;
@@ -1574,14 +1501,14 @@ schedule_ulsch_rnti(module_id_t module_idP,
if (tpc != 1) {
LOG_D(MAC, "[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
- module_idP,
- frameP,
- subframeP,
- harq_pid,
- tpc,
- tpc_accumulated,
- normalized_rx_power,
- target_rx_power);
+ module_idP,
+ frameP,
+ subframeP,
+ harq_pid,
+ tpc,
+ tpc_accumulated,
+ normalized_rx_power,
+ target_rx_power);
}
/* New transmission */
@@ -1611,7 +1538,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += rb_table[rb_table_index];
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = UE_template_ptr->TBS_UL[harq_pid];
UE_list->eNB_UE_stats[CC_id][UE_id].total_ulsch_TBS += UE_template_ptr->TBS_UL[harq_pid];
-
T(T_ENB_MAC_UE_UL_SCHEDULE,
T_INT(module_idP),
T_INT(CC_id),
@@ -1624,7 +1550,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
T_INT(rb_table[rb_table_index]),
T_INT(UE_template_ptr->TBS_UL[harq_pid]),
T_INT(ndi));
-
/* Store information for possible retransmission */
UE_template_ptr->nb_rb_ul[harq_pid] = rb_table[rb_table_index];
UE_template_ptr->first_rb_ul[harq_pid] = first_rb_slice[CC_id];
@@ -1636,24 +1561,19 @@ schedule_ulsch_rnti(module_id_t module_idP,
/* Adjust scheduled UL bytes by TBS, wait for UL sdus to do final update */
LOG_D(MAC, "[eNB %d] CC_id %d UE %d/%x : adjusting scheduled_ul_bytes, old %d, TBS %d\n",
- module_idP,
- CC_id,
- UE_id,
- rnti,
- UE_template_ptr->scheduled_ul_bytes,
- UE_template_ptr->TBS_UL[harq_pid]);
-
+ module_idP,
+ CC_id,
+ UE_id,
+ rnti,
+ UE_template_ptr->scheduled_ul_bytes,
+ UE_template_ptr->TBS_UL[harq_pid]);
UE_template_ptr->scheduled_ul_bytes += UE_template_ptr->TBS_UL[harq_pid];
-
LOG_D(MAC, "scheduled_ul_bytes, new %d\n",
- UE_template_ptr->scheduled_ul_bytes);
-
+ UE_template_ptr->scheduled_ul_bytes);
/* Cyclic shift for DM-RS */
cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1)
-
/* Save it for a potential retransmission */
UE_template_ptr->cshift[harq_pid] = cshift;
-
/* Setting DCI0 NFAPI struct */
hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi];
memset((void *) hi_dci0_pdu, 0,sizeof(nfapi_hi_dci0_request_pdu_t));
@@ -1679,65 +1599,60 @@ schedule_ulsch_rnti(module_id_t module_idP,
hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG;
hi_dci0_req->sfn_sf = frameP << 4 | subframeP;
hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST;
-
LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n",
- harq_pid,
- frameP,
- subframeP,
- UE_id,
- rnti,
- sched_frame,
- sched_subframeP);
-
+ harq_pid,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ sched_frame,
+ sched_subframeP);
ul_req_index = 0;
dlsch_flag = 0;
for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) {
if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE &&
- ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) {
-
+ ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) {
dlsch_flag = 1;
-
LOG_D(MAC, "Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",
- frameP,
- subframeP,
- rnti,
- ul_req_index);
-
+ frameP,
+ subframeP,
+ rnti,
+ ul_req_index);
break;
}
}
/* Add UL_config PDUs */
fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index],
- cqi_req,
- cc,
- UE_template_ptr->physicalConfigDedicated,
- get_tmode(module_idP, CC_id, UE_id),
- mac->ul_handle,
- rnti,
- first_rb_slice[CC_id], // resource_block_start
- rb_table[rb_table_index], // number_of_resource_blocks
- UE_template_ptr->mcs_UL[harq_pid],
- cshift, // cyclic_shift_2_for_drms
- 0, // frequency_hopping_enabled_flag
- 0, // frequency_hopping_bits
- ndi, // new_data_indication
- 0, // redundancy_version
- harq_pid, // harq_process_number
- 0, // ul_tx_mode
- 0, // current_tx_nb
- 0, // n_srs
- get_TBS_UL(UE_template_ptr->mcs_UL[harq_pid], rb_table[rb_table_index]));
-
+ cqi_req,
+ cc,
+ UE_template_ptr->physicalConfigDedicated,
+ get_tmode(module_idP, CC_id, UE_id),
+ mac->ul_handle,
+ rnti,
+ first_rb_slice[CC_id], // resource_block_start
+ rb_table[rb_table_index], // number_of_resource_blocks
+ UE_template_ptr->mcs_UL[harq_pid],
+ cshift, // cyclic_shift_2_for_drms
+ 0, // frequency_hopping_enabled_flag
+ 0, // frequency_hopping_bits
+ ndi, // new_data_indication
+ 0, // redundancy_version
+ harq_pid, // harq_process_number
+ 0, // ul_tx_mode
+ 0, // current_tx_nb
+ 0, // n_srs
+ get_TBS_UL(UE_template_ptr->mcs_UL[harq_pid], rb_table[rb_table_index]));
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+
/* This is a BL/CE UE allocation */
if (UE_template_ptr->rach_resource_type > 0) {
fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index],
- UE_template_ptr->rach_resource_type > 2 ? 2 : 1,
- 1, // total_number_of_repetitions
- 1, // repetition_number
- (frameP * 10) + subframeP);
+ UE_template_ptr->rach_resource_type > 2 ? 2 : 1,
+ 1, // total_number_of_repetitions
+ 1, // repetition_number
+ (frameP * 10) + subframeP);
}
#endif
@@ -1746,19 +1661,21 @@ schedule_ulsch_rnti(module_id_t module_idP,
if (cqi_req == 1) {
ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE;
ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.harq_information;
- ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG;
+ ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag =
+ NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG;
ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured
- ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index];
+ ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_cqi_harq_ri_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks =
+ rb_table[rb_table_index];
} else {
ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type = NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE;
ulsch_harq_information = &ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.harq_information;
- ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag = NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG;
+ ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.tl.tag =
+ NFAPI_UL_CONFIG_REQUEST_INITIAL_TRANSMISSION_PARAMETERS_REL8_TAG;
ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.n_srs_initial = 0; // last symbol not punctured
ul_req_tmp_body->ul_config_pdu_list[ul_req_index].ulsch_harq_pdu.initial_transmission_parameters.initial_transmission_parameters_rel8.initial_number_of_resource_blocks = rb_table[rb_table_index];
}
fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information,subframeP);
-
} else {
ul_req_tmp_body->number_of_pdus++;
}
@@ -1767,29 +1684,24 @@ schedule_ulsch_rnti(module_id_t module_idP,
ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
mac->ul_handle++;
ul_req_tmp->sfn_sf = sched_frame << 4 | sched_subframeP;
-
add_ue_ulsch_info(module_idP, CC_id, UE_id, subframeP, S_UL_SCHEDULED);
-
LOG_D(MAC, "[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n",
- module_idP,
- CC_id,
- frameP,
- subframeP,
- UE_id);
-
+ module_idP,
+ CC_id,
+ frameP,
+ subframeP,
+ UE_id);
LOG_D(MAC, "[PUSCH %d] SFN/SF:%04d%d UL_CFG:SFN/SF:%04d%d CQI:%d for UE %d/%x\n",
- harq_pid,
- frameP,
- subframeP,
- sched_frame,
- sched_subframeP,
- cqi_req,
- UE_id,
- rnti);
-
+ harq_pid,
+ frameP,
+ subframeP,
+ sched_frame,
+ sched_subframeP,
+ cqi_req,
+ UE_id,
+ rnti);
/* Increment first rb for next UE allocation */
first_rb_slice[CC_id] += rb_table[rb_table_index];
-
} else { // round_index > 0 => retransmission
T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION,
T_INT(module_idP),
@@ -1802,66 +1714,60 @@ schedule_ulsch_rnti(module_id_t module_idP,
T_INT(first_rb_slice[CC_id]),
T_INT(rb_table[rb_table_index]),
T_INT(round_index));
-
/* Add UL_config PDUs */
LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n",
- harq_pid,
- frameP,
- subframeP,
- UE_id,
- rnti,
- sched_frame,
- sched_subframeP);
-
+ harq_pid,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ sched_frame,
+ sched_subframeP);
ul_req_index = 0;
dlsch_flag = 0;
for(ul_req_index = 0; ul_req_index < ul_req_tmp_body->number_of_pdus; ul_req_index++) {
if(ul_req_tmp_body->ul_config_pdu_list[ul_req_index].pdu_type == NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE &&
- ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) {
-
+ ul_req_tmp_body->ul_config_pdu_list[ul_req_index].uci_harq_pdu.ue_information.ue_information_rel8.rnti == rnti) {
dlsch_flag = 1;
-
LOG_D(MAC, "Frame %d, Subframe %d:rnti %x ul_req_index %d Switched UCI HARQ to ULSCH HARQ(first)\n",
- frameP,
- subframeP,
- rnti,
- ul_req_index);
-
+ frameP,
+ subframeP,
+ rnti,
+ ul_req_index);
break;
}
}
fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index],
- cqi_req,
- cc,
- UE_template_ptr->physicalConfigDedicated,
- get_tmode(module_idP, CC_id, UE_id),
- mac->ul_handle,
- rnti,
- UE_template_ptr->first_rb_ul[harq_pid], // resource_block_start
- UE_template_ptr->nb_rb_ul[harq_pid], // number_of_resource_blocks
- UE_template_ptr->mcs_UL[harq_pid],
- cshift, // cyclic_shift_2_for_drms
- 0, // frequency_hopping_enabled_flag
- 0, // frequency_hopping_bits
- UE_template_ptr->oldNDI_UL[harq_pid], // new_data_indication
- rvidx_tab[round_index & 3], // redundancy_version
- harq_pid, // harq_process_number
- 0, // ul_tx_mode
- 0, // current_tx_nb
- 0, // n_srs
- UE_template_ptr->TBS_UL[harq_pid]);
-
+ cqi_req,
+ cc,
+ UE_template_ptr->physicalConfigDedicated,
+ get_tmode(module_idP, CC_id, UE_id),
+ mac->ul_handle,
+ rnti,
+ UE_template_ptr->first_rb_ul[harq_pid], // resource_block_start
+ UE_template_ptr->nb_rb_ul[harq_pid], // number_of_resource_blocks
+ UE_template_ptr->mcs_UL[harq_pid],
+ cshift, // cyclic_shift_2_for_drms
+ 0, // frequency_hopping_enabled_flag
+ 0, // frequency_hopping_bits
+ UE_template_ptr->oldNDI_UL[harq_pid], // new_data_indication
+ rvidx_tab[round_index & 3], // redundancy_version
+ harq_pid, // harq_process_number
+ 0, // ul_tx_mode
+ 0, // current_tx_nb
+ 0, // n_srs
+ UE_template_ptr->TBS_UL[harq_pid]);
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
/* This is a BL/CE UE allocation */
if (UE_template_ptr->rach_resource_type > 0) {
fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp_body->ul_config_pdu_list[ul_req_index],
- UE_template_ptr->rach_resource_type > 2 ? 2 : 1,
- 1, // total_number_of_repetitions
- 1, // repetition_number
- (frameP * 10) + subframeP);
+ UE_template_ptr->rach_resource_type > 2 ? 2 : 1,
+ 1, // total_number_of_repetitions
+ 1, // repetition_number
+ (frameP * 10) + subframeP);
}
#endif
@@ -1886,7 +1792,6 @@ schedule_ulsch_rnti(module_id_t module_idP,
}
fill_nfapi_ulsch_harq_information(module_idP, CC_id,rnti, ulsch_harq_information, subframeP);
-
} else {
ul_req_tmp_body->number_of_pdus++;
}
@@ -1895,16 +1800,15 @@ schedule_ulsch_rnti(module_id_t module_idP,
ul_req_tmp_body->tl.tag = NFAPI_UL_CONFIG_REQUEST_BODY_TAG;
ul_req_tmp->sfn_sf = sched_frame<<4|sched_subframeP;
ul_req_tmp->header.message_id = NFAPI_UL_CONFIG_REQUEST;
-
LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d cqi_req %d\n",
- harq_pid,
- frameP,
- subframeP,
- UE_id,
- rnti,
- sched_frame,
- sched_subframeP,
- cqi_req);
+ harq_pid,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ sched_frame,
+ sched_subframeP,
+ cqi_req);
} // end of round > 0
} // UE_is_to_be_scheduled
} // loop over all active CC_ids
@@ -1917,10 +1821,10 @@ schedule_ulsch_rnti(module_id_t module_idP,
* default ULSCH scheduler for LTE-M
*/
void schedule_ulsch_rnti_emtc(module_id_t module_idP,
- frame_t frameP,
- sub_frame_t subframeP,
- unsigned char sched_subframeP,
- int *emtc_active)
+ frame_t frameP,
+ sub_frame_t subframeP,
+ unsigned char sched_subframeP,
+ int *emtc_active)
//-----------------------------------------------------------------------------
{
int UE_id = -1;
@@ -1947,11 +1851,10 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
if (sched_subframeP < subframeP) {
sched_frame++;
- }
+ }
nfapi_hi_dci0_request_body_t *hi_dci0_req = &(eNB->HI_DCI0_req[CC_id][subframeP].hi_dci0_request_body);
nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = NULL;
-
nfapi_ul_config_request_body_t *ul_req_tmp = &(eNB->UL_req_tmp[CC_id][sched_subframeP].ul_config_request_body);
/* If frameP odd don't schedule */
@@ -1979,12 +1882,11 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
rnti = UE_RNTI(module_idP, UE_id);
if (rnti == NOT_A_RNTI) {
- LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d: no RNTI \n",
+ LOG_W(MAC,"[eNB %d] frame %d subframe %d, UE %d: no RNTI \n",
module_idP,
frameP,
subframeP,
UE_id);
-
continue;
}
@@ -1993,18 +1895,14 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
/* This is the actual CC_id in the list */
CC_id = UE_list->ordered_ULCCids[n][UE_id];
N_RB_UL = to_prb(cc[CC_id].ul_Bandwidth);
-
UE_template = &(UE_list->UE_template[CC_id][UE_id]);
UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id];
-
harq_pid = 0;
round_UL = UE_sched_ctrl->round_UL[CC_id][harq_pid];
-
AssertFatal(round_UL < 8,"round_UL %d > 7 for UE %d/%x\n",
round_UL,
UE_id,
rnti);
-
LOG_D(MAC,"[eNB %d] frame %d subframe %d,Checking PUSCH %d for BL/CE UE %d/%x CC %d : aggregation level %d, N_RB_UL %d\n",
module_idP,
frameP,
@@ -2012,22 +1910,20 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
harq_pid,
UE_id,
rnti,
- CC_id,
+ CC_id,
24, // agregation level
N_RB_UL);
-
RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->estimated_ul_buffer;
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_UE0_BO, UE_template->estimated_ul_buffer);
//if ((UE_is_to_be_scheduled(module_idP, CC_id, UE_id) > 0) && (subframeP == 5)) {
if ((UE_template->ul_SR > 0 || round_UL > 0 || status < RRC_CONNECTED) && (subframeP == 5)) {
- /*
+ /*
* if there is information on bsr of DCCH, DTCH,
- * or if there is UL_SR,
- * or if there is a packet to retransmit,
+ * or if there is UL_SR,
+ * or if there is a packet to retransmit,
* or we want to schedule a periodic feedback every frame
*/
-
LOG_D(MAC,"[eNB %d][PUSCH %d] Frame %d subframe %d Scheduling UE %d/%x in round_UL %d(SR %d,UL_inactivity timer %d,UL_failure timer %d,cqi_req_timer %d)\n",
module_idP,
harq_pid,
@@ -2039,42 +1935,40 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
UE_template->ul_SR,
UE_sched_ctrl->ul_inactivity_timer,
UE_sched_ctrl->ul_failure_timer,
- UE_sched_ctrl->cqi_req_timer);
-
+ UE_sched_ctrl->cqi_req_timer);
/* Reset the scheduling request */
emtc_active[CC_id] = 1;
- UE_template->ul_SR = 0;
- status = mac_eNB_get_rrc_status(module_idP,rnti);
- cqi_req = 0;
-
+ UE_template->ul_SR = 0;
+ status = mac_eNB_get_rrc_status(module_idP,rnti);
+ cqi_req = 0;
/* Power control: compute the expected ULSCH RX power (for the stats) */
/* This is the normalized RX power and this should be constant (regardless of mcs) */
- normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id];
- target_rx_power = 178;
-
+ normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id];
+ target_rx_power = 178;
/* This assumes accumulated tpc */
/* Make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out */
int32_t framex10psubframe = UE_template->pusch_tpc_tx_frame * 10 + UE_template->pusch_tpc_tx_subframe;
+
if (((framex10psubframe + 10) <= (frameP * 10 + subframeP)) || // normal case
- ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) // frame wrap-around
- {
- UE_template->pusch_tpc_tx_frame = frameP;
- UE_template->pusch_tpc_tx_subframe = subframeP;
- if (normalized_rx_power > (target_rx_power + 4)) {
- tpc = 0; //-1
- UE_sched_ctrl->tpc_accumulated[CC_id]--;
- } else if (normalized_rx_power < (target_rx_power - 4)) {
- tpc = 2; //+1
- UE_sched_ctrl->tpc_accumulated[CC_id]++;
- } else {
- tpc = 1; //0
- }
- } else {
+ ((framex10psubframe > (frameP * 10 + subframeP)) && (((10240 - framex10psubframe + frameP * 10 + subframeP) >= 10)))) { // frame wrap-around
+ UE_template->pusch_tpc_tx_frame = frameP;
+ UE_template->pusch_tpc_tx_subframe = subframeP;
+
+ if (normalized_rx_power > (target_rx_power + 4)) {
+ tpc = 0; //-1
+ UE_sched_ctrl->tpc_accumulated[CC_id]--;
+ } else if (normalized_rx_power < (target_rx_power - 4)) {
+ tpc = 2; //+1
+ UE_sched_ctrl->tpc_accumulated[CC_id]++;
+ } else {
tpc = 1; //0
}
+ } else {
+ tpc = 1; //0
+ }
if (tpc != 1) {
- LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
+ LOG_D(MAC,"[eNB %d] ULSCH scheduler: frame %d, subframe %d, harq_pid %d, tpc %d, accumulated %d, normalized/target rx power %d/%d\n",
module_idP,
frameP,
subframeP,
@@ -2083,38 +1977,34 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
UE_sched_ctrl->tpc_accumulated[CC_id],
normalized_rx_power,
target_rx_power);
- }
+ }
/* New transmission */
if (round_UL == 0) {
ndi = 1 - UE_template->oldNDI_UL[harq_pid];
-
UE_template->oldNDI_UL[harq_pid] = ndi;
- UE_template->mcs_UL[harq_pid] = 4;
+ UE_template->mcs_UL[harq_pid] = 4;
UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid], 6);
-
UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power = normalized_rx_power;
UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power = target_rx_power;
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = 4;
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = UE_template->mcs_UL[harq_pid];
UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += 6;
UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = UE_template->TBS_UL[harq_pid];
-
- T(T_ENB_MAC_UE_UL_SCHEDULE,
- T_INT(module_idP),
- T_INT(CC_id),
- T_INT(rnti),
+ T(T_ENB_MAC_UE_UL_SCHEDULE,
+ T_INT(module_idP),
+ T_INT(CC_id),
+ T_INT(rnti),
T_INT(frameP),
- T_INT(subframeP),
- T_INT(harq_pid),
- T_INT(UE_template->mcs_UL[harq_pid]),
- T_INT(0),
+ T_INT(subframeP),
+ T_INT(harq_pid),
+ T_INT(UE_template->mcs_UL[harq_pid]),
+ T_INT(0),
T_INT(6),
- T_INT(UE_template->TBS_UL[harq_pid]),
+ T_INT(UE_template->TBS_UL[harq_pid]),
T_INT(ndi));
-
/* Store for possible retransmission */
- UE_template->nb_rb_ul[harq_pid] = 6;
+ UE_template->nb_rb_ul[harq_pid] = 6;
UE_sched_ctrl->ul_scheduled |= (1 << harq_pid);
if (UE_id == UE_list->head) {
@@ -2122,34 +2012,28 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
}
/* Adjust total UL buffer status by TBS, wait for UL sdus to do final update */
- UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid];
-
- LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes);
-
+ UE_template->scheduled_ul_bytes += UE_template->TBS_UL[harq_pid];
+ LOG_D(MAC, "scheduled_ul_bytes, new %d\n", UE_template->scheduled_ul_bytes);
/* Cyclic shift for DMRS */
cshift = 0; // values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1)
/* save it for a potential retransmission */
- UE_template->cshift[harq_pid] = cshift;
-
+ UE_template->cshift[harq_pid] = cshift;
AssertFatal (UE_template->physicalConfigDedicated != NULL, "UE_template->physicalConfigDedicated is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, "UE_template->physicalConfigDedicated->ext4 is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n");
- AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
- AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
-
- LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
-
- AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
+ AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup,
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
+ AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
+ LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
+ AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
AssertFatal(epdcch_setconfig_r11->ext2 != NULL, "epdcch_setconfig_r11->ext2 is null\n");
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
- AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup,
- "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
+ AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup,
+ "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 != NULL, "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null");
- AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup,
- "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
-
+ AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup,
+ "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL 6-0A MPDCCH for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d, UESS MPDCCH Narrowband %d\n",
harq_pid,
frameP,
@@ -2159,58 +2043,49 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
sched_frame,
sched_subframeP,
(int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
-
UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb (cc, epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
-
hi_dci0_pdu = &(hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci + hi_dci0_req->number_of_hi]);
- memset((void*) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
-
- hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
- hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted
-
+ memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
+ hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
+ hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted
AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
-
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti;
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti;
hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2; // already set above...
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid];
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid];
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6;
hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB = 3
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0;
-
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0;
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13 == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off,
- "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n");
-
+ "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n");
hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag = 1 - epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid];
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1;
-
- hi_dci0_req->number_of_dci++;
-
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid];
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1;
+ hi_dci0_req->number_of_dci++;
LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG. Request for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d, UESS mpdcch narrowband %d\n",
harq_pid,
frameP,
@@ -2220,179 +2095,157 @@ void schedule_ulsch_rnti_emtc(module_id_t module_idP,
sched_frame,
sched_subframeP,
(int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
-
- fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
- cqi_req,
- cc,
- UE_template->physicalConfigDedicated,
- get_tmode(module_idP,CC_id,UE_id),
- eNB->ul_handle,
- rnti,
- UE_template->first_rb_ul[harq_pid], // resource_block_start
- UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
- UE_template->mcs_UL[harq_pid],
- cshift, // cyclic_shift_2_for_drms
- 0, // frequency_hopping_enabled_flag
- 0, // frequency_hopping_bits
- UE_template->oldNDI_UL[harq_pid], // new_data_indication
- rvidx_tab[round_UL&3], // redundancy_version
- harq_pid, // harq_process_number
- 0, // ul_tx_mode
- 0, // current_tx_nb
- 0, // n_srs
- UE_template->TBS_UL[harq_pid]
- );
-
+ fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+ cqi_req,
+ cc,
+ UE_template->physicalConfigDedicated,
+ get_tmode(module_idP,CC_id,UE_id),
+ eNB->ul_handle,
+ rnti,
+ UE_template->first_rb_ul[harq_pid], // resource_block_start
+ UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
+ UE_template->mcs_UL[harq_pid],
+ cshift, // cyclic_shift_2_for_drms
+ 0, // frequency_hopping_enabled_flag
+ 0, // frequency_hopping_bits
+ UE_template->oldNDI_UL[harq_pid], // new_data_indication
+ rvidx_tab[round_UL&3], // redundancy_version
+ harq_pid, // harq_process_number
+ 0, // ul_tx_mode
+ 0, // current_tx_nb
+ 0, // n_srs
+ UE_template->TBS_UL[harq_pid]
+ );
fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
- UE_template->rach_resource_type > 2 ? 2 : 1,
- 1, // total_number_of_repetitions
- 1, // repetition_number
- (frameP * 10) + subframeP);
-
- ul_req_tmp->number_of_pdus++;
- eNB->ul_handle++;
-
- add_ue_ulsch_info(module_idP,
- CC_id,
- UE_id,
- subframeP,
- S_UL_SCHEDULED);
-
- LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n",
+ UE_template->rach_resource_type > 2 ? 2 : 1,
+ 1, // total_number_of_repetitions
+ 1, // repetition_number
+ (frameP * 10) + subframeP);
+ ul_req_tmp->number_of_pdus++;
+ eNB->ul_handle++;
+ add_ue_ulsch_info(module_idP,
+ CC_id,
+ UE_id,
+ subframeP,
+ S_UL_SCHEDULED);
+ LOG_D(MAC,"[eNB %d] CC_id %d Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n",
module_idP,
CC_id,
frameP,
subframeP,
UE_id);
-
} else { // round_UL > 0 => retransmission
- /* In LTE-M the UL HARQ process is asynchronous */
- T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION,
- T_INT(module_idP),
- T_INT(CC_id),
- T_INT(rnti),
+ /* In LTE-M the UL HARQ process is asynchronous */
+ T(T_ENB_MAC_UE_UL_SCHEDULE_RETRANSMISSION,
+ T_INT(module_idP),
+ T_INT(CC_id),
+ T_INT(rnti),
T_INT(frameP),
- T_INT(subframeP),
- T_INT(harq_pid),
- T_INT(UE_template->mcs_UL[harq_pid]),
- T_INT(0),
+ T_INT(subframeP),
+ T_INT(harq_pid),
+ T_INT(UE_template->mcs_UL[harq_pid]),
+ T_INT(0),
T_INT(6),
T_INT(round_UL));
-
AssertFatal (UE_template->physicalConfigDedicated != NULL, "UE_template->physicalConfigDedicated is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4 != NULL, "UE_template->physicalConfigDedicated->ext4 is null\n");
AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 != NULL, "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11 is null\n");
- AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
- AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
-
- LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
-
- AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
+ AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present == LTE_EPDCCH_Config_r11__config_r11_PR_setup,
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.present != setup\n");
+ AssertFatal (UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 != NULL,
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11 = NULL\n");
+ LTE_EPDCCH_SetConfig_r11_t *epdcch_setconfig_r11 = UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.setConfigToAddModList_r11->list.array[0];
+ AssertFatal(epdcch_setconfig_r11 != NULL, "epdcch_setconfig_r11 is null\n");
AssertFatal(epdcch_setconfig_r11->ext2 != NULL, "epdcch_setconfig_r11->ext2 is null\n");
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13 != NULL, "epdcch_setconfig_r11->ext2->mpdcch_config_r13 is null");
- AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup,
- "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
+ AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->present == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13_PR_setup,
+ "epdcch_setconfig_r11->ext2->mpdcch_config_r13->present is not setup\n");
AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 != NULL, "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310 is null");
- AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup,
- "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
-
+ AssertFatal(epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present == LTE_EPDCCH_SetConfig_r11__ext2__numberPRB_Pairs_v1310_PR_setup,
+ "epdcch_setconfig_r11->ext2->numberPRB_Pairs_v1310->present is not setup\n");
LOG_D(MAC,"[PUSCH %d] Frame %d, Subframe %d: Adding UL 6-0A MPDCCH for BL/CE UE %d/%x, ulsch_frame %d, ulsch_subframe %d,UESS MPDCCH Narrowband %d\n",
- harq_pid,
- frameP,
- subframeP,
- UE_id,
- rnti,
- sched_frame,
- sched_subframeP,
- (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
-
- UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb(cc, epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);
-
+ harq_pid,
+ frameP,
+ subframeP,
+ UE_id,
+ rnti,
+ sched_frame,
+ sched_subframeP,
+ (int)epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1);
+ UE_template->first_rb_ul[harq_pid] = narrowband_to_first_rb(cc, epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13-1);
hi_dci0_pdu = &(hi_dci0_req->hi_dci0_pdu_list[hi_dci0_req->number_of_dci+hi_dci0_req->number_of_hi]);
-
- memset((void*) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
-
- hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
- hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1;
+ memset((void *) hi_dci0_pdu, 0, sizeof(nfapi_hi_dci0_request_pdu_t));
+ hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE;
+ hi_dci0_pdu->pdu_size = (uint8_t) (2 + sizeof (nfapi_dl_config_mpdcch_pdu));
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_format = (UE_template->rach_resource_type > 1) ? 5 : 4;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type > 1) ? 2 : 1;
hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_narrowband = epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_Narrowband_r13 - 1;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted
-
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_prb_pairs = 6; // checked above that it has to be this
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_assignment = 0; // Note: this can be dynamic
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mpdcch_transmission_type = epdcch_setconfig_r11->transmissionType_r11; // distibuted
AssertFatal(UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 != NULL,
- "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
-
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid];
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0;
-
+ "UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11 is null\n");
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.start_symbol = *UE_template->physicalConfigDedicated->ext4->epdcch_Config_r11->config_r11.choice.setup.startSymbol_r11;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ecce_index = 0; // Note: this should be dynamic
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.aggreagation_level = 24; // OK for CEModeA r1-3 (9.1.5-1b) or CEModeB r1-4
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti_type = 4; // other
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.rnti = rnti;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ce_mode = (UE_template->rach_resource_type < 3) ? 1 : 2;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.drms_scrambling_init = epdcch_setconfig_r11->dmrs_ScramblingSequenceInt_r11;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.initial_transmission_sf_io = (frameP * 10) + subframeP;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.transmission_power = 6000; // 0dB
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.resource_block_start = UE_template->first_rb_ul[harq_pid];
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_resource_blocks = 6;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.mcs = 4; // adjust according to size of RAR, 208 bits with N1A_PRB=3
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.pusch_repetition_levels = 0;
AssertFatal(epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13 == LTE_EPDCCH_SetConfig_r11__ext2__mpdcch_config_r13__setup__mpdcch_pdsch_HoppingConfig_r13_off,
- "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n");
-
+ "epdcch_setconfig_r11->ext2->mpdcch_config_r13->mpdcch_pdsch_HoppingConfig_r13 is not off\n");
hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.frequency_hopping_flag = 1 - epdcch_setconfig_r11->ext2->mpdcch_config_r13->choice.setup.mpdcch_pdsch_HoppingConfig_r13;
hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.redudency_version = rvidx_tab[round_UL&3];
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid];
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = harq_pid;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0;
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz
- hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1;
-
- hi_dci0_req->number_of_dci++;
-
- fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
- cqi_req,
- cc,
- UE_template->physicalConfigDedicated,
- get_tmode(module_idP,CC_id,UE_id),
- eNB->ul_handle,
- rnti,
- UE_template->first_rb_ul[harq_pid], // resource_block_start
- UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
- UE_template->mcs_UL[harq_pid],
- cshift, // cyclic_shift_2_for_drms
- 0, // frequency_hopping_enabled_flag
- 0, // frequency_hopping_bits
- UE_template->oldNDI_UL[harq_pid], // new_data_indication
- rvidx_tab[round_UL&3], // redundancy_version
- harq_pid, // harq_process_number
- 0, // ul_tx_mode
- 0, // current_tx_nb
- 0, // n_srs
- UE_template->TBS_UL[harq_pid]
- );
-
- fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
- UE_template->rach_resource_type>2 ? 2 : 1,
- 1, //total_number_of_repetitions
- 1, //repetition_number
- (frameP * 10) + subframeP);
-
- ul_req_tmp->number_of_pdus++;
- eNB->ul_handle++;
- }
- } // UE_is_to_be_scheduled
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.new_data_indication = UE_template->oldNDI_UL[harq_pid];
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.harq_process = harq_pid;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tpc = tpc;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.csi_request = cqi_req;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.ul_inex = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dai_presence_flag = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dl_assignment_index = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.srs_request = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.dci_subframe_repetition_number = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.tcp_bitmap = 0;
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.total_dci_length_include_padding = 29; // hard-coded for 10 MHz
+ hi_dci0_pdu->mpdcch_dci_pdu.mpdcch_dci_pdu_rel13.number_of_tx_antenna_ports = 1;
+ hi_dci0_req->number_of_dci++;
+ fill_nfapi_ulsch_config_request_rel8(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+ cqi_req,
+ cc,
+ UE_template->physicalConfigDedicated,
+ get_tmode(module_idP,CC_id,UE_id),
+ eNB->ul_handle,
+ rnti,
+ UE_template->first_rb_ul[harq_pid], // resource_block_start
+ UE_template->nb_rb_ul[harq_pid], // number_of_resource_blocks
+ UE_template->mcs_UL[harq_pid],
+ cshift, // cyclic_shift_2_for_drms
+ 0, // frequency_hopping_enabled_flag
+ 0, // frequency_hopping_bits
+ UE_template->oldNDI_UL[harq_pid], // new_data_indication
+ rvidx_tab[round_UL&3], // redundancy_version
+ harq_pid, // harq_process_number
+ 0, // ul_tx_mode
+ 0, // current_tx_nb
+ 0, // n_srs
+ UE_template->TBS_UL[harq_pid]
+ );
+ fill_nfapi_ulsch_config_request_emtc(&ul_req_tmp->ul_config_pdu_list[ul_req_tmp->number_of_pdus],
+ UE_template->rach_resource_type>2 ? 2 : 1,
+ 1, //total_number_of_repetitions
+ 1, //repetition_number
+ (frameP * 10) + subframeP);
+ ul_req_tmp->number_of_pdus++;
+ eNB->ul_handle++;
+ }
+ } // UE_is_to_be_scheduled
} // ULCCs
} // loop over UE_id
}
diff --git a/openair2/LAYER2/MAC/main_ue.c b/openair2/LAYER2/MAC/main_ue.c
index bf4af9f5a9..f482806e1d 100644
--- a/openair2/LAYER2/MAC/main_ue.c
+++ b/openair2/LAYER2/MAC/main_ue.c
@@ -39,12 +39,12 @@
#include "LAYER2/PDCP_v10.1.0/pdcp.h"
#include "RRC/LTE/rrc_defs.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
#include "common/ran_context.h"
extern FILL_UL_INFO_MUTEX_t fill_ul_mutex;
-extern uint8_t nfapi_mode;
extern void openair_rrc_top_init_ue( int eMBMS_active, char *uecap_xer, uint8_t cba_group_active, uint8_t HO_active);
void dl_phy_sync_success(module_id_t module_idP, frame_t frameP, unsigned char eNB_index, uint8_t first_sync) { //init as MR
@@ -91,7 +91,7 @@ mac_top_init_ue(int eMBMS_active, char *uecap_xer,
}
// mutex below are used for multiple UE's L2 FAPI simulation.
- if (nfapi_mode == 3) {
+ if (NFAPI_MODE == NFAPI_UE_STUB_PNF) {
pthread_mutex_init(&fill_ul_mutex.rx_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.crc_mutex,NULL);
pthread_mutex_init(&fill_ul_mutex.sr_mutex,NULL);
diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c
index d139c8bd47..70cee3e24b 100644
--- a/openair2/LAYER2/MAC/ra_procedures.c
+++ b/openair2/LAYER2/MAC/ra_procedures.c
@@ -40,585 +40,586 @@
#include "RRC/LTE/rrc_extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
#include "OCG_extern.h"
-#include "SIMULATION/TOOLS/sim.h" // for taus
+#include "SIMULATION/TOOLS/sim.h" // for taus
#include "PHY/LTE_TRANSPORT/transport_common_proto.h"
#include "PHY/LTE_ESTIMATION/lte_estimation.h"
-extern uint8_t nfapi_mode;
+
extern UE_MODE_t get_ue_mode(uint8_t Mod_id,uint8_t CC_id,uint8_t eNB_index);
/// This routine implements Section 5.1.2 (UE Random Access Resource Selection) from 36.321
void
get_prach_resources(module_id_t module_idP,
- int CC_id,
- uint8_t eNB_index,
- uint8_t t_id,
- uint8_t first_Msg3,
- LTE_RACH_ConfigDedicated_t * rach_ConfigDedicated)
-{
- uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size;
- PRACH_RESOURCES_t *prach_resources =
- &UE_mac_inst[module_idP].RA_prach_resources;
- LTE_RACH_ConfigCommon_t *rach_ConfigCommon = NULL;
- uint8_t noGroupB = 0;
- uint8_t f_id = 0, num_prach = 0;
- int numberOfRA_Preambles;
- int messageSizeGroupA;
- int sizeOfRA_PreamblesGroupA;
- int messagePowerOffsetGroupB;
- int PLThreshold;
+ int CC_id,
+ uint8_t eNB_index,
+ uint8_t t_id,
+ uint8_t first_Msg3,
+ LTE_RACH_ConfigDedicated_t *rach_ConfigDedicated) {
+ uint8_t Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size;
+ PRACH_RESOURCES_t *prach_resources =
+ &UE_mac_inst[module_idP].RA_prach_resources;
+ LTE_RACH_ConfigCommon_t *rach_ConfigCommon = NULL;
+ uint8_t noGroupB = 0;
+ uint8_t f_id = 0, num_prach = 0;
+ int numberOfRA_Preambles;
+ int messageSizeGroupA;
+ int sizeOfRA_PreamblesGroupA;
+ int messagePowerOffsetGroupB;
+ int PLThreshold;
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
+ AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon != NULL,
+ "[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",
+ module_idP);
+ rach_ConfigCommon =
+ &UE_mac_inst[module_idP].radioResourceConfigCommon->
+ rach_ConfigCommon;
+ numberOfRA_Preambles =
+ (1 + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) << 2;
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
- AssertFatal(UE_mac_inst[module_idP].radioResourceConfigCommon != NULL,
- "[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",
- module_idP);
+ if (rach_ConfigDedicated) { // This is for network controlled Mobility, later
+ if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) {
+ prach_resources->ra_PreambleIndex =
+ rach_ConfigDedicated->ra_PreambleIndex;
+ prach_resources->ra_RACH_MaskIndex =
+ rach_ConfigDedicated->ra_PRACH_MaskIndex;
+ return;
+ }
+ }
- rach_ConfigCommon =
- &UE_mac_inst[module_idP].radioResourceConfigCommon->
- rach_ConfigCommon;
- numberOfRA_Preambles =
- (1 + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) << 2;
+ /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */
+ messageSizeGroupA = -1;
- if (rach_ConfigDedicated) { // This is for network controlled Mobility, later
- if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) {
- prach_resources->ra_PreambleIndex =
- rach_ConfigDedicated->ra_PreambleIndex;
- prach_resources->ra_RACH_MaskIndex =
- rach_ConfigDedicated->ra_PRACH_MaskIndex;
- return;
- }
+ if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) {
+ noGroupB = 1;
+ } else {
+ sizeOfRA_PreamblesGroupA =
+ (rach_ConfigCommon->preambleInfo.
+ preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + 1) << 2;
+
+ switch (rach_ConfigCommon->preambleInfo.
+ preamblesGroupAConfig->messageSizeGroupA) {
+ case 0:
+ messageSizeGroupA = 56;
+ break;
+
+ case 1:
+ messageSizeGroupA = 144;
+ break;
+
+ case 2:
+ messageSizeGroupA = 208;
+ break;
+
+ case 3:
+ messageSizeGroupA = 256;
+ break;
}
- /* TODO: gcc warns if this variable is not always set, let's put -1 for no more warning */
- messageSizeGroupA = -1;
+ /* TODO: what value to use as default? */
+ messagePowerOffsetGroupB = -9999;
- if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) {
- noGroupB = 1;
+ switch (rach_ConfigCommon->preambleInfo.
+ preamblesGroupAConfig->messagePowerOffsetGroupB) {
+ case 0:
+ messagePowerOffsetGroupB = -9999;
+ break;
+
+ case 1:
+ messagePowerOffsetGroupB = 0;
+ break;
+
+ case 2:
+ messagePowerOffsetGroupB = 5;
+ break;
+
+ case 3:
+ messagePowerOffsetGroupB = 8;
+ break;
+
+ case 4:
+ messagePowerOffsetGroupB = 10;
+ break;
+
+ case 5:
+ messagePowerOffsetGroupB = 12;
+ break;
+
+ case 6:
+ messagePowerOffsetGroupB = 15;
+ break;
+
+ case 7:
+ messagePowerOffsetGroupB = 18;
+ break;
+ }
+
+ PLThreshold =
+ 0 - get_DELTA_PREAMBLE(module_idP,
+ CC_id) -
+ get_Po_NOMINAL_PUSCH(module_idP,
+ CC_id) - messagePowerOffsetGroupB;
+ // Note Pcmax is set to 0 here, we have to fix this
+
+ if (sizeOfRA_PreamblesGroupA == numberOfRA_Preambles) {
+ noGroupB = 1;
+ }
+ }
+
+ if (first_Msg3 == 1) {
+ if (noGroupB == 1) {
+ // use Group A procedure
+ UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
+ (taus()) % numberOfRA_Preambles;
+ UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
+ 0;
+ UE_mac_inst[module_idP].RA_usedGroupA = 1;
+ } else if ((Msg3_size < messageSizeGroupA) ||
+ (get_PL(module_idP, 0, eNB_index) > PLThreshold)) {
+ // use Group A procedure
+ UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
+ (taus()) % sizeOfRA_PreamblesGroupA;
+ UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
+ 0;
+ UE_mac_inst[module_idP].RA_usedGroupA = 1;
+ } else { // use Group B
+ UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
+ sizeOfRA_PreamblesGroupA +
+ (taus()) % (numberOfRA_Preambles -
+ sizeOfRA_PreamblesGroupA);
+ UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
+ 0;
+ UE_mac_inst[module_idP].RA_usedGroupA = 0;
+ }
+
+ UE_mac_inst[module_idP].
+ RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER =
+ get_Po_NOMINAL_PUSCH(module_idP, CC_id);
+ } else { // Msg3 is being retransmitted
+ if (UE_mac_inst[module_idP].RA_usedGroupA == 1) {
+ if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) {
+ UE_mac_inst[module_idP].RA_prach_resources.
+ ra_PreambleIndex =
+ (taus()) %
+ rach_ConfigCommon->preambleInfo.
+ preamblesGroupAConfig->sizeOfRA_PreamblesGroupA;
+ } else {
+ UE_mac_inst[module_idP].RA_prach_resources.
+ ra_PreambleIndex = (taus()) & 0x3f;
+ }
+
+ UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
+ 0;
} else {
- sizeOfRA_PreamblesGroupA =
- (rach_ConfigCommon->preambleInfo.
- preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + 1) << 2;
- switch (rach_ConfigCommon->preambleInfo.
- preamblesGroupAConfig->messageSizeGroupA) {
- case 0:
- messageSizeGroupA = 56;
- break;
- case 1:
- messageSizeGroupA = 144;
- break;
- case 2:
- messageSizeGroupA = 208;
- break;
- case 3:
- messageSizeGroupA = 256;
- break;
- }
+ // FIXME rach_ConfigCommon->preambleInfo.preamblesGroupAConfig may be zero
+ UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
+ rach_ConfigCommon->preambleInfo.
+ preamblesGroupAConfig->sizeOfRA_PreamblesGroupA +
+ (taus()) %
+ (rach_ConfigCommon->preambleInfo.numberOfRA_Preambles -
+ rach_ConfigCommon->preambleInfo.
+ preamblesGroupAConfig->sizeOfRA_PreamblesGroupA);
+ UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
+ 0;
+ }
+ }
- /* TODO: what value to use as default? */
- messagePowerOffsetGroupB = -9999;
- switch (rach_ConfigCommon->preambleInfo.
- preamblesGroupAConfig->messagePowerOffsetGroupB) {
- case 0:
- messagePowerOffsetGroupB = -9999;
- break;
- case 1:
- messagePowerOffsetGroupB = 0;
- break;
- case 2:
- messagePowerOffsetGroupB = 5;
- break;
- case 3:
- messagePowerOffsetGroupB = 8;
- break;
- case 4:
- messagePowerOffsetGroupB = 10;
- break;
- case 5:
- messagePowerOffsetGroupB = 12;
- break;
- case 6:
- messagePowerOffsetGroupB = 15;
- break;
- case 7:
- messagePowerOffsetGroupB = 18;
- break;
- }
+ // choose random PRACH resource in TDD
+ if (UE_mac_inst[module_idP].tdd_Config) {
+ num_prach = get_num_prach_tdd(module_idP);
- PLThreshold =
- 0 - get_DELTA_PREAMBLE(module_idP,
- CC_id) -
- get_Po_NOMINAL_PUSCH(module_idP,
- CC_id) - messagePowerOffsetGroupB;
- // Note Pcmax is set to 0 here, we have to fix this
-
- if (sizeOfRA_PreamblesGroupA == numberOfRA_Preambles) {
- noGroupB = 1;
- }
+ if ((num_prach > 0) && (num_prach < 6)) {
+ UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index =
+ (taus() % num_prach);
}
- if (first_Msg3 == 1) {
- if (noGroupB == 1) {
- // use Group A procedure
- UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
- (taus()) % numberOfRA_Preambles;
- UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
- 0;
- UE_mac_inst[module_idP].RA_usedGroupA = 1;
- } else if ((Msg3_size < messageSizeGroupA) ||
- (get_PL(module_idP, 0, eNB_index) > PLThreshold)) {
- // use Group A procedure
- UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
- (taus()) % sizeOfRA_PreamblesGroupA;
- UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
- 0;
- UE_mac_inst[module_idP].RA_usedGroupA = 1;
- } else { // use Group B
- UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
- sizeOfRA_PreamblesGroupA +
- (taus()) % (numberOfRA_Preambles -
- sizeOfRA_PreamblesGroupA);
- UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
- 0;
- UE_mac_inst[module_idP].RA_usedGroupA = 0;
- }
+ f_id = get_fid_prach_tdd(module_idP,
+ UE_mac_inst
+ [module_idP].RA_prach_resources.
+ ra_TDD_map_index);
+ }
- UE_mac_inst[module_idP].
- RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER =
- get_Po_NOMINAL_PUSCH(module_idP, CC_id);
- } else { // Msg3 is being retransmitted
- if (UE_mac_inst[module_idP].RA_usedGroupA == 1) {
- if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) {
- UE_mac_inst[module_idP].RA_prach_resources.
- ra_PreambleIndex =
- (taus()) %
- rach_ConfigCommon->preambleInfo.
- preamblesGroupAConfig->sizeOfRA_PreamblesGroupA;
- } else {
- UE_mac_inst[module_idP].RA_prach_resources.
- ra_PreambleIndex = (taus()) & 0x3f;
- }
-
- UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
- 0;
- } else {
- // FIXME rach_ConfigCommon->preambleInfo.preamblesGroupAConfig may be zero
- UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex =
- rach_ConfigCommon->preambleInfo.
- preamblesGroupAConfig->sizeOfRA_PreamblesGroupA +
- (taus()) %
- (rach_ConfigCommon->preambleInfo.numberOfRA_Preambles -
- rach_ConfigCommon->preambleInfo.
- preamblesGroupAConfig->sizeOfRA_PreamblesGroupA);
- UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex =
- 0;
- }
- }
-
- // choose random PRACH resource in TDD
- if (UE_mac_inst[module_idP].tdd_Config) {
- num_prach = get_num_prach_tdd(module_idP);
-
- if ((num_prach > 0) && (num_prach < 6)) {
- UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index =
- (taus() % num_prach);
- }
-
- f_id = get_fid_prach_tdd(module_idP,
- UE_mac_inst
- [module_idP].RA_prach_resources.
- ra_TDD_map_index);
- }
- // choose RA-RNTI
- UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI =
- 1 + t_id + 10 * f_id;
+ // choose RA-RNTI
+ UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI =
+ 1 + t_id + 10 * f_id;
}
void
Msg1_transmitted(module_id_t module_idP, uint8_t CC_id,
- frame_t frameP, uint8_t eNB_id)
-{
-
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
- // start contention resolution timer
- UE_mac_inst[module_idP].RA_attempt_number++;
-
- if (opt_enabled) {
- trace_pdu(DIRECTION_UPLINK, NULL, 0, module_idP, WS_NO_RNTI,
- UE_mac_inst[module_idP].RA_prach_resources.
- ra_PreambleIndex, UE_mac_inst[module_idP].txFrame,
- UE_mac_inst[module_idP].txSubframe, 0,
- UE_mac_inst[module_idP].RA_attempt_number);
- LOG_D(OPT,
- "[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n",
- module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size);
- }
+ frame_t frameP, uint8_t eNB_id) {
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
+ // start contention resolution timer
+ UE_mac_inst[module_idP].RA_attempt_number++;
+ if (opt_enabled) {
+ trace_pdu(DIRECTION_UPLINK, NULL, 0, module_idP, WS_NO_RNTI,
+ UE_mac_inst[module_idP].RA_prach_resources.
+ ra_PreambleIndex, UE_mac_inst[module_idP].txFrame,
+ UE_mac_inst[module_idP].txSubframe, 0,
+ UE_mac_inst[module_idP].RA_attempt_number);
+ LOG_D(OPT,
+ "[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n",
+ module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size);
+ }
}
void
Msg3_transmitted(module_id_t module_idP, uint8_t CC_id,
- frame_t frameP, uint8_t eNB_id)
-{
-
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
-
- // start contention resolution timer
- LOG_D(MAC,
- "[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",
- module_idP, frameP);
- UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0;
- UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
-
- if (opt_enabled) { // msg3
- trace_pdu(DIRECTION_UPLINK , &UE_mac_inst[module_idP].CCCH_pdu.payload[0],
- UE_mac_inst[module_idP].RA_Msg3_size, module_idP, WS_C_RNTI,
- UE_mac_inst[module_idP].crnti,
- UE_mac_inst[module_idP].txFrame,
- UE_mac_inst[module_idP].txSubframe, 0, 0);
- LOG_D(OPT,
- "[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n",
- module_idP, frameP, UE_mac_inst[module_idP].crnti
- /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex */
- , UE_mac_inst[module_idP].RA_Msg3_size);
- }
+ frame_t frameP, uint8_t eNB_id) {
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
+ // start contention resolution timer
+ LOG_D(MAC,
+ "[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",
+ module_idP, frameP);
+ UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0;
+ UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1;
+ if (opt_enabled) { // msg3
+ trace_pdu(DIRECTION_UPLINK, &UE_mac_inst[module_idP].CCCH_pdu.payload[0],
+ UE_mac_inst[module_idP].RA_Msg3_size, module_idP, WS_C_RNTI,
+ UE_mac_inst[module_idP].crnti,
+ UE_mac_inst[module_idP].txFrame,
+ UE_mac_inst[module_idP].txSubframe, 0, 0);
+ LOG_D(OPT,
+ "[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n",
+ module_idP, frameP, UE_mac_inst[module_idP].crnti
+ /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex */
+ , UE_mac_inst[module_idP].RA_Msg3_size);
+ }
}
PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP, int CC_id,
- frame_t frameP, uint8_t eNB_indexP,
- sub_frame_t subframeP)
-{
+ frame_t frameP, uint8_t eNB_indexP,
+ sub_frame_t subframeP) {
+ uint8_t Size = 0;
+ UE_MODE_t UE_mode;
- uint8_t Size = 0;
- UE_MODE_t UE_mode;
- // Modification for phy_stub_ue operation
- if(nfapi_mode == 3) { // phy_stub_ue mode
- UE_mode = UE_mac_inst[module_idP].UE_mode[0];
- LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode);
- }
- else { // Full stack mode
- UE_mode = get_ue_mode(module_idP,0,eNB_indexP);
+ // Modification for phy_stub_ue operation
+ if(NFAPI_MODE == NFAPI_UE_STUB_PNF) { // phy_stub_ue mode
+ UE_mode = UE_mac_inst[module_idP].UE_mode[0];
+ LOG_D(MAC, "ue_get_rach , UE_mode: %d", UE_mode);
+ } else { // Full stack mode
+ UE_mode = get_ue_mode(module_idP,0,eNB_indexP);
+ }
+
+ uint8_t lcid = CCCH;
+ uint16_t Size16;
+ struct LTE_RACH_ConfigCommon *rach_ConfigCommon =
+ (struct LTE_RACH_ConfigCommon *) NULL;
+ int32_t frame_diff = 0;
+ uint8_t dcch_header_len = 0;
+ uint16_t sdu_lengths;
+ uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
+
+ if (UE_mode == PRACH) {
+ LOG_D(MAC, "ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active);
+
+ if (UE_mac_inst[module_idP].radioResourceConfigCommon) {
+ rach_ConfigCommon =
+ &UE_mac_inst[module_idP].
+ radioResourceConfigCommon->rach_ConfigCommon;
+ } else {
+ return (NULL);
}
+ if (UE_mac_inst[module_idP].RA_active == 0) {
+ LOG_I(MAC, "RA not active\n");
+ // check if RRC is ready to initiate the RA procedure
+ Size = mac_rrc_data_req_ue(module_idP,
+ CC_id,
+ frameP,
+ CCCH, 1,
+ &UE_mac_inst[module_idP].
+ CCCH_pdu.payload[sizeof
+ (SCH_SUBHEADER_SHORT)
+ + 1], eNB_indexP,
+ 0);
+ Size16 = (uint16_t) Size;
+ // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size);
+ LOG_I(RRC,
+ "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n",
+ frameP, module_idP, eNB_indexP, module_idP);
+ LOG_I(MAC,
+ "[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",
+ module_idP, frameP, Size);
- uint8_t lcid = CCCH;
- uint16_t Size16;
- struct LTE_RACH_ConfigCommon *rach_ConfigCommon =
- (struct LTE_RACH_ConfigCommon *) NULL;
- int32_t frame_diff = 0;
- uint8_t dcch_header_len = 0;
- uint16_t sdu_lengths;
- uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
+ if (Size > 0) {
+ UE_mac_inst[module_idP].RA_active = 1;
+ UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER =
+ 1;
+ UE_mac_inst[module_idP].RA_Msg3_size =
+ Size + sizeof(SCH_SUBHEADER_SHORT) +
+ sizeof(SCH_SUBHEADER_SHORT);
+ UE_mac_inst[module_idP].RA_prachMaskIndex = 0;
+ UE_mac_inst[module_idP].RA_prach_resources.Msg3 =
+ UE_mac_inst[module_idP].CCCH_pdu.payload;
+ UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator)
+ AssertFatal(rach_ConfigCommon != NULL,
+ "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",
+ module_idP, frameP);
+ UE_mac_inst[module_idP].RA_window_cnt =
+ 2 +
+ rach_ConfigCommon->ra_SupervisionInfo.
+ ra_ResponseWindowSize;
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
+ if (UE_mac_inst[module_idP].RA_window_cnt == 9) {
+ UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10!
+ }
- if (UE_mode == PRACH) {
- LOG_D(MAC, "ue_get_rach 3, RA_active value: %d", UE_mac_inst[module_idP].RA_active);
- if (UE_mac_inst[module_idP].radioResourceConfigCommon) {
- rach_ConfigCommon =
- &UE_mac_inst[module_idP].
- radioResourceConfigCommon->rach_ConfigCommon;
- } else {
- return (NULL);
- }
-
- if (UE_mac_inst[module_idP].RA_active == 0) {
- LOG_I(MAC, "RA not active\n");
- // check if RRC is ready to initiate the RA procedure
- Size = mac_rrc_data_req_ue(module_idP,
- CC_id,
- frameP,
- CCCH, 1,
- &UE_mac_inst[module_idP].
- CCCH_pdu.payload[sizeof
- (SCH_SUBHEADER_SHORT)
- + 1], eNB_indexP,
- 0);
- Size16 = (uint16_t) Size;
-
- // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size);
- LOG_I(RRC,
- "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n",
- frameP, module_idP, eNB_indexP, module_idP);
- LOG_I(MAC,
- "[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",
- module_idP, frameP, Size);
-
- if (Size > 0) {
- UE_mac_inst[module_idP].RA_active = 1;
- UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER =
- 1;
- UE_mac_inst[module_idP].RA_Msg3_size =
- Size + sizeof(SCH_SUBHEADER_SHORT) +
- sizeof(SCH_SUBHEADER_SHORT);
- UE_mac_inst[module_idP].RA_prachMaskIndex = 0;
- UE_mac_inst[module_idP].RA_prach_resources.Msg3 =
- UE_mac_inst[module_idP].CCCH_pdu.payload;
- UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator)
-
- AssertFatal(rach_ConfigCommon != NULL,
- "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",
- module_idP, frameP);
- UE_mac_inst[module_idP].RA_window_cnt =
- 2 +
- rach_ConfigCommon->ra_SupervisionInfo.
- ra_ResponseWindowSize;
-
- if (UE_mac_inst[module_idP].RA_window_cnt == 9) {
- UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10!
- }
-
- UE_mac_inst[module_idP].RA_tx_frame = frameP;
- UE_mac_inst[module_idP].RA_tx_subframe = subframeP;
- UE_mac_inst[module_idP].RA_backoff_frame = frameP;
- UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
- // Fill in preamble and PRACH resource
- get_prach_resources(module_idP, CC_id, eNB_indexP,
- subframeP, 1, NULL);
-
- generate_ulsch_header((uint8_t *) & UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header
- 1, // num sdus
- 0, // short pading
- &Size16, // sdu length
- &lcid, // sdu lcid
- NULL, // power headroom
- NULL, // crnti
- NULL, // truncated bsr
- NULL, // short bsr
- NULL, // long_bsr
- 1); //post_padding
- return (&UE_mac_inst[module_idP].RA_prach_resources);
-
- } else if (UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
- scheduling_info.LCGID
- [DCCH]] > 0) {
- // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example)
- dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element
- LOG_USEDINLOG_VAR(mac_rlc_status_resp_t,rlc_status)=mac_rlc_status_ind(module_idP,
- UE_mac_inst[module_idP].crnti,
- eNB_indexP, frameP, subframeP,
- ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6
+ UE_mac_inst[module_idP].RA_tx_frame = frameP;
+ UE_mac_inst[module_idP].RA_tx_subframe = subframeP;
+ UE_mac_inst[module_idP].RA_backoff_frame = frameP;
+ UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
+ // Fill in preamble and PRACH resource
+ get_prach_resources(module_idP, CC_id, eNB_indexP,
+ subframeP, 1, NULL);
+ generate_ulsch_header((uint8_t *) & UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header
+ 1, // num sdus
+ 0, // short pading
+ &Size16, // sdu length
+ &lcid, // sdu lcid
+ NULL, // power headroom
+ NULL, // crnti
+ NULL, // truncated bsr
+ NULL, // short bsr
+ NULL, // long_bsr
+ 1); //post_padding
+ return (&UE_mac_inst[module_idP].RA_prach_resources);
+ } else if (UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
+ scheduling_info.LCGID
+ [DCCH]] > 0) {
+ // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example)
+ dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element
+ LOG_USEDINLOG_VAR(mac_rlc_status_resp_t,rlc_status)=mac_rlc_status_ind(module_idP,
+ UE_mac_inst[module_idP].crnti,
+ eNB_indexP, frameP, subframeP,
+ ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,0, 0
+ ,0, 0
#endif
- );
+ );
- if (UE_mac_inst[module_idP].crnti_before_ho)
- LOG_D(MAC,
- "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n",
- module_idP, frameP,
- UE_mac_inst[module_idP].crnti,
- UE_mac_inst[module_idP].crnti_before_ho,
- rlc_status.bytes_in_buffer, dcch_header_len);
- else
- LOG_D(MAC,
- "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n",
- module_idP, frameP, rlc_status.bytes_in_buffer,
- dcch_header_len);
+ if (UE_mac_inst[module_idP].crnti_before_ho)
+ LOG_D(MAC,
+ "[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n",
+ module_idP, frameP,
+ UE_mac_inst[module_idP].crnti,
+ UE_mac_inst[module_idP].crnti_before_ho,
+ rlc_status.bytes_in_buffer, dcch_header_len);
+ else
+ LOG_D(MAC,
+ "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n",
+ module_idP, frameP, rlc_status.bytes_in_buffer,
+ dcch_header_len);
- sdu_lengths = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used
- (char *) &ulsch_buff[0]
+ sdu_lengths = mac_rlc_data_req(module_idP, UE_mac_inst[module_idP].crnti, eNB_indexP, frameP, ENB_FLAG_NO, MBMS_FLAG_NO, DCCH, 6, //not used
+ (char *) &ulsch_buff[0]
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,0,
- 0
+ ,0,
+ 0
#endif
- );
+ );
- if(sdu_lengths > 0)
- LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n",
- module_idP, sdu_lengths);
- else
- LOG_E(MAC, "[UE %d] TX DCCH error\n",
- module_idP );
+ if(sdu_lengths > 0)
+ LOG_D(MAC, "[UE %d] TX Got %d bytes for DCCH\n",
+ module_idP, sdu_lengths);
+ else
+ LOG_E(MAC, "[UE %d] TX DCCH error\n",
+ module_idP );
- update_bsr(module_idP, frameP, subframeP, eNB_indexP);
- UE_mac_inst[module_idP].
- scheduling_info.BSR[UE_mac_inst[module_idP].
- scheduling_info.LCGID[DCCH]] =
- locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE,
- UE_mac_inst
- [module_idP].scheduling_info.BSR_bytes
- [UE_mac_inst
- [module_idP].scheduling_info.LCGID
- [DCCH]]);
+ update_bsr(module_idP, frameP, subframeP, eNB_indexP);
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR[UE_mac_inst[module_idP].
+ scheduling_info.LCGID[DCCH]] =
+ locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE,
+ UE_mac_inst
+ [module_idP].scheduling_info.BSR_bytes
+ [UE_mac_inst
+ [module_idP].scheduling_info.LCGID
+ [DCCH]]);
+ //TO DO: fill BSR infos in UL TBS
+ //header_len +=2;
+ UE_mac_inst[module_idP].RA_active = 1;
+ UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER =
+ 1;
+ UE_mac_inst[module_idP].RA_Msg3_size =
+ Size + dcch_header_len;
+ UE_mac_inst[module_idP].RA_prachMaskIndex = 0;
+ UE_mac_inst[module_idP].RA_prach_resources.Msg3 =
+ ulsch_buff;
+ UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator)
+ AssertFatal(rach_ConfigCommon != NULL,
+ "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",
+ module_idP, frameP);
+ UE_mac_inst[module_idP].RA_window_cnt =
+ 2 +
+ rach_ConfigCommon->ra_SupervisionInfo.
+ ra_ResponseWindowSize;
- //TO DO: fill BSR infos in UL TBS
+ if (UE_mac_inst[module_idP].RA_window_cnt == 9) {
+ UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10!
+ }
- //header_len +=2;
- UE_mac_inst[module_idP].RA_active = 1;
- UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER =
- 1;
- UE_mac_inst[module_idP].RA_Msg3_size =
- Size + dcch_header_len;
- UE_mac_inst[module_idP].RA_prachMaskIndex = 0;
- UE_mac_inst[module_idP].RA_prach_resources.Msg3 =
- ulsch_buff;
- UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator)
+ UE_mac_inst[module_idP].RA_tx_frame = frameP;
+ UE_mac_inst[module_idP].RA_tx_subframe = subframeP;
+ UE_mac_inst[module_idP].RA_backoff_frame = frameP;
+ UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
+ // Fill in preamble and PRACH resource
+ get_prach_resources(module_idP, CC_id, eNB_indexP,
+ subframeP, 1, NULL);
+ generate_ulsch_header((uint8_t *) ulsch_buff, // mac header
+ 1, // num sdus
+ 0, // short pading
+ &Size16, // sdu length
+ &lcid, // sdu lcid
+ NULL, // power headroom
+ &UE_mac_inst[module_idP].crnti, // crnti
+ NULL, // truncated bsr
+ NULL, // short bsr
+ NULL, // long_bsr
+ 0); //post_padding
+ return (&UE_mac_inst[module_idP].RA_prach_resources);
+ }
+ } else { // RACH is active
+ LOG_D(MAC,
+ "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",
+ module_idP, frameP, subframeP,
+ UE_mac_inst[module_idP].RA_window_cnt,
+ UE_mac_inst[module_idP].RA_tx_frame,
+ UE_mac_inst[module_idP].RA_tx_subframe);
- AssertFatal(rach_ConfigCommon != NULL,
- "[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",
- module_idP, frameP);
- UE_mac_inst[module_idP].RA_window_cnt =
- 2 +
- rach_ConfigCommon->ra_SupervisionInfo.
- ra_ResponseWindowSize;
+ // compute backoff parameters
+ if (UE_mac_inst[module_idP].RA_backoff_cnt > 0) {
+ frame_diff =
+ (sframe_t) frameP -
+ UE_mac_inst[module_idP].RA_backoff_frame;
- if (UE_mac_inst[module_idP].RA_window_cnt == 9) {
- UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10!
- }
+ if (frame_diff < 0) {
+ frame_diff = -frame_diff;
+ }
+ UE_mac_inst[module_idP].RA_backoff_cnt -=
+ ((10 * frame_diff) +
+ (subframeP -
+ UE_mac_inst[module_idP].RA_backoff_subframe));
+ UE_mac_inst[module_idP].RA_backoff_frame = frameP;
+ UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
+ }
- UE_mac_inst[module_idP].RA_tx_frame = frameP;
- UE_mac_inst[module_idP].RA_tx_subframe = subframeP;
- UE_mac_inst[module_idP].RA_backoff_frame = frameP;
- UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
- // Fill in preamble and PRACH resource
- get_prach_resources(module_idP, CC_id, eNB_indexP,
- subframeP, 1, NULL);
- generate_ulsch_header((uint8_t *) ulsch_buff, // mac header
- 1, // num sdus
- 0, // short pading
- &Size16, // sdu length
- &lcid, // sdu lcid
- NULL, // power headroom
- &UE_mac_inst[module_idP].crnti, // crnti
- NULL, // truncated bsr
- NULL, // short bsr
- NULL, // long_bsr
- 0); //post_padding
+ // compute RA window parameters
+ if (UE_mac_inst[module_idP].RA_window_cnt > 0) {
+ frame_diff =
+ (frame_t) frameP - UE_mac_inst[module_idP].RA_tx_frame;
- return (&UE_mac_inst[module_idP].RA_prach_resources);
- }
- } else { // RACH is active
- LOG_D(MAC,
- "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",
- module_idP, frameP, subframeP,
- UE_mac_inst[module_idP].RA_window_cnt,
- UE_mac_inst[module_idP].RA_tx_frame,
- UE_mac_inst[module_idP].RA_tx_subframe);
+ if (frame_diff < 0) {
+ frame_diff = -frame_diff;
+ }
- // compute backoff parameters
- if (UE_mac_inst[module_idP].RA_backoff_cnt > 0) {
- frame_diff =
- (sframe_t) frameP -
- UE_mac_inst[module_idP].RA_backoff_frame;
+ UE_mac_inst[module_idP].RA_window_cnt -=
+ ((10 * frame_diff) +
+ (subframeP - UE_mac_inst[module_idP].RA_tx_subframe));
+ LOG_D(MAC,
+ "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",
+ module_idP, frameP, subframeP,
+ UE_mac_inst[module_idP].RA_window_cnt);
+ }
- if (frame_diff < 0) {
- frame_diff = -frame_diff;
- }
+ if ((UE_mac_inst[module_idP].RA_window_cnt <= 0) &&
+ (UE_mac_inst[module_idP].RA_backoff_cnt <= 0)) {
+ UE_mac_inst[module_idP].RA_tx_frame = frameP;
+ UE_mac_inst[module_idP].RA_tx_subframe = subframeP;
+ UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++;
+ UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep << 1); // 2dB increments in ASN.1 definition
+ int preambleTransMax = -1;
- UE_mac_inst[module_idP].RA_backoff_cnt -=
- ((10 * frame_diff) +
- (subframeP -
- UE_mac_inst[module_idP].RA_backoff_subframe));
+ switch (rach_ConfigCommon->ra_SupervisionInfo.
+ preambleTransMax) {
+ case LTE_PreambleTransMax_n3:
+ preambleTransMax = 3;
+ break;
- UE_mac_inst[module_idP].RA_backoff_frame = frameP;
- UE_mac_inst[module_idP].RA_backoff_subframe = subframeP;
- }
- // compute RA window parameters
- if (UE_mac_inst[module_idP].RA_window_cnt > 0) {
- frame_diff =
- (frame_t) frameP - UE_mac_inst[module_idP].RA_tx_frame;
+ case LTE_PreambleTransMax_n4:
+ preambleTransMax = 4;
+ break;
- if (frame_diff < 0) {
- frame_diff = -frame_diff;
- }
+ case LTE_PreambleTransMax_n5:
+ preambleTransMax = 5;
+ break;
- UE_mac_inst[module_idP].RA_window_cnt -=
- ((10 * frame_diff) +
- (subframeP - UE_mac_inst[module_idP].RA_tx_subframe));
- LOG_D(MAC,
- "[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",
- module_idP, frameP, subframeP,
- UE_mac_inst[module_idP].RA_window_cnt);
- }
+ case LTE_PreambleTransMax_n6:
+ preambleTransMax = 6;
+ break;
- if ((UE_mac_inst[module_idP].RA_window_cnt <= 0) &&
- (UE_mac_inst[module_idP].RA_backoff_cnt <= 0)) {
+ case LTE_PreambleTransMax_n7:
+ preambleTransMax = 7;
+ break;
- UE_mac_inst[module_idP].RA_tx_frame = frameP;
- UE_mac_inst[module_idP].RA_tx_subframe = subframeP;
- UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++;
- UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep << 1); // 2dB increments in ASN.1 definition
- int preambleTransMax = -1;
- switch (rach_ConfigCommon->ra_SupervisionInfo.
- preambleTransMax) {
- case LTE_PreambleTransMax_n3:
- preambleTransMax = 3;
- break;
- case LTE_PreambleTransMax_n4:
- preambleTransMax = 4;
- break;
- case LTE_PreambleTransMax_n5:
- preambleTransMax = 5;
- break;
- case LTE_PreambleTransMax_n6:
- preambleTransMax = 6;
- break;
- case LTE_PreambleTransMax_n7:
- preambleTransMax = 7;
- break;
- case LTE_PreambleTransMax_n8:
- preambleTransMax = 8;
- break;
- case LTE_PreambleTransMax_n10:
- preambleTransMax = 10;
- break;
- case LTE_PreambleTransMax_n20:
- preambleTransMax = 20;
- break;
- case LTE_PreambleTransMax_n50:
- preambleTransMax = 50;
- break;
- case LTE_PreambleTransMax_n100:
- preambleTransMax = 100;
- break;
- case LTE_PreambleTransMax_n200:
- preambleTransMax = 200;
- break;
- }
+ case LTE_PreambleTransMax_n8:
+ preambleTransMax = 8;
+ break;
- if (UE_mac_inst[module_idP].
- RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) {
- LOG_D(MAC,
- "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",
- module_idP, frameP, preambleTransMax);
- // send message to RRC
- UE_mac_inst[module_idP].
- RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
- UE_mac_inst[module_idP].
- RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER
- = get_Po_NOMINAL_PUSCH(module_idP, CC_id);
- }
+ case LTE_PreambleTransMax_n10:
+ preambleTransMax = 10;
+ break;
- UE_mac_inst[module_idP].RA_window_cnt =
- 2 +
- rach_ConfigCommon->ra_SupervisionInfo.
- ra_ResponseWindowSize;
- UE_mac_inst[module_idP].RA_backoff_cnt = 0;
+ case LTE_PreambleTransMax_n20:
+ preambleTransMax = 20;
+ break;
- // Fill in preamble and PRACH resource
- get_prach_resources(module_idP, CC_id, eNB_indexP,
- subframeP, 0, NULL);
- return (&UE_mac_inst[module_idP].RA_prach_resources);
- }
- }
- } else if (UE_mode == PUSCH) {
- LOG_D(MAC,
- "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...",
- module_idP);
- AssertFatal(1 == 0, "");
+ case LTE_PreambleTransMax_n50:
+ preambleTransMax = 50;
+ break;
+
+ case LTE_PreambleTransMax_n100:
+ preambleTransMax = 100;
+ break;
+
+ case LTE_PreambleTransMax_n200:
+ preambleTransMax = 200;
+ break;
+ }
+
+ if (UE_mac_inst[module_idP].
+ RA_PREAMBLE_TRANSMISSION_COUNTER == preambleTransMax) {
+ LOG_D(MAC,
+ "[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",
+ module_idP, frameP, preambleTransMax);
+ // send message to RRC
+ UE_mac_inst[module_idP].
+ RA_PREAMBLE_TRANSMISSION_COUNTER = 1;
+ UE_mac_inst[module_idP].
+ RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER
+ = get_Po_NOMINAL_PUSCH(module_idP, CC_id);
+ }
+
+ UE_mac_inst[module_idP].RA_window_cnt =
+ 2 +
+ rach_ConfigCommon->ra_SupervisionInfo.
+ ra_ResponseWindowSize;
+ UE_mac_inst[module_idP].RA_backoff_cnt = 0;
+ // Fill in preamble and PRACH resource
+ get_prach_resources(module_idP, CC_id, eNB_indexP,
+ subframeP, 0, NULL);
+ return (&UE_mac_inst[module_idP].RA_prach_resources);
+ }
}
+ } else if (UE_mode == PUSCH) {
+ LOG_D(MAC,
+ "[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...",
+ module_idP);
+ AssertFatal(1 == 0, "");
+ }
- return (NULL);
+ return (NULL);
}
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 7d77cb62c3..6561cbf625 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -30,7 +30,7 @@
*/
#ifdef EXMIMO
-#include
+ #include
#endif
#include "mac_extern.h"
@@ -46,6 +46,7 @@
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
#include "RRC/LTE/rrc_extern.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "OCG.h"
@@ -55,12 +56,12 @@
#include "pdcp.h"
#if defined(ENABLE_ITTI)
-#include "intertask_interface.h"
+ #include "intertask_interface.h"
#endif
#include "assertions.h"
-#include "SIMULATION/TOOLS/sim.h" // for taus
+#include "SIMULATION/TOOLS/sim.h" // for taus
#define DEBUG_HEADER_PARSING 1
#define ENABLE_MAC_PAYLOAD_DEBUG 1
@@ -68,7 +69,7 @@
extern UL_IND_t *UL_INFO;
-extern uint8_t nfapi_mode;
+
extern int next_ra_frame;
extern module_id_t next_Mod_id;
@@ -80,854 +81,812 @@ extern module_id_t next_Mod_id;
*/
mapping BSR_names[] = {
- {"NONE", 0},
- {"SHORT BSR", 1},
- {"TRUNCATED BSR", 2},
- {"LONG BSR", 3},
- {"PADDING BSR", 4},
- {NULL, -1}
+ {"NONE", 0},
+ {"SHORT BSR", 1},
+ {"TRUNCATED BSR", 2},
+ {"LONG BSR", 3},
+ {"PADDING BSR", 4},
+ {NULL, -1}
};
-void ue_init_mac(module_id_t module_idP)
-{
+void ue_init_mac(module_id_t module_idP) {
+ int i;
+ // default values as deined in 36.331 sec 9.2.2
+ LOG_I(MAC, "[UE%d] Applying default macMainConfig\n", module_idP);
+ //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL;
+ UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer =
+ LTE_RetxBSR_Timer_r12_sf10240;
+ UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer =
+ LTE_PeriodicBSR_Timer_r12_infinity;
+ UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer =
+ LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
+ UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer =
+ LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
+ UE_mac_inst[module_idP].scheduling_info.PathlossChange_db =
+ LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
+ UE_mac_inst[module_idP].PHR_state =
+ LTE_MAC_MainConfig__phr_Config_PR_setup;
+ UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0;
+ UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer = 0;
+ UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running = 0;
+ UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx =
+ LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
+ UE_mac_inst[module_idP].scheduling_info.ttiBundling = 0;
+ UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 = 0;
+ UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10 = 0;
+ UE_mac_inst[module_idP].scheduling_info.drx_config = NULL;
+ UE_mac_inst[module_idP].scheduling_info.phr_config = NULL;
+ // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW.
+ UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF =
+ MAC_UE_BSR_TIMER_NOT_RUNNING;
+ UE_mac_inst[module_idP].scheduling_info.retxBSR_SF =
+ MAC_UE_BSR_TIMER_NOT_RUNNING;
+ UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
+ UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF =
+ get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].
+ scheduling_info.periodicPHR_Timer);
+ UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF =
+ get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].
+ scheduling_info.prohibitPHR_Timer);
+ UE_mac_inst[module_idP].scheduling_info.PathlossChange_db =
+ get_db_dl_PathlossChange(UE_mac_inst[module_idP].
+ scheduling_info.PathlossChange);
+ UE_mac_inst[module_idP].PHR_reporting_active = 0;
- int i;
- // default values as deined in 36.331 sec 9.2.2
- LOG_I(MAC, "[UE%d] Applying default macMainConfig\n", module_idP);
- //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL;
- UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer =
- LTE_RetxBSR_Timer_r12_sf10240;
- UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer =
- LTE_PeriodicBSR_Timer_r12_infinity;
- UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer =
- LTE_MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20;
- UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer =
- LTE_MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20;
- UE_mac_inst[module_idP].scheduling_info.PathlossChange_db =
- LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1;
- UE_mac_inst[module_idP].PHR_state =
- LTE_MAC_MainConfig__phr_Config_PR_setup;
- UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0;
- UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer = 0;
- UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running = 0;
- UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx =
- LTE_MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5;
- UE_mac_inst[module_idP].scheduling_info.ttiBundling = 0;
- UE_mac_inst[module_idP].scheduling_info.extendedBSR_Sizes_r10 = 0;
- UE_mac_inst[module_idP].scheduling_info.extendedPHR_r10 = 0;
- UE_mac_inst[module_idP].scheduling_info.drx_config = NULL;
- UE_mac_inst[module_idP].scheduling_info.phr_config = NULL;
- // set init value 0xFFFF, make sure periodic timer and retx time counters are NOT active, after bsr transmission set the value configured by the NW.
- UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF =
- MAC_UE_BSR_TIMER_NOT_RUNNING;
- UE_mac_inst[module_idP].scheduling_info.retxBSR_SF =
- MAC_UE_BSR_TIMER_NOT_RUNNING;
- UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
+ for (i = 0; i < MAX_NUM_LCID; i++) {
+ LOG_D(MAC,
+ "[UE%d] Applying default logical channel config for LCGID %d\n",
+ module_idP, i);
+ UE_mac_inst[module_idP].scheduling_info.Bj[i] = -1;
+ UE_mac_inst[module_idP].scheduling_info.bucket_size[i] = -1;
- UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF =
- get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].
- scheduling_info.periodicPHR_Timer);
- UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF =
- get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].
- scheduling_info.prohibitPHR_Timer);
- UE_mac_inst[module_idP].scheduling_info.PathlossChange_db =
- get_db_dl_PathlossChange(UE_mac_inst[module_idP].
- scheduling_info.PathlossChange);
- UE_mac_inst[module_idP].PHR_reporting_active = 0;
-
- for (i = 0; i < MAX_NUM_LCID; i++) {
- LOG_D(MAC,
- "[UE%d] Applying default logical channel config for LCGID %d\n",
- module_idP, i);
- UE_mac_inst[module_idP].scheduling_info.Bj[i] = -1;
- UE_mac_inst[module_idP].scheduling_info.bucket_size[i] = -1;
-
- if (i < DTCH) { // initilize all control channels lcgid to 0
- UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 0;
- } else { // initialize all the data channels lcgid to 1
- UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 1;
- }
-
- UE_mac_inst[module_idP].scheduling_info.LCID_status[i] =
- LCID_EMPTY;
- UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0;
+ if (i < DTCH) { // initilize all control channels lcgid to 0
+ UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 0;
+ } else { // initialize all the data channels lcgid to 1
+ UE_mac_inst[module_idP].scheduling_info.LCGID[i] = 1;
}
- if(nfapi_mode == 3) {
- pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL);
- UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH;
- UE_mac_inst[module_idP].first_ULSCH_Tx =0;
- UE_mac_inst[module_idP].SI_Decoded = 0;
- next_ra_frame = 0;
- next_Mod_id = 0;
- tx_request_pdu_list = NULL;
- tx_req_num_elems = 0;
-
+ UE_mac_inst[module_idP].scheduling_info.LCID_status[i] =
+ LCID_EMPTY;
+ UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[i] = 0;
+ }
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
+ pthread_mutex_init(&UE_mac_inst[module_idP].UL_INFO_mutex,NULL);
+ UE_mac_inst[module_idP].UE_mode[0] = NOT_SYNCHED; //PRACH;
+ UE_mac_inst[module_idP].first_ULSCH_Tx =0;
+ UE_mac_inst[module_idP].SI_Decoded = 0;
+ next_ra_frame = 0;
+ next_Mod_id = 0;
+ tx_request_pdu_list = NULL;
+ tx_req_num_elems = 0;
}
#ifdef CBA
- for (i = 0; i < NUM_MAX_CBA_GROUP; i++) {
- UE_mac_inst[module_idP].cba_last_access[i] =
- round(uniform_rngen(1, 30));
- }
+ for (i = 0; i < NUM_MAX_CBA_GROUP; i++) {
+ UE_mac_inst[module_idP].cba_last_access[i] =
+ round(uniform_rngen(1, 30));
+ }
#endif
}
unsigned char *parse_header(unsigned char *mac_header,
- unsigned char *num_ce,
- unsigned char *num_sdu,
- unsigned char *rx_ces,
- unsigned char *rx_lcids,
- unsigned short *rx_lengths,
- unsigned short tb_length)
-{
+ unsigned char *num_ce,
+ unsigned char *num_sdu,
+ unsigned char *rx_ces,
+ unsigned char *rx_lcids,
+ unsigned short *rx_lengths,
+ unsigned short tb_length) {
+ unsigned char not_done = 1, num_ces = 0, num_cont_res =
+ 0, num_padding = 0, num_sdus = 0, lcid, num_sdu_cnt;
+ unsigned char *mac_header_ptr = mac_header;
+ unsigned short length, ce_len = 0;
- unsigned char not_done = 1, num_ces = 0, num_cont_res =
- 0, num_padding = 0, num_sdus = 0, lcid, num_sdu_cnt;
- unsigned char *mac_header_ptr = mac_header;
- unsigned short length, ce_len = 0;
-
- while (not_done == 1) {
-
- if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) {
- // printf("E=0\n");
- not_done = 0;
- }
-
- lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID;
-
- if (lcid < UE_CONT_RES) {
- //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]);
- if (not_done == 0) { // last MAC SDU, length is implicit
- mac_header_ptr++;
- length =
- tb_length - (mac_header_ptr - mac_header) - ce_len;
-
- for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus;
- num_sdu_cnt++) {
- length -= rx_lengths[num_sdu_cnt];
- }
- } else {
- if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) {
- length =
- ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->
- L_MSB & 0x7f)
- << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)->
- L_LSB & 0xff);
- mac_header_ptr += 3;
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] parse long sdu, size %x \n", length);
-#endif
-
- } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) {
- length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L;
- mac_header_ptr += 2;
- }
- }
-
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] sdu %d lcid %d length %d (offset now %ld)\n",
- num_sdus, lcid, length, mac_header_ptr - mac_header);
-#endif
- rx_lcids[num_sdus] = lcid;
- rx_lengths[num_sdus] = length;
- num_sdus++;
- } else { // This is a control element subheader
- if (lcid == SHORT_PADDING) {
- num_padding++;
- mac_header_ptr++;
- } else {
- rx_ces[num_ces] = lcid;
- num_ces++;
- mac_header_ptr++;
-
- if (lcid == TIMING_ADV_CMD) {
- ce_len++;
- } else if (lcid == UE_CONT_RES) {
-
- // FNA: check MAC Header is one of thoses defined in Annex B of 36.321
- // Check there is only 1 Contention Resolution
- if (num_cont_res) {
- LOG_W(MAC,
- "[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n");
- // exit parsing
- return NULL;
-
- }
- // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader
- if ((not_done == 0)
- && ((num_sdus) || (num_ces > 1) || (num_padding))) {
- LOG_W(MAC,
- "[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n",
- num_ces, num_sdus, num_padding);
- // exit parsing
- return NULL;
- }
- num_cont_res++;
- ce_len += 6;
- }
- }
-
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] ce %d lcid %d (offset now %ld)\n", num_ces,
- lcid, mac_header_ptr - mac_header);
-#endif
- }
+ while (not_done == 1) {
+ if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) {
+ // printf("E=0\n");
+ not_done = 0;
}
- *num_ce = num_ces;
- *num_sdu = num_sdus;
+ lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID;
- return (mac_header_ptr);
+ if (lcid < UE_CONT_RES) {
+ //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]);
+ if (not_done == 0) { // last MAC SDU, length is implicit
+ mac_header_ptr++;
+ length =
+ tb_length - (mac_header_ptr - mac_header) - ce_len;
+
+ for (num_sdu_cnt = 0; num_sdu_cnt < num_sdus;
+ num_sdu_cnt++) {
+ length -= rx_lengths[num_sdu_cnt];
+ }
+ } else {
+ if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) {
+ length =
+ ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->
+ L_MSB & 0x7f)
+ << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)->
+ L_LSB & 0xff);
+ mac_header_ptr += 3;
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] parse long sdu, size %x \n", length);
+#endif
+ } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) {
+ length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L;
+ mac_header_ptr += 2;
+ }
+ }
+
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] sdu %d lcid %d length %d (offset now %ld)\n",
+ num_sdus, lcid, length, mac_header_ptr - mac_header);
+#endif
+ rx_lcids[num_sdus] = lcid;
+ rx_lengths[num_sdus] = length;
+ num_sdus++;
+ } else { // This is a control element subheader
+ if (lcid == SHORT_PADDING) {
+ num_padding++;
+ mac_header_ptr++;
+ } else {
+ rx_ces[num_ces] = lcid;
+ num_ces++;
+ mac_header_ptr++;
+
+ if (lcid == TIMING_ADV_CMD) {
+ ce_len++;
+ } else if (lcid == UE_CONT_RES) {
+ // FNA: check MAC Header is one of thoses defined in Annex B of 36.321
+ // Check there is only 1 Contention Resolution
+ if (num_cont_res) {
+ LOG_W(MAC,
+ "[UE] Msg4 Wrong received format: More than 1 Contention Resolution\n");
+ // exit parsing
+ return NULL;
+ }
+
+ // UE_CONT_RES shall never be the last subheader unless this is the only MAC subheader
+ if ((not_done == 0)
+ && ((num_sdus) || (num_ces > 1) || (num_padding))) {
+ LOG_W(MAC,
+ "[UE] Msg4 Wrong received format: Contention Resolution after num_ces=%d num_sdus=%d num_padding=%d\n",
+ num_ces, num_sdus, num_padding);
+ // exit parsing
+ return NULL;
+ }
+
+ num_cont_res++;
+ ce_len += 6;
+ }
+ }
+
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] ce %d lcid %d (offset now %ld)\n", num_ces,
+ lcid, mac_header_ptr - mac_header);
+#endif
+ }
+ }
+
+ *num_ce = num_ces;
+ *num_sdu = num_sdus;
+ return (mac_header_ptr);
}
uint32_t
ue_get_SR(module_id_t module_idP, int CC_id, frame_t frameP,
- uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe)
-{
+ uint8_t eNB_id, uint16_t rnti, sub_frame_t subframe) {
+ // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti
+ // int MGL=6;// measurement gap length in ms
+ int MGRP = 0; // measurement gap repetition period in ms
+ int gapOffset = -1;
+ int T = 0;
+ DevCheck(module_idP < (int) NB_UE_INST, module_idP, NB_UE_INST, 0);
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
- // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti
- // int MGL=6;// measurement gap length in ms
- int MGRP = 0; // measurement gap repetition period in ms
- int gapOffset = -1;
- int T = 0;
-
- DevCheck(module_idP < (int) NB_UE_INST, module_idP, NB_UE_INST, 0);
-
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
-
- // determin the measurement gap
- if (UE_mac_inst[module_idP].measGapConfig != NULL) {
- if (UE_mac_inst[module_idP].measGapConfig->choice.setup.
- gapOffset.present == LTE_MeasGapConfig__setup__gapOffset_PR_gp0) {
- MGRP = 40;
- gapOffset =
- UE_mac_inst[module_idP].measGapConfig->choice.
- setup.gapOffset.choice.gp0;
- } else if (UE_mac_inst[module_idP].measGapConfig->choice.
- setup.gapOffset.present ==
- LTE_MeasGapConfig__setup__gapOffset_PR_gp1) {
- MGRP = 80;
- gapOffset =
- UE_mac_inst[module_idP].measGapConfig->choice.
- setup.gapOffset.choice.gp1;
- } else {
- LOG_W(MAC, "Measurement GAP offset is unknown\n");
- }
-
- T = MGRP / 10;
- DevAssert(T != 0);
-
- //check the measurement gap and sr prohibit timer
- if ((subframe == gapOffset % 10)
- && ((frameP % T) == (floor(gapOffset / 10)))
- && (UE_mac_inst[module_idP].
- scheduling_info.sr_ProhibitTimer_Running == 0)) {
- UE_mac_inst[module_idP].scheduling_info.SR_pending = 1;
- return (0);
- }
- }
-
- if ((UE_mac_inst[module_idP].physicalConfigDedicated != NULL) &&
- (UE_mac_inst[module_idP].scheduling_info.SR_pending == 1) &&
- (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER <
- (1 <<
- (2 +
- UE_mac_inst[module_idP].
- physicalConfigDedicated->schedulingRequestConfig->choice.setup.
- dsr_TransMax)))) {
- LOG_D(MAC,
- "[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
- module_idP, rnti, frameP, subframe,
- UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
- (1 <<
- (2 +
- UE_mac_inst[module_idP].
- physicalConfigDedicated->schedulingRequestConfig->choice.
- setup.dsr_TransMax)),
- UE_mac_inst[module_idP].scheduling_info.SR_pending);
-
- UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++;
-
- // start the sr-prohibittimer : rel 9 and above
- if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured
- UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--;
- UE_mac_inst[module_idP].scheduling_info.
- sr_ProhibitTimer_Running = 1;
- } else {
- UE_mac_inst[module_idP].scheduling_info.
- sr_ProhibitTimer_Running = 0;
- }
-
- LOG_D(MAC,
- "[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
- module_idP, rnti, frameP, subframe,
- UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
- (1 <<
- (2 +
- UE_mac_inst[module_idP].
- physicalConfigDedicated->schedulingRequestConfig->choice.
- setup.dsr_TransMax)),
- UE_mac_inst[module_idP].scheduling_info.SR_pending);
-
- //UE_mac_inst[module_idP].ul_active =1;
- return (1); //instruct phy to signal SR
+ // determin the measurement gap
+ if (UE_mac_inst[module_idP].measGapConfig != NULL) {
+ if (UE_mac_inst[module_idP].measGapConfig->choice.setup.
+ gapOffset.present == LTE_MeasGapConfig__setup__gapOffset_PR_gp0) {
+ MGRP = 40;
+ gapOffset =
+ UE_mac_inst[module_idP].measGapConfig->choice.
+ setup.gapOffset.choice.gp0;
+ } else if (UE_mac_inst[module_idP].measGapConfig->choice.
+ setup.gapOffset.present ==
+ LTE_MeasGapConfig__setup__gapOffset_PR_gp1) {
+ MGRP = 80;
+ gapOffset =
+ UE_mac_inst[module_idP].measGapConfig->choice.
+ setup.gapOffset.choice.gp1;
} else {
- // notify RRC to relase PUCCH/SRS
- // clear any configured dl/ul
- // initiate RA
- if (UE_mac_inst[module_idP].scheduling_info.SR_pending) {
- // release all pucch resource
- UE_mac_inst[module_idP].physicalConfigDedicated = NULL;
- UE_mac_inst[module_idP].ul_active = 0;
- UE_mac_inst[module_idP].BSR_reporting_active =
- BSR_TRIGGER_NONE;
-
- LOG_I(MAC, "[UE %d] Release all SRs \n", module_idP);
- }
- UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
- UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0;
- return (0);
+ LOG_W(MAC, "Measurement GAP offset is unknown\n");
}
+
+ T = MGRP / 10;
+ DevAssert(T != 0);
+
+ //check the measurement gap and sr prohibit timer
+ if ((subframe == gapOffset % 10)
+ && ((frameP % T) == (floor(gapOffset / 10)))
+ && (UE_mac_inst[module_idP].
+ scheduling_info.sr_ProhibitTimer_Running == 0)) {
+ UE_mac_inst[module_idP].scheduling_info.SR_pending = 1;
+ return (0);
+ }
+ }
+
+ if ((UE_mac_inst[module_idP].physicalConfigDedicated != NULL) &&
+ (UE_mac_inst[module_idP].scheduling_info.SR_pending == 1) &&
+ (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER <
+ (1 <<
+ (2 +
+ UE_mac_inst[module_idP].
+ physicalConfigDedicated->schedulingRequestConfig->choice.setup.
+ dsr_TransMax)))) {
+ LOG_D(MAC,
+ "[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
+ module_idP, rnti, frameP, subframe,
+ UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
+ (1 <<
+ (2 +
+ UE_mac_inst[module_idP].
+ physicalConfigDedicated->schedulingRequestConfig->choice.
+ setup.dsr_TransMax)),
+ UE_mac_inst[module_idP].scheduling_info.SR_pending);
+ UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++;
+
+ // start the sr-prohibittimer : rel 9 and above
+ if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured
+ UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--;
+ UE_mac_inst[module_idP].scheduling_info.
+ sr_ProhibitTimer_Running = 1;
+ } else {
+ UE_mac_inst[module_idP].scheduling_info.
+ sr_ProhibitTimer_Running = 0;
+ }
+
+ LOG_D(MAC,
+ "[UE %d][SR %x] Frame %d subframe %d send SR indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n",
+ module_idP, rnti, frameP, subframe,
+ UE_mac_inst[module_idP].scheduling_info.SR_COUNTER,
+ (1 <<
+ (2 +
+ UE_mac_inst[module_idP].
+ physicalConfigDedicated->schedulingRequestConfig->choice.
+ setup.dsr_TransMax)),
+ UE_mac_inst[module_idP].scheduling_info.SR_pending);
+ //UE_mac_inst[module_idP].ul_active =1;
+ return (1); //instruct phy to signal SR
+ } else {
+ // notify RRC to relase PUCCH/SRS
+ // clear any configured dl/ul
+ // initiate RA
+ if (UE_mac_inst[module_idP].scheduling_info.SR_pending) {
+ // release all pucch resource
+ UE_mac_inst[module_idP].physicalConfigDedicated = NULL;
+ UE_mac_inst[module_idP].ul_active = 0;
+ UE_mac_inst[module_idP].BSR_reporting_active =
+ BSR_TRIGGER_NONE;
+ LOG_I(MAC, "[UE %d] Release all SRs \n", module_idP);
+ }
+
+ UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
+ UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0;
+ return (0);
+ }
}
//------------------------------------------------------------------------------
void
ue_send_sdu(module_id_t module_idP,
- uint8_t CC_id,
- frame_t frameP,
- sub_frame_t subframeP,
- uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index)
+ uint8_t CC_id,
+ frame_t frameP,
+ sub_frame_t subframeP,
+ uint8_t *sdu, uint16_t sdu_len, uint8_t eNB_index)
//------------------------------------------------------------------------------
{
-
- unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr;
- unsigned char rx_lcids[NB_RB_MAX];
- unsigned short rx_lengths[NB_RB_MAX];
- unsigned char *tx_sdu;
+ unsigned char rx_ces[MAX_NUM_CE], num_ce, num_sdu, i, *payload_ptr;
+ unsigned char rx_lcids[NB_RB_MAX];
+ unsigned short rx_lengths[NB_RB_MAX];
+ unsigned char *tx_sdu;
#if UE_TIMING_TRACE
- start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
+ start_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN);
-
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_IN);
//LOG_D(MAC,"sdu: %x.%x.%x\n",sdu[0],sdu[1],sdu[2]);
- if (opt_enabled) {
- trace_pdu(DIRECTION_DOWNLINK, sdu, sdu_len, module_idP, WS_C_RNTI,
- UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0);
- LOG_D(OPT,
- "[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
- module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len);
- }
-
- payload_ptr =
- parse_header(sdu, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths,
- sdu_len);
+ if (opt_enabled) {
+ trace_pdu(DIRECTION_DOWNLINK, sdu, sdu_len, module_idP, WS_C_RNTI,
+ UE_mac_inst[module_idP].crnti, frameP, subframeP, 0, 0);
+ LOG_D(OPT,
+ "[UE %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n",
+ module_idP, frameP, UE_mac_inst[module_idP].crnti, sdu_len);
+ }
+ payload_ptr =
+ parse_header(sdu, &num_ce, &num_sdu, rx_ces, rx_lcids, rx_lengths,
+ sdu_len);
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC,
- "[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n",
- module_idP, frameP, eNB_index, num_ce, num_sdu);
+ LOG_D(MAC,
+ "[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n",
+ module_idP, frameP, eNB_index, num_ce, num_sdu);
#endif
-
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
- LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP);
+ LOG_T(MAC, "[UE %d] First 32 bytes of DLSCH : \n", module_idP);
- for (i = 0; i < 32; i++) {
- LOG_T(MAC, "%x.", sdu[i]);
- }
+ for (i = 0; i < 32; i++) {
+ LOG_T(MAC, "%x.", sdu[i]);
+ }
- LOG_T(MAC, "\n");
+ LOG_T(MAC, "\n");
#endif
- if (payload_ptr != NULL) {
+ if (payload_ptr != NULL) {
+ for (i = 0; i < num_ce; i++) {
+ // printf("ce %d : %d\n",i,rx_ces[i]);
+ switch (rx_ces[i]) {
+ case UE_CONT_RES:
+ LOG_I(MAC,
+ "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n",
+ module_idP, frameP, payload_ptr[0], payload_ptr[1],
+ payload_ptr[2], payload_ptr[3], payload_ptr[4],
+ payload_ptr[5]);
- for (i = 0; i < num_ce; i++) {
- // printf("ce %d : %d\n",i,rx_ces[i]);
- switch (rx_ces[i]) {
- case UE_CONT_RES:
+ if (UE_mac_inst[module_idP].RA_active == 1) {
+ LOG_I(MAC,
+ "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n",
+ module_idP, frameP);
+ UE_mac_inst[module_idP].RA_active = 0;
+ // check if RA procedure has finished completely (no contention)
+ tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3];
- LOG_I(MAC,
- "[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n",
- module_idP, frameP, payload_ptr[0], payload_ptr[1],
- payload_ptr[2], payload_ptr[3], payload_ptr[4],
- payload_ptr[5]);
+ //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits)
+ // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT)
+ for (i = 0; i < 6; i++)
+ if (tx_sdu[i] != payload_ptr[i]) {
+ LOG_E(MAC,
+ "[UE %d][RAPROC] Contention detected, RA failed\n",
+ module_idP);
- if (UE_mac_inst[module_idP].RA_active == 1) {
- LOG_I(MAC,
- "[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n",
- module_idP, frameP);
- UE_mac_inst[module_idP].RA_active = 0;
- // check if RA procedure has finished completely (no contention)
- tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3];
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode
+ // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to
+ // PRACH state.
+ LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n");
+ UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH;
+ //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0;
+ } else {
+ ra_failed(module_idP, CC_id, eNB_index);
+ }
- //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits)
- // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT)
- for (i = 0; i < 6; i++)
- if (tx_sdu[i] != payload_ptr[i]) {
- LOG_E(MAC,
- "[UE %d][RAPROC] Contention detected, RA failed\n",
- module_idP);
- if(nfapi_mode == 3) { // phy_stub mode
- // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to
- // PRACH state.
- LOG_I(MAC, "nfapi_mode3: Setting UE_mode BACK to PRACH 1\n");
- UE_mac_inst[module_idP].UE_mode[eNB_index] = PRACH;
- //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0;
- }
- else{
- ra_failed(module_idP, CC_id, eNB_index);
- }
- UE_mac_inst
- [module_idP].
- RA_contention_resolution_timer_active = 0;
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU,
- VCD_FUNCTION_OUT);
- return;
- }
+ UE_mac_inst
+ [module_idP].
+ RA_contention_resolution_timer_active = 0;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU,
+ VCD_FUNCTION_OUT);
+ return;
+ }
- LOG_I(MAC,
- "[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n",
- module_idP, frameP);
- UE_mac_inst
- [module_idP].
- RA_contention_resolution_timer_active = 0;
- if(nfapi_mode == 3) // phy_stub mode
- {
- // Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH
- UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH;
- }
- else { // Full stack mode
- ra_succeeded(module_idP,CC_id,eNB_index);
- }
- }
+ LOG_I(MAC,
+ "[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n",
+ module_idP, frameP);
+ UE_mac_inst
+ [module_idP].
+ RA_contention_resolution_timer_active = 0;
- payload_ptr += 6;
- break;
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode
+ // Modification for phy_stub mode operation here. We only need to change the ue_mode to PUSCH
+ UE_mac_inst[module_idP].UE_mode[eNB_index] = PUSCH;
+ } else { // Full stack mode
+ ra_succeeded(module_idP,CC_id,eNB_index);
+ }
+ }
- case TIMING_ADV_CMD:
+ payload_ptr += 6;
+ break;
+
+ case TIMING_ADV_CMD:
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i,
- payload_ptr[0]);
+ LOG_D(MAC, "[UE] CE %d : UE Timing Advance : %d\n", i,
+ payload_ptr[0]);
#endif
- // Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct?
- if (nfapi_mode!=3)
- {
- process_timing_advance(module_idP,CC_id,payload_ptr[0]);
+ // Eliminate call to process_timing_advance for the phy_stub UE operation mode. Is this correct?
+ if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
+ process_timing_advance(module_idP,CC_id,payload_ptr[0]);
+ }
+
+ payload_ptr++;
+ break;
+
+ case DRX_CMD:
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] CE %d : UE DRX :", i);
+#endif
+ payload_ptr++;
+ break;
}
- payload_ptr++;
- break;
+ }
- case DRX_CMD:
+ for (i = 0; i < num_sdu; i++) {
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] CE %d : UE DRX :", i);
+ LOG_D(MAC, "[UE] SDU %d : LCID %d, length %d\n", i,
+ rx_lcids[i], rx_lengths[i]);
#endif
- payload_ptr++;
- break;
- }
- }
-
- for (i = 0; i < num_sdu; i++) {
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] SDU %d : LCID %d, length %d\n", i,
- rx_lcids[i], rx_lengths[i]);
-#endif
- if (rx_lcids[i] == CCCH) {
-
- LOG_D(MAC,
- "[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",
- module_idP, UE_mac_inst[module_idP].crnti, frameP,
- eNB_index, rx_lengths[i]);
+ if (rx_lcids[i] == CCCH) {
+ LOG_D(MAC,
+ "[UE %d] rnti %x Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",
+ module_idP, UE_mac_inst[module_idP].crnti, frameP,
+ eNB_index, rx_lengths[i]);
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
- int j;
+ int j;
- for (j = 0; j < rx_lengths[i]; j++) {
- LOG_T(MAC, "%x.", (uint8_t) payload_ptr[j]);
- }
+ for (j = 0; j < rx_lengths[i]; j++) {
+ LOG_T(MAC, "%x.", (uint8_t) payload_ptr[j]);
+ }
- LOG_T(MAC, "\n");
+ LOG_T(MAC, "\n");
#endif
-
- mac_rrc_data_ind_ue(module_idP,
- CC_id,
- frameP,subframeP,
- UE_mac_inst[module_idP].crnti,
- CCCH,
- (uint8_t*)payload_ptr,
- rx_lengths[i],
- eNB_index,
- 0
- );
-
- } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) {
- LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]);
- mac_rlc_data_ind(module_idP,
- UE_mac_inst[module_idP].crnti,
- eNB_index,
- frameP,
- ENB_FLAG_NO,
- MBMS_FLAG_NO,
- rx_lcids[i],
- (char *)payload_ptr,
- rx_lengths[i],
- 1,
- NULL);
-
- } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) {
-
- LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]);
-
+ mac_rrc_data_ind_ue(module_idP,
+ CC_id,
+ frameP,subframeP,
+ UE_mac_inst[module_idP].crnti,
+ CCCH,
+ (uint8_t *)payload_ptr,
+ rx_lengths[i],
+ eNB_index,
+ 0
+ );
+ } else if ((rx_lcids[i] == DCCH) || (rx_lcids[i] == DCCH1)) {
+ LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frameP, rx_lcids[i],eNB_index,rx_lengths[i]);
+ mac_rlc_data_ind(module_idP,
+ UE_mac_inst[module_idP].crnti,
+ eNB_index,
+ frameP,
+ ENB_FLAG_NO,
+ MBMS_FLAG_NO,
+ rx_lcids[i],
+ (char *)payload_ptr,
+ rx_lengths[i],
+ 1,
+ NULL);
+ } else if ((rx_lcids[i] < NB_RB_MAX) && (rx_lcids[i] > DCCH1 )) {
+ LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frameP,rx_lcids[i], eNB_index,rx_lengths[i]);
#if defined(ENABLE_MAC_PAYLOAD_DEBUG)
- int j;
- for (j = 0; j < rx_lengths[i]; j++)
- LOG_T(MAC, "%x.", (unsigned char) payload_ptr[j]);
- LOG_T(MAC, "\n");
-#endif
- mac_rlc_data_ind(module_idP,
- UE_mac_inst[module_idP].crnti,
- eNB_index,
- frameP,
- ENB_FLAG_NO,
- MBMS_FLAG_NO,
- rx_lcids[i],
- (char *) payload_ptr, rx_lengths[i], 1,
- NULL);
- } else {
- LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (eNB %d)\n",
- module_idP, frameP, rx_lcids[i], eNB_index);
- }
- payload_ptr += rx_lengths[i];
- }
- } // end if (payload_ptr != NULL)
+ int j;
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT);
+ for (j = 0; j < rx_lengths[i]; j++)
+ LOG_T(MAC, "%x.", (unsigned char) payload_ptr[j]);
+
+ LOG_T(MAC, "\n");
+#endif
+ mac_rlc_data_ind(module_idP,
+ UE_mac_inst[module_idP].crnti,
+ eNB_index,
+ frameP,
+ ENB_FLAG_NO,
+ MBMS_FLAG_NO,
+ rx_lcids[i],
+ (char *) payload_ptr, rx_lengths[i], 1,
+ NULL);
+ } else {
+ LOG_E(MAC, "[UE %d] Frame %d : unknown LCID %d (eNB %d)\n",
+ module_idP, frameP, rx_lcids[i], eNB_index);
+ }
+
+ payload_ptr += rx_lengths[i];
+ }
+ } // end if (payload_ptr != NULL)
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
+ stop_meas(&UE_mac_inst[module_idP].rx_dlsch_sdu);
#endif
}
void
ue_decode_si(module_id_t module_idP, int CC_id, frame_t frameP,
- uint8_t eNB_index, void *pdu, uint16_t len)
-{
+ uint8_t eNB_index, void *pdu, uint16_t len) {
#if UE_TIMING_TRACE
- start_meas(&UE_mac_inst[module_idP].rx_si);
+ start_meas(&UE_mac_inst[module_idP].rx_si);
+#endif
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN);
+ LOG_D(MAC, "[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",
+ module_idP, frameP, BCCH, len);
+ mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe
+ SI_RNTI,
+ BCCH, (uint8_t *) pdu, len, eNB_index,
+ 0);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT);
+#if UE_TIMING_TRACE
+ stop_meas(&UE_mac_inst[module_idP].rx_si);
#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN);
-
- LOG_D(MAC, "[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",
- module_idP, frameP, BCCH, len);
-
- mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe
- SI_RNTI,
- BCCH, (uint8_t *) pdu, len, eNB_index,
- 0);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT);
-
-#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].rx_si);
-#endif
- if (opt_enabled == 1) {
- trace_pdu(DIRECTION_UPLINK,
- (uint8_t *) pdu,
- len,
- module_idP,
- WS_SI_RNTI,
- 0xffff,
- UE_mac_inst[module_idP].rxFrame,
- UE_mac_inst[module_idP].rxSubframe, 0, 0);
- LOG_D(OPT,
- "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
- module_idP, frameP, CC_id, 0xffff, len);
- }
+ if (opt_enabled == 1) {
+ trace_pdu(DIRECTION_UPLINK,
+ (uint8_t *) pdu,
+ len,
+ module_idP,
+ WS_SI_RNTI,
+ 0xffff,
+ UE_mac_inst[module_idP].rxFrame,
+ UE_mac_inst[module_idP].rxSubframe, 0, 0);
+ LOG_D(OPT,
+ "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
+ module_idP, frameP, CC_id, 0xffff, len);
+ }
}
void
ue_decode_p(module_id_t module_idP, int CC_id, frame_t frameP,
- uint8_t eNB_index, void *pdu, uint16_t len)
-{
+ uint8_t eNB_index, void *pdu, uint16_t len) {
#if UE_TIMING_TRACE
- start_meas(&UE_mac_inst[module_idP].rx_p);
+ start_meas(&UE_mac_inst[module_idP].rx_p);
+#endif
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN);
+ LOG_D(MAC,
+ "[UE %d] Frame %d Sending Paging message to RRC (LCID Id %d,len %d)\n",
+ module_idP, frameP, PCCH, len);
+ mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe
+ P_RNTI,
+ PCCH, (uint8_t *) pdu, len, eNB_index,
+ 0);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT);
+#if UE_TIMING_TRACE
+ stop_meas(&UE_mac_inst[module_idP].rx_p);
#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_IN);
-
- LOG_D(MAC,
- "[UE %d] Frame %d Sending Paging message to RRC (LCID Id %d,len %d)\n",
- module_idP, frameP, PCCH, len);
-
- mac_rrc_data_ind_ue(module_idP, CC_id, frameP, 0, // unknown subframe
- P_RNTI,
- PCCH, (uint8_t *) pdu, len, eNB_index,
- 0);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_PCCH, VCD_FUNCTION_OUT);
-
-#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].rx_p);
-#endif
- if (opt_enabled == 1) {
- trace_pdu(DIRECTION_UPLINK ,
- (uint8_t *) pdu,
- len,
- module_idP,
- WS_SI_RNTI,
- P_RNTI,
- UE_mac_inst[module_idP].rxFrame,
- UE_mac_inst[module_idP].rxSubframe, 0, 0);
- LOG_D(OPT,
- "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
- module_idP, frameP, CC_id, P_RNTI, len);
- }
+ if (opt_enabled == 1) {
+ trace_pdu(DIRECTION_UPLINK,
+ (uint8_t *) pdu,
+ len,
+ module_idP,
+ WS_SI_RNTI,
+ P_RNTI,
+ UE_mac_inst[module_idP].rxFrame,
+ UE_mac_inst[module_idP].rxSubframe, 0, 0);
+ LOG_D(OPT,
+ "[UE %d][BCH] Frame %d trace pdu for CC_id %d rnti %x with size %d\n",
+ module_idP, frameP, CC_id, P_RNTI, len);
+ }
}
#if (LTE_RRC_VERSION >= MAKE_VERSION(10, 0, 0))
unsigned char *parse_mch_header(unsigned char *mac_header,
- unsigned char *num_sdu,
- unsigned char *rx_lcids,
- unsigned short *rx_lengths,
- unsigned short tb_length)
-{
- unsigned char not_done = 1, num_sdus = 0, lcid, i;
- unsigned char *mac_header_ptr = mac_header;
- unsigned short length;
+ unsigned char *num_sdu,
+ unsigned char *rx_lcids,
+ unsigned short *rx_lengths,
+ unsigned short tb_length) {
+ unsigned char not_done = 1, num_sdus = 0, lcid, i;
+ unsigned char *mac_header_ptr = mac_header;
+ unsigned short length;
- while (not_done == 1) {
- if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) {
- not_done = 0;
- }
-
- lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID;
-
- if (lcid < SHORT_PADDING) { // subheader for MSI, MCCH or MTCH
- if (not_done == 0) { // last MAC SDU, length is implicit
- mac_header_ptr++;
- length = tb_length - (mac_header_ptr - mac_header);
-
- for (i = 0; i < num_sdus; i++) {
- length -= rx_lengths[i];
- }
- } else { // not the last MAC SDU
- if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { // subheader has length of 3octets
- // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L;
- length =
- ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->
- L_MSB & 0x7f)
- << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)->
- L_LSB & 0xff);
- mac_header_ptr += 3;
- } else { // subheader has length of 2octets
- length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L;
- mac_header_ptr += 2;
- }
- }
-
- rx_lcids[num_sdus] = lcid;
- rx_lengths[num_sdus] = length;
- num_sdus++;
- } else { // subheader for padding
- // if (lcid == SHORT_PADDING)
- mac_header_ptr++;
- }
+ while (not_done == 1) {
+ if (((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E == 0) {
+ not_done = 0;
}
- *num_sdu = num_sdus;
- return (mac_header_ptr);
+ lcid = ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID;
+
+ if (lcid < SHORT_PADDING) { // subheader for MSI, MCCH or MTCH
+ if (not_done == 0) { // last MAC SDU, length is implicit
+ mac_header_ptr++;
+ length = tb_length - (mac_header_ptr - mac_header);
+
+ for (i = 0; i < num_sdus; i++) {
+ length -= rx_lengths[i];
+ }
+ } else { // not the last MAC SDU
+ if (((SCH_SUBHEADER_LONG *) mac_header_ptr)->F == 1) { // subheader has length of 3octets
+ // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L;
+ length =
+ ((((SCH_SUBHEADER_LONG *) mac_header_ptr)->
+ L_MSB & 0x7f)
+ << 8) | (((SCH_SUBHEADER_LONG *) mac_header_ptr)->
+ L_LSB & 0xff);
+ mac_header_ptr += 3;
+ } else { // subheader has length of 2octets
+ length = ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L;
+ mac_header_ptr += 2;
+ }
+ }
+
+ rx_lcids[num_sdus] = lcid;
+ rx_lengths[num_sdus] = length;
+ num_sdus++;
+ } else { // subheader for padding
+ // if (lcid == SHORT_PADDING)
+ mac_header_ptr++;
+ }
+ }
+
+ *num_sdu = num_sdus;
+ return (mac_header_ptr);
}
// this function is for sending mch_sdu from phy to mac
void
ue_send_mch_sdu(module_id_t module_idP, uint8_t CC_id, frame_t frameP,
- uint8_t * sdu, uint16_t sdu_len, uint8_t eNB_index,
- uint8_t sync_area)
-{
-
- unsigned char num_sdu, i, j, *payload_ptr;
- unsigned char rx_lcids[NB_RB_MAX];
- unsigned short rx_lengths[NB_RB_MAX];
+ uint8_t *sdu, uint16_t sdu_len, uint8_t eNB_index,
+ uint8_t sync_area) {
+ unsigned char num_sdu, i, j, *payload_ptr;
+ unsigned char rx_lcids[NB_RB_MAX];
+ unsigned short rx_lengths[NB_RB_MAX];
#if UE_TIMING_TRACE
- start_meas(&UE_mac_inst[module_idP].rx_mch_sdu);
+ start_meas(&UE_mac_inst[module_idP].rx_mch_sdu);
#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN);
+ LOG_D(MAC,
+ "[UE %d] Frame %d : process the mch PDU for sync area %d \n",
+ module_idP, frameP, sync_area);
+ LOG_D(MAC, "[UE %d] sdu: %x.%x\n", module_idP, sdu[0], sdu[1]);
+ LOG_D(MAC, "[UE %d] parse_mch_header, demultiplex\n", module_idP);
+ payload_ptr =
+ parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len);
+ LOG_D(MAC, "[UE %d] parse_mch_header, found %d sdus\n", module_idP,
+ num_sdu);
- LOG_D(MAC,
- "[UE %d] Frame %d : process the mch PDU for sync area %d \n",
- module_idP, frameP, sync_area);
- LOG_D(MAC, "[UE %d] sdu: %x.%x\n", module_idP, sdu[0], sdu[1]);
- LOG_D(MAC, "[UE %d] parse_mch_header, demultiplex\n", module_idP);
-
- payload_ptr =
- parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len);
- LOG_D(MAC, "[UE %d] parse_mch_header, found %d sdus\n", module_idP,
- num_sdu);
-
- for (i = 0; i < num_sdu; i++) {
- if (rx_lcids[i] == MCH_SCHDL_INFO) {
- if (rx_lengths[i] & 0x01) {
- LOG_E(MAC,"MCH Scheduling Information MAC Control Element should have an even size\n");
- }
-
- LOG_D(MAC,"MCH Scheduling Information, len(%d)\n",rx_lengths[i]);
-
- for (j=0; j> 3;
- UE_mac_inst[module_idP].pmch_stop_mtch[j] = stop_mtch_val;
- LOG_D(MAC,"lcid(%d),stop_mtch_val %d frameP(%d)\n", UE_mac_inst[module_idP].pmch_lcids[j], stop_mtch_val, frameP);
-
- if ((stop_mtch_val >= 2043) && (stop_mtch_val <= 2046)) {
- LOG_D(MAC,"(reserved)\n");
- }
-
- UE_mac_inst[module_idP].msi_status_v[j] = 0;
-
- if (UE_mac_inst[module_idP].mcch_status==1) {
- LOG_D(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes), i(%d)\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], UE_mac_inst[module_idP].pmch_stop_mtch[j]);
- if (UE_mac_inst[module_idP].pmch_stop_mtch[j] < 2043) {
- UE_mac_inst[module_idP].pmch_stop_mtch[j] += UE_mac_inst[module_idP].msi_current_alloc;
- UE_mac_inst[module_idP].msi_status_v[j] = 1;
- }
- }
- }
- } else if (rx_lcids[i] == MCCH_LCHANID) {
- LOG_D(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]);
- mac_rrc_data_ind_ue(module_idP,
- CC_id,
- frameP,0, // unknown subframe
- M_RNTI,
- MCCH,
- payload_ptr + 1, // Skip RLC layer 1st byte
- rx_lengths[i] - 1,
- eNB_index,
- sync_area);
- } else if (rx_lcids[i] <= 28) {
- for (j=0; j<28; j++) {
- if (rx_lcids[i] == UE_mac_inst[module_idP].pmch_lcids[j])
- break;
- }
-
- if (j<28 && UE_mac_inst[module_idP].msi_status_v[j]==1) {
- LOG_D(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes), j=%d\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], j);
-
- mac_rlc_data_ind(
- module_idP,
- UE_mac_inst[module_idP].crnti,
- eNB_index,
- frameP,
- ENB_FLAG_NO,
- MBMS_FLAG_YES,
- rx_lcids[i], /*+ (maxDRB + 3),*/
- (char *)payload_ptr,
- rx_lengths[i],
- 1,
- NULL);
-
- }
- } else {
- LOG_W(MAC,
- "[UE %d] Frame %d : unknown sdu %d rx_lcids[%d]=%d mcch status %d eNB %d \n",
- module_idP, frameP, rx_lengths[i], i, rx_lcids[i],
- UE_mac_inst[module_idP].mcch_status, eNB_index);
+ for (i = 0; i < num_sdu; i++) {
+ if (rx_lcids[i] == MCH_SCHDL_INFO) {
+ if (rx_lengths[i] & 0x01) {
+ LOG_E(MAC,"MCH Scheduling Information MAC Control Element should have an even size\n");
}
- payload_ptr += rx_lengths[i];
+ LOG_D(MAC,"MCH Scheduling Information, len(%d)\n",rx_lengths[i]);
+
+ for (j=0; j> 3;
+ UE_mac_inst[module_idP].pmch_stop_mtch[j] = stop_mtch_val;
+ LOG_D(MAC,"lcid(%d),stop_mtch_val %d frameP(%d)\n", UE_mac_inst[module_idP].pmch_lcids[j], stop_mtch_val, frameP);
+
+ if ((stop_mtch_val >= 2043) && (stop_mtch_val <= 2046)) {
+ LOG_D(MAC,"(reserved)\n");
+ }
+
+ UE_mac_inst[module_idP].msi_status_v[j] = 0;
+
+ if (UE_mac_inst[module_idP].mcch_status==1) {
+ LOG_D(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes), i(%d)\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], UE_mac_inst[module_idP].pmch_stop_mtch[j]);
+
+ if (UE_mac_inst[module_idP].pmch_stop_mtch[j] < 2043) {
+ UE_mac_inst[module_idP].pmch_stop_mtch[j] += UE_mac_inst[module_idP].msi_current_alloc;
+ UE_mac_inst[module_idP].msi_status_v[j] = 1;
+ }
+ }
+ }
+ } else if (rx_lcids[i] == MCCH_LCHANID) {
+ LOG_D(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frameP, i, sync_area, eNB_index, rx_lengths[i]);
+ mac_rrc_data_ind_ue(module_idP,
+ CC_id,
+ frameP,0, // unknown subframe
+ M_RNTI,
+ MCCH,
+ payload_ptr + 1, // Skip RLC layer 1st byte
+ rx_lengths[i] - 1,
+ eNB_index,
+ sync_area);
+ } else if (rx_lcids[i] <= 28) {
+ for (j=0; j<28; j++) {
+ if (rx_lcids[i] == UE_mac_inst[module_idP].pmch_lcids[j])
+ break;
+ }
+
+ if (j<28 && UE_mac_inst[module_idP].msi_status_v[j]==1) {
+ LOG_D(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes), j=%d\n", module_idP, frameP, sync_area, eNB_index, rx_lengths[i], j);
+ mac_rlc_data_ind(
+ module_idP,
+ UE_mac_inst[module_idP].crnti,
+ eNB_index,
+ frameP,
+ ENB_FLAG_NO,
+ MBMS_FLAG_YES,
+ rx_lcids[i], /*+ (maxDRB + 3),*/
+ (char *)payload_ptr,
+ rx_lengths[i],
+ 1,
+ NULL);
+ }
+ } else {
+ LOG_W(MAC,
+ "[UE %d] Frame %d : unknown sdu %d rx_lcids[%d]=%d mcch status %d eNB %d \n",
+ module_idP, frameP, rx_lengths[i], i, rx_lcids[i],
+ UE_mac_inst[module_idP].mcch_status, eNB_index);
}
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT);
+ payload_ptr += rx_lengths[i];
+ }
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].rx_mch_sdu);
+ stop_meas(&UE_mac_inst[module_idP].rx_mch_sdu);
#endif
}
void ue_send_sl_sdu(module_id_t module_idP,
- uint8_t CC_id,
- frame_t frameP,
- sub_frame_t subframeP,
- uint8_t* sdu,
- uint16_t sdu_len,
- uint8_t eNB_index,
- sl_discovery_flag_t sl_discovery_flag
- ) {
-
+ uint8_t CC_id,
+ frame_t frameP,
+ sub_frame_t subframeP,
+ uint8_t *sdu,
+ uint16_t sdu_len,
+ uint8_t eNB_index,
+ sl_discovery_flag_t sl_discovery_flag
+ ) {
int rlc_sdu_len;
char *rlc_sdu;
uint32_t destinationL2Id =0x00000000;
if (sl_discovery_flag == SL_DISCOVERY_FLAG_NO) {
+ // Notes: 1. no control elements are supported yet
+ // 2. we exit with error if LCID != 3
+ // 3. we exit with error if E=1 (more than one SDU/CE)
+ // extract header
+ SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu;
+ AssertFatal(longh->E==0,"E is non-zero\n");
+ AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID);
+ //filter incoming packet based on destination address
+ destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
+ LOG_I( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id );
+ //in case of 1-n communication, verify that UE belongs to that group
+ int i=0;
- // Notes: 1. no control elements are supported yet
- // 2. we exit with error if LCID != 3
- // 3. we exit with error if E=1 (more than one SDU/CE)
- // extract header
- SLSCH_SUBHEADER_24_Bit_DST_LONG *longh = (SLSCH_SUBHEADER_24_Bit_DST_LONG *)sdu;
- AssertFatal(longh->E==0,"E is non-zero\n");
- AssertFatal(((longh->LCID==3)|(longh->LCID==10)),"LCID is %d (not 3 or 10)\n",longh->LCID);
- //filter incoming packet based on destination address
- destinationL2Id = (longh->DST07<<16) | (longh->DST815 <<8) | (longh->DST1623);
- LOG_I( MAC, "[DestinationL2Id: 0x%08x] \n", destinationL2Id );
- //in case of 1-n communication, verify that UE belongs to that group
- int i=0;
- for (i=0; i< MAX_NUM_DEST; i++)
- if (UE_mac_inst[module_idP].destinationList[i] == destinationL2Id) break;
- //match the destinationL2Id with UE L2Id or groupL2ID
- if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (i < MAX_NUM_DEST))){
- LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
- return;
- }
+ for (i=0; i< MAX_NUM_DEST; i++)
+ if (UE_mac_inst[module_idP].destinationList[i] == destinationL2Id) break;
+ //match the destinationL2Id with UE L2Id or groupL2ID
+ if (!((destinationL2Id == UE_mac_inst[module_idP].sourceL2Id) | (i < MAX_NUM_DEST))) {
+ LOG_I( MAC, "[Destination Id is neither matched with Source Id nor with Group Id, drop the packet!!! \n");
+ return;
+ }
- if (longh->F==1) {
- rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF);
- rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG);
- }
- else {
- rlc_sdu_len = ((SLSCH_SUBHEADER_24_Bit_DST_SHORT *)sdu)->L;
- rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_SHORT);
- }
- mac_rlc_data_ind(
- module_idP,
- 0x1234,
- eNB_index,
- frameP,
- ENB_FLAG_NO,
- MBMS_FLAG_NO,
- longh->LCID, //3/10
- rlc_sdu,
- rlc_sdu_len,
- 1,
- NULL);
+ if (longh->F==1) {
+ rlc_sdu_len = ((longh->L_MSB<<8)&0x7F00)|(longh->L_LSB&0xFF);
+ rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG);
+ } else {
+ rlc_sdu_len = ((SLSCH_SUBHEADER_24_Bit_DST_SHORT *)sdu)->L;
+ rlc_sdu = (char *)sdu+sizeof(SLSCH_SUBHEADER_24_Bit_DST_SHORT);
+ }
+
+ mac_rlc_data_ind(
+ module_idP,
+ 0x1234,
+ eNB_index,
+ frameP,
+ ENB_FLAG_NO,
+ MBMS_FLAG_NO,
+ longh->LCID, //3/10
+ rlc_sdu,
+ rlc_sdu_len,
+ 1,
+ NULL);
} else { //SL_DISCOVERY
- uint16_t len = sdu_len;
- LOG_I( MAC, "SL DISCOVERY \n");
- mac_rrc_data_ind_ue(module_idP,
- CC_id,
- frameP,subframeP,
- UE_mac_inst[module_idP].crnti,
- SL_DISCOVERY,
- sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0],
- len,
- eNB_index,
- 0);
-
+ uint16_t len = sdu_len;
+ LOG_I( MAC, "SL DISCOVERY \n");
+ mac_rrc_data_ind_ue(module_idP,
+ CC_id,
+ frameP,subframeP,
+ UE_mac_inst[module_idP].crnti,
+ SL_DISCOVERY,
+ sdu, //(uint8_t*)&UE_mac_inst[Mod_id].SL_Discovery[0].Rx_buffer.Payload[0],
+ len,
+ eNB_index,
+ 0);
}
}
@@ -935,26 +894,26 @@ void ue_send_sl_sdu(module_id_t module_idP,
int8_t ue_get_mbsfn_sf_alloction (module_id_t module_idP, uint8_t mbsfn_sync_area, unsigned char eNB_index)
{
- // currently there is one-to-one mapping between sf allocation pattern and sync area
- if (mbsfn_sync_area >= MAX_MBSFN_AREA) {
- LOG_W(MAC,
- "[UE %" PRIu8 "] MBSFN synchronization area %" PRIu8
- " out of range for eNB %" PRIu8 "\n", module_idP,
- mbsfn_sync_area, eNB_index);
- return -1;
- } else if (UE_mac_inst[module_idP].
- mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) {
- return mbsfn_sync_area;
- } else {
- LOG_W(MAC,
- "[UE %" PRIu8 "] MBSFN Subframe Config pattern %" PRIu8
- " not found \n", module_idP, mbsfn_sync_area);
- return -1;
- }
+ // currently there is one-to-one mapping between sf allocation pattern and sync area
+ if (mbsfn_sync_area >= MAX_MBSFN_AREA) {
+ LOG_W(MAC,
+ "[UE %" PRIu8 "] MBSFN synchronization area %" PRIu8
+ " out of range for eNB %" PRIu8 "\n", module_idP,
+ mbsfn_sync_area, eNB_index);
+ return -1;
+ } else if (UE_mac_inst[module_idP].
+ mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) {
+ return mbsfn_sync_area;
+ } else {
+ LOG_W(MAC,
+ "[UE %" PRIu8 "] MBSFN Subframe Config pattern %" PRIu8
+ " not found \n", module_idP, mbsfn_sync_area);
+ return -1;
+ }
}
-int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int commonSFAlloc_period, int commonSFAlloc_offset, int num_sf_alloc, int *mtch_active, int *msi_active, uint8_t *mch_lcid)
-{
+int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int commonSFAlloc_period, int commonSFAlloc_offset, int num_sf_alloc, int *mtch_active, int *msi_active,
+ uint8_t *mch_lcid) {
int i, mtch_mcs = -1;
int mtch_flag = 0;
int msi_flag = 0;
@@ -976,16 +935,18 @@ int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subfra
//msi and mtch are mutally excluded then the break is safe
if ((num_sf_alloc == 0) && (sf_AllocEnd_r9 >= 1)) {
msi_flag = 1;
- LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9,UE_mac_inst[module_idP].common_num_sf_alloc);
+ LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9,
+ UE_mac_inst[module_idP].common_num_sf_alloc);
UE_mac_inst[module_idP].msi_current_alloc = num_sf_alloc;
UE_mac_inst[module_idP].msi_pmch = i;
}
} else { //more that one MCH ?? check better this condition
//msi and mtch are mutally excluded then the break is safe
if ((num_sf_alloc == UE_mac_inst[module_idP].pmch_Config[i-1]->sf_AllocEnd_r9 + 1) && (sf_AllocEnd_r9 >= (num_sf_alloc+1))) {
- //msi should be just after
+ //msi should be just after
msi_flag = 1;
- LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9,UE_mac_inst[module_idP].common_num_sf_alloc);
+ LOG_D(MAC,"msi(%d) should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),sf_AllocEnd_r9(%d),common_num_sf_alloc(%d)\n",i,frameP,subframe,num_sf_alloc,sf_AllocEnd_r9,
+ UE_mac_inst[module_idP].common_num_sf_alloc);
UE_mac_inst[module_idP].msi_current_alloc = num_sf_alloc;
UE_mac_inst[module_idP].msi_pmch = i;
}
@@ -997,12 +958,15 @@ int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subfra
if (UE_mac_inst[module_idP].pmch_stop_mtch[i] >= num_sf_alloc) {
if (UE_mac_inst[module_idP].pmch_stop_mtch[i] != 2047) {
mtch_flag = 1;
+
if (UE_mac_inst[module_idP].pmch_Config[UE_mac_inst[module_idP].msi_pmch] != NULL)
mtch_mcs = UE_mac_inst[module_idP].pmch_Config[UE_mac_inst[module_idP].msi_pmch]->dataMCS_r9;
else
mtch_mcs = -1;
+
*mch_lcid = (uint8_t)i;
- LOG_D(MAC,"mtch should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),mtch_mcs(%d),pmch_stop_mtch(%d),lcid(%d),msi_pmch(%d)\n",frameP,subframe,num_sf_alloc,mtch_mcs,UE_mac_inst[module_idP].pmch_stop_mtch[i],UE_mac_inst[module_idP].pmch_lcids[i],UE_mac_inst[module_idP].msi_pmch);
+ LOG_D(MAC,"mtch should be allocated:frame(%d),submframe(%d),num_sf_alloc(%d),mtch_mcs(%d),pmch_stop_mtch(%d),lcid(%d),msi_pmch(%d)\n",frameP,subframe,num_sf_alloc,mtch_mcs,
+ UE_mac_inst[module_idP].pmch_stop_mtch[i],UE_mac_inst[module_idP].pmch_lcids[i],UE_mac_inst[module_idP].msi_pmch);
break;
}
}
@@ -1010,17 +974,15 @@ int ue_query_p_mch_info(module_id_t module_idP, uint32_t frameP, uint32_t subfra
*mtch_active = mtch_flag;
*msi_active = msi_flag;
-
return mtch_mcs;
}
-int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int *mtch_active, int *msi_active, uint8_t *mch_lcid)
-{
+int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, int *mtch_active, int *msi_active, uint8_t *mch_lcid) {
int i, j, mtch_mcs = -1;
int mtch_flag = 0;
-
// Acount for sf_allocable in CSA
int num_sf_alloc = 0;
+
for (i = 0; i < 8; i++) {
if (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] == NULL)
continue;
@@ -1030,8 +992,9 @@ int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, i
// four-frameP format
uint32_t common_mbsfn_SubframeConfig = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[2] |
- (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) |
- (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16);
+ (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) |
+ (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16);
+
for (j = 0; j < 24; j++)
num_sf_alloc += ((common_mbsfn_SubframeConfig & (0x800000 >> j)) == (0x800000 >> j));
}
@@ -1047,84 +1010,92 @@ int ue_query_p_mch(module_id_t module_idP, uint32_t frameP, uint32_t subframe, i
int common_mbsfn_alloc_offset = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->radioframeAllocationOffset;
int common_mbsfn_period = 1 << UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->radioframeAllocationPeriod;
int commonSF_AllocPeriod = 4 << UE_mac_inst[module_idP].commonSF_AllocPeriod_r9;
-
uint32_t common_mbsfn_SubframeConfig = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[2] |
- (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) |
- (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16);
-
+ (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[1]<<8) |
+ (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]<<16);
int jj = frameP % 4;
+
if ((frameP % common_mbsfn_period) != (common_mbsfn_alloc_offset + jj))
continue;
- if(UE_mac_inst[module_idP].tdd_Config == NULL){
+ if(UE_mac_inst[module_idP].tdd_Config == NULL) {
switch (subframe) {
- case 1:
- if ((common_mbsfn_SubframeConfig & (0x800000 >> (jj*6))) == (0x800000 >> (jj*6))) {
- mtch_flag = 1;
- mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
- }
- break;
- case 2:
- if ((common_mbsfn_SubframeConfig & (0x400000 >> (jj*6))) == (0x400000 >> (jj*6))) {
- mtch_flag = 1;
- mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
- }
- break;
- case 3:
- if ((common_mbsfn_SubframeConfig & (0x200000 >> (jj*6))) == (0x200000 >> (jj*6))) {
- mtch_flag = 1;
- mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
- }
- break;
- case 6:
- if ((common_mbsfn_SubframeConfig & (0x100000 >> (jj*6))) == (0x100000 >> (jj*6))) {
- mtch_flag = 1;
- mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
- }
- break;
- case 7:
- if ((common_mbsfn_SubframeConfig & (0x80000 >> (jj*6))) == (0x80000 >> (jj*6))) {
- mtch_flag = 1;
- mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
- }
- break;
- case 8:
- if ((common_mbsfn_SubframeConfig & (0x40000 >> (jj*6))) == (0x40000 >> (jj*6))) {
- mtch_flag = 1;
- mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc% ( num_sf_alloc*commonSF_AllocPeriod/common_mbsfn_period);//48;
- }
- break;
+ case 1:
+ if ((common_mbsfn_SubframeConfig & (0x800000 >> (jj*6))) == (0x800000 >> (jj*6))) {
+ mtch_flag = 1;
+ mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
+ }
+
+ break;
+
+ case 2:
+ if ((common_mbsfn_SubframeConfig & (0x400000 >> (jj*6))) == (0x400000 >> (jj*6))) {
+ mtch_flag = 1;
+ mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
+ }
+
+ break;
+
+ case 3:
+ if ((common_mbsfn_SubframeConfig & (0x200000 >> (jj*6))) == (0x200000 >> (jj*6))) {
+ mtch_flag = 1;
+ mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
+ }
+
+ break;
+
+ case 6:
+ if ((common_mbsfn_SubframeConfig & (0x100000 >> (jj*6))) == (0x100000 >> (jj*6))) {
+ mtch_flag = 1;
+ mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
+ }
+
+ break;
+
+ case 7:
+ if ((common_mbsfn_SubframeConfig & (0x80000 >> (jj*6))) == (0x80000 >> (jj*6))) {
+ mtch_flag = 1;
+ mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc % (num_sf_alloc * commonSF_AllocPeriod / common_mbsfn_period);//48;
+ }
+
+ break;
+
+ case 8:
+ if ((common_mbsfn_SubframeConfig & (0x40000 >> (jj*6))) == (0x40000 >> (jj*6))) {
+ mtch_flag = 1;
+ mtch_mcs = ue_query_p_mch_info(module_idP,frameP,subframe,common_mbsfn_period,common_mbsfn_alloc_offset,UE_mac_inst[module_idP].common_num_sf_alloc,mtch_active,msi_active,mch_lcid);
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ UE_mac_inst[module_idP].common_num_sf_alloc = UE_mac_inst[module_idP].common_num_sf_alloc% ( num_sf_alloc*commonSF_AllocPeriod/common_mbsfn_period);//48;
+ }
+
+ break;
}
} else {
// TODO TDD
}
+
if (mtch_flag == 1)
break;
}
- return mtch_mcs;
+ return mtch_mcs;
}
-int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active)
-{
-
+int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) {
int i = 0, j = 0, ii = 0, jj = 0, msi_pos = 0, mcch_mcs = -1, mtch_mcs = -1;
int mcch_flag = 0, mtch_flag = 0, msi_flag = 0;
long mch_scheduling_period = -1;
uint8_t mch_lcid = 0;
-
#if UE_TIMING_TRACE
start_meas(&UE_mac_inst[module_idP].ue_query_mch);
#endif
@@ -1135,8 +1106,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
for (i = 0;
i < UE_mac_inst[module_idP].num_active_mbsfn_area;
- i++ )
- {
+ i++ ) {
// assume, that there is always a mapping
if ((j = ue_get_mbsfn_sf_alloction(module_idP,i,eNB_index)) == -1) {
return -1; // continue;
@@ -1144,12 +1114,10 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
ii = 0;
msi_pos = 0;
-
long mbsfn_period = 1 << UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod;
long mbsfn_alloc_offset = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset;
long mcch_period = 32 << UE_mac_inst[module_idP].mbsfn_AreaInfo[j]->mcch_Config_r9.mcch_RepetitionPeriod_r9;
long mcch_offset = UE_mac_inst[module_idP].mbsfn_AreaInfo[j]->mcch_Config_r9.mcch_Offset_r9;
-
LOG_D(MAC,
"[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %ld, mcch period %ld,mac sched period (%ld,%ld))\n",
module_idP,frameP, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area,
@@ -1158,26 +1126,25 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
// get the real MCS value
switch (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) {
- case 0:
- mcch_mcs = 2;
- break;
+ case 0:
+ mcch_mcs = 2;
+ break;
- case 1:
- mcch_mcs = 7;
- break;
+ case 1:
+ mcch_mcs = 7;
+ break;
- case 2:
- mcch_mcs = 13;
- break;
+ case 2:
+ mcch_mcs = 13;
+ break;
- case 3:
- mcch_mcs = 19;
- break;
+ case 3:
+ mcch_mcs = 19;
+ break;
}
if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == LTE_MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame) { // one-frameP format
if (frameP % mbsfn_period == mbsfn_alloc_offset) { // MBSFN frameP
-
if (UE_mac_inst[module_idP].pmch_Config[0]) {
// Find the first subframe in this MCH to transmit MSI
if (frameP % mch_scheduling_period == mbsfn_alloc_offset) {
@@ -1190,192 +1157,193 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
// Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1
switch (subframe) {
- case 1:
- if (UE_mac_inst[module_idP].tdd_Config == NULL) {
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) {
- if (msi_pos == 1) {
- msi_flag = 1;
- }
+ case 1:
+ if (UE_mac_inst[module_idP].tdd_Config == NULL) {
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) {
+ if (msi_pos == 1) {
+ msi_flag = 1;
+ }
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1)) {
- mcch_flag = 1;
- }
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1)) {
+ mcch_flag = 1;
+ }
- mtch_flag = 1;
+ mtch_flag = 1;
+ }
}
- }
- break;
+ break;
- case 2:
- if (UE_mac_inst[module_idP].tdd_Config == NULL) {
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) {
- if (msi_pos == 2) {
- msi_flag = 1;
+ case 2:
+ if (UE_mac_inst[module_idP].tdd_Config == NULL) {
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) {
+ if (msi_pos == 2) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
-
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2)) {
- mcch_flag = 1;
- }
-
- mtch_flag = 1;
}
- }
- break;
+ break;
- case 3:
- if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) {
- if (msi_pos == 1) {
- msi_flag = 1;
+ case 3:
+ if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) {
+ if (msi_pos == 1) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
+ } else { // FDD
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) {
+ if (msi_pos == 3) {
+ msi_flag = 1;
+ }
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3)) {
- mcch_flag = 1;
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
-
- mtch_flag = 1;
}
- } else { // FDD
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) {
- if (msi_pos == 3) {
- msi_flag = 1;
- }
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3)) {
- mcch_flag = 1;
- }
+ break;
- mtch_flag = 1;
+ case 4:
+ if (UE_mac_inst[module_idP].tdd_Config != NULL) {
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) {
+ if (msi_pos == 2) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
+ }
}
- }
- break;
+ break;
- case 4:
- if (UE_mac_inst[module_idP].tdd_Config != NULL) {
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) {
- if (msi_pos == 2) {
- msi_flag = 1;
+ case 6:
+ if (UE_mac_inst[module_idP].tdd_Config == NULL) {
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) {
+ if (msi_pos == 4) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
-
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4)) {
- mcch_flag = 1;
- }
-
- mtch_flag = 1;
}
- }
- break;
+ break;
- case 6:
- if (UE_mac_inst[module_idP].tdd_Config == NULL) {
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) {
- if (msi_pos == 4) {
- msi_flag = 1;
+ case 7:
+ if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) {
+ if (msi_pos == 3) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
+ } else { // FDD
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) {
+ if (msi_pos == 5) {
+ msi_flag = 1;
+ }
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6)) {
- mcch_flag = 1;
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
-
- mtch_flag = 1;
}
- }
- break;
+ break;
- case 7:
- if (UE_mac_inst[module_idP].tdd_Config != NULL) { // TDD
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) {
- if (msi_pos == 3) {
- msi_flag = 1;
+ case 8:
+ if (UE_mac_inst[module_idP].tdd_Config != NULL) { //TDD
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) {
+ if (msi_pos == 4) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
+ } else { // FDD
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) {
+ if (msi_pos == 6) {
+ msi_flag = 1;
+ }
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7)) {
- mcch_flag = 1;
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
}
-
- mtch_flag = 1;
}
- } else { // FDD
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) {
- if (msi_pos == 5) {
- msi_flag = 1;
- }
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7)) {
- mcch_flag = 1;
- }
+ break;
- mtch_flag = 1;
+ case 9:
+ if (UE_mac_inst[module_idP].tdd_Config != NULL) {
+ if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) {
+ if (msi_pos == 5) {
+ msi_flag = 1;
+ }
+
+ if ((frameP % mcch_period == mcch_offset) &&
+ ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9)) {
+ mcch_flag = 1;
+ }
+
+ mtch_flag = 1;
+ }
}
- }
- break;
-
- case 8:
- if (UE_mac_inst[module_idP].tdd_Config != NULL) { //TDD
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) {
- if (msi_pos == 4) {
- msi_flag = 1;
- }
-
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8)) {
- mcch_flag = 1;
- }
-
- mtch_flag = 1;
- }
- } else { // FDD
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) {
- if (msi_pos == 6) {
- msi_flag = 1;
- }
-
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8)) {
- mcch_flag = 1;
- }
-
- mtch_flag = 1;
- }
- }
-
- break;
-
- case 9:
- if (UE_mac_inst[module_idP].tdd_Config != NULL) {
- if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) {
- if (msi_pos == 5) {
- msi_flag = 1;
- }
-
- if ((frameP % mcch_period == mcch_offset) &&
- ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9)) {
- mcch_flag = 1;
- }
-
- mtch_flag = 1;
- }
- }
-
- break;
+ break;
}// end switch
// Acount for sf_allocable in CSA
int num_sf_alloc = 0;
+
for (i = 0; i < 8; i++) {
if (UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] == NULL)
continue;
@@ -1384,6 +1352,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
continue;
uint32_t common_mbsfn_SubframeConfig = UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0];
+
for (j = 0; j < 6; j++)
num_sf_alloc += ((common_mbsfn_SubframeConfig & (0x80 >> j)) == (0x80 >> j));
}
@@ -1395,6 +1364,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
mtch_mcs = UE_mac_inst[module_idP].pmch_Config[UE_mac_inst[module_idP].msi_pmch]->dataMCS_r9;
else
mtch_mcs = -1;
+
mch_lcid = (uint8_t)i;
break;
}
@@ -1405,89 +1375,107 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)) {
LOG_D(MAC,"[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n",
module_idP, frameP, subframe,i,j,msi_flag,mcch_flag,mtch_flag);
-
*sync_area=i;
break;
}
}
} else { // four-frameP format
uint32_t mbsfn_SubframeConfig = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[2] |
- (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[1]<<8) |
- (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0]<<16);
+ (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[1]<<8) |
+ (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0]<<16);
uint32_t MCCH_mbsfn_SubframeConfig = /* UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[2] |
(UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[1]<<8) | */
- (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0]<<16);
-
+ (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0]<<16);
jj=frameP%4;
+
if ((frameP % mbsfn_period) == (mbsfn_alloc_offset+jj)) {
if (UE_mac_inst[module_idP].tdd_Config == NULL) {
switch (subframe) {
- case 1:
- if ((mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6))) {
- if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6)))) {
- mcch_flag=1;
- LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
- frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x800000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
- if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
- UE_mac_inst[module_idP].common_num_sf_alloc++;
+ case 1:
+ if ((mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6))) {
+ if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x800000>>(jj*6))) == (0x800000>>(jj*6)))) {
+ mcch_flag=1;
+ LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
+ frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x800000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
+
+ if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ }
}
- }
- break;
- case 2:
- if ((mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6))) {
- if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6)))) {
- mcch_flag=1;
- LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
- frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x400000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
- if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
- UE_mac_inst[module_idP].common_num_sf_alloc++;
+
+ break;
+
+ case 2:
+ if ((mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6))) {
+ if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x400000>>(jj*6))) == (0x400000>>(jj*6)))) {
+ mcch_flag=1;
+ LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
+ frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x400000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
+
+ if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ }
}
- }
- break;
- case 3:
- if ((mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6))) {
- if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6)))) {
- LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
- frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x200000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
- mcch_flag=1;
- if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
- UE_mac_inst[module_idP].common_num_sf_alloc++;
+
+ break;
+
+ case 3:
+ if ((mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6))) {
+ if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x200000>>(jj*6))) == (0x200000>>(jj*6)))) {
+ LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
+ frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x200000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
+ mcch_flag=1;
+
+ if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ }
}
- }
- break;
- case 6:
- if ((mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6))) {
- if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6)))) {
- LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
- frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x100000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
- mcch_flag=1;
- if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
- UE_mac_inst[module_idP].common_num_sf_alloc++;
+
+ break;
+
+ case 6:
+ if ((mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6))) {
+ if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x100000>>(jj*6))) == (0x100000>>(jj*6)))) {
+ LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
+ frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x100000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
+ mcch_flag=1;
+
+ if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+ }
}
- }
- break;
- case 7:
- if ((mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6))) {
- if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6)))) {
- LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
- frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x80000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
- if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- mcch_flag=1;
+
+ break;
+
+ case 7:
+ if ((mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6))) {
+ if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x80000>>(jj*6))) == (0x80000>>(jj*6)))) {
+ LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
+ frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x80000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
+
+ if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+
+ mcch_flag=1;
+ }
}
- }
- break;
- case 8:
- if ((mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6))) {
- if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6)))) {
- LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
- frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x40000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
- if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
- UE_mac_inst[module_idP].common_num_sf_alloc++;
- mcch_flag=1;
+
+ break;
+
+ case 8:
+ if ((mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6))) {
+ if ((frameP % mcch_period == (mcch_offset+jj)) && ((MCCH_mbsfn_SubframeConfig & (0x40000>>(jj*6))) == (0x40000>>(jj*6)))) {
+ LOG_D(MAC,"frameP(%d),mcch_period(%ld),mbsfn_SubframeConfig(%x),MCCH_mbsfn_SubframeConfig(%x),mask(%x),jj(%d),num_sf_alloc(%d)\n",
+ frameP, mcch_period, mbsfn_SubframeConfig, MCCH_mbsfn_SubframeConfig, (0x40000>>(jj*6)), jj, UE_mac_inst[module_idP].common_num_sf_alloc);
+
+ if(UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[0]==NULL)
+ UE_mac_inst[module_idP].common_num_sf_alloc++;
+
+ mcch_flag=1;
+ }
}
- }
- break;
+
+ break;
}// end switch
} else {
// TODO TDD
@@ -1510,7 +1498,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
stop_meas(&UE_mac_inst[module_idP].ue_query_mch);
#endif
- if ((mcch_flag == 1)) { // || (msi_flag==1))
+ if ((mcch_flag == 1)) { // || (msi_flag==1))
*mcch_active = 1;
}
@@ -1518,9 +1506,11 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
if (msi_flag!=1) {
for (i=0; i<8; i++)
UE_mac_inst[module_idP].commonSF_Alloc_r9_mbsfn_SubframeConfig[i] = NULL;
+
for (i=0; i<15; i++)
UE_mac_inst[module_idP].pmch_Config[i] = NULL;
- for (i=0; i<28 ;i++) {
+
+ for (i=0; i<28 ; i++) {
UE_mac_inst[module_idP].pmch_lcids[i] = -1;
UE_mac_inst[module_idP].pmch_stop_mtch[i] = 2047;
UE_mac_inst[module_idP].msi_status_v[i] = 0;
@@ -1532,6 +1522,7 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
UE_mac_inst[module_idP].msi_status_v[i] = 0;
}
}
+
return mcch_mcs;
} else if ((mtch_flag==1) && (UE_mac_inst[module_idP].msi_status_v[(mch_lcid > 27) ? 27 : mch_lcid] == 1)) {
return mtch_mcs;
@@ -1543,949 +1534,905 @@ int ue_query_mch(module_id_t module_idP, uint8_t CC_id, uint32_t frameP, uint32_
#endif
unsigned char
-generate_ulsch_header(uint8_t * mac_header,
- uint8_t num_sdus,
- uint8_t short_padding,
- uint16_t * sdu_lengths,
- uint8_t * sdu_lcids,
- POWER_HEADROOM_CMD * power_headroom,
- uint16_t * crnti,
- BSR_SHORT * truncated_bsr,
- BSR_SHORT * short_bsr,
- BSR_LONG * long_bsr, unsigned short post_padding)
-{
-
- SCH_SUBHEADER_FIXED *mac_header_ptr =
- (SCH_SUBHEADER_FIXED *) mac_header;
- unsigned char first_element = 0, last_size = 0, i;
- unsigned char mac_header_control_elements[16], *ce_ptr;
-
- LOG_D(MAC, "[UE] Generate ULSCH : num_sdus %d\n", num_sdus);
+generate_ulsch_header(uint8_t *mac_header,
+ uint8_t num_sdus,
+ uint8_t short_padding,
+ uint16_t *sdu_lengths,
+ uint8_t *sdu_lcids,
+ POWER_HEADROOM_CMD *power_headroom,
+ uint16_t *crnti,
+ BSR_SHORT *truncated_bsr,
+ BSR_SHORT *short_bsr,
+ BSR_LONG *long_bsr, unsigned short post_padding) {
+ SCH_SUBHEADER_FIXED *mac_header_ptr =
+ (SCH_SUBHEADER_FIXED *) mac_header;
+ unsigned char first_element = 0, last_size = 0, i;
+ unsigned char mac_header_control_elements[16], *ce_ptr;
+ LOG_D(MAC, "[UE] Generate ULSCH : num_sdus %d\n", num_sdus);
#ifdef DEBUG_HEADER_PARSING
- for (i = 0; i < num_sdus; i++) {
- LOG_T(MAC, "[UE] sdu %d : lcid %d length %d", i, sdu_lcids[i],
- sdu_lengths[i]);
+ for (i = 0; i < num_sdus; i++) {
+ LOG_T(MAC, "[UE] sdu %d : lcid %d length %d", i, sdu_lcids[i],
+ sdu_lengths[i]);
+ }
+
+ LOG_T(MAC, "\n");
+#endif
+ ce_ptr = &mac_header_control_elements[0];
+
+ if ((short_padding == 1) || (short_padding == 2)) {
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = SHORT_PADDING;
+ first_element = 1;
+ last_size = 1;
+ }
+
+ if (short_padding == 2) {
+ mac_header_ptr->E = 1;
+ mac_header_ptr++;
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = SHORT_PADDING;
+ last_size = 1;
+ }
+
+ if (power_headroom) {
+ if (first_element > 0) {
+ mac_header_ptr->E = 1;
+ mac_header_ptr++;
+ } else {
+ first_element = 1;
}
- LOG_T(MAC, "\n");
-#endif
- ce_ptr = &mac_header_control_elements[0];
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = POWER_HEADROOM;
+ last_size = 1;
+ *((POWER_HEADROOM_CMD *) ce_ptr) = (*power_headroom);
+ ce_ptr += sizeof(POWER_HEADROOM_CMD);
+ LOG_D(MAC, "phr header size %zu\n", sizeof(POWER_HEADROOM_CMD));
+ }
- if ((short_padding == 1) || (short_padding == 2)) {
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = SHORT_PADDING;
- first_element = 1;
- last_size = 1;
+ if (crnti) {
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] CRNTI : %x (first_element %d)\n", *crnti,
+ first_element);
+#endif
+
+ if (first_element > 0) {
+ mac_header_ptr->E = 1;
+ mac_header_ptr++;
+ } else {
+ first_element = 1;
}
- if (short_padding == 2) {
- mac_header_ptr->E = 1;
- mac_header_ptr++;
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = SHORT_PADDING;
- last_size = 1;
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = CRNTI;
+ last_size = 1;
+ *((uint16_t *) ce_ptr) = (*crnti);
+ ce_ptr += sizeof(uint16_t);
+ // printf("offset %d\n",ce_ptr-mac_header_control_elements);
+ }
+
+ if (truncated_bsr) {
+ if (first_element > 0) {
+ mac_header_ptr->E = 1;
+ /*
+ printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
+ */
+ mac_header_ptr++;
+ } else {
+ first_element = 1;
}
- if (power_headroom) {
- if (first_element > 0) {
- mac_header_ptr->E = 1;
- mac_header_ptr++;
- } else {
- first_element = 1;
- }
-
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = POWER_HEADROOM;
- last_size = 1;
- *((POWER_HEADROOM_CMD *) ce_ptr) = (*power_headroom);
- ce_ptr += sizeof(POWER_HEADROOM_CMD);
- LOG_D(MAC, "phr header size %zu\n", sizeof(POWER_HEADROOM_CMD));
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] Scheduler Truncated BSR Header\n");
+#endif
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = TRUNCATED_BSR;
+ last_size = 1;
+ *((BSR_TRUNCATED *) ce_ptr) = (*truncated_bsr);
+ ce_ptr += sizeof(BSR_TRUNCATED);
+ // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
+ } else if (short_bsr) {
+ if (first_element > 0) {
+ mac_header_ptr->E = 1;
+ /*
+ printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
+ */
+ mac_header_ptr++;
+ } else {
+ first_element = 1;
}
- if (crnti) {
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] CRNTI : %x (first_element %d)\n", *crnti,
- first_element);
+ LOG_D(MAC, "[UE] Scheduler SHORT BSR Header\n");
#endif
-
- if (first_element > 0) {
- mac_header_ptr->E = 1;
- mac_header_ptr++;
- } else {
- first_element = 1;
- }
-
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = CRNTI;
- last_size = 1;
- *((uint16_t *) ce_ptr) = (*crnti);
- ce_ptr += sizeof(uint16_t);
- // printf("offset %d\n",ce_ptr-mac_header_control_elements);
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = SHORT_BSR;
+ last_size = 1;
+ *((BSR_SHORT *) ce_ptr) = (*short_bsr);
+ ce_ptr += sizeof(BSR_SHORT);
+ // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
+ } else if (long_bsr) {
+ if (first_element > 0) {
+ mac_header_ptr->E = 1;
+ /*
+ printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
+ ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
+ */
+ mac_header_ptr++;
+ } else {
+ first_element = 1;
}
- if (truncated_bsr) {
- if (first_element > 0) {
- mac_header_ptr->E = 1;
- /*
- printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
- */
- mac_header_ptr++;
- } else {
- first_element = 1;
- }
-
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] Scheduler Truncated BSR Header\n");
+ LOG_D(MAC, "[UE] Scheduler Long BSR Header\n");
#endif
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = TRUNCATED_BSR;
- last_size = 1;
- *((BSR_TRUNCATED *) ce_ptr) = (*truncated_bsr);
- ce_ptr += sizeof(BSR_TRUNCATED);
- // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = LONG_BSR;
+ last_size = 1;
+ *(ce_ptr) =
+ (long_bsr->
+ Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4);
+ *(ce_ptr + 1) =
+ ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->
+ Buffer_size2 & 0x3C)
+ >> 2);
+ *(ce_ptr + 2) =
+ ((long_bsr->
+ Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F);
+ ce_ptr += BSR_LONG_SIZE;
+ // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
+ }
- } else if (short_bsr) {
- if (first_element > 0) {
- mac_header_ptr->E = 1;
- /*
- printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
- */
- mac_header_ptr++;
- } else {
- first_element = 1;
- }
+ // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
+ for (i = 0; i < num_sdus; i++) {
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] Scheduler SHORT BSR Header\n");
+ LOG_T(MAC, "[UE] sdu subheader %d (lcid %d, %d bytes)\n", i,
+ sdu_lcids[i], sdu_lengths[i]);
#endif
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = SHORT_BSR;
- last_size = 1;
- *((BSR_SHORT *) ce_ptr) = (*short_bsr);
- ce_ptr += sizeof(BSR_SHORT);
-
- // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
- } else if (long_bsr) {
- if (first_element > 0) {
- mac_header_ptr->E = 1;
- /*
- printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E,
- ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID);
- */
- mac_header_ptr++;
- } else {
- first_element = 1;
- }
+ if ((i == (num_sdus - 1))
+ && ((short_padding) || (post_padding == 0))) {
+ if (first_element > 0) {
+ mac_header_ptr->E = 1;
#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] Scheduler Long BSR Header\n");
+ LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n",
+ *(unsigned char *) mac_header_ptr,
+ ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R,
+ ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E,
+ ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID);
#endif
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = LONG_BSR;
- last_size = 1;
+ mac_header_ptr += last_size;
+ }
- *(ce_ptr) =
- (long_bsr->
- Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4);
- *(ce_ptr + 1) =
- ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->
- Buffer_size2 & 0x3C)
- >> 2);
- *(ce_ptr + 2) =
- ((long_bsr->
- Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F);
- ce_ptr += BSR_LONG_SIZE;
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = sdu_lcids[i];
+ } else {
+ if ((first_element > 0)) {
+ mac_header_ptr->E = 1;
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n",
+ *(unsigned char *) mac_header_ptr,
+ ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R,
+ ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E,
+ ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID);
+#endif
+ mac_header_ptr += last_size;
+ // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
+ } else {
+ first_element = 1;
+ }
- // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements);
+ if (sdu_lengths[i] < 128) {
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; // 3
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0;
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0;
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID =
+ sdu_lcids[i];
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L =
+ (unsigned char) sdu_lengths[i];
+ last_size = 2;
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] short sdu\n");
+ LOG_T(MAC,
+ "[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n",
+ ((uint16_t *) mac_header_ptr)[0],
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R,
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E,
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID,
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F,
+ ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L);
+#endif
+ } else {
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0;
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0;
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1;
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID =
+ sdu_lcids[i];
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB =
+ ((unsigned short) sdu_lengths[i] >> 8) & 0x7f;
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB =
+ (unsigned short) sdu_lengths[i] & 0xff;
+ ((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00;
+ last_size = 3;
+#ifdef DEBUG_HEADER_PARSING
+ LOG_D(MAC, "[UE] long sdu\n");
+#endif
+ }
}
- // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
+ }
+
+ if (post_padding > 0) { // we have lots of padding at the end of the packet
+ mac_header_ptr->E = 1;
+ mac_header_ptr += last_size;
+ // add a padding element
+ mac_header_ptr->R = 0;
+ mac_header_ptr->E = 0;
+ mac_header_ptr->LCID = SHORT_PADDING;
+ mac_header_ptr++;
+ } else { // no end of packet padding
+ // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE)
+ mac_header_ptr++;
+ //mac_header_ptr=last_size; // FIXME: should be ++
+ }
+
+ if ((ce_ptr - mac_header_control_elements) > 0) {
+ memcpy((void *) mac_header_ptr, mac_header_control_elements,
+ ce_ptr - mac_header_control_elements);
+ mac_header_ptr +=
+ (unsigned char) (ce_ptr - mac_header_control_elements);
+ }
- for (i = 0; i < num_sdus; i++) {
#ifdef DEBUG_HEADER_PARSING
- LOG_T(MAC, "[UE] sdu subheader %d (lcid %d, %d bytes)\n", i,
- sdu_lcids[i], sdu_lengths[i]);
+ LOG_T(MAC, " [UE] header : ");
+
+ for (i = 0; i < ((unsigned char *) mac_header_ptr - mac_header); i++) {
+ LOG_T(MAC, "%2x.", mac_header[i]);
+ }
+
+ LOG_T(MAC, "\n");
#endif
-
- if ((i == (num_sdus - 1))
- && ((short_padding) || (post_padding == 0))) {
- if (first_element > 0) {
- mac_header_ptr->E = 1;
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n",
- *(unsigned char *) mac_header_ptr,
- ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R,
- ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E,
- ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID);
-#endif
- mac_header_ptr += last_size;
- }
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = sdu_lcids[i];
- } else {
- if ((first_element > 0)) {
- mac_header_ptr->E = 1;
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] last subheader : %x (R%d,E%d,LCID%d)\n",
- *(unsigned char *) mac_header_ptr,
- ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->R,
- ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->E,
- ((SCH_SUBHEADER_FIXED *) mac_header_ptr)->LCID);
-#endif
- mac_header_ptr += last_size;
- // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr);
- } else {
- first_element = 1;
-
- }
-
- if (sdu_lengths[i] < 128) {
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R = 0; // 3
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E = 0;
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F = 0;
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID =
- sdu_lcids[i];
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L =
- (unsigned char) sdu_lengths[i];
- last_size = 2;
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] short sdu\n");
- LOG_T(MAC,
- "[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n",
- ((uint16_t *) mac_header_ptr)[0],
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->R,
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->E,
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->LCID,
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->F,
- ((SCH_SUBHEADER_SHORT *) mac_header_ptr)->L);
-#endif
- } else {
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->R = 0;
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->E = 0;
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->F = 1;
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->LCID =
- sdu_lcids[i];
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_MSB =
- ((unsigned short) sdu_lengths[i] >> 8) & 0x7f;
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->L_LSB =
- (unsigned short) sdu_lengths[i] & 0xff;
- ((SCH_SUBHEADER_LONG *) mac_header_ptr)->padding = 0x00;
- last_size = 3;
-#ifdef DEBUG_HEADER_PARSING
- LOG_D(MAC, "[UE] long sdu\n");
-#endif
- }
- }
- }
-
- if (post_padding > 0) { // we have lots of padding at the end of the packet
- mac_header_ptr->E = 1;
- mac_header_ptr += last_size;
- // add a padding element
- mac_header_ptr->R = 0;
- mac_header_ptr->E = 0;
- mac_header_ptr->LCID = SHORT_PADDING;
- mac_header_ptr++;
- } else { // no end of packet padding
- // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE)
- mac_header_ptr++;
- //mac_header_ptr=last_size; // FIXME: should be ++
- }
-
-
- if ((ce_ptr - mac_header_control_elements) > 0) {
- memcpy((void *) mac_header_ptr, mac_header_control_elements,
- ce_ptr - mac_header_control_elements);
- mac_header_ptr +=
- (unsigned char) (ce_ptr - mac_header_control_elements);
- }
-#ifdef DEBUG_HEADER_PARSING
- LOG_T(MAC, " [UE] header : ");
-
- for (i = 0; i < ((unsigned char *) mac_header_ptr - mac_header); i++) {
- LOG_T(MAC, "%2x.", mac_header[i]);
- }
-
- LOG_T(MAC, "\n");
-#endif
- return ((unsigned char *) mac_header_ptr - mac_header);
-
+ return ((unsigned char *) mac_header_ptr - mac_header);
}
void
ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
- sub_frame_t subframe, uint8_t eNB_index,
- uint8_t * ulsch_buffer, uint16_t buflen, uint8_t * access_mode)
-{
-
- uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0;
- uint16_t buflen_remain = 0;
- uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0;
- uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0;
- uint8_t lcid = 0, lcid_rlc_pdu_count = 0;
- boolean_t is_lcid_processed = FALSE;
- boolean_t is_all_lcid_processed = FALSE;
- uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
- uint8_t payload_offset = 0, num_sdus = 0;
- uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
- uint16_t sdu_length_total = 0;
- BSR_SHORT bsr_short, bsr_truncated;
- BSR_LONG bsr_long;
- BSR_SHORT *bsr_s = &bsr_short;
- BSR_LONG *bsr_l = &bsr_long;
- BSR_SHORT *bsr_t = &bsr_truncated;
- POWER_HEADROOM_CMD phr;
- POWER_HEADROOM_CMD *phr_p = &phr;
- unsigned short short_padding = 0, post_padding = 0, padding_len = 0;
- int j; // used for padding
- // Compute header length
- int lcg_id = 0;
- int lcg_id_bsr_trunc = 0;
- int highest_priority = 16;
- int num_lcg_id_with_data = 0;
- rlc_buffer_occupancy_t lcid_buffer_occupancy_old =
- 0, lcid_buffer_occupancy_new = 0;
-
- LOG_D(MAC,
- "[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n",
- module_idP, frameP, subframe, buflen);
-
-
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
-
+ sub_frame_t subframe, uint8_t eNB_index,
+ uint8_t *ulsch_buffer, uint16_t buflen, uint8_t *access_mode) {
+ uint8_t total_rlc_pdu_header_len = 0, rlc_pdu_header_len_last = 0;
+ uint16_t buflen_remain = 0;
+ uint8_t bsr_len = 0, bsr_ce_len = 0, bsr_header_len = 0;
+ uint8_t phr_header_len = 0, phr_ce_len = 0, phr_len = 0;
+ uint8_t lcid = 0, lcid_rlc_pdu_count = 0;
+ boolean_t is_lcid_processed = FALSE;
+ boolean_t is_all_lcid_processed = FALSE;
+ uint16_t sdu_lengths[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ uint8_t sdu_lcids[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ uint8_t payload_offset = 0, num_sdus = 0;
+ uint8_t ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES];
+ uint16_t sdu_length_total = 0;
+ BSR_SHORT bsr_short, bsr_truncated;
+ BSR_LONG bsr_long;
+ BSR_SHORT *bsr_s = &bsr_short;
+ BSR_LONG *bsr_l = &bsr_long;
+ BSR_SHORT *bsr_t = &bsr_truncated;
+ POWER_HEADROOM_CMD phr;
+ POWER_HEADROOM_CMD *phr_p = &phr;
+ unsigned short short_padding = 0, post_padding = 0, padding_len = 0;
+ int j; // used for padding
+ // Compute header length
+ int lcg_id = 0;
+ int lcg_id_bsr_trunc = 0;
+ int highest_priority = 16;
+ int num_lcg_id_with_data = 0;
+ rlc_buffer_occupancy_t lcid_buffer_occupancy_old =
+ 0, lcid_buffer_occupancy_new = 0;
+ LOG_D(MAC,
+ "[UE %d] MAC PROCESS UL TRANSPORT BLOCK at frame%d subframe %d TBS=%d\n",
+ module_idP, frameP, subframe, buflen);
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
#if UE_TIMING_TRACE
- start_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu);
+ start_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu);
#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN);
-
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_IN);
#ifdef CBA
- if (*access_mode == CBA_ACCESS) {
- LOG_D(MAC, "[UE %d] frameP %d subframe %d try CBA transmission\n",
- module_idP, frameP, subframe);
+ if (*access_mode == CBA_ACCESS) {
+ LOG_D(MAC, "[UE %d] frameP %d subframe %d try CBA transmission\n",
+ module_idP, frameP, subframe);
- //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY)
- if (cba_access(module_idP, frameP, subframe, eNB_index, buflen) ==
- 0) {
- *access_mode = POSTPONED_ACCESS;
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
- return;
- }
-
- LOG_I(MAC,
- "[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n",
- module_idP, frameP, subframe, buflen);
+ //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY)
+ if (cba_access(module_idP, frameP, subframe, eNB_index, buflen) ==
+ 0) {
+ *access_mode = POSTPONED_ACCESS;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
+ return;
}
+
+ LOG_I(MAC,
+ "[UE %d] frameP %d subframe %d CBA transmission oppurtunity, tbs %d\n",
+ module_idP, frameP, subframe, buflen);
+ }
+
#endif
- bsr_header_len = 0;
- phr_header_len = 1; //sizeof(SCH_SUBHEADER_FIXED);
+ bsr_header_len = 0;
+ phr_header_len = 1; //sizeof(SCH_SUBHEADER_FIXED);
- while (lcg_id < MAX_NUM_LCGID) {
- if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) {
- num_lcg_id_with_data++;
- }
- lcg_id++;
+ while (lcg_id < MAX_NUM_LCGID) {
+ if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) {
+ num_lcg_id_with_data++;
}
- if (num_lcg_id_with_data) {
- LOG_D(MAC,
- "[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n",
- module_idP, frameP, subframe, num_lcg_id_with_data,
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0],
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1],
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2],
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3],
- UE_mac_inst[module_idP].BSR_reporting_active, buflen);
+ lcg_id++;
+ }
+ if (num_lcg_id_with_data) {
+ LOG_D(MAC,
+ "[UE %d] MAC Tx data pending at frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n",
+ module_idP, frameP, subframe, num_lcg_id_with_data,
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0],
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1],
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2],
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3],
+ UE_mac_inst[module_idP].BSR_reporting_active, buflen);
+ }
+
+ //Restart ReTxBSR Timer at new grant indication (36.321)
+ if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF !=
+ MAC_UE_BSR_TIMER_NOT_RUNNING) {
+ UE_mac_inst[module_idP].scheduling_info.retxBSR_SF =
+ get_sf_retxBSRTimer(UE_mac_inst[module_idP].
+ scheduling_info.retxBSR_Timer);
+ }
+
+ // periodicBSR-Timer expires, trigger BSR
+ if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer !=
+ LTE_PeriodicBSR_Timer_r12_infinity)
+ && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)) {
+ // Trigger BSR Periodic
+ UE_mac_inst[module_idP].BSR_reporting_active |=
+ BSR_TRIGGER_PERIODIC;
+ LOG_D(MAC,
+ "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n",
+ module_idP, frameP, subframe, buflen);
+ }
+
+ //Compute BSR Length if Regular or Periodic BSR is triggered
+ //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx
+ if (UE_mac_inst[module_idP].BSR_reporting_active) {
+ AssertFatal((UE_mac_inst[module_idP].BSR_reporting_active &
+ BSR_TRIGGER_PADDING) == 0,
+ "Inconsistent BSR Trigger=%d !\n",
+ UE_mac_inst[module_idP].BSR_reporting_active);
+
+ if (buflen >= 4) {
+ //A Regular or Periodic BSR can only be sent if TBS >= 4 as transmitting only a BSR is not allowed if UE has data to transmit
+ bsr_header_len = 1;
+
+ if (num_lcg_id_with_data <= 1) {
+ bsr_ce_len = sizeof(BSR_SHORT); //1 byte
+ } else {
+ bsr_ce_len = BSR_LONG_SIZE; //3 bytes
+ }
}
- //Restart ReTxBSR Timer at new grant indication (36.321)
- if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF !=
- MAC_UE_BSR_TIMER_NOT_RUNNING) {
- UE_mac_inst[module_idP].scheduling_info.retxBSR_SF =
- get_sf_retxBSRTimer(UE_mac_inst[module_idP].
- scheduling_info.retxBSR_Timer);
- }
- // periodicBSR-Timer expires, trigger BSR
- if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer !=
- LTE_PeriodicBSR_Timer_r12_infinity)
- && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF == 0)) {
- // Trigger BSR Periodic
- UE_mac_inst[module_idP].BSR_reporting_active |=
- BSR_TRIGGER_PERIODIC;
+ }
- LOG_D(MAC,
- "[UE %d] MAC BSR Triggered PeriodicBSR Timer expiry at frame%d subframe %d TBS=%d\n",
- module_idP, frameP, subframe, buflen);
+ bsr_len = bsr_ce_len + bsr_header_len;
+ phr_ce_len =
+ (UE_mac_inst[module_idP].PHR_reporting_active ==
+ 1) ? 1 /* sizeof(POWER_HEADROOM_CMD) */ : 0;
- }
- //Compute BSR Length if Regular or Periodic BSR is triggered
- //WARNING: if BSR long is computed, it may be changed to BSR short during or after multiplexing if there remains less than 1 LCGROUP with data after Tx
- if (UE_mac_inst[module_idP].BSR_reporting_active) {
+ if ((phr_ce_len > 0)
+ && ((phr_ce_len + phr_header_len + bsr_len) <= buflen)) {
+ phr_len = phr_ce_len + phr_header_len;
+ LOG_D(MAC,
+ "[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n",
+ module_idP, phr_len, phr_ce_len, phr_header_len, buflen);
+ } else {
+ phr_len = 0;
+ phr_header_len = 0;
+ phr_ce_len = 0;
+ }
- AssertFatal((UE_mac_inst[module_idP].BSR_reporting_active &
- BSR_TRIGGER_PADDING) == 0,
- "Inconsistent BSR Trigger=%d !\n",
- UE_mac_inst[module_idP].BSR_reporting_active);
+ // check for UL bandwidth requests and add SR control element
- if (buflen >= 4) {
- //A Regular or Periodic BSR can only be sent if TBS >= 4 as transmitting only a BSR is not allowed if UE has data to transmit
- bsr_header_len = 1;
+ // check for UL bandwidth requests and add SR control element
- if (num_lcg_id_with_data <= 1) {
- bsr_ce_len = sizeof(BSR_SHORT); //1 byte
- } else {
- bsr_ce_len = BSR_LONG_SIZE; //3 bytes
- }
- }
- }
+ // Check for DCCH first
+ // TO DO: Multiplex in the order defined by the logical channel prioritization
+ for (lcid = DCCH;
+ (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE); lcid++) {
+ if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] ==
+ LCID_NOT_EMPTY) {
+ lcid_rlc_pdu_count = 0;
+ is_lcid_processed = FALSE;
+ lcid_buffer_occupancy_old =
+ mac_rlc_get_buffer_occupancy_ind(module_idP,
+ UE_mac_inst[module_idP].
+ crnti, eNB_index, frameP,
+ subframe, ENB_FLAG_NO,
+ lcid);
+ lcid_buffer_occupancy_new = lcid_buffer_occupancy_old;
+ AssertFatal(lcid_buffer_occupancy_new ==
+ UE_mac_inst[module_idP].
+ scheduling_info.LCID_buffer_remain[lcid],
+ "LCID=%d RLC has BO %d bytes but MAC has stored %d bytes\n",
+ lcid, lcid_buffer_occupancy_new,
+ UE_mac_inst[module_idP].
+ scheduling_info.LCID_buffer_remain[lcid]);
+ AssertFatal(lcid_buffer_occupancy_new <=
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
+ scheduling_info.LCGID
+ [lcid]],
+ "LCID=%d RLC has more BO %d bytes than BSR = %d bytes\n",
+ lcid, lcid_buffer_occupancy_new,
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
+ scheduling_info.LCGID
+ [lcid]]);
- bsr_len = bsr_ce_len + bsr_header_len;
+ //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data
+ //Adjust at the end of the loop
+ while ((!is_lcid_processed) && (lcid_buffer_occupancy_new)
+ && (bsr_len + phr_len + total_rlc_pdu_header_len +
+ sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen)) {
+ // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU
+ if (( get_softmodem_params()->usim_test == 0) && (lcid == DCCH1)
+ && (lcid_rlc_pdu_count == 0) && (num_sdus)) {
+ // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed
+ break;
+ }
- phr_ce_len =
- (UE_mac_inst[module_idP].PHR_reporting_active ==
- 1) ? 1 /* sizeof(POWER_HEADROOM_CMD) */ : 0;
- if ((phr_ce_len > 0)
- && ((phr_ce_len + phr_header_len + bsr_len) <= buflen)) {
- phr_len = phr_ce_len + phr_header_len;
- LOG_D(MAC,
- "[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n",
- module_idP, phr_len, phr_ce_len, phr_header_len, buflen);
- } else {
- phr_len = 0;
- phr_header_len = 0;
- phr_ce_len = 0;
- }
-
- // check for UL bandwidth requests and add SR control element
-
- // check for UL bandwidth requests and add SR control element
-
- // Check for DCCH first
-// TO DO: Multiplex in the order defined by the logical channel prioritization
- for (lcid = DCCH;
- (lcid < MAX_NUM_LCID) && (is_all_lcid_processed == FALSE); lcid++)
- {
- if (UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] ==
- LCID_NOT_EMPTY) {
-
- lcid_rlc_pdu_count = 0;
- is_lcid_processed = FALSE;
- lcid_buffer_occupancy_old =
- mac_rlc_get_buffer_occupancy_ind(module_idP,
- UE_mac_inst[module_idP].
- crnti, eNB_index, frameP,
- subframe, ENB_FLAG_NO,
- lcid);
-
- lcid_buffer_occupancy_new = lcid_buffer_occupancy_old;
-
- AssertFatal(lcid_buffer_occupancy_new ==
- UE_mac_inst[module_idP].
- scheduling_info.LCID_buffer_remain[lcid],
- "LCID=%d RLC has BO %d bytes but MAC has stored %d bytes\n",
- lcid, lcid_buffer_occupancy_new,
- UE_mac_inst[module_idP].
- scheduling_info.LCID_buffer_remain[lcid]);
-
- AssertFatal(lcid_buffer_occupancy_new <=
- UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
- scheduling_info.LCGID
- [lcid]],
- "LCID=%d RLC has more BO %d bytes than BSR = %d bytes\n",
- lcid, lcid_buffer_occupancy_new,
- UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
- scheduling_info.LCGID
- [lcid]]);
-
-
- //Multiplex all available DCCH RLC PDUs considering to multiplex the last PDU each time for maximize the data
- //Adjust at the end of the loop
- while ((!is_lcid_processed) && (lcid_buffer_occupancy_new)
- && (bsr_len + phr_len + total_rlc_pdu_header_len +
- sdu_length_total + MIN_MAC_HDR_RLC_SIZE <= buflen))
- {
-
- // Workaround for issue in OAI eNB or EPC which are not able to process SRB2 message multiplexed with SRB1 on the same MAC PDU
- if (( get_softmodem_params()->usim_test == 0) && (lcid == DCCH1)
- && (lcid_rlc_pdu_count == 0) && (num_sdus)) {
-
- // Skip SRB2 multiplex if at least one SRB1 SDU is already multiplexed
- break;
- }
-
- buflen_remain =
- buflen - (bsr_len + phr_len +
- total_rlc_pdu_header_len + sdu_length_total +
- 1);
-
-
- LOG_D(MAC,
- "[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to "
- "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n",
- module_idP, frameP, lcid, lcid_buffer_occupancy_new,
- buflen, bsr_len, phr_len, sdu_length_total,
- total_rlc_pdu_header_len,
- UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
- scheduling_info.LCGID
- [lcid]]);
-
-
- sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
- UE_mac_inst
- [module_idP].
- crnti, eNB_index,
- frameP,
- ENB_FLAG_NO,
- MBMS_FLAG_NO,
- lcid,
- buflen_remain,
- (char *)&ulsch_buff[sdu_length_total]
+ buflen_remain =
+ buflen - (bsr_len + phr_len +
+ total_rlc_pdu_header_len + sdu_length_total +
+ 1);
+ LOG_D(MAC,
+ "[UE %d] Frame %d : UL-DXCH -> ULSCH, RLC %d has %d bytes to "
+ "send (Transport Block size %d BSR size=%d PHR=%d SDU Length Total %d , mac header len %d BSR byte before Tx=%d)\n",
+ module_idP, frameP, lcid, lcid_buffer_occupancy_new,
+ buflen, bsr_len, phr_len, sdu_length_total,
+ total_rlc_pdu_header_len,
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
+ scheduling_info.LCGID
+ [lcid]]);
+ sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,
+ UE_mac_inst
+ [module_idP].
+ crnti, eNB_index,
+ frameP,
+ ENB_FLAG_NO,
+ MBMS_FLAG_NO,
+ lcid,
+ buflen_remain,
+ (char *)&ulsch_buff[sdu_length_total]
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,0,
- 0
+ ,0,
+ 0
#endif
- );
+ );
+ AssertFatal(buflen_remain >= sdu_lengths[num_sdus],
+ "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n",
+ lcid, sdu_lengths[num_sdus], buflen_remain);
+ if (sdu_lengths[num_sdus]) {
+ sdu_length_total += sdu_lengths[num_sdus];
+ sdu_lcids[num_sdus] = lcid;
+ LOG_I(MAC,
+ "[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n",
+ module_idP, sdu_lengths[num_sdus], lcid);
+ if (buflen ==
+ (bsr_len + phr_len + total_rlc_pdu_header_len +
+ sdu_length_total + 1)) {
+ //No more remaining TBS after this PDU
+ //exit the function
+ rlc_pdu_header_len_last = 1;
+ is_lcid_processed = TRUE;
+ is_all_lcid_processed = TRUE;
+ } else {
+ rlc_pdu_header_len_last =
+ (sdu_lengths[num_sdus] > 128) ? 3 : 2;
- AssertFatal(buflen_remain >= sdu_lengths[num_sdus],
- "LCID=%d RLC has segmented %d bytes but MAC has max=%d\n",
- lcid, sdu_lengths[num_sdus], buflen_remain);
+ //Change to 1 byte if it does not fit in the TBS, ie last PDU
+ if (buflen <=
+ (bsr_len + phr_len + total_rlc_pdu_header_len +
+ rlc_pdu_header_len_last + sdu_length_total)) {
+ rlc_pdu_header_len_last = 1;
+ is_lcid_processed = TRUE;
+ is_all_lcid_processed = TRUE;
+ }
+ }
+ //Update number of SDU
+ num_sdus++;
+ //Update total MAC Header size for RLC PDUs and save last one
+ total_rlc_pdu_header_len += rlc_pdu_header_len_last;
+ lcid_rlc_pdu_count++;
+ } else {
+ /* avoid infinite loop ... */
+ is_lcid_processed = TRUE;
+ }
- if (sdu_lengths[num_sdus]) {
- sdu_length_total += sdu_lengths[num_sdus];
- sdu_lcids[num_sdus] = lcid;
- LOG_I(MAC,
- "[UE %d] TX Multiplex RLC PDU TX Got %d bytes for LcId%d\n",
- module_idP, sdu_lengths[num_sdus], lcid);
+ /* Get updated BO after multiplexing this PDU */
+ lcid_buffer_occupancy_new =
+ mac_rlc_get_buffer_occupancy_ind(module_idP,
+ UE_mac_inst
+ [module_idP].crnti,
+ eNB_index, frameP,
+ subframe, ENB_FLAG_NO,
+ lcid);
+ is_lcid_processed = (is_lcid_processed)
+ || (lcid_buffer_occupancy_new <= 0);
+ }
- if (buflen ==
- (bsr_len + phr_len + total_rlc_pdu_header_len +
- sdu_length_total + 1)) {
- //No more remaining TBS after this PDU
- //exit the function
- rlc_pdu_header_len_last = 1;
- is_lcid_processed = TRUE;
- is_all_lcid_processed = TRUE;
- } else {
- rlc_pdu_header_len_last =
- (sdu_lengths[num_sdus] > 128) ? 3 : 2;
+ //Update Buffer remain and BSR bytes after transmission
+ AssertFatal(lcid_buffer_occupancy_new <=
+ lcid_buffer_occupancy_old,
+ "MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n",
+ lcid_buffer_occupancy_new,
+ lcid_buffer_occupancy_old, lcid,
+ lcid_rlc_pdu_count, frameP, subframe);
+ UE_mac_inst[module_idP].scheduling_info.
+ LCID_buffer_remain[lcid] = lcid_buffer_occupancy_new;
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
+ scheduling_info.LCGID[lcid]] +=
+ (lcid_buffer_occupancy_new - lcid_buffer_occupancy_old);
- //Change to 1 byte if it does not fit in the TBS, ie last PDU
- if (buflen <=
- (bsr_len + phr_len + total_rlc_pdu_header_len +
- rlc_pdu_header_len_last + sdu_length_total)) {
- rlc_pdu_header_len_last = 1;
- is_lcid_processed = TRUE;
- is_all_lcid_processed = TRUE;
- }
- }
+ //Update the number of LCGID with data as BSR shall reflect status after BSR transmission
+ if ((num_lcg_id_with_data > 1)
+ && (UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
+ scheduling_info.LCGID[lcid]]
+ == 0)) {
+ num_lcg_id_with_data--;
- //Update number of SDU
- num_sdus++;
+ // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1
+ if ((bsr_len) && (num_lcg_id_with_data == 1)) {
+ bsr_ce_len = sizeof(BSR_SHORT);
+ bsr_len = bsr_ce_len + bsr_header_len;
+ }
+ }
- //Update total MAC Header size for RLC PDUs and save last one
- total_rlc_pdu_header_len += rlc_pdu_header_len_last;
-
- lcid_rlc_pdu_count++;
- } else {
- /* avoid infinite loop ... */
- is_lcid_processed = TRUE;
- }
-
- /* Get updated BO after multiplexing this PDU */
- lcid_buffer_occupancy_new =
- mac_rlc_get_buffer_occupancy_ind(module_idP,
- UE_mac_inst
- [module_idP].crnti,
- eNB_index, frameP,
- subframe, ENB_FLAG_NO,
- lcid);
-
- is_lcid_processed = (is_lcid_processed)
- || (lcid_buffer_occupancy_new <= 0);
- }
-
- //Update Buffer remain and BSR bytes after transmission
-
- AssertFatal(lcid_buffer_occupancy_new <=
- lcid_buffer_occupancy_old,
- "MAC UE Tx error : Buffer Occupancy After Tx=%d greater than before=%d BO! for LCID=%d RLC PDU nb=%d Frame %d Subrame %d\n",
- lcid_buffer_occupancy_new,
- lcid_buffer_occupancy_old, lcid,
- lcid_rlc_pdu_count, frameP, subframe);
-
- UE_mac_inst[module_idP].scheduling_info.
- LCID_buffer_remain[lcid] = lcid_buffer_occupancy_new;
- UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
- scheduling_info.LCGID[lcid]] +=
- (lcid_buffer_occupancy_new - lcid_buffer_occupancy_old);
-
- //Update the number of LCGID with data as BSR shall reflect status after BSR transmission
- if ((num_lcg_id_with_data > 1)
- && (UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[UE_mac_inst[module_idP].
- scheduling_info.LCGID[lcid]]
- == 0)) {
- num_lcg_id_with_data--;
- // Change BSR size to BSR SHORT if num_lcg_id_with_data becomes to 1
- if ((bsr_len) && (num_lcg_id_with_data == 1)) {
- bsr_ce_len = sizeof(BSR_SHORT);
- bsr_len = bsr_ce_len + bsr_header_len;
- }
- }
-
-
- UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] =
- LCID_EMPTY;
- }
+ UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] =
+ LCID_EMPTY;
}
+ }
+ // Compute BSR Values and update Nb LCGID with data after multiplexing
+ num_lcg_id_with_data = 0;
+ lcg_id_bsr_trunc = 0;
+ for (lcg_id = 0; lcg_id < MAX_NUM_LCGID; lcg_id++) {
+ UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] =
+ locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE,
+ UE_mac_inst
+ [module_idP].scheduling_info.
+ BSR_bytes[lcg_id]);
- // Compute BSR Values and update Nb LCGID with data after multiplexing
- num_lcg_id_with_data = 0;
- lcg_id_bsr_trunc = 0;
- for (lcg_id = 0; lcg_id < MAX_NUM_LCGID; lcg_id++) {
- UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] =
- locate_BsrIndexByBufferSize(BSR_TABLE, BSR_TABLE_SIZE,
- UE_mac_inst
- [module_idP].scheduling_info.
- BSR_bytes[lcg_id]);
-
- if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) {
- num_lcg_id_with_data++;
- lcg_id_bsr_trunc = lcg_id;
- }
+ if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]) {
+ num_lcg_id_with_data++;
+ lcg_id_bsr_trunc = lcg_id;
}
+ }
-
- if (bsr_ce_len) {
- //Print updated BSR when sent
- LOG_D(MAC,
- "[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n",
- module_idP, frameP, subframe, num_lcg_id_with_data,
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0],
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1],
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2],
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3],
- UE_mac_inst[module_idP].BSR_reporting_active, buflen);
-
- LOG_D(MAC,
- "[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n",
- module_idP, frameP, subframe, bsr_ce_len,
- UE_mac_inst[module_idP].scheduling_info.BSR[0],
- UE_mac_inst[module_idP].scheduling_info.BSR[1],
- UE_mac_inst[module_idP].scheduling_info.BSR[2],
- UE_mac_inst[module_idP].scheduling_info.BSR[3]);
- }
- // build PHR and update the timers
- if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) {
- if(nfapi_mode ==3){
- //Substitute with a static value for the MAC layer abstraction (phy_stub mode)
- phr_p->PH = 40;
- }
- else{
- phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index);
- }
-
-
- phr_p->R = 0;
- LOG_D(MAC,
- "[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n",
- module_idP, frameP, get_PHR(module_idP, CC_id, eNB_index),
- phr_p->PH, POWER_HEADROOM);
- update_phr(module_idP, CC_id);
- } else {
- phr_p = NULL;
- }
-
- LOG_T(MAC, "[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n",
- module_idP, frameP, bsr_s, bsr_l, phr_p);
-
- // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order
- // Check for max padding size, ie MAC Hdr for last RLC PDU = 1
- /* For Padding BSR:
- - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader:
- - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission;
- - else report Short BSR.
- - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR.
- */
- if (sdu_length_total) {
- padding_len =
- buflen - (bsr_len + phr_len + total_rlc_pdu_header_len -
- rlc_pdu_header_len_last + sdu_length_total + 1);
- } else {
- padding_len = buflen - (bsr_len + phr_len);
- }
-
-
- if ((padding_len) && (bsr_len == 0)) {
- /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */
- if (padding_len >= (1 + BSR_LONG_SIZE)) {
- bsr_ce_len = BSR_LONG_SIZE;
- bsr_header_len = 1;
- // Trigger BSR Padding
- UE_mac_inst[module_idP].BSR_reporting_active |=
- BSR_TRIGGER_PADDING;
-
-
- } else if (padding_len >= (1 + sizeof(BSR_SHORT))) {
- bsr_ce_len = sizeof(BSR_SHORT);
- bsr_header_len = 1;
-
- if (num_lcg_id_with_data > 1) {
- // REPORT TRUNCATED BSR
- //Get LCGID of highest priority LCID with data
- for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
- if (UE_mac_inst[module_idP].
- logicalChannelConfig[lcid] != NULL) {
- lcg_id =
- UE_mac_inst[module_idP].scheduling_info.
- LCGID[lcid];
-
- if ((lcg_id < MAX_NUM_LCGID)
- && (UE_mac_inst[module_idP].
- scheduling_info.BSR_bytes[lcg_id])
- &&
- (UE_mac_inst[module_idP].logicalChannelConfig
- [lcid]->ul_SpecificParameters->priority <=
- highest_priority)) {
- highest_priority =
- UE_mac_inst[module_idP].
- logicalChannelConfig[lcid]->
- ul_SpecificParameters->priority;
- lcg_id_bsr_trunc = lcg_id;
- }
- }
- }
- } else {
- //Report SHORT BSR, clear bsr_t
- bsr_t = NULL;
- }
-
- // Trigger BSR Padding
- UE_mac_inst[module_idP].BSR_reporting_active |=
- BSR_TRIGGER_PADDING;
- }
- bsr_len = bsr_header_len + bsr_ce_len;
- }
- //Fill BSR Infos
- if (bsr_ce_len == 0) {
- bsr_s = NULL;
- bsr_l = NULL;
- bsr_t = NULL;
- } else if (bsr_ce_len == BSR_LONG_SIZE) {
- bsr_s = NULL;
- bsr_t = NULL;
- bsr_l->Buffer_size0 =
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0];
- bsr_l->Buffer_size1 =
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1];
- bsr_l->Buffer_size2 =
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2];
- bsr_l->Buffer_size3 =
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3];
-
- LOG_D(MAC,
- "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].BSR_reporting_active,
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0],
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1],
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2],
- UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]);
-
- } else if (bsr_ce_len == sizeof(BSR_SHORT)) {
- bsr_l = NULL;
- if ((bsr_t != NULL)
- && (UE_mac_inst[module_idP].BSR_reporting_active &
- BSR_TRIGGER_PADDING)) {
- //Truncated BSR
- bsr_s = NULL;
- bsr_t->LCGID = lcg_id_bsr_trunc;
- bsr_t->Buffer_size =
- UE_mac_inst[module_idP].scheduling_info.
- BSR[lcg_id_bsr_trunc];
-
- LOG_D(MAC,
- "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].BSR_reporting_active,
- UE_mac_inst[module_idP].
- scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc);
-
- } else {
- bsr_t = NULL;
- bsr_s->LCGID = lcg_id_bsr_trunc;
- bsr_s->Buffer_size =
- UE_mac_inst[module_idP].scheduling_info.
- BSR[lcg_id_bsr_trunc];
-
- LOG_D(MAC,
- "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].BSR_reporting_active,
- UE_mac_inst[module_idP].
- scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc);
- }
- }
-// 1-bit padding or 2-bit padding special padding subheader
-// Check for max padding size, ie MAC Hdr for last RLC PDU = 1
- if (sdu_length_total) {
- padding_len =
- buflen - (bsr_len + phr_len + total_rlc_pdu_header_len -
- rlc_pdu_header_len_last + sdu_length_total + 1);
- } else {
- padding_len = buflen - (bsr_len + phr_len);
- }
-
- if (padding_len <= 2) {
- short_padding = padding_len;
- // only add padding header
- post_padding = 0;
- //update total MAC Hdr size for RLC data
- if (sdu_length_total) {
- total_rlc_pdu_header_len =
- total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1;
- rlc_pdu_header_len_last = 1;
- }
- } else if (sdu_length_total) {
- post_padding =
- buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
- sdu_length_total + 1);
- // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding
- if (post_padding == 0) {
- total_rlc_pdu_header_len -= rlc_pdu_header_len_last;
- padding_len =
- buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
- sdu_length_total + 1);
- short_padding = padding_len;
- total_rlc_pdu_header_len++;
- }
- } else {
- if (padding_len == buflen) { // nona mac pdu
- *access_mode = CANCELED_ACCESS;
- }
-
- short_padding = 0;
-
- post_padding =
- buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
- sdu_length_total + 1);
- }
-
- // Generate header
- // if (num_sdus>0) {
-
- payload_offset = generate_ulsch_header(ulsch_buffer, // mac header
- num_sdus, // num sdus
- short_padding, // short pading
- sdu_lengths, // sdu length
- sdu_lcids, // sdu lcid
- phr_p, // power headroom
- NULL, // crnti
- bsr_t, // truncated bsr
- bsr_s, // short bsr
- bsr_l, post_padding); // long_bsr
-
+ if (bsr_ce_len) {
+ //Print updated BSR when sent
LOG_D(MAC,
- "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n",
- module_idP, buflen, sdu_length_total, num_sdus, sdu_lengths[0],
- sdu_lcids[0], payload_offset, total_rlc_pdu_header_len,
- short_padding, post_padding, bsr_len, phr_len,
- buflen - sdu_length_total - payload_offset);
- // cycle through SDUs and place in ulsch_buffer
- if (sdu_length_total) {
- memcpy(&ulsch_buffer[payload_offset], ulsch_buff,
- sdu_length_total);
- }
- // fill remainder of DLSCH with random data
- if (post_padding) {
- for (j = 0; j < (buflen - sdu_length_total - payload_offset); j++) {
- ulsch_buffer[payload_offset + sdu_length_total + j] =
- (char) (taus() & 0xff);
- }
- }
+ "[UE %d] Remaining Buffer after Tx frame%d subframe %d nb LCG =%d Bytes for LCG0=%d LCG1=%d LCG2=%d LCG3=%d BSR Trigger status =%d TBS=%d\n",
+ module_idP, frameP, subframe, num_lcg_id_with_data,
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[0],
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[1],
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[2],
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[3],
+ UE_mac_inst[module_idP].BSR_reporting_active, buflen);
LOG_D(MAC,
- "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n",
- module_idP);
- UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
- UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0;
+ "[UE %d] Frame %d Subframe %d TX BSR Regular or Periodic size=%d BSR0=%d BSR1=%d BSR2=%d BSR3=%d\n",
+ module_idP, frameP, subframe, bsr_ce_len,
+ UE_mac_inst[module_idP].scheduling_info.BSR[0],
+ UE_mac_inst[module_idP].scheduling_info.BSR[1],
+ UE_mac_inst[module_idP].scheduling_info.BSR[2],
+ UE_mac_inst[module_idP].scheduling_info.BSR[3]);
+ }
- /* Actions when a BSR is sent */
- if (bsr_ce_len) {
- LOG_D(MAC,
- "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n",
- module_idP, bsr_ce_len, bsr_header_len, buflen);
-
- // Reset ReTx BSR Timer
- UE_mac_inst[module_idP].scheduling_info.retxBSR_SF =
- get_sf_retxBSRTimer(UE_mac_inst[module_idP].
- scheduling_info.retxBSR_Timer);
-
- LOG_D(MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP,
- UE_mac_inst[module_idP].scheduling_info.retxBSR_SF);
-
- // Reset Periodic Timer except when BSR is truncated
- if ((bsr_t == NULL)
- && (UE_mac_inst[module_idP].scheduling_info.
- periodicBSR_Timer != LTE_PeriodicBSR_Timer_r12_infinity)) {
- UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF =
- get_sf_periodicBSRTimer(UE_mac_inst
- [module_idP].scheduling_info.
- periodicBSR_Timer);
-
- LOG_D(MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n",
- module_idP,
- UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF);
-
- }
- // Reset BSR Trigger flags
- UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
+ // build PHR and update the timers
+ if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)) {
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
+ //Substitute with a static value for the MAC layer abstraction (phy_stub mode)
+ phr_p->PH = 40;
+ } else {
+ phr_p->PH = get_phr_mapping(module_idP, CC_id, eNB_index);
}
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
+ phr_p->R = 0;
+ LOG_D(MAC,
+ "[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n",
+ module_idP, frameP, get_PHR(module_idP, CC_id, eNB_index),
+ phr_p->PH, POWER_HEADROOM);
+ update_phr(module_idP, CC_id);
+ } else {
+ phr_p = NULL;
+ }
+
+ LOG_T(MAC, "[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n",
+ module_idP, frameP, bsr_s, bsr_l, phr_p);
+
+ // Check BSR padding: it is done after PHR according to Logical Channel Prioritization order
+ // Check for max padding size, ie MAC Hdr for last RLC PDU = 1
+ /* For Padding BSR:
+ - if the number of padding bits is equal to or larger than the size of the Short BSR plus its subheader but smaller than the size of the Long BSR plus its subheader:
+ - if more than one LCG has data available for transmission in the TTI where the BSR is transmitted: report Truncated BSR of the LCG with the highest priority logical channel with data available for transmission;
+ - else report Short BSR.
+ - else if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR.
+ */
+ if (sdu_length_total) {
+ padding_len =
+ buflen - (bsr_len + phr_len + total_rlc_pdu_header_len -
+ rlc_pdu_header_len_last + sdu_length_total + 1);
+ } else {
+ padding_len = buflen - (bsr_len + phr_len);
+ }
+
+ if ((padding_len) && (bsr_len == 0)) {
+ /* if the number of padding bits is equal to or larger than the size of the Long BSR plus its subheader, report Long BSR */
+ if (padding_len >= (1 + BSR_LONG_SIZE)) {
+ bsr_ce_len = BSR_LONG_SIZE;
+ bsr_header_len = 1;
+ // Trigger BSR Padding
+ UE_mac_inst[module_idP].BSR_reporting_active |=
+ BSR_TRIGGER_PADDING;
+ } else if (padding_len >= (1 + sizeof(BSR_SHORT))) {
+ bsr_ce_len = sizeof(BSR_SHORT);
+ bsr_header_len = 1;
+
+ if (num_lcg_id_with_data > 1) {
+ // REPORT TRUNCATED BSR
+ //Get LCGID of highest priority LCID with data
+ for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
+ if (UE_mac_inst[module_idP].
+ logicalChannelConfig[lcid] != NULL) {
+ lcg_id =
+ UE_mac_inst[module_idP].scheduling_info.
+ LCGID[lcid];
+
+ if ((lcg_id < MAX_NUM_LCGID)
+ && (UE_mac_inst[module_idP].
+ scheduling_info.BSR_bytes[lcg_id])
+ &&
+ (UE_mac_inst[module_idP].logicalChannelConfig
+ [lcid]->ul_SpecificParameters->priority <=
+ highest_priority)) {
+ highest_priority =
+ UE_mac_inst[module_idP].
+ logicalChannelConfig[lcid]->
+ ul_SpecificParameters->priority;
+ lcg_id_bsr_trunc = lcg_id;
+ }
+ }
+ }
+ } else {
+ //Report SHORT BSR, clear bsr_t
+ bsr_t = NULL;
+ }
+
+ // Trigger BSR Padding
+ UE_mac_inst[module_idP].BSR_reporting_active |=
+ BSR_TRIGGER_PADDING;
+ }
+
+ bsr_len = bsr_header_len + bsr_ce_len;
+ }
+
+ //Fill BSR Infos
+ if (bsr_ce_len == 0) {
+ bsr_s = NULL;
+ bsr_l = NULL;
+ bsr_t = NULL;
+ } else if (bsr_ce_len == BSR_LONG_SIZE) {
+ bsr_s = NULL;
+ bsr_t = NULL;
+ bsr_l->Buffer_size0 =
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0];
+ bsr_l->Buffer_size1 =
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1];
+ bsr_l->Buffer_size2 =
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2];
+ bsr_l->Buffer_size3 =
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3];
+ LOG_D(MAC,
+ "[UE %d] Frame %d subframe %d BSR Trig=%d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].BSR_reporting_active,
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0],
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1],
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2],
+ UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]);
+ } else if (bsr_ce_len == sizeof(BSR_SHORT)) {
+ bsr_l = NULL;
+
+ if ((bsr_t != NULL)
+ && (UE_mac_inst[module_idP].BSR_reporting_active &
+ BSR_TRIGGER_PADDING)) {
+ //Truncated BSR
+ bsr_s = NULL;
+ bsr_t->LCGID = lcg_id_bsr_trunc;
+ bsr_t->Buffer_size =
+ UE_mac_inst[module_idP].scheduling_info.
+ BSR[lcg_id_bsr_trunc];
+ LOG_D(MAC,
+ "[UE %d] Frame %d subframe %d BSR Trig=%d report TRUNCATED BSR with level %d for LCGID %d\n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].BSR_reporting_active,
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc);
+ } else {
+ bsr_t = NULL;
+ bsr_s->LCGID = lcg_id_bsr_trunc;
+ bsr_s->Buffer_size =
+ UE_mac_inst[module_idP].scheduling_info.
+ BSR[lcg_id_bsr_trunc];
+ LOG_D(MAC,
+ "[UE %d] Frame %d subframe %d BSR Trig=%d report SHORT BSR with level %d for LCGID %d\n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].BSR_reporting_active,
+ UE_mac_inst[module_idP].
+ scheduling_info.BSR[lcg_id_bsr_trunc], lcg_id_bsr_trunc);
+ }
+ }
+
+ // 1-bit padding or 2-bit padding special padding subheader
+ // Check for max padding size, ie MAC Hdr for last RLC PDU = 1
+ if (sdu_length_total) {
+ padding_len =
+ buflen - (bsr_len + phr_len + total_rlc_pdu_header_len -
+ rlc_pdu_header_len_last + sdu_length_total + 1);
+ } else {
+ padding_len = buflen - (bsr_len + phr_len);
+ }
+
+ if (padding_len <= 2) {
+ short_padding = padding_len;
+ // only add padding header
+ post_padding = 0;
+
+ //update total MAC Hdr size for RLC data
+ if (sdu_length_total) {
+ total_rlc_pdu_header_len =
+ total_rlc_pdu_header_len - rlc_pdu_header_len_last + 1;
+ rlc_pdu_header_len_last = 1;
+ }
+ } else if (sdu_length_total) {
+ post_padding =
+ buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
+ sdu_length_total + 1);
+
+ // If by adding MAC Hdr for last RLC PDU the padding is 0 then set MAC Hdr for last RLC PDU = 1 and compute 1 or 2 byte padding
+ if (post_padding == 0) {
+ total_rlc_pdu_header_len -= rlc_pdu_header_len_last;
+ padding_len =
+ buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
+ sdu_length_total + 1);
+ short_padding = padding_len;
+ total_rlc_pdu_header_len++;
+ }
+ } else {
+ if (padding_len == buflen) { // nona mac pdu
+ *access_mode = CANCELED_ACCESS;
+ }
+
+ short_padding = 0;
+ post_padding =
+ buflen - (bsr_len + phr_len + total_rlc_pdu_header_len +
+ sdu_length_total + 1);
+ }
+
+ // Generate header
+ // if (num_sdus>0) {
+ payload_offset = generate_ulsch_header(ulsch_buffer, // mac header
+ num_sdus, // num sdus
+ short_padding, // short pading
+ sdu_lengths, // sdu length
+ sdu_lcids, // sdu lcid
+ phr_p, // power headroom
+ NULL, // crnti
+ bsr_t, // truncated bsr
+ bsr_s, // short bsr
+ bsr_l, post_padding); // long_bsr
+ LOG_D(MAC,
+ "[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, total_rlc_pdu_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n",
+ module_idP, buflen, sdu_length_total, num_sdus, sdu_lengths[0],
+ sdu_lcids[0], payload_offset, total_rlc_pdu_header_len,
+ short_padding, post_padding, bsr_len, phr_len,
+ buflen - sdu_length_total - payload_offset);
+
+ // cycle through SDUs and place in ulsch_buffer
+ if (sdu_length_total) {
+ memcpy(&ulsch_buffer[payload_offset], ulsch_buff,
+ sdu_length_total);
+ }
+
+ // fill remainder of DLSCH with random data
+ if (post_padding) {
+ for (j = 0; j < (buflen - sdu_length_total - payload_offset); j++) {
+ ulsch_buffer[payload_offset + sdu_length_total + j] =
+ (char) (taus() & 0xff);
+ }
+ }
+
+ LOG_D(MAC,
+ "[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n",
+ module_idP);
+ UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
+ UE_mac_inst[module_idP].scheduling_info.SR_COUNTER = 0;
+
+ /* Actions when a BSR is sent */
+ if (bsr_ce_len) {
+ LOG_D(MAC,
+ "[UE %d] MAC BSR Sent !! bsr (ce%d,hdr%d) buff_len %d\n",
+ module_idP, bsr_ce_len, bsr_header_len, buflen);
+ // Reset ReTx BSR Timer
+ UE_mac_inst[module_idP].scheduling_info.retxBSR_SF =
+ get_sf_retxBSRTimer(UE_mac_inst[module_idP].
+ scheduling_info.retxBSR_Timer);
+ LOG_D(MAC, "[UE %d] MAC ReTx BSR Timer Reset =%d\n", module_idP,
+ UE_mac_inst[module_idP].scheduling_info.retxBSR_SF);
+
+ // Reset Periodic Timer except when BSR is truncated
+ if ((bsr_t == NULL)
+ && (UE_mac_inst[module_idP].scheduling_info.
+ periodicBSR_Timer != LTE_PeriodicBSR_Timer_r12_infinity)) {
+ UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF =
+ get_sf_periodicBSRTimer(UE_mac_inst
+ [module_idP].scheduling_info.
+ periodicBSR_Timer);
+ LOG_D(MAC, "[UE %d] MAC Periodic BSR Timer Reset =%d\n",
+ module_idP,
+ UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF);
+ }
+
+ // Reset BSR Trigger flags
+ UE_mac_inst[module_idP].BSR_reporting_active = BSR_TRIGGER_NONE;
+ }
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu);
+ stop_meas(&UE_mac_inst[module_idP].tx_ulsch_sdu);
#endif
- if (opt_enabled) {
- trace_pdu(DIRECTION_UPLINK, ulsch_buffer, buflen, module_idP, WS_C_RNTI,
- UE_mac_inst[module_idP].crnti,
- UE_mac_inst[module_idP].txFrame,
- UE_mac_inst[module_idP].txSubframe, 0, 0);
- LOG_D(OPT,
- "[UE %d][ULSCH] Frame %d subframe %d trace pdu for rnti %x with size %d\n",
- module_idP, frameP, subframe, UE_mac_inst[module_idP].crnti,
- buflen);
- }
+ if (opt_enabled) {
+ trace_pdu(DIRECTION_UPLINK, ulsch_buffer, buflen, module_idP, WS_C_RNTI,
+ UE_mac_inst[module_idP].crnti,
+ UE_mac_inst[module_idP].txFrame,
+ UE_mac_inst[module_idP].txSubframe, 0, 0);
+ LOG_D(OPT,
+ "[UE %d][ULSCH] Frame %d subframe %d trace pdu for rnti %x with size %d\n",
+ module_idP, frameP, subframe, UE_mac_inst[module_idP].crnti,
+ buflen);
+ }
}
@@ -2500,515 +2447,498 @@ ue_get_sdu(module_id_t module_idP, int CC_id, frame_t frameP,
UE_L2_STATE_t
ue_scheduler(const module_id_t module_idP,
- const frame_t rxFrameP,
- const sub_frame_t rxSubframeP,
- const frame_t txFrameP,
- const sub_frame_t txSubframeP,
- const lte_subframe_t directionP,
- const uint8_t eNB_indexP, const int CC_id)
+ const frame_t rxFrameP,
+ const sub_frame_t rxSubframeP,
+ const frame_t txFrameP,
+ const sub_frame_t txSubframeP,
+ const lte_subframe_t directionP,
+ const uint8_t eNB_indexP, const int CC_id)
//------------------------------------------------------------------------------
{
- int lcid; // lcid index
- int TTI = 1;
- int bucketsizeduration = -1;
- int bucketsizeduration_max = -1;
- // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4
- // int8_t lcg_id;
- struct LTE_RACH_ConfigCommon *rach_ConfigCommon =
- (struct LTE_RACH_ConfigCommon *) NULL;
- protocol_ctxt_t ctxt;
-
+ int lcid; // lcid index
+ int TTI = 1;
+ int bucketsizeduration = -1;
+ int bucketsizeduration_max = -1;
+ // mac_rlc_status_resp_t rlc_status[MAX_NUM_LCGID]; // 4
+ // int8_t lcg_id;
+ struct LTE_RACH_ConfigCommon *rach_ConfigCommon =
+ (struct LTE_RACH_ConfigCommon *) NULL;
+ protocol_ctxt_t ctxt;
#if defined(ENABLE_ITTI)
- MessageDef *msg_p;
- int result;
+ MessageDef *msg_p;
+ int result;
#endif
#if UE_TIMING_TRACE
- start_meas(&UE_mac_inst[module_idP].ue_scheduler);
+ start_meas(&UE_mac_inst[module_idP].ue_scheduler);
#endif
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN);
-
- PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO,
- UE_mac_inst[module_idP].crnti, txFrameP,
- txSubframeP, eNB_indexP);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_IN);
+ PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_NO,
+ UE_mac_inst[module_idP].crnti, txFrameP,
+ txSubframeP, eNB_indexP);
#if defined(ENABLE_ITTI)
- if(module_idP == 0){
- do {
- // Checks if a message has been sent to MAC sub-task
- itti_poll_msg(TASK_MAC_UE, &msg_p);
- if (msg_p != NULL) {
+ if(module_idP == 0) {
+ do {
+ // Checks if a message has been sent to MAC sub-task
+ itti_poll_msg(TASK_MAC_UE, &msg_p);
- switch (ITTI_MSG_ID(msg_p)) {
- case RRC_MAC_CCCH_DATA_REQ:
- LOG_I(MAC,
- "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
- ITTI_MSG_NAME(msg_p), ITTI_MSG_ORIGIN_NAME(msg_p), ITTI_MSG_INSTANCE(msg_p),
- RRC_MAC_CCCH_DATA_REQ(msg_p).frame,
- RRC_MAC_CCCH_DATA_REQ(msg_p).enb_index);
+ if (msg_p != NULL) {
+ switch (ITTI_MSG_ID(msg_p)) {
+ case RRC_MAC_CCCH_DATA_REQ:
+ LOG_I(MAC,
+ "Received %s from %s: instance %d, frameP %d, eNB_index %d\n",
+ ITTI_MSG_NAME(msg_p), ITTI_MSG_ORIGIN_NAME(msg_p), ITTI_MSG_INSTANCE(msg_p),
+ RRC_MAC_CCCH_DATA_REQ(msg_p).frame,
+ RRC_MAC_CCCH_DATA_REQ(msg_p).enb_index);
+ // TODO process CCCH data req.
+ break;
- // TODO process CCCH data req.
- break;
+ default:
+ LOG_E(MAC, "Received unexpected message %s\n", ITTI_MSG_NAME(msg_p));
+ break;
+ }
-
- default:
- LOG_E(MAC, "Received unexpected message %s\n", ITTI_MSG_NAME(msg_p));
- break;
- }
-
- result = itti_free(ITTI_MSG_ORIGIN_ID(msg_p), msg_p);
- AssertFatal(result == EXIT_SUCCESS,
- "Failed to free memory (%d)!\n", result);
- }
+ 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);
- }
+ } while (msg_p != NULL);
+ }
+
#endif
- //Mac_rlc_xface->frameP=frameP;
- //Rrc_xface->Frame_index=Mac_rlc_xface->frameP;
- //if (subframe%5 == 0)
- //LG#ifdef EXMIMO
+ //Mac_rlc_xface->frameP=frameP;
+ //Rrc_xface->Frame_index=Mac_rlc_xface->frameP;
+ //if (subframe%5 == 0)
+ //LG#ifdef EXMIMO
- // data to/from NETLINK is treated in pdcp_run.
- // one socket is used in multiple UE's L2 FAPI simulator and
- // only first UE need to do this.
- if (UE_NAS_USE_TUN) {
+ // data to/from NETLINK is treated in pdcp_run.
+ // one socket is used in multiple UE's L2 FAPI simulator and
+ // only first UE need to do this.
+ if (UE_NAS_USE_TUN) {
+ pdcp_run(&ctxt);
+ } else {
+ if(module_idP == 0) {
pdcp_run(&ctxt);
- } else {
- if(module_idP == 0){
- pdcp_run(&ctxt);
- }
}
- //#endif
- UE_mac_inst[module_idP].txFrame = txFrameP;
- UE_mac_inst[module_idP].txSubframe = txSubframeP;
- UE_mac_inst[module_idP].rxFrame = rxFrameP;
- UE_mac_inst[module_idP].rxSubframe = rxSubframeP;
+ }
+ //#endif
+ UE_mac_inst[module_idP].txFrame = txFrameP;
+ UE_mac_inst[module_idP].txSubframe = txSubframeP;
+ UE_mac_inst[module_idP].rxFrame = rxFrameP;
+ UE_mac_inst[module_idP].rxSubframe = rxSubframeP;
#ifdef CELLULAR
- rrc_rx_tx_ue(module_idP, txFrameP, 0, eNB_indexP);
+ rrc_rx_tx_ue(module_idP, txFrameP, 0, eNB_indexP);
#else
- switch (rrc_rx_tx_ue(&ctxt, eNB_indexP, CC_id)) {
+ switch (rrc_rx_tx_ue(&ctxt, eNB_indexP, CC_id)) {
case RRC_OK:
- break;
+ break;
case RRC_ConnSetup_failed:
- LOG_E(MAC, "RRCConnectionSetup failed, returning to IDLE state\n");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
+ LOG_E(MAC, "RRCConnectionSetup failed, returning to IDLE state\n");
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
+ stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
#endif
- return (CONNECTION_LOST);
- break;
+ return (CONNECTION_LOST);
+ break;
case RRC_PHY_RESYNCH:
- LOG_E(MAC, "RRC Loss of synch, returning PHY_RESYNCH\n");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
+ LOG_E(MAC, "RRC Loss of synch, returning PHY_RESYNCH\n");
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
+ stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
#endif
- return (PHY_RESYNCH);
+ return (PHY_RESYNCH);
case RRC_Handover_failed:
- LOG_I(MAC, "Handover failure for UE %d eNB_index %d\n", module_idP,
- eNB_indexP);
- //Invalid...need to add another MAC UE state for re-connection procedure
- phy_config_afterHO_ue(module_idP, 0, eNB_indexP,
- (LTE_MobilityControlInfo_t *) NULL, 1);
- //return(3);
- break;
+ LOG_I(MAC, "Handover failure for UE %d eNB_index %d\n", module_idP,
+ eNB_indexP);
+ //Invalid...need to add another MAC UE state for re-connection procedure
+ phy_config_afterHO_ue(module_idP, 0, eNB_indexP,
+ (LTE_MobilityControlInfo_t *) NULL, 1);
+ //return(3);
+ break;
case RRC_HO_STARTED:
- LOG_I(MAC,
- "RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
+ LOG_I(MAC,
+ "RRC handover, Instruct PHY to start the contention-free PRACH and synchronization\n");
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
+ stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
#endif
- return (PHY_HO_PRACH);
+ return (PHY_HO_PRACH);
default:
- break;
- }
+ break;
+ }
#endif
- // Check Contention resolution timer (put in a function later)
- if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) {
-
- if (UE_mac_inst[module_idP].radioResourceConfigCommon) {
- rach_ConfigCommon =
- &UE_mac_inst[module_idP].
- radioResourceConfigCommon->rach_ConfigCommon;
- } else {
- LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n");
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER,
- VCD_FUNCTION_OUT);
-
- stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
- AssertFatal(1 == 0, "");
-
+ // Check Contention resolution timer (put in a function later)
+ if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) {
+ if (UE_mac_inst[module_idP].radioResourceConfigCommon) {
+ rach_ConfigCommon =
+ &UE_mac_inst[module_idP].
+ radioResourceConfigCommon->rach_ConfigCommon;
+ } else {
+ LOG_E(MAC, "FATAL: radioResourceConfigCommon is NULL!!!\n");
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER,
+ VCD_FUNCTION_OUT);
+ stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
+ AssertFatal(1 == 0, "");
#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
+ stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
#endif
-
- //return(RRC_OK);
- }
-
- LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n",
- txFrameP,
- UE_mac_inst[module_idP].RA_contention_resolution_cnt,
- ((1 +
- rach_ConfigCommon->
- ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3));
-
- UE_mac_inst[module_idP].RA_contention_resolution_cnt++;
-
- if (UE_mac_inst[module_idP].RA_contention_resolution_cnt ==
- ((1 +
- rach_ConfigCommon->
- ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)) {
- UE_mac_inst[module_idP].RA_active = 0;
- UE_mac_inst[module_idP].RA_contention_resolution_timer_active =
- 0;
- // Signal PHY to quit RA procedure
- LOG_E(MAC,
- "Module id %u Contention resolution timer expired, RA failed\n",
- module_idP);
- if(nfapi_mode == 3) { // phy_stub mode
- // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to
- // PRACH state.
- LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n");
- UE_mac_inst[module_idP].UE_mode[eNB_indexP] = PRACH;
- //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0;
- }
- else{
- ra_failed(module_idP, CC_id, eNB_indexP);
- }
- //ra_failed(module_idP, 0, eNB_indexP);
- }
- }
- // Get RLC status info and update Bj for all lcids that are active
- for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
- if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) {
- // meausre the Bj
- if ((directionP == SF_UL)
- && (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) {
- if (UE_mac_inst[module_idP].
- logicalChannelConfig[lcid]->ul_SpecificParameters) {
- bucketsizeduration =
- UE_mac_inst[module_idP].logicalChannelConfig
- [lcid]->ul_SpecificParameters->prioritisedBitRate *
- TTI;
- bucketsizeduration_max =
- get_ms_bucketsizeduration(UE_mac_inst
- [module_idP].logicalChannelConfig
- [lcid]->ul_SpecificParameters->bucketSizeDuration);
- } else {
- LOG_E(MAC,
- "[UE %d] lcid %d, NULL ul_SpecificParameters\n",
- module_idP, lcid);
- AssertFatal(1 == 0, "");
- }
-
- if (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >
- bucketsizeduration_max) {
- UE_mac_inst[module_idP].scheduling_info.Bj[lcid] =
- bucketsizeduration_max;
- } else {
- UE_mac_inst[module_idP].scheduling_info.Bj[lcid] =
- bucketsizeduration;
- }
- }
-
-
- /*
- if (lcid == DCCH) {
- LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n",
- module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]],
- // UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]);
- }
- */
- }
+ //return(RRC_OK);
}
- // Call BSR procedure as described in Section 5.4.5 in 36.321
+ LOG_I(MAC, "Frame %d: Contention resolution timer %d/%ld\n",
+ txFrameP,
+ UE_mac_inst[module_idP].RA_contention_resolution_cnt,
+ ((1 +
+ rach_ConfigCommon->
+ ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3));
+ UE_mac_inst[module_idP].RA_contention_resolution_cnt++;
- // First check ReTxBSR Timer because it is always configured
- // Decrement ReTxBSR Timer if it is running and not null
- if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF !=
- MAC_UE_BSR_TIMER_NOT_RUNNING)
- && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)) {
- UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--;
+ if (UE_mac_inst[module_idP].RA_contention_resolution_cnt ==
+ ((1 +
+ rach_ConfigCommon->
+ ra_SupervisionInfo.mac_ContentionResolutionTimer) << 3)) {
+ UE_mac_inst[module_idP].RA_active = 0;
+ UE_mac_inst[module_idP].RA_contention_resolution_timer_active =
+ 0;
+ // Signal PHY to quit RA procedure
+ LOG_E(MAC,
+ "Module id %u Contention resolution timer expired, RA failed\n",
+ module_idP);
+
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) { // phy_stub mode
+ // Modification for phy_stub mode operation here. We only need to make sure that the ue_mode is back to
+ // PRACH state.
+ LOG_I(MAC, "nfapi_mode3: Setting UE_mode to PRACH 2 \n");
+ UE_mac_inst[module_idP].UE_mode[eNB_indexP] = PRACH;
+ //ra_failed(module_idP,CC_id,eNB_index);UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0;
+ } else {
+ ra_failed(module_idP, CC_id, eNB_indexP);
+ }
+
+ //ra_failed(module_idP, 0, eNB_indexP);
}
- // Decrement Periodic Timer if it is running and not null
- if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF !=
- MAC_UE_BSR_TIMER_NOT_RUNNING)
- && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)) {
- UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--;
- }
- //Check whether Regular BSR is triggered
- if (update_bsr(module_idP, txFrameP, txSubframeP, eNB_indexP) == TRUE) {
- // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures
- // outlined in Sections 5.4.4 an 5.4.5 of 36.321
- UE_mac_inst[module_idP].scheduling_info.SR_pending = 1;
- // Regular BSR trigger
- UE_mac_inst[module_idP].BSR_reporting_active |=
- BSR_TRIGGER_REGULAR;
- LOG_D(MAC,
- "[UE %d][BSR] Regular BSR Triggered Frame %d subframe %d SR for PUSCH is pending\n",
- module_idP, txFrameP, txSubframeP);
- }
- // UE has no valid phy config dedicated || no valid/released SR
- if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) {
- // cancel all pending SRs
- UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
- UE_mac_inst[module_idP].ul_active = 0;
- LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
-#if UE_TIMING_TRACE
- stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
-#endif
- return (CONNECTION_OK);
+ }
+
+ // Get RLC status info and update Bj for all lcids that are active
+ for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
+ if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) {
+ // meausre the Bj
+ if ((directionP == SF_UL)
+ && (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)) {
+ if (UE_mac_inst[module_idP].
+ logicalChannelConfig[lcid]->ul_SpecificParameters) {
+ bucketsizeduration =
+ UE_mac_inst[module_idP].logicalChannelConfig
+ [lcid]->ul_SpecificParameters->prioritisedBitRate *
+ TTI;
+ bucketsizeduration_max =
+ get_ms_bucketsizeduration(UE_mac_inst
+ [module_idP].logicalChannelConfig
+ [lcid]->ul_SpecificParameters->bucketSizeDuration);
+ } else {
+ LOG_E(MAC,
+ "[UE %d] lcid %d, NULL ul_SpecificParameters\n",
+ module_idP, lcid);
+ AssertFatal(1 == 0, "");
+ }
+
+ if (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >
+ bucketsizeduration_max) {
+ UE_mac_inst[module_idP].scheduling_info.Bj[lcid] =
+ bucketsizeduration_max;
+ } else {
+ UE_mac_inst[module_idP].scheduling_info.Bj[lcid] =
+ bucketsizeduration;
+ }
+ }
+
+ /*
+ if (lcid == DCCH) {
+ LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d Pending data for SRB1=%d for LCGID %d \n",
+ module_idP, txFrameP,txSubframeP,UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]],
+ // UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]);
+ }
+ */
}
+ }
- if ((UE_mac_inst[module_idP].
- physicalConfigDedicated->schedulingRequestConfig == NULL)
- || (UE_mac_inst[module_idP].
- physicalConfigDedicated->schedulingRequestConfig->present ==
- LTE_SchedulingRequestConfig_PR_release)) {
+ // Call BSR procedure as described in Section 5.4.5 in 36.321
- // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5
+ // First check ReTxBSR Timer because it is always configured
+ // Decrement ReTxBSR Timer if it is running and not null
+ if ((UE_mac_inst[module_idP].scheduling_info.retxBSR_SF !=
+ MAC_UE_BSR_TIMER_NOT_RUNNING)
+ && (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF != 0)) {
+ UE_mac_inst[module_idP].scheduling_info.retxBSR_SF--;
+ }
- // cancel all pending SRs
- UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
- UE_mac_inst[module_idP].ul_active = 0;
- LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP);
- }
- // Put this in a function
- // Call PHR procedure as described in Section 5.4.6 in 36.321
- if (UE_mac_inst[module_idP].PHR_state == LTE_MAC_MainConfig__phr_Config_PR_setup) { // normal operation
+ // Decrement Periodic Timer if it is running and not null
+ if ((UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF !=
+ MAC_UE_BSR_TIMER_NOT_RUNNING)
+ && (UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF != 0)) {
+ UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF--;
+ }
- if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers
- UE_mac_inst[module_idP].PHR_reporting_active = 1;
- UE_mac_inst[module_idP].PHR_reconfigured = 0;
- } else {
- //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active);
- if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <=
- 0)
- &&
- ((get_PL(module_idP, 0, eNB_indexP) <
- UE_mac_inst[module_idP].scheduling_info.
- PathlossChange_db)
- || (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] >
- UE_mac_inst[module_idP].
- scheduling_info.PathlossChange_db)))
- // trigger PHR and reset the timer later when the PHR report is sent
- {
- UE_mac_inst[module_idP].PHR_reporting_active = 1;
- } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) {
- UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--;
- }
+ //Check whether Regular BSR is triggered
+ if (update_bsr(module_idP, txFrameP, txSubframeP, eNB_indexP) == TRUE) {
+ // call SR procedure to generate pending SR and BSR for next PUCCH/PUSCH TxOp. This should implement the procedures
+ // outlined in Sections 5.4.4 an 5.4.5 of 36.321
+ UE_mac_inst[module_idP].scheduling_info.SR_pending = 1;
+ // Regular BSR trigger
+ UE_mac_inst[module_idP].BSR_reporting_active |=
+ BSR_TRIGGER_REGULAR;
+ LOG_D(MAC,
+ "[UE %d][BSR] Regular BSR Triggered Frame %d subframe %d SR for PUSCH is pending\n",
+ module_idP, txFrameP, txSubframeP);
+ }
- if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <=
- 0)
- // trigger PHR and reset the timer later when the PHR report is sent
- {
- UE_mac_inst[module_idP].PHR_reporting_active = 1;
- } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) {
- UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--;
- }
- }
- } else { // release / nothing
- UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR
- }
-
- //If the UE has UL resources allocated for new transmission for this TTI here:
+ // UE has no valid phy config dedicated || no valid/released SR
+ if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) {
+ // cancel all pending SRs
+ UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
+ UE_mac_inst[module_idP].ul_active = 0;
+ LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
- (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
#if UE_TIMING_TRACE
stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
#endif
return (CONNECTION_OK);
+ }
+
+ if ((UE_mac_inst[module_idP].
+ physicalConfigDedicated->schedulingRequestConfig == NULL)
+ || (UE_mac_inst[module_idP].
+ physicalConfigDedicated->schedulingRequestConfig->present ==
+ LTE_SchedulingRequestConfig_PR_release)) {
+ // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5
+ // cancel all pending SRs
+ UE_mac_inst[module_idP].scheduling_info.SR_pending = 0;
+ UE_mac_inst[module_idP].ul_active = 0;
+ LOG_T(MAC, "[UE %d] Release all SRs \n", module_idP);
+ }
+
+ // Put this in a function
+ // Call PHR procedure as described in Section 5.4.6 in 36.321
+ if (UE_mac_inst[module_idP].PHR_state == LTE_MAC_MainConfig__phr_Config_PR_setup) { // normal operation
+ if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers
+ UE_mac_inst[module_idP].PHR_reporting_active = 1;
+ UE_mac_inst[module_idP].PHR_reconfigured = 0;
+ } else {
+ //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active);
+ if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <=
+ 0)
+ &&
+ ((get_PL(module_idP, 0, eNB_indexP) <
+ UE_mac_inst[module_idP].scheduling_info.
+ PathlossChange_db)
+ || (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] >
+ UE_mac_inst[module_idP].
+ scheduling_info.PathlossChange_db)))
+ // trigger PHR and reset the timer later when the PHR report is sent
+ {
+ UE_mac_inst[module_idP].PHR_reporting_active = 1;
+ } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) {
+ UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--;
+ }
+
+ if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <=
+ 0)
+ // trigger PHR and reset the timer later when the PHR report is sent
+ {
+ UE_mac_inst[module_idP].PHR_reporting_active = 1;
+ } else if (UE_mac_inst[module_idP].PHR_reporting_active == 0) {
+ UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--;
+ }
+ }
+ } else { // release / nothing
+ UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR
+ }
+
+ //If the UE has UL resources allocated for new transmission for this TTI here:
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME
+ (VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT);
+#if UE_TIMING_TRACE
+ stop_meas(&UE_mac_inst[module_idP].ue_scheduler);
+#endif
+ return (CONNECTION_OK);
}
// to be improved
#ifdef CBA
extern int cba_backoff;
-double uniform_rngen(int min, int max)
-{
- double random = (double) taus() / ((double) 0xffffffff);
- return (max - min) * random + min;
+double uniform_rngen(int min, int max) {
+ double random = (double) taus() / ((double) 0xffffffff);
+ return (max - min) * random + min;
}
int
cba_access(module_id_t module_idP, frame_t frameP,
- sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen)
-{
+ sub_frame_t subframe, uint8_t eNB_index, uint16_t buflen) {
+ mac_rlc_status_resp_t rlc_status;
+ int header_offset = 4;
+ int rv = 0;
- mac_rlc_status_resp_t rlc_status;
- int header_offset = 4;
- int rv = 0;
+ /*
+ if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) )
+ // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
+ && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff
+ // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe,
+ // UE_mac_inst[module_idP].cba_last_access[0] );
- /*
- if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) )
- // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
- && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff
- // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frameP, subframe,
- // UE_mac_inst[module_idP].cba_last_access[0] );
+ UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40));
+ LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
- UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,40));
- LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+ rv=1;
+ } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) )
+ // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
+ && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){
- rv=1;
- } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) )
- // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
- && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){
+ UE_mac_inst[module_idP].cba_last_access[0]-=1;
+ LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
- UE_mac_inst[module_idP].cba_last_access[0]-=1;
- LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+ } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) &&
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) &&
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) )
+ && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){
+ UE_mac_inst[module_idP].cba_last_access[0]-=1;
+ } */
- } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) &&
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) &&
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) )
- && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){
- UE_mac_inst[module_idP].cba_last_access[0]-=1;
- } */
+ if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] > 0)
+ && (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] < 64)) {
+ return 0;
+ }
- if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] > 0)
- && (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0] < 64)) {
- return 0;
+ if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0) &&
+ (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0) &&
+ (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0)) {
+ return 0;
+ }
+
+ if (cba_backoff == 0) { // apply probablisitc method
+ UE_mac_inst[module_idP].cba_last_access[0] = uniform_rngen(0, 1);
+
+ if (uniform_rngen(0, 1) > 0.6) {
+ LOG_I(MAC,
+ "[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n",
+ module_idP, frameP, subframe, cba_backoff,
+ UE_mac_inst[module_idP].ul_active);
+ rv = 1;
}
+ } else {
+ if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) {
+ UE_mac_inst[module_idP].cba_last_access[0] =
+ round(uniform_rngen(1, cba_backoff));
+ LOG_I(MAC,
+ "[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,
+ UE_mac_inst[module_idP].ul_active);
+ rv = 1;
+ /*
+ rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
+ DTCH,
+ 0);
- if ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] <= 0) &&
- (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] <= 0) &&
- (UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] <= 0)) {
- return 0;
- }
+ if ((
+ // (rlc_status.pdus_in_buffer > 0 ) &&
+ // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive
+ (rlc_status.head_sdu_is_segmented == 0 ) &&
+ ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen )
+ )){
+ rv = 1;
- if (cba_backoff == 0) { // apply probablisitc method
- UE_mac_inst[module_idP].cba_last_access[0] = uniform_rngen(0, 1);
-
- if (uniform_rngen(0, 1) > 0.6) {
- LOG_I(MAC,
- "[UE %d] Frame %d Subframe %d: CBA probability-based backoff (%d), UL active state %d \n",
- module_idP, frameP, subframe, cba_backoff,
- UE_mac_inst[module_idP].ul_active);
-
- rv = 1;
- }
+ UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30));
+ LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+ */
} else {
-
- if (UE_mac_inst[module_idP].cba_last_access[0] <= 0) {
- UE_mac_inst[module_idP].cba_last_access[0] =
- round(uniform_rngen(1, cba_backoff));
-
- LOG_I(MAC,
- "[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,
- UE_mac_inst[module_idP].ul_active);
-
- rv = 1;
- /*
- rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
- DTCH,
- 0);
-
- if ((
- // (rlc_status.pdus_in_buffer > 0 ) &&
- // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive
- (rlc_status.head_sdu_is_segmented == 0 ) &&
- ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen )
- )){
- rv = 1;
-
- UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30));
- LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
- */
- } else {
- UE_mac_inst[module_idP].cba_last_access[0] -= 1;
- LOG_D(MAC,
- "[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0],
- UE_mac_inst[module_idP].ul_active);
- }
+ UE_mac_inst[module_idP].cba_last_access[0] -= 1;
+ LOG_D(MAC,
+ "[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0],
+ UE_mac_inst[module_idP].ul_active);
}
+ }
- return rv;
- /*
- if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) )
- // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
- && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) {
+ return rv;
+ /*
+ if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) )
+ // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
+ && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) {
- UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff));
+ UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,cba_backoff));
- LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active);
+ LOG_I(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d/%d UL active state %d \n", module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], cba_backoff,UE_mac_inst[module_idP].ul_active);
- rv = 1;
+ rv = 1;
- rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
- DTCH,
- 0);
+ rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,frameP,ENB_FLAG_NO,MBMS_FLAG_NO, // eNB_index
+ DTCH,
+ 0);
- if ((
- // (rlc_status.pdus_in_buffer > 0 ) &&
- // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive
- (rlc_status.head_sdu_is_segmented == 0 ) &&
- ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen )
- )){
- rv = 1;
+ if ((
+ // (rlc_status.pdus_in_buffer > 0 ) &&
+ // (UE_mac_inst[module_idP].ul_active == 0) && // check if the ul is acrtive
+ (rlc_status.head_sdu_is_segmented == 0 ) &&
+ ((rlc_status.head_sdu_remaining_size_to_send + header_offset ) <= buflen )
+ )){
+ rv = 1;
- UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30));
- LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
- } else
- UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5));
+ UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,30));
+ LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+ } else
+ UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,5));
- } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) ||
- ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) )
- // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
- && (UE_mac_inst[module_idP].cba_last_access[0]> 0) )
- {
-
- UE_mac_inst[module_idP].cba_last_access[0]-=1;
- LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n",
- module_idP, frameP, subframe,
- UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
- }
- }
- */
+ } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) ||
+ ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) )
+ // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive
+ && (UE_mac_inst[module_idP].cba_last_access[0]> 0) )
+ {
+ UE_mac_inst[module_idP].cba_last_access[0]-=1;
+ LOG_D(MAC,"[UE %d] Frame %d Subframe %d: wait for backoff to expire (%d) CBA UL active state %d \n",
+ module_idP, frameP, subframe,
+ UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active);
+ }
+ }
+ */
}
#endif
boolean_t
update_bsr(module_id_t module_idP, frame_t frameP,
- sub_frame_t subframeP, eNB_index_t eNB_index)
-{
-
+ sub_frame_t subframeP, eNB_index_t eNB_index) {
mac_rlc_status_resp_t rlc_status;
boolean_t bsr_regular_triggered = FALSE;
uint8_t lcid;
@@ -3022,537 +2952,493 @@ update_bsr(module_id_t module_idP, frame_t frameP,
uint8_t pos_next = 0;
uint8_t highest_priority = 16;
uint8_t array_index = 0;
-
// Reset All BSR Infos
lcid_bytes_in_buffer[0] = 0;
- for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++)
- {
- // Reset transmission status
- lcid_bytes_in_buffer[lcid] = 0;
- UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY;
+
+ for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) {
+ // Reset transmission status
+ lcid_bytes_in_buffer[lcid] = 0;
+ UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY;
}
- for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++)
- {
- // Reset Buffer Info
- UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]=0;
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid]=0;
+ for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++) {
+ // Reset Buffer Info
+ UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]=0;
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid]=0;
}
//Get Buffer Occupancy and fill lcid_reordered_array
- for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++)
- {
- if (UE_mac_inst[module_idP].logicalChannelConfig[lcid])
- {
- lcgid = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid];
+ for (lcid=DCCH; lcid < MAX_NUM_LCID; lcid++) {
+ if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]) {
+ lcgid = UE_mac_inst[module_idP].scheduling_info.LCGID[lcid];
- // Store already available data to transmit per Group
- if (lcgid < MAX_NUM_LCGID)
- {
- lcgid_buffer_remain[lcgid] += UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid];
- }
+ // Store already available data to transmit per Group
+ if (lcgid < MAX_NUM_LCGID) {
+ lcgid_buffer_remain[lcgid] += UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid];
+ }
- rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,eNB_index,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
- lcid,
- 0xFFFF //TBS is not used in RLC at this step, set a special value for debug
+ rlc_status = mac_rlc_status_ind(module_idP, UE_mac_inst[module_idP].crnti,eNB_index,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
+ lcid,
+ 0xFFFF //TBS is not used in RLC at this step, set a special value for debug
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,0, 0
+ ,0, 0
#endif
- );
+ );
+ lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer;
- lcid_bytes_in_buffer[lcid] = rlc_status.bytes_in_buffer;
+ if (rlc_status.bytes_in_buffer > 0) {
+ LOG_D(MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n",
+ module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,subframeP);
+ UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY;
- if (rlc_status.bytes_in_buffer > 0)
- {
- LOG_D(MAC,"[UE %d] PDCCH Tick : LCID%d LCGID%d has data to transmit =%d bytes at frame %d subframe %d\n",
- module_idP, lcid,lcgid,rlc_status.bytes_in_buffer,frameP,subframeP);
+ //Update BSR_bytes and position in lcid_reordered_array only if Group is defined
+ if (lcgid < MAX_NUM_LCGID) {
+ num_lcid_with_data ++;
+ // sum lcid buffer which has same lcgid
+ UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] += rlc_status.bytes_in_buffer;
+ //Fill in the array
+ array_index = 0;
- UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY;
- //Update BSR_bytes and position in lcid_reordered_array only if Group is defined
- if (lcgid < MAX_NUM_LCGID)
- {
- num_lcid_with_data ++;
- // sum lcid buffer which has same lcgid
- UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] += rlc_status.bytes_in_buffer;
+ do {
+ if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority) {
+ //Insert if priority is higher or equal (lower or equal in value)
+ for (pos_next=num_lcid_with_data-1; pos_next > array_index; pos_next--) {
+ lcid_reordered_array[pos_next] = lcid_reordered_array[pos_next - 1];
+ }
- //Fill in the array
- array_index = 0;
- do
- {
- if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->priority <= highest_priority)
- {
- //Insert if priority is higher or equal (lower or equal in value)
- for (pos_next=num_lcid_with_data-1; pos_next > array_index; pos_next--)
- {
- lcid_reordered_array[pos_next] = lcid_reordered_array[pos_next - 1];
+ lcid_reordered_array[array_index] = lcid;
+ break;
+ }
- }
- lcid_reordered_array[array_index] = lcid;
- break;
+ array_index ++;
+ } while ((array_index < num_lcid_with_data) && (array_index < MAX_NUM_LCID));
+ }
+ }
+ }
+ }
- }
- array_index ++;
- }
- while ((array_index < num_lcid_with_data) && (array_index < MAX_NUM_LCID));
- }
- }
- }
+ // Check whether a regular BSR can be triggered according to the first cases in 36.321
+ if (num_lcid_with_data) {
+ LOG_D(MAC,
+ "[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n",
+ module_idP, frameP, subframeP, num_lcid_with_data,
+ lcid_reordered_array[0], lcid_reordered_array[1],
+ lcid_reordered_array[2]);
+ for (array_index = 0; array_index < num_lcid_with_data;
+ array_index++) {
+ lcid = lcid_reordered_array[array_index];
+
+ /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity
+ either the data belongs to a logical channel with higher priority than the priorities of the logical channels
+ which belong to any LCG and for which data is already available for transmission
+ */
+ if ((UE_mac_inst[module_idP].
+ scheduling_info.LCID_buffer_remain[lcid] == 0)
+ /* or there is no data available for any of the logical channels which belong to a LCG */
+ ||
+ (lcgid_buffer_remain
+ [UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] ==
+ 0)) {
+ bsr_regular_triggered = TRUE;
+ LOG_D(MAC,
+ "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n",
+ module_idP, lcid,
+ UE_mac_inst[module_idP].scheduling_info.LCGID[lcid],
+ frameP, subframeP);
+ break;
+ }
}
- // Check whether a regular BSR can be triggered according to the first cases in 36.321
- if (num_lcid_with_data) {
- LOG_D(MAC,
- "[UE %d] PDCCH Tick at frame %d subframe %d: NumLCID with data=%d Reordered LCID0=%d LCID1=%d LCID2=%d\n",
- module_idP, frameP, subframeP, num_lcid_with_data,
- lcid_reordered_array[0], lcid_reordered_array[1],
- lcid_reordered_array[2]);
+ // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission
+ if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0) {
+ bsr_regular_triggered = TRUE;
- for (array_index = 0; array_index < num_lcid_with_data;
- array_index++) {
- lcid = lcid_reordered_array[array_index];
- /* UL data, for a logical channel which belongs to a LCG, becomes available for transmission in the RLC entity
- either the data belongs to a logical channel with higher priority than the priorities of the logical channels
- which belong to any LCG and for which data is already available for transmission
- */
- if ((UE_mac_inst[module_idP].
- scheduling_info.LCID_buffer_remain[lcid] == 0)
- /* or there is no data available for any of the logical channels which belong to a LCG */
- ||
- (lcgid_buffer_remain
- [UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]] ==
- 0)) {
- bsr_regular_triggered = TRUE;
-
- LOG_D(MAC,
- "[UE %d] PDCCH Tick : MAC BSR Triggered LCID%d LCGID%d data become available at frame %d subframe %d\n",
- module_idP, lcid,
- UE_mac_inst[module_idP].scheduling_info.LCGID[lcid],
- frameP, subframeP);
-
- break;
- }
- }
-
- // Trigger Regular BSR if ReTxBSR Timer has expired and UE has data for transmission
- if (UE_mac_inst[module_idP].scheduling_info.retxBSR_SF == 0) {
- bsr_regular_triggered = TRUE;
-
- if ((UE_mac_inst[module_idP].BSR_reporting_active &
- BSR_TRIGGER_REGULAR) == 0) {
- LOG_I(MAC,
- "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n",
- module_idP, frameP, subframeP);
- }
-
- }
- }
- //Store Buffer Occupancy in remain buffers for next TTI
- for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
- UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] =
- lcid_bytes_in_buffer[lcid];
+ if ((UE_mac_inst[module_idP].BSR_reporting_active &
+ BSR_TRIGGER_REGULAR) == 0) {
+ LOG_I(MAC,
+ "[UE %d] PDCCH Tick : MAC BSR Triggered ReTxBSR Timer expiry at frame %d subframe %d\n",
+ module_idP, frameP, subframeP);
+ }
}
+ }
- return bsr_regular_triggered;
+ //Store Buffer Occupancy in remain buffers for next TTI
+ for (lcid = DCCH; lcid < MAX_NUM_LCID; lcid++) {
+ UE_mac_inst[module_idP].scheduling_info.LCID_buffer_remain[lcid] =
+ lcid_bytes_in_buffer[lcid];
+ }
+
+ return bsr_regular_triggered;
}
uint8_t
-locate_BsrIndexByBufferSize(const uint32_t * table, int size, int value)
-{
+locate_BsrIndexByBufferSize(const uint32_t *table, int size, int value) {
+ uint8_t ju, jm, jl;
+ int ascend;
+ DevAssert(size > 0);
+ DevAssert(size <= 256);
- uint8_t ju, jm, jl;
- int ascend;
+ if (value == 0) {
+ return 0; //elseif (value > 150000) return 63;
+ }
- DevAssert(size > 0);
- DevAssert(size <= 256);
+ jl = 0; // lower bound
+ ju = size - 1; // upper bound
+ ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise
- if (value == 0) {
- return 0; //elseif (value > 150000) return 63;
- }
+ while (ju - jl > 1) { //If we are not yet done,
+ jm = (ju + jl) >> 1; //compute a midpoint,
- jl = 0; // lower bound
- ju = size - 1; // upper bound
- ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise
-
- while (ju - jl > 1) { //If we are not yet done,
- jm = (ju + jl) >> 1; //compute a midpoint,
-
- if ((value >= table[jm]) == ascend) {
- jl = jm; // replace the lower limit
- } else {
- ju = jm; //replace the upper limit
- }
-
- LOG_T(MAC,
- "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n",
- jm, table[jm], value);
- }
-
- if (value == table[jl]) {
- return jl;
+ if ((value >= table[jm]) == ascend) {
+ jl = jm; // replace the lower limit
} else {
- return jl + 1; //equally ju
+ ju = jm; //replace the upper limit
}
+ LOG_T(MAC,
+ "[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n",
+ jm, table[jm], value);
+ }
+
+ if (value == table[jl]) {
+ return jl;
+ } else {
+ return jl + 1; //equally ju
+ }
}
-int get_sf_periodicBSRTimer(uint8_t sf_offset)
-{
-
- switch (sf_offset) {
+int get_sf_periodicBSRTimer(uint8_t sf_offset) {
+ switch (sf_offset) {
case LTE_PeriodicBSR_Timer_r12_sf5:
- return 5;
- break;
+ return 5;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf10:
- return 10;
- break;
+ return 10;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf16:
- return 16;
- break;
+ return 16;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf20:
- return 20;
- break;
+ return 20;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf32:
- return 32;
- break;
+ return 32;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf40:
- return 40;
- break;
+ return 40;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf64:
- return 64;
- break;
+ return 64;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf80:
- return 80;
- break;
+ return 80;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf128:
- return 128;
- break;
+ return 128;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf160:
- return 160;
- break;
+ return 160;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf320:
- return 320;
- break;
+ return 320;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf640:
- return 640;
- break;
+ return 640;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf1280:
- return 1280;
- break;
+ return 1280;
+ break;
case LTE_PeriodicBSR_Timer_r12_sf2560:
- return 2560;
- break;
+ return 2560;
+ break;
case LTE_PeriodicBSR_Timer_r12_infinity:
default:
- return 0xFFFF;
- break;
- }
+ return 0xFFFF;
+ break;
+ }
}
-int get_sf_retxBSRTimer(uint8_t sf_offset)
-{
-
- switch (sf_offset) {
+int get_sf_retxBSRTimer(uint8_t sf_offset) {
+ switch (sf_offset) {
case LTE_RetxBSR_Timer_r12_sf320:
- return 320;
- break;
+ return 320;
+ break;
case LTE_RetxBSR_Timer_r12_sf640:
- return 640;
- break;
+ return 640;
+ break;
case LTE_RetxBSR_Timer_r12_sf1280:
- return 1280;
- break;
+ return 1280;
+ break;
case LTE_RetxBSR_Timer_r12_sf2560:
- return 2560;
- break;
+ return 2560;
+ break;
case LTE_RetxBSR_Timer_r12_sf5120:
- return 5120;
- break;
+ return 5120;
+ break;
case LTE_RetxBSR_Timer_r12_sf10240:
- return 10240;
- break;
+ return 10240;
+ break;
default:
- return -1;
- break;
- }
+ return -1;
+ break;
+ }
}
-int get_ms_bucketsizeduration(uint8_t bucketsizeduration)
-{
-
- switch (bucketsizeduration) {
+int get_ms_bucketsizeduration(uint8_t bucketsizeduration) {
+ switch (bucketsizeduration) {
case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50:
- return
- 50;
- break;
+ return
+ 50;
+ break;
case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms100:
- return
- 100;
- break;
+ return
+ 100;
+ break;
case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms150:
- return
- 150;
- break;
+ return
+ 150;
+ break;
case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms300:
- return
- 300;
- break;
+ return
+ 300;
+ break;
case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms500:
- return
- 500;
- break;
+ return
+ 500;
+ break;
case LTE_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000:
- return
- 1000;
- break;
+ return
+ 1000;
+ break;
default:
- return 0;
- break;
- }
+ return 0;
+ break;
+ }
}
-void update_phr(module_id_t module_idP, int CC_id)
-{
-
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
-
- UE_mac_inst[module_idP].PHR_reporting_active = 0;
- UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF =
- get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].
- scheduling_info.periodicPHR_Timer);
- UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF =
- get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].
- scheduling_info.prohibitPHR_Timer);
- // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF);
+void update_phr(module_id_t module_idP, int CC_id) {
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
+ UE_mac_inst[module_idP].PHR_reporting_active = 0;
+ UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF =
+ get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].
+ scheduling_info.periodicPHR_Timer);
+ UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF =
+ get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].
+ scheduling_info.prohibitPHR_Timer);
+ // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF);
}
uint8_t
-get_phr_mapping(module_id_t module_idP, int CC_id, uint8_t eNB_index)
-{
+get_phr_mapping(module_id_t module_idP, int CC_id, uint8_t eNB_index) {
+ AssertFatal(CC_id == 0,
+ "Transmission on secondary CCs is not supported yet\n");
- AssertFatal(CC_id == 0,
- "Transmission on secondary CCs is not supported yet\n");
-
- //power headroom reporting range is from -23 ...+40 dB, as described in 36313
- //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float
- if (get_PHR(module_idP, CC_id, eNB_index) < -23) {
- return 0;
- } else if (get_PHR(module_idP, CC_id, eNB_index) >= 40) {
- return 63;
- } else { // -23 to 40
- return (uint8_t) get_PHR(module_idP, CC_id,
- eNB_index) + PHR_MAPPING_OFFSET;
-
- }
+ //power headroom reporting range is from -23 ...+40 dB, as described in 36313
+ //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float
+ if (get_PHR(module_idP, CC_id, eNB_index) < -23) {
+ return 0;
+ } else if (get_PHR(module_idP, CC_id, eNB_index) >= 40) {
+ return 63;
+ } else { // -23 to 40
+ return (uint8_t) get_PHR(module_idP, CC_id,
+ eNB_index) + PHR_MAPPING_OFFSET;
+ }
}
-int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer)
-{
- return (perioidicPHR_Timer + 1) * 10;
+int get_sf_perioidicPHR_Timer(uint8_t perioidicPHR_Timer) {
+ return (perioidicPHR_Timer + 1) * 10;
}
-int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer)
-{
- return (prohibitPHR_Timer) * 10;
+int get_sf_prohibitPHR_Timer(uint8_t prohibitPHR_Timer) {
+ return (prohibitPHR_Timer) * 10;
}
-int get_db_dl_PathlossChange(uint8_t dl_PathlossChange)
-{
- switch (dl_PathlossChange) {
+int get_db_dl_PathlossChange(uint8_t dl_PathlossChange) {
+ switch (dl_PathlossChange) {
case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1:
- return 1;
- break;
+ return 1;
+ break;
case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB3:
- return 3;
- break;
+ return 3;
+ break;
case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB6:
- return 6;
- break;
+ return 6;
+ break;
case LTE_MAC_MainConfig__phr_Config__setup__dl_PathlossChange_infinity:
default:
- return -1;
- break;
- }
+ return -1;
+ break;
+ }
}
SLSS_t *ue_get_slss(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
-
- return((SLSS_t*)NULL);
+ return((SLSS_t *)NULL);
}
SLDCH_t *ue_get_sldch(module_id_t Mod_id,int CC_id,frame_t frame_tx,sub_frame_t subframe_tx) {
+ //UE_MAC_INST *ue = &UE_mac_inst[Mod_id];
+ SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch;
+ sldch->payload_length = mac_rrc_data_req_ue(Mod_id,
+ CC_id,
+ frame_tx,
+ SL_DISCOVERY,
+ 1,
+ (uint8_t *)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0],
+ 0, //eNB_indexP
+ 0);
- //UE_MAC_INST *ue = &UE_mac_inst[Mod_id];
- SLDCH_t *sldch = &UE_mac_inst[Mod_id].sldch;
-
- sldch->payload_length = mac_rrc_data_req_ue(Mod_id,
- CC_id,
- frame_tx,
- SL_DISCOVERY,
- 1,
- (uint8_t*)(sldch->payload), //&UE_mac_inst[Mod_id].SL_Discovery[0].Tx_buffer.Payload[0],
- 0, //eNB_indexP
- 0);
-
-
-
- if (sldch->payload_length >0 ) {
- LOG_I(MAC,"Got %d bytes from RRC for SLDCH @ %p\n",sldch->payload_length,sldch);
- return (sldch);
- }
- else
-
- return((SLDCH_t*)NULL);
+ if (sldch->payload_length >0 ) {
+ LOG_I(MAC,"Got %d bytes from RRC for SLDCH @ %p\n",sldch->payload_length,sldch);
+ return (sldch);
+ } else
+ return((SLDCH_t *)NULL);
}
SLSCH_t *ue_get_slsch(module_id_t module_idP,int CC_id,frame_t frameP,sub_frame_t subframeP) {
+ mac_rlc_status_resp_t rlc_status; //, rlc_status_data;
+ uint32_t absSF = (frameP*10)+subframeP;
+ UE_MAC_INST *ue = &UE_mac_inst[module_idP];
+ int rvtab[4] = {0,2,3,1};
+ int sdu_length;
+ //uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded
+ int i = 0;
+ // Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH)
+ SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch;
+ LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF);
- mac_rlc_status_resp_t rlc_status; //, rlc_status_data;
- uint32_t absSF = (frameP*10)+subframeP;
- UE_MAC_INST *ue = &UE_mac_inst[module_idP];
- int rvtab[4] = {0,2,3,1};
- int sdu_length;
- //uint8_t sl_lcids[2] = {3, 10}; //list of lcids for SL - hardcoded
- int i = 0;
+ if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
+ ue->sltx_active = 0;
- // Note: this is hard-coded for now for the default SL configuration (4 SF PSCCH, 36 SF PSSCH)
- SLSCH_t *slsch = &UE_mac_inst[module_idP].slsch;
+ for (i = 0; i < MAX_NUM_LCID; i++) {
+ if (ue->SL_LCID[i] > 0) {
+ for (int j = 0; j < ue->numCommFlows; j++) {
+ if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ) {
+ rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
+ ue->SL_LCID[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]);
- LOG_D(MAC,"Checking SLSCH for absSF %d\n",absSF);
- if ((absSF%40) == 0) { // fill PSCCH data later in first subframe of SL period
- ue->sltx_active = 0;
-
- for (i = 0; i < MAX_NUM_LCID; i++){
- if (ue->SL_LCID[i] > 0) {
- for (int j = 0; j < ue->numCommFlows; j++){
- if ((ue->sourceL2Id > 0) && (ue->destinationList[j] >0) ){
- rlc_status = mac_rlc_status_ind(module_idP, 0x1234,0,frameP,subframeP,ENB_FLAG_NO,MBMS_FLAG_NO,
- ue->SL_LCID[i], 0xFFFF, ue->sourceL2Id, ue->destinationList[j]);
- if (rlc_status.bytes_in_buffer > 2){
- LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
- // Fill in group id for off-network communications
- ue->sltx_active = 1;
- //store LCID, destinationL2Id
- ue->slsch_lcid = ue->SL_LCID[i];
- ue->destinationL2Id = ue->destinationList[j];
- break;
- }
- }
+ if (rlc_status.bytes_in_buffer > 2) {
+ LOG_I(MAC,"SFN.SF %d.%d: Scheduling for %d bytes in Sidelink buffer\n",frameP,subframeP,rlc_status.bytes_in_buffer);
+ // Fill in group id for off-network communications
+ ue->sltx_active = 1;
+ //store LCID, destinationL2Id
+ ue->slsch_lcid = ue->SL_LCID[i];
+ ue->destinationL2Id = ue->destinationList[j];
+ break;
}
- }
- if ( ue->sltx_active == 1) break;
+ }
+ }
}
- } // we're not in the SCCH period
- else if (((absSF & 3) == 0 ) &&
- (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC
- // 10 PRBs, mcs 19
- int TBS = 4584/8;
- int req;
+ if ( ue->sltx_active == 1) break;
+ }
+ } // we're not in the SCCH period
+ else if (((absSF & 3) == 0 ) &&
+ (ue->sltx_active == 1)) { // every 4th subframe, check for new data from RLC
+ // 10 PRBs, mcs 19
+ int TBS = 4584/8;
+ int req;
- if (TBS <= rlc_status.bytes_in_buffer) req = TBS;
- else req = rlc_status.bytes_in_buffer;
+ if (TBS <= rlc_status.bytes_in_buffer) req = TBS;
+ else req = rlc_status.bytes_in_buffer;
- if (req>0) {
- sdu_length = mac_rlc_data_req(module_idP,
- 0x1234,
- 0,
- frameP,
- ENB_FLAG_NO,
- MBMS_FLAG_NO,
- ue->slsch_lcid,
- req,
- (char*)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG))
+ if (req>0) {
+ sdu_length = mac_rlc_data_req(module_idP,
+ 0x1234,
+ 0,
+ frameP,
+ ENB_FLAG_NO,
+ MBMS_FLAG_NO,
+ ue->slsch_lcid,
+ req,
+ (char *)(ue->slsch_pdu.payload + sizeof(SLSCH_SUBHEADER_24_Bit_DST_LONG))
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,ue->sourceL2Id,
- ue->destinationL2Id
+ ,ue->sourceL2Id,
+ ue->destinationL2Id
#endif
- );
+ );
- // Notes: 1. hard-coded to 24-bit destination format for now
- if (sdu_length > 0) {
+ // Notes: 1. hard-coded to 24-bit destination format for now
+ if (sdu_length > 0) {
+ LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req);
+ LOG_I(MAC,"sourceL2Id: 0x%08x \n",ue->sourceL2Id);
+ LOG_I(MAC,"groupL2Id/destinationL2Id: 0x%08x \n",ue->destinationL2Id);
+ slsch->payload = (unsigned char *)ue->slsch_pdu.payload;
- LOG_I(MAC,"SFN.SF %d.%d : got %d bytes from Sidelink buffer (%d requested)\n",frameP,subframeP,sdu_length,req);
- LOG_I(MAC,"sourceL2Id: 0x%08x \n",ue->sourceL2Id);
- LOG_I(MAC,"groupL2Id/destinationL2Id: 0x%08x \n",ue->destinationL2Id);
+ if (sdu_length < 128) {
+ slsch->payload++;
+ SLSCH_SUBHEADER_24_Bit_DST_SHORT *shorth= (SLSCH_SUBHEADER_24_Bit_DST_SHORT *)slsch->payload;
+ shorth->F = 0;
+ shorth->L = sdu_length;
+ shorth->E = 0;
+ shorth->LCID = ue->slsch_lcid;
+ shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff;
+ shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
+ shorth->SRC1623 = ue->sourceL2Id & 0x000000ff;
+ shorth->DST07 = (ue->destinationL2Id >>16) & 0x000000ff;
+ shorth->DST815 = (ue->destinationL2Id >>8) & 0x000000ff;
+ shorth->DST1623 = ue->destinationL2Id & 0x000000ff;
+ shorth->V = 0x1;
+ } else {
+ SLSCH_SUBHEADER_24_Bit_DST_LONG *longh= (SLSCH_SUBHEADER_24_Bit_DST_LONG *)slsch->payload;
+ longh->F = 1;
+ longh->L_LSB = sdu_length&0xff;
+ longh->L_MSB = (sdu_length>>8)&0x7f;
+ longh->E = 0;
+ longh->LCID = ue->slsch_lcid;
+ longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff;
+ longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
+ longh->SRC1623 = ue->sourceL2Id & 0x000000ff;
+ longh->DST07 = (ue->destinationL2Id >>16) & 0x000000ff;
+ longh->DST815 = (ue->destinationL2Id>>8) & 0x000000ff;
+ longh->DST1623 = ue->destinationL2Id & 0x000000ff;
+ longh->V = 0x1;
+ }
- slsch->payload = (unsigned char*)ue->slsch_pdu.payload;
- if (sdu_length < 128) {
- slsch->payload++;
- SLSCH_SUBHEADER_24_Bit_DST_SHORT *shorth= (SLSCH_SUBHEADER_24_Bit_DST_SHORT *)slsch->payload;
- shorth->F = 0;
- shorth->L = sdu_length;
- shorth->E = 0;
- shorth->LCID = ue->slsch_lcid;
- shorth->SRC07 = (ue->sourceL2Id>>16) & 0x000000ff;
- shorth->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
- shorth->SRC1623 = ue->sourceL2Id & 0x000000ff;
- shorth->DST07 = (ue->destinationL2Id >>16) & 0x000000ff;
- shorth->DST815 = (ue->destinationL2Id >>8) & 0x000000ff;
- shorth->DST1623 = ue->destinationL2Id & 0x000000ff;
- shorth->V = 0x1;
- }
- else {
- SLSCH_SUBHEADER_24_Bit_DST_LONG *longh= (SLSCH_SUBHEADER_24_Bit_DST_LONG *)slsch->payload;
- longh->F = 1;
- longh->L_LSB = sdu_length&0xff;
- longh->L_MSB = (sdu_length>>8)&0x7f;
- longh->E = 0;
- longh->LCID = ue->slsch_lcid;
- longh->SRC07 = (ue->sourceL2Id >>16) & 0x000000ff;
- longh->SRC815 = (ue->sourceL2Id>>8) & 0x000000ff;
- longh->SRC1623 = ue->sourceL2Id & 0x000000ff;
- longh->DST07 = (ue->destinationL2Id >>16) & 0x000000ff;
- longh->DST815 = (ue->destinationL2Id>>8) & 0x000000ff;
- longh->DST1623 = ue->destinationL2Id & 0x000000ff;
- longh->V = 0x1;
- }
- slsch->rvidx = 0;
- slsch->payload_length = TBS;
- // fill in SLSCH configuration
- return(&ue->slsch);
- }
- else ue->sltx_active = 0;
- }
-
- } else if ((absSF%40)>3 && ue->sltx_active == 1) { // handle retransmission of SDU
- LOG_I(MAC,"SFN.SF %d.%d : retransmission\n",frameP,subframeP);
- slsch->rvidx = rvtab[absSF&3];
- return(&ue->slsch);
- }
+ slsch->rvidx = 0;
+ slsch->payload_length = TBS;
+ // fill in SLSCH configuration
+ return(&ue->slsch);
+ } else ue->sltx_active = 0;
+ }
+ } else if ((absSF%40)>3 && ue->sltx_active == 1) { // handle retransmission of SDU
+ LOG_I(MAC,"SFN.SF %d.%d : retransmission\n",frameP,subframeP);
+ slsch->rvidx = rvtab[absSF&3];
+ return(&ue->slsch);
+ }
return(NULL);
}
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
index b72f26780c..016b626738 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c
@@ -46,10 +46,12 @@
#include "common/utils/LOG/log.h"
#include
#include "platform_constants.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "msc.h"
#include "common/ngran_types.h"
#include "targets/COMMON/openairinterface5g_limits.h"
+#include "targets/RT/USER/lte-softmodem.h"
#include "SIMULATION/ETH_TRANSPORT/proto.h"
#include "UTIL/OSA/osa_defs.h"
#include "openair2/RRC/NAS/nas_config.h"
@@ -60,9 +62,8 @@
# include "gtpv1u.h"
#include "ENB_APP/enb_config.h"
-#ifndef UETARGET
-#include "LAYER2/PROTO_AGENT/proto_agent.h"
-#endif
+
+
extern int otg_enabled;
extern uint8_t nfapi_mode;
@@ -83,7 +84,7 @@ hash_table_t *pdcp_coll_p = NULL;
/* pdcp module parameters and related functions*/
-static pdcp_params_t pdcp_params= {0};
+static pdcp_params_t pdcp_params= {0,NULL};
uint64_t get_pdcp_optmask(void) {
return pdcp_params.optmask;
@@ -190,22 +191,9 @@ boolean_t pdcp_data_req(
sdu_buffer_sizeP);
LOG_UI(PDCP, "Before rlc_data_req 1, srb_flagP: %d, rb_idP: %d \n", srb_flagP, rb_idP);
}
-#ifndef UETARGET
- if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) {
- /* currently, there is no support to send also the source/destinationL2Id */
- proto_agent_send_rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP,
- confirmP, sdu_buffer_sizeP, pdcp_pdu_p);
- /* assume good status */
- rlc_status = RLC_OP_STATUS_OK;
- } else
-#endif
- {
- rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_YES, rb_idP, muiP,
- confirmP, sdu_buffer_sizeP, pdcp_pdu_p
- ,NULL, NULL
- );
- }
+ rlc_status = pdcp_params.send_rlc_data_req_func(ctxt_pP, srb_flagP, NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)?MBMS_FLAG_NO:MBMS_FLAG_YES, rb_idP, muiP,
+ confirmP, sdu_buffer_sizeP, pdcp_pdu_p,NULL,NULL);
} else {
rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES;
LOG_E(PDCP,PROTOCOL_CTXT_FMT" PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n",
@@ -364,74 +352,55 @@ boolean_t pdcp_data_req(
*/
LOG_DUMPMSG(PDCP,DEBUG_PDCP,(char *)pdcp_pdu_p->data,pdcp_pdu_size,
"[MSG] PDCP DL %s PDU on rb_id %d\n",(srb_flagP)? "CONTROL" : "DATA", rb_idP);
-
- if ((pdcp_pdu_p!=NULL) && (srb_flagP == 0) && (ctxt_pP->enb_flag == 1))
- {
-#ifndef UETARGET
- LOG_D(PDCP, "pdcp data req on drb %d, size %d, rnti %x, node_type %d \n",
+ if ((pdcp_pdu_p!=NULL) && (srb_flagP == 0) && (ctxt_pP->enb_flag == 1)) {
+ LOG_D(PDCP, "pdcp data req on drb %d, size %d, rnti %x, node_type %d \n",
rb_idP, pdcp_pdu_size, ctxt_pP->rnti, RC.rrc[ctxt_pP->module_id]->node_type);
- if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) {
- /* currently, there is no support to send also the source/destinationL2Id */
- proto_agent_send_rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP,
- confirmP, pdcp_pdu_size, pdcp_pdu_p);
- /* assume good status */
- rlc_status = RLC_OP_STATUS_OK;
- ret = TRUE;
- LOG_D(PDCP, "proto_agent_send_rlc_data_req for UE RNTI %x, rb %d, pdu size %d \n",
- ctxt_pP->rnti, rb_idP, pdcp_pdu_size);
-
- } else if (NODE_IS_DU(RC.rrc[ctxt_pP->module_id]->node_type)){
+ if (ctxt_pP->enb_flag == ENB_FLAG_YES && NODE_IS_DU(RC.rrc[ctxt_pP->module_id]->node_type)) {
LOG_E(PDCP, "Can't be DU, bad node type %d \n", RC.rrc[ctxt_pP->module_id]->node_type);
ret=FALSE;
- } else
-#endif
- {
- rlc_status = rlc_data_req(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP,
- confirmP, pdcp_pdu_size, pdcp_pdu_p, sourceL2Id,
- destinationL2Id
- );
- switch (rlc_status) {
- case RLC_OP_STATUS_OK:
- LOG_D(PDCP, "Data sending request over RLC succeeded!\n");
- ret=TRUE;
- break;
+ } else {
+ rlc_status = pdcp_params.send_rlc_data_req_func(ctxt_pP, srb_flagP, MBMS_FLAG_NO, rb_idP, muiP,
+ confirmP, pdcp_pdu_size, pdcp_pdu_p,sourceL2Id,
+ destinationL2Id);
- case RLC_OP_STATUS_BAD_PARAMETER:
- LOG_W(PDCP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
- ret= FALSE;
- break;
+ switch (rlc_status) {
+ case RLC_OP_STATUS_OK:
+ LOG_D(PDCP, "Data sending request over RLC succeeded!\n");
+ ret=TRUE;
+ break;
- case RLC_OP_STATUS_INTERNAL_ERROR:
- LOG_W(PDCP, "Data sending request over RLC failed with 'Internal Error' reason!\n");
- ret= FALSE;
- break;
+ case RLC_OP_STATUS_BAD_PARAMETER:
+ LOG_W(PDCP, "Data sending request over RLC failed with 'Bad Parameter' reason!\n");
+ ret= FALSE;
+ break;
- case RLC_OP_STATUS_OUT_OF_RESSOURCES:
- LOG_W(PDCP, "Data sending request over RLC failed with 'Out of Resources' reason!\n");
- ret= FALSE;
- break;
+ case RLC_OP_STATUS_INTERNAL_ERROR:
+ LOG_W(PDCP, "Data sending request over RLC failed with 'Internal Error' reason!\n");
+ ret= FALSE;
+ break;
- default:
- LOG_W(PDCP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
- ret= FALSE;
- break;
- } // switch case
- } /* end if node_type is CU */
- }
- else // SRB
- {
+ case RLC_OP_STATUS_OUT_OF_RESSOURCES:
+ LOG_W(PDCP, "Data sending request over RLC failed with 'Out of Resources' reason!\n");
+ ret= FALSE;
+ break;
-#ifndef UETARGET
- if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) {
+ default:
+ LOG_W(PDCP, "RLC returned an unknown status code after PDCP placed the order to send some data (Status Code:%d)\n", rlc_status);
+ ret= FALSE;
+ break;
+ } // switch case
+ } /* end if node_type is not DU */
+ } else { // SRB
+ if (ctxt_pP->enb_flag == ENB_FLAG_YES && NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type)) {
// DL transfer
MessageDef *message_p;
// Note: the acyual task must be TASK_PDCP_ENB, but this task is not created
message_p = itti_alloc_new_message (TASK_PDCP_ENB, F1AP_DL_RRC_MESSAGE);
F1AP_DL_RRC_MESSAGE (message_p).rrc_container = &pdcp_pdu_p->data[0] ;
F1AP_DL_RRC_MESSAGE (message_p).rrc_container_length = pdcp_pdu_size;
- F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
+ F1AP_DL_RRC_MESSAGE (message_p).gNB_CU_ue_id = 0;
F1AP_DL_RRC_MESSAGE (message_p).gNB_DU_ue_id = 0;
F1AP_DL_RRC_MESSAGE (message_p).old_gNB_DU_ue_id = 0xFFFFFFFF; // unknown
F1AP_DL_RRC_MESSAGE (message_p).rnti = ctxt_pP->rnti;
@@ -442,10 +411,7 @@ boolean_t pdcp_data_req(
//CU_send_DL_RRC_MESSAGE_TRANSFER(ctxt_pP->module_id, message_p);
LOG_I(PDCP, "Send F1AP_DL_RRC_MESSAGE with ITTI\n");
ret=TRUE;
-
- } else
-#endif
- {
+ } else {
rlc_status = rlc_data_req(ctxt_pP
, srb_flagP
, MBMS_FLAG_NO
@@ -454,11 +420,10 @@ boolean_t pdcp_data_req(
, confirmP
, pdcp_pdu_size
, pdcp_pdu_p
-#ifdef Rel14
,NULL
,NULL
-#endif
- );
+ );
+
switch (rlc_status) {
case RLC_OP_STATUS_OK:
LOG_D(PDCP, "Data sending request over RLC succeeded!\n");
@@ -719,13 +684,13 @@ pdcp_data_ind(
}
security_ok = pdcp_validate_security(ctxt_pP,
- pdcp_p,
- srb_flagP,
- rb_idP,
- pdcp_header_len,
+ pdcp_p,
+ srb_flagP,
+ rb_idP,
+ pdcp_header_len,
rx_hfn_for_count,
pdcp_sn_for_count,
- sdu_buffer_pP->data,
+ sdu_buffer_pP->data,
sdu_buffer_sizeP - pdcp_tailer_len) == 0;
if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
@@ -788,35 +753,106 @@ pdcp_data_ind(
payload_offset=pdcp_header_len;// PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE;
switch (pdcp_p->rlc_mode) {
- case RLC_MODE_AM: {
- /* process as described in 36.323 5.1.2.1.2 */
- int reordering_window;
+ case RLC_MODE_AM: {
+ /* process as described in 36.323 5.1.2.1.2 */
+ int reordering_window;
- if (pdcp_p->seq_num_size == 7)
- reordering_window = REORDERING_WINDOW_SN_7BIT;
- else
- reordering_window = REORDERING_WINDOW_SN_12BIT;
+ if (pdcp_p->seq_num_size == 7)
+ reordering_window = REORDERING_WINDOW_SN_7BIT;
+ else
+ reordering_window = REORDERING_WINDOW_SN_12BIT;
+
+ if (sequence_number - pdcp_p->last_submitted_pdcp_rx_sn > reordering_window ||
+ (pdcp_p->last_submitted_pdcp_rx_sn - sequence_number >= 0 &&
+ pdcp_p->last_submitted_pdcp_rx_sn - sequence_number < reordering_window)) {
+ /* TODO: specs say to decipher and do header decompression */
+ LOG_W(PDCP,
+ PROTOCOL_PDCP_CTXT_FMT"discard PDU, out of\n",
+ PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
+ LOG_W(PDCP, "Ignoring PDU...\n");
+ free_mem_block(sdu_buffer_pP, __func__);
+ /* TODO: indicate integrity verification failure to upper layer */
+ return FALSE;
+ } else if (pdcp_p->next_pdcp_rx_sn - sequence_number > reordering_window) {
+ pdcp_p->rx_hfn++;
+ rx_hfn_for_count = pdcp_p->rx_hfn;
+ pdcp_sn_for_count = sequence_number;
+ pdcp_p->next_pdcp_rx_sn = sequence_number + 1;
+ } else if (sequence_number - pdcp_p->next_pdcp_rx_sn >= reordering_window) {
+ rx_hfn_for_count = pdcp_p->rx_hfn - 1;
+ pdcp_sn_for_count = sequence_number;
+ } else if (sequence_number >= pdcp_p->next_pdcp_rx_sn) {
+ rx_hfn_for_count = pdcp_p->rx_hfn;
+ pdcp_sn_for_count = sequence_number;
+ pdcp_p->next_pdcp_rx_sn = sequence_number + 1;
+
+ if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) {
+ pdcp_p->next_pdcp_rx_sn = 0;
+ pdcp_p->rx_hfn++;
+ }
+ } else { /* sequence_number < pdcp_p->next_pdcp_rx_sn */
+ rx_hfn_for_count = pdcp_p->rx_hfn;
+ pdcp_sn_for_count = sequence_number;
+ }
+
+ if (pdcp_p->security_activated == 1) {
+ if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
+ start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
+ } else {
+ start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
+ }
+
+ security_ok = pdcp_validate_security(ctxt_pP,
+ pdcp_p,
+ srb_flagP,
+ rb_idP,
+ pdcp_header_len,
+ rx_hfn_for_count,
+ pdcp_sn_for_count,
+ sdu_buffer_pP->data,
+ sdu_buffer_sizeP - pdcp_tailer_len) == 0;
+
+ if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
+ stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
+ } else {
+ stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
+ }
+ } else {
+ security_ok = 1;
+ }
+
+ if (security_ok == 0) {
+ LOG_W(PDCP,
+ PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/AM PDU\n",
+ PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
+ LOG_W(PDCP, "Ignoring PDU...\n");
+ free_mem_block(sdu_buffer_pP, __func__);
+ /* TODO: indicate integrity verification failure to upper layer */
+ return FALSE;
+ }
+
+ /* TODO: specs say we have to store this PDU in a list and then deliver
+ * stored packets to upper layers according to a well defined
+ * procedure. The code below that deals with delivery is today
+ * too complex to do this properly, so we only send the current
+ * received packet. This is not correct and has to be fixed
+ * some day.
+ * In the meantime, let's pretend the last submitted PDCP SDU
+ * is the current one.
+ * TODO: we also have to deal with re-establishment PDU (control PDUs)
+ * that contain no SDU.
+ */
+ pdcp_p->last_submitted_pdcp_rx_sn = sequence_number;
+ break;
+ } /* case RLC_MODE_AM */
+
+ case RLC_MODE_UM:
+
+ /* process as described in 36.323 5.1.2.1.3 */
+ if (sequence_number < pdcp_p->next_pdcp_rx_sn) {
+ pdcp_p->rx_hfn++;
+ }
- if (sequence_number - pdcp_p->last_submitted_pdcp_rx_sn > reordering_window ||
- (pdcp_p->last_submitted_pdcp_rx_sn - sequence_number >= 0 &&
- pdcp_p->last_submitted_pdcp_rx_sn - sequence_number < reordering_window)) {
- /* TODO: specs say to decipher and do header decompression */
- LOG_W(PDCP,
- PROTOCOL_PDCP_CTXT_FMT"discard PDU, out of\n",
- PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
- LOG_W(PDCP, "Ignoring PDU...\n");
- free_mem_block(sdu_buffer_pP, __func__);
- /* TODO: indicate integrity verification failure to upper layer */
- return FALSE;
- } else if (pdcp_p->next_pdcp_rx_sn - sequence_number > reordering_window) {
- pdcp_p->rx_hfn++;
- rx_hfn_for_count = pdcp_p->rx_hfn;
- pdcp_sn_for_count = sequence_number;
- pdcp_p->next_pdcp_rx_sn = sequence_number + 1;
- } else if (sequence_number - pdcp_p->next_pdcp_rx_sn >= reordering_window) {
- rx_hfn_for_count = pdcp_p->rx_hfn - 1;
- pdcp_sn_for_count = sequence_number;
- } else if (sequence_number >= pdcp_p->next_pdcp_rx_sn) {
rx_hfn_for_count = pdcp_p->rx_hfn;
pdcp_sn_for_count = sequence_number;
pdcp_p->next_pdcp_rx_sn = sequence_number + 1;
@@ -825,119 +861,48 @@ pdcp_data_ind(
pdcp_p->next_pdcp_rx_sn = 0;
pdcp_p->rx_hfn++;
}
- } else { /* sequence_number < pdcp_p->next_pdcp_rx_sn */
- rx_hfn_for_count = pdcp_p->rx_hfn;
- pdcp_sn_for_count = sequence_number;
- }
- if (pdcp_p->security_activated == 1) {
- if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
- start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
- } else {
- start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
- }
+ if (pdcp_p->security_activated == 1) {
+ if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
+ start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
+ } else {
+ start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
+ }
- security_ok = pdcp_validate_security(ctxt_pP,
- pdcp_p,
- srb_flagP,
- rb_idP,
- pdcp_header_len,
- rx_hfn_for_count,
- pdcp_sn_for_count,
- sdu_buffer_pP->data,
- sdu_buffer_sizeP - pdcp_tailer_len) == 0;
+ security_ok = pdcp_validate_security(ctxt_pP,
+ pdcp_p,
+ srb_flagP,
+ rb_idP,
+ pdcp_header_len,
+ rx_hfn_for_count,
+ pdcp_sn_for_count,
+ sdu_buffer_pP->data,
+ sdu_buffer_sizeP - pdcp_tailer_len) == 0;
- if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
- stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
- } else {
- stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
- }
- } else {
- security_ok = 1;
- }
-
- if (security_ok == 0) {
- LOG_W(PDCP,
- PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/AM PDU\n",
- PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
- LOG_W(PDCP, "Ignoring PDU...\n");
- free_mem_block(sdu_buffer_pP, __func__);
- /* TODO: indicate integrity verification failure to upper layer */
- return FALSE;
- }
-
- /* TODO: specs say we have to store this PDU in a list and then deliver
- * stored packets to upper layers according to a well defined
- * procedure. The code below that deals with delivery is today
- * too complex to do this properly, so we only send the current
- * received packet. This is not correct and has to be fixed
- * some day.
- * In the meantime, let's pretend the last submitted PDCP SDU
- * is the current one.
- * TODO: we also have to deal with re-establishment PDU (control PDUs)
- * that contain no SDU.
- */
- pdcp_p->last_submitted_pdcp_rx_sn = sequence_number;
- break;
- } /* case RLC_MODE_AM */
-
- case RLC_MODE_UM:
-
- /* process as described in 36.323 5.1.2.1.3 */
- if (sequence_number < pdcp_p->next_pdcp_rx_sn) {
- pdcp_p->rx_hfn++;
- }
-
- rx_hfn_for_count = pdcp_p->rx_hfn;
- pdcp_sn_for_count = sequence_number;
- pdcp_p->next_pdcp_rx_sn = sequence_number + 1;
-
- if (pdcp_p->next_pdcp_rx_sn > pdcp_p->maximum_pdcp_rx_sn) {
- pdcp_p->next_pdcp_rx_sn = 0;
- pdcp_p->rx_hfn++;
- }
-
- if (pdcp_p->security_activated == 1) {
- if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
- start_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
- } else {
- start_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
- }
-
- security_ok = pdcp_validate_security(ctxt_pP,
- pdcp_p,
- srb_flagP,
- rb_idP,
- pdcp_header_len,
- rx_hfn_for_count,
- pdcp_sn_for_count,
- sdu_buffer_pP->data,
- sdu_buffer_sizeP - pdcp_tailer_len) == 0;
-
- if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
- stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
+ if (ctxt_pP->enb_flag == ENB_FLAG_NO) {
+ stop_meas(&eNB_pdcp_stats[ctxt_pP->module_id].validate_security);
+ } else {
+ stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
+ }
} else {
- stop_meas(&UE_pdcp_stats[ctxt_pP->module_id].validate_security);
+ security_ok = 1;
}
- } else {
- security_ok = 1;
- }
- if (security_ok == 0) {
- LOG_W(PDCP,
- PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/UM PDU\n",
- PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
- LOG_W(PDCP, "Ignoring PDU...\n");
- free_mem_block(sdu_buffer_pP, __func__);
- /* TODO: indicate integrity verification failure to upper layer */
- return FALSE;
- }
+ if (security_ok == 0) {
+ LOG_W(PDCP,
+ PROTOCOL_PDCP_CTXT_FMT"security not validated for incoming PDPC DRB RLC/UM PDU\n",
+ PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
+ LOG_W(PDCP, "Ignoring PDU...\n");
+ free_mem_block(sdu_buffer_pP, __func__);
+ /* TODO: indicate integrity verification failure to upper layer */
+ return FALSE;
+ }
- break;
+ break;
- default:
- LOG_E(PDCP, "bad RLC mode, cannot happen.\n");
- exit(1);
+ default:
+ LOG_E(PDCP, "bad RLC mode, cannot happen.\n");
+ exit(1);
} /* switch (pdcp_p->rlc_mode) */
} else { /* MBMS_flagP == 0 */
payload_offset=0;
@@ -966,37 +931,36 @@ pdcp_data_ind(
*/
if (LINK_ENB_PDCP_TO_GTPV1U) {
- if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) {
- LOG_D(PDCP, "Sending packet to GTP, Calling GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u\n",
+ if ((TRUE == ctxt_pP->enb_flag) && (FALSE == srb_flagP)) {
+ LOG_D(PDCP, "Sending packet to GTP, Calling GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u\n",
ctxt_pP->rnti,
rb_id + 4,
sdu_buffer_sizeP - payload_offset );
-
- MSC_LOG_TX_MESSAGE(
- MSC_PDCP_ENB,
- MSC_GTPU_ENB,
- NULL,0,
- "0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u",
- ctxt_pP->rnti,
- rb_id + 4,
- sdu_buffer_sizeP - payload_offset);
- //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset);
- gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
- sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX);
- AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
- memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset);
- message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ);
- AssertFatal(message_p != NULL, "OUT OF MEMORY");
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset;
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti;
- GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
- itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
- packet_forwarded = TRUE;
- }
+ MSC_LOG_TX_MESSAGE(
+ MSC_PDCP_ENB,
+ MSC_GTPU_ENB,
+ NULL,0,
+ "0 GTPV1U_ENB_TUNNEL_DATA_REQ ue %x rab %u len %u",
+ ctxt_pP->rnti,
+ rb_id + 4,
+ sdu_buffer_sizeP - payload_offset);
+ //LOG_T(PDCP,"Sending to GTPV1U %d bytes\n", sdu_buffer_sizeP - payload_offset);
+ gtpu_buffer_p = itti_malloc(TASK_PDCP_ENB, TASK_GTPV1_U,
+ sdu_buffer_sizeP - payload_offset + GTPU_HEADER_OVERHEAD_MAX);
+ AssertFatal(gtpu_buffer_p != NULL, "OUT OF MEMORY");
+ memcpy(>pu_buffer_p[GTPU_HEADER_OVERHEAD_MAX], &sdu_buffer_pP->data[payload_offset], sdu_buffer_sizeP - payload_offset);
+ message_p = itti_alloc_new_message(TASK_PDCP_ENB, GTPV1U_ENB_TUNNEL_DATA_REQ);
+ AssertFatal(message_p != NULL, "OUT OF MEMORY");
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).buffer = gtpu_buffer_p;
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).length = sdu_buffer_sizeP - payload_offset;
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).offset = GTPU_HEADER_OVERHEAD_MAX;
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rnti = ctxt_pP->rnti;
+ GTPV1U_ENB_TUNNEL_DATA_REQ(message_p).rab_id = rb_id + 4;
+ itti_send_msg_to_task(TASK_GTPV1_U, INSTANCE_DEFAULT, message_p);
+ packet_forwarded = TRUE;
+ }
} else {
- packet_forwarded = FALSE;
+ packet_forwarded = FALSE;
}
#ifdef MBMS_MULTICAST_OUT
@@ -1035,28 +999,28 @@ pdcp_data_ind(
((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_id;
if (EPC_MODE_ENABLED) {
- /* for the UE compiled in S1 mode, we need 1 here
- * for the UE compiled in noS1 mode, we need 0
- * TODO: be sure of this
- */
- if (nfapi_mode == 3) {
+ /* for the UE compiled in S1 mode, we need 1 here
+ * for the UE compiled in noS1 mode, we need 0
+ * TODO: be sure of this
+ */
+ if (NFAPI_MODE == NFAPI_UE_STUB_PNF ) {
#ifdef UESIM_EXPANSION
if (UE_NAS_USE_TUN) {
((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id;
} else {
- ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0;
+ ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 0;
}
#else
- ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id;
+ ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id;
#endif
} else { // nfapi_mode
if (UE_NAS_USE_TUN) {
((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ctxt_pP->module_id;
- } else {
- ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1;
- }
+ } else {
+ ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = 1;
+ }
} // nfapi_mode
}
} else {
@@ -1065,9 +1029,9 @@ pdcp_data_ind(
}
if( LOG_DEBUGFLAG(DEBUG_PDCP) ) {
- static uint32_t pdcp_inst = 0;
- ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++;
- LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size);
+ static uint32_t pdcp_inst = 0;
+ ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = pdcp_inst++;
+ LOG_D(PDCP, "inst=%d size=%d\n", ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst, ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size);
}
memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)],
@@ -1082,35 +1046,23 @@ pdcp_data_ind(
sdu_buffer_sizeP - payload_offset);
//util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset);
//util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset);
-
-#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD)
- /* This was an "orphan else" in tag 2019.w07 and discovered during merge.
- * Commenting so it could be reintegrated. */
- //else {
- // AssertFatal(0, PROTOCOL_PDCP_CTXT_FMT" PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n",
- // PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP, pdcp_p));
- //}
-
-#endif
}
/* Update PDCP statistics */
- for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB;pdcp_uid++){
- if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ){
+ for (pdcp_uid=0; pdcp_uid< MAX_MOBILES_PER_ENB; pdcp_uid++) {
+ if (pdcp_enb[ctxt_pP->module_id].rnti[pdcp_uid] == ctxt_pP->rnti ) {
break;
}
- }
-
+ }
+
Pdcp_stats_rx[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++;
Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]++;
Pdcp_stats_rx_bytes[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset);
Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(sdu_buffer_sizeP - payload_offset);
-
Pdcp_stats_rx_sn[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=sequence_number;
Pdcp_stats_rx_aiat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+= (pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]);
Pdcp_stats_rx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]+=(pdcp_enb[ctxt_pP->module_id].sfn - Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]);
Pdcp_stats_rx_iat[ctxt_pP->module_id][pdcp_uid][rb_idP+rb_offset]=pdcp_enb[ctxt_pP->module_id].sfn;
-
free_mem_block(sdu_buffer_pP, __func__);
if (ctxt_pP->enb_flag) {
@@ -1296,8 +1248,7 @@ pdcp_run (
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT);
}
-void pdcp_init_stats_UE(module_id_t mod, uint16_t uid)
-{
+void pdcp_init_stats_UE(module_id_t mod, uint16_t uid) {
Pdcp_stats_tx_window_ms[mod][uid] = 100;
Pdcp_stats_rx_window_ms[mod][uid] = 100;
@@ -1314,7 +1265,6 @@ void pdcp_init_stats_UE(module_id_t mod, uint16_t uid)
Pdcp_stats_tx_aiat_w[mod][uid][i] = 0;
Pdcp_stats_tx_aiat_tmp_w[mod][uid][i] = 0;
Pdcp_stats_tx_iat[mod][uid][i] = 0;
-
Pdcp_stats_rx[mod][uid][i] = 0;
Pdcp_stats_rx_w[mod][uid][i] = 0;
Pdcp_stats_rx_tmp_w[mod][uid][i] = 0;
@@ -2186,6 +2136,16 @@ rrc_pdcp_config_req (
}
}
+pdcp_data_ind_func_t get_pdcp_data_ind_func() {
+ return pdcp_params.pdcp_data_ind_func;
+}
+
+void pdcp_set_rlc_funcptr(send_rlc_data_req_func_t send_rlc_data_req,
+ pdcp_data_ind_func_t pdcp_data_ind) {
+ pdcp_params.send_rlc_data_req_func = send_rlc_data_req;
+ pdcp_params.pdcp_data_ind_func = pdcp_data_ind;
+}
+
uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
/* temporary enforce netlink when UE_NAS_USE_TUN is set,
this is while switching from noS1 as build option
@@ -2203,10 +2163,11 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
nas_getparams();
if(UE_NAS_USE_TUN) {
- netlink_init_tun("ue");
+ int num_if = (NFAPI_MODE == NFAPI_UE_STUB_PNF || IS_SOFTMODEM_SIML1 )?MAX_NUMBER_NETIF:1;
+ netlink_init_tun("ue",num_if);
LOG_I(PDCP, "UE pdcp will use tun interface\n");
} else if(ENB_NAS_USE_TUN) {
- netlink_init_tun("enb");
+ netlink_init_tun("enb",1);
nas_config(1, 1, 1, "enb");
LOG_I(PDCP, "ENB pdcp will use tun interface\n");
} else {
@@ -2215,6 +2176,8 @@ uint64_t pdcp_module_init( uint64_t pdcp_optmask ) {
}
}
+ /* default interface with rlc (will be modified if CU) */
+ pdcp_set_rlc_funcptr((send_rlc_data_req_func_t)rlc_data_req, (pdcp_data_ind_func_t) pdcp_data_ind);
return pdcp_params.optmask ;
}
@@ -2301,6 +2264,7 @@ void pdcp_layer_init(void)
memset(pdcp_enb, 0, sizeof(pdcp_enb_t));
memset(Pdcp_stats_tx_window_ms, 0, sizeof(Pdcp_stats_tx_window_ms));
memset(Pdcp_stats_rx_window_ms, 0, sizeof(Pdcp_stats_rx_window_ms));
+
for (i = 0; i < MAX_eNB; i++) {
for (j = 0; j < MAX_MOBILES_PER_ENB; j++) {
Pdcp_stats_tx_window_ms[i][j]=100;
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
index ce62893170..305b8ab2b4 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h
@@ -26,7 +26,7 @@
* \version 1.0
*/
-/** @defgroup _pdcp PDCP
+/** @defgroup _pdcp PDCP
* @ingroup _oai2
* @{
*/
@@ -51,6 +51,17 @@
#include "LTE_PMCH-InfoList-r9.h"
#endif
+typedef rlc_op_status_t (*send_rlc_data_req_func_t)(const protocol_ctxt_t *const,
+ const srb_flag_t, const MBMS_flag_t,
+ const rb_id_t, const mui_t,
+ confirm_t, sdu_size_t, mem_block_t *,const uint32_t *const, const uint32_t *const);
+typedef boolean_t (*pdcp_data_ind_func_t)( const protocol_ctxt_t *, const srb_flag_t,
+ const MBMS_flag_t, const rb_id_t, const sdu_size_t,
+ mem_block_t *,const uint32_t *const, const uint32_t *const);
+/* maximum number of tun interfaces that will be created to emulates UEs */
+/* UEs beyond that will be multiplexed on the same tun */
+#define MAX_NUMBER_NETIF 16
+
#define PDCP_USE_NETLINK_BIT (1<< 11)
#define LINK_ENB_PDCP_TO_IP_DRIVER_BIT (1<< 13)
#define LINK_ENB_PDCP_TO_GTPV1U_BIT (1<< 14)
@@ -58,8 +69,12 @@
#define ENB_NAS_USE_TUN_BIT (1<< 16)
typedef struct {
uint64_t optmask;
+ send_rlc_data_req_func_t send_rlc_data_req_func;
+ pdcp_data_ind_func_t pdcp_data_ind_func;
} pdcp_params_t;
+
+
#define PDCP_USE_NETLINK ( get_pdcp_optmask() & PDCP_USE_NETLINK_BIT)
#define LINK_ENB_PDCP_TO_IP_DRIVER ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_IP_DRIVER_BIT)
#define LINK_ENB_PDCP_TO_GTPV1U ( get_pdcp_optmask() & LINK_ENB_PDCP_TO_GTPV1U_BIT)
@@ -76,8 +91,8 @@ extern int pdcp_instance_cnt;
#define PROTOCOL_PDCP_CTXT_FMT PROTOCOL_CTXT_FMT"[%s %02u] "
#define PROTOCOL_PDCP_CTXT_ARGS(CTXT_Pp, pDCP_Pp) PROTOCOL_CTXT_ARGS(CTXT_Pp),\
- (pDCP_Pp->is_srb) ? "SRB" : "DRB",\
- pDCP_Pp->rb_id
+ (pDCP_Pp->is_srb) ? "SRB" : "DRB",\
+ pDCP_Pp->rb_id
int init_pdcp_thread(void);
void cleanup_pdcp_thread(void);
@@ -121,12 +136,12 @@ typedef struct pdcp_enb_s {
uint16_t uid[MAX_MOBILES_PER_ENB];
rnti_t rnti[MAX_MOBILES_PER_ENB];
uint16_t num_ues;
-
+
uint64_t sfn;
frame_t frame;
sub_frame_t subframe;
-
-} pdcp_enb_t;
+
+} pdcp_enb_t;
pdcp_enb_t pdcp_enb[MAX_NUM_CCs];
@@ -151,7 +166,7 @@ typedef struct pdcp_s {
boolean_t is_ue;
boolean_t is_srb;
- /* Configured security algorithms */
+ /* Configured security algorithms */
uint8_t cipheringAlgorithm;
uint8_t integrityProtAlgorithm;
@@ -202,10 +217,6 @@ typedef struct pdcp_s {
* which is not also a valid sequence number
*/
short int first_missing_pdu;
- /*
- * decipher using a different rx_hfn
- */
-
} pdcp_t;
@@ -239,13 +250,13 @@ typedef struct pdcp_mbms_s {
*/
boolean_t pdcp_data_req(
protocol_ctxt_t *ctxt_pP,
- const srb_flag_t srb_flagP,
- const rb_id_t rb_id,
- const mui_t muiP,
- const confirm_t confirmP, \
- const sdu_size_t sdu_buffer_size,
+ const srb_flag_t srb_flagP,
+ const rb_id_t rb_id,
+ const mui_t muiP,
+ const confirm_t confirmP, \
+ const sdu_size_t sdu_buffer_size,
unsigned char *const sdu_buffer,
- const pdcp_transmission_mode_t mode
+ const pdcp_transmission_mode_t mode
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
,const uint32_t *const sourceL2Id
,const uint32_t *const destinationL2Id
@@ -267,10 +278,10 @@ boolean_t pdcp_data_req(
*/
boolean_t pdcp_data_ind(
const protocol_ctxt_t *const ctxt_pP,
- const srb_flag_t srb_flagP,
- const MBMS_flag_t MBMS_flagP,
- const rb_id_t rb_id,
- const sdu_size_t sdu_buffer_size,
+ const srb_flag_t srb_flagP,
+ const MBMS_flag_t MBMS_flagP,
+ const rb_id_t rb_id,
+ const sdu_size_t sdu_buffer_size,
mem_block_t *const sdu_buffer);
/*! \fn void rrc_pdcp_config_req(const protocol_ctxt_t* const ,uint32_t,rb_id_t,uint8_t)
@@ -285,10 +296,10 @@ boolean_t pdcp_data_ind(
*/
void rrc_pdcp_config_req (
const protocol_ctxt_t *const ctxt_pP,
- const srb_flag_t srb_flagP,
- const uint32_t actionP,
- const rb_id_t rb_idP,
- const uint8_t security_modeP);
+ const srb_flag_t srb_flagP,
+ const uint32_t actionP,
+ const rb_id_t rb_idP,
+ const uint8_t security_modeP);
/*! \fn bool rrc_pdcp_config_asn1_req (const protocol_ctxt_t* const , SRB_ToAddModList_t* srb2add_list, DRB_ToAddModList_t* drb2add_list, DRB_ToReleaseList_t* drb2release_list)
* \brief Function for RRC to configure a Radio Bearer.
@@ -306,17 +317,17 @@ void rrc_pdcp_config_req (
*/
boolean_t rrc_pdcp_config_asn1_req (
const protocol_ctxt_t *const ctxt_pP,
- LTE_SRB_ToAddModList_t *const srb2add_list,
- LTE_DRB_ToAddModList_t *const drb2add_list,
- LTE_DRB_ToReleaseList_t *const drb2release_list,
- const uint8_t security_modeP,
- uint8_t *const kRRCenc,
- uint8_t *const kRRCint,
- uint8_t *const kUPenc
+ LTE_SRB_ToAddModList_t *const srb2add_list,
+ LTE_DRB_ToAddModList_t *const drb2add_list,
+ LTE_DRB_ToReleaseList_t *const drb2release_list,
+ const uint8_t security_modeP,
+ uint8_t *const kRRCenc,
+ uint8_t *const kRRCint,
+ uint8_t *const kUPenc
#if (LTE_RRC_VERSION >= MAKE_VERSION(9, 0, 0))
- ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9
+ ,LTE_PMCH_InfoList_r9_t *pmch_InfoList_r9
#endif
- ,rb_id_t *const defaultDRB
+ ,rb_id_t *const defaultDRB
);
/*! \fn boolean_t pdcp_config_req_asn1 (const protocol_ctxt_t* const ctxt_pP, srb_flag_t srb_flagP, uint32_t action, rb_id_t rb_id, uint8_t rb_sn, uint8_t rb_report, uint16_t header_compression_profile, uint8_t security_mode)
@@ -341,20 +352,20 @@ boolean_t rrc_pdcp_config_asn1_req (
*/
boolean_t pdcp_config_req_asn1 (
const protocol_ctxt_t *const ctxt_pP,
- pdcp_t *const pdcp_pP,
- const srb_flag_t srb_flagP,
- const rlc_mode_t rlc_mode,
- const uint32_t action,
- const uint16_t lc_id,
- const uint16_t mch_id,
- const rb_id_t rb_id,
- const uint8_t rb_sn,
- const uint8_t rb_report,
- const uint16_t header_compression_profile,
- const uint8_t security_mode,
- uint8_t *const kRRCenc,
- uint8_t *const kRRCint,
- uint8_t *const kUPenc);
+ pdcp_t *const pdcp_pP,
+ const srb_flag_t srb_flagP,
+ const rlc_mode_t rlc_mode,
+ const uint32_t action,
+ const uint16_t lc_id,
+ const uint16_t mch_id,
+ const rb_id_t rb_id,
+ const uint8_t rb_sn,
+ const uint8_t rb_report,
+ const uint16_t header_compression_profile,
+ const uint8_t security_mode,
+ uint8_t *const kRRCenc,
+ uint8_t *const kRRCint,
+ uint8_t *const kUPenc);
/*! \fn void pdcp_add_UE(const protocol_ctxt_t* const ctxt_pP)
* \brief Function (for RRC) to add a new UE in PDCP module
@@ -362,9 +373,9 @@ boolean_t pdcp_config_req_asn1 (
* \return A status about the processing, OK or error code.
*/
void pdcp_add_UE(const protocol_ctxt_t *const ctxt_pP);
-
+
/*! \fn boolean_t pdcp_remove_UE(const protocol_ctxt_t* const ctxt_pP)
-* \brief Function for RRC to remove UE from PDCP module hashtable
+* \brief Function for RRC to remove UE from PDCP module hashtable
* \param[in] ctxt_pP Running context.
* \return A status about the processing, OK or error code.
*/
@@ -401,7 +412,9 @@ int pdcp_fifo_flush_sdus ( const protocol_ctxt_t *const ct
int pdcp_fifo_read_input_sdus_remaining_bytes ( const protocol_ctxt_t *const ctxt_pP);
int pdcp_fifo_read_input_sdus ( const protocol_ctxt_t *const ctxt_pP);
void pdcp_fifo_read_input_sdus_from_otg ( const protocol_ctxt_t *const ctxt_pP);
-
+void pdcp_set_rlc_funcptr(send_rlc_data_req_func_t send_rlc_data_req,
+ pdcp_data_ind_func_t pdcp_data_ind);
+pdcp_data_ind_func_t get_pdcp_data_ind_func(void);
//-----------------------------------------------------------------------------
/*
@@ -449,26 +462,26 @@ struct sockaddr_in pdcp_sin;
void pdcp_pc5_socket_init(void);
typedef struct {
- rb_id_t rb_id;
- sdu_size_t data_size;
- signed int inst;
- ip_traffic_type_t traffic_type;
- uint32_t sourceL2Id;
- uint32_t destinationL2Id;
+ rb_id_t rb_id;
+ sdu_size_t data_size;
+ signed int inst;
+ ip_traffic_type_t traffic_type;
+ uint32_t sourceL2Id;
+ uint32_t destinationL2Id;
} __attribute__((__packed__)) pc5s_header_t;
//new PC5S-message
typedef struct {
- unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE];
+ unsigned char bytes[PC5_SIGNALLING_PAYLOAD_SIZE];
} __attribute__((__packed__)) PC5SignallingMessage ;
//example of PC5-S messages
typedef struct {
- pc5s_header_t pc5s_header;
- union {
- uint8_t status;
- PC5SignallingMessage pc5_signalling_message;
- } pc5sPrimitive;
+ pc5s_header_t pc5s_header;
+ union {
+ uint8_t status;
+ PC5SignallingMessage pc5_signalling_message;
+ } pc5sPrimitive;
} __attribute__((__packed__)) sidelink_pc5s_element;
@@ -513,33 +526,33 @@ sdu_size_t pdcp_input_sdu_size_read;
sdu_size_t pdcp_input_sdu_remaining_size_to_read;
#define PDCP_COLL_KEY_VALUE(mODULE_iD, rNTI, iS_eNB, rB_iD, iS_sRB) \
- ((hash_key_t)mODULE_iD | \
- (((hash_key_t)(rNTI)) << 8) | \
- (((hash_key_t)(iS_eNB)) << 24) | \
- (((hash_key_t)(rB_iD)) << 25) | \
- (((hash_key_t)(iS_sRB)) << 33) | \
- (((hash_key_t)(0x55)) << 34))
+ ((hash_key_t)mODULE_iD | \
+ (((hash_key_t)(rNTI)) << 8) | \
+ (((hash_key_t)(iS_eNB)) << 24) | \
+ (((hash_key_t)(rB_iD)) << 25) | \
+ (((hash_key_t)(iS_sRB)) << 33) | \
+ (((hash_key_t)(0x55)) << 34))
// hash key to the same PDCP as indexed by PDCP_COLL_KEY_VALUE(... rB_iD, iS_sRB=0) where rB_iD
// is the default DRB ID. The hidden code 0x55 indicates the key is indexed by (rB_iD,is_sRB)
// whereas the hidden code 0xaa indicates the key is for default DRB only
#define PDCP_COLL_KEY_DEFAULT_DRB_VALUE(mODULE_iD, rNTI, iS_eNB) \
- ((hash_key_t)mODULE_iD | \
- (((hash_key_t)(rNTI)) << 8) | \
- (((hash_key_t)(iS_eNB)) << 24) | \
- (((hash_key_t)(0xff)) << 25) | \
- (((hash_key_t)(0x00)) << 33) | \
- (((hash_key_t)(0xaa)) << 34))
+ ((hash_key_t)mODULE_iD | \
+ (((hash_key_t)(rNTI)) << 8) | \
+ (((hash_key_t)(iS_eNB)) << 24) | \
+ (((hash_key_t)(0xff)) << 25) | \
+ (((hash_key_t)(0x00)) << 33) | \
+ (((hash_key_t)(0xaa)) << 34))
// service id max val is maxServiceCount = 16 (asn1_constants.h)
#define PDCP_COLL_KEY_MBMS_VALUE(mODULE_iD, rNTI, iS_eNB, sERVICE_ID, sESSION_ID) \
- ((hash_key_t)mODULE_iD | \
- (((hash_key_t)(rNTI)) << 8) | \
- (((hash_key_t)(iS_eNB)) << 24) | \
- (((hash_key_t)(sERVICE_ID)) << 32) | \
- (((hash_key_t)(sESSION_ID)) << 37) | \
- (((hash_key_t)(0x0000000000000001)) << 63))
+ ((hash_key_t)mODULE_iD | \
+ (((hash_key_t)(rNTI)) << 8) | \
+ (((hash_key_t)(iS_eNB)) << 24) | \
+ (((hash_key_t)(sERVICE_ID)) << 32) | \
+ (((hash_key_t)(sESSION_ID)) << 37) | \
+ (((hash_key_t)(0x0000000000000001)) << 63))
extern hash_table_t *pdcp_coll_p;
diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
index 7324a7c7ea..17d386343b 100644
--- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
+++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c
@@ -54,6 +54,7 @@ extern int otg_enabled;
#include "UTIL/OCG/OCG_extern.h"
#include "common/utils/LOG/log.h"
#include "UTIL/OTG/otg_tx.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "UTIL/FIFO/pad_list.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "platform_constants.h"
@@ -80,7 +81,7 @@ extern struct msghdr nas_msg_tx;
extern struct msghdr nas_msg_rx;
-extern uint8_t nfapi_mode;
+
#ifdef UESIM_EXPANSION
extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX];
#endif
@@ -106,19 +107,19 @@ void debug_pdcp_pc5s_sdu(sidelink_pc5s_element *sl_pc5s_msg, char *title) {
//-----------------------------------------------------------------------------
int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) {
mem_block_t *sdu_p;
- int pdcp_nb_sdu_sent = 0;
+ int pdcp_nb_sdu_sent = 0;
int ret=0;
while ((sdu_p = list_get_head (&pdcp_sdu_list)) != NULL && ((pdcp_data_ind_header_t *)(sdu_p->data))->inst == ctxt_pP->module_id) {
((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
- int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id;
+ int rb_id = ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id;
int sizeToWrite= sizeof (pdcp_data_ind_header_t) +
((pdcp_data_ind_header_t *) sdu_p->data)->data_size;
- if (rb_id == 10) { //hardcoded for PC5-Signaling
+ if (rb_id == 10) { //hardcoded for PC5-Signaling
if( LOG_DEBUGFLAG(DEBUG_PDCP) ) {
debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)&(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),
- "pdcp_fifo_flush_sdus received aPC5S message");
+ "pdcp_fifo_flush_sdus sends a aPC5S message");
}
ret = sendto(pdcp_pc5_sockfd, &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]),
@@ -134,52 +135,48 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t *const ctxt_pP) {
} // PDCP_USE_NETLINK
AssertFatal(ret >= 0,"[PDCP_FIFOS] pdcp_fifo_flush_sdus (errno: %d %s)\n", errno, strerror(errno));
- list_remove_head (&pdcp_sdu_list);
- free_mem_block (sdu_p, __func__);
+ list_remove_head (&pdcp_sdu_list);
+ free_mem_block (sdu_p, __func__);
pdcp_nb_sdu_sent ++;
- }
+ }
- return pdcp_nb_sdu_sent;
+ return pdcp_nb_sdu_sent;
}
-//-----------------------------------------------------------------------------
-int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) {
- pdcp_data_req_header_t pdcp_read_header_g;
-
- if (UE_NAS_USE_TUN || ENB_NAS_USE_TUN) {
+int pdcp_fifo_read_input_sdus_fromtun (const protocol_ctxt_t *const ctxt_pP) {
protocol_ctxt_t ctxt = *ctxt_pP;
hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
hashtable_rc_t h_rc;
- pdcp_t *pdcp_p = NULL;
+ pdcp_t *pdcp_p = NULL;
int len;
rb_id_t rab_id = DEFAULT_RAB_ID;
do {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 );
- len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
+ len = read(UE_NAS_USE_TUN?nas_sock_fd[ctxt_pP->module_id]:nas_sock_fd[0], &nl_rx_buf, NL_MAX_PAYLOAD);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
if (len<=0) continue;
- if (UE_NAS_USE_TUN) {
- key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
+ if (UE_NAS_USE_TUN) {
+ key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
- } else {
- ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0];
- ctxt.enb_flag=ENB_FLAG_YES;
- ctxt.module_id=0;
- key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_YES);
- h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
- }
+ } else { // => ENB_NAS_USE_TUN
+ ctxt.rnti=pdcp_eNB_UE_instance_to_rnti[0];
+ ctxt.enb_flag=ENB_FLAG_YES;
+ ctxt.module_id=0;
+ key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_YES);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+ }
- LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
- ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
+ LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
+ ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
if (h_rc == HASH_TABLE_OK) {
LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n",
ctxt.frame, ctxt.instance, len, rab_id);
- LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %04x][RB %u]\n",
+ LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %04x][RB %u]\n",
ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id,
ctxt.rnti, rab_id);
MSC_LOG_RX_MESSAGE((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
@@ -195,15 +192,15 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) {
);
} else {
MSC_LOG_RX_DISCARDED_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,
- 0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- ctxt.instance, rab_id, rab_id, len);
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ ctxt.instance, rab_id, rab_id, len);
LOG_D(PDCP,
- "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %04x][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
+ "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %04x][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id,
ctxt.rnti, rab_id, key);
}
@@ -211,307 +208,149 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 );
return len;
- } else { /* UE_NAS_USE_TUN */
- if (PDCP_USE_NETLINK) {
- protocol_ctxt_t ctxt_cpy = *ctxt_pP;
- protocol_ctxt_t ctxt;
- hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
- hashtable_rc_t h_rc;
- struct pdcp_netlink_element_s *data_p = NULL;
- /* avoid gcc warnings */
- (void)data_p;
- module_id_t ue_id = 0;
- pdcp_t *pdcp_p = NULL;
- //TTN for D2D (PC5S)
- int prose_addr_len;
- char send_buf[BUFSIZE], receive_buf[BUFSIZE];
- //int optval;
- int bytes_received;
- sidelink_pc5s_element *sl_pc5s_msg_recv = NULL;
- sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
- //uint32_t sourceL2Id;
- //uint32_t groupL2Id;
- //module_id_t module_id = 0;
- pc5s_header_t *pc5s_header;
- static unsigned char pdcp_read_state_g =0;
- int len = 1;
- int msg_len;
- rb_id_t rab_id = 0;
- int rlc_data_req_flag = 3;
- //TTN for D2D (PC5S)
- prose_addr_len = sizeof(prose_pdcp_addr);
- // receive a message from ProSe App
- memset(receive_buf, 0, BUFSIZE);
- bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
- (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len);
+}
- // if (bytes_received < 0){
- // LOG_E(RRC, "ERROR: Failed to receive from ProSe App\n");
- // exit(EXIT_FAILURE);
- // }
- if (bytes_received > 0) {
- pc5s_header = calloc(1, sizeof(pc5s_header_t));
- memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t));
+int pdcp_fifo_read_input_sdus_fromnetlinksock (const protocol_ctxt_t *const ctxt_pP) {
+ int len = 1;
+ int rlc_data_req_flag = 3;
- if (pc5s_header->traffic_type == TRAFFIC_PC5S_SESSION_INIT) {
- //send reply to ProSe app
- LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n");
- memset(send_buf, 0, BUFSIZE);
- sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element));
- sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT;
- sl_pc5s_msg_send->pc5sPrimitive.status = 1;
- memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element));
- int prose_addr_len = sizeof(prose_pdcp_addr);
- int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len);
+ while ((len > 0) && (rlc_data_req_flag !=0)) {
+ pdcp_data_req_header_t pdcp_read_header_g;
+ protocol_ctxt_t ctxt_cpy = *ctxt_pP;
+ protocol_ctxt_t ctxt;
+ hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
+ hashtable_rc_t h_rc;
+ module_id_t ue_id = 0;
+ pdcp_t *pdcp_p = NULL;
+ static unsigned char pdcp_read_state_g =0;
+ rb_id_t rab_id = 0;
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 );
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 );
+ len = recvmsg(nas_sock_fd[0], &nas_msg_rx, 0);
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
- if (bytes_sent < 0) {
- LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
- exit(EXIT_FAILURE);
- }
- } else if (pc5s_header->traffic_type == TRAFFIC_PC5S_SIGNALLING) { //if containing PC5-S message -> send to other UE
- LOG_D(PDCP,"Received PC5-S message ... send to the other UE\n");
- LOG_D(PDCP,"Received PC5-S message, traffic_type: %d)\n", pc5s_header->traffic_type);
- LOG_D(PDCP,"Received PC5-S message, rbid: %d)\n", pc5s_header->rb_id);
- LOG_D(PDCP,"Received PC5-S message, data_size: %d)\n", pc5s_header->data_size);
- LOG_D(PDCP,"Received PC5-S message, inst: %d)\n", pc5s_header->inst);
- LOG_D(PDCP,"Received PC5-S message,sourceL2Id: 0x%08x\n)\n", pc5s_header->sourceL2Id);
- LOG_D(PDCP,"Received PC5-S message,destinationL1Id: 0x%08x\n)\n", pc5s_header->destinationL2Id);
-#ifdef OAI_EMU
+ if (len > 0) {
+ for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf;
+ NLMSG_OK (nas_nlh_rx, len);
+ nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) {
+ if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) {
+ LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n");
+ //return;
+ }
- // overwrite function input parameters, because only one netlink socket for all instances
- if (pc5s_header->inst < oai_emulation.info.nb_enb_local) {
- ctxt.frame = ctxt_cpy.frame;
- ctxt.enb_flag = ENB_FLAG_YES;
- ctxt.module_id = pc5s_header.inst + oai_emulation.info.first_enb_local;
- ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pc5s_header->rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local];
- rab_id = pc5s_header->rb_id % LTE_maxDRB;
- } else {
- ctxt.frame = ctxt_cpy.frame;
- ctxt.enb_flag = ENB_FLAG_NO;
- ctxt.module_id = pc5s_header->inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local;
- ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
- rab_id = pc5s_header->rb_id % LTE_maxDRB;
- }
+ if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) {
+ LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n");
+ }
- CHECK_CTXT_ARGS(&ctxt);
- AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB);
- /*LGpdcp_read_header.inst = (pc5s_header.inst >= oai_emulation.info.nb_enb_local) ? \
- pc5s_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
- pc5s_header.inst + oai_emulation.info.first_enb_local;*/
-#else // OAI_EMU
- /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
- // pc5s_header.inst = 0;
- //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
- ctxt.frame = ctxt_cpy.frame;
- ctxt.enb_flag = ctxt_cpy.enb_flag;
- LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id);
+ if (pdcp_read_state_g == 0) {
+ if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) {
+ pdcp_read_state_g = 1; //get
+ memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t));
+ LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n",
+ pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id );
+ } else {
+ LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n",
+ nas_nlh_rx->nlmsg_len);
+ }
+ } else {
+ pdcp_read_state_g = 0;
+ // print_active_requests()
+ LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n",
+ nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr));
+ /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
+ // pdcp_read_header_g.inst = 0;
+ //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
+ ctxt.frame = ctxt_cpy.frame;
+ ctxt.enb_flag = ctxt_cpy.enb_flag;
+ LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id,
+ pdcp_read_header_g.destinationL2Id);
- if (ctxt_cpy.enb_flag) {
- ctxt.module_id = 0;
- rab_id = pc5s_header->rb_id % LTE_maxDRB;
- ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index];
- } else {
- ctxt.module_id = 0;
- rab_id = pc5s_header->rb_id % LTE_maxDRB;
- ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
- }
-
-#endif
-
- //UE
- if (!ctxt.enb_flag) {
- if (rab_id != 0) {
- if (rab_id == UE_IP_DEFAULT_RAB_ID) {
- LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
- ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
- key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
- h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
- LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n",
- (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
- } else {
- rab_id = rab_id % LTE_maxDRB;
- LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
- ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
- key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
- h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
- LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n",
- (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
- }
-
- if (h_rc == HASH_TABLE_OK) {
- rab_id = pdcp_p->rb_id;
- LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n",
- ctxt.frame,
- pc5s_header->inst,
- bytes_received,
- pc5s_header->rb_id);
- LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
- ctxt.frame,
- pc5s_header->inst,
- pc5s_header->rb_id,
- pc5s_header->data_size,
- ctxt.module_id,
- ctxt.rnti,
- rab_id);
- MSC_LOG_RX_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,
- 0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pc5s_header->inst,
- pc5s_header->rb_id,
- rab_id,
- pc5s_header->data_size);
- pdcp_data_req(
- &ctxt,
- SRB_FLAG_NO,
- rab_id,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pc5s_header->data_size,
- (unsigned char *)receive_buf,
- PDCP_TRANSMISSION_MODE_DATA,
- &pc5s_header->sourceL2Id,
- &pc5s_header->destinationL2Id
- );
- } else {
- MSC_LOG_RX_DISCARDED_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,
- 0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pc5s_header->inst,
- pc5s_header->rb_id,
- rab_id,
- pc5s_header->data_size);
- LOG_D(PDCP,
- "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
- ctxt.frame,
- pc5s_header->inst,
- pc5s_header->rb_id,
- pc5s_header->data_size,
- ctxt.module_id,
- ctxt.rnti,
- rab_id,
- key);
- }
- } else { //if (rab_id == 0)
- LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
- LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
- ctxt.frame,
- pc5s_header->inst,
- pc5s_header->rb_id,
- pc5s_header->data_size,
- ctxt.module_id,
- ctxt.rnti,
- DEFAULT_RAB_ID);
- MSC_LOG_RX_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pc5s_header->inst,
- pc5s_header->rb_id,
- DEFAULT_RAB_ID,
- pc5s_header->data_size);
- pdcp_data_req (
- &ctxt,
- SRB_FLAG_NO,
- DEFAULT_RAB_ID,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pc5s_header->data_size,
- (unsigned char *)receive_buf,
- PDCP_TRANSMISSION_MODE_DATA,
- &pc5s_header->sourceL2Id,
- &pc5s_header->destinationL2Id
- );
- }
- }
-
- free (sl_pc5s_msg_recv);
- free (sl_pc5s_msg_send);
- }
- }
-
- while ((len > 0) && (rlc_data_req_flag !=0)) {
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 );
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 );
- len = recvmsg(nas_sock_fd[0], &nas_msg_rx, 0);
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 );
-
- if (len<=0) {
- // nothing in pdcp NAS socket
- //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len);
- } else {
- msg_len = len;
-
- for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf;
- NLMSG_OK (nas_nlh_rx, msg_len);
- nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, msg_len)) {
- if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) {
- LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n");
- //return;
- }
-
- if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) {
- LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n");
- }
-
- if (pdcp_read_state_g == 0) {
- if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) {
- pdcp_read_state_g = 1; //get
- memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t));
- LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d, source L2Id 0x%08x, destination L2Id 0x%08x\n",
- pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size,pdcp_read_header_g.sourceL2Id, pdcp_read_header_g.destinationL2Id );
- } else {
- LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n",
- nas_nlh_rx->nlmsg_len);
- }
- } else {
- pdcp_read_state_g = 0;
- // print_active_requests()
- LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %zu\n",
- nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr));
-#ifdef OAI_EMU
-
- // overwrite function input parameters, because only one netlink socket for all instances
- if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) {
- ctxt.frame = ctxt_cpy.frame;
- ctxt.enb_flag = ENB_FLAG_YES;
- ctxt.module_id = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;
- ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / LTE_maxDRB + oai_emulation.info.first_ue_local];
- rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB;
- } else {
- ctxt.frame = ctxt_cpy.frame;
- ctxt.enb_flag = ENB_FLAG_NO;
- ctxt.module_id = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local;
- ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
- rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB;
- }
-
- CHECK_CTXT_ARGS(&ctxt);
- AssertFatal (rab_id < LTE_maxDRB, "RB id is too high (%u/%d)!\n", rab_id, LTE_maxDRB);
-#else // OAI_EMU
- /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
- // pdcp_read_header_g.inst = 0;
- //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
- ctxt.frame = ctxt_cpy.frame;
- ctxt.enb_flag = ctxt_cpy.enb_flag;
- LOG_D(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d, source L2Id = 0x%08x, destination L2Id = 0x%08x \n", pdcp_read_header_g.rb_id, pdcp_read_header_g.sourceL2Id,
- pdcp_read_header_g.destinationL2Id);
-
- if (ctxt_cpy.enb_flag) {
+ if (ctxt.enb_flag) {
ctxt.module_id = 0;
rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB;
ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_read_header_g.rb_id / LTE_maxDRB];
- } else {
- if (nfapi_mode == 3) {
+
+ if (rab_id != 0) {
+ rab_id = rab_id % LTE_maxDRB;
+ key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+
+ if (h_rc == HASH_TABLE_OK) {
+ LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ len,
+ nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
+ pdcp_read_header_g.rb_id);
+ MSC_LOG_RX_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ rab_id,
+ pdcp_read_header_g.data_size);
+ LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n",
+ ctxt_cpy.frame,
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ pdcp_read_header_g.data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ rab_id);
+ pdcp_data_req(&ctxt,
+ SRB_FLAG_NO,
+ rab_id,
+ RLC_MUI_UNDEFINED,
+ RLC_SDU_CONFIRM_NO,
+ pdcp_read_header_g.data_size,
+ (unsigned char *)NLMSG_DATA(nas_nlh_rx),
+ PDCP_TRANSMISSION_MODE_DATA
+ ,NULL, NULL
+ );
+ } else {
+ LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ pdcp_read_header_g.data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ rab_id);
+ }
+ } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast
+ // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs
+ //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES
+ for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) {
+ if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) {
+ ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id];
+ LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ pdcp_read_header_g.data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ DEFAULT_RAB_ID);
+ pdcp_data_req (
+ &ctxt,
+ SRB_FLAG_NO,
+ DEFAULT_RAB_ID,
+ RLC_MUI_UNDEFINED,
+ RLC_SDU_CONFIRM_NO,
+ pdcp_read_header_g.data_size,
+ (unsigned char *)NLMSG_DATA(nas_nlh_rx),
+ PDCP_TRANSMISSION_MODE_DATA
+ ,NULL, NULL
+ );
+ }
+ }
+ }
+ } else { // ctxt.enb_flag => UE
+ if (NFAPI_MODE == NFAPI_UE_STUB_PNF) {
#ifdef UESIM_EXPANSION
ctxt.module_id = inst_pdcp_list[pdcp_read_header_g.inst];
#else
@@ -523,249 +362,336 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) {
rab_id = pdcp_read_header_g.rb_id % LTE_maxDRB;
ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
- }
-#endif
-
- if (ctxt.enb_flag) {
if (rab_id != 0) {
+ if (rab_id == UE_IP_DEFAULT_RAB_ID) {
+ LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
+ ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
+ key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+ LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n",
+ (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
+ } else {
+ rab_id = rab_id % LTE_maxDRB;
+ LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
+ ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
+ key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+ LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n",
+ (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
+ }
+
+ if (h_rc == HASH_TABLE_OK) {
+ rab_id = pdcp_p->rb_id;
+ LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ len,
+ nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
+ pdcp_read_header_g.rb_id);
+ LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ pdcp_read_header_g.data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ rab_id);
+ MSC_LOG_RX_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ rab_id,
+ pdcp_read_header_g.data_size);
+ pdcp_data_req(
+ &ctxt,
+ SRB_FLAG_NO,
+ rab_id,
+ RLC_MUI_UNDEFINED,
+ RLC_SDU_CONFIRM_NO,
+ pdcp_read_header_g.data_size,
+ (unsigned char *)NLMSG_DATA(nas_nlh_rx),
+ PDCP_TRANSMISSION_MODE_DATA,
+ (NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.sourceL2Id,
+ (NFAPI_MODE == NFAPI_UE_STUB_PNF)?NULL:&pdcp_read_header_g.destinationL2Id
+ );
+ } else { /* else of h_rc == HASH_TABLE_OK */
+ MSC_LOG_RX_DISCARDED_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ rab_id,
+ pdcp_read_header_g.data_size);
+ LOG_D(PDCP,
+ "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ pdcp_read_header_g.data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ rab_id,
+ key);
+ } /* h_rc != HASH_TABLE_OK */
+ } else {/* else of rab_id != 0 */
+ LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
+ LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
+ ctxt.frame,
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ pdcp_read_header_g.data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ DEFAULT_RAB_ID);
+ MSC_LOG_RX_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pdcp_read_header_g.inst,
+ pdcp_read_header_g.rb_id,
+ DEFAULT_RAB_ID,
+ pdcp_read_header_g.data_size);
+ pdcp_data_req (
+ &ctxt,
+ SRB_FLAG_NO,
+ DEFAULT_RAB_ID,
+ RLC_MUI_UNDEFINED,
+ RLC_SDU_CONFIRM_NO,
+ pdcp_read_header_g.data_size,
+ (unsigned char *)NLMSG_DATA(nas_nlh_rx),
+ PDCP_TRANSMISSION_MODE_DATA,
+ (NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.sourceL2Id,
+ (NFAPI_MODE == NFAPI_UE_STUB_PNF) ? NULL :&pdcp_read_header_g.destinationL2Id
+ );
+ } /* rab_id == 0 */
+ } /*pdcp_read_state_g != 0 */
+ } /* UE */
+ } /* for loop on netlink buffers */
+
+ return len;
+ } /* len > 0 */
+
+ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 );
+ } /* while loop on reading from netlink socket */
+
+ return 0;
+} /* pdcp_fifo_read_input_sdus_fromnetlinksock */
+
+void pdcp_fifo_read_input_sdus_frompc5s (const protocol_ctxt_t *const ctxt_pP) {
+ protocol_ctxt_t ctxt_cpy = *ctxt_pP;
+ protocol_ctxt_t ctxt;
+ hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE;
+ hashtable_rc_t h_rc;
+ struct pdcp_netlink_element_s *data_p = NULL;
+ /* avoid gcc warnings */
+ (void)data_p;
+ pdcp_t *pdcp_p = NULL;
+ //TTN for D2D (PC5S)
+ int prose_addr_len;
+ char send_buf[BUFSIZE], receive_buf[BUFSIZE];
+ //int optval;
+ int bytes_received;
+ sidelink_pc5s_element *sl_pc5s_msg_send = NULL;
+ pc5s_header_t *pc5s_header;
+ rb_id_t rab_id = 0;
+ //TTN for D2D (PC5S)
+ // receive a message from ProSe App
+ memset(receive_buf, 0, BUFSIZE);
+ bytes_received = recvfrom(pdcp_pc5_sockfd, receive_buf, BUFSIZE, 0,
+ (struct sockaddr *) &prose_pdcp_addr, (socklen_t *)&prose_addr_len);
+
+ if (bytes_received > 0) {
+ pc5s_header = calloc(1, sizeof(pc5s_header_t));
+ memcpy((void *)pc5s_header, (void *)receive_buf, sizeof(pc5s_header_t));
+
+ switch(pc5s_header->traffic_type) {
+ case TRAFFIC_PC5S_SESSION_INIT :
+ //send reply to ProSe app
+ LOG_D(PDCP,"Received a request to open PDCP socket and establish a new PDCP session ... send response to ProSe App \n");
+ memset(send_buf, 0, BUFSIZE);
+ sl_pc5s_msg_send = calloc(1, sizeof(sidelink_pc5s_element));
+ sl_pc5s_msg_send->pc5s_header.traffic_type = TRAFFIC_PC5S_SESSION_INIT;
+ sl_pc5s_msg_send->pc5sPrimitive.status = 1;
+ memcpy((void *)send_buf, (void *)sl_pc5s_msg_send, sizeof(sidelink_pc5s_element));
+ int prose_addr_len = sizeof(prose_pdcp_addr);
+ int bytes_sent = sendto(pdcp_pc5_sockfd, (char *)send_buf, sizeof(sidelink_pc5s_element), 0, (struct sockaddr *)&prose_pdcp_addr, prose_addr_len);
+ free (sl_pc5s_msg_send);
+
+ if (bytes_sent < 0) {
+ LOG_E(PDCP, "ERROR: Failed to send to ProSe App\n");
+ exit(EXIT_FAILURE);
+ }
+
+ break;
+
+ case TRAFFIC_PC5S_SIGNALLING: /* PC5-S message -> send to other UE */
+ if( LOG_DEBUGFLAG(DEBUG_PDCP) ) {
+ debug_pdcp_pc5s_sdu((sidelink_pc5s_element *)send_buf,
+ "pdcp_fifo_read_input_sdus received aPC5S message");
+ }
+
+ /* TODO: do we have to reset to 0 or not? not for a scenario with 1 UE at least */
+ // pc5s_header.inst = 0;
+ //#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
+ ctxt.frame = ctxt_cpy.frame;
+ ctxt.enb_flag = ctxt_cpy.enb_flag;
+ LOG_I(PDCP, "[PDCP] pc5s_header->rb_id = %d\n", pc5s_header->rb_id);
+
+ if (ctxt_cpy.enb_flag) {
+ ctxt.module_id = 0;
+ rab_id = pc5s_header->rb_id % LTE_maxDRB;
+ ctxt.rnti = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index];
+ } else {
+ ctxt.module_id = 0;
+ rab_id = pc5s_header->rb_id % LTE_maxDRB;
+ ctxt.rnti = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
+ }
+
+ //UE
+ if (!ctxt.enb_flag) {
+ if (rab_id != 0) {
+ if (rab_id == UE_IP_DEFAULT_RAB_ID) {
+ LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
+ ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
+ key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+ LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n",
+ (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
+ } else {
rab_id = rab_id % LTE_maxDRB;
+ LOG_I(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
+ ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
- h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
-
- if (h_rc == HASH_TABLE_OK) {
- LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- len,
- nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
- pdcp_read_header_g.rb_id);
- MSC_LOG_RX_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,
- 0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- rab_id,
- pdcp_read_header_g.data_size);
- LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n",
- ctxt_cpy.frame,
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- pdcp_read_header_g.data_size,
- ctxt.module_id,
- ctxt.rnti,
- rab_id);
- pdcp_data_req(&ctxt,
- SRB_FLAG_NO,
- rab_id,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pdcp_read_header_g.data_size,
- (unsigned char *)NLMSG_DATA(nas_nlh_rx),
- PDCP_TRANSMISSION_MODE_DATA
- ,NULL, NULL
- );
- } else {
- LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- pdcp_read_header_g.data_size,
- ctxt.module_id,
- ctxt.rnti,
- rab_id);
- }
- } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast
- // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs
- //#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES
- for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) {
- if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) {
- ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id];
- LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- pdcp_read_header_g.data_size,
- ctxt.module_id,
- ctxt.rnti,
- DEFAULT_RAB_ID);
- pdcp_data_req (
- &ctxt,
- SRB_FLAG_NO,
- DEFAULT_RAB_ID,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pdcp_read_header_g.data_size,
- (unsigned char *)NLMSG_DATA(nas_nlh_rx),
- PDCP_TRANSMISSION_MODE_DATA
- ,NULL, NULL
- );
- }
- }
- }
- } else { // enb_flag
- if (rab_id != 0) {
- if (rab_id == UE_IP_DEFAULT_RAB_ID) {
- LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
- ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
- key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
- h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
- LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n",
- (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
- } else {
- rab_id = rab_id % LTE_maxDRB;
- LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
- ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
- key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
- h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
- LOG_D(PDCP,"request key %x : (%d,%x,%d,%d)\n",
- (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
- }
-
- if (h_rc == HASH_TABLE_OK) {
- rab_id = pdcp_p->rb_id;
- LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %zu) on Rab %d \n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- len,
- nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
- pdcp_read_header_g.rb_id);
- LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- pdcp_read_header_g.data_size,
- ctxt.module_id,
- ctxt.rnti,
- rab_id);
- MSC_LOG_RX_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,
- 0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- rab_id,
- pdcp_read_header_g.data_size);
-
- if(nfapi_mode == 3) {
- pdcp_data_req(
- &ctxt,
- SRB_FLAG_NO,
- rab_id,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pdcp_read_header_g.data_size,
- (unsigned char *)NLMSG_DATA(nas_nlh_rx),
- PDCP_TRANSMISSION_MODE_DATA,
- NULL,
- NULL
- );
- } else {
- pdcp_data_req(
- &ctxt,
- SRB_FLAG_NO,
- rab_id,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pdcp_read_header_g.data_size,
- (unsigned char *)NLMSG_DATA(nas_nlh_rx),
- PDCP_TRANSMISSION_MODE_DATA,
- &pdcp_read_header_g.sourceL2Id,
- &pdcp_read_header_g.destinationL2Id
- );
- }
- } else {
- MSC_LOG_RX_DISCARDED_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,
- 0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- rab_id,
- pdcp_read_header_g.data_size);
- LOG_D(PDCP,
- "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- pdcp_read_header_g.data_size,
- ctxt.module_id,
- ctxt.rnti,
- rab_id,
- key);
- }
- } else {
- LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
- LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
- ctxt.frame,
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- pdcp_read_header_g.data_size,
- ctxt.module_id,
- ctxt.rnti,
- DEFAULT_RAB_ID);
- MSC_LOG_RX_MESSAGE(
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
- (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
- NULL,0,
- MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u",
- MSC_AS_TIME_ARGS(ctxt_pP),
- pdcp_read_header_g.inst,
- pdcp_read_header_g.rb_id,
- DEFAULT_RAB_ID,
- pdcp_read_header_g.data_size);
-
- if(nfapi_mode == 3) {
- pdcp_data_req (
- &ctxt,
- SRB_FLAG_NO,
- DEFAULT_RAB_ID,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pdcp_read_header_g.data_size,
- (unsigned char *)NLMSG_DATA(nas_nlh_rx),
- PDCP_TRANSMISSION_MODE_DATA,
- NULL,
- NULL
- );
- } else {
- pdcp_data_req (
- &ctxt,
- SRB_FLAG_NO,
- DEFAULT_RAB_ID,
- RLC_MUI_UNDEFINED,
- RLC_SDU_CONFIRM_NO,
- pdcp_read_header_g.data_size,
- (unsigned char *)NLMSG_DATA(nas_nlh_rx),
- PDCP_TRANSMISSION_MODE_DATA,
- &pdcp_read_header_g.sourceL2Id,
- &pdcp_read_header_g.destinationL2Id
- );
- }
- }
- }
+ h_rc = hashtable_get(pdcp_coll_p, key, (void **)&pdcp_p);
+ LOG_I(PDCP,"request key %x : (%d,%x,%d,%d)\n",
+ (uint8_t)key,ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id);
}
- }
- }
- VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 );
- }
+ if (h_rc == HASH_TABLE_OK) {
+ rab_id = pdcp_p->rb_id;
+ LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n",
+ ctxt.frame,
+ pc5s_header->inst,
+ bytes_received,
+ pc5s_header->rb_id);
+ LOG_I(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
+ ctxt.frame,
+ pc5s_header->inst,
+ pc5s_header->rb_id,
+ pc5s_header->data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ rab_id);
+ MSC_LOG_RX_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pc5s_header->inst,
+ pc5s_header->rb_id,
+ rab_id,
+ pc5s_header->data_size);
+ pdcp_data_req(
+ &ctxt,
+ SRB_FLAG_NO,
+ rab_id,
+ RLC_MUI_UNDEFINED,
+ RLC_SDU_CONFIRM_NO,
+ pc5s_header->data_size,
+ (unsigned char *)receive_buf,
+ PDCP_TRANSMISSION_MODE_DATA,
+ &pc5s_header->sourceL2Id,
+ &pc5s_header->destinationL2Id
+ );
+ } else { /* else of h_rc == HASH_TABLE_OK */
+ MSC_LOG_RX_DISCARDED_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,
+ 0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pc5s_header->inst,
+ pc5s_header->rb_id,
+ rab_id,
+ pc5s_header->data_size);
+ LOG_D(PDCP,
+ "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
+ ctxt.frame,
+ pc5s_header->inst,
+ pc5s_header->rb_id,
+ pc5s_header->data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ rab_id,
+ key);
+ }
+ } else { /* else of if (rab_id == 0) */
+ LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
+ LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
+ ctxt.frame,
+ pc5s_header->inst,
+ pc5s_header->rb_id,
+ pc5s_header->data_size,
+ ctxt.module_id,
+ ctxt.rnti,
+ DEFAULT_RAB_ID);
+ MSC_LOG_RX_MESSAGE(
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
+ (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
+ NULL,0,
+ MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u",
+ MSC_AS_TIME_ARGS(ctxt_pP),
+ pc5s_header->inst,
+ pc5s_header->rb_id,
+ DEFAULT_RAB_ID,
+ pc5s_header->data_size);
+ pdcp_data_req (
+ &ctxt,
+ SRB_FLAG_NO,
+ DEFAULT_RAB_ID,
+ RLC_MUI_UNDEFINED,
+ RLC_SDU_CONFIRM_NO,
+ pc5s_header->data_size,
+ (unsigned char *)receive_buf,
+ PDCP_TRANSMISSION_MODE_DATA,
+ &pc5s_header->sourceL2Id,
+ &pc5s_header->destinationL2Id
+ );
+ }
+ } /* end of !ctxt.enb_flag */
- return len;
- } else { /* PDCP_USE_NETLINK */
- return 0;
- } // else PDCP_USE_NETLINK
- } /* #else UE_NAS_USE_TUN */
+ default:
+ LOG_D(PDCP, "pc5s message type %d, unknown...\n", pc5s_header->traffic_type);
+ break;
+ } /* end of switch */
+ }/* end of bytes_received > 0 */
+} /* pdcp_fifo_read_input_sdus_frompc5s */
+
+//-----------------------------------------------------------------------------
+int pdcp_fifo_read_input_sdus (const protocol_ctxt_t *const ctxt_pP) {
+ if (UE_NAS_USE_TUN || ENB_NAS_USE_TUN) {
+ return pdcp_fifo_read_input_sdus_fromtun (ctxt_pP);
+ } else if (PDCP_USE_NETLINK) {
+ pdcp_fifo_read_input_sdus_frompc5s (ctxt_pP);
+ return pdcp_fifo_read_input_sdus_fromnetlinksock(ctxt_pP);
+ } /* PDCP_USE_NETLINK */
+
+ return 0;
}
@@ -790,37 +716,36 @@ void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t *const ctxt_pP)
}
}
-
//TTN for D2D (PC5S)
void
pdcp_pc5_socket_init() {
- //pthread_attr_t attr;
- //struct sched_param sched_param;
- int optval; // flag value for setsockopt
- //int n; // message byte size
- //create PDCP socket
- pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ //pthread_attr_t attr;
+ //struct sched_param sched_param;
+ int optval; // flag value for setsockopt
+ //int n; // message byte size
+ //create PDCP socket
+ pdcp_pc5_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (pdcp_pc5_sockfd < 0) {
- LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno));
- exit(EXIT_FAILURE);
- }
+ LOG_E(PDCP,"[pdcp_pc5_socket_init] Error opening socket %d (%d:%s)\n",pdcp_pc5_sockfd,errno, strerror(errno));
+ exit(EXIT_FAILURE);
+ }
- optval = 1;
- setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR,
+ optval = 1;
+ setsockopt(pdcp_pc5_sockfd, SOL_SOCKET, SO_REUSEADDR,
(const void *)&optval, sizeof(int));
- fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK);
- bzero((char *) &pdcp_sin, sizeof(pdcp_sin));
- pdcp_sin.sin_family = AF_INET;
- pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY);
- pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO);
+ fcntl(pdcp_pc5_sockfd,F_SETFL,O_NONBLOCK);
+ bzero((char *) &pdcp_sin, sizeof(pdcp_sin));
+ pdcp_sin.sin_family = AF_INET;
+ pdcp_sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ pdcp_sin.sin_port = htons(PDCP_SOCKET_PORT_NO);
- // associate the parent socket with a port
- if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin,
- sizeof(pdcp_sin)) < 0) {
- LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n");
- exit(1);
- }
+ // associate the parent socket with a port
+ if (bind(pdcp_pc5_sockfd, (struct sockaddr *) &pdcp_sin,
+ sizeof(pdcp_sin)) < 0) {
+ LOG_E(PDCP,"[pdcp_pc5_socket_init] ERROR: Failed on binding the socket\n");
+ exit(1);
+ }
}
diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.c b/openair2/LAYER2/PROTO_AGENT/proto_agent.c
index 4b2c0218ea..7cc0db24a7 100644
--- a/openair2/LAYER2/PROTO_AGENT/proto_agent.c
+++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.c
@@ -39,7 +39,7 @@
#include "proto_agent.h"
#include "assertions.h"
#include "proto_agent_net_comm.h"
-#include "proto_agent_async.h"
+#include "proto_agent_async.h"
#include
@@ -49,58 +49,53 @@ proto_agent_instance_t proto_agent[MAX_DU];
pthread_t new_thread(void *(*f)(void *), void *b);
-Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void* args);
+Protocol__FlexsplitMessage *proto_agent_timeout_fsp(void *args);
#define TEST_MOD 0
#define ECHO
-/* Server side function; upon a new connection
+/* Server side function; upon a new connection
reception, sends the hello packets
*/
-int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p)
-{
+int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p) {
int channel_id;
-
// RS: CUDU does not work!
//DevAssert(p->local_interface);
//DevAssert(p->local_ipv4_address);
//DevAssert(p->local_port > 1024); // "unprivileged" port
//DevAssert(p->remote_ipv4_address);
//DevAssert(p->remote_port > 1024); // "unprivileged" port
-
proto_agent[mod_id].mod_id = mod_id;
proto_agent[mod_id].exit = 0;
-
/* Initialize the channel container */
-
/* TODO only initialize the first time */
proto_agent_init_channel_container();
-
/*Create the async channel info*/
proto_agent_async_channel_t *channel_info;
channel_info = proto_agent_async_channel_info(mod_id, p->local_ipv4_address, p->local_port,
- p->remote_ipv4_address, p->remote_port);
+ p->remote_ipv4_address, p->remote_port);
+
if (!channel_info) goto error;
-
+
/* Create a channel using the async channel info */
channel_id = proto_agent_create_channel((void *) channel_info,
- proto_agent_async_msg_send,
- proto_agent_async_msg_recv,
- proto_agent_async_release);
+ proto_agent_async_msg_send,
+ proto_agent_async_msg_recv,
+ proto_agent_async_release);
+
if (channel_id <= 0) goto error;
proto_agent_channel_t *channel = proto_agent_get_channel(channel_id);
- if (!channel) goto error;
- proto_agent[mod_id].channel = channel;
+ if (!channel) goto error;
+
+ proto_agent[mod_id].channel = channel;
/* Register the channel for all underlying agents (use ENB_AGENT_MAX) */
proto_agent_register_channel(mod_id, channel, ENB_AGENT_MAX);
-
// Code for sending the HELLO/ECHO_REQ message once a connection is established
//uint8_t *msg = NULL;
//Protocol__FlexsplitMessage *init_msg=NULL;
-
//if (udp == 0)
//{
// // If the comm is not UDP, allow the server to send the first packet over the channel
@@ -112,7 +107,6 @@ int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p)
// int msgsize = 0;
// if (init_msg != NULL)
// msg = proto_agent_pack_message(init_msg, &msgsize);
-
// if (msg!= NULL)
// {
// LOG_D(PROTO_AGENT, "Server sending the message over the async channel\n");
@@ -122,23 +116,18 @@ int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p)
// the server thread blocks until it reads any data
// over the channel
// */
-
//}
-
proto_agent[mod_id].recv_thread = new_thread(proto_agent_receive, &proto_agent[mod_id]);
-
fprintf(stderr, "[PROTO_AGENT] server started at port %s:%d\n", p->local_ipv4_address, p->local_port);
return 0;
-
error:
LOG_E(PROTO_AGENT, "there was an error\n");
return 1;
-
}
-void proto_agent_stop(mod_id_t mod_id)
-{
+void proto_agent_stop(mod_id_t mod_id) {
if (!proto_agent[mod_id].channel) return;
+
/* unlock the independent read thread proto_agent_receive() */
proto_agent[mod_id].exit = 1;
proto_agent_async_msg_recv_unlock(proto_agent[mod_id].channel->channel_info);
@@ -171,22 +160,19 @@ void proto_agent_stop(mod_id_t mod_id)
//}
-void
-proto_agent_send_rlc_data_req(const protocol_ctxt_t* const ctxt_pP,
- const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
- const rb_id_t rb_idP, const mui_t muiP,
- confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP)
-{
+
+rlc_op_status_t proto_agent_send_rlc_data_req(const protocol_ctxt_t *const ctxt_pP,
+ const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
+ const rb_id_t rb_idP, const mui_t muiP,
+ confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) {
uint8_t *msg = NULL;
Protocol__FlexsplitMessage *init_msg=NULL;
int msg_flag = 0;
int msgsize = 0;
mod_id_t mod_id = ctxt_pP->module_id;
data_req_args args;
-
DevAssert(proto_agent[mod_id].channel);
DevAssert(proto_agent[mod_id].channel->channel_info);
-
args.ctxt = ctxt_pP;
args.srb_flag = srb_flagP;
args.MBMS_flag = MBMS_flagP;
@@ -195,112 +181,103 @@ proto_agent_send_rlc_data_req(const protocol_ctxt_t* const ctxt_pP,
args.confirm = confirmP;
args.sdu_size = sdu_sizeP;
args.sdu_p = sdu_pP;
-
msg_flag = proto_agent_pdcp_data_req(mod_id, (void *) &args, &init_msg);
- if (msg_flag != 0 || !init_msg) goto error;
-
- msg = proto_agent_pack_message(init_msg, &msgsize);
- if (!msg) goto error;
-
- proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
+ if (msg_flag != 0 || !init_msg) goto error;
+
+ msg = proto_agent_pack_message(init_msg, &msgsize);
+
+ if (!msg) goto error;
+
+ proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
free_mem_block(sdu_pP, __func__);
-
- return;
+ return 0;
error:
LOG_E(PROTO_AGENT, "PROTO_AGENT there was an error\n");
- return;
-
+ return -1;
}
-
+
void
-proto_agent_send_pdcp_data_ind(const protocol_ctxt_t* const ctxt_pP, const srb_flag_t srb_flagP,
- const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP)
-{
+proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP, const srb_flag_t srb_flagP,
+ const MBMS_flag_t MBMS_flagP, const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP) {
uint8_t *msg = NULL;
Protocol__FlexsplitMessage *init_msg = NULL;
int msg_flag = 0;
int msgsize = 0;
mod_id_t mod_id = ctxt_pP->module_id;
data_req_args args;
-
DevAssert(proto_agent[mod_id].channel);
DevAssert(proto_agent[mod_id].channel->channel_info);
-
args.ctxt = ctxt_pP;
args.srb_flag = srb_flagP;
args.MBMS_flag = MBMS_flagP;
args.rb_id = rb_idP;
args.sdu_size = sdu_sizeP;
args.sdu_p = sdu_pP;
-
msg_flag = proto_agent_pdcp_data_ind(mod_id, (void *) &args, &init_msg);
+
if (msg_flag != 0 || !init_msg) goto error;
msg = proto_agent_pack_message(init_msg, &msgsize);
+
if (!msg) goto error;
proto_agent_async_msg_send((void *)msg, (int) msgsize, 1, proto_agent[mod_id].channel->channel_info);
-
free_mem_block(sdu_pP, __func__);
-
return;
-
error:
LOG_E(PROTO_AGENT, "there was an error in %s\n", __func__);
return;
-
}
void *
-proto_agent_receive(void *args)
-{
+proto_agent_receive(void *args) {
proto_agent_instance_t *inst = args;
void *data = NULL;
int size;
int priority;
err_code_t err_code;
-
pthread_setname_np(pthread_self(), "proto_rx");
Protocol__FlexsplitMessage *msg;
uint8_t *ser_msg;
-
+
while (1) {
-
msg = NULL;
ser_msg = NULL;
-
- if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0){
+
+ if ((size = proto_agent_async_msg_recv(&data, &priority, inst->channel->channel_info)) < 0) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
goto error;
}
+
if (inst->exit) break;
LOG_D(PROTO_AGENT, "Server side Received message with size %d and priority %d, calling message handle\n", size, priority);
-
msg = proto_agent_handle_message(inst->mod_id, data, size);
+
if (!msg) {
LOG_D(PROTO_AGENT, "msg to send back is NULL\n");
continue;
}
ser_msg = proto_agent_pack_message(msg, &size);
+
if (!ser_msg) {
continue;
}
-
+
LOG_D(PROTO_AGENT, "Server sending the reply message over the async channel\n");
- if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)){
+
+ if (proto_agent_async_msg_send((void *)ser_msg, (int) size, 1, inst->channel->channel_info)) {
err_code = PROTOCOL__FLEXSPLIT_ERR__MSG_ENQUEUING;
goto error;
}
+
LOG_D(PROTO_AGENT, "sent message with size %d\n", size);
-
}
-
- return NULL;
+ return NULL;
error:
LOG_E(PROTO_AGENT, "proto_agent_receive(): error %d occured\n",err_code);
return NULL;
diff --git a/openair2/LAYER2/PROTO_AGENT/proto_agent.h b/openair2/LAYER2/PROTO_AGENT/proto_agent.h
index 0c5cd3fa8d..674bd245e2 100644
--- a/openair2/LAYER2/PROTO_AGENT/proto_agent.h
+++ b/openair2/LAYER2/PROTO_AGENT/proto_agent.h
@@ -29,7 +29,7 @@
*******************************************************************************/
/*! \file proto_agent.h
- * \brief top level protocol agent
+ * \brief top level protocol agent
* \author Navid Nikaein and Xenofon Foukas
* \date 2016
* \version 0.1
@@ -41,18 +41,18 @@
#include "proto_agent_common.h"
-void * proto_agent_receive(void *args);
+void *proto_agent_receive(void *args);
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p);
void proto_agent_stop(mod_id_t mod_id);
-void proto_agent_send_rlc_data_req( const protocol_ctxt_t* const ctxt_pP,
+rlc_op_status_t proto_agent_send_rlc_data_req( const protocol_ctxt_t *const ctxt_pP,
const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
const rb_id_t rb_idP, const mui_t muiP, confirm_t confirmP,
sdu_size_t sdu_sizeP, mem_block_t *sdu_pP);
-void proto_agent_send_pdcp_data_ind(const protocol_ctxt_t* const ctxt_pP,
- const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
- const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP);
+void proto_agent_send_pdcp_data_ind(const protocol_ctxt_t *const ctxt_pP,
+ const srb_flag_t srb_flagP, const MBMS_flag_t MBMS_flagP,
+ const rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t *sdu_pP);
#endif
diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c
index 96803652e8..7454e253b5 100644
--- a/openair2/LAYER2/RLC/rlc.c
+++ b/openair2/LAYER2/RLC/rlc.c
@@ -330,8 +330,6 @@ rlc_op_status_t rlc_data_req (const protocol_ctxt_t *const ctxt_pP,
#endif
) {
//-----------------------------------------------------------------------------
-
-
mem_block_t *new_sdu_p = NULL;
rlc_mode_t rlc_mode = RLC_MODE_NONE;
rlc_union_t *rlc_union_p = NULL;
@@ -599,34 +597,27 @@ void rlc_data_ind (
rb_idP,
sdu_sizeP);
rlc_util_print_hex_octets(RLC, (unsigned char *)sdu_pP->data, sdu_sizeP);
+
+ if (ctxt_pP->enb_flag) {
#if T_TRACER
-
- if (ctxt_pP->enb_flag)
T(T_ENB_RLC_UL, T_INT(ctxt_pP->module_id), T_INT(ctxt_pP->rnti), T_INT(rb_idP), T_INT(sdu_sizeP));
-
#endif
+ const ngran_node_t type = RC.rrc[ctxt_pP->module_id]->node_type;
+ AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU,
+ "Can't be CU, bad node type %d\n", type);
-#ifndef UETARGET
- const ngran_node_t type = RC.rrc[ctxt_pP->module_id]->node_type;
- AssertFatal(type != ngran_eNB_CU && type != ngran_ng_eNB_CU && type != ngran_gNB_CU,
- "Can't be CU, bad node type %d\n", type);
+ if (NODE_IS_DU(type) && srb_flagP == 1) {
+ MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, F1AP_UL_RRC_MESSAGE);
+ F1AP_UL_RRC_MESSAGE(msg).rnti = ctxt_pP->rnti;
+ F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_idP;
+ F1AP_UL_RRC_MESSAGE(msg).rrc_container = sdu_pP->data;
+ F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = sdu_sizeP;
+ itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg);
+ return;
+ }
+ } // case monolithic eNodeB or UE
- if (NODE_IS_DU(type)) {
- if (srb_flagP == 1) {
- MessageDef *msg = itti_alloc_new_message(TASK_RLC_ENB, F1AP_UL_RRC_MESSAGE);
- F1AP_UL_RRC_MESSAGE(msg).rnti = ctxt_pP->rnti;
- F1AP_UL_RRC_MESSAGE(msg).srb_id = rb_idP;
- F1AP_UL_RRC_MESSAGE(msg).rrc_container = sdu_pP->data;
- F1AP_UL_RRC_MESSAGE(msg).rrc_container_length = sdu_sizeP;
- itti_send_msg_to_task(TASK_DU_F1, ENB_MODULE_ID_TO_INSTANCE(ctxt_pP->module_id), msg);
- } else {
- proto_agent_send_pdcp_data_ind (ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP);
- }
- } else
-#endif
- { // case monolithic eNodeB or UE
- pdcp_data_ind(ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP);
- }
+ get_pdcp_data_ind_func()(ctxt_pP, srb_flagP, MBMS_flagP, rb_idP, sdu_sizeP, sdu_pP,NULL,NULL);
}
//-----------------------------------------------------------------------------
void rlc_data_conf (const protocol_ctxt_t *const ctxt_pP,
@@ -671,12 +662,12 @@ rlc_module_init (void) {
}
}
- for (k=0; k < RLC_MAX_MBMS_LC; k++) {
+ for (k=0; k < RLC_MAX_MBMS_LC; k++) {
rlc_mbms_lcid2service_session_id_eNB[0][k].service_id = 0;
rlc_mbms_lcid2service_session_id_eNB[0][k].session_id = 0;
- }
+ }
- for (k=0; k < NB_RB_MBMS_MAX; k++) {
+ for (k=0; k < NB_RB_MBMS_MAX; k++) {
rlc_mbms_rbid2lcid_eNB[0][k] = RLC_LC_UNALLOCATED;
}
diff --git a/openair2/NETWORK_DRIVER/UE_IP/device.c b/openair2/NETWORK_DRIVER/UE_IP/device.c
index 4f295543dc..32f9442747 100644
--- a/openair2/NETWORK_DRIVER/UE_IP/device.c
+++ b/openair2/NETWORK_DRIVER/UE_IP/device.c
@@ -51,13 +51,12 @@
struct net_device *ue_ip_dev[UE_IP_NB_INSTANCES_MAX];
#ifdef OAI_NW_DRIVER_USE_NETLINK
-extern void ue_ip_netlink_release(void);
-extern int ue_ip_netlink_init(void);
+ extern void ue_ip_netlink_release(void);
+ extern int ue_ip_netlink_init(void);
#endif
//---------------------------------------------------------------------------
-int ue_ip_find_inst(struct net_device *dev_pP)
-{
+int ue_ip_find_inst(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
int i;
@@ -72,15 +71,12 @@ int ue_ip_find_inst(struct net_device *dev_pP)
//---------------------------------------------------------------------------
#ifndef OAI_NW_DRIVER_USE_NETLINK
-void *ue_ip_interrupt(void)
-{
+void *ue_ip_interrupt(void) {
//---------------------------------------------------------------------------
uint8_t cxi;
-
// ue_ip_priv_t *priv_p=netdev_priv(dev_id);
// unsigned int flags;
// priv_p->lock = SPIN_LOCK_UNLOCKED;
-
#ifdef OAI_DRV_DEBUG_INTERRUPT
printk("INTERRUPT - begin\n");
#endif
@@ -100,9 +96,9 @@ void *ue_ip_interrupt(void)
#endif //NETLINK
//---------------------------------------------------------------------------
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
-void ue_ip_timer(struct timer_list *t)
+ void ue_ip_timer(struct timer_list *t)
#else
-void ue_ip_timer(unsigned long dataP)
+ void ue_ip_timer(unsigned long dataP)
#endif
{
//---------------------------------------------------------------------------
@@ -111,7 +107,6 @@ void ue_ip_timer(unsigned long dataP)
#else
ue_ip_priv_t *priv_p = (ue_ip_priv_t *)dataP;
#endif
-
spin_lock(&priv_p->lock);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0))
mod_timer(&priv_p->timer, jiffies + UE_IP_TIMER_TICK);
@@ -121,7 +116,6 @@ void ue_ip_timer(unsigned long dataP)
(priv_p->timer).data = dataP;
add_timer(&priv_p->timer);
#endif
-
spin_unlock(&priv_p->lock);
return;
// add_timer(&gpriv->timer);
@@ -130,11 +124,9 @@ void ue_ip_timer(unsigned long dataP)
//---------------------------------------------------------------------------
// Called by ifconfig when the device is activated by ifconfig
-int ue_ip_open(struct net_device *dev_pP)
-{
+int ue_ip_open(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
ue_ip_priv_t *priv_p=netdev_priv(dev_pP);
-
// Address has already been set at init
#ifndef OAI_NW_DRIVER_USE_NETLINK
@@ -161,18 +153,15 @@ int ue_ip_open(struct net_device *dev_pP)
(priv_p->timer).function = ue_ip_timer;
#endif
//add_timer(&priv_p->timer);
-
printk("[UE_IP_DRV][%s] name = %s\n", __FUNCTION__, dev_pP->name);
return 0;
}
//---------------------------------------------------------------------------
// Called by ifconfig when the device is desactivated
-int ue_ip_stop(struct net_device *dev_pP)
-{
+int ue_ip_stop(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
-
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
del_timer(&(priv_p->timer));
netif_stop_queue(dev_pP);
@@ -182,12 +171,10 @@ int ue_ip_stop(struct net_device *dev_pP)
}
//---------------------------------------------------------------------------
-void ue_ip_teardown(struct net_device *dev_pP)
-{
+void ue_ip_teardown(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
ue_ip_priv_t *priv_p;
int inst;
-
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
if (dev_pP) {
@@ -199,7 +186,6 @@ void ue_ip_teardown(struct net_device *dev_pP)
return;
}
-
printk("[UE_IP_DRV][%s] End\n", __FUNCTION__);
} // check dev_pP
else {
@@ -207,8 +193,7 @@ void ue_ip_teardown(struct net_device *dev_pP)
}
}
//---------------------------------------------------------------------------
-int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP)
-{
+int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP) {
//---------------------------------------------------------------------------
printk("[UE_IP_DRV][%s] Begin\n", __FUNCTION__);
@@ -231,8 +216,7 @@ int ue_ip_set_config(struct net_device *dev_pP, struct ifmap *map_pP)
//---------------------------------------------------------------------------
//
-int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP)
-{
+int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP) {
//---------------------------------------------------------------------------
int inst;
@@ -284,15 +268,13 @@ int ue_ip_hard_start_xmit(struct sk_buff *skb_pP, struct net_device *dev_pP)
}
//---------------------------------------------------------------------------
-struct net_device_stats *ue_ip_get_stats(struct net_device *dev_pP)
-{
+struct net_device_stats *ue_ip_get_stats(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
return &priv_p->stats;
}
//---------------------------------------------------------------------------
-int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP)
-{
+int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP) {
//---------------------------------------------------------------------------
//struct sockaddr *addr = mac_pP;
printk("[UE_IP_DRV][%s] CHANGE MAC ADDRESS UNSUPPORTED\n", __FUNCTION__);
@@ -300,8 +282,7 @@ int ue_ip_set_mac_address(struct net_device *dev_pP, void *mac_pP)
return 0;
}
//---------------------------------------------------------------------------
-int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP)
-{
+int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP) {
//---------------------------------------------------------------------------
printk("[UE_IP_DRV][%s] CHANGE MTU %d bytes\n", __FUNCTION__, mtuP);
@@ -313,8 +294,7 @@ int ue_ip_change_mtu(struct net_device *dev_pP, int mtuP)
return 0;
}
//---------------------------------------------------------------------------
-void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP)
-{
+void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP) {
//---------------------------------------------------------------------------
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
printk("[UE_IP_DRV][%s] CHANGE RX FLAGS %08X\n", __FUNCTION__, flagsP);
@@ -322,12 +302,10 @@ void ue_ip_change_rx_flags(struct net_device *dev_pP, int flagsP)
}
//---------------------------------------------------------------------------
-void ue_ip_tx_timeout(struct net_device *dev_pP)
-{
+void ue_ip_tx_timeout(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
// Transmitter timeout, serious problems.
ue_ip_priv_t *priv_p = netdev_priv(dev_pP);
-
printk("[UE_IP_DRV][%s] begin\n", __FUNCTION__);
// (ue_ip_priv_t *)(dev_pP->priv_p)->stats.tx_errors++;
(priv_p->stats).tx_errors++;
@@ -349,7 +327,7 @@ static const struct net_device_ops ue_ip_netdev_ops = {
.ndo_set_mac_address = ue_ip_set_mac_address,
.ndo_set_config = ue_ip_set_config,
.ndo_do_ioctl = NULL,
-#if RHEL_RELEASE_CODE>=1797
+#if (defined RHEL_RELEASE_CODE && RHEL_RELEASE_CODE >= 1797)
.extended.ndo_change_mtu = ue_ip_change_mtu,
#else
.ndo_change_mtu = ue_ip_change_mtu,
@@ -361,8 +339,7 @@ static const struct net_device_ops ue_ip_netdev_ops = {
//---------------------------------------------------------------------------
// Initialisation of the network device
-void ue_ip_init(struct net_device *dev_pP)
-{
+void ue_ip_init(struct net_device *dev_pP) {
//---------------------------------------------------------------------------
ue_ip_priv_t *priv_p = NULL;
@@ -382,13 +359,10 @@ void ue_ip_init(struct net_device *dev_pP)
}
}
//---------------------------------------------------------------------------
-int init_module (void)
-{
+int init_module (void) {
//---------------------------------------------------------------------------
int err,inst;
char devicename[100];
-
-
// Initialize parameters shared with RRC
printk("[UE_IP_DRV][%s] Starting OAI IP driver", __FUNCTION__);
@@ -423,15 +397,12 @@ int init_module (void)
}
return err;
-
}
//---------------------------------------------------------------------------
-void cleanup_module(void)
-{
+void cleanup_module(void) {
//---------------------------------------------------------------------------
int inst;
-
printk("[UE_IP_DRV][CLEANUP] begin\n");
for (inst=0; instrach_ind.rach_indication_body.number_of_preambles>0) {
-
AssertFatal(UL_info->rach_ind.rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n");
UL_info->rach_ind.rach_indication_body.number_of_preambles=0;
LOG_D(MAC,"UL_info[Frame %d, Subframe %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->subframe, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf));
initiate_ra_proc(UL_info->module_id,
- UL_info->CC_id,
- NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf),
- NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
- UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
- UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
- UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti
+ UL_info->CC_id,
+ NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf),
+ NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf),
+ UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble,
+ UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance,
+ UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
- ,0
+ ,0
#endif
- );
+ );
}
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
+
if (UL_info->rach_ind_br.rach_indication_body.number_of_preambles>0) {
-
AssertFatal(UL_info->rach_ind_br.rach_indication_body.number_of_preambles<5,"More than 4 preambles not supported\n");
- for (i=0;irach_ind_br.rach_indication_body.number_of_preambles;i++) {
+
+ for (i=0; irach_ind_br.rach_indication_body.number_of_preambles; i++) {
AssertFatal(UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type>0,
- "Got regular PRACH preamble, not BL/CE\n");
+ "Got regular PRACH preamble, not BL/CE\n");
LOG_D(MAC,"Frame %d, Subframe %d Calling initiate_ra_proc (CE_level %d)\n",UL_info->frame,UL_info->subframe,
-
- UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type-1);
+ UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type-1);
UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0;
-
initiate_ra_proc(UL_info->module_id,
- UL_info->CC_id,
- UL_info->frame,
- UL_info->subframe,
- UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.preamble,
- UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.timing_advance,
- UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.rnti,
- UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type);
+ UL_info->CC_id,
+ UL_info->frame,
+ UL_info->subframe,
+ UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.preamble,
+ UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.timing_advance,
+ UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel8.rnti,
+ UL_info->rach_ind_br.rach_indication_body.preamble_list[i].preamble_rel13.rach_resource_type);
}
+
UL_info->rach_ind_br.rach_indication_body.number_of_preambles=0;
}
+
#endif
}
void handle_sr(UL_IND_t *UL_info) {
-
int i;
- if (nfapi_mode == 1) // PNF
- {
- if (UL_info->sr_ind.sr_indication_body.number_of_srs>0)
- {
+ if (NFAPI_MODE == NFAPI_MODE_PNF) { // PNF
+ if (UL_info->sr_ind.sr_indication_body.number_of_srs>0) {
oai_nfapi_sr_indication(&UL_info->sr_ind);
}
- }
- else
- {
- for (i=0;isr_ind.sr_indication_body.number_of_srs;i++)
+ } else {
+ for (i=0; isr_ind.sr_indication_body.number_of_srs; i++)
SR_indication(UL_info->module_id,
- UL_info->CC_id,
- UL_info->frame,
- UL_info->subframe,
- UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti,
- UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi);
+ UL_info->CC_id,
+ UL_info->frame,
+ UL_info->subframe,
+ UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].rx_ue_information.rnti,
+ UL_info->sr_ind.sr_indication_body.sr_pdu_list[i].ul_cqi_information.ul_cqi);
}
UL_info->sr_ind.sr_indication_body.number_of_srs=0;
}
void handle_cqi(UL_IND_t *UL_info) {
-
int i;
- if (nfapi_mode == 1)
- {
- if (UL_info->cqi_ind.number_of_cqis>0)
- {
+ if (NFAPI_MODE==NFAPI_MODE_PNF) {
+ if (UL_info->cqi_ind.number_of_cqis>0) {
LOG_D(PHY,"UL_info->cqi_ind.number_of_cqis:%d\n", UL_info->cqi_ind.number_of_cqis);
nfapi_cqi_indication_t ind;
-
ind.header.message_id = NFAPI_RX_CQI_INDICATION;
ind.sfn_sf = UL_info->frame<<4 | UL_info->subframe;
ind.cqi_indication_body = UL_info->cqi_ind;
-
oai_nfapi_cqi_indication(&ind);
-
UL_info->cqi_ind.number_of_cqis=0;
}
- }
- else
- {
- for (i=0;icqi_ind.number_of_cqis;i++)
+ } else {
+ for (i=0; icqi_ind.number_of_cqis; i++)
cqi_indication(UL_info->module_id,
- UL_info->CC_id,
- UL_info->frame,
- UL_info->subframe,
- UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti,
- &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9,
- UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu,
- &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information);
+ UL_info->CC_id,
+ UL_info->frame,
+ UL_info->subframe,
+ UL_info->cqi_ind.cqi_pdu_list[i].rx_ue_information.rnti,
+ &UL_info->cqi_ind.cqi_pdu_list[i].cqi_indication_rel9,
+ UL_info->cqi_ind.cqi_raw_pdu_list[i].pdu,
+ &UL_info->cqi_ind.cqi_pdu_list[i].ul_cqi_information);
UL_info->cqi_ind.number_of_cqis=0;
}
}
void handle_harq(UL_IND_t *UL_info) {
-
int i;
- if (nfapi_mode == 1 && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) // PNF
- {
+ if (NFAPI_MODE == NFAPI_MODE_PNF && UL_info->harq_ind.harq_indication_body.number_of_harqs>0) { // PNF
//LOG_D(PHY, "UL_info->harq_ind.harq_indication_body.number_of_harqs:%d Send to VNF\n", UL_info->harq_ind.harq_indication_body.number_of_harqs);
-
int retval = oai_nfapi_harq_indication(&UL_info->harq_ind);
- if (retval!=0)
- {
+ if (retval!=0) {
LOG_E(PHY, "Failed to encode NFAPI HARQ_IND retval:%d\n", retval);
}
UL_info->harq_ind.harq_indication_body.number_of_harqs = 0;
- }
- else
- {
- for (i=0;iharq_ind.harq_indication_body.number_of_harqs;i++)
+ } else {
+ for (i=0; iharq_ind.harq_indication_body.number_of_harqs; i++)
harq_indication(UL_info->module_id,
- UL_info->CC_id,
- NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf),
- NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf),
- &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]);
+ UL_info->CC_id,
+ NFAPI_SFNSF2SFN(UL_info->harq_ind.sfn_sf),
+ NFAPI_SFNSF2SF(UL_info->harq_ind.sfn_sf),
+ &UL_info->harq_ind.harq_indication_body.harq_pdu_list[i]);
UL_info->harq_ind.harq_indication_body.number_of_harqs=0;
}
}
void handle_ulsch(UL_IND_t *UL_info) {
-
int i,j;
- if(nfapi_mode == 1)
- {
- if (UL_info->crc_ind.crc_indication_body.number_of_crcs>0)
- {
+ if(NFAPI_MODE == NFAPI_MODE_PNF) {
+ if (UL_info->crc_ind.crc_indication_body.number_of_crcs>0) {
//LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.number_of_crcs:%d CRC_IND:SFN/SF:%d\n", UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf));
-
oai_nfapi_crc_indication(&UL_info->crc_ind);
-
UL_info->crc_ind.crc_indication_body.number_of_crcs = 0;
}
- if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0)
- {
+ if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0) {
//LOG_D(PHY,"UL_info->rx_ind.number_of_pdus:%d RX_IND:SFN/SF:%d\n", UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf));
oai_nfapi_rx_ind(&UL_info->rx_ind);
UL_info->rx_ind.rx_indication_body.number_of_pdus = 0;
}
- }
- else
- {
+ } else {
if (UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->crc_ind.crc_indication_body.number_of_crcs>0) {
- for (i=0;irx_ind.rx_indication_body.number_of_pdus;i++) {
- for (j=0;jcrc_ind.crc_indication_body.number_of_crcs;j++) {
+ for (i=0; irx_ind.rx_indication_body.number_of_pdus; i++) {
+ for (j=0; jcrc_ind.crc_indication_body.number_of_crcs; j++) {
// find crc_indication j corresponding rx_indication i
- LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti);
+ LOG_D(PHY,"UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].rx_ue_information.rnti:%04x UL_info->rx_ind.rx_indication_body.rx_pdu_list[%d].rx_ue_information.rnti:%04x\n", j,
+ UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti, i, UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti);
+
if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].rx_ue_information.rnti ==
UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti) {
LOG_D(PHY, "UL_info->crc_ind.crc_indication_body.crc_pdu_list[%d].crc_indication_rel8.crc_flag:%d\n", j, UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag);
+
if (UL_info->crc_ind.crc_indication_body.crc_pdu_list[j].crc_indication_rel8.crc_flag == 1) { // CRC error indication
LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe);
rx_sdu(UL_info->module_id,
- UL_info->CC_id,
- NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
- NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
- (uint8_t *)NULL,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
- }
- else {
+ UL_info->CC_id,
+ NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
+ NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
+ (uint8_t *)NULL,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
+ } else {
LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC ok) \n",UL_info->frame,UL_info->subframe);
rx_sdu(UL_info->module_id,
- UL_info->CC_id,
- NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
- NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
- UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
+ UL_info->CC_id,
+ NFAPI_SFNSF2SFN(UL_info->rx_ind.sfn_sf), //UL_info->frame,
+ NFAPI_SFNSF2SF(UL_info->rx_ind.sfn_sf), //UL_info->subframe,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_ue_information.rnti,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].data,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.length,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.timing_advance,
+ UL_info->rx_ind.rx_indication_body.rx_pdu_list[i].rx_indication_rel8.ul_cqi);
}
+
break;
} //if (UL_info->crc_ind.crc_pdu_list[j].rx_ue_information.rnti ==
+
// UL_info->rx_ind.rx_pdu_list[i].rx_ue_information.rnti)
} // for (j=0;jcrc_ind.crc_indication_body.number_of_crcs;j++)
} // for (i=0;irx_ind.number_of_pdus;i++)
+
UL_info->crc_ind.crc_indication_body.number_of_crcs=0;
UL_info->rx_ind.rx_indication_body.number_of_pdus = 0;
} // UL_info->rx_ind.rx_indication_body.number_of_pdus>0 && UL_info->subframe && UL_info->crc_ind.crc_indication_body.number_of_crcs>0
else if (UL_info->rx_ind.rx_indication_body.number_of_pdus!=0 || UL_info->crc_ind.crc_indication_body.number_of_crcs!=0) {
LOG_E(PHY,"hoping not to have mis-match between CRC ind and RX ind - hopefully the missing message is coming shortly rx_ind:%d(SFN/SF:%05d) crc_ind:%d(SFN/SF:%05d) UL_info(SFN/SF):%04d%d\n",
- UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf),
- UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf),
- UL_info->frame, UL_info->subframe);
+ UL_info->rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(UL_info->rx_ind.sfn_sf),
+ UL_info->crc_ind.crc_indication_body.number_of_crcs, NFAPI_SFNSF2DEC(UL_info->crc_ind.sfn_sf),
+ UL_info->frame, UL_info->subframe);
}
}
}
@@ -246,257 +224,334 @@ static char s[SMAX];
static int size;
static int maxsize = SMAX;
-static void put(char x)
-{
- if (size == maxsize) { printf("incrase SMAX\n"); exit(1); }
+static void put(char x) {
+ if (size == maxsize) {
+ printf("incrase SMAX\n");
+ exit(1);
+ }
+
s[size++] = x;
}
-static void append_string(char *t)
-{
+static void append_string(char *t) {
size--;
+
while (*t) put(*t++);
+
put(0);
}
-static void dump_ul(UL_IND_t *u)
-{
+static void dump_ul(UL_IND_t *u) {
int i;
-
C;
A("XXXX UL mod %d CC %d f.sf %d.%d\n",
u->module_id, u->CC_id, u->frame, u->subframe);
-
A("XXXX harq_ind %d\n", u->harq_ind.harq_indication_body.number_of_harqs);
- for (i = 0; i < u->harq_ind.harq_indication_body.number_of_harqs; i++) {
- nfapi_harq_indication_pdu_t *v = &u->harq_ind.harq_indication_body.harq_pdu_list[i];
- A("XXXX harq ind %d\n", i);
- A("XXXX rnti %d\n", v->rx_ue_information.rnti);
- A("XXXX tb1 %d tb2 %d\n", v->harq_indication_fdd_rel8.harq_tb1,
- v->harq_indication_fdd_rel8.harq_tb2);
- A("XXXX number_of_ack_nack %d\n",
- v->harq_indication_fdd_rel9.number_of_ack_nack);
- A("XXXX harq[0] = %d\n",
- v->harq_indication_fdd_rel9.harq_tb_n[0]);
- A("XXXX harq ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi,
- v->ul_cqi_information.channel);
- }
+
+ for (i = 0; i < u->harq_ind.harq_indication_body.number_of_harqs; i++) {
+ nfapi_harq_indication_pdu_t *v = &u->harq_ind.harq_indication_body.harq_pdu_list[i];
+ A("XXXX harq ind %d\n", i);
+ A("XXXX rnti %d\n", v->rx_ue_information.rnti);
+ A("XXXX tb1 %d tb2 %d\n", v->harq_indication_fdd_rel8.harq_tb1,
+ v->harq_indication_fdd_rel8.harq_tb2);
+ A("XXXX number_of_ack_nack %d\n",
+ v->harq_indication_fdd_rel9.number_of_ack_nack);
+ A("XXXX harq[0] = %d\n",
+ v->harq_indication_fdd_rel9.harq_tb_n[0]);
+ A("XXXX harq ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi,
+ v->ul_cqi_information.channel);
+ }
A("XXXX crc_ind %d\n", u->crc_ind.crc_indication_body.number_of_crcs);
-
A("XXXX sr_ind %d\n", u->sr_ind.sr_indication_body.number_of_srs);
-
A("XXXX cqi_ind %d\n", u->cqi_ind.number_of_cqis);
- for (i = 0; i < u->cqi_ind.number_of_cqis; i++) {
- nfapi_cqi_indication_pdu_t *v = &u->cqi_ind.cqi_pdu_list[i];
- A("XXXX cqi ind %d\n", i);
- A("XXXX cqi ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi,
- v->ul_cqi_information.channel);
- }
+
+ for (i = 0; i < u->cqi_ind.number_of_cqis; i++) {
+ nfapi_cqi_indication_pdu_t *v = &u->cqi_ind.cqi_pdu_list[i];
+ A("XXXX cqi ind %d\n", i);
+ A("XXXX cqi ul_cqi %d channel %d\n", v->ul_cqi_information.ul_cqi,
+ v->ul_cqi_information.channel);
+ }
A("XXXX rach_ind %d\n", u->rach_ind.rach_indication_body.number_of_preambles);
-
A("XXXX rx_ind %d\n", u->rx_ind.rx_indication_body.number_of_pdus);
- for (i = 0; i < u->rx_ind.rx_indication_body.number_of_pdus; i++) {
- nfapi_rx_indication_pdu_t *v = &u->rx_ind.rx_indication_body.rx_pdu_list[i];
- A("XXXX rx ind %d\n", i);
- A("XXXX timing_advance %d\n",
- v->rx_indication_rel8.timing_advance);
- A("XXXX rx ul_cqi %d\n", v->rx_indication_rel8.ul_cqi);
- }
+
+ for (i = 0; i < u->rx_ind.rx_indication_body.number_of_pdus; i++) {
+ nfapi_rx_indication_pdu_t *v = &u->rx_ind.rx_indication_body.rx_pdu_list[i];
+ A("XXXX rx ind %d\n", i);
+ A("XXXX timing_advance %d\n",
+ v->rx_indication_rel8.timing_advance);
+ A("XXXX rx ul_cqi %d\n", v->rx_indication_rel8.ul_cqi);
+ }
LOG_I(PHY, "XXXX UL\nXXXX UL\n%s", s);
}
-static char *DL_PDU_TYPE(int x)
-{
+static char *DL_PDU_TYPE(int x) {
switch (x) {
- case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: return "NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE";
- case NFAPI_DL_CONFIG_BCH_PDU_TYPE: return "NFAPI_DL_CONFIG_BCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_MCH_PDU_TYPE: return "NFAPI_DL_CONFIG_MCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: return "NFAPI_DL_CONFIG_DLSCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_PCH_PDU_TYPE: return "NFAPI_DL_CONFIG_PCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_PRS_PDU_TYPE: return "NFAPI_DL_CONFIG_PRS_PDU_TYPE";
- case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE: return "NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE";
- case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE: return "NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE";
- case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE: return "NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_NBCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NBCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE";
- case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE: return "NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE";
+ case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_BCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_BCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_MCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_MCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_DLSCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_PCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_PCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_PRS_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_PRS_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_CSI_RS_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_EPDCCH_DL_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_MPDCCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_NBCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_NBCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_NPDCCH_PDU_TYPE";
+
+ case NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE:
+ return "NFAPI_DL_CONFIG_NDLSCH_PDU_TYPE";
}
+
return "UNKNOWN";
}
-static char *UL_PDU_TYPE(int x)
-{
+static char *UL_PDU_TYPE(int x) {
switch (x) {
- case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_PDU_TYPE";
- case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE";
- case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE";
- case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_SRS_PDU_TYPE: return "NFAPI_UL_CONFIG_SRS_PDU_TYPE";
- case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE: return "NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE";
- case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE";
- case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE: return "NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE";
- case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE: return "NFAPI_UL_CONFIG_NULSCH_PDU_TYPE";
- case NFAPI_UL_CONFIG_NRACH_PDU_TYPE: return "NFAPI_UL_CONFIG_NRACH_PDU_TYPE";
+ case NFAPI_UL_CONFIG_ULSCH_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_CQI_HARQ_RI_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_CQI_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_SR_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_CQI_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_CQI_SR_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_UCI_CQI_SR_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_SRS_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_SRS_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_HARQ_BUFFER_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_UCI_CSI_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_UCI_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_ULSCH_CSI_UCI_HARQ_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_NULSCH_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_NULSCH_PDU_TYPE";
+
+ case NFAPI_UL_CONFIG_NRACH_PDU_TYPE:
+ return "NFAPI_UL_CONFIG_NRACH_PDU_TYPE";
}
+
return "UNKNOWN";
}
-static char *HI_DCI0_PDU_TYPE(int x)
-{
+static char *HI_DCI0_PDU_TYPE(int x) {
switch (x) {
- case NFAPI_HI_DCI0_HI_PDU_TYPE: return "NFAPI_HI_DCI0_HI_PDU_TYPE";
- case NFAPI_HI_DCI0_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_DCI_PDU_TYPE";
- case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE";
- case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE";
- case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE: return "NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE";
+ case NFAPI_HI_DCI0_HI_PDU_TYPE:
+ return "NFAPI_HI_DCI0_HI_PDU_TYPE";
+
+ case NFAPI_HI_DCI0_DCI_PDU_TYPE:
+ return "NFAPI_HI_DCI0_DCI_PDU_TYPE";
+
+ case NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE:
+ return "NFAPI_HI_DCI0_EPDCCH_DCI_PDU_TYPE";
+
+ case NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE:
+ return "NFAPI_HI_DCI0_MPDCCH_DCI_PDU_TYPE";
+
+ case NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE:
+ return "NFAPI_HI_DCI0_NPDCCH_DCI_PDU_TYPE";
}
+
return "UNKNOWN";
}
-static void dump_dl(Sched_Rsp_t *d)
-{
+static void dump_dl(Sched_Rsp_t *d) {
int i;
-
C;
A("XXXX DL mod %d CC %d f.sf %d.%d\n",
d->module_id, d->CC_id, d->frame, d->subframe);
- if (d->DL_req != NULL) {
- nfapi_dl_config_request_body_t *v=&d->DL_req->dl_config_request_body;
- nfapi_dl_config_request_pdu_t *p = v->dl_config_pdu_list;
- A("XXXX DL_req sfnsf %d\n", d->DL_req->sfn_sf);
- A("XXXX PDCCH size %d\n", v->number_pdcch_ofdm_symbols);
- A("XXXX DCIs %d\n", v->number_dci);
- A("XXXX PDUs %d\n", v->number_pdu);
- A("XXXX rntis %d\n", v->number_pdsch_rnti);
- A("XXXX pcfich power %d\n", v->transmission_power_pcfich);
- for (i = 0; i < v->number_pdu; i++) {
- A("XXXX pdu %d\n", i);
- A("XXXX type %d %s\n", p[i].pdu_type, DL_PDU_TYPE(p[i].pdu_type));
- switch (p[i].pdu_type) {
- case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: {
- nfapi_dl_config_dci_dl_pdu_rel8_t *q =
- &p[i].dci_dl_pdu.dci_dl_pdu_rel8;
- A("XXXX dci format %d\n", q->dci_format);
- A("XXXX cce idx %d\n", q->cce_idx);
- A("XXXX agg lvl %d\n", q->aggregation_level);
- A("XXXX rnti %d\n", q->rnti);
- A("XXXX rb coding %8.8x\n", q->resource_block_coding);
- A("XXXX mcs_1 %d\n", q->mcs_1);
- A("XXXX rv_1 %d\n", q->redundancy_version_1);
- A("XXXX ndi_1 %d\n", q->new_data_indicator_1);
- A("XXXX harq pid %d\n", q->harq_process);
- A("XXXX tpc %d\n", q->tpc);
- A("XXXX tbs idx %d\n", q->transport_block_size_index);
- A("XXXX dl pow off %d\n", q->downlink_power_offset);
- A("XXXX rnti type %d\n", q->rnti_type);
- A("XXXX xmit pow %d\n", q->transmission_power);
- break;
- }
- case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: {
- nfapi_dl_config_dlsch_pdu_rel8_t *q =
- &p[i].dlsch_pdu.dlsch_pdu_rel8;
- A("XXXX pdu_index %d\n", q->pdu_index);
- A("XXXX rnti %d\n", q->rnti);
- A("XXXX rv %d\n", q->redundancy_version);
- A("XXXX mcs %d\n", q->modulation);
- A("XXXX pa %d\n", q->pa);
- break;
- }}
+ if (d->DL_req != NULL) {
+ nfapi_dl_config_request_body_t *v=&d->DL_req->dl_config_request_body;
+ nfapi_dl_config_request_pdu_t *p = v->dl_config_pdu_list;
+ A("XXXX DL_req sfnsf %d\n", d->DL_req->sfn_sf);
+ A("XXXX PDCCH size %d\n", v->number_pdcch_ofdm_symbols);
+ A("XXXX DCIs %d\n", v->number_dci);
+ A("XXXX PDUs %d\n", v->number_pdu);
+ A("XXXX rntis %d\n", v->number_pdsch_rnti);
+ A("XXXX pcfich power %d\n", v->transmission_power_pcfich);
+
+ for (i = 0; i < v->number_pdu; i++) {
+ A("XXXX pdu %d\n", i);
+ A("XXXX type %d %s\n", p[i].pdu_type, DL_PDU_TYPE(p[i].pdu_type));
+
+ switch (p[i].pdu_type) {
+ case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE: {
+ nfapi_dl_config_dci_dl_pdu_rel8_t *q =
+ &p[i].dci_dl_pdu.dci_dl_pdu_rel8;
+ A("XXXX dci format %d\n", q->dci_format);
+ A("XXXX cce idx %d\n", q->cce_idx);
+ A("XXXX agg lvl %d\n", q->aggregation_level);
+ A("XXXX rnti %d\n", q->rnti);
+ A("XXXX rb coding %8.8x\n", q->resource_block_coding);
+ A("XXXX mcs_1 %d\n", q->mcs_1);
+ A("XXXX rv_1 %d\n", q->redundancy_version_1);
+ A("XXXX ndi_1 %d\n", q->new_data_indicator_1);
+ A("XXXX harq pid %d\n", q->harq_process);
+ A("XXXX tpc %d\n", q->tpc);
+ A("XXXX tbs idx %d\n", q->transport_block_size_index);
+ A("XXXX dl pow off %d\n", q->downlink_power_offset);
+ A("XXXX rnti type %d\n", q->rnti_type);
+ A("XXXX xmit pow %d\n", q->transmission_power);
+ break;
}
+
+ case NFAPI_DL_CONFIG_DLSCH_PDU_TYPE: {
+ nfapi_dl_config_dlsch_pdu_rel8_t *q =
+ &p[i].dlsch_pdu.dlsch_pdu_rel8;
+ A("XXXX pdu_index %d\n", q->pdu_index);
+ A("XXXX rnti %d\n", q->rnti);
+ A("XXXX rv %d\n", q->redundancy_version);
+ A("XXXX mcs %d\n", q->modulation);
+ A("XXXX pa %d\n", q->pa);
+ break;
+ }
+ }
+ }
+ }
+
+ if (d->HI_DCI0_req != NULL) {
+ nfapi_hi_dci0_request_body_t *v=&d->HI_DCI0_req->hi_dci0_request_body;
+ A("XXXX up HI_DCI0_req sfnsf %d (%d.%d)\n", d->HI_DCI0_req->sfn_sf,
+ d->HI_DCI0_req->sfn_sf/16, d->HI_DCI0_req->sfn_sf%16);
+ A("XXXX up sfnsf %d\n", v->sfnsf);
+ A("XXXX up DCIs %d\n", v->number_of_dci);
+ A("XXXX up HIs %d\n", v->number_of_hi);
+
+ for (i = 0; i < v->number_of_dci + v->number_of_hi; i++) {
+ nfapi_hi_dci0_request_pdu_t *p = &v->hi_dci0_pdu_list[i];
+ A("XXXX up pdu %d\n", i);
+ A("XXXX up type %d %s\n",p->pdu_type,HI_DCI0_PDU_TYPE(p->pdu_type));
+
+ if (p->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) {
+ nfapi_hi_dci0_dci_pdu_rel8_t *q = &p->dci_pdu.dci_pdu_rel8;
+ A("XXXX up dci_format %d\n", q->dci_format);
+ A("XXXX up cce_index %d\n", q->cce_index);
+ A("XXXX up aggregation_level %d\n", q->aggregation_level);
+ A("XXXX up rnti %d\n", q->rnti);
+ A("XXXX up rb start %d\n", q->resource_block_start);
+ A("XXXX up # rb %d\n", q->number_of_resource_block);
+ A("XXXX up mcs_1 %d\n", q->mcs_1);
+ A("XXXX up cshift_2_for_drms %d\n", q->cyclic_shift_2_for_drms);
+ A("XXXX up freq hop enabled %d\n", q->frequency_hopping_enabled_flag);
+ A("XXXX up fre hop bits %d\n", q->frequency_hopping_bits);
+ A("XXXX up NDI_1 %d\n", q->new_data_indication_1);
+ A("XXXX up tx_antenna_seleciton %d\n", q->ue_tx_antenna_seleciton);
+ A("XXXX up tpc %d\n", q->tpc);
+ A("XXXX up cqi_csi_request %d\n", q->cqi_csi_request);
+ A("XXXX up ul_index %d\n", q->ul_index);
+ A("XXXX up dl_assignment_index %d\n", q->dl_assignment_index);
+ A("XXXX up tpc_bitmap %d\n", q->tpc_bitmap);
+ A("XXXX up transmission_power %d\n", q->transmission_power);
}
- if (d->HI_DCI0_req != NULL) {
- nfapi_hi_dci0_request_body_t *v=&d->HI_DCI0_req->hi_dci0_request_body;
- A("XXXX up HI_DCI0_req sfnsf %d (%d.%d)\n", d->HI_DCI0_req->sfn_sf,
- d->HI_DCI0_req->sfn_sf/16, d->HI_DCI0_req->sfn_sf%16);
- A("XXXX up sfnsf %d\n", v->sfnsf);
- A("XXXX up DCIs %d\n", v->number_of_dci);
- A("XXXX up HIs %d\n", v->number_of_hi);
- for (i = 0; i < v->number_of_dci + v->number_of_hi; i++) {
- nfapi_hi_dci0_request_pdu_t *p = &v->hi_dci0_pdu_list[i];
- A("XXXX up pdu %d\n", i);
- A("XXXX up type %d %s\n",p->pdu_type,HI_DCI0_PDU_TYPE(p->pdu_type));
- if (p->pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE) {
- nfapi_hi_dci0_dci_pdu_rel8_t *q = &p->dci_pdu.dci_pdu_rel8;
- A("XXXX up dci_format %d\n", q->dci_format);
- A("XXXX up cce_index %d\n", q->cce_index);
- A("XXXX up aggregation_level %d\n", q->aggregation_level);
- A("XXXX up rnti %d\n", q->rnti);
- A("XXXX up rb start %d\n", q->resource_block_start);
- A("XXXX up # rb %d\n", q->number_of_resource_block);
- A("XXXX up mcs_1 %d\n", q->mcs_1);
- A("XXXX up cshift_2_for_drms %d\n", q->cyclic_shift_2_for_drms);
- A("XXXX up freq hop enabled %d\n", q->frequency_hopping_enabled_flag);
- A("XXXX up fre hop bits %d\n", q->frequency_hopping_bits);
- A("XXXX up NDI_1 %d\n", q->new_data_indication_1);
- A("XXXX up tx_antenna_seleciton %d\n", q->ue_tx_antenna_seleciton);
- A("XXXX up tpc %d\n", q->tpc);
- A("XXXX up cqi_csi_request %d\n", q->cqi_csi_request);
- A("XXXX up ul_index %d\n", q->ul_index);
- A("XXXX up dl_assignment_index %d\n", q->dl_assignment_index);
- A("XXXX up tpc_bitmap %d\n", q->tpc_bitmap);
- A("XXXX up transmission_power %d\n", q->transmission_power);
- }
- if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) {
- nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8;
- A("XXXX up rb start %d\n", q->resource_block_start);
- A("XXXX up cs2_drms %d\n", q->cyclic_shift_2_for_drms);
- A("XXXX up ack %d\n", q->hi_value);
- A("XXXX up i_phich %d\n", q->i_phich);
- A("XXXX up power %d\n", q->transmission_power);
- }
- }
+ if (p->pdu_type == NFAPI_HI_DCI0_HI_PDU_TYPE) {
+ nfapi_hi_dci0_hi_pdu_rel8_t *q = &p->hi_pdu.hi_pdu_rel8;
+ A("XXXX up rb start %d\n", q->resource_block_start);
+ A("XXXX up cs2_drms %d\n", q->cyclic_shift_2_for_drms);
+ A("XXXX up ack %d\n", q->hi_value);
+ A("XXXX up i_phich %d\n", q->i_phich);
+ A("XXXX up power %d\n", q->transmission_power);
}
+ }
+ }
- if (d->UL_req != NULL) {
- nfapi_ul_config_request_body_t *v=&d->UL_req->ul_config_request_body;
- A("XXXX UL_req sfnsf %d (%d.%d)\n", d->UL_req->sfn_sf,
- d->UL_req->sfn_sf/16, d->UL_req->sfn_sf%16);
- A("XXXX PDUs %d\n", v->number_of_pdus);
- A("XXXX ra freq %d\n", v->rach_prach_frequency_resources);
- A("XXXX srs? %d\n", v->srs_present);
- for (i = 0; i < v->number_of_pdus; i++) {
- nfapi_ul_config_request_pdu_t *p = &v->ul_config_pdu_list[i];
- A("XXXX pdu %d\n", i);
- A("XXXX type %d %s\n", p->pdu_type, UL_PDU_TYPE(p->pdu_type));
- switch(p->pdu_type) {
- case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: {
- nfapi_ul_config_uci_harq_pdu *q = &p->uci_harq_pdu;
- nfapi_ul_config_harq_information_rel9_fdd_t *h =
- &q->harq_information.harq_information_rel9_fdd;
- A("XXXX rnti %d\n",
- q->ue_information.ue_information_rel8.rnti);
- A("XXXX harq size %d\n", h->harq_size);
- A("XXXX ack_nack_mode %d\n", h->ack_nack_mode);
- A("XXXX # pucch res %d\n", h->number_of_pucch_resources);
- A("XXXX n_pucch_1_0 %d\n", h->n_pucch_1_0);
- A("XXXX n_pucch_1_1 %d\n", h->n_pucch_1_1);
- A("XXXX n_pucch_1_2 %d\n", h->n_pucch_1_2);
- A("XXXX n_pucch_1_3 %d\n", h->n_pucch_1_3);
- break;
- }
- case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: {
- nfapi_ul_config_uci_sr_pdu *q = &p->uci_sr_pdu;
- nfapi_ul_config_sr_information_rel8_t *h =
- &q->sr_information.sr_information_rel8;
- A("XXXX rnti %d\n",
- q->ue_information.ue_information_rel8.rnti);
- A("XXXX pucch_index %d\n", h->pucch_index);
- }}
+ if (d->UL_req != NULL) {
+ nfapi_ul_config_request_body_t *v=&d->UL_req->ul_config_request_body;
+ A("XXXX UL_req sfnsf %d (%d.%d)\n", d->UL_req->sfn_sf,
+ d->UL_req->sfn_sf/16, d->UL_req->sfn_sf%16);
+ A("XXXX PDUs %d\n", v->number_of_pdus);
+ A("XXXX ra freq %d\n", v->rach_prach_frequency_resources);
+ A("XXXX srs? %d\n", v->srs_present);
+
+ for (i = 0; i < v->number_of_pdus; i++) {
+ nfapi_ul_config_request_pdu_t *p = &v->ul_config_pdu_list[i];
+ A("XXXX pdu %d\n", i);
+ A("XXXX type %d %s\n", p->pdu_type, UL_PDU_TYPE(p->pdu_type));
+
+ switch(p->pdu_type) {
+ case NFAPI_UL_CONFIG_UCI_HARQ_PDU_TYPE: {
+ nfapi_ul_config_uci_harq_pdu *q = &p->uci_harq_pdu;
+ nfapi_ul_config_harq_information_rel9_fdd_t *h =
+ &q->harq_information.harq_information_rel9_fdd;
+ A("XXXX rnti %d\n",
+ q->ue_information.ue_information_rel8.rnti);
+ A("XXXX harq size %d\n", h->harq_size);
+ A("XXXX ack_nack_mode %d\n", h->ack_nack_mode);
+ A("XXXX # pucch res %d\n", h->number_of_pucch_resources);
+ A("XXXX n_pucch_1_0 %d\n", h->n_pucch_1_0);
+ A("XXXX n_pucch_1_1 %d\n", h->n_pucch_1_1);
+ A("XXXX n_pucch_1_2 %d\n", h->n_pucch_1_2);
+ A("XXXX n_pucch_1_3 %d\n", h->n_pucch_1_3);
+ break;
+ }
+
+ case NFAPI_UL_CONFIG_UCI_SR_PDU_TYPE: {
+ nfapi_ul_config_uci_sr_pdu *q = &p->uci_sr_pdu;
+ nfapi_ul_config_sr_information_rel8_t *h =
+ &q->sr_information.sr_information_rel8;
+ A("XXXX rnti %d\n",
+ q->ue_information.ue_information_rel8.rnti);
+ A("XXXX pucch_index %d\n", h->pucch_index);
}
}
+ }
+ }
LOG_I(PHY, "XXXX DL\nXXXX DL\n%s", s);
}
@@ -510,81 +565,69 @@ static void dump_dl(Sched_Rsp_t *d)
/* debug utility functions end */
/****************************************************************************/
-void UL_indication(UL_IND_t *UL_info)
-{
-
+void UL_indication(UL_IND_t *UL_info) {
AssertFatal(UL_info!=NULL,"UL_INFO is null\n");
-
#ifdef DUMP_FAPI
dump_ul(UL_info);
#endif
-
module_id_t module_id = UL_info->module_id;
int CC_id = UL_info->CC_id;
Sched_Rsp_t *sched_info = &Sched_INFO[module_id][CC_id];
IF_Module_t *ifi = if_inst[module_id];
eNB_MAC_INST *mac = RC.mac[module_id];
-
LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d preambles:%d sr_ind:%d]\n",
UL_info->frame,UL_info->subframe,
module_id,CC_id,
- UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs);
- if(UL_info->frame==1023&&UL_info->subframe==6){ // dl scheduling (0,0)
- frame_cnt= (frame_cnt + 1)%7; // to prevent frame_cnt get too big
- LOG_D(MAC,"current (%d,%d) frame count dl is %d\n",UL_info->frame,UL_info->subframe,frame_cnt);
+ UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis,
+ UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs);
+
+ if(UL_info->frame==1023&&UL_info->subframe==6) { // dl scheduling (0,0)
+ frame_cnt= (frame_cnt + 1)%7; // to prevent frame_cnt get too big
+ LOG_D(MAC,"current (%d,%d) frame count dl is %d\n",UL_info->frame,UL_info->subframe,frame_cnt);
}
- if (nfapi_mode != 1)
- {
+ if (NFAPI_MODE != NFAPI_MODE_PNF) {
if (ifi->CC_mask==0) {
ifi->current_frame = UL_info->frame;
ifi->current_subframe = UL_info->subframe;
- }
- else {
+ } else {
AssertFatal(UL_info->frame != ifi->current_frame,"CC_mask %x is not full and frame has changed\n",ifi->CC_mask);
AssertFatal(UL_info->subframe != ifi->current_subframe,"CC_mask %x is not full and subframe has changed\n",ifi->CC_mask);
}
+
ifi->CC_mask |= (1<frame,UL_info->subframe);
-
+ UL_info->frame,UL_info->subframe);
handle_rach(UL_info);
-
handle_sr(UL_info);
-
handle_cqi(UL_info);
-
handle_harq(UL_info);
-
// clear HI prior to handling ULSCH
- uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_id] , UL_info->subframe);
- if(sf_ahead_dl!=255){
- mac->HI_DCI0_req[CC_id][(UL_info->subframe+sf_ahead_dl)%10].hi_dci0_request_body.number_of_hi = 0;
- LOG_D(MAC,"current (%d,%d) clear HI_DCI0_req[0][%d]\n",UL_info->frame,UL_info->subframe,(UL_info->subframe+sf_ahead_dl)%10);
+ uint8_t sf_ahead_dl = ul_subframe2_k_phich(&mac->common_channels[CC_id], UL_info->subframe);
+
+ if(sf_ahead_dl!=255) {
+ mac->HI_DCI0_req[CC_id][(UL_info->subframe+sf_ahead_dl)%10].hi_dci0_request_body.number_of_hi = 0;
+ LOG_D(MAC,"current (%d,%d) clear HI_DCI0_req[0][%d]\n",UL_info->frame,UL_info->subframe,(UL_info->subframe+sf_ahead_dl)%10);
}
-
+
handle_ulsch(UL_info);
- if (nfapi_mode != 1)
- {
+ if (NFAPI_MODE != NFAPI_MODE_PNF) {
if (ifi->CC_mask == ((1<frame+((UL_info->subframe>(9-sf_ahead))?1:0)) % 1024,
- (UL_info->subframe+sf_ahead)%10);
-
+ (UL_info->frame+((UL_info->subframe>(9-sf_ahead))?1:0)) % 1024,
+ (UL_info->subframe+sf_ahead)%10);
ifi->CC_mask = 0;
-
sched_info->module_id = module_id;
sched_info->CC_id = CC_id;
sched_info->frame = (UL_info->frame + ((UL_info->subframe>(9-sf_ahead)) ? 1 : 0)) % 1024;
sched_info->subframe = (UL_info->subframe+sf_ahead)%10;
sched_info->DL_req = &mac->DL_req[CC_id];
sched_info->HI_DCI0_req = &mac->HI_DCI0_req[CC_id][sched_info->subframe];
+
if ((mac->common_channels[CC_id].tdd_Config==NULL) ||
(is_UL_sf(&mac->common_channels[CC_id],sched_info->subframe)>0))
sched_info->UL_req = &mac->UL_req[CC_id];
@@ -592,17 +635,15 @@ void UL_indication(UL_IND_t *UL_info)
sched_info->UL_req = NULL;
sched_info->TX_req = &mac->TX_req[CC_id];
-
#ifdef DUMP_FAPI
dump_dl(sched_info);
#endif
- if (ifi->schedule_response)
- {
+ if (ifi->schedule_response) {
AssertFatal(ifi->schedule_response!=NULL,
- "schedule_response is null (mod %d, cc %d)\n",
- module_id,
- CC_id);
+ "schedule_response is null (mod %d, cc %d)\n",
+ module_id,
+ CC_id);
ifi->schedule_response(sched_info);
}
@@ -611,28 +652,24 @@ void UL_indication(UL_IND_t *UL_info)
}
}
-IF_Module_t *IF_Module_init(int Mod_id){
-
+IF_Module_t *IF_Module_init(int Mod_id) {
AssertFatal(Mod_id %d\n",Mod_id,MAX_IF_MODULES);
-
LOG_D(PHY,"Installing callbacks for IF_Module - UL_indication\n");
if (if_inst[Mod_id]==NULL) {
- if_inst[Mod_id] = (IF_Module_t*)malloc(sizeof(IF_Module_t));
- memset((void*)if_inst[Mod_id],0,sizeof(IF_Module_t));
-
+ if_inst[Mod_id] = (IF_Module_t *)malloc(sizeof(IF_Module_t));
+ memset((void *)if_inst[Mod_id],0,sizeof(IF_Module_t));
if_inst[Mod_id]->CC_mask=0;
if_inst[Mod_id]->UL_indication = UL_indication;
-
AssertFatal(pthread_mutex_init(&if_inst[Mod_id]->if_mutex,NULL)==0,
- "allocation of if_inst[%d]->if_mutex fails\n",Mod_id);
+ "allocation of if_inst[%d]->if_mutex fails\n",Mod_id);
}
+
return if_inst[Mod_id];
}
void IF_Module_kill(int Mod_id) {
-
AssertFatal(Mod_id>MAX_MODULES,"Asking for Module %d > %d\n",Mod_id,MAX_IF_MODULES);
- if (if_inst[Mod_id]!=NULL) free(if_inst[Mod_id]);
+ if (if_inst[Mod_id]!=NULL) free(if_inst[Mod_id]);
}
diff --git a/openair2/RRC/LTE/L2_interface_common.c b/openair2/RRC/LTE/L2_interface_common.c
index c17318d601..b5cc99bc3a 100644
--- a/openair2/RRC/LTE/L2_interface_common.c
+++ b/openair2/RRC/LTE/L2_interface_common.c
@@ -38,7 +38,7 @@
#include "common/ran_context.h"
#if defined(ENABLE_ITTI)
-# include "intertask_interface.h"
+ #include "intertask_interface.h"
#endif
//#define RRC_DATA_REQ_DEBUG
@@ -49,21 +49,21 @@ extern RAN_CONTEXT_t RC;
//------------------------------------------------------------------------------
uint8_t
rrc_data_req(
- const protocol_ctxt_t* const ctxt_pP,
+ const protocol_ctxt_t *const ctxt_pP,
const rb_id_t rb_idP,
const mui_t muiP,
const confirm_t confirmP,
const sdu_size_t sdu_sizeP,
- uint8_t* const buffer_pP,
+ uint8_t *const buffer_pP,
const pdcp_transmission_mode_t modeP
)
//------------------------------------------------------------------------------
{
- if(sdu_sizeP == 255)
- {
+ if(sdu_sizeP == 255) {
LOG_I(RRC,"sdu_sizeP == 255");
return FALSE;
}
+
MSC_LOG_TX_MESSAGE(
ctxt_pP->enb_flag ? MSC_RRC_ENB : MSC_RRC_UE,
ctxt_pP->enb_flag ? MSC_PDCP_ENB : MSC_PDCP_UE,
@@ -74,71 +74,49 @@ rrc_data_req(
ctxt_pP->rnti,
muiP,
sdu_sizeP);
+ MessageDef *message_p;
+ // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
+ uint8_t *message_buffer;
+ message_buffer = itti_malloc (
+ ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE,
+ ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
+ sdu_sizeP);
+ memcpy (message_buffer, buffer_pP, sdu_sizeP);
+ message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ);
+ RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame;
+ RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag;
+ RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP;
+ RRC_DCCH_DATA_REQ (message_p).muip = muiP;
+ RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP;
+ RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP;
+ RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer;
+ //memcpy (RRC_DCCH_DATA_REQ (message_p).sdu_p, buffer_pP, sdu_sizeP);
+ RRC_DCCH_DATA_REQ (message_p).mode = modeP;
+ RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id;
+ RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti;
+ RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index;
+ itti_send_msg_to_task (
+ ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
+ ctxt_pP->instance,
+ message_p);
+ LOG_I(RRC,"sent RRC_DCCH_DATA_REQ to TASK_PDCP_ENB\n");
-#if defined(ENABLE_ITTI)
- {
- MessageDef *message_p;
- // Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
- uint8_t *message_buffer;
+ /* Hack: only trigger PDCP if in CU, otherwise it is triggered by RU threads
+ * Ideally, PDCP would not neet to be triggered like this but react to ITTI
+ * messages automatically */
+ if (ctxt_pP->enb_flag && NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type))
+ pdcp_run(ctxt_pP);
- message_buffer = itti_malloc (
- ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE,
- ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
- sdu_sizeP);
-
- memcpy (message_buffer, buffer_pP, sdu_sizeP);
-
- message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ);
- RRC_DCCH_DATA_REQ (message_p).frame = ctxt_pP->frame;
- RRC_DCCH_DATA_REQ (message_p).enb_flag = ctxt_pP->enb_flag;
- RRC_DCCH_DATA_REQ (message_p).rb_id = rb_idP;
- RRC_DCCH_DATA_REQ (message_p).muip = muiP;
- RRC_DCCH_DATA_REQ (message_p).confirmp = confirmP;
- RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_sizeP;
- RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer;
- //memcpy (RRC_DCCH_DATA_REQ (message_p).sdu_p, buffer_pP, sdu_sizeP);
-
- RRC_DCCH_DATA_REQ (message_p).mode = modeP;
- RRC_DCCH_DATA_REQ (message_p).module_id = ctxt_pP->module_id;
- RRC_DCCH_DATA_REQ (message_p).rnti = ctxt_pP->rnti;
- RRC_DCCH_DATA_REQ (message_p).eNB_index = ctxt_pP->eNB_index;
-
- itti_send_msg_to_task (
- ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE,
- ctxt_pP->instance,
- message_p);
- LOG_I(RRC,"sent RRC_DCCH_DATA_REQ to TASK_PDCP_ENB\n");
-#ifndef UETARGET
- /* Hack: only trigger PDCP if in CU, otherwise it is triggered by RU threads
- * Ideally, PDCP would not neet to be triggered like this but react to ITTI
- * messages automatically */
- if (NODE_IS_CU(RC.rrc[ctxt_pP->module_id]->node_type))
- pdcp_run(ctxt_pP);
-#endif
-
- return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
-
- }
-#else
- return pdcp_data_req (
- ctxt_pP,
- SRB_FLAG_YES,
- rb_idP,
- muiP,
- confirmP,
- sdu_sizeP,
- buffer_pP,
- modeP);
-#endif
+ return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway.
}
//------------------------------------------------------------------------------
void
rrc_data_ind(
- const protocol_ctxt_t* const ctxt_pP,
+ const protocol_ctxt_t *const ctxt_pP,
const rb_id_t Srb_id,
const sdu_size_t sdu_sizeP,
- const uint8_t* const buffer_pP
+ const uint8_t *const buffer_pP
)
//------------------------------------------------------------------------------
{
@@ -162,10 +140,8 @@ rrc_data_ind(
MessageDef *message_p;
// Uses a new buffer to avoid issue with PDCP buffer content that could be changed by PDCP (asynchronous message handling).
uint8_t *message_buffer;
-
message_buffer = itti_malloc (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_sizeP);
memcpy (message_buffer, buffer_pP, sdu_sizeP);
-
message_p = itti_alloc_new_message (ctxt_pP->enb_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND);
RRC_DCCH_DATA_IND (message_p).frame = ctxt_pP->frame;
RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index;
@@ -174,16 +150,13 @@ rrc_data_ind(
RRC_DCCH_DATA_IND (message_p).rnti = ctxt_pP->rnti;
RRC_DCCH_DATA_IND (message_p).module_id = ctxt_pP->module_id;
RRC_DCCH_DATA_IND (message_p).eNB_index = ctxt_pP->eNB_index;
-
itti_send_msg_to_task (ctxt_pP->enb_flag ? TASK_RRC_ENB : TASK_RRC_UE, ctxt_pP->instance, message_p);
}
#else
-
- rrc_eNB_decode_dcch(
- ctxt_pP,
- DCCH_index,
- buffer_pP,
- sdu_sizeP);
-
+ rrc_eNB_decode_dcch(
+ ctxt_pP,
+ DCCH_index,
+ buffer_pP,
+ sdu_sizeP);
#endif
}
diff --git a/openair2/RRC/LTE/rrc_UE.c b/openair2/RRC/LTE/rrc_UE.c
index a00bc53759..4b7e765241 100644
--- a/openair2/RRC/LTE/rrc_UE.c
+++ b/openair2/RRC/LTE/rrc_UE.c
@@ -801,42 +801,33 @@ rrc_ue_establish_drb(
(void)ip_addr_offset4;
LOG_I(RRC,"[UE %d] Frame %d: processing RRCConnectionReconfiguration: reconfiguring DRB %ld/LCID %d\n",
ue_mod_idP, frameP, DRB_config->drb_Identity, (int)*DRB_config->logicalChannelIdentity);
- /*
- rrc_pdcp_config_req (ue_mod_idP+NB_eNB_INST, frameP, 0, CONFIG_ACTION_ADD,
- (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, UNDEF_SECURITY_MODE);
- rrc_rlc_config_req(ue_mod_idP+NB_eNB_INST,frameP,0,CONFIG_ACTION_ADD,
- (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity,
- RADIO_ACCESS_BEARER,Rlc_info_um);
- */
- // if(!EPC_MODE_ENABLED) {
- //# if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) && !defined(OAI_USRP) && !defined(OAI_BLADERF) && !defined(ETHERNET) && !defined(LINK_ENB_PDCP_TO_GTPV1U)
- ip_addr_offset3 = 0;
- ip_addr_offset4 = 1;
- LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oip%d, IP 10.0.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP,
- ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1);
- oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id
- ip_addr_offset3+ue_mod_idP+1, // third_octet
- ip_addr_offset4+ue_mod_idP+1, // fourth_octet
- "oip"); // interface suffix
+ if(!EPC_MODE_ENABLED) {
+ ip_addr_offset3 = 0;
+ ip_addr_offset4 = 1;
+ LOG_I(OIP,"[UE %d] trying to bring up the OAI interface %d, IP X.Y.%d.%d\n", ue_mod_idP, ip_addr_offset3+ue_mod_idP,
+ ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1);
+ oip_ifup=nas_config(ip_addr_offset3+ue_mod_idP+1, // interface_id
+ UE_NAS_USE_TUN?1:(ip_addr_offset3+ue_mod_idP+1), // third_octet
+ ip_addr_offset4+ue_mod_idP+1, // fourth_octet
+ "oip"); // interface suffix (when using kernel module)
- if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB
- LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n",
- ue_mod_idP,
- ip_addr_offset3+ue_mod_idP,
- (long int)((eNB_index * LTE_maxDRB) + DRB_config->drb_Identity));
- rb_conf_ipv4(0,//add
- ue_mod_idP,//cx align with the UE index
- ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index
- (eNB_index * LTE_maxDRB) + DRB_config->drb_Identity,//rb
- 0,//dscp
- ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr
- ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr
- LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index);
- }
+ if (oip_ifup == 0 && (!UE_NAS_USE_TUN)) { // interface is up --> send a config the DRB
+ LOG_I(OIP,"[UE %d] Config the ue net interface %d to send/receive pkt on DRB %ld to/from the protocol stack\n",
+ ue_mod_idP,
+ ip_addr_offset3+ue_mod_idP,
+ (long int)((eNB_index * LTE_maxDRB) + DRB_config->drb_Identity));
+ rb_conf_ipv4(0,//add
+ ue_mod_idP,//cx align with the UE index
+ ip_addr_offset3+ue_mod_idP,//inst num_enb+ue_index
+ (eNB_index * LTE_maxDRB) + DRB_config->drb_Identity,//rb
+ 0,//dscp
+ ipv4_address(ip_addr_offset3+ue_mod_idP+1,ip_addr_offset4+ue_mod_idP+1),//saddr
+ ipv4_address(ip_addr_offset3+ue_mod_idP+1,eNB_index+1));//daddr
+ LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",ue_mod_idP,eNB_index);
+ }
+ } // !EPC_MODE_ENABLED
- //# endif
- // }
return(0);
}
@@ -2656,11 +2647,6 @@ int decode_BCCH_DLSCH_Message(
}
}
- // if ((rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE)
- //#if defined(ENABLE_USE_MME)
- // && (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL)
- //#endif
- // ) {
if (rrc_get_sub_state(ctxt_pP->module_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) {
if ( (UE_rrc_inst[ctxt_pP->module_id].initialNasMsg.data != NULL) || (!EPC_MODE_ENABLED)) {
rrc_ue_generate_RRCConnectionRequest(ctxt_pP, 0);
diff --git a/openair2/RRC/NAS/nas_config.c b/openair2/RRC/NAS/nas_config.c
index 61909df5ec..aa6696c864 100644
--- a/openair2/RRC/NAS/nas_config.c
+++ b/openair2/RRC/NAS/nas_config.c
@@ -168,7 +168,6 @@ int setInterfaceParameter(char *interfaceName, char *settingAddress, int operati
}
close(sock_fd);
- // printf("Set OK!\n");
return 0;
}
@@ -225,7 +224,9 @@ int NAS_config(char *interfaceName, char *ipAddress, char *networkMask, char *br
// if(!returnValue)
// returnValue=set_gateway(interfaceName, broadcastAddress);
- bringInterfaceUp(interfaceName, 1);
+ if(!returnValue)
+ returnValue = bringInterfaceUp(interfaceName, 1);
+
return returnValue;
}
@@ -236,8 +237,8 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname)
char broadcastAddress[20];
char interfaceName[20];
int returnValue;
- sprintf(ipAddress, "10.0.%d.%d", thirdOctet,fourthOctet);
- sprintf(broadcastAddress, "10.0.%d.255", thirdOctet);
+ sprintf(ipAddress, "%s.%d.%d", baseNetAddress,thirdOctet,fourthOctet);
+ sprintf(broadcastAddress, "%s.%d.255",baseNetAddress, thirdOctet);
sprintf(interfaceName, "%s%s%d", (UE_NAS_USE_TUN || ENB_NAS_USE_TUN)?"oaitun_":ifname,
UE_NAS_USE_TUN?"ue": (ENB_NAS_USE_TUN?"enb":""),interface_id);
bringInterfaceUp(interfaceName, 0);
@@ -252,7 +253,16 @@ int nas_config(int interface_id, int thirdOctet, int fourthOctet, char *ifname)
if(!returnValue)
returnValue= setInterfaceParameter(interfaceName, broadcastAddress,SIOCSIFBRDADDR);
- bringInterfaceUp(interfaceName, 1);
+ if(!returnValue)
+ bringInterfaceUp(interfaceName, 1);
+
+ if(!returnValue)
+ LOG_I(OIP,"Interface %s successfuly configured, ip address %s, mask %s broadcast address %s\n",
+ interfaceName, ipAddress, netMask, broadcastAddress);
+ else
+ LOG_E(OIP,"Interface %s couldn't be configured (ip address %s, mask %s broadcast address %s)\n",
+ interfaceName, ipAddress, netMask, broadcastAddress);
+
return returnValue;
}
diff --git a/openair3/NAS/UE/ESM/esm_ebr_context.c b/openair3/NAS/UE/ESM/esm_ebr_context.c
index 5830518df0..cd493dd09e 100644
--- a/openair3/NAS/UE/ESM/esm_ebr_context.c
+++ b/openair3/NAS/UE/ESM/esm_ebr_context.c
@@ -50,7 +50,7 @@ Description Defines functions used to handle EPS bearer contexts.
#include "system.h"
#include "assertions.h"
#include "pdcp.h"
-
+#include "nfapi/oai_integration/vendor_ext.h"
#include
#include
@@ -59,7 +59,6 @@ Description Defines functions used to handle EPS bearer contexts.
#include "openairinterface5g_limits.h"
extern uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX];
#endif
-extern uint8_t nfapi_mode;
/****************************************************************************/
/**************** E X T E R N A L D E F I N I T I O N S ****************/
@@ -268,7 +267,7 @@ int esm_ebr_context_create(
strcpy(broadcast, ipv4_addr);
}
- if(nfapi_mode ==3) {
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
// this is for L2 FAPI simulator.
// change for multiple UE's like 256UEs.
// if it's made too many tables , OS may crush so we use one table.
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index bcc9e8cfc5..8ae3d8956c 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -48,7 +48,7 @@
#include "PHY/defs_eNB.h"
#include "SCHED/sched_eNB.h"
#include "PHY/LTE_TRANSPORT/transport_proto.h"
-
+#include "nfapi/oai_integration/vendor_ext.h"
#undef MALLOC //there are two conflicting definitions, so we better make sure we don't use it at all
//#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all
@@ -139,7 +139,7 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
#endif
-extern uint8_t nfapi_mode;
+
extern void oai_subframe_ind(uint16_t sfn, uint16_t sf);
extern void add_subframe(uint16_t *frameP, uint16_t *subframeP, int offset);
@@ -160,7 +160,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name
return -1;
}
- if (nfapi_mode == 1) {
+ if (NFAPI_MODE==NFAPI_MODE_PNF) {
// I am a PNF and I need to let nFAPI know that we have a (sub)frame tick
uint16_t frame = proc->frame_rx;
uint16_t subframe = proc->subframe_rx;
@@ -188,7 +188,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name
}
}
- if (nfapi_mode == 1 && eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) {
+ if (NFAPI_MODE==NFAPI_MODE_PNF && eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0) {
LOG_E(PHY, "eNB->pdcch_vars[proc->subframe_tx&1].num_pdcch_symbols == 0");
return 0;
}
@@ -208,14 +208,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,L1_rxtx_proc_t *proc, char *thread_name
release_UE_in_freeList(eNB->Mod_id);
// UE-specific RX processing for subframe n
- if (nfapi_mode == 0 || nfapi_mode == 1) {
+ if (NFAPI_MODE==NFAPI_MONOLITHIC || NFAPI_MODE==NFAPI_MODE_PNF) {
phy_procedures_eNB_uespec_RX(eNB, proc);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER, 1 );
#if defined(PRE_SCD_THREAD)
- if (nfapi_mode == 2) {
+ if (NFAPI_MODE==NFAPI_MODE_VNF) {
new_dlsch_ue_select_tbl_in_use = dlsch_ue_select_tbl_in_use;
dlsch_ue_select_tbl_in_use = !dlsch_ue_select_tbl_in_use;
// L2-emulator can work only one eNB.
@@ -365,7 +365,7 @@ static void *L1_thread( void *param ) {
L1_rxtx_proc_t *proc;
// Working
- if(nfapi_mode ==2) {
+ if(NFAPI_MODE==NFAPI_MODE_VNF) {
proc = (L1_rxtx_proc_t *)param;
} else {
L1_proc_t *eNB_proc = (L1_proc_t *)param;
@@ -406,7 +406,7 @@ static void *L1_thread( void *param ) {
if (release_thread(&proc->mutex,&proc->instance_cnt,thread_name)<0) break;
- if (nfapi_mode!=2) {
+ if (NFAPI_MODE!=NFAPI_MODE_VNF) {
if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) wakeup_tx(eNB);
else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT) wakeup_txfh(proc,eNB);
}
@@ -908,10 +908,10 @@ void init_eNB_proc(int inst) {
LOG_I(PHY,"eNB->single_thread_flag:%d\n", eNB->single_thread_flag);
- if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
+ if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && NFAPI_MODE!=NFAPI_MODE_VNF) {
pthread_create( &L1_proc->pthread, attr0, L1_thread, proc );
pthread_create( &L1_proc_tx->pthread, attr1, L1_thread_tx, proc);
- } else if (nfapi_mode == 2) { // this is neccesary in VNF or L2 FAPI simulator.
+ } else if (NFAPI_MODE==NFAPI_MODE_VNF) { // this is neccesary in VNF or L2 FAPI simulator.
// Original Code from Fujitsu w/ old structure/field name
//pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] );
//pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] );
@@ -974,7 +974,7 @@ void kill_eNB_proc(int inst) {
LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst );
- if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
+ if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && NFAPI_MODE!=NFAPI_MODE_VNF) {
pthread_mutex_lock(&L1_proc->mutex);
L1_proc->instance_cnt = 0;
pthread_cond_signal(&L1_proc->cond);
@@ -1006,7 +1006,7 @@ void kill_eNB_proc(int inst) {
LOG_I(PHY, "Destroying UL_INFO mutex\n");
pthread_mutex_destroy(&eNB->UL_INFO_mutex);
- if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
+ if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && NFAPI_MODE!=NFAPI_MODE_VNF) {
LOG_I(PHY, "Joining L1_proc mutex/cond\n");
pthread_join( L1_proc->pthread, (void **)&status );
LOG_I(PHY, "Joining L1_proc_tx mutex/cond\n");
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index d4c53441d6..93a2440b94 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -75,6 +75,7 @@
#include "PHY_INTERFACE/phy_interface.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "UTIL/OTG/otg_tx.h"
#include "UTIL/OTG/otg_externs.h"
#include "UTIL/MATH/oml.h"
@@ -109,7 +110,7 @@ extern int emulate_rf;
extern int numerology;
extern clock_source_t clock_source;
extern uint8_t dlsch_ue_select_tbl_in_use;
-extern uint8_t nfapi_mode;
+
extern PARALLEL_CONF_t get_thread_parallel_conf(void);
extern WORKER_CONF_t get_thread_worker_conf(void);
@@ -1869,7 +1870,7 @@ void *pre_scd_thread( void *param ) {
RU_t *ru = (RU_t *)param;
// L2-emulator can work only one eNB
- if( nfapi_mode == 2)
+ if( NFAPI_MODE==NFAPI_MODE_VNF)
Mod_id = 0;
else
Mod_id = ru->eNB_list[0]->Mod_id;
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index aa8d832ed3..fbfcf9020b 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -64,7 +64,7 @@
#include "LAYER2/MAC/mac_proto.h"
#include "RRC/LTE/rrc_vars.h"
#include "PHY_INTERFACE/phy_interface_vars.h"
-
+#include "nfapi/oai_integration/vendor_ext.h"
#ifdef SMBV
#include "PHY/TOOLS/smbv.h"
unsigned short config_frames[4] = {2,9,11,13};
@@ -112,7 +112,6 @@ pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
-uint8_t nfapi_mode = 0; // Default to monolithic mode
uint16_t sf_ahead=4;
@@ -133,7 +132,7 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
int UE_scan = 1;
int UE_scan_carrier = 0;
runmode_t mode = normal_txrx;
-int simL1flag;
+
FILE *input_fd=NULL;
@@ -657,21 +656,22 @@ int main( int argc, char **argv ) {
/* Read configuration */
if (RC.nb_inst > 0)
read_config_and_init();
-
+
/* Start the agent. If it is turned off in the configuration, it won't start */
RCconfig_flexran();
+
for (i = 0; i < RC.nb_inst; i++) {
flexran_agent_start(i);
}
uint32_t pdcp_initmask = ( IS_SOFTMODEM_NOS1 )? ( PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT) : LINK_ENB_PDCP_TO_GTPV1U_BIT;
+
if ( IS_SOFTMODEM_NOS1)
pdcp_initmask = pdcp_initmask | ENB_NAS_USE_TUN_BIT | SOFTMODEM_NOKRNMOD_BIT ;
pdcp_module_init(pdcp_initmask);
if (RC.nb_inst > 0) {
-
if (create_tasks(1) < 0) {
printf("cannot create ITTI tasks\n");
exit(-1);
@@ -682,8 +682,7 @@ int main( int argc, char **argv ) {
RRC_CONFIGURATION_REQ(msg_p) = RC.rrc[enb_id]->configuration;
itti_send_msg_to_task (TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
}
- }
- else {
+ } else {
printf("No ITTI, Initializing L1\n");
RCconfig_L1();
}
@@ -705,7 +704,6 @@ int main( int argc, char **argv ) {
mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL);
-
#ifdef XFORMS
int UE_id;
printf("XFORMS\n");
@@ -740,46 +738,24 @@ int main( int argc, char **argv ) {
printf("Scope thread created, ret=%d\n",ret);
}
+
#endif
-
rt_sleep_ns(10*100000000ULL);
- if (nfapi_mode) {
- LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
+ if (NFAPI_MODE!=NFAPI_MONOLITHIC) {
+ LOG_I(ENB_APP,"NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL);
}
- const char *nfapi_mode_str = "";
-
- switch(nfapi_mode) {
- case 0:
- nfapi_mode_str = "MONOLITHIC";
- break;
-
- case 1:
- nfapi_mode_str = "PNF";
- break;
-
- case 2:
- nfapi_mode_str = "VNF";
- break;
-
- default:
- nfapi_mode_str = "";
- break;
- }
-
- LOG_I(ENB_APP,"NFAPI MODE:%s\n", nfapi_mode_str);
-
- if (nfapi_mode==2) {// VNF
+ if (NFAPI_MODE==NFAPI_MODE_VNF) {// VNF
#if defined(PRE_SCD_THREAD)
init_ru_vnf(); // ru pointer is necessary for pre_scd.
#endif
wait_nfapi_init("main?");
}
- LOG_I(ENB_APP,"START MAIN THREADS\n");
+ LOG_I(ENB_APP,"START MAIN THREADS\n");
// start the main threads
number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
@@ -798,11 +774,11 @@ int main( int argc, char **argv ) {
// RU thread and some L1 procedure aren't necessary in VNF or L2 FAPI simulator.
// but RU thread deals with pre_scd and this is necessary in VNF and simulator.
// some initialization is necessary and init_ru_vnf do this.
- if (RC.nb_RU >0 && nfapi_mode != 2) {
+ if (RC.nb_RU >0 && NFAPI_MODE!=NFAPI_MODE_VNF) {
printf("Initializing RU threads\n");
init_RU(get_softmodem_params()->rf_config_file);
- for (ru_id=0; ru_idrf_map.card=0;
RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
}
@@ -810,7 +786,7 @@ int main( int argc, char **argv ) {
config_sync_var=0;
- if (nfapi_mode==1) { // PNF
+ if (NFAPI_MODE==NFAPI_MODE_PNF) { // PNF
wait_nfapi_init("main?");
}
@@ -818,21 +794,21 @@ int main( int argc, char **argv ) {
fflush(stdout);
fflush(stderr);
wait_RUs();
- LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU);
+ LOG_I(ENB_APP,"RC.nb_RU:%d\n", RC.nb_RU);
// once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration)
printf("ALL RUs ready - init eNBs\n");
- if (nfapi_mode != 1 && nfapi_mode != 2) {
- LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n");
+ if (NFAPI_MODE!=NFAPI_MODE_PNF && NFAPI_MODE!=NFAPI_MODE_VNF) {
+ LOG_I(ENB_APP,"Not NFAPI mode - call init_eNB_afterRU()\n");
init_eNB_afterRU();
} else {
- LOG_I(ENB_APP,"NFAPI mode - DO NOT call init_eNB_afterRU()\n");
+ LOG_I(ENB_APP,"NFAPI mode - DO NOT call init_eNB_afterRU()\n");
}
- LOG_UI(ENB_APP,"ALL RUs ready - ALL eNBs ready\n");
+ LOG_UI(ENB_APP,"ALL RUs ready - ALL eNBs ready\n");
// connect the TX/RX buffers
sleep(1); /* wait for thread activation */
- LOG_I(ENB_APP,"Sending sync to all threads\n");
+ LOG_I(ENB_APP,"Sending sync to all threads\n");
pthread_mutex_lock(&sync_mutex);
sync_var=0;
pthread_cond_broadcast(&sync_cond);
@@ -848,7 +824,6 @@ int main( int argc, char **argv ) {
LOG_I(ENB_APP,"oai_exit=%d\n",oai_exit);
// stop threads
-
if (RC.nb_inst == 0 || !NODE_IS_CU(RC.rrc[0]->node_type)) {
int UE_id;
#ifdef XFORMS
@@ -868,11 +843,12 @@ int main( int argc, char **argv ) {
}
}
}
-#endif
+#endif
LOG_I(ENB_APP,"stopping MODEM threads\n");
stop_eNB(NB_eNB_INST);
stop_RU(RC.nb_RU);
+
/* release memory used by the RU/eNB threads (incomplete), after all
* threads have been stopped (they partially use the same memory) */
for (int inst = 0; inst < NB_eNB_INST; inst++) {
@@ -881,9 +857,11 @@ int main( int argc, char **argv ) {
phy_free_lte_eNB(RC.eNB[inst][cc_id]);
}
}
+
for (int inst = 0; inst < RC.nb_RU; inst++) {
phy_free_RU(RC.ru[inst]);
}
+
free_lte_top();
end_configmodule();
pthread_cond_destroy(&sync_cond);
@@ -891,12 +869,13 @@ int main( int argc, char **argv ) {
pthread_cond_destroy(&nfapi_sync_cond);
pthread_mutex_destroy(&nfapi_sync_mutex);
pthread_mutex_destroy(&ue_pf_po_mutex);
-
+
for(ru_id=0; ru_idrfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
}
+
if (RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index 9b820e6e19..2d05ca174e 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -243,6 +243,7 @@
#define SOFTMODEM_NONBIOT_BIT (1<<2)
#define SOFTMODEM_RFSIM_BIT (1<<10)
#define SOFTMODEM_BASICSIM_BIT (1<<11)
+#define SOFTMODEM_SIML1_BIT (1<<12)
typedef struct {
uint64_t optmask;
THREAD_STRUCT thread_struct;
@@ -265,6 +266,7 @@ typedef struct {
#define IS_SOFTMODEM_NONBIOT ( get_softmodem_optmask() & SOFTMODEM_NONBIOT_BIT)
#define IS_SOFTMODEM_RFSIM ( get_softmodem_optmask() & SOFTMODEM_RFSIM_BIT)
#define IS_SOFTMODEM_BASICSIM ( get_softmodem_optmask() & SOFTMODEM_BASICSIM_BIT)
+#define IS_SOFTMODEM_SIML1 ( get_softmodem_optmask() & SOFTMODEM_SIML1_BIT)
extern uint64_t get_softmodem_optmask(void);
extern uint64_t set_softmodem_optmask(uint64_t bitmask);
extern void get_common_options(void);
diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c
index bb2319774c..4efe974b75 100644
--- a/targets/RT/USER/lte-ue.c
+++ b/targets/RT/USER/lte-ue.c
@@ -53,6 +53,7 @@
#include
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "UTIL/OTG/otg_tx.h"
#include "UTIL/OTG/otg_externs.h"
#include "UTIL/MATH/oml.h"
@@ -63,7 +64,7 @@
#include "T.h"
extern double cpuf;
-extern uint8_t nfapi_mode;
+
#define FRAME_PERIOD 100000000ULL
#define DAQ_PERIOD 66667ULL
@@ -93,7 +94,7 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind);
extern int oai_nfapi_rx_ind(nfapi_rx_indication_t *ind);
extern int multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP);
-extern int simL1flag;
+
extern uint16_t sf_ahead;
//extern int tx_req_UE_MAC1();
@@ -192,7 +193,7 @@ PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
ue->mac_enabled = 1;
// In phy_stub_UE (MAC-to-MAC) mode these init functions don't need to get called. Is this correct?
- if (nfapi_mode!=3) {
+ if (NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
// initialize all signal buffers
init_lte_ue_signal(ue,1,abstraction_flag);
// intialize transport
@@ -266,7 +267,7 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
LOG_I(PHY,"Allocating UE context %d\n",inst);
- if (simL1flag == 0) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
+ if ( !IS_SOFTMODEM_SIML1 ) PHY_vars_UE_g[inst][0] = init_ue_vars(fp0,inst,0);
else {
// needed for memcopy below. these are not used in the RU, but needed for UE
RC.ru[0]->frame_parms.nb_antennas_rx = fp0->nb_antennas_rx;
@@ -354,12 +355,12 @@ void init_UE(int nb_inst,int eMBMS_active, int uecap_xer_in, int timing_correcti
*/
UE->N_TA_offset = 0;
- if (simL1flag == 1) init_ue_devices(UE);
+ if (IS_SOFTMODEM_SIML1 ) init_ue_devices(UE);
LOG_I(PHY,"Intializing UE Threads for instance %d (%p,%p)...\n",inst,PHY_vars_UE_g[inst],PHY_vars_UE_g[inst][0]);
init_UE_threads(inst);
- if (simL1flag == 0) {
+ if (!IS_SOFTMODEM_SIML1 ) {
ret = openair0_device_load(&(UE->rfdevice), &openair0_cfg[0]);
if (ret !=0) {
@@ -397,7 +398,7 @@ void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in,
printf("UE threads created \n");
LOG_I(PHY,"Starting multicast link on %s\n",emul_iface);
- if(nfapi_mode!=3)
+ if(NFAPI_MODE!=NFAPI_UE_STUB_PNF)
multicast_link_start(ue_stub_rx_handler,0,emul_iface);
}
@@ -427,7 +428,7 @@ void init_UE_stub(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_ifa
printf("UE threads created \n");
LOG_I(PHY,"Starting multicast link on %s\n",emul_iface);
- if(nfapi_mode !=3)
+ if(NFAPI_MODE!=NFAPI_UE_STUB_PNF)
multicast_link_start(ue_stub_rx_handler,0,emul_iface);
}
@@ -1123,7 +1124,7 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) {
hi_dci0_req_UE_MAC(hi_dci0_req, ue_Mod_id);
}
- if(nfapi_mode!=3)
+ if(NFAPI_MODE!=NFAPI_UE_STUB_PNF)
phy_procedures_UE_SL_TX(UE,proc);
}
@@ -1405,7 +1406,7 @@ static void *UE_phy_stub_thread_rxn_txnp4(void *arg) {
hi_dci0_req = NULL;
}
- if (nfapi_mode != 3)
+ if (NFAPI_MODE!=NFAPI_UE_STUB_PNF)
phy_procedures_UE_SL_TX(UE,proc);
}
@@ -1858,7 +1859,7 @@ void init_UE_single_thread_stub(int nb_inst) {
AssertFatal(PHY_vars_UE_g[i]!=NULL,"PHY_vars_UE_g[inst] is NULL\n");
AssertFatal(PHY_vars_UE_g[i][0]!=NULL,"PHY_vars_UE_g[inst][0] is NULL\n");
- if(nfapi_mode == 3) {
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
#ifdef NAS_UE
MessageDef *message_p;
message_p = itti_alloc_new_message(TASK_NAS_UE, INITIALIZE_MESSAGE);
@@ -2040,7 +2041,7 @@ static void *timer_thread( void *param ) {
opp_enabled = 1;
// first check if we are receiving timing indications
- if(nfapi_mode==4) {
+ if(NFAPI_MODE==NFAPI_UE_STUB_OFFNET) {
usleep(10000);
if (UE->instance_cnt_timer > 0) {
@@ -2128,7 +2129,7 @@ static void *timer_thread( void *param ) {
pdu.header.packet_type = TTI_SYNC;
pdu.header.absSF = (timer_frame*10)+timer_subframe;
- if (nfapi_mode!=3) {
+ if (NFAPI_MODE != NFAPI_UE_STUB_PNF) {
multicast_link_write_sock(0,
(char *)&pdu,
sizeof(UE_tport_header_t));
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index 159cde39ae..3ae3e22ef0 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -68,6 +68,7 @@
#include "PHY_INTERFACE/phy_interface_vars.h"
#include "common/utils/LOG/log.h"
+#include "nfapi/oai_integration/vendor_ext.h"
#include "UTIL/OTG/otg_tx.h"
#include "UTIL/OTG/otg_externs.h"
#include "UTIL/MATH/oml.h"
@@ -109,7 +110,7 @@ pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
-uint8_t nfapi_mode = 0;
+
#ifdef UESIM_EXPANSION
uint16_t inst_pdcp_list[NUMBER_OF_UE_MAX];
#endif
@@ -141,7 +142,7 @@ int32_t uplink_frequency_offset[MAX_NUM_CCs][4];
int UE_scan = 1;
int UE_scan_carrier = 0;
-int simL1flag = 0;
+
int snr_dB=25;
runmode_t mode = normal_txrx;
@@ -321,12 +322,10 @@ void exit_function(const char *file, const char *function, const int line, const
}
sleep(1); //allow lte-softmodem threads to exit first
-#if defined(ENABLE_ITTI)
if(PHY_vars_UE_g != NULL )
itti_terminate_tasks (TASK_UNKNOWN);
-#endif
exit(1);
}
@@ -403,6 +402,8 @@ static void get_options(void) {
char *loopfile=NULL;
int dumpframe;
int timingadv;
+ uint8_t nfapi_mode;
+ int simL1flag ;
set_default_frame_parms(frame_parms);
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
/* unknown parameters on command line will be checked in main
@@ -413,6 +414,10 @@ static void get_options(void) {
paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC;
config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL);
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
+ nfapi_setmode(nfapi_mode);
+
+ if (simL1flag)
+ set_softmodem_optmask(SOFTMODEM_SIML1_BIT);
if (loopfile != NULL) {
printf("Input file for hardware emulation: %s",loopfile);
@@ -445,7 +450,7 @@ static void get_options(void) {
}
UE_scan=0;
-
+
if (tddflag > 0) {
for (CC_id=0; CC_idframe_type = TDD;
@@ -487,16 +492,6 @@ static void get_options(void) {
rx_gain[0][CC_id] = rx_gain[0][0];
tx_gain[0][CC_id] = tx_gain[0][0];
}
-
- /*
- if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) && (!(CONFIG_ISFLAGSET(CONFIG_NOOOPT))) ) {
- // Here the configuration file is the XER encoded UE capabilities
- // Read it in and store in asn1c data structures
- sprintf(uecap_xer,"%stargets/PROJECTS/GENERIC-LTE-EPC/CONF/UE_config.xml",getenv("OPENAIR_HOME"));
- printf("%s\n",uecap_xer);
- if(nfapi_mode!=3)
- uecap_xer_in=1;
- } *//* UE with config file */
}
@@ -634,10 +629,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
-
-#if defined(ENABLE_ITTI)
-/*
- * helper function to terminate a certain ITTI task
+/* helper function to terminate a certain ITTI task
*/
void terminate_task(task_id_t task_id, module_id_t mod_id) {
LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id);
@@ -647,11 +639,6 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) {
}
-
-#endif
-
-
-
static inline void wait_nfapi_init(char *thread_name) {
printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name);
pthread_mutex_lock( &nfapi_sync_mutex );
@@ -712,13 +699,11 @@ int main( int argc, char **argv ) {
EPC_MODE_ENABLED = !IS_SOFTMODEM_NOS1;
printf("Running with %d UE instances\n",NB_UE_INST);
- if (NB_UE_INST > 1 && simL1flag != 1 && nfapi_mode != 3) {
+ if (NB_UE_INST > 1 && (!IS_SOFTMODEM_SIML1) && NFAPI_MODE!=NFAPI_UE_STUB_PNF) {
printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n");
abort();
}
- printf("NFAPI_MODE value: %d \n", nfapi_mode);
-
// Checking option of nums_ue_thread.
if(NB_THREAD_INST < 1) {
printf("Running with 0 UE rxtx thread, exiting.\n");
@@ -731,17 +716,6 @@ int main( int argc, char **argv ) {
abort();
}
- // Not sure if the following is needed here
- /*if (CONFIG_ISFLAGSET(CONFIG_ABORT)) {
- if (UE_flag == 0) {
- fprintf(stderr,"Getting configuration failed\n");
- exit(-1);
- }
- else {
- printf("Setting nfapi mode to UE_STUB_OFFNET\n");
- nfapi_mode = 4;
- }
- }*/
#if T_TRACER
T_Config_Init();
#endif
@@ -762,7 +736,7 @@ int main( int argc, char **argv ) {
init_opt();
uint32_t pdcp_initmask = (!IS_SOFTMODEM_NOS1 )? LINK_ENB_PDCP_TO_GTPV1U_BIT : (LINK_ENB_PDCP_TO_GTPV1U_BIT | PDCP_USE_NETLINK_BIT | LINK_ENB_PDCP_TO_IP_DRIVER_BIT);
- if ( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_mode == 3) ) {
+ if ( IS_SOFTMODEM_BASICSIM || IS_SOFTMODEM_RFSIM || (nfapi_getmode()==NFAPI_UE_STUB_PNF) ) {
pdcp_initmask = pdcp_initmask | UE_NAS_USE_TUN_BIT;
}
@@ -795,7 +769,7 @@ int main( int argc, char **argv ) {
NB_INST=1;
- if(nfapi_mode == 3) {
+ if(NFAPI_MODE==NFAPI_UE_STUB_PNF) {
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST);
for (int i=0; i";
- // start the main UE threads
int eMBMS_active = 0;
- switch(nfapi_mode) {
- case 0:
- nfapi_mode_str = "MONOLITHIC";
- break;
-
- case 1:
- nfapi_mode_str = "PNF";
- break;
-
- case 2:
- nfapi_mode_str = "VNF";
- break;
-
- case 3:
- nfapi_mode_str = "UE_STUB_PNF";
- break;
-
- case 4:
- nfapi_mode_str = "UE_STUB_OFFNET";
- break;
-
- default:
- nfapi_mode_str = "";
- break;
- }
-
- printf("NFAPI MODE:%s\n", nfapi_mode_str);
-
- if (nfapi_mode==3) { // UE-STUB-PNF
- config_sync_var=0;
- wait_nfapi_init("main?");
- //Panos: Temporarily we will be using single set of threads for multiple UEs.
- //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface);
- init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface);
+ if (NFAPI_MODE==NFAPI_UE_STUB_PNF) { // UE-STUB-PNF
+ config_sync_var=0;
+ wait_nfapi_init("main?");
+ //Panos: Temporarily we will be using single set of threads for multiple UEs.
+ //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface);
+ init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface);
} else {
- init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0],
- frame_parms[0]);
+ init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0],
+ frame_parms[0]);
}
if (get_softmodem_params()->phy_test==0) {
@@ -922,25 +864,14 @@ int main( int argc, char **argv ) {
dl_phy_sync_success (0, 0, 0, 1);
}
- if (nfapi_mode!=3) {
- number_of_cards = 1;
+ if (NFAPI_MODE != NFAPI_UE_STUB_PNF) {
+ number_of_cards = 1;
- for(CC_id=0; CC_idrf_map.card=0;
- PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
- }
- }
-
- // connect the TX/RX buffers
-
- /*
- if(nfapi_mode!=3) {
- if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) {
- printf("Error setting up eNB buffer\n");
- exit(-1);
+ for(CC_id=0; CC_idrf_map.card=0;
+ PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
}
}
- */
if (input_fd) {
printf("Reading in from file to antenna buffer %d\n",0);
@@ -954,7 +885,7 @@ int main( int argc, char **argv ) {
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
- if (simL1flag==1) {
+ if (IS_SOFTMODEM_SIML1 ) {
init_ocm((double)snr_dB,0);
PHY_vars_UE_g[0][0]->no_timing_correction = 1;
}