Change in osmo-pcu[master]: WIP: Replace ul_ass_state with osmocom FSM

pespin gerrit-no-reply at lists.osmocom.org
Tue Jul 27 10:51:04 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/25056 )


Change subject: WIP: Replace ul_ass_state with osmocom FSM
......................................................................

WIP: Replace ul_ass_state with osmocom FSM

Change-Id: Id414eafe9c04a9a8759c6fb1a483bf2ee093a4d2
---
M src/Makefile.am
M src/gprs_rlcmac_sched.cpp
M src/pdch.cpp
M src/tbf.cpp
M src/tbf.h
A src/tbf_ul_ass_fsm.c
A src/tbf_ul_ass_fsm.h
7 files changed, 308 insertions(+), 64 deletions(-)



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

diff --git a/src/Makefile.am b/src/Makefile.am
index 8070fda..c36abed 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -60,6 +60,7 @@
 	tbf.cpp \
 	tbf_fsm.c \
 	tbf_ul.cpp \
+	tbf_ul_ass_fsm.c \
 	tbf_dl.cpp \
 	bts.cpp \
 	pdch.cpp \
@@ -99,6 +100,7 @@
 	tbf.h \
 	tbf_fsm.h \
 	tbf_ul.h \
+	tbf_ul_ass_fsm.h \
 	tbf_dl.h \
 	bts.h \
 	pdch.h \
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 2adf1f3..b65d5be 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -58,8 +58,7 @@
 			tbf_cand->ul_ack = ul_tbf;
 		if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
 			tbf_cand->dl_ass = ul_tbf;
-		if (ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
-		    || ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
+		if (tbf_ul_ass_rts(ul_tbf))
 			tbf_cand->ul_ass = ul_tbf;
 		/* NACC ready to send. TFI assigned is needed to send messages */
 		if (ul_tbf->is_tfi_assigned() && ms_nacc_rts(ul_tbf->ms()))
@@ -75,8 +74,7 @@
 			continue;
 		if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
 			tbf_cand->dl_ass = dl_tbf;
-		if (dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
-		    || dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
+		if (tbf_ul_ass_rts(dl_tbf))
 			tbf_cand->ul_ass = dl_tbf;
 		/* NACC ready to send. TFI assigned is needed to send messages */
 		if (dl_tbf->is_tfi_assigned() && ms_nacc_rts(dl_tbf->ms()))
@@ -169,7 +167,7 @@
 			 * received, thus preventing the others from being processed.
 			 */
 			if (tbf == tbfs->ul_ass && tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
-				msg = tbfs->ul_ass->create_packet_access_reject();
+				msg = tbf_ul_ass_create_rlcmac_msg(tbfs->ul_ass);
 			else if (tbf == tbfs->ul_ass && tbf->direction == GPRS_RLCMAC_DL_TBF)
 				msg = tbfs->ul_ass->create_ul_ass(fn, ts);
 			else if (tbf == tbfs->dl_ass && tbf->direction == GPRS_RLCMAC_UL_TBF)
diff --git a/src/pdch.cpp b/src/pdch.cpp
index b5622b4..ce29fbb 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -124,10 +124,10 @@
 	/* schedule uplink assignment or reject */
 	if (ul_tbf) {
 		LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack message, so we provide one:\n");
-		TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS);
+		osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS, NULL);
 	} else {
 		LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack message, so we packet access reject:\n");
-		TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
+		osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL);
 	}
 }
 
@@ -695,7 +695,7 @@
 
 		ul_tbf->control_ts = ts_no;
 		/* schedule uplink assignment */
-		TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS);
+		osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS, NULL);
 
 		/* get measurements */
 		get_meas(meas, request);
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 8f85d2e..fc42148 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -50,6 +50,7 @@
 #include "gsm_rlcmac.h"
 #include "coding_scheme.h"
 #include "nacc_fsm.h"
+#include "tbf_ul_ass_fsm.h"
 }
 
 #include <errno.h>
@@ -133,7 +134,6 @@
 	m_ctrs(NULL),
 	m_ms(ms),
 	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_egprs_enabled(false)
 {
@@ -153,6 +153,10 @@
 	state_fsm.tbf = this;
 	state_fsm.fi = osmo_fsm_inst_alloc(&tbf_fsm, this, &state_fsm, LOGL_INFO, NULL);
 
+	memset(&ul_ass_fsm, 0, sizeof(ul_state_fsm));
+	ul_ass_fsm.tbf = this;
+	ul_ass_fsm.fi = osmo_fsm_inst_alloc(&tbf_ul_ass_fsm, this, &ul_ass_fsm, LOGL_INFO, NULL);
+
 	m_rlc.init();
 	m_llc.init();
 
@@ -164,6 +168,10 @@
 {
 	osmo_fsm_inst_free(state_fsm.fi);
 	state_fsm.fi = NULL;
+
+	osmo_fsm_inst_free(ul_ass_fsm.fi);
+	ul_ass_fsm.fi = NULL;
+
 	rate_ctr_group_free(m_ctrs);
 }
 
@@ -921,36 +929,6 @@
 	return NULL;
 }
 
