diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2019-09-27 15:55:45 +0200 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2019-10-05 20:50:13 +0000 |
commit | 972c24314694396c9b66fd8175cdcd40f01bdd39 (patch) | |
tree | 89b9a353434133e96d83df7c0efab23bf8c42861 | |
parent | 41c7b052838aaf17cd96daa8d7478b434bf4ab2a (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
-rw-r--r-- | include/osmo-bts/gsm_data_shared.h | 14 | ||||
-rw-r--r-- | src/osmo-bts-oc2g/l1_if.h | 7 | ||||
-rw-r--r-- | src/osmo-bts-oc2g/main.c | 6 | ||||
-rw-r--r-- | src/osmo-bts-virtual/l1_if.h | 7 | ||||
-rw-r--r-- | src/osmo-bts-virtual/main.c | 3 | ||||
-rw-r--r-- | src/osmo-bts-virtual/scheduler_virtbts.c | 20 |
6 files changed, 33 insertions, 24 deletions
diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h index cf7b7157..5d8bc76e 100644 --- a/include/osmo-bts/gsm_data_shared.h +++ b/include/osmo-bts/gsm_data_shared.h @@ -775,19 +775,7 @@ struct gsm_bts { char *sock_path; } pcu; - struct { - uint32_t last_fn; - struct timeval tv_clock; - struct osmo_timer_list fn_timer; - } vbts; -#ifdef ENABLE_OC2GBTS - /* specific to Open Cellular 2G BTS */ - struct { - uint8_t led_ctrl_mode; /* 0: control by BTS, 1: not control by BTS */ - struct llist_head ceased_alarm_list; /* ceased alarm list*/ - unsigned int rtp_drift_thres_ms; /* RTP timestamp drift detection threshold */ - } oc2g; -#endif + void *model_priv; /* Allocated by bts_model, contains model specific data pointer */ }; diff --git a/src/osmo-bts-oc2g/l1_if.h b/src/osmo-bts-oc2g/l1_if.h index 38699e01..e4b8feb4 100644 --- a/src/osmo-bts-oc2g/l1_if.h +++ b/src/osmo-bts-oc2g/l1_if.h @@ -30,6 +30,13 @@ enum { _NUM_MQ_WRITE }; +/* gsm_bts->model_priv, specific to Open Cellular 2G BTS */ +struct bts_oc2g_priv { + uint8_t led_ctrl_mode; /* 0: control by BTS, 1: not control by BTS */ + struct llist_head ceased_alarm_list; /* ceased alarm list*/ + unsigned int rtp_drift_thres_ms; /* RTP timestamp drift detection threshold */ +}; + struct calib_send_state { FILE *fp; const char *path; diff --git a/src/osmo-bts-oc2g/main.c b/src/osmo-bts-oc2g/main.c index 5b66c6f3..abecba14 100644 --- a/src/osmo-bts-oc2g/main.c +++ b/src/osmo-bts-oc2g/main.c @@ -87,15 +87,17 @@ int bts_model_init(struct gsm_bts *bts) static struct osmo_fd accept_fd, read_fd; int rc; + struct bts_oc2g_priv *bts_oc2g = talloc(bts, struct bts_oc2g_priv); + bts->model_priv = bts_oc2g; bts->variant = BTS_OSMO_OC2G; bts->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3); /* specific default values for OC2G platform */ /* TODO(oramadan) MERGE - bts->oc2g.led_ctrl_mode = OC2G_BTS_LED_CTRL_MODE_DEFAULT; + bts_oc2g->led_ctrl_mode = OC2G_BTS_LED_CTRL_MODE_DEFAULT; */ /* RTP drift threshold default */ - /* bts->oc2g.rtp_drift_thres_ms = OC2G_BTS_RTP_DRIFT_THRES_DEFAULT; */ + /* bts_oc2g->rtp_drift_thres_ms = OC2G_BTS_RTP_DRIFT_THRES_DEFAULT; */ rc = oml_router_init(bts, OML_ROUTER_PATH, &accept_fd, &read_fd); if (rc < 0) { diff --git a/src/osmo-bts-virtual/l1_if.h b/src/osmo-bts-virtual/l1_if.h index 6a843b37..075856f1 100644 --- a/src/osmo-bts-virtual/l1_if.h +++ b/src/osmo-bts-virtual/l1_if.h @@ -5,6 +5,13 @@ #include "virtual_um.h" +/* gsm_bts->model_priv, specific to osmo-bts-virtual */ +struct bts_virt_priv { + uint32_t last_fn; + struct timeval tv_clock; + struct osmo_timer_list fn_timer; +}; + struct vbts_l1h { struct gsm_bts_trx *trx; struct l1sched_trx l1s; diff --git a/src/osmo-bts-virtual/main.c b/src/osmo-bts-virtual/main.c index aa1c608e..c329f3a9 100644 --- a/src/osmo-bts-virtual/main.c +++ b/src/osmo-bts-virtual/main.c @@ -47,6 +47,7 @@ #include <osmo-bts/l1sap.h> #include <osmo-bts/phy_link.h> #include "virtual_um.h" +#include "l1_if.h" /* dummy, since no direct dsp support */ uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx) @@ -56,6 +57,8 @@ uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx) int bts_model_init(struct gsm_bts *bts) { + struct bts_virt_priv *bts_virt = talloc_zero(bts, struct bts_virt_priv); + bts->model_priv = bts_virt; bts->variant = BTS_OSMO_VIRTUAL; bts->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3); 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; } |