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


Change subject: osmo-bts-trx: use direct pointer to chan_state->{ul,dl}_bursts
......................................................................

osmo-bts-trx: use direct pointer to chan_state->{ul,dl}_bursts

There is no more need to access the UL/DL buffers via pointer to pointer
thanks to the previous patch [1] moving the memory management routines
out of the logical channel specific Rx/Tx handlers.

Change-Id: Ib1e8e86ac60a7ac9b0415ef66b609eaa33443c19
Related: [1] c45e03726af8a2b46b7166b3c47bc666ba933a69
---
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
4 files changed, 68 insertions(+), 54 deletions(-)



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

diff --git a/src/osmo-bts-trx/sched_lchan_pdtch.c 
b/src/osmo-bts-trx/sched_lchan_pdtch.c
index ddb4478..5ff7229 100644
--- a/src/osmo-bts-trx/sched_lchan_pdtch.c
+++ b/src/osmo-bts-trx/sched_lchan_pdtch.c
@@ -42,7 +42,7 @@
 int rx_pdtch_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
 {
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
-       sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
+       sbit_t *burst, *bursts_p = chan_state->ul_bursts;
        uint32_t first_fn;
        uint8_t *mask = &chan_state->ul_mask;
        struct l1sched_meas_set meas_avg;
@@ -62,7 +62,7 @@

        /* clear burst */
        if (bi->bid == 0) {
-               memset(*bursts_p, 0, GSM0503_EGPRS_BURSTS_NBITS);
+               memset(bursts_p, 0, GSM0503_EGPRS_BURSTS_NBITS);
                *mask = 0x0;
        }

@@ -75,20 +75,20 @@
        /* copy burst to buffer of 4 bursts */
        switch (bi->burst_len) {
        case EGPRS_BURST_LEN:
-               burst = *bursts_p + bi->bid * 348;
+               burst = bursts_p + bi->bid * 348;
                memcpy(burst, bi->burst + 9, 174);
                memcpy(burst + 174, bi->burst + 261, 174);
                n_bursts_bits = GSM0503_EGPRS_BURSTS_NBITS;
                break;
        case GSM_BURST_LEN:
-               burst = *bursts_p + bi->bid * 116;
+               burst = bursts_p + bi->bid * 116;
                memcpy(burst, bi->burst + 3, 58);
                memcpy(burst + 58, bi->burst + 87, 58);
                n_bursts_bits = GSM0503_GPRS_BURSTS_NBITS;
                break;
        case 0:
                /* NOPE.ind, assume GPRS? */
-               burst = *bursts_p + bi->bid * 116;
+               burst = bursts_p + bi->bid * 116;
                memset(burst, 0, 116);
                n_bursts_bits = GSM0503_GPRS_BURSTS_NBITS;
        }
@@ -113,11 +113,11 @@
         * then we incur decoding overhead of 31 bits on the Type 3 EGPRS
         * header, which is tolerable.
         */
-       rc = gsm0503_pdtch_egprs_decode(l2, *bursts_p, n_bursts_bits,
+       rc = gsm0503_pdtch_egprs_decode(l2, bursts_p, n_bursts_bits,
                                NULL, &n_errors, &n_bits_total);

        if ((bi->burst_len == GSM_BURST_LEN) && (rc < 0)) {
-               rc = gsm0503_pdtch_decode(l2, *bursts_p, NULL,
+               rc = gsm0503_pdtch_decode(l2, bursts_p, NULL,
                                  &n_errors, &n_bits_total);
        }

@@ -144,7 +144,7 @@
 int tx_pdtch_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
 {
        struct msgb *msg = NULL; /* make GCC happy */
-       ubit_t *burst, **bursts_p = &l1ts->chan_state[br->chan].dl_bursts;
+       ubit_t *burst, *bursts_p = l1ts->chan_state[br->chan].dl_bursts;
        enum trx_mod_type *mod = &l1ts->chan_state[br->chan].dl_mod_type;
        int rc = 0;

@@ -166,9 +166,9 @@
        /* BURST BYPASS */

        /* encode bursts */
-       rc = gsm0503_pdtch_egprs_encode(*bursts_p, msg->l2h, msg->tail - 
msg->l2h);
+       rc = gsm0503_pdtch_egprs_encode(bursts_p, msg->l2h, msg->tail - 
msg->l2h);
        if (rc < 0)
-               rc = gsm0503_pdtch_encode(*bursts_p, msg->l2h, msg->tail - 
msg->l2h);
+               rc = gsm0503_pdtch_encode(bursts_p, msg->l2h, msg->tail - 
msg->l2h);

        /* check validity of message */
        if (rc < 0) {
@@ -189,7 +189,7 @@
 send_burst:
        /* compose burst */
        if (*mod == TRX_MOD_T_8PSK) {
-               burst = *bursts_p + br->bid * 348;
+               burst = bursts_p + br->bid * 348;
                memset(br->burst, 1, 9);
                memcpy(br->burst + 9, burst, 174);
                memcpy(br->burst + 183, TRX_8PSK_NB_TSC(br), 78);
@@ -198,7 +198,7 @@

                br->burst_len = EGPRS_BURST_LEN;
        } else {
-               burst = *bursts_p + br->bid * 116;
+               burst = bursts_p + br->bid * 116;
                memcpy(br->burst + 3, burst, 58);
                memcpy(br->burst + 61, TRX_GMSK_NB_TSC(br), 26);
                memcpy(br->burst + 87, burst + 58, 58);
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c 
b/src/osmo-bts-trx/sched_lchan_tchf.c
index 823f410..6dfdff8 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -75,7 +75,7 @@
 {
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
        struct gsm_lchan *lchan = chan_state->lchan;
-       sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
+       sbit_t *burst, *bursts_p = chan_state->ul_bursts;
        uint8_t *mask = &chan_state->ul_mask;
        uint8_t rsl_cmode = chan_state->rsl_cmode;
        uint8_t tch_mode = chan_state->tch_mode;
@@ -101,8 +101,8 @@

        /* shift the buffer by 4 bursts leftwards */
        if (bi->bid == 0) {
-               memcpy(*bursts_p, *bursts_p + 464, 464);
-               memset(*bursts_p + 464, 0, 464);
+               memcpy(bursts_p, bursts_p + 464, 464);
+               memset(bursts_p + 464, 0, 464);
                *mask = *mask << 4;
        }

@@ -113,7 +113,7 @@
        trx_sched_meas_push(chan_state, bi);

        /* copy burst to end of buffer of 8 bursts */
-       burst = *bursts_p + bi->bid * 116 + 464;
+       burst = bursts_p + bi->bid * 116 + 464;
        if (bi->burst_len > 0) {
                memcpy(burst, bi->burst + 3, 58);
                memcpy(burst + 58, bi->burst + 87, 58);
@@ -137,12 +137,12 @@
        switch (tch_mode) {
        case GSM48_CMODE_SIGN:
        case GSM48_CMODE_SPEECH_V1: /* FR */
-               rc = gsm0503_tch_fr_decode(tch_data, *bursts_p, 1, 0, 
&n_errors, &n_bits_total);
+               rc = gsm0503_tch_fr_decode(tch_data, bursts_p, 1, 0, &n_errors, 
&n_bits_total);
                if (rc == GSM_FR_BYTES) /* only for valid *speech* frames */
                        lchan_set_marker(osmo_fr_is_any_sid(tch_data), lchan); 
/* DTXu */
                break;
        case GSM48_CMODE_SPEECH_EFR: /* EFR */
-               rc = gsm0503_tch_fr_decode(tch_data, *bursts_p, 1, 1, 
&n_errors, &n_bits_total);
+               rc = gsm0503_tch_fr_decode(tch_data, bursts_p, 1, 1, &n_errors, 
&n_bits_total);
                if (rc == GSM_EFR_BYTES) /* only for valid *speech* frames */
                        lchan_set_marker(osmo_efr_is_any_sid(tch_data), lchan); 
/* DTXu */
                break;
@@ -168,7 +168,7 @@
                 * we receive an FACCH frame instead of a voice frame (we
                 * do not know this before we actually decode the frame) */
                amr = sizeof(struct amr_hdr);
-               rc = gsm0503_tch_afs_decode_dtx(tch_data + amr, *bursts_p,
+               rc = gsm0503_tch_afs_decode_dtx(tch_data + amr, bursts_p,
                        amr_is_cmr, chan_state->codec, chan_state->codecs, 
&chan_state->ul_ft,
                        &chan_state->ul_cmr, &n_errors, &n_bits_total, 
&chan_state->amr_last_dtx);

@@ -473,7 +473,7 @@
 {
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
        uint8_t tch_mode = chan_state->tch_mode;
-       ubit_t *burst, **bursts_p = &chan_state->dl_bursts;
+       ubit_t *burst, *bursts_p = chan_state->dl_bursts;
        struct msgb *msg;

        /* send burst, if we already got a frame */
@@ -483,8 +483,8 @@
        /* BURST BYPASS */

         /* shift buffer by 4 bursts for interleaving */
-       memcpy(*bursts_p, *bursts_p + 464, 464);
-       memset(*bursts_p + 464, 0, 464);
+       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);
@@ -498,27 +498,27 @@
                };

                LOGL1SB(DL1P, LOGL_DEBUG, l1ts, br, "No TCH or FACCH prim for 
transmit.\n");
-               gsm0503_tch_fr_encode(*bursts_p, dummy, sizeof(dummy), 1);
+               gsm0503_tch_fr_encode(bursts_p, dummy, sizeof(dummy), 1);
                chan_state->dl_facch_bursts = 8;
                goto send_burst;
        }

        /* populate the buffer with bursts */
        if (msgb_l2len(msg) == GSM_MACBLOCK_LEN) {
-               gsm0503_tch_fr_encode(*bursts_p, msg->l2h, msgb_l2len(msg), 1);
+               gsm0503_tch_fr_encode(bursts_p, msg->l2h, msgb_l2len(msg), 1);
                chan_state->dl_facch_bursts = 8;
        } else if (tch_mode == GSM48_CMODE_SPEECH_AMR) {
                /* the first FN 4,13,21 defines that CMI is included in frame,
                 * the first FN 0,8,17 defines that CMR is included in frame.
                 */
-               gsm0503_tch_afs_encode(*bursts_p, msg->l2h + sizeof(struct 
amr_hdr),
+               gsm0503_tch_afs_encode(bursts_p, msg->l2h + sizeof(struct 
amr_hdr),
                        msgb_l2len(msg) - sizeof(struct amr_hdr),
                        !sched_tchf_dl_amr_cmi_map[br->fn % 26],
                        chan_state->codec, chan_state->codecs,
                        chan_state->dl_ft,
                        chan_state->dl_cmr);
        } else {
-               gsm0503_tch_fr_encode(*bursts_p, msg->l2h, msgb_l2len(msg), 1);
+               gsm0503_tch_fr_encode(bursts_p, msg->l2h, msgb_l2len(msg), 1);
        }

        /* free message */
@@ -526,7 +526,7 @@

 send_burst:
        /* compose burst */
-       burst = *bursts_p + br->bid * 116;
+       burst = bursts_p + br->bid * 116;
        memcpy(br->burst + 3, burst, 58);
        memcpy(br->burst + 61, TRX_GMSK_NB_TSC(br), 26);
        memcpy(br->burst + 87, burst + 58, 58);
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c 
b/src/osmo-bts-trx/sched_lchan_tchh.c
index 068351a..94e2a9c 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -97,7 +97,7 @@
 {
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
        struct gsm_lchan *lchan = chan_state->lchan;
-       sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
+       sbit_t *burst, *bursts_p = chan_state->ul_bursts;
        uint8_t *mask = &chan_state->ul_mask;
        uint8_t rsl_cmode = chan_state->rsl_cmode;
        uint8_t tch_mode = chan_state->tch_mode;
@@ -124,9 +124,9 @@

        /* shift the buffer by 2 bursts leftwards */
        if (bi->bid == 0) {
-               memcpy(*bursts_p, *bursts_p + 232, 232);
-               memcpy(*bursts_p + 232, *bursts_p + 464, 232);
-               memset(*bursts_p + 464, 0, 232);
+               memcpy(bursts_p, bursts_p + 232, 232);
+               memcpy(bursts_p + 232, bursts_p + 464, 232);
+               memset(bursts_p + 464, 0, 232);
                *mask = *mask << 2;
        }

@@ -137,7 +137,7 @@
        trx_sched_meas_push(chan_state, bi);

        /* copy burst to end of buffer of 6 bursts */
-       burst = *bursts_p + bi->bid * 116 + 464;
+       burst = bursts_p + bi->bid * 116 + 464;
        if (bi->burst_len > 0) {
                memcpy(burst, bi->burst + 3, 58);
                memcpy(burst + 58, bi->burst + 87, 58);
@@ -174,7 +174,7 @@
                meas_avg_mode = SCHED_MEAS_AVG_M_S6N6;
                /* fall-through */
        case GSM48_CMODE_SPEECH_V1: /* HR or signalling */
-               rc = gsm0503_tch_hr_decode(tch_data, *bursts_p,
+               rc = gsm0503_tch_hr_decode(tch_data, bursts_p,
                                           !sched_tchh_ul_facch_map[bi->fn % 
26],
                                           &n_errors, &n_bits_total);
                if (rc == GSM_HR_BYTES_RTP_RFC5993) { /* only for valid 
*speech* frames */
@@ -204,7 +204,7 @@

                /* See comment in function rx_tchf_fn() */
                amr = sizeof(struct amr_hdr);
-               rc = gsm0503_tch_ahs_decode_dtx(tch_data + amr, *bursts_p,
+               rc = gsm0503_tch_ahs_decode_dtx(tch_data + amr, bursts_p,
                                                !sched_tchh_ul_facch_map[bi->fn 
% 26],
                                                !fn_is_cmi, chan_state->codec,
                                                chan_state->codecs, 
&chan_state->ul_ft,
@@ -372,7 +372,7 @@
 {
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
        uint8_t tch_mode = chan_state->tch_mode;
-       ubit_t *burst, **bursts_p = &chan_state->dl_bursts;
+       ubit_t *burst, *bursts_p = chan_state->dl_bursts;
        struct msgb *msg;

        /* send burst, if we already got a frame */
@@ -382,12 +382,12 @@
        /* BURST BYPASS */

         /* shift buffer by 2 bursts for interleaving */
-       memcpy(*bursts_p, *bursts_p + 232, 232);
+       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);
+               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 */
@@ -418,7 +418,7 @@
                        goto send_burst;
                }

-               gsm0503_tch_hr_encode(*bursts_p, dummy, sizeof(dummy));
+               gsm0503_tch_hr_encode(bursts_p, dummy, sizeof(dummy));
                chan_state->dl_ongoing_facch = 1;
                chan_state->dl_facch_bursts = 6;
                goto send_burst;
@@ -426,21 +426,21 @@

        /* populate the buffer with bursts */
        if (msgb_l2len(msg) == GSM_MACBLOCK_LEN) {
-               gsm0503_tch_hr_encode(*bursts_p, msg->l2h, msgb_l2len(msg));
+               gsm0503_tch_hr_encode(bursts_p, msg->l2h, msgb_l2len(msg));
                chan_state->dl_ongoing_facch = 1; /* first of two TCH frames */
                chan_state->dl_facch_bursts = 6;
        } else if (tch_mode == GSM48_CMODE_SPEECH_AMR) {
                /* the first FN 4,13,21 or 5,14,22 defines that CMI is included
                 * in frame, the first FN 0,8,17 or 1,9,18 defines that CMR is
                 * included in frame. */
-               gsm0503_tch_ahs_encode(*bursts_p, msg->l2h + sizeof(struct 
amr_hdr),
+               gsm0503_tch_ahs_encode(bursts_p, msg->l2h + sizeof(struct 
amr_hdr),
                        msgb_l2len(msg) - sizeof(struct amr_hdr),
                        !sched_tchh_dl_amr_cmi_map[br->fn % 26],
                        chan_state->codec, chan_state->codecs,
                        chan_state->dl_ft,
                        chan_state->dl_cmr);
        } else {
-               gsm0503_tch_hr_encode(*bursts_p, msg->l2h, msgb_l2len(msg));
+               gsm0503_tch_hr_encode(bursts_p, msg->l2h, msgb_l2len(msg));
        }

        /* free message */
@@ -448,7 +448,7 @@

 send_burst:
        /* compose burst */
-       burst = *bursts_p + br->bid * 116;
+       burst = bursts_p + br->bid * 116;
        memcpy(br->burst + 3, burst, 58);
        memcpy(br->burst + 61, TRX_GMSK_NB_TSC(br), 26);
        memcpy(br->burst + 87, burst + 58, 58);
diff --git a/src/osmo-bts-trx/sched_lchan_xcch.c 
b/src/osmo-bts-trx/sched_lchan_xcch.c
index 786b509..1945d32 100644
--- a/src/osmo-bts-trx/sched_lchan_xcch.c
+++ b/src/osmo-bts-trx/sched_lchan_xcch.c
@@ -50,7 +50,7 @@
 int rx_data_fn(struct l1sched_ts *l1ts, const struct trx_ul_burst_ind *bi)
 {
        struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
-       sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
+       sbit_t *burst, *bursts_p = chan_state->ul_bursts;
        uint32_t *first_fn = &chan_state->ul_first_fn;
        uint8_t *mask = &chan_state->ul_mask;
        uint8_t l2[GSM_MACBLOCK_LEN], l2_len;
@@ -71,7 +71,7 @@

        /* clear burst & store frame number of first burst */
        if (bi->bid == 0) {
-               memset(*bursts_p, 0, 464);
+               memset(bursts_p, 0, 464);
                *mask = 0x0;
                *first_fn = bi->fn;
        }
@@ -84,7 +84,7 @@

        /* Copy burst to buffer of 4 bursts. If the burst indication contains
         * no data, ensure that the buffer does not stay uninitialized */
-       burst = *bursts_p + bi->bid * 116;
+       burst = bursts_p + bi->bid * 116;
        if (bi->burst_len > 0) {
                memcpy(burst, bi->burst + 3, 58);
                memcpy(burst + 58, bi->burst + 87, 58);
@@ -112,7 +112,7 @@
        *mask = 0x0;

        /* decode */
-       rc = gsm0503_xcch_decode(l2, *bursts_p, &n_errors, &n_bits_total);
+       rc = gsm0503_xcch_decode(l2, bursts_p, &n_errors, &n_bits_total);
        if (rc) {
                LOGL1SB(DL1P, LOGL_NOTICE, l1ts, bi, "Received bad data 
(%u/%u)\n",
                        bi->fn % l1ts->mf_period, l1ts->mf_period);
@@ -123,8 +123,8 @@
                 * information from the previous SACCH block. See also:
                 * 3GPP TS 44.006, section 11.2 */
                if (rep_sacch) {
-                       add_sbits(*bursts_p, chan_state->ul_bursts_prev);
-                       rc = gsm0503_xcch_decode(l2, *bursts_p, &n_errors, 
&n_bits_total);
+                       add_sbits(bursts_p, chan_state->ul_bursts_prev);
+                       rc = gsm0503_xcch_decode(l2, bursts_p, &n_errors, 
&n_bits_total);
                        if (rc) {
                                LOGL1SB(DL1P, LOGL_NOTICE, l1ts, bi,
                                       "Combining current SACCH block with 
previous SACCH block also yields bad data (%u/%u)\n",
@@ -143,7 +143,7 @@

        /* Keep a copy to ease decoding in the next repetition pass */
        if (rep_sacch)
-               memcpy(chan_state->ul_bursts_prev, *bursts_p, 464);
+               memcpy(chan_state->ul_bursts_prev, bursts_p, 464);

        return _sched_compose_ph_data_ind(l1ts, *first_fn,
                                          bi->chan, l2, l2_len,
@@ -156,7 +156,7 @@
 int tx_data_fn(struct l1sched_ts *l1ts, struct trx_dl_burst_req *br)
 {
        struct msgb *msg = NULL; /* make GCC happy */
-       ubit_t *burst, **bursts_p = &l1ts->chan_state[br->chan].dl_bursts;
+       ubit_t *burst, *bursts_p = l1ts->chan_state[br->chan].dl_bursts;

        /* send burst, if we already got a frame */
        if (br->bid > 0)
@@ -181,14 +181,14 @@
        /* BURST BYPASS */

        /* encode bursts */
-       gsm0503_xcch_encode(*bursts_p, msg->l2h);
+       gsm0503_xcch_encode(bursts_p, msg->l2h);

        /* free message */
        msgb_free(msg);

 send_burst:
        /* compose burst */
-       burst = *bursts_p + br->bid * 116;
+       burst = bursts_p + br->bid * 116;
        memcpy(br->burst + 3, burst, 58);
        memcpy(br->burst + 61, TRX_GMSK_NB_TSC(br), 26);
        memcpy(br->burst + 87, burst + 58, 58);

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

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

Reply via email to