Change in osmo-pcu[master]: WIP: Move FINISHED tbf_state transition to tbf_fsm

pespin gerrit-no-reply at lists.osmocom.org
Fri Jul 23 16:33:31 UTC 2021


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


Change subject: WIP: Move FINISHED tbf_state transition to tbf_fsm
......................................................................

WIP: Move FINISHED tbf_state transition to tbf_fsm

Related: OS#2709
Change-Id: I81f507e3a2821254f03364a58ead02333e63099f
---
M src/tbf_dl.cpp
M src/tbf_fsm.c
M src/tbf_fsm.h
M src/tbf_ul.cpp
4 files changed, 24 insertions(+), 5 deletions(-)



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

diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 12fd99f..ed5003c 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -711,7 +711,7 @@
 				is_final = llc_queue_size(llc_queue()) == 0 && !keep_open(fn);
 				if (is_final) {
 					rdbi->cv = 0;
-					TBF_SET_STATE(this, TBF_ST_FINISHED);
+					osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_LAST_DL_DATA_SENT, NULL);
 				}
 
 				if (mcs_is_edge(cs)) {
@@ -756,7 +756,7 @@
 
 		if (is_final) {
 			request_dl_ack();
-			TBF_SET_STATE(this, TBF_ST_FINISHED);
+			osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_LAST_DL_DATA_SENT, NULL);
 		}
 
 		/* dequeue next LLC frame, if any */
diff --git a/src/tbf_fsm.c b/src/tbf_fsm.c
index 1c777a7..3322857 100644
--- a/src/tbf_fsm.c
+++ b/src/tbf_fsm.c
@@ -47,6 +47,8 @@
 	//{ TBF_EV_ASSIGN_DEL_PACCH, "ASSIGN_DEL_PACCH" },
 	{ TBF_EV_ASSIGN_ACK_PACCH, "ASSIGN_ACK_PACCH" },
 	{ TBF_EV_ASSIGN_READY_CCCH, "ASSIGN_READY_CCCH" },
+	{ TBF_EV_LAST_DL_DATA_SENT, "LAST_DL_DATA_SENT" },
+	{ TBF_EV_LAST_UL_DATA_RECVD, "LAST_UL_DATA_RECVD" },
 	{ 0, NULL }
 };
 
@@ -138,6 +140,20 @@
 	}
 }
 
+static void st_flow(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+	//struct tbf_fsm_ctx *ctx = (struct tbf_fsm_ctx *)fi->priv;
+	switch (event) {
+	case TBF_EV_LAST_DL_DATA_SENT:
+	case TBF_EV_LAST_UL_DATA_RECVD:
+		/* All data has been sent or received, change state to FINISHED */
+		tbf_fsm_state_chg(fi, TBF_ST_FINISHED);
+		break;
+	default:
+		OSMO_ASSERT(0);
+	}
+}
+
 static void tbf_fsm_cleanup(struct osmo_fsm_inst *fi, enum osmo_fsm_term_cause cause)
 {
 	/* TODO: needed ?
@@ -182,14 +198,15 @@
 	},
 	[TBF_ST_FLOW] = {
 		.in_event_mask =
-			0,
+			X(TBF_EV_LAST_DL_DATA_SENT) |
+			X(TBF_EV_LAST_UL_DATA_RECVD),
 		.out_state_mask =
 			X(TBF_ST_FINISHED) |
 			X(TBF_ST_WAIT_RELEASE) |
 			X(TBF_ST_RELEASING),
 		.name = "FLOW",
 		//.onenter = st_flow_on_enter,
-		//.action = st_flow,
+		.action = st_flow,
 	},
 	[TBF_ST_FINISHED] = {
 		.in_event_mask =
diff --git a/src/tbf_fsm.h b/src/tbf_fsm.h
index 405f5c6..f4f5ad7 100644
--- a/src/tbf_fsm.h
+++ b/src/tbf_fsm.h
@@ -33,6 +33,8 @@
 	//TBF_EV_ASSIGN_DEL_PACCH,
 	TBF_EV_ASSIGN_ACK_PACCH, /*  We received a CTRL ACK confirming assignment started on PACCH */
 	TBF_EV_ASSIGN_READY_CCCH, /* TBF Start Time timer triggered */
+	TBF_EV_LAST_DL_DATA_SENT, /* DL TBF sends RLCMAC block containing last DL avilable data buffered */
+	TBF_EV_LAST_UL_DATA_RECVD, /* UL TBF sends RLCMAC block containing last UL data (cv=0) */
 };
 
 enum tbf_fsm_states {
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 4b3d015..54108ed 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -534,7 +534,7 @@
 			  rdbi->bsn, rdbi->cv);
 		if (rdbi->cv == 0) {
 			LOGPTBFUL(this, LOGL_DEBUG, "Finished with UL TBF\n");
-			TBF_SET_STATE(this, TBF_ST_FINISHED);
+			osmo_fsm_inst_dispatch(this->state_fsm.fi, TBF_EV_LAST_UL_DATA_RECVD, NULL);
 			/* Reset N3103 counter. */
 			this->n_reset(N3103);
 		}

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I81f507e3a2821254f03364a58ead02333e63099f
Gerrit-Change-Number: 25034
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210723/b9f4dbb1/attachment.htm>


More information about the gerrit-log mailing list