-struct msgb *gprs_rlcmac_tbf::create_packet_access_reject()
-{
-	struct msgb *msg;
-
-	msg = msgb_alloc(GSM_MACBLOCK_LEN, "rlcmac_ul_ass_rej");
-
-	bitvec *packet_access_rej = bitvec_alloc(GSM_MACBLOCK_LEN, tall_pcu_ctx);
-
-	bitvec_unhex(packet_access_rej, DUMMY_VEC);
-
-	Encoding::write_packet_access_reject(packet_access_rej, tlli(),
-					     osmo_tdef_get(bts->T_defs_bts, 3172, OSMO_TDEF_MS, -1));
-
-	bts_do_rate_ctr_inc(bts, CTR_PKT_ACCESS_REJ);
-
-	bitvec_pack(packet_access_rej, msgb_put(msg, GSM_MACBLOCK_LEN));
-
-	bitvec_free(packet_access_rej);
-	ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
-
-	/* Start release only if it is UL TBF */
-	if (direction == GPRS_RLCMAC_UL_TBF) {
-		/* tbf_free() called in gprs_rlcmac_tbf::handle_timeout */
-		T_START(this, T0, -2000, "reject (PACCH)", true);
-	}
-
-	return msg;
-
-}
-
 struct msgb *gprs_rlcmac_tbf::create_ul_ass(uint32_t fn, uint8_t ts)
 {
 	struct msgb *msg = NULL;
diff --git a/src/tbf.h b/src/tbf.h
index 6c33bc2..485f559 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -64,15 +64,6 @@
 
 extern const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[];
 
-enum gprs_rlcmac_tbf_ul_ass_state {
-	GPRS_RLCMAC_UL_ASS_NONE = 0,
-	GPRS_RLCMAC_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
-	GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */
-	GPRS_RLCMAC_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
-};
-
-extern const struct value_string gprs_rlcmac_tbf_ul_ass_state_names[];
-
 enum gprs_rlcmac_tbf_ul_ack_state {
 	GPRS_RLCMAC_UL_ACK_NONE = 0,
 	GPRS_RLCMAC_UL_ACK_SEND_ACK, /* send acknowledge on next RTS */
@@ -153,7 +144,6 @@
 #define T_START(tbf, t, T, r, f) tbf->t_start(t, T, r, f, __FILE__, __LINE__)
 
 #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)
 
 #ifdef __cplusplus
@@ -196,10 +186,9 @@
 	bool state_is(enum tbf_fsm_states rhs) const;
 	bool state_is_not(enum tbf_fsm_states 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_ass_state_is(enum tbf_ul_ass_fsm_event rhs) const;
 	bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const;
 	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);
@@ -210,7 +199,6 @@
 
 	struct msgb *create_dl_ass(uint32_t fn, uint8_t ts);
 	struct msgb *create_ul_ass(uint32_t fn, uint8_t ts);
-	struct msgb *create_packet_access_reject();
 
 	GprsMs *ms() const;
 	void set_ms(GprsMs *ms);
@@ -305,6 +293,8 @@
 
 	struct rate_ctr_group *m_ctrs;
 	struct tbf_fsm_ctx state_fsm;
+	struct tbf_ul_ass_fsm_ctx ul_ass_fsm;
+
 	struct llist_item m_ms_list;
 	struct llist_item m_trx_list;
 
@@ -318,7 +308,6 @@
 private:
 	void enable_egprs();
 	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;
 	bool m_egprs_enabled;
 	struct osmo_timer_list Tarr[T_MAX];
@@ -336,9 +325,9 @@
 	return dl_ass_state == rhs;
 }
 
-inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const
+inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum tbf_ul_ass_fsm_event rhs) const
 {
-	return ul_ass_state == rhs;
+	return (enum tbf_fsm_states)tbf->ul_ass_fsm.fi->state == rhs;
 }
 
 inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const
@@ -366,15 +355,6 @@
 	dl_ass_state = new_state;
 }
 
