aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-24 11:00:17 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-27 22:23:57 +0100
commitc4640ca6df25c150baf65c917956efb8a4ee460e (patch)
treec4f8b729619f60375b6ea320db14a0cb8cb009e8
parent8dacdd87a363a5bc6f980bca6920682da2e0b0c4 (diff)
TBF: make poll state internal
* add functions/macros for setting TBF's poll state * add function for checking TBF's poll state Change-Id: I6db1c4e7bd0a49aeb5e391afe371c36b96c6a702 Related: OS#1539
-rw-r--r--src/bts.cpp4
-rw-r--r--src/gprs_rlcmac_sched.cpp6
-rw-r--r--src/poll_controller.cpp4
-rw-r--r--src/tbf.cpp8
-rw-r--r--src/tbf.h28
-rw-r--r--src/tbf_dl.cpp4
-rw-r--r--src/tbf_ul.cpp3
7 files changed, 43 insertions, 14 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index f614c1a..94354f2 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -399,7 +399,7 @@ void BTS::send_gsmtap(enum pcu_gsmtap_category categ, bool uplink, uint8_t trx_n
static inline bool tbf_check(gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t trx_no, uint8_t ts)
{
- if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) && tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
+ if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) && tbf->poll_scheduled()
&& tbf->poll_fn == fn && tbf->trx->trx_no == trx_no && tbf->poll_ts == ts)
return true;
@@ -1010,7 +1010,7 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] Packet Control Ack\n");
- tbf->poll_state = GPRS_RLCMAC_POLL_NONE;
+ TBF_POLL_SCHED_UNSET(tbf);
/* check if this control ack belongs to packet uplink ack */
ul_tbf = as_ul_tbf(tbf);
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 3f9fcb1..ebf4714 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -49,8 +49,7 @@ static uint32_t sched_poll(BTS *bts,
if (ul_tbf->trx->trx_no != trx || !ul_tbf->is_control_ts(ts))
continue;
/* polling for next uplink block */
- if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
- && ul_tbf->poll_fn == poll_fn)
+ if (ul_tbf->poll_scheduled() && ul_tbf->poll_fn == poll_fn)
*poll_tbf = ul_tbf;
if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
*ul_ack_tbf = ul_tbf;
@@ -69,8 +68,7 @@ states? */
if (dl_tbf->trx->trx_no != trx || !dl_tbf->is_control_ts(ts))
continue;
/* polling for next uplink block */
- if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
- && dl_tbf->poll_fn == poll_fn)
+ if (dl_tbf->poll_scheduled() && dl_tbf->poll_fn == poll_fn)
*poll_tbf = dl_tbf;
if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
*dl_ass_tbf = dl_tbf;
diff --git a/src/poll_controller.cpp b/src/poll_controller.cpp
index f8ab6c9..5c5a717 100644
--- a/src/poll_controller.cpp
+++ b/src/poll_controller.cpp
@@ -47,14 +47,14 @@ void PollController::expireTimedout(int frame_number, unsigned max_delay)
llist_for_each(pos, &m_bts.ul_tbfs()) {
ul_tbf = as_ul_tbf(pos->entry());
- if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
+ if (ul_tbf->poll_scheduled()) {
if (elapsed_fn_check(max_delay, frame_number, ul_tbf->poll_fn))
ul_tbf->poll_timeout();
}
}
llist_for_each(pos, &m_bts.dl_tbfs()) {
dl_tbf = as_dl_tbf(pos->entry());
- if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
+ if (dl_tbf->poll_scheduled()) {
if (elapsed_fn_check(max_delay, frame_number, dl_tbf->poll_fn))
dl_tbf->poll_timeout();
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index b99c521..672c296 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -45,6 +45,12 @@ extern void *tall_pcu_ctx;
static void tbf_timer_cb(void *_tbf);
+const struct value_string gprs_rlcmac_tbf_poll_state_names[] = {
+ OSMO_VALUE_STRING(GPRS_RLCMAC_POLL_NONE),
+ OSMO_VALUE_STRING(GPRS_RLCMAC_POLL_SCHED), /* a polling was scheduled */
+ { 0, NULL }
+};
+
const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[] = {
OSMO_VALUE_STRING(GPRS_RLCMAC_DL_ASS_NONE),
OSMO_VALUE_STRING(GPRS_RLCMAC_DL_ASS_SEND_ASS),
@@ -172,7 +178,6 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
first_ts(0),
first_common_ts(0),
control_ts(0xff),
- poll_state(GPRS_RLCMAC_POLL_NONE),
poll_fn(0),
poll_ts(0),
n3105(0),
@@ -192,6 +197,7 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE),
ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE),
ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
+ poll_state(GPRS_RLCMAC_POLL_NONE),
m_list(this),
m_ms_list(this),
m_egprs_enabled(false)
diff --git a/src/tbf.h b/src/tbf.h
index 2828772..bb5fd0a 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -64,6 +64,8 @@ enum gprs_rlcmac_tbf_poll_state {
GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
};
+extern const struct value_string gprs_rlcmac_tbf_poll_state_names[];
+
enum gprs_rlcmac_tbf_dl_ass_state {
GPRS_RLCMAC_DL_ASS_NONE = 0,
GPRS_RLCMAC_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */
@@ -186,6 +188,8 @@ enum tbf_timers {
#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_POLL_SCHED_SET(t) do { t->poll_sched_set(__FILE__, __LINE__); } while(0)
+#define TBF_POLL_SCHED_UNSET(t) do { t->poll_sched_unset(__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 {
@@ -199,10 +203,13 @@ struct gprs_rlcmac_tbf {
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;
+ bool poll_scheduled() 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 poll_sched_set(const char *file, int line);
+ void poll_sched_unset(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);
@@ -284,7 +291,6 @@ struct gprs_rlcmac_tbf {
gprs_llc m_llc;
- enum gprs_rlcmac_tbf_poll_state poll_state;
uint32_t poll_fn; /* frame number to poll */
uint8_t poll_ts; /* TS to poll */
@@ -347,6 +353,7 @@ private:
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;
+ enum gprs_rlcmac_tbf_poll_state poll_state;
LListHead<gprs_rlcmac_tbf> m_list;
LListHead<gprs_rlcmac_tbf> m_ms_list;
bool m_egprs_enabled;
@@ -394,6 +401,11 @@ inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state r
return ul_ack_state == rhs;
}
+inline bool gprs_rlcmac_tbf::poll_scheduled() const
+{
+ return poll_state == GPRS_RLCMAC_POLL_SCHED;
+}
+
inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const
{
return state != rhs;
@@ -452,6 +464,20 @@ inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new
ul_ack_state = new_state;
}
+inline void gprs_rlcmac_tbf::poll_sched_set(const char *file, int line)
+{
+ LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes poll state from %s to GPRS_RLCMAC_POLL_SCHED\n",
+ tbf_name(this), get_value_string(gprs_rlcmac_tbf_poll_state_names, poll_state));
+ poll_state = GPRS_RLCMAC_POLL_SCHED;
+}
+
+inline void gprs_rlcmac_tbf::poll_sched_unset(const char *file, int line)
+{
+ LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes poll state from %s to GPRS_RLCMAC_POLL_NONE\n",
+ tbf_name(this), get_value_string(gprs_rlcmac_tbf_poll_state_names, poll_state));
+ poll_state = GPRS_RLCMAC_POLL_NONE;
+}
+
inline void gprs_rlcmac_tbf::check_pending_ass()
{
if (ul_ass_state != GPRS_RLCMAC_UL_ASS_NONE)
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index fdbbd16..80e3831 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -635,7 +635,7 @@ bool gprs_rlcmac_dl_tbf::handle_ack_nack()
/* reset N3105 */
n3105 = 0;
t_stop(T3191, "ACK/NACK received");
- poll_state = GPRS_RLCMAC_POLL_NONE;
+ TBF_POLL_SCHED_UNSET(this);
return ack_recovered;
}
@@ -1181,7 +1181,7 @@ void gprs_rlcmac_dl_tbf::request_dl_ack()
bool gprs_rlcmac_dl_tbf::need_control_ts() const
{
- if (poll_state != GPRS_RLCMAC_POLL_NONE)
+ if (poll_scheduled())
return false;
return state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK) ||
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index c1a3388..1560eb0 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -123,8 +123,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts)
uint32_t new_poll_fn = 0;
if (final) {
- if (poll_state == GPRS_RLCMAC_POLL_SCHED &&
- ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) {
+ if (poll_scheduled() && 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;