Move control_ts explicit checks out of the scheduler implementation
Let each subsystem handle that internally.
Change-Id: Ifaf7dde651d56942779d84aa9135fc8c974b6f26
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index f641013..a201b92 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -28,6 +28,7 @@
extern "C" {
#include <osmocom/core/gsmtap.h>
+ #include "nacc_fsm.h"
}
struct tbf_sched_candidates {
@@ -47,17 +48,13 @@
llist_for_each_entry(pos, &pdch->trx->ul_tbfs, list) {
ul_tbf = tbf_as_ul_tbf((struct gprs_rlcmac_tbf *)pos->entry);
OSMO_ASSERT(ul_tbf);
- /* this trx, this ts */
- if (!tbf_is_control_ts(ul_tbf, pdch))
- continue;
- if (tbf_ul_ack_rts(ul_tbf))
+ if (tbf_ul_ack_rts(ul_tbf, pdch))
tbf_cand->ul_ack = ul_tbf;
- if (tbf_dl_ass_rts(ul_tbf))
+ if (tbf_dl_ass_rts(ul_tbf, pdch))
tbf_cand->dl_ass = ul_tbf;
- if (tbf_ul_ass_rts(ul_tbf))
+ if (tbf_ul_ass_rts(ul_tbf, pdch))
tbf_cand->ul_ass = ul_tbf;
- /* NACC ready to send. TFI assigned is needed to send messages */
- if (tbf_is_tfi_assigned(ul_tbf) && ms_nacc_rts(ul_tbf->ms()))
+ if (tbf_nacc_rts(ul_tbf, pdch))
tbf_cand->nacc = ul_tbf;
/* FIXME: Is this supposed to be fair? The last TBF for each wins? Maybe use llist_add_tail and skip once we have all
states? */
@@ -65,15 +62,11 @@
llist_for_each_entry(pos, &pdch->trx->dl_tbfs, list) {
dl_tbf = tbf_as_dl_tbf((struct gprs_rlcmac_tbf *)pos->entry);
OSMO_ASSERT(dl_tbf);
- /* this trx, this ts */
- if (!tbf_is_control_ts(dl_tbf, pdch))
- continue;
- if (tbf_dl_ass_rts(dl_tbf))
+ if (tbf_dl_ass_rts(dl_tbf, pdch))
tbf_cand->dl_ass = dl_tbf;
- if (tbf_ul_ass_rts(dl_tbf))
+ if (tbf_ul_ass_rts(dl_tbf, pdch))
tbf_cand->ul_ass = dl_tbf;
- /* NACC ready to send. TFI assigned is needed to send messages */
- if (tbf_is_tfi_assigned(dl_tbf) && ms_nacc_rts(dl_tbf->ms()))
+ if (tbf_nacc_rts(dl_tbf, pdch))
tbf_cand->nacc = dl_tbf;
}
}
diff --git a/src/nacc_fsm.c b/src/nacc_fsm.c
index 25e7cd8..b4d8583 100644
--- a/src/nacc_fsm.c
+++ b/src/nacc_fsm.c
@@ -900,3 +900,11 @@
ctx->continue_poll_fn == fn &&
ctx->continue_poll_ts == ts;
}
+
+bool tbf_nacc_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch)
+{
+ if (!tbf_is_control_ts(tbf, pdch))
+ return false;
+
+ return tbf_is_tfi_assigned(tbf) && ms_nacc_rts(tbf_ms(tbf));
+}
diff --git a/src/nacc_fsm.h b/src/nacc_fsm.h
index b33dafa..b67ba11 100644
--- a/src/nacc_fsm.h
+++ b/src/nacc_fsm.h
@@ -22,6 +22,7 @@
struct GprsMs;
struct gprs_rlcmac_tbf;
+struct gprs_rlcmac_pdch;
enum nacc_fsm_event {
NACC_EV_RX_CELL_CHG_NOTIFICATION, /* data: Packet_Cell_Change_Notification_t* */
@@ -73,3 +74,5 @@
const struct osmo_cell_global_id_ps *cgi_ps);
bool nacc_fsm_exp_ctrl_ack(const struct nacc_fsm_ctx *ctx, uint32_t fn, uint8_t ts);
+
+bool tbf_nacc_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch);
diff --git a/src/tbf_dl_ass_fsm.c b/src/tbf_dl_ass_fsm.c
index fe959cc..d4dafe2 100644
--- a/src/tbf_dl_ass_fsm.c
+++ b/src/tbf_dl_ass_fsm.c
@@ -248,9 +248,14 @@
return data_ctx.msg;
}
-bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf *tbf)
+bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch)
{
- struct osmo_fsm_inst *fi = tbf_dl_ass_fi(tbf);
+ struct osmo_fsm_inst *fi;
+
+ if (!tbf_is_control_ts(tbf, pdch))
+ return false;
+
+ fi = tbf_dl_ass_fi(tbf);
if (fi->state != TBF_DL_ASS_SEND_ASS)
return false;
diff --git a/src/tbf_dl_ass_fsm.h b/src/tbf_dl_ass_fsm.h
index a259c03..70d768e 100644
--- a/src/tbf_dl_ass_fsm.h
+++ b/src/tbf_dl_ass_fsm.h
@@ -21,6 +21,7 @@
#include <gprs_pcu.h>
struct gprs_rlcmac_tbf;
+struct gprs_rlcmac_pdch;
enum tbf_dl_ass_fsm_event {
TBF_DL_ASS_EV_SCHED_ASS, /* Tx Uplink Assignment is pending */
@@ -62,4 +63,4 @@
struct msgb *tbf_dl_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts);
-bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf* tbf);
+bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch);
diff --git a/src/tbf_ul_ack_fsm.c b/src/tbf_ul_ack_fsm.c
index f6e7a0d..1421c68 100644
--- a/src/tbf_ul_ack_fsm.c
+++ b/src/tbf_ul_ack_fsm.c
@@ -236,9 +236,14 @@
return data_ctx.msg;
}
-bool tbf_ul_ack_rts(const struct gprs_rlcmac_ul_tbf *ul_tbf)
+bool tbf_ul_ack_rts(const struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_pdch *pdch)
{
- struct osmo_fsm_inst *fi = tbf_ul_ack_fi(ul_tbf);
+ struct osmo_fsm_inst *fi;
+
+ if (!tbf_is_control_ts(ul_tbf_as_tbf_const(ul_tbf), pdch))
+ return false;
+
+ fi = tbf_ul_ack_fi(ul_tbf);
return fi->state == TBF_UL_ACK_ST_SCHED_UL_ACK;
}
diff --git a/src/tbf_ul_ack_fsm.h b/src/tbf_ul_ack_fsm.h
index f25972e..e06728e 100644
--- a/src/tbf_ul_ack_fsm.h
+++ b/src/tbf_ul_ack_fsm.h
@@ -22,6 +22,7 @@
struct gprs_rlcmac_tbf;
struct gprs_rlcmac_ul_tbf;
+struct gprs_rlcmac_pdch;
enum tbf_ul_ack_fsm_event {
TBF_UL_ACK_EV_SCHED_ACK, /* Tx UL ACK/NACK is pending */
@@ -63,6 +64,6 @@
struct msgb *tbf_ul_ack_create_rlcmac_msg(const struct gprs_rlcmac_ul_tbf *ul_tbf, uint32_t fn, uint8_t ts);
-bool tbf_ul_ack_rts(const struct gprs_rlcmac_ul_tbf *ul_tbf);
+bool tbf_ul_ack_rts(const struct gprs_rlcmac_ul_tbf *ul_tbf, const struct gprs_rlcmac_pdch *pdch);
bool tbf_ul_ack_waiting_cnf_final_ack(const struct gprs_rlcmac_ul_tbf *ul_tbf);
bool tbf_ul_ack_exp_ctrl_ack(const struct gprs_rlcmac_ul_tbf *ul_tbf, uint32_t fn, uint8_t ts);
diff --git a/src/tbf_ul_ass_fsm.c b/src/tbf_ul_ass_fsm.c
index 932a91f..cff17bc 100644
--- a/src/tbf_ul_ass_fsm.c
+++ b/src/tbf_ul_ass_fsm.c
@@ -341,8 +341,13 @@
return data_ctx.msg;
}
-bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf)
+bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch)
{
- struct osmo_fsm_inst *fi = tbf_ul_ass_fi(tbf);
+ struct osmo_fsm_inst *fi;
+
+ if (!tbf_is_control_ts(tbf, pdch))
+ return false;
+
+ fi = tbf_ul_ass_fi(tbf);
return fi->state == TBF_UL_ASS_SEND_ASS || fi->state == TBF_UL_ASS_SEND_ASS_REJ;
}
diff --git a/src/tbf_ul_ass_fsm.h b/src/tbf_ul_ass_fsm.h
index 8a612f2..aa68adc 100644
--- a/src/tbf_ul_ass_fsm.h
+++ b/src/tbf_ul_ass_fsm.h
@@ -21,6 +21,7 @@
#include <gprs_pcu.h>
struct gprs_rlcmac_tbf;
+struct gprs_rlcmac_pdch;
enum tbf_ul_ass_fsm_event {
TBF_UL_ASS_EV_SCHED_ASS, /* Tx Uplink Assignment is pending */
@@ -65,4 +66,4 @@
struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts);
-bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf);
+bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch);