[PATCH] osmo-pcu[master]: TBF: make poll state internal

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Wed Jan 24 10:09:10 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/5864

to look at the new patch set (#3).

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
---
M src/bts.cpp
M src/gprs_rlcmac_sched.cpp
M src/poll_controller.cpp
M src/tbf.cpp
M src/tbf.h
M src/tbf_dl.cpp
M src/tbf_ul.cpp
7 files changed, 43 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/64/5864/3

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 @@
 
 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 @@
 	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 @@
 		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 @@
 		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 @@
 
 	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 @@
 
 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 @@
 	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 @@
 	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 @@
 	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 @@
 #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 @@
 	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 @@
 
 	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 @@
 	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;
@@ -392,6 +399,11 @@
 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::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
@@ -452,6 +464,20 @@
 	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 @@
 	/* 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 @@
 
 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 @@
 	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;

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I6db1c4e7bd0a49aeb5e391afe371c36b96c6a702
Gerrit-PatchSet: 3
Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list