From: Max <[email protected]>

Add support for explicitly passing PH-DATA presence info.
Remove in-band passing of presence information and replace corresponding
check. This also fixes integration between Octasic BTS hw and OsmoPCU:
previously osmo-bts-octphy have not provided in-band presence
information which cause off-by-one errors and misinterpretation of
ph_data_ind by PCU.

Note: this requires libosmocore version with osmo_ph_pres_info_type
support integrated.
---
 include/osmo-bts/scheduler_backend.h |  2 +-
 src/common/l1sap.c                   |  5 +++--
 src/common/scheduler.c               |  3 ++-
 src/osmo-bts-octphy/l1_if.c          |  1 +
 src/osmo-bts-trx/scheduler_trx.c     | 16 +++++++---------
 5 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/osmo-bts/scheduler_backend.h 
b/include/osmo-bts/scheduler_backend.h
index 9f663cd..1614250 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -42,7 +42,7 @@ struct msgb *_sched_dequeue_prim(struct l1sched_trx *l1t, 
int8_t tn, uint32_t fn
                                 enum trx_chan_type chan);

 int _sched_compose_ph_data_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t 
fn,
-                               enum trx_chan_type chan, uint8_t *l2, uint8_t 
l2_len, float rssi);
+                               enum trx_chan_type chan, uint8_t *l2, uint8_t 
l2_len, float rssi, enum osmo_ph_pres_info_type presence_info);

 int _sched_compose_tch_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
                    enum trx_chan_type chan, uint8_t *tch, uint8_t tch_len);
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 8056034..ac398d3 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -744,6 +744,7 @@ static int l1sap_ph_data_ind(struct gsm_bts_trx *trx,
        uint8_t tn;
        uint32_t fn;
        int8_t rssi;
+       enum osmo_ph_pres_info_type pr_info = data_ind->pdch_presence_info;

        rssi = data_ind->rssi;
        chan_nr = data_ind->chan_nr;
@@ -767,11 +768,11 @@ static int l1sap_ph_data_ind(struct gsm_bts_trx *trx,
                        return 0;
                }
                /* drop incomplete UL block */
-               if (data[0] != 7)
+               if (pr_info != PRES_INFO_BOTH)
                        return 0;
                /* PDTCH / PACCH frame handling */
                pcu_tx_data_ind(&trx->ts[tn], 0, fn, 0 /* ARFCN */,
-                       L1SAP_FN2MACBLOCK(fn), data + 1, len - 1, rssi);
+                       L1SAP_FN2MACBLOCK(fn), data, len, rssi);

                return 0;
        }
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index e9d2423..07c2e12 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -268,7 +268,7 @@ found_msg:
 }

 int _sched_compose_ph_data_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t 
fn,
-                               enum trx_chan_type chan, uint8_t *l2, uint8_t 
l2_len, float rssi)
+                               enum trx_chan_type chan, uint8_t *l2, uint8_t 
l2_len, float rssi, enum osmo_ph_pres_info_type presence_info)
 {
        struct msgb *msg;
        struct osmo_phsap_prim *l1sap;
@@ -284,6 +284,7 @@ int _sched_compose_ph_data_ind(struct l1sched_trx *l1t, 
uint8_t tn, uint32_t fn,
        l1sap->u.data.link_id = trx_chan_desc[chan].link_id;
        l1sap->u.data.fn = fn;
        l1sap->u.data.rssi = (int8_t) (rssi);
+       l1sap->u.data.pdch_presence_info = presence_info;
        msg->l2h = msgb_put(msg, l2_len);
        if (l2_len)
                memcpy(msg->l2h, l2, l2_len);
diff --git a/src/osmo-bts-octphy/l1_if.c b/src/osmo-bts-octphy/l1_if.c
index 3215aa1..781d589 100644
--- a/src/osmo-bts-octphy/l1_if.c
+++ b/src/osmo-bts-octphy/l1_if.c
@@ -1032,6 +1032,7 @@ static int handle_ph_data_ind(struct octphy_hdl *fl1,
        l1sap->u.data.chan_nr = chan_nr;
        l1sap->u.data.fn = fn;
        l1sap->u.data.rssi = rssi;
+       l1sap->u.data.pdch_presence_info = PRES_INFO_BOTH; /* FIXME: consider 
EDGE support */

        l1sap_up(trx, l1sap);

diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index 15c05e8..243539d 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -190,7 +190,7 @@ got_msg:
                        l1if_process_meas_res(l1t->trx, tn, fn, 
trx_chan_desc[chan].chan_nr | tn,
                                456, 456, -110, 0);

-                       _sched_compose_ph_data_ind(l1t, tn, 0, chan, NULL, 0, 
-110);
+                       _sched_compose_ph_data_ind(l1t, tn, 0, chan, NULL, 0, 
-110, PRES_INFO_INVALID);
                }
        }

@@ -841,7 +841,7 @@ int rx_data_fn(struct l1sched_trx *l1t, uint8_t tn, 
uint32_t fn,
        l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | 
tn,
                n_errors, n_bits_total, *rssi_sum / *rssi_num, *toa_sum / 
*toa_num);

-       return _sched_compose_ph_data_ind(l1t, tn, *first_fn, chan, l2, l2_len, 
*rssi_sum / *rssi_num);
+       return _sched_compose_ph_data_ind(l1t, tn, *first_fn, chan, l2, l2_len, 
*rssi_sum / *rssi_num, PRES_INFO_UNKNOWN);
 }

 int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
