diff --git a/executables/nr-ue.c b/executables/nr-ue.c index ee2a3c59a0..ef45cd3cb7 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -290,8 +290,9 @@ static void *NRUE_phy_stub_standalone_pnf_task(void *arg) free_and_zero(ch_info); } - frame_t frame = NFAPI_SFNSLOT2SFN(sfn_slot); - int slot = NFAPI_SFNSLOT2SLOT(sfn_slot); + int mu = 1; // NR-UE emul-L1 is hardcoded to 30kHZ, see check_and_process_dci() + frame_t frame = NFAPI_SFNSLOTDEC2SFN(mu, sfn_slot); + int slot = NFAPI_SFNSLOTDEC2SLOT(mu, sfn_slot); if (sfn_slot == last_sfn_slot) { LOG_D(NR_MAC, "repeated sfn_sf = %d.%d\n", frame, slot); diff --git a/nfapi/oai_integration/nfapi_pnf.c b/nfapi/oai_integration/nfapi_pnf.c index 51e371a4cd..585c1a8585 100644 --- a/nfapi/oai_integration/nfapi_pnf.c +++ b/nfapi/oai_integration/nfapi_pnf.c @@ -1702,6 +1702,9 @@ int nr_start_request(nfapi_pnf_config_t *config, nfapi_pnf_phy_config_t *phy, nf p7_config->timing_info_mode_aperiodic = 1; } + pnf_p7_t* pnf_p7 = (pnf_p7_t*)(p7_config); + pnf_p7->mu = 1; /* TODO */ + // NR p7_config->dl_tti_req_fn = &pnf_phy_dl_tti_req; p7_config->ul_tti_req_fn = &pnf_phy_ul_tti_req; @@ -2281,20 +2284,23 @@ void handle_nr_slot_ind(uint16_t sfn, uint16_t slot) maybe_slow_down_pnf(); } + nfapi_pnf_p7_config_t* config = p7_config_g; + pnf_p7_t* _this = (pnf_p7_t*)(config); //send VNF slot indication, which is aligned with TX thread, so that it can call the scheduler //we give four additional slots (2ms) which should be enough time for the VNF to //answer int slot_ahead = 4; - uint32_t sfn_slot_tx = sfnslot_add_slot(sfn, slot, slot_ahead); - uint16_t sfn_tx = NFAPI_SFNSLOT2SFN(sfn_slot_tx); - uint8_t slot_tx = NFAPI_SFNSLOT2SLOT(sfn_slot_tx); + int mu = _this->mu; + uint16_t sfn_tx = sfn; + uint16_t slot_tx = slot; + sfnslot_add_slot(mu, &sfn_tx, &slot_tx, slot_ahead); // modify: do in place - NFAPI_TRACE(NFAPI_TRACE_DEBUG, "send slot indication for sfn/slot:%4d.%2d current:%4d.%2d\n", sfn_tx, slot_tx, sfn, slot); + //printf("send slot indication for sfn/slot:%4d.%2d current:%4d.%2d\n", sfn_tx, slot_tx, sfn, slot); nfapi_nr_slot_indication_scf_t ind = { .sfn = sfn_tx, .slot = slot_tx }; oai_nfapi_nr_slot_indication(&ind); //copy data from appropriate p7 slot buffers into channel structures for PHY processing - nfapi_pnf_p7_slot_ind(p7_config_g, p7_config_g->phy_id, sfn, slot); + nfapi_pnf_p7_slot_ind(config, config->phy_id, sfn, slot); return; } diff --git a/nfapi/oai_integration/nfapi_pnf.h b/nfapi/oai_integration/nfapi_pnf.h index 0d27a486da..0ba0676f10 100644 --- a/nfapi/oai_integration/nfapi_pnf.h +++ b/nfapi/oai_integration/nfapi_pnf.h @@ -29,7 +29,7 @@ void configure_nr_nfapi_pnf(char *vnf_ip_addr, int vnf_p5_port, char *pnf_ip_add void oai_subframe_ind(uint16_t sfn, uint16_t sf); void handle_nr_slot_ind(uint16_t sfn, uint16_t slot); -uint32_t sfnslot_add_slot(uint16_t sfn, uint16_t slot, int offset); +void sfnslot_add_slot(int mu, uint16_t *sfn, uint16_t *slot, int offset); int oai_nfapi_nr_slot_indication(nfapi_nr_slot_indication_scf_t *ind); int oai_nfapi_nr_rx_data_indication(nfapi_nr_rx_data_indication_t *ind); diff --git a/nfapi/oai_integration/nfapi_vnf.h b/nfapi/oai_integration/nfapi_vnf.h index 1dbb319d83..71cc50c2f7 100644 --- a/nfapi/oai_integration/nfapi_vnf.h +++ b/nfapi/oai_integration/nfapi_vnf.h @@ -25,6 +25,4 @@ void configure_nfapi_vnf(char *vnf_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); void configure_nr_nfapi_vnf(char *vnf_addr, int vnf_p5_port, char *pnf_ip_addr, int pnf_p7_port, int vnf_p7_port); -uint32_t sfnslot_add_slot(uint16_t sfn, uint16_t slot, int offset); - #endif /* NFAPI_VNF_H_ */ diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h index 2d761bab88..f830e904e2 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h @@ -120,16 +120,14 @@ typedef struct { #define NFAPI_TAG_LENGTH_PACKED_LEN 4 // Convenience methods to convert between SFN/SLOT formats -#define NFAPI_SFNSLOT2DEC(_sfn,_slot) ( _sfn*20 + _slot ) // total count of slots -#define NFAPI_SFNSLOTDEC2SFNSLOT(_sfnslot_dec) ((((_sfnslot_dec) / 20) << 6) | (((_sfnslot_dec) - (((_sfnslot_dec) / 20) * 20)) & 0x3F)) +#define NFAPI_SLOTNUM(_mu) (10 << (_mu)) +#define NFAPI_SLOTLEN(_mu) (1000.f / (1 << _mu)) -#define NFAPI_SFNSLOT2SFN(_sfnslot) ((_sfnslot) >> 6) -#define NFAPI_SFNSLOT2SLOT(_sfnslot) ((_sfnslot) & 0x3F) -#define NFAPI_SFNSLOTDEC2SFN(_sfnslot_dec) ((_sfnslot_dec) / 20) -#define NFAPI_SFNSLOTDEC2SLOT(_sfnslot_dec) ((_sfnslot_dec) % 20) -#define NFAPI_SFNSLOT2HEX(_sfn,_slot) ((_sfn << 6) | (_slot & 0x3F)) +#define NFAPI_SFNSLOT2DEC(_mu, _sfn, _slot) ((_sfn) * NFAPI_SLOTNUM(_mu) + (_slot)) +#define NFAPI_SFNSLOTDEC2SFN(_mu, _sfnslot_dec) ((_sfnslot_dec) / NFAPI_SLOTNUM(_mu)) +#define NFAPI_SFNSLOTDEC2SLOT(_mu, _sfnslot_dec) ((_sfnslot_dec) % NFAPI_SLOTNUM(_mu)) -#define NFAPI_MAX_SFNSLOTDEC 1024*20 // 20 is for numerology 1 +#define NFAPI_MAX_SFNSLOTDEC(_mu) (1024 * NFAPI_SLOTNUM(_mu)) // Convenience methods to convert between SFN/SFN formats #define NFAPI_SFNSF2DEC(_sfnsf) ((((_sfnsf) >> 4) * 10) + ((_sfnsf) & 0xF)) diff --git a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h index 7e936c84bf..0c14fcebef 100644 --- a/nfapi/open-nFAPI/pnf/inc/pnf_p7.h +++ b/nfapi/open-nFAPI/pnf/inc/pnf_p7.h @@ -114,6 +114,7 @@ typedef struct { uint16_t sfn; uint16_t slot; + int mu; uint16_t sfn_slot; uint32_t slot_start_time_hr; int32_t slot_shift; diff --git a/nfapi/open-nFAPI/pnf/src/pnf_p7.c b/nfapi/open-nFAPI/pnf/src/pnf_p7.c index 23862be2e1..9bb348e265 100644 --- a/nfapi/open-nFAPI/pnf/src/pnf_p7.c +++ b/nfapi/open-nFAPI/pnf/src/pnf_p7.c @@ -36,9 +36,9 @@ extern int sf_ahead; -void add_slot(uint16_t *frameP, uint16_t *slotP, int offset) +static void add_slot(int mu, uint16_t *frameP, uint16_t *slotP, int offset) { - uint16_t num_slots = 20; // set based on numerlogy (fixing for 1) + uint16_t num_slots = NFAPI_SLOTNUM(mu); *frameP = (*frameP + ((*slotP + offset) / num_slots))%1024; @@ -61,18 +61,12 @@ void subtract_sf(uint16_t *frameP, uint16_t *subframeP, int offset) *subframeP = (*subframeP+10-offset)%10; } -uint32_t sfnslot_add_slot(uint16_t sfn, uint16_t slot, int offset) +void sfnslot_add_slot(int mu, uint16_t *sfn, uint16_t *slot, int offset) { - uint32_t new_sfnslot; - //printf("%s() sfn:%u sf:%u\n", __FUNCTION__, sfn, sf); - add_slot(&sfn, &slot, offset); - - new_sfnslot = sfn<<6|slot; + add_slot(mu, sfn, slot, offset); //printf("%s() sfn:%u sf:%u offset:%d sfnsf:%d(DEC:%d) new:%d(DEC:%d)\n", __FUNCTION__, sfn, sf, offset, sfnsf, NFAPI_SFNSF2DEC(sfnsf), new_sfnsf, NFAPI_SFNSF2DEC(new_sfnsf)); - - return new_sfnslot; } uint16_t sfnsf_add_sf(uint16_t sfnsf, int offset) @@ -786,8 +780,8 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl pnf_p7->sfn = sfn; pnf_p7->slot = slot; - uint32_t tx_slot_dec = NFAPI_SFNSLOT2DEC(sfn,slot); - uint8_t buffer_index_tx = tx_slot_dec % 20; + uint32_t tx_slot_dec = NFAPI_SFNSLOT2DEC(pnf_p7->mu, sfn,slot); + uint8_t buffer_index_tx = tx_slot_dec % NFAPI_SLOTNUM(pnf_p7->mu); // If the subframe_buffer has been configured if(pnf_p7->_public.slot_buffer_size!= 0) // for now value is same as sf_buffer_size @@ -800,9 +794,9 @@ int pnf_p7_slot_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn, uint16_t sl // adjust for wrap-around if(shifted_slot < 0) - shifted_slot += NFAPI_MAX_SFNSLOTDEC; - else if(shifted_slot > NFAPI_MAX_SFNSLOTDEC) - shifted_slot -= NFAPI_MAX_SFNSLOTDEC; + shifted_slot += NFAPI_MAX_SFNSLOTDEC(pnf_p7->mu); + else if(shifted_slot > NFAPI_MAX_SFNSLOTDEC(pnf_p7->mu)) + shifted_slot -= NFAPI_MAX_SFNSLOTDEC(pnf_p7->mu); // NFAPI_TRACE(NFAPI_TRACE_INFO, "Applying shift %d to sfn/slot (%d -> %d)\n", pnf_p7->sfn_slot_shift, NFAPI_SFNSF2DEC(sfn_slot), shifted_sfn_slot); slot = shifted_slot; @@ -1187,12 +1181,12 @@ int pnf_p7_subframe_ind(pnf_p7_t* pnf_p7, uint16_t phy_id, uint16_t sfn_sf) bool is_nr_p7_request_in_window(const uint16_t sfn, const uint16_t slot, const char* name, const pnf_p7_t* phy) { - const uint32_t recv = NFAPI_SFNSLOT2DEC(sfn, slot); // unpack sfn/slot - const uint32_t curr = NFAPI_SFNSLOT2DEC(phy->sfn, phy->slot); - const uint8_t timing_window = phy->_public.slot_buffer_size; + const uint32_t recv = NFAPI_SFNSLOT2DEC(phy->mu, sfn, slot); // unpack sfn/slot + const uint32_t curr = NFAPI_SFNSLOT2DEC(phy->mu, phy->sfn, phy->slot); + const uint8_t timing_window = phy->_public.slot_buffer_size; // TODO check uint32_t diff = curr < recv ? recv - curr : curr - recv; - if (diff > NFAPI_MAX_SFNSLOTDEC / 2) - diff = NFAPI_MAX_SFNSLOTDEC - diff; + if (diff > NFAPI_MAX_SFNSLOTDEC(phy->mu) / 2) + diff = NFAPI_MAX_SFNSLOTDEC(phy->mu) - diff; if (diff > timing_window) { NFAPI_TRACE(NFAPI_TRACE_WARN, "[%d] %s is out of window %d (delta:%d) [max:%d]\n", curr, name, recv, diff, timing_window); return false; @@ -1289,8 +1283,8 @@ void pnf_handle_dl_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) } if (check_nr_nfapi_p7_slot_type(frame, slot, "DL_TTI.request", NR_DOWNLINK_SLOT) && is_nr_p7_request_in_window(frame, slot, "dl_tti_request", pnf_p7)) { - uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(frame, slot); - uint8_t buffer_index = sfn_slot_dec % 20; + uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(pnf_p7->mu, frame, slot); + uint8_t buffer_index = sfn_slot_dec % NFAPI_SLOTNUM(pnf_p7->mu); pnf_p7->slot_buffer[buffer_index].sfn = frame; pnf_p7->slot_buffer[buffer_index].slot = slot; nfapi_nr_dl_tti_request_t *req = &pnf_p7->slot_buffer[buffer_index].dl_tti_req; @@ -1422,8 +1416,8 @@ void pnf_handle_ul_tti_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) if (check_nr_nfapi_p7_slot_type(frame, slot, "UL_TTI.request", NR_UPLINK_SLOT) && is_nr_p7_request_in_window(frame, slot, "ul_tti_request", pnf_p7)) { - uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(frame, slot); - uint8_t buffer_index = (sfn_slot_dec % 20); + uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(pnf_p7->mu, frame, slot); + uint8_t buffer_index = sfn_slot_dec % NFAPI_SLOTNUM(pnf_p7->mu); pnf_p7->slot_buffer[buffer_index].sfn = frame; pnf_p7->slot_buffer[buffer_index].slot = slot; nfapi_nr_ul_tti_request_t* req = &pnf_p7->slot_buffer[buffer_index].ul_tti_req; @@ -1541,8 +1535,8 @@ void pnf_handle_ul_dci_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7) } if (check_nr_nfapi_p7_slot_type(frame, slot, "UL_DCI.request", NR_DOWNLINK_SLOT) && is_nr_p7_request_in_window(frame, slot, "ul_dci_request", pnf_p7)) { - uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(frame, slot); - uint8_t buffer_index = sfn_slot_dec % 20; + uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(pnf_p7->mu, frame, slot); + uint8_t buffer_index = sfn_slot_dec % NFAPI_SLOTNUM(pnf_p7->mu); pnf_p7->slot_buffer[buffer_index].sfn = frame; pnf_p7->slot_buffer[buffer_index].slot = slot; nfapi_nr_ul_dci_request_t *req = &pnf_p7->slot_buffer[buffer_index].ul_dci_req; @@ -1654,8 +1648,8 @@ void pnf_handle_tx_data_request(void* pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7 } if (check_nr_nfapi_p7_slot_type(frame, slot, "TX_DATA.REQUEST", NR_DOWNLINK_SLOT) && is_nr_p7_request_in_window(frame, slot, "tx_request", pnf_p7)) { - uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(frame, slot); - uint8_t buffer_index = sfn_slot_dec % 20; + uint32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(pnf_p7->mu, frame, slot); + uint8_t buffer_index = sfn_slot_dec % NFAPI_SLOTNUM(pnf_p7->mu); // TODO where is buffer length? pnf_p7->slot_buffer[buffer_index].sfn = frame; pnf_p7->slot_buffer[buffer_index].slot = slot; nfapi_nr_tx_data_request_t *req = &pnf_p7->slot_buffer[buffer_index].tx_data_req; @@ -1957,10 +1951,10 @@ uint32_t calculate_t2(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_t return t2; } -uint32_t calculate_nr_t2(uint32_t now_time_hr, uint16_t sfn,uint16_t slot, uint32_t slot_start_time_hr) +static uint32_t calculate_nr_t2(uint32_t now_time_hr, int mu, uint16_t sfn,uint16_t slot, uint32_t slot_start_time_hr) { uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t t2 = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us; + uint32_t t2 = NFAPI_SFNSLOT2DEC(mu, sfn, slot) * NFAPI_SLOTLEN(mu) + slot_time_us; if (0) { @@ -1990,13 +1984,13 @@ uint32_t calculate_t3(uint16_t sfn_sf, uint32_t sf_start_time_hr) return t3; } -uint32_t calculate_nr_t3(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) +static uint32_t calculate_nr_t3(int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) { uint32_t now_time_hr = pnf_get_current_time_hr(); uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t t3 = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us; + uint32_t t3 = NFAPI_SFNSLOT2DEC(mu, sfn, slot) * NFAPI_SLOTLEN(mu) + slot_time_us; return t3; } @@ -2092,8 +2086,8 @@ void pnf_nr_handle_dl_node_sync(void *pRecvMsg, int recvMsgLen, pnf_p7_t* pnf_p7 ul_node_sync.header.message_id = NFAPI_NR_PHY_MSG_TYPE_UL_NODE_SYNC; ul_node_sync.header.phy_id = dl_node_sync.header.phy_id; ul_node_sync.t1 = dl_node_sync.t1; - ul_node_sync.t2 = calculate_nr_t2(rx_hr_time, pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr); - ul_node_sync.t3 = calculate_nr_t3(pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr); + ul_node_sync.t2 = calculate_nr_t2(rx_hr_time, pnf_p7->mu, pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr); + ul_node_sync.t3 = calculate_nr_t3(pnf_p7->mu, pnf_p7->sfn,pnf_p7->slot, pnf_p7->slot_start_time_hr); if(pthread_mutex_unlock(&(pnf_p7->mutex)) != 0) { diff --git a/nfapi/open-nFAPI/vnf/inc/vnf_p7.h b/nfapi/open-nFAPI/vnf/inc/vnf_p7.h index 31512124ac..3684997c22 100644 --- a/nfapi/open-nFAPI/vnf/inc/vnf_p7.h +++ b/nfapi/open-nFAPI/vnf/inc/vnf_p7.h @@ -91,6 +91,8 @@ typedef struct nfapi_vnf_p7_connection_info { int sfn_sf; int sfn; int slot; + int mu; // some 5G slot calculations need the numerology to know the number + // of slots int socket; struct sockaddr_in local_addr; diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7.c b/nfapi/open-nFAPI/vnf/src/vnf_p7.c index a73ec28998..0caebd2130 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7.c @@ -362,13 +362,13 @@ uint32_t calculate_t1(uint16_t sfn_sf, uint32_t sf_start_time_hr) return t1; } -uint32_t calculate_nr_t1(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) +uint32_t calculate_nr_t1(int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) { uint32_t now_time_hr = vnf_get_current_time_hr(); uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t t1 = (NFAPI_SFNSLOT2DEC(sfn,slot) * 500) + slot_time_us; + uint32_t t1 = NFAPI_SFNSLOT2DEC(mu, sfn,slot) * NFAPI_SLOTLEN(mu) + slot_time_us; return t1; } @@ -384,24 +384,24 @@ uint32_t calculate_t4(uint32_t now_time_hr, uint16_t sfn_sf, uint32_t sf_start_t } -uint32_t calculate_nr_t4(uint32_t now_time_hr, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) +uint32_t calculate_nr_t4(uint32_t now_time_hr, int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) { uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t t4 = (NFAPI_SFNSLOT2DEC(sfn,slot) * 500) + slot_time_us; + uint32_t t4 = NFAPI_SFNSLOT2DEC(mu, sfn,slot) * NFAPI_SLOTLEN(mu) + slot_time_us; return t4; } -uint32_t calculate_transmit_timestamp(uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) +uint32_t calculate_transmit_timestamp(int mu, uint16_t sfn, uint16_t slot, uint32_t slot_start_time_hr) { uint32_t now_time_hr = vnf_get_current_time_hr(); uint32_t slot_time_us = get_slot_time(now_time_hr, slot_start_time_hr); - uint32_t tt = (NFAPI_SFNSLOT2DEC(sfn, slot) * 500) + slot_time_us; + uint32_t tt = NFAPI_SFNSLOT2DEC(mu, sfn, slot) * NFAPI_SLOTLEN(mu) + slot_time_us; return tt; } @@ -538,7 +538,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_ nfapi_nr_p7_update_checksum(tx_buffer, segment_size); } - nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); + nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size); @@ -551,7 +551,7 @@ int vnf_nr_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_nr_p7_message_header_ nfapi_nr_p7_update_checksum(buffer, len); } - nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); + nfapi_nr_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); // simple case that the message fits in a single segement send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len); @@ -632,7 +632,7 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea nfapi_p7_update_checksum(tx_buffer, segment_size); } - nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); + nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &tx_buffer[0], segment_size); } @@ -644,7 +644,7 @@ int vnf_p7_pack_and_send_p7_msg(vnf_p7_t* vnf_p7, nfapi_p7_message_header_t* hea nfapi_p7_update_checksum(buffer, len); } - nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); + nfapi_p7_update_transmit_timestamp(buffer, calculate_transmit_timestamp(p7_connection->mu, p7_connection->sfn, p7_connection->slot, vnf_p7->slot_start_time_hr)); // simple case that the message fits in a single segement send_result = vnf_send_p7_msg(vnf_p7, p7_connection, &buffer[0], len); @@ -681,7 +681,7 @@ int vnf_nr_build_send_dl_node_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_inf dl_node_sync.header.phy_id = p7_info->phy_id; dl_node_sync.header.message_id = NFAPI_NR_PHY_MSG_TYPE_DL_NODE_SYNC; //dl_node_sync.t1 = calculate_t1(p7_info->sfn_sf, vnf_p7->sf_start_time_hr); - dl_node_sync.t1 = calculate_nr_t1(p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr); + dl_node_sync.t1 = calculate_nr_t1(p7_info->mu, p7_info->sfn,p7_info->slot, vnf_p7->slot_start_time_hr); dl_node_sync.delta_sfn_slot = 0; return vnf_nr_p7_pack_and_send_p7_msg(vnf_p7, &dl_node_sync.header); @@ -693,11 +693,9 @@ int vnf_nr_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) if(p7_info->in_sync == 1) { uint16_t dl_sync_period_mask = p7_info->dl_in_sync_period-1; - // uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); - uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->sfn,p7_info->slot); + uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->mu, p7_info->sfn,p7_info->slot); - //if ((((sfn_sf_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) - if ((((sfn_slot_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0) + if ((((sfn_slot_dec + p7_info->dl_in_sync_offset) % NFAPI_MAX_SFNSLOTDEC(p7_info->mu)) & dl_sync_period_mask) == 0) { vnf_nr_build_send_dl_node_sync(vnf_p7, p7_info); } @@ -706,10 +704,9 @@ int vnf_nr_sync(vnf_p7_t* vnf_p7, nfapi_vnf_p7_connection_info_t* p7_info) { uint16_t dl_sync_period_mask = p7_info->dl_out_sync_period-1; //uint16_t sfn_sf_dec = NFAPI_SFNSF2DEC(p7_info->sfn_sf); - uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->sfn, p7_info->slot); + uint16_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(p7_info->mu, p7_info->sfn, p7_info->slot); - //if ((((sfn_sf_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSFDEC) & dl_sync_period_mask) == 0) - if ((((sfn_slot_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSLOTDEC) & dl_sync_period_mask) == 0) + if ((((sfn_slot_dec + p7_info->dl_out_sync_offset) % NFAPI_MAX_SFNSLOTDEC(p7_info->mu)) & dl_sync_period_mask) == 0) { vnf_nr_build_send_dl_node_sync(vnf_p7, p7_info); } @@ -1671,9 +1668,9 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 //NFAPI_TRACE(NFAPI_TRACE_INFO, "Received UL_NODE_SYNC phy_id:%d t1:%d t2:%d t3:%d\n", ind.header.phy_id, ind.t1, ind.t2, ind.t3); nfapi_vnf_p7_connection_info_t* phy = vnf_p7_connection_info_list_find(vnf_p7, ind.header.phy_id); - uint32_t t4 = calculate_nr_t4(now_time_hr, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr); + uint32_t t4 = calculate_nr_t4(now_time_hr, phy->mu, phy->sfn, phy->slot, vnf_p7->slot_start_time_hr); - uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSLOTDEC - ind.t1 ; //time taken to receive ul node sync - time taken to send dl node sync + uint32_t tx_2_rx = t4>ind.t1 ? t4 - ind.t1 : t4 + NFAPI_MAX_SFNSLOTDEC(phy->mu) - ind.t1 ; //time taken to receive ul node sync - time taken to send dl node sync uint32_t pnf_proc_time = ind.t3 - ind.t2; // divide by 2 using shift operator @@ -1698,12 +1695,12 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 if (ind.t2 < phy->previous_t2 && ind.t1 > phy->previous_t1) { // Only t2 wrap has occurred!!! - phy->slot_offset = (NFAPI_MAX_SFNSLOTDEC + ind.t2) - ind.t1 - latency; + phy->slot_offset = (NFAPI_MAX_SFNSLOTDEC(phy->mu) + ind.t2) - ind.t1 - latency; } else if (ind.t2 > phy->previous_t2 && ind.t1 < phy->previous_t1) { // Only t1 wrap has occurred - phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC) - latency; + phy->slot_offset = ind.t2 - ( ind.t1 + NFAPI_MAX_SFNSLOTDEC(phy->mu)) - latency; } else { @@ -1755,7 +1752,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 { uint32_t curr_sfn = phy->sfn; uint32_t curr_slot = phy->slot; - int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->sfn,phy->slot); + int32_t sfn_slot_dec = NFAPI_SFNSLOT2DEC(phy->mu, phy->sfn,phy->slot); if(!phy->filtered_adjust) { @@ -1772,7 +1769,7 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 sfn_slot_dec += (phy->slot_offset / 500); - NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec) ); + NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF slot offset:%d sfn :%d slot:%d \n",phy->slot_offset,NFAPI_SFNSLOTDEC2SFN(phy->mu, sfn_slot_dec),NFAPI_SFNSLOTDEC2SLOT(phy->mu, sfn_slot_dec) ); } @@ -1784,19 +1781,19 @@ void vnf_nr_handle_ul_node_sync(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7 if(sfn_slot_dec < 0) { - sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC; + sfn_slot_dec += NFAPI_MAX_SFNSLOTDEC(phy->mu); } - else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC) + else if( sfn_slot_dec >= NFAPI_MAX_SFNSLOTDEC(phy->mu)) { - sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC; + sfn_slot_dec -= NFAPI_MAX_SFNSLOTDEC(phy->mu); } - uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(sfn_slot_dec); - uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(sfn_slot_dec); + uint16_t new_sfn = NFAPI_SFNSLOTDEC2SFN(phy->mu, sfn_slot_dec); + uint16_t new_slot = NFAPI_SFNSLOTDEC2SLOT(phy->mu, sfn_slot_dec); { - phy->adjustment = NFAPI_SFNSLOT2DEC(new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(curr_sfn, curr_slot); + phy->adjustment = NFAPI_SFNSLOT2DEC(phy->mu, new_sfn, new_slot) - NFAPI_SFNSLOT2DEC(phy->mu, curr_sfn, curr_slot); //NFAPI_TRACE(NFAPI_TRACE_NOTE, "PNF to VNF phy_id:%d adjustment%d phy->previous_slot_offset_filtered:%d phy->previous_slot_offset_filtered:%d phy->slot_offset_trend:%d\n", ind.header.phy_id, phy->adjustment, phy->previous_slot_offset_filtered, phy->previous_slot_offset_filtered, phy->slot_offset_trend); @@ -2106,7 +2103,8 @@ void vnf_nr_handle_timing_info(void *pRecvMsg, int recvMsgLen, vnf_p7_t* vnf_p7) if (vnf_p7 && vnf_p7->p7_connections) { //int16_t vnf_pnf_sfnsf_delta = NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf) - NFAPI_SFNSF2DEC(ind.last_sfn_sf); - vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(vnf_p7->p7_connections[0].sfn,vnf_p7->p7_connections[0].slot) - NFAPI_SFNSLOT2DEC(ind.last_sfn,ind.last_slot); + nfapi_vnf_p7_connection_info_t *p7_con = &vnf_p7->p7_connections[0]; + vnf_pnf_sfnslot_delta = NFAPI_SFNSLOT2DEC(p7_con->mu, p7_con->sfn,p7_con->slot) - NFAPI_SFNSLOT2DEC(p7_con->mu, ind.last_sfn,ind.last_slot); //NFAPI_TRACE(NFAPI_TRACE_INFO, "%s() PNF:SFN/SF:%d VNF:SFN/SF:%d deltaSFNSF:%d\n", __FUNCTION__, NFAPI_SFNSF2DEC(ind.last_sfn_sf), NFAPI_SFNSF2DEC(vnf_p7->p7_connections[0].sfn_sf), vnf_pnf_sfnsf_delta); // Panos: Careful here!!! Modification of the original nfapi-code diff --git a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c index 18fa798e9e..2289a51120 100644 --- a/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c +++ b/nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c @@ -558,6 +558,7 @@ int nfapi_vnf_p7_add_pnf(nfapi_vnf_p7_config_t* config, const char* pnf_p7_addr, node->sfn = 0; node->slot = 0; node->min_sync_cycle_count = 8; + node->mu = 1; /* TODO */ // save the remote endpoint information node->remote_addr.sin_family = AF_INET; diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 3007890844..aa00daf9c9 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -2523,7 +2523,9 @@ void nr_ue_pucch_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, int slotP) LOG_E(NR_MAC, "Error in pucch allocation\n"); return; } - mac->nr_ue_emul_l1.active_uci_sfn_slot = NFAPI_SFNSLOT2HEX(frameP, slotP); + DevAssert(mac->current_DL_BWP != NULL); + int mu = mac->current_DL_BWP->scs; + mac->nr_ue_emul_l1.active_uci_sfn_slot = NFAPI_SFNSLOT2DEC(mu, frameP, slotP); int ret = nr_ue_configure_pucch(mac, slotP, frameP, diff --git a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c index 0c2b1dcd2d..a8c06604d7 100644 --- a/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_UE_PHY_INTERFACE/NR_IF_Module.c @@ -1043,11 +1043,13 @@ void *nrue_standalone_pnf_task(void *context) // TODO: Update sinr field of slot_rnti_mcs to be array. for (int i = 0; i < ch_info->nb_of_csi; ++i) { - slot_rnti_mcs[NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)].sinr = ch_info->csi[i].sinr; - slot_rnti_mcs[NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)].area_code = ch_info->csi[i].area_code; + int mu = 1; // NR-UE emul-L1 is hardcoded to 30kHZ, see check_and_process_dci() + int frame = NFAPI_SFNSLOTDEC2SFN(mu, ch_info->sfn_slot); + int slot = NFAPI_SFNSLOTDEC2SLOT(mu, ch_info->sfn_slot); + slot_rnti_mcs[slot].sinr = ch_info->csi[i].sinr; + slot_rnti_mcs[slot].area_code = ch_info->csi[i].area_code; - LOG_D(NR_PHY, "Received_SINR[%d] = %f, sfn:slot %d:%d\n", - i, ch_info->csi[i].sinr, NFAPI_SFNSLOT2SFN(ch_info->sfn_slot), NFAPI_SFNSLOT2SLOT(ch_info->sfn_slot)); + LOG_D(NR_PHY, "Received_SINR[%d] = %f, sfn:slot %d:%d\n", i, ch_info->csi[i].sinr, frame, slot); } if (!put_queue(&nr_chan_param_queue, ch_info))