Review at  https://gerrit.osmocom.org/3118

octphy: remap frame number in MEAS_IND

The octasic phy stamps the SACCH channel that carries the
measurmenet indication with the frame number of the last
SACCH that falls within the measurement period.

The higher layers expect the frame number to be aligned
to the SACCH channel after, which marks also the beginning
of the next measurement period.

Make the octphy code compatible to the higher layers by
remapping the measurement indication frame number.

Change-Id: I8ecb27c018bf4ad5151878a6ad34026fd0f801a1
---
M src/osmo-bts-octphy/l1_if.c
1 file changed, 52 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/18/3118/1

diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 8b31630..c7a7fe8 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -803,6 +803,57 @@
  * handling of messages coming up from PHY
  ***********************************************************************/
 
+/* When the measurement indication is received from the phy, the phy will
+ * automatically stamp it with the frame number that matches the frame
+ * number of the SACCH channel that marks the end of the measurement
+ * period. (e.g. fn%104=90, on a TCH/H, TS0). However, the upper layers
+ * expect the frame number to be aligned to the next SACCH frame after,
+ * after the end of the measurement period that has just passed. (e.g.
+ * (fn%104=10, on a TCH/H, TS0). The following function remaps the frame
+ * number in order to match the higher layers expectations.
+ * See also: 3GPP TS 05.02 Clause 7 Table 1 of 9  Mapping of logical channels
+ * onto physical channels (see subclauses 6.3, 6.4, 6.5) */
+static uint32_t translate_tch_meas_rep_fn104_reverse(uint32_t fn)
+{
+       uint8_t new_fn_mod;
+       uint8_t fn_mod;
+
+       fn_mod = fn % 104;
+
+       switch (fn_mod) {
+       case 103:
+               new_fn_mod = 25;
+               break;
+       case 12:
+               new_fn_mod = 38;
+               break;
+       case 25:
+               new_fn_mod = 51;
+               break;
+       case 38:
+               new_fn_mod = 64;
+               break;
+       case 51:
+               new_fn_mod = 77;
+               break;
+       case 64:
+               new_fn_mod = 90;
+               break;
+       case 77:
+               new_fn_mod = 103;
+               break;
+       case 90:
+               new_fn_mod = 12;
+               break;
+       default:
+               /* No translation for frame numbers
+                * fall out of the raster */
+               new_fn_mod = fn_mod;
+       }
+
+       return (fn - fn_mod) + new_fn_mod;
+}
+
 static void process_meas_res(struct gsm_bts_trx *trx, uint8_t chan_nr,
                             uint32_t fn, uint32_t data_len,
                             tOCTVC1_GSM_MEASUREMENT_INFO * m)
@@ -841,7 +892,7 @@
        l1sap.u.info.u.meas_ind.inv_rssi = (uint8_t) ((m->sRSSIDbm >> 8) * -1);
 
        /* copy logical frame number to MEAS IND data structure */
-       l1sap.u.info.u.meas_ind.fn = fn;
+       l1sap.u.info.u.meas_ind.fn = translate_tch_meas_rep_fn104_reverse(fn);
 
        /* l1sap wants to take msgb ownership.  However, as there is no
         * msg, it will msgb_free(l1sap.oph.msg == NULL) */

-- 
To view, visit https://gerrit.osmocom.org/3118
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ecb27c018bf4ad5151878a6ad34026fd0f801a1
Gerrit-PatchSet: 1
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Owner: dexter <pma...@sysmocom.de>

Reply via email to