@@ -856,7 +856,7 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, 
uint32_t fn,
        uint8_t *rssi_num = &chan_state->rssi_num;
        float *toa_sum = &chan_state->toa_sum;
        uint8_t *toa_num = &chan_state->toa_num;
-       uint8_t l2[54+1];
+       uint8_t l2[54];
        int n_errors, n_bits_total;
        int rc;

@@ -906,7 +906,7 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, 
uint32_t fn,
        *mask = 0x0;

        /* decode */
-       rc = pdtch_decode(l2 + 1, *bursts_p, NULL, &n_errors, &n_bits_total);
+       rc = pdtch_decode(l2, *bursts_p, NULL, &n_errors, &n_bits_total);

        /* Send uplnk measurement information to L2 */
        l1if_process_meas_res(l1t->trx, tn, fn, trx_chan_desc[chan].chan_nr | 
tn,
@@ -919,10 +919,8 @@ int rx_pdtch_fn(struct l1sched_trx *l1t, uint8_t tn, 
uint32_t fn,
                return 0;
        }

-       l2[0] = 7; /* valid frame */
-
        return _sched_compose_ph_data_ind(l1t, tn, (fn + GSM_HYPERFRAME - 3) % 
GSM_HYPERFRAME, chan,
-               l2, rc + 1, *rssi_sum / *rssi_num);
+               l2, rc + 1, *rssi_sum / *rssi_num, PRES_INFO_BOTH);
 }

 int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
@@ -1038,7 +1036,7 @@ int rx_tchf_fn(struct l1sched_trx *l1t, uint8_t tn, 
uint32_t fn,
        /* FACCH */
        if (rc == GSM_MACBLOCK_LEN) {
                _sched_compose_ph_data_ind(l1t, tn, (fn + GSM_HYPERFRAME - 7) % 
GSM_HYPERFRAME, chan,
-                       tch_data + amr, GSM_MACBLOCK_LEN, rssi);
+                       tch_data + amr, GSM_MACBLOCK_LEN, rssi, 
PRES_INFO_UNKNOWN);
 bfi:
                if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
                        /* indicate bad frame */
@@ -1204,7 +1202,7 @@ int rx_tchh_fn(struct l1sched_trx *l1t, uint8_t tn, 
uint32_t fn,
                chan_state->ul_ongoing_facch = 1;
                _sched_compose_ph_data_ind(l1t, tn,
                        (fn + GSM_HYPERFRAME - 10 - ((fn % 26) >= 19)) % 
GSM_HYPERFRAME, chan,
-                       tch_data + amr, GSM_MACBLOCK_LEN, rssi);
+                       tch_data + amr, GSM_MACBLOCK_LEN, rssi, 
PRES_INFO_UNKNOWN);
 bfi:
                if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
                        /* indicate bad frame */
-- 
2.7.1

Reply via email to