Change in ...osmo-bts[master]: lapdm: Use new libosmocore API to ensure per-channel-type N200 values

laforge gerrit-no-reply at lists.osmocom.org
Thu Jun 13 15:38:03 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-bts/+/14340 )

Change subject: lapdm: Use new libosmocore API to ensure per-channel-type N200 values
......................................................................

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
---
M include/osmo-bts/oml.h
M src/common/bts.c
M src/common/oml.c
3 files changed, 40 insertions(+), 59 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



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_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 @@
 	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];
 
-	lapdm_channel_init(lc, LAPDM_MODE_BTS);
+	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_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 @@
 	[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)
 {

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/14340
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I0e814fbae13e0feddd148c47255dcc38cb718f48
Gerrit-Change-Number: 14340
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190613/92b79c1f/attachment.html>


More information about the gerrit-log mailing list