Commit 04d27b9c authored by Andrew Burger's avatar Andrew Burger

Finalized Raymond changes

parent 898d402a
...@@ -50,6 +50,9 @@ queue_t tx_req_pdu_queue; ...@@ -50,6 +50,9 @@ queue_t tx_req_pdu_queue;
queue_t ul_config_req_queue; queue_t ul_config_req_queue;
queue_t hi_dci0_req_queue; queue_t hi_dci0_req_queue;
int subframe_sf = 0;
int frame_sfn = 0;
void init_queue(queue_t *q) { void init_queue(queue_t *q) {
memset(q, 0, sizeof(*q)); memset(q, 0, sizeof(*q));
pthread_mutex_init(&q->mutex, NULL); pthread_mutex_init(&q->mutex, NULL);
...@@ -1152,14 +1155,11 @@ void *ue_standalone_pnf_task(void *context) ...@@ -1152,14 +1155,11 @@ void *ue_standalone_pnf_task(void *context)
continue; continue;
} }
if (len == 2 && len > 0) if (len == sizeof(uint16_t))
{ {
memcpy((void *)&sfn_sf, buffer, sizeof(sfn_sf)); memcpy((void *)&sfn_sf, buffer, sizeof(sfn_sf));
if (sfn_sf % 300 == 0) subframe_sf = NFAPI_SFNSF2SF(sfn_sf);
{ frame_sfn = NFAPI_SFNSF2SFN(sfn_sf);
LOG_I(MAC, "Unpacked sfn_sf sf: %u sfn: %u\n", NFAPI_SFNSF2SFN(sfn_sf),
NFAPI_SFNSF2SF(sfn_sf));
}
} }
else else
{ {
......
...@@ -156,4 +156,7 @@ extern queue_t hi_dci0_req_queue; ...@@ -156,4 +156,7 @@ extern queue_t hi_dci0_req_queue;
extern nfapi_ul_config_request_t* ul_config_req; extern nfapi_ul_config_request_t* ul_config_req;
extern nfapi_hi_dci0_request_t* hi_dci0_req; extern nfapi_hi_dci0_request_t* hi_dci0_req;
extern int subframe_sf;
extern int frame_sfn;
#endif /* PHY_STUB_UE_H_ */ #endif /* PHY_STUB_UE_H_ */
...@@ -94,7 +94,6 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind); ...@@ -94,7 +94,6 @@ extern int oai_nfapi_sr_indication(nfapi_sr_indication_t *ind);
extern int oai_nfapi_rx_ind(nfapi_rx_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 multicast_link_write_sock(int groupP, char *dataP, uint32_t sizeP);
extern uint16_t sf_ahead; extern uint16_t sf_ahead;
//extern int tx_req_UE_MAC1(); //extern int tx_req_UE_MAC1();
...@@ -1056,6 +1055,10 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1056,6 +1055,10 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
int num_pairs = 0; int num_pairs = 0;
int num_lone = 0; int num_lone = 0;
int last_sf = 0;
int last_sfn = 0;
bool sfn_sf_changed = false;
while (!oai_exit) { while (!oai_exit) {
if (ue_thread_id == 0) { if (ue_thread_id == 0) {
...@@ -1078,15 +1081,19 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1078,15 +1081,19 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
exit_fun("nothing to add"); exit_fun("nothing to add");
} }
} }
proc->subframe_rx = timer_subframe; // set this to sf from proxy **Get from Queue - Andrew proc->subframe_rx = subframe_sf;
proc->frame_rx = timer_frame; // set this to sfn from proxy **Get from Queue - Andrew proc->frame_rx = frame_sfn;
// variable to say that there has been a change in sf and sfn - Andrew
if (proc->subframe_rx != last_sf && proc->frame_rx != last_sfn) {
last_sf = proc->subframe_rx;
last_sfn = proc->frame_rx;
sfn_sf_changed = true;
}
// FDD and TDD tx timing settings. // FDD and TDD tx timing settings.
// XXX:It is the result of timing adjustment in debug. // XXX:It is the result of timing adjustment in debug.
// It is necessary to investigate why this will work in the future. // It is necessary to investigate why this will work in the future.
proc->subframe_tx = (timer_subframe + sf_ahead) % 10; proc->subframe_tx = (proc->subframe_rx + sf_ahead) % 10;
proc->frame_tx = proc->frame_rx + (proc->subframe_rx > (9 - sf_ahead) ? 1 : 0); proc->frame_tx = proc->frame_rx + (proc->subframe_rx > (9 - sf_ahead) ? 1 : 0);
//oai_subframe_ind(proc->frame_rx, proc->subframe_rx); //oai_subframe_ind(proc->frame_rx, proc->subframe_rx);
if (NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) { if (NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) {
...@@ -1226,103 +1233,106 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg) ...@@ -1226,103 +1233,106 @@ static void *UE_phy_stub_single_thread_rxn_txnp4(void *arg)
} }
//for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) { //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) {
// if sfn_sf change variable is true if (sfn_sf_changed) {
for (ue_index = 0; ue_index < ue_num; ue_index++) { for (ue_index = 0; ue_index < ue_num; ue_index++) {
ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index; ue_Mod_id = ue_thread_id + NB_THREAD_INST * ue_index;
UE = PHY_vars_UE_g[ue_Mod_id][0]; UE = PHY_vars_UE_g[ue_Mod_id][0];
//LOG_D(MAC, "UE_phy_stub_single_thread_rxn_txnp4, NB_UE_INST:%d, Mod_id:%d \n", NB_UE_INST, Mod_id); //LOG_D(MAC, "UE_phy_stub_single_thread_rxn_txnp4, NB_UE_INST:%d, Mod_id:%d \n", NB_UE_INST, Mod_id);
//UE = PHY_vars_UE_g[Mod_id][0]; //UE = PHY_vars_UE_g[Mod_id][0];
lte_subframe_t sf_type = subframe_select(&UE->frame_parms, proc->subframe_rx); lte_subframe_t sf_type = subframe_select(&UE->frame_parms, proc->subframe_rx);
if ((sf_type == SF_DL) || if ((sf_type == SF_DL) ||
(UE->frame_parms.frame_type == FDD) || (UE->frame_parms.frame_type == FDD) ||
(sf_type == SF_S)) { (sf_type == SF_S)) {
if (UE->frame_parms.frame_type == TDD) { if (UE->frame_parms.frame_type == TDD) {
LOG_D(PHY, "TDD%d,%s: calling UE_RX\n", LOG_D(PHY, "TDD%d,%s: calling UE_RX\n",
UE->frame_parms.tdd_config, UE->frame_parms.tdd_config,
(sf_type == SF_DL ? "SF_DL" : (sf_type == SF_UL ? "SF_UL" : (sf_type == SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); (sf_type == SF_DL ? "SF_DL" : (sf_type == SF_UL ? "SF_UL" : (sf_type == SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
} else { } else {
LOG_D(PHY, "%s,%s: calling UE_RX\n", LOG_D(PHY, "%s,%s: calling UE_RX\n",
(UE->frame_parms.frame_type == FDD ? "FDD" : (UE->frame_parms.frame_type == TDD ? "TDD" : "UNKNOWN_DUPLEX_MODE")), (UE->frame_parms.frame_type == FDD ? "FDD" : (UE->frame_parms.frame_type == TDD ? "TDD" : "UNKNOWN_DUPLEX_MODE")),
(sf_type == SF_DL ? "SF_DL" : (sf_type == SF_UL ? "SF_UL" : (sf_type == SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); (sf_type == SF_DL ? "SF_DL" : (sf_type == SF_UL ? "SF_UL" : (sf_type == SF_S ? "SF_S" : "UNKNOWN_SF_TYPE"))));
} }
phy_procedures_UE_SL_RX(UE, proc); phy_procedures_UE_SL_RX(UE, proc);
if (NFAPI_MODE != NFAPI_UE_STUB_PNF && NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF) if (NFAPI_MODE != NFAPI_UE_STUB_PNF && NFAPI_MODE != NFAPI_MODE_STANDALONE_PNF)
phy_procedures_UE_SL_TX(UE, proc); phy_procedures_UE_SL_TX(UE, proc);
} }
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
start_meas(&UE->generic_stat); start_meas(&UE->generic_stat);
#endif #endif
if (UE->mac_enabled == 1) { if (UE->mac_enabled == 1) {
ret = ue_scheduler(ue_Mod_id, ret = ue_scheduler(ue_Mod_id,
proc->frame_rx, proc->frame_rx,
proc->subframe_rx, proc->subframe_rx,
proc->frame_tx, proc->frame_tx,
proc->subframe_tx, proc->subframe_tx,
subframe_select(&UE->frame_parms, proc->subframe_tx), subframe_select(&UE->frame_parms, proc->subframe_tx),
0, 0,
0 /*FIXME CC_id*/); 0 /*FIXME CC_id*/);
if (ret != CONNECTION_OK) { if (ret != CONNECTION_OK) {
LOG_E(PHY, "[UE %" PRIu8 "] Frame %" PRIu32 ", subframe %u %s\n", LOG_E(PHY, "[UE %" PRIu8 "] Frame %" PRIu32 ", subframe %u %s\n",
UE->Mod_id, proc->frame_rx, proc->subframe_tx, get_connectionloss_errstr(ret)); UE->Mod_id, proc->frame_rx, proc->subframe_tx, get_connectionloss_errstr(ret));
}
} }
}
#if UE_TIMING_TRACE #if UE_TIMING_TRACE
stop_meas(&UE->generic_stat); stop_meas(&UE->generic_stat);
#endif #endif
// Prepare the future Tx data // Prepare the future Tx data
if ((subframe_select(&UE->frame_parms, proc->subframe_tx) == SF_UL) || if ((subframe_select(&UE->frame_parms, proc->subframe_tx) == SF_UL) ||
(UE->frame_parms.frame_type == FDD)) (UE->frame_parms.frame_type == FDD))
if (UE->mode != loop_through_memory) { if (UE->mode != loop_through_memory) {
// We make the start of RA between consecutive UEs differ by 20 frames // We make the start of RA between consecutive UEs differ by 20 frames
//if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) { //if ((UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id == 0) || (UE_mac_inst[Mod_id].UE_mode[0] == PRACH && Mod_id>0 && proc->frame_rx >= UE_mac_inst[Mod_id-1].ra_frame + 20) ) {
if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) { if (UE_mac_inst[ue_Mod_id].UE_mode[0] == PRACH && ue_Mod_id == next_Mod_id) {
next_ra_frame++; next_ra_frame++;
if (next_ra_frame > 500) { if (next_ra_frame > 500) {
// check if we have PRACH opportunity // check if we have PRACH opportunity
// LOG_I(MAC, "is_prach_subframe: %d UE_mac_inst[ue_MOD_id].SI_Decoded: %u\n", // LOG_I(MAC, "is_prach_subframe: %d UE_mac_inst[ue_MOD_id].SI_Decoded: %u\n",
// is_prach_subframe(&UE->frame_parms, proc->frame_tx, proc->subframe_tx), // is_prach_subframe(&UE->frame_parms, proc->frame_tx, proc->subframe_tx),
// UE_mac_inst[ue_Mod_id].SI_Decoded); // UE_mac_inst[ue_Mod_id].SI_Decoded);
if (is_prach_subframe(&UE->frame_parms, proc->frame_tx, proc->subframe_tx) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) { LOG_I(MAC, "is_prach_subframe: %d UE_mac_inst %d\n",
// The one working strangely... is_prach_subframe(&UE->frame_parms, proc->frame_tx, proc->subframe_tx),
//if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) { UE_mac_inst[ue_Mod_id].SI_Decoded);
PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx); if (is_prach_subframe(&UE->frame_parms, proc->frame_tx, proc->subframe_tx) && UE_mac_inst[ue_Mod_id].SI_Decoded == 1) {
LOG_I(MAC, "Celtics prach_resources %p\n", prach_resources); // The one working strangely...
if (prach_resources != NULL) { //if (is_prach_subframe(&UE->frame_parms,proc->frame_tx, proc->subframe_tx && Mod_id == (module_id_t) init_ra_UE) ) {
UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx; PRACH_RESOURCES_t *prach_resources = ue_get_rach(ue_Mod_id, 0, proc->frame_tx, 0, proc->subframe_tx);
LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, proc->frame_tx, proc->subframe_tx); LOG_I(MAC, "Celtics prach_resources %p\n", prach_resources);
fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx, proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI); if (prach_resources != NULL) {
Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0); UE_mac_inst[ue_Mod_id].ra_frame = proc->frame_rx;
UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE; LOG_I(MAC, "UE_phy_stub_thread_rxn_txnp4 before RACH, Mod_id: %d frame %d subframe %d\n", ue_Mod_id, proc->frame_tx, proc->subframe_tx);
next_Mod_id = ue_Mod_id + 1; fill_rach_indication_UE_MAC(ue_Mod_id, proc->frame_tx, proc->subframe_tx, UL_INFO, prach_resources->ra_PreambleIndex, prach_resources->ra_RNTI);
//next_ra_frame = (proc->frame_rx + 20)%1000; Msg1_transmitted(ue_Mod_id, 0, proc->frame_tx, 0);
next_ra_frame = 0; UE_mac_inst[ue_Mod_id].UE_mode[0] = RA_RESPONSE;
next_Mod_id = ue_Mod_id + 1;
//next_ra_frame = (proc->frame_rx + 20)%1000;
next_ra_frame = 0;
}
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
//ue_prach_procedures(ue,proc,eNB_id,abstraction_flag,mode);
} }
} } // mode is PRACH
} // mode is PRACH
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger
// Substitute call to phy_procedures Tx with call to phy_stub functions in order to trigger // UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB).
// UE Tx procedures directly at the MAC layer, based on the received ul_config requests from the vnf (eNB). // Generate UL_indications which correspond to UL traffic.
// Generate UL_indications which correspond to UL traffic. if (ul_config_req != NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){
if (ul_config_req != NULL) { //&& UE_mac_inst[Mod_id].ul_config_req->ul_config_request_body.ul_config_pdu_list != NULL){ ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id); // Andrew - send over socket to proxy here
ul_config_req_UE_MAC(ul_config_req, timer_frame, timer_subframe, ue_Mod_id); // Andrew - send over socket to proxy here } // Andrew - else send a dummy over the socket
} // Andrew - else send a dummy over the socket }
}
phy_procedures_UE_SL_RX(UE, proc); phy_procedures_UE_SL_RX(UE, proc);
} //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++) } //for (Mod_id=0; Mod_id<NB_UE_INST; Mod_id++)
// end of if - Andrew Burger }
if (phy_stub_ticking != NULL) { if (phy_stub_ticking != NULL) {
phy_stub_ticking->num_single_thread[ue_thread_id] = -1; phy_stub_ticking->num_single_thread[ue_thread_id] = -1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment