Adjust slot length based on numerology for proper timing
This commit is contained in:
@@ -2258,8 +2258,8 @@ void oai_subframe_ind(uint16_t sfn, uint16_t sf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SLOT_DURATION 300 // in microseconds
|
#define SLOT_DURATION 800 // in microseconds
|
||||||
static void maybe_slow_down_pnf(void)
|
static void maybe_slow_down_pnf(int mu)
|
||||||
{
|
{
|
||||||
/* uses a usleep to wait for approximately the same time period (300 us) */
|
/* uses a usleep to wait for approximately the same time period (300 us) */
|
||||||
static struct timespec last_execution = {0};
|
static struct timespec last_execution = {0};
|
||||||
@@ -2268,29 +2268,31 @@ static void maybe_slow_down_pnf(void)
|
|||||||
// Calculate elapsed time since last execution
|
// Calculate elapsed time since last execution
|
||||||
long elapsed_time = (current_execution.tv_sec - last_execution.tv_sec) * 1000000; // Convert seconds to microseconds
|
long elapsed_time = (current_execution.tv_sec - last_execution.tv_sec) * 1000000; // Convert seconds to microseconds
|
||||||
elapsed_time += (current_execution.tv_nsec - last_execution.tv_nsec) / 1000; // Convert nanoseconds to microseconds
|
elapsed_time += (current_execution.tv_nsec - last_execution.tv_nsec) / 1000; // Convert nanoseconds to microseconds
|
||||||
if (elapsed_time < SLOT_DURATION)
|
int duration = SLOT_DURATION >> mu;
|
||||||
usleep(SLOT_DURATION - elapsed_time);
|
if (elapsed_time < duration)
|
||||||
|
usleep(duration - elapsed_time);
|
||||||
// Update last_execution time
|
// Update last_execution time
|
||||||
last_execution = current_execution;
|
last_execution = current_execution;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_nr_slot_ind(uint16_t sfn, uint16_t slot)
|
void handle_nr_slot_ind(uint16_t sfn, uint16_t slot)
|
||||||
{
|
{
|
||||||
|
nfapi_pnf_p7_config_t *config = p7_config_g;
|
||||||
|
pnf_p7_t *_this = (pnf_p7_t *)(config);
|
||||||
|
int mu = _this->mu;
|
||||||
|
|
||||||
if (IS_SOFTMODEM_RFSIM) {
|
if (IS_SOFTMODEM_RFSIM) {
|
||||||
// RFsim can run faster than realtime. However, we need to give the VNF
|
// RFsim can run faster than realtime. However, we need to give the VNF
|
||||||
// some time to send an answer, so the PNF can run faster than realtime,
|
// some time to send an answer, so the PNF can run faster than realtime,
|
||||||
// but it should not too much. This function will "maybe" slow down, up to
|
// but it should not too much. This function will "maybe" slow down, up to
|
||||||
// a slot length of SLOT_DURATION us
|
// a slot length
|
||||||
maybe_slow_down_pnf();
|
maybe_slow_down_pnf(mu);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
//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
|
//we give four additional slots (2ms) which should be enough time for the VNF to
|
||||||
//answer
|
//answer
|
||||||
int slot_ahead = 4;
|
int slot_ahead = 2 << mu;
|
||||||
int mu = _this->mu;
|
|
||||||
uint16_t sfn_tx = sfn;
|
uint16_t sfn_tx = sfn;
|
||||||
uint16_t slot_tx = slot;
|
uint16_t slot_tx = slot;
|
||||||
sfnslot_add_slot(mu, &sfn_tx, &slot_tx, slot_ahead); // modify: do in place
|
sfnslot_add_slot(mu, &sfn_tx, &slot_tx, slot_ahead); // modify: do in place
|
||||||
|
|||||||
Reference in New Issue
Block a user