Move GPRS_RLCMAC_FLAG_DL_ACK from state_fsm to dl_tbf
That flag was still in state_fsm for historical reasons (refactoring
steps), but it's not really the best place for it, since it's really
specific to dl_tbf and to transmit of data and DL ACK/NACK not the
overall state of the TBF.
Change-Id: I12c28c1a52f363f2d17a8bc24bbdf379543fc7a6
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 8981615..279efcd 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -885,7 +885,7 @@
OSMO_STRBUF_PRINTF(sb, "Assignment was on CCCH|");
if (dl_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))
OSMO_STRBUF_PRINTF(sb, "Assignment was on PACCH|");
- if (dl_tbf->state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_DL_ACK))
+ if (dl_tbf->m_first_dl_ack_rcvd)
OSMO_STRBUF_PRINTF(sb, "Downlink ACK was received|");
else
OSMO_STRBUF_PRINTF(sb, "No downlink ACK received yet|");
diff --git a/src/tbf.h b/src/tbf.h
index 941e350..124a2e6 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -109,7 +109,6 @@
#define GPRS_RLCMAC_FLAG_CCCH 0 /* assignment on CCCH */
#define GPRS_RLCMAC_FLAG_PACCH 1 /* assignment on PACCH */
-#define GPRS_RLCMAC_FLAG_DL_ACK 2 /* DL TBF: At least one DL ACK/NACK was recieved since it was assigned */
#define TBF_TFI_UNSET 0xff
#define T_START(tbf, t, T, r, f) tbf->t_start(t, T, r, f, __FILE__, __LINE__)
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 170ed25..17d2934 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -164,6 +164,7 @@
m_last_dl_poll_fn(-1),
m_last_dl_poll_ack_lost(false),
m_last_dl_drained_fn(-1),
+ m_first_dl_ack_rcvd(false),
m_dl_gprs_ctrs(NULL),
m_dl_egprs_ctrs(NULL)
{
@@ -1080,7 +1081,7 @@
int rc;
LOGPTBFDL(this, LOGL_DEBUG, "downlink acknowledge\n");
- state_fsm.state_flags |= (1 << GPRS_RLCMAC_FLAG_DL_ACK);
+ m_first_dl_ack_rcvd = true;
m_last_dl_poll_ack_lost = false;
/* reset N3105 */
@@ -1114,6 +1115,11 @@
dl_tbf->request_dl_ack();
}
+bool dl_tbf_first_dl_ack_rcvd(const struct gprs_rlcmac_dl_tbf *tbf)
+{
+ return tbf->m_first_dl_ack_rcvd;
+}
+
/* Does this DL TBF require to poll the MS for DL ACK/NACK? */
bool gprs_rlcmac_dl_tbf::need_poll_for_dl_ack_nack() const
{
diff --git a/src/tbf_dl.h b/src/tbf_dl.h
index ec75e32..dabe9a9 100644
--- a/src/tbf_dl.h
+++ b/src/tbf_dl.h
@@ -75,6 +75,8 @@
* MS polled during DL ACK/NACK with RRBP set in "m_last_dl_poll_fn": */
bool m_last_dl_poll_ack_lost;
int32_t m_last_dl_drained_fn;
+ /* Whether we receive at least one PKT DL ACK/NACK from MS since this DL TBF was assigned: */
+ bool m_first_dl_ack_rcvd;
struct BandWidth {
struct timespec dl_bw_tv; /* timestamp for dl bw calculation */
@@ -156,6 +158,7 @@
void dl_tbf_trigger_ass_on_pacch(struct gprs_rlcmac_dl_tbf *tbf, struct gprs_rlcmac_tbf *old_tbf);
void dl_tbf_trigger_ass_on_pch(struct gprs_rlcmac_dl_tbf *tbf);
void dl_tbf_request_dl_ack(struct gprs_rlcmac_dl_tbf *tbf);
+bool dl_tbf_first_dl_ack_rcvd(const struct gprs_rlcmac_dl_tbf *tbf);
int dl_tbf_upgrade_to_multislot(struct gprs_rlcmac_dl_tbf *tbf);
static inline struct gprs_rlcmac_tbf *dl_tbf_as_tbf(struct gprs_rlcmac_dl_tbf *dl_tbf)
diff --git a/src/tbf_dl_fsm.c b/src/tbf_dl_fsm.c
index 6c3f4f1..ce9bee3 100644
--- a/src/tbf_dl_fsm.c
+++ b/src/tbf_dl_fsm.c
@@ -208,8 +208,8 @@
* don't even know if the MS successfully received the Imm Ass on
* CCCH and hence is listening on PDCH. Let's better refrain
* from continuing and start assignment on CCCH again */
- if ((ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
- && !(ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_DL_ACK))) {
+ if ((ctx->state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH)) &&
+ !dl_tbf_first_dl_ack_rcvd(ctx->dl_tbf)) {
struct GprsMs *ms = tbf_ms(ctx->tbf);
LOGPTBFDL(ctx->dl_tbf, LOGL_DEBUG,
"Re-send downlink assignment on PCH (IMSI=%s)\n",