aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-06-02 22:00:25 +0200
committerlaforge <laforge@gnumonks.org>2019-06-13 15:38:01 +0000
commit46d62b984a10b3966d8a0d0a435d4efab0e9c500 (patch)
treead5f976b7463510c7a426db203435442c4d3627e
parent1ff0a2addd04de5bfe1601e84b013c65e500faf0 (diff)
lapdm: Use new libosmocore API to ensure per-channel-type N200 values
By using new libosmocore LAPDm API we can specify the GSM channel type and hence enable the LAPDm code to use a per-channel-type specific N200 value. At the same time, this new API also allows us to specify T200 values when initializing the LAPDm channel, so we don't have to fiddle with low-level lapdm data structures in what used to be oml_set_lchan_t200(). Change-Id: I0e814fbae13e0feddd148c47255dcc38cb718f48 Depends: libosmocore I90fdc4dd4720d4e02213197c894eb0a55a39158c Closes: OS#4037
-rw-r--r--include/osmo-bts/oml.h2
-rw-r--r--src/common/bts.c42
-rw-r--r--src/common/oml.c55
3 files changed, 40 insertions, 59 deletions
diff --git a/include/osmo-bts/oml.h b/include/osmo-bts/oml.h
index 14da70e..b92a974 100644
--- a/include/osmo-bts/oml.h
+++ b/include/osmo-bts/oml.h
@@ -40,8 +40,6 @@ int oml_fom_ack_nack(struct msgb *old_msg, uint8_t cause);
int oml_mo_fom_ack_nack(const struct gsm_abis_mo *mo, uint8_t orig_msg_type,
uint8_t cause);
-/* Configure LAPDm T200 timers for this lchan according to OML */
-int oml_set_lchan_t200(struct gsm_lchan *lchan);
extern const unsigned int oml_default_t200_ms[7];
/* Transmit failure event report */
diff --git a/src/common/bts.c b/src/common/bts.c
index c57d9f4..b912f33 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -377,15 +377,53 @@ int trx_set_available(struct gsm_bts_trx *trx, int avail)
return 0;
}
+/* prepare the per-SAPI T200 arrays for a given lchan */
+static int t200_by_lchan(int *t200_ms_dcch, int *t200_ms_acch, struct gsm_lchan *lchan)
+{
+ struct gsm_bts *bts = lchan->ts->trx->bts;
+
+ /* we have to compensate for the "RTS advance" due to the asynchronous interface between
+ * the BTS (LAPDm) and the PHY/L1 (OsmoTRX or DSP in case of osmo-bts-{sysmo,lc15,oc2g,octphy} */
+ int32_t fn_advance = bts_get_avg_fn_advance(bts);
+ int32_t fn_advance_us = fn_advance * 4615;
+ int fn_advance_ms = fn_advance_us / 1000;
+
+ t200_ms_acch[DL_SAPI0] = bts->t200_ms[T200_SACCH_SDCCH] + fn_advance_ms;
+ t200_ms_acch[DL_SAPI3] = bts->t200_ms[T200_SACCH_SDCCH] + fn_advance_ms;
+
+ switch (lchan->type) {
+ case GSM_LCHAN_SDCCH:
+ t200_ms_dcch[DL_SAPI0] = bts->t200_ms[T200_SDCCH] + fn_advance_ms;
+ t200_ms_dcch[DL_SAPI3] = bts->t200_ms[T200_SDCCH_SAPI3] + fn_advance_ms;
+ break;
+ case GSM_LCHAN_TCH_F:
+ t200_ms_dcch[DL_SAPI0] = bts->t200_ms[T200_FACCH_F] + fn_advance_ms;
+ t200_ms_dcch[DL_SAPI3] = bts->t200_ms[T200_FACCH_F] + fn_advance_ms;
+ break;
+ case GSM_LCHAN_TCH_H:
+ t200_ms_dcch[DL_SAPI0] = bts->t200_ms[T200_FACCH_H] + fn_advance_ms;
+ t200_ms_dcch[DL_SAPI3] = bts->t200_ms[T200_FACCH_H] + fn_advance_ms;
+ break;
+ default:
+ return -1;
+ }
+ return 0;
+}
+
int lchan_init_lapdm(struct gsm_lchan *lchan)
{
struct lapdm_channel *lc = &lchan->lapdm_ch;
+ int t200_ms_dcch[_NR_DL_SAPI], t200_ms_acch[_NR_DL_SAPI];
+
+ t200_by_lchan(t200_ms_dcch, t200_ms_acch, lchan);
+
+ LOGPLCHAN(lchan, DLLAPD, LOGL_DEBUG, "Setting T200 D0=%u, D3=%u, S0=%u, S3=%u (all in ms)\n",
+ t200_ms_dcch[DL_SAPI0], t200_ms_dcch[DL_SAPI3], t200_ms_acch[DL_SAPI0], t200_ms_acch[DL_SAPI3]);
- lapdm_channel_init(lc, LAPDM_MODE_BTS);
+ lapdm_channel_init2(lc, LAPDM_MODE_BTS, t200_ms_dcch, t200_ms_acch, lchan->type);
lapdm_channel_set_flags(lc, LAPDM_ENT_F_POLLING_ONLY);
lapdm_channel_set_l1(lc, NULL, lchan);
lapdm_channel_set_l3(lc, lapdm_rll_tx_cb, lchan);
- oml_set_lchan_t200(lchan);
return 0;
}
diff --git a/src/common/oml.c b/src/common/oml.c
index 7d24509..8ecafbb 100644
--- a/src/common/oml.c
+++ b/src/common/oml.c
@@ -488,61 +488,6 @@ const unsigned int oml_default_t200_ms[7] = {
[T200_SACCH_TCH_SAPI3] = 1500,
};
-static void dl_set_t200(struct gsm_bts *bts, struct lapdm_datalink *dl, unsigned int t200_msec)
-{
- int32_t fn_advance = bts_get_avg_fn_advance(bts);
- int32_t fn_advance_us = fn_advance * 4615; /* 4.615 ms per frame */
-
- /* we have to compensate for the "RTS advance" due to the asynchronous interface between
- * the BTS (LAPDm) and the PHY/L1 (OsmoTRX or DSP in case of osmo-bts-{sysmo,lc15,oc2g,octphy} */
- t200_msec += fn_advance_us / 1000;
-
- dl->dl.t200_sec = t200_msec / 1000;
- dl->dl.t200_usec = (t200_msec % 1000) * 1000;
-}
-
-/* Configure LAPDm T200 timers for this lchan according to OML */
-int oml_set_lchan_t200(struct gsm_lchan *lchan)
-{
- struct gsm_bts *bts = lchan->ts->trx->bts;
- struct lapdm_channel *lc = &lchan->lapdm_ch;
- unsigned int t200_dcch, t200_dcch_sapi3, t200_acch, t200_acch_sapi3;
-
- /* set T200 for main and associated channel */
- switch (lchan->type) {
- case GSM_LCHAN_SDCCH:
- t200_dcch = bts->t200_ms[T200_SDCCH];
- t200_dcch_sapi3 = bts->t200_ms[T200_SDCCH_SAPI3];
- t200_acch = bts->t200_ms[T200_SACCH_SDCCH];
- t200_acch_sapi3 = bts->t200_ms[T200_SACCH_SDCCH];
- break;
- case GSM_LCHAN_TCH_F:
- t200_dcch = bts->t200_ms[T200_FACCH_F];
- t200_dcch_sapi3 = bts->t200_ms[T200_FACCH_F];
- t200_acch = bts->t200_ms[T200_SACCH_TCH_SAPI0];
- t200_acch_sapi3 = bts->t200_ms[T200_SACCH_TCH_SAPI3];
- break;
- case GSM_LCHAN_TCH_H:
- t200_dcch = bts->t200_ms[T200_FACCH_H];
- t200_dcch_sapi3 = bts->t200_ms[T200_FACCH_H];
- t200_acch = bts->t200_ms[T200_SACCH_TCH_SAPI0];
- t200_acch_sapi3 = bts->t200_ms[T200_SACCH_TCH_SAPI3];
- break;
- default:
- return -1;
- }
-
- LOGPLCHAN(lchan, DLLAPD, LOGL_DEBUG, "Setting T200 D0=%u, D3=%u, S0=%u, S3=%u (all in ms)\n",
- t200_dcch, t200_dcch_sapi3, t200_acch, t200_acch_sapi3);
-
- dl_set_t200(bts, &lc->lapdm_dcch.datalink[DL_SAPI0], t200_dcch);
- dl_set_t200(bts, &lc->lapdm_dcch.datalink[DL_SAPI3], t200_dcch_sapi3);
- dl_set_t200(bts, &lc->lapdm_acch.datalink[DL_SAPI0], t200_acch);
- dl_set_t200(bts, &lc->lapdm_acch.datalink[DL_SAPI3], t200_acch_sapi3);
-
- return 0;
-}
-
/* 3GPP TS 52.021 ยง8.11.1 Get Attributes has been received */
static int oml_rx_get_attr(struct gsm_bts *bts, struct msgb *msg)
{