-inline void gprs_rlcmac_tbf::set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line)
-{
-	LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ASS state from %s to %s\n",
-		tbf_name(this),
-		get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, ul_ass_state),
-		get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, new_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",
diff --git a/src/tbf_ul_ass_fsm.c b/src/tbf_ul_ass_fsm.c
new file mode 100644
index 0000000..e45482f
--- /dev/null
+++ b/src/tbf_ul_ass_fsm.c
@@ -0,0 +1,221 @@
+/* tbf_ul_ass_fsm.c
+ *
+ * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info at sysmocom.de>
+ * Author: Pau Espin Pedrol <pespin at sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+
+#include <unistd.h>
+
+#include <talloc.h>
+
+#include <tbf_ul_ass_fsm.h>
+#include <gprs_rlcmac.h>
+#include <gprs_debug.h>
+#include <gprs_ms.h>
+#include <encoding.h>
+#include <bts.h>
+
+#define X(s) (1 << (s))
+
+const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32] = {
+	[TBF_UL_ASS_NONE] = {},
+	[TBF_UL_ASS_SEND_ASS] = {},
+	[TBF_UL_ASS_SEND_ASS_REJ] = {},
+	[TBF_UL_ASS_WAIT_ACK] = {},
+};
+
+const struct value_string tbf_ul_ass_fsm_event_names[] = {
+	{ TBF_UL_ASS_EV_SCHED_ASS, "SCHED_ASS" },
+	{ TBF_UL_ASS_EV_SCHED_ASS_REJ, "SCHED_ASS_REJ" },
+	{ TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, "CREATE_RLCMAC_MSG" },
+	{ 0, NULL }
+};
+
+
+static struct msgb *create_packet_access_reject(const struct tbf_ul_ass_fsm_ctx *ctx)
+{
+	struct msgb *msg;
+
+	msg = msgb_alloc(GSM_MACBLOCK_LEN, "rlcmac_ul_ass_rej");
+
+	bitvec *packet_access_rej = bitvec_alloc(GSM_MACBLOCK_LEN, tall_pcu_ctx);
+
+	bitvec_unhex(packet_access_rej, DUMMY_VEC);
+
+	Encoding::write_packet_access_reject(packet_access_rej, tlli(),
+					     osmo_tdef_get(bts->T_defs_bts, 3172, OSMO_TDEF_MS, -1));
+
+	bts_do_rate_ctr_inc(bts, CTR_PKT_ACCESS_REJ);
+
+	bitvec_pack(packet_access_rej, msgb_put(msg, GSM_MACBLOCK_LEN));
+
+	bitvec_free(packet_access_rej);
+	ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
+
+	/* Start release only if it is UL TBF */
+	if (direction == GPRS_RLCMAC_UL_TBF) {
+		/* tbf_free() called in gprs_rlcmac_tbf::handle_timeout */
+		T_START(this, T0, -2000, "reject (PACCH)", true);
+	}
+
+	return msg;
+
+}
+
+
+static void st_none(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	switch (event) {
+	case TBF_UL_ASS_EV_SCHED_ASS:
+		tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_SEND_ASS);
+		break;
+	case TBF_UL_ASS_EV_SCHED_ASS_REJ:
+		tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_SEND_ASS_REJ);
+		break;
+	default:
+		OSMO_ASSERT(0);
+	}
+}
+
+static void st_send_ass(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	switch (event) {
+	case TBF_UL_ASS_EV_CREATE_RLCMAC_MSG:
+		break;
+	default:
+		OSMO_ASSERT(0);
+	}
+}
+
+static void st_send_ass_rej(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	switch (event) {
+	case TBF_UL_ASS_EV_CREATE_RLCMAC_MSG:
+		data_ctx = (struct ms_anr_ev_create_rlcmac_msg_ctx *)data;
+		*data = create_packet_access_reject(ctx);
+		if (!*data)
+			return;
+		tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_NONE);
+		break;
+	default:
+		OSMO_ASSERT(0);
+	}
+}
+
+static void st_wait_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	switch (event) {
+	default:
+		OSMO_ASSERT(0);
+	}
+}
+
+static void tbf_ul_ass_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
+{
+	/* TODO: needed ?
+	 * struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	 */
+}
+
+static int tbf_ul_ass_fsm_timer_cb(struct osmo_fsm_inst *fi)
+{
+	struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	switch (fi->T) {
+	default:
+		OSMO_ASSERT(0);
+	}
+	return 0;
+}
+
+static struct osmo_fsm_state tbf_ul_ass_fsm_states[] = {
+	[TBF_UL_ASS_NONE] = {
+		.in_event_mask =
+			X(TBF_UL_ASS_EV_SCHED_ASS) |
+			X(TBF_UL_ASS_EV_SCHED_ASS_REJ),
+		.out_state_mask =
+			X(TBF_UL_ASS_SEND_ASS) |
+			X(TBF_UL_ASS_SEND_ASS_REJ),
+		.name = "NONE",
+		.action = st_none,
+	},
+	[TBF_UL_ASS_SEND_ASS] = {
+		.in_event_mask = X(TBF_UL_ASS_EV_CREATE_RLCMAC_MSG),
+		.out_state_mask = X(TBF_UL_ASS_WAIT_ACK),
+		.name = "SEND_ASS",
+		//.onenter = st_assign_on_enter,
+		.action = st_send_ass,
+	},
+	[TBF_UL_ASS_SEND_ASS_REJ] = {
+		.in_event_mask = X(TBF_UL_ASS_EV_CREATE_RLCMAC_MSG),
+		.out_state_mask = X(TBF_UL_ASS_NONE),
+		.name = "SEND_ASS_REJ",
+		//.onenter = st_flow_on_enter,
+		.action = st_send_ass_rej,
+	},
+	[TBF_UL_ASS_WAIT_ACK] = {
+		.in_event_mask = 0,
+		.out_state_mask = X(TBF_UL_ASS_NONE),
+		.name = "WAIT_ACK",
+		//.onenter = st_finished_on_enter,
+		.action = st_wait_ack,
+	},
+};
+
+/*void tbf_ul_ass_fsm_allstate_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
+	switch (event) {
+	case TBF_EV_ASSIGN_DEL_CCCH:
+		mod_ass_type(ctx, GPRS_RLCMAC_FLAG_CCCH, false);
+		break;
+	default:
+		OSMO_ASSERT(0);
+	}
+}*/
+
+struct osmo_fsm tbf_ul_ass_fsm = {
+	.name = "UL_ASS_TBF",
+	.states = tbf_ul_ass_fsm_states,
+	.num_states = ARRAY_SIZE(tbf_ul_ass_fsm_states),
+	.timer_cb = tbf_ul_ass_fsm_timer_cb,
+	.cleanup = tbf_ul_ass_fsm_cleanup,
+	.log_subsys = DTBF,
+	.event_names = tbf_ul_ass_fsm_event_names,
+	//.allstate_action = tbf_ul_ass_fsm_allstate_action,
+	//.allstate_event_mask = 0,
+};
+
+static __attribute__((constructor)) void tbf_ul_ass_fsm_init(void)
+{
+	OSMO_ASSERT(osmo_fsm_register(&tbf_ul_ass_fsm) == 0);
+}
+
+
+struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf)
+{
+	int rc;
+	struct msgb *msg = NULL;
+
+	rc = osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, &msg);
+	if (rc != 0 || !msg)
+		return NULL;
+	return msg;
+}
diff --git a/src/tbf_ul_ass_fsm.h b/src/tbf_ul_ass_fsm.h
new file mode 100644
index 0000000..9aa84fc
--- /dev/null
+++ b/src/tbf_ul_ass_fsm.h
@@ -0,0 +1,65 @@
+/* tbf_ul_ass_fsm.h
+ *
+ * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info at sysmocom.de>
+ * Author: Pau Espin Pedrol <pespin at sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ */
+#pragma once
+
+#include <osmocom/core/fsm.h>
+#include <osmocom/core/tdef.h>
+
+#include <gprs_pcu.h>
+
+struct gprs_rlcmac_ul_tbf;
+
+enum tbf_ul_ass_fsm_event {
+	TBF_UL_ASS_EV_SCHED_ASS, /* Tx Uplink Assignment is pending */
+	TBF_UL_ASS_EV_SCHED_ASS_REJ, /* Tx Uplink Assignment is pending */
+	TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, /* SCheduler wants to schedule a rlcmac msg from us */
+};
+
+enum tbf_ul_ass_fsm_states {
+	TBF_UL_ASS_NONE = 0,
+	TBF_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
+	TBF_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */
+	TBF_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
+};
+
+struct tbf_ul_ass_fsm_ctx {
+	struct osmo_fsm_inst *fi;
+	struct gprs_rlcmac_tbf* tbf; /* back pointer */
+};
+
+extern const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32];
+/* Transition to a state, using the T timer defined in assignment_fsm_timeouts.
+ * The actual timeout value is in turn obtained from conn->T_defs.
+ * Assumes local variable fi exists. */
+#define tbf_ul_ass_fsm_state_chg(fi, NEXT_STATE) \
+	osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \
+				     tbf_ul_ass_fsm_timeouts, \
+				     the_pcu->T_defs, \
+				     -1)
+
+extern struct osmo_fsm tbf_ul_ass_fsm;
+
+
+struct msgb *tbf_ul_ass_create_rlcmac_msg_rej(const struct gprs_rlcmac_tbf* tbf);
+static inline bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf)
+{
+	return tbf->ul_ass_fsm.fi->state == TBF_UL_ASS_SEND_ASS ||
+		tbf->ul_ass_fsm.fi->state == TBF_UL_ASS_SEND_ASS_REJ;
+}

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/25056
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Id414eafe9c04a9a8759c6fb1a483bf2ee093a4d2
Gerrit-Change-Number: 25056
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210727/c0f01bfe/attachment.htm>


More information about the gerrit-log mailing list