Stefan Sperling has uploaded this change for review. ( 
https://gerrit.osmocom.org/10415


Change subject: send TCH/F fill frames in DTX mode (WIP)
......................................................................

send TCH/F fill frames in DTX mode (WIP)

Send DTX TCH fill frames according to GSM 05.08, section 8.3.

Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Related: OS#1950
---
M src/common/l1sap.c
1 file changed, 52 insertions(+), 13 deletions(-)



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

diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 8d735e5..ed818cb 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -670,6 +670,19 @@
        return 0;
 }

+ /* Determine whether we need to send a DTX TCH fill frame according to GSM 
05.08, section 8.3. */
+static bool is_required_tchf_fill_frame_dtx(uint32_t fn) {
+       /* On TCHF this subset of TDMA frames (mod 104) is always used for 
transmission during DTX: */
+       const int tchf_required_fn_dtx[] = { 52, 53, 54, 55, 56, 57, 58, 59 };
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(tchf_required_fn_dtx); i++) {
+               if (fn % 104 == tchf_required_fn_dtx[i])
+                       return true;
+       }
+       return false;
+}
+
 /* PH-RTS-IND prim received from bts model */
 static int l1sap_ph_rts_ind(struct gsm_bts_trx *trx,
        struct osmo_phsap_prim *l1sap, struct ph_data_param *rts_ind)
@@ -729,14 +742,18 @@
                si = bts_sysinfo_get(trx->bts, &g_time);
                if (si)
                        memcpy(p, si, GSM_MACBLOCK_LEN);
-               else
+               else {
                        memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+                       DEBUGPGT(DL1P, &g_time, "sending fill frame BCCH 
chan_nr=%d fn=%u\n", chan_nr, fn);
+               }
        } else if (!(chan_nr & 0x80)) { /* only TCH/F, TCH/H, SDCCH/4 and 
SDCCH/8 have C5 bit cleared */
+               bool dtxd = false;
                lchan = get_active_lchan_by_chan_nr(trx, chan_nr);
                if (!lchan) {
                        LOGPGT(DL1P, LOGL_ERROR, &g_time, "No lchan for 
PH-RTS.ind (chan_nr=%u)\n", chan_nr);
                        return 0;
                }
+               dtxd = lchan->ts->trx->bts->dtxd;
                if (L1SAP_IS_LINK_SACCH(link_id)) {
                        p = msgb_put(msg, GSM_MACBLOCK_LEN);
                        /* L1-header, if not set/modified by layer 1 */
@@ -756,20 +773,39 @@
                                if (si) {
                                        /* The +2 is empty space where the DSP 
inserts the L1 hdr */
                                        memcpy(p + 2, si, GSM_MACBLOCK_LEN - 2);
-                               } else
+                               } else {
                                        memcpy(p + 2, fill_frame, 
GSM_MACBLOCK_LEN - 2);
-                       } else if (L1SAP_IS_CHAN_SDCCH4(chan_nr) || 
L1SAP_IS_CHAN_SDCCH8(chan_nr) ||
-                                  (lchan->rsl_cmode == RSL_CMOD_SPD_SIGN && 
!lchan->ts->trx->bts->dtxd)) {
-                               /*
-                                * SDCCH or TCH in signalling mode without DTX.
-                                *
-                                * Send fill frame according to GSM 05.08, 
section 8.3: "On the SDCCH and on the
-                                * half rate speech traffic channel in 
signalling only mode DTX is not allowed.
-                                * In these cases and during signalling on the 
TCH when DTX is not used, the same
-                                * L2 fill frame shall be transmitted in case 
there is nothing else to transmit."
-                                */
+                                       DEBUGPGT(DL1P, &g_time, "sending fill 
frame SACCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? "enabled" : 
"disabled");
+                               }
+                       } else if (L1SAP_IS_CHAN_SDCCH4(chan_nr) || 
L1SAP_IS_CHAN_SDCCH8(chan_nr)) {
                                p = msgb_put(msg, GSM_MACBLOCK_LEN);
                                memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+                               DEBUGPGT(DL1P, &g_time, "sending fill frame 
SDCCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? "enabled" : "disabled");
+                       } else if (lchan->rsl_cmode == RSL_CMOD_SPD_SIGN) {
+                               if (lchan->ts->trx->bts->dtxd) {
+                                       /*
+                                        * TCH in signalling mode with DTX.
+                                        * Send fill frame according to GSM 
05.08, section 8.3.
+                                        */
+                                       if (L1SAP_IS_CHAN_TCHF(chan_nr) && 
is_required_tchf_fill_frame_dtx(fn)) {
+                                               p = msgb_put(msg, 
GSM_MACBLOCK_LEN);
+                                               memcpy(p, fill_frame, 
GSM_MACBLOCK_LEN);
+                                               DEBUGPGT(DL1P, &g_time, 
"sending fill frame TCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? 
"enabled" : "disabled");
+                                               //dtx_dispatch(lchan, E_FACCH);
+                                       }
+                               } else {
+                                       /*
+                                        * TCH in signalling mode without DTX.
+                                        *
+                                        * Send fill frame according to GSM 
05.08, section 8.3: "On the SDCCH and on the
+                                        * half rate speech traffic channel in 
signalling only mode DTX is not allowed.
+                                        * In these cases and during signalling 
on the TCH when DTX is not used, the same
+                                        * L2 fill frame shall be transmitted 
in case there is nothing else to transmit."
+                                        */
+                                       p = msgb_put(msg, GSM_MACBLOCK_LEN);
+                                       memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+                                       DEBUGPGT(DL1P, &g_time, "sending fill 
frame TCH chan_nr=%d fn=%u dtx=%s\n", chan_nr, fn, dtxd ? "enabled" : 
"disabled");
+                               }
                        } /* else the message remains empty, so TCH frames are 
sent */
                } else {
                        /* The +2 is empty space where the DSP inserts the L1 
hdr */
@@ -790,8 +826,10 @@
                rc = bts_ccch_copy_msg(trx->bts, p, &g_time,
                                       (L1SAP_FN2CCCHBLOCK(fn) <
                                        num_agch(trx, "PH-RTS-IND")));
-               if (rc <= 0)
+               if (rc <= 0) {
                        memcpy(p, fill_frame, GSM_MACBLOCK_LEN);
+                       DEBUGPGT(DL1P, &g_time, "sending fill frame AGCH PCH 
chan_nr=%d fn=%u\n", chan_nr, fn);
+               }
        }

        DEBUGPGT(DL1P, &g_time, "Tx PH-DATA.req chan_nr=0x%02x 
link_id=0x%02x\n", chan_nr, link_id);
@@ -1440,6 +1478,7 @@
                char name[32];
                snprintf(name, sizeof(name), "bts%u-trx%u-ts%u-ss%u", 
lchan->ts->trx->bts->nr,
                         lchan->ts->trx->nr, lchan->ts->nr, lchan->nr);
+               LOGP(DL1C, LOGL_NOTICE, "allocating DTX FSM for chan_nr=%d\n", 
chan_nr);
                lchan->tch.dtx.dl_amr_fsm = osmo_fsm_inst_alloc(&dtx_dl_amr_fsm,
                                                                tall_bts_ctx,
                                                                lchan,

--
To view, visit https://gerrit.osmocom.org/10415
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7bff00b8cf41dc1b0e6e668173bebce23be0d253
Gerrit-Change-Number: 10415
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>

Reply via email to