fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/31672 )


Change subject: osmo-bts-trx: alloc/free burst bufers in trx_sched_set_lchan()
......................................................................

osmo-bts-trx: alloc/free burst bufers in trx_sched_set_lchan()

Change-Id: I6a5f76023fc492786076a63016f81285b3576c33
Related: OS#1572
---
M include/osmo-bts/scheduler_backend.h
M src/common/scheduler.c
M src/osmo-bts-trx/sched_lchan_pdtch.c
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
M src/osmo-bts-trx/sched_lchan_xcch.c
6 files changed, 91 insertions(+), 115 deletions(-)



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

diff --git a/include/osmo-bts/scheduler_backend.h 
b/include/osmo-bts/scheduler_backend.h
index 3b1388f..a389f25 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -29,6 +29,8 @@
        trx_sched_dl_func       *dl_fn;
        /*! \brief function to call when burst received from PHY */
        trx_sched_ul_func       *ul_fn;
+       /*! \brief size of Rx/Tx burst buffers */
+       size_t                  burst_buf_size;
        /*! \brief channel flags, see TRX_CHAN_FLAG_* */
        uint8_t                 flags;
 };
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index 14aff34..1d317a7 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -35,6 +35,7 @@
 #include <osmocom/core/stats.h>

 #include <osmocom/gsm/protocol/gsm_08_58.h>
+#include <osmocom/gsm/gsm0502.h>
 #include <osmocom/gsm/a5.h>

 #include <osmo-bts/gsm_data.h>
@@ -169,6 +170,7 @@
                /* Tx only, xCCH convolutional coding (3GPP TS 05.03, section 
4.4),
                 * regular interleaving (3GPP TS 05.02, clause 7, table 3):
                 * a L2 frame is interleaved over 4 consecutive bursts. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .flags = TRX_CHAN_FLAG_AUTO_ACTIVE,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
@@ -190,6 +192,7 @@
                /* Tx only, xCCH convolutional coding (3GPP TS 05.03, section 
4.4),
                 * regular interleaving (3GPP TS 05.02, clause 7, table 3):
                 * a L2 frame is interleaved over 4 consecutive bursts. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .flags = TRX_CHAN_FLAG_AUTO_ACTIVE,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
@@ -208,6 +211,7 @@
                 *     and odd numbered bits of the last 4 bursts;
                 *   - a FACCH/F frame 'steals' (replaces) one traffic frame,
                 *     interleaving is done in the same way. */
+               .burst_buf_size = 8 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_tchf_fn,
                .dl_fn = tx_tchf_fn,
                .ul_fn = rx_tchf_fn,
@@ -229,6 +233,7 @@
                 *     using the even numbered bits of the first 2 bursts,
                 *     all bits of the middle two 2 bursts,
                 *     and odd numbered bits of the last 2 bursts. */
+               .burst_buf_size = 6 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_tchh_fn,
                .dl_fn = tx_tchh_fn,
                .ul_fn = rx_tchh_fn,
@@ -240,6 +245,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_TCHH_0, see above. */
+               .burst_buf_size = 6 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_tchh_fn,
                .dl_fn = tx_tchh_fn,
                .ul_fn = rx_tchh_fn,
@@ -251,6 +257,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -262,6 +269,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -273,6 +281,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -284,6 +293,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -295,6 +305,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -306,6 +317,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -317,6 +329,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -328,6 +341,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -339,6 +353,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -350,6 +365,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -361,6 +377,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -372,6 +389,7 @@
                .link_id = LID_DEDIC,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -383,6 +401,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -394,6 +413,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -405,6 +425,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -416,6 +437,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -427,6 +449,7 @@
                .link_id = LID_SACCH,
 
                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -438,6 +461,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -449,6 +473,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH4_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -460,6 +485,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -471,6 +497,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -482,6 +509,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -493,6 +521,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -504,6 +533,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -515,6 +545,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -526,6 +557,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -537,6 +569,7 @@
                .link_id = LID_SACCH,

                /* Same as for TRXC_BCCH and TRXC_SDCCH8_* (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
                .ul_fn = rx_data_fn,
@@ -548,8 +581,8 @@

                /* Rx and Tx, multiple coding schemes: CS-2..4 and MCS-1..9 
(3GPP TS
                 * 05.03, chapter 5), regular interleaving as specified for 
xCCH.
-                * NOTE: the burst buffer is three times bigger because the
-                * payload of EDGE bursts is three times longer. */
+                * NOTE: 8-PSK modulated bursts are longer than GMSK modulated 
ones. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_8PSK_BURST,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_pdtch_fn,
                .ul_fn = rx_pdtch_fn,
