aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-virtual/scheduler_virtbts.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-09-27 15:55:45 +0200
committerpespin <pespin@sysmocom.de>2019-10-05 20:50:13 +0000
commit972c24314694396c9b66fd8175cdcd40f01bdd39 (patch)
tree89b9a353434133e96d83df7c0efab23bf8c42861 /src/osmo-bts-virtual/scheduler_virtbts.c
parent41c7b052838aaf17cd96daa8d7478b434bf4ab2a (diff)
struct gsm_bts: Add model_priv pointer handing bts_model specific data
Currently there's bts-virtual specific fields in gsm_bts which is not used by other models and are always allocated. An alternative would be having a union with different structs inside, one per model, but since we already have the bts_model abstraction, in this case it makes more sense to use that abstraction instead of filling code with preprocessor ifdefs to guard against non-defined types, etc. Existing model specific data is moved there. This new infra will be user further in forthcoming commits. Related: OS#4215 Change-Id: Ib17a752cdbaa7d5eb8c5dfa0b197f80a4f38b38e
Diffstat (limited to 'src/osmo-bts-virtual/scheduler_virtbts.c')
-rw-r--r--src/osmo-bts-virtual/scheduler_virtbts.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c
index 259a573a..83c37f35 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -562,8 +562,9 @@ static int vbts_sched_fn(struct gsm_bts *bts, uint32_t fn)
static void vbts_fn_timer_cb(void *data)
{
struct gsm_bts *bts = data;
+ struct bts_virt_priv *bts_virt = (struct bts_virt_priv *)bts->model_priv;
struct timeval tv_now;
- struct timeval *tv_clock = &bts->vbts.tv_clock;
+ struct timeval *tv_clock = &bts_virt->tv_clock;
int32_t elapsed_us;
gettimeofday(&tv_now, NULL);
@@ -587,28 +588,29 @@ static void vbts_fn_timer_cb(void *data)
};
timeradd(tv_clock, &tv_frame, tv_clock);
/* increment the frame number in the BTS model instance */
- bts->vbts.last_fn = (bts->vbts.last_fn + 1) % GSM_HYPERFRAME;
- vbts_sched_fn(bts, bts->vbts.last_fn);
+ bts_virt->last_fn = (bts_virt->last_fn + 1) % GSM_HYPERFRAME;
+ vbts_sched_fn(bts, bts_virt->last_fn);
elapsed_us -= FRAME_DURATION_uS;
}
/* re-schedule the timer */
/* timer is set to frame duration - elapsed time to guarantee that this cb method will be
* periodically executed every 4.615ms */
- osmo_timer_schedule(&bts->vbts.fn_timer, 0, FRAME_DURATION_uS - elapsed_us);
+ osmo_timer_schedule(&bts_virt->fn_timer, 0, FRAME_DURATION_uS - elapsed_us);
}
int vbts_sched_start(struct gsm_bts *bts)
{
+ struct bts_virt_priv *bts_virt = (struct bts_virt_priv *)bts->model_priv;
LOGP(DL1P, LOGL_NOTICE, "starting VBTS scheduler\n");
- memset(&bts->vbts.fn_timer, 0, sizeof(bts->vbts.fn_timer));
- bts->vbts.fn_timer.cb = vbts_fn_timer_cb;
- bts->vbts.fn_timer.data = bts;
+ memset(&bts_virt->fn_timer, 0, sizeof(bts_virt->fn_timer));
+ bts_virt->fn_timer.cb = vbts_fn_timer_cb;
+ bts_virt->fn_timer.data = bts;
- gettimeofday(&bts->vbts.tv_clock, NULL);
+ gettimeofday(&bts_virt->tv_clock, NULL);
/* trigger the first timer after 4615us (a frame duration) */
- osmo_timer_schedule(&bts->vbts.fn_timer, 0, FRAME_DURATION_uS);
+ osmo_timer_schedule(&bts_virt->fn_timer, 0, FRAME_DURATION_uS);
return 0;
}