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

Remove TBF knowledge from rcv_control*dl_ack_nack

Do not access TBF internals directly from rcv_control*dl_ack_nack() -
wrap corresponding code into TBF-DL method.

Change-Id: I3d1b5782001e45617b4a960612fcfc249904b37c
Related: OS#1539
---
M src/bts.cpp
M src/tbf.h
M src/tbf_dl.cpp
3 files changed, 34 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/54/3154/1

diff --git a/src/bts.cpp b/src/bts.cpp
index e66699f..9847e9b 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1175,17 +1175,11 @@
                        "wrong TFI=%d, ignoring!\n", tfi);
                return;
        }
-       tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_DL_ACK);
-       if ((tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK))) {
-               tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK);
-               LOGP(DRLCMAC, LOGL_NOTICE, "Recovered downlink ack "
-                       "for %s\n", tbf_name(tbf));
-       }
-       /* reset N3105 */
-       tbf->n3105 = 0;
-       tbf->stop_t3191();
+
+       if (tbf->handle_ack_nack())
+               LOGP(DRLCMAC, LOGL_NOTICE, "Recovered downlink ack for %s\n", 
tbf_name(tbf));
+
        LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] %s Packet Downlink 
Ack/Nack\n", tbf_name(tbf));
-       tbf->poll_state = GPRS_RLCMAC_POLL_NONE;
 
        bits.data = bits_data;
        bits.data_len = sizeof(bits_data);
@@ -1263,19 +1257,13 @@
                        "wrong TFI=%d, ignoring!\n", tfi);
                return;
        }
-       tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_DL_ACK);
-       if ((tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK))) {
-               tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK);
-               LOGP(DRLCMAC, LOGL_NOTICE, "Recovered EGPRS downlink ack "
-                       "for %s\n", tbf_name(tbf));
-       }
-       /* reset N3105 */
-       tbf->n3105 = 0;
-       tbf->stop_t3191();
+
+       if (tbf->handle_ack_nack())
+               LOGP(DRLCMAC, LOGL_NOTICE, "Recovered EGPRS downlink ack for 
%s\n", tbf_name(tbf));
+
        LOGP(DRLCMAC, LOGL_DEBUG,
                "RX: [PCU <- BTS] %s EGPRS Packet Downlink Ack/Nack\n",
                tbf_name(tbf));
-       tbf->poll_state = GPRS_RLCMAC_POLL_NONE;
 
        LOGP(DRLCMAC, LOGL_DEBUG, "EGPRS ACK/NACK: "
                "ut: %d, final: %d, bow: %d, eow: %d, ssn: %d, have_crbb: %d, "
diff --git a/src/tbf.h b/src/tbf.h
index ee9648a..64cfa91 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -423,6 +423,8 @@
        int rcvd_dl_ack(uint8_t final, uint8_t ssn, uint8_t *rbb);
        int rcvd_dl_ack(uint8_t final_ack, unsigned first_bsn, struct bitvec 
*rbb);
        struct msgb *create_dl_acked_block(uint32_t fn, uint8_t ts);
+       void clear_poll_timeout_flag();
+       bool handle_ack_nack();
        void request_dl_ack();
        bool need_control_ts() const;
        bool have_data() const;
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 24c6385..a894789 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -609,6 +609,29 @@
        return bsn;
 }
 
+void gprs_rlcmac_dl_tbf::clear_poll_timeout_flag()
+{
+       state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK);
+}
+
+bool gprs_rlcmac_dl_tbf::handle_ack_nack()
+{
+       bool ack_recovered = false;
+
+       state_flags |= (1 << GPRS_RLCMAC_FLAG_DL_ACK);
+       if ((state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK))) {
+               clear_poll_timeout_flag();
+               ack_recovered = true;
+       }
+
+       /* reset N3105 */
+       n3105 = 0;
+       stop_t3191();
+       poll_state = GPRS_RLCMAC_POLL_NONE;
+
+       return ack_recovered;
+}
+
 struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
                                const uint32_t fn, const uint8_t ts,
                                int index, int index2)
@@ -807,8 +830,7 @@
                        if (is_final)
                                tbf_timer_start(this, 3191, bts_data()->t3191, 
0);
 
-                       /* Clear poll timeout flag */
-                       state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK);
+                       clear_poll_timeout_flag();
 
                        /* Clear request flag */
                        m_dl_ack_requested = false;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d1b5782001e45617b4a960612fcfc249904b37c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <[email protected]>

Reply via email to