@@ -564,6 +597,7 @@
                 * transfer mode. On Downlink, the network sends timing advance
                 * updates for several mobile stations. The coding scheme used
                 * for PTCCH/D messages is the same as for PDTCH CS-1. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_pdtch_fn,
                .ul_fn = rx_rach_fn,
@@ -575,6 +609,7 @@
                .chan_nr = RSL_CHAN_OSMO_CBCH4,

                /* Tx only, same as for TRXC_BCCH (xCCH), see above. */
+               .burst_buf_size = 4 * GSM_NBITS_NB_GMSK_PAYLOAD,
                .flags = TRX_CHAN_FLAG_AUTO_ACTIVE,
                .rts_fn = rts_data_fn,
                .dl_fn = tx_data_fn,
@@ -1097,29 +1132,31 @@
                LOGPLCHAN(lchan, DL1C, LOGL_INFO, "%s %s\n",
                          (active) ? "Activating" : "Deactivating",
                          trx_chan_desc[i].name);
-               /* free burst memory, to cleanly start with burst 0 */
-               if (chan_state->dl_bursts) {
-                       talloc_free(chan_state->dl_bursts);
-                       chan_state->dl_bursts = NULL;
-               }
-               if (chan_state->ul_bursts) {
-                       talloc_free(chan_state->ul_bursts);
-                       chan_state->ul_bursts = NULL;
-               }
-               if (chan_state->ul_bursts_prev) {
-                       talloc_free(chan_state->ul_bursts_prev);
-                       chan_state->ul_bursts_prev = NULL;
-               }

                if (active) {
                        /* Clean up everything */
                        memset(chan_state, 0, sizeof(*chan_state));

+                       /* Allocate memory for Rx/Tx burst buffers */
+                       const size_t buf_size = trx_chan_desc[i].burst_buf_size;
+                       if (trx_chan_desc[i].dl_fn != NULL)
+                               chan_state->dl_bursts = talloc_zero_size(l1ts, 
buf_size);
+                       if (trx_chan_desc[i].ul_fn != NULL) {
+                               chan_state->ul_bursts = talloc_zero_size(l1ts, 
buf_size);
+                               if 
(L1SAP_IS_LINK_SACCH(trx_chan_desc[i].link_id))
+                                       chan_state->ul_bursts_prev = 
talloc_zero_size(l1ts, buf_size);
+                       }
+
                        /* Bind to generic 'struct gsm_lchan' */
                        chan_state->lchan = lchan;
                } else {
                        chan_state->ho_rach_detect = 0;

+                       /* Release memory used by Rx/Tx burst buffers */
+                       TALLOC_FREE(chan_state->dl_bursts);
+                       TALLOC_FREE(chan_state->ul_bursts);
+                       TALLOC_FREE(chan_state->ul_bursts_prev);
+
                        /* Remove pending Tx prims belonging to this lchan */
                        trx_sched_queue_filter(&l1ts->dl_prims, chan_nr, 
link_id);
                }
diff --git a/src/osmo-bts-trx/sched_lchan_pdtch.c 
b/src/osmo-bts-trx/sched_lchan_pdtch.c
index 8300bdb..3afb4f5 100644
--- a/src/osmo-bts-trx/sched_lchan_pdtch.c
+++ b/src/osmo-bts-trx/sched_lchan_pdtch.c
@@ -60,13 +60,6 @@
        if (bi->flags & TRX_BI_F_ACCESS_BURST)
                return rx_rach_fn(l1ts, bi);

