aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-23 20:16:23 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:23:57 +0100
commit8dacdd87a363a5bc6f980bca6920682da2e0b0c4 (patch)
tree3fb2f820b8f904876a9e3bd05db3ac69cde44a3c
parentd372c393e57897dab5f33eca3f064b6d57ae1dd3 (diff)
TBF: make UL ack state internal
* add functions/macros for setting TBF's UL ack state * add functions for checking TBF's UL ack state N. B: this should not be confused with TBF-UL state. Change-Id: I144483447d4b0b93e775da0e926ee45eb8ab39f3 Related: OS#1539
-rw-r--r--src/gprs_rlcmac_sched.cpp2
-rw-r--r--src/tbf.cpp9
-rw-r--r--src/tbf.h22
-rw-r--r--src/tbf_ul.cpp12
-rw-r--r--tests/tbf/TbfTest.cpp6
5 files changed, 38 insertions, 13 deletions
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index a87217f..3f9fcb1 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -52,7 +52,7 @@ static uint32_t sched_poll(BTS *bts,
if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
&& ul_tbf->poll_fn == poll_fn)
*poll_tbf = ul_tbf;
- if (ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_SEND_ACK)
+ if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
*ul_ack_tbf = ul_tbf;
if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
*dl_ass_tbf = ul_tbf;
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 0cb54bc..b99c521 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -60,6 +60,13 @@ const struct value_string gprs_rlcmac_tbf_ul_ass_state_names[] = {
{ 0, NULL }
};
+const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[] = {
+ OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_NONE),
+ OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_SEND_ACK), /* send acknowledge on next RTS */
+ OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_WAIT_ACK), /* wait for PACKET CONTROL ACK */
+ { 0, NULL }
+};
+
static const struct value_string tbf_timers_names[] = {
OSMO_VALUE_STRING(T0),
OSMO_VALUE_STRING(T3169),
@@ -165,7 +172,6 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
first_ts(0),
first_common_ts(0),
control_ts(0xff),
- ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
poll_state(GPRS_RLCMAC_POLL_NONE),
poll_fn(0),
poll_ts(0),
@@ -185,6 +191,7 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
state(GPRS_RLCMAC_NULL),
dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE),
ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE),
+ ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
m_list(this),
m_ms_list(this),
m_egprs_enabled(false)
diff --git a/src/tbf.h b/src/tbf.h
index 2d51945..2828772 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -87,6 +87,8 @@ enum gprs_rlcmac_tbf_ul_ack_state {
GPRS_RLCMAC_UL_ACK_WAIT_ACK, /* wait for PACKET CONTROL ACK */
};
+extern const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[];
+
enum gprs_rlcmac_tbf_direction {
GPRS_RLCMAC_DL_TBF,
GPRS_RLCMAC_UL_TBF
@@ -183,6 +185,7 @@ enum tbf_timers {
#define TBF_SET_STATE(t, st) do { t->set_state(st, __FILE__, __LINE__); } while(0)
#define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, __LINE__); } while(0)
#define TBF_SET_ASS_STATE_UL(t, st) do { t->set_ass_state_ul(st, __FILE__, __LINE__); } while(0)
+#define TBF_SET_ACK_STATE(t, st) do { t->set_ack_state(st, __FILE__, __LINE__); } while(0)
#define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, __LINE__); } while(0)
struct gprs_rlcmac_tbf {
@@ -195,9 +198,11 @@ struct gprs_rlcmac_tbf {
bool state_is_not(enum gprs_rlcmac_tbf_state rhs) const;
bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const;
bool ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const;
+ bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const;
void set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line);
void set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, const char *file, int line);
void set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line);
+ void set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line);
void check_pending_ass();
bool check_n_clear(uint8_t state_flag);
void set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line);
@@ -279,8 +284,6 @@ struct gprs_rlcmac_tbf {
gprs_llc m_llc;
- enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
-
enum gprs_rlcmac_tbf_poll_state poll_state;
uint32_t poll_fn; /* frame number to poll */
uint8_t poll_ts; /* TS to poll */
@@ -343,6 +346,7 @@ private:
enum gprs_rlcmac_tbf_state state;
enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state;
enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
+ enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
LListHead<gprs_rlcmac_tbf> m_list;
LListHead<gprs_rlcmac_tbf> m_ms_list;
bool m_egprs_enabled;
@@ -385,6 +389,11 @@ inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state r
return ul_ass_state == rhs;
}
+inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const
+{
+ return ul_ack_state == rhs;
+}
+
inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const
{
return state != rhs;
@@ -434,6 +443,15 @@ inline void gprs_rlcmac_tbf::set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state
ul_ass_state = new_state;
}
+inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line)
+{
+ LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ACK state from %s to %s\n",
+ tbf_name(this),
+ get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, ul_ack_state),
+ get_value_string(gprs_rlcmac_tbf_ul_ack_state_names, new_state));
+ ul_ack_state = new_state;
+}
+
inline void gprs_rlcmac_tbf::check_pending_ass()
{
if (ul_ass_state != GPRS_RLCMAC_UL_ASS_NONE)
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index ba048e5..c1a3388 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -106,8 +106,8 @@ bool gprs_rlcmac_ul_tbf::ctrl_ack_to_toggle()
bool gprs_rlcmac_ul_tbf::handle_ctrl_ack()
{
/* check if this control ack belongs to packet uplink ack */
- if (ul_ack_state == GPRS_RLCMAC_UL_ACK_WAIT_ACK) {
- ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE;
+ if (ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) {
+ TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_NONE);
return true;
}
@@ -124,7 +124,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts)
if (final) {
if (poll_state == GPRS_RLCMAC_POLL_SCHED &&
- ul_ack_state == GPRS_RLCMAC_UL_ACK_WAIT_ACK) {
+ ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) {
LOGPTBFUL(this, LOGL_DEBUG,
"Polling is already scheduled, so we must wait for the final uplink ack...\n");
return NULL;
@@ -158,7 +158,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts)
/* waiting for final acknowledge */
m_final_ack_sent = 1;
} else
- ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE;
+ TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_NONE);
return msg;
}
@@ -362,9 +362,9 @@ void gprs_rlcmac_ul_tbf::maybe_schedule_uplink_acknack(
"Scheduling Ack/Nack, because %d frames received.\n",
SEND_ACK_AFTER_FRAMES);
}
- if (ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE) {
+ if (ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE)) {
/* trigger sending at next RTS */
- ul_ack_state = GPRS_RLCMAC_UL_ACK_SEND_ACK;
+ TBF_SET_ACK_STATE(this, GPRS_RLCMAC_UL_ACK_SEND_ACK);
} else {
/* already triggered */
LOGPTBFUL(this, LOGL_DEBUG,
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index 968f9eb..0ac519c 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -1350,7 +1350,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_no_length(BTS *t
request_dl_rlc_block(ul_tbf, fn);
check_tbf(ul_tbf);
- OSMO_ASSERT(ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE);
+ OSMO_ASSERT(ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE));
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
@@ -1434,7 +1434,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_URBB_with_length(BTS
request_dl_rlc_block(ul_tbf, fn);
check_tbf(ul_tbf);
- OSMO_ASSERT(ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE);
+ OSMO_ASSERT(ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE));
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);
@@ -1522,7 +1522,7 @@ static gprs_rlcmac_ul_tbf *establish_ul_tbf_two_phase_puan_CRBB(BTS *the_bts,
request_dl_rlc_block(ul_tbf, fn);
check_tbf(ul_tbf);
- OSMO_ASSERT(ul_tbf->ul_ack_state == GPRS_RLCMAC_UL_ACK_NONE);
+ OSMO_ASSERT(ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_NONE));
ms = the_bts->ms_by_tlli(tlli);
OSMO_ASSERT(ms != NULL);