-       /* allocate burst memory, if not already */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, GSM0503_EGPRS_BURSTS_NBITS);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       }
-
        /* clear burst */
        if (bi->bid == 0) {
                memset(*bursts_p, 0, GSM0503_EGPRS_BURSTS_NBITS);
@@ -157,8 +150,10 @@

        /* send burst, if we already got a frame */
        if (br->bid > 0) {
-               if (!*bursts_p)
+#if 0
+               if (!*bursts_p) // XXX: align to the first burst
                        return -ENODEV;
+#endif
                goto send_burst;
        }

@@ -170,18 +165,11 @@
                 * take care of filling C0 with dummy bursts to keep expected
                 * power transmit levels
                 */
-               goto no_msg;
+               return -ENODEV;
        }

        /* BURST BYPASS */

-       /* allocate burst memory, if not already */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, GSM0503_EGPRS_BURSTS_NBITS);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       }
-
        /* encode bursts */
        rc = gsm0503_pdtch_egprs_encode(*bursts_p, msg->l2h, msg->tail - 
msg->l2h);
        if (rc < 0)
@@ -193,7 +181,7 @@
                        "(len=%ld)\n", (long)(msg->tail - msg->l2h));
                /* free message */
                msgb_free(msg);
-               goto no_msg;
+               return -EINVAL;
        } else if (rc == GSM0503_EGPRS_BURSTS_NBITS) {
                *mod = TRX_MOD_T_8PSK;
        } else {
@@ -226,12 +214,4 @@
        LOGL1SB(DL1P, LOGL_DEBUG, l1ts, br, "Transmitting burst=%u.\n", 
br->bid);

        return 0;
-
-no_msg:
-       /* free burst memory */
-       if (*bursts_p) {
-               talloc_free(*bursts_p);
-               *bursts_p = NULL;
-       }
-       return -ENODEV;
 }
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c 
b/src/osmo-bts-trx/sched_lchan_tchf.c
index eff0f63..41153cb 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -99,13 +99,6 @@

        LOGL1SB(DL1P, LOGL_DEBUG, l1ts, bi, "Received TCH/F, bid=%u\n", 
bi->bid);

-       /* allocate burst memory, if not already */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, 928);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       }
-
        /* shift the buffer by 4 bursts leftwards */
        if (bi->bid == 0) {
                memcpy(*bursts_p, *bursts_p + 464, 464);
@@ -483,23 +476,18 @@

        /* send burst, if we already got a frame */
        if (br->bid > 0) {
-               if (!*bursts_p)
+#if 0
+               if (!*bursts_p) // XXX
                        return -ENODEV;
+#endif
                goto send_burst;
        }

        /* BURST BYPASS */

-       /* allocate burst memory, if not already,
-        * otherwise shift buffer by 4 bursts for interleaving */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, 928);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       } else {
-               memcpy(*bursts_p, *bursts_p + 464, 464);
-               memset(*bursts_p + 464, 0, 464);
-       }
+        /* shift buffer by 4 bursts for interleaving */
+       memcpy(*bursts_p, *bursts_p + 464, 464);
+       memset(*bursts_p + 464, 0, 464);

        /* dequeue a message to be transmitted */
        msg = tch_dl_dequeue(l1ts, br);
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c 
b/src/osmo-bts-trx/sched_lchan_tchh.c
index 37fd59d..c722efa 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -122,13 +122,6 @@

        LOGL1SB(DL1P, LOGL_DEBUG, l1ts, bi, "Received TCH/H, bid=%u\n", 
bi->bid);

-       /* allocate burst memory, if not already */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, 696);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       }
-
        /* shift the buffer by 2 bursts leftwards */
        if (bi->bid == 0) {
                memcpy(*bursts_p, *bursts_p + 232, 232);
@@ -384,27 +377,22 @@

        /* send burst, if we already got a frame */
        if (br->bid > 0) {
-               if (!*bursts_p)
+#if 0
+               if (!*bursts_p) // XXX
                        return -ENODEV;
+#endif
                goto send_burst;
        }

        /* BURST BYPASS */

-       /* allocate burst memory, if not already,
-        * otherwise shift buffer by 2 bursts for interleaving */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, 696);
-               if (!*bursts_p)
-                       return -ENOMEM;
+        /* shift buffer by 2 bursts for interleaving */
+       memcpy(*bursts_p, *bursts_p + 232, 232);
+       if (chan_state->dl_ongoing_facch) {
+               memcpy(*bursts_p + 232, *bursts_p + 464, 232);
+               memset(*bursts_p + 464, 0, 232);
        } else {
-               memcpy(*bursts_p, *bursts_p + 232, 232);
-               if (chan_state->dl_ongoing_facch) {
-                       memcpy(*bursts_p + 232, *bursts_p + 464, 232);
-                       memset(*bursts_p + 464, 0, 232);
-               } else {
-                       memset(*bursts_p + 232, 0, 232);
-               }
+               memset(*bursts_p + 232, 0, 232);
        }

        /* dequeue a message to be transmitted */
diff --git a/src/osmo-bts-trx/sched_lchan_xcch.c 
b/src/osmo-bts-trx/sched_lchan_xcch.c
index e936621..ec6163d 100644
--- a/src/osmo-bts-trx/sched_lchan_xcch.c
+++ b/src/osmo-bts-trx/sched_lchan_xcch.c
@@ -69,21 +69,6 @@

        LOGL1SB(DL1P, LOGL_DEBUG, l1ts, bi, "Received Data, bid=%u\n", bi->bid);

-       /* allocate burst memory, if not already */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, 464);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       }
-
-       /* UL-SACCH requires additional memory to keep a copy of each previous
-        * burst set. */
-       if (L1SAP_IS_LINK_SACCH(trx_chan_desc[bi->chan].link_id) && 
!chan_state->ul_bursts_prev) {
-               chan_state->ul_bursts_prev = talloc_zero_size(l1ts, 464);
-               if (!chan_state->ul_bursts_prev)
-                       return -ENOMEM;
-       }
-
        /* clear burst & store frame number of first burst */
        if (bi->bid == 0) {
                memset(*bursts_p, 0, 464);
@@ -175,45 +160,31 @@

        /* send burst, if we already got a frame */
        if (br->bid > 0) {
-               if (!*bursts_p)
+#if 0
+               if (!*bursts_p) // XXX: align to the first burst
                        return -ENODEV;
+#endif
                goto send_burst;
        }

        /* get mac block from queue */
        msg = _sched_dequeue_prim(l1ts, br);
-       if (msg)
-               goto got_msg;
-
-       LOGL1SB(DL1P, LOGL_INFO, l1ts, br, "No prim for transmit.\n");
-
-no_msg:
-       /* free burst memory */
-       if (*bursts_p) {
-               talloc_free(*bursts_p);
-               *bursts_p = NULL;
+       if (msg == NULL) {
+               LOGL1SB(DL1P, LOGL_INFO, l1ts, br, "No prim for transmit.\n");
+               return -ENODEV;
        }
-       return -ENODEV;

-got_msg:
        /* check validity of message */
        if (msgb_l2len(msg) != GSM_MACBLOCK_LEN) {
                LOGL1SB(DL1P, LOGL_FATAL, l1ts, br, "Prim has odd len=%u != 
%u\n",
                        msgb_l2len(msg), GSM_MACBLOCK_LEN);
                /* free message */
                msgb_free(msg);
-               goto no_msg;
+               return -EINVAL;
        }

        /* BURST BYPASS */
 
-       /* allocate burst memory, if not already */
-       if (!*bursts_p) {
-               *bursts_p = talloc_zero_size(l1ts, 464);
-               if (!*bursts_p)
-                       return -ENOMEM;
-       }
-
        /* encode bursts */
        gsm0503_xcch_encode(*bursts_p, msg->l2h);
 

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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I6a5f76023fc492786076a63016f81285b3576c33
Gerrit-Change-Number: 31672
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <[email protected]>
Gerrit-MessageType: newchange

Reply via email to