pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/34167 )
Change subject: WIP: DO NOT MERGE
......................................................................
WIP: DO NOT MERGE
Change-Id: I2c4e4c207203cc637c20eca931dd3ffd9cefab59
---
M include/osmocom/gprs/rlcmac/sched.h
M src/rlcmac/sched.c
M src/rlcmac/tbf_ul_ass_fsm.c
M tests/rlcmac/rlcmac_prim_test.c
4 files changed, 53 insertions(+), 16 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/67/34167/1
diff --git a/include/osmocom/gprs/rlcmac/sched.h b/include/osmocom/gprs/rlcmac/sched.h
index 18fbe7d..2c45c5f 100644
--- a/include/osmocom/gprs/rlcmac/sched.h
+++ b/include/osmocom/gprs/rlcmac/sched.h
@@ -32,3 +32,16 @@
/* FN1 goes after FN2: */
return 1;
}
+
+static inline unsigned fn2bn(unsigned fn)
+{
+ return (fn % 52) / 4;
+}
+
+static inline unsigned fn_next_block(unsigned fn)
+{
+ unsigned bn = fn2bn(fn) + 1;
+ fn = fn - (fn % 52);
+ fn += bn * 4 + bn / 3;
+ return fn % GSM_MAX_FN;
+}
diff --git a/src/rlcmac/sched.c b/src/rlcmac/sched.c
index 8709f71..6af2b6a 100644
--- a/src/rlcmac/sched.c
+++ b/src/rlcmac/sched.c
@@ -222,7 +222,7 @@
if (tbfs->poll_ul_ass) {
LOGRLCMAC(LOGL_DEBUG, "(ts=%u,fn=%u,usf=%u) Tx Pkt Control Ack (UL ASS
poll)\n",
bi->ts, bi->fn, bi->usf);
- msg =
gprs_rlcmac_gre_create_pkt_ctrl_ack(ul_tbf_as_tbf(tbfs->poll_ul_ass)->gre);
+ msg = gprs_rlcmac_tbf_ul_ass_create_rlcmac_msg(tbfs->poll_ul_ass, bi);
if (msg)
return msg;
}
diff --git a/src/rlcmac/tbf_ul_ass_fsm.c b/src/rlcmac/tbf_ul_ass_fsm.c
index 8244f8e..26817a2 100644
--- a/src/rlcmac/tbf_ul_ass_fsm.c
+++ b/src/rlcmac/tbf_ul_ass_fsm.c
@@ -30,6 +30,7 @@
#include <osmocom/gprs/rlcmac/types.h>
#include <osmocom/gprs/rlcmac/tbf_ul_ass_fsm.h>
#include <osmocom/gprs/rlcmac/tbf_ul.h>
+#include <osmocom/gprs/rlcmac/tbf_dl.h>
#include <osmocom/gprs/rlcmac/gre.h>
#include <osmocom/gprs/rlcmac/sched.h>
#include <osmocom/gprs/rlcmac/csn1_defs.h>
@@ -392,9 +393,17 @@
/* If RRBP contains valid data, schedule a response (PKT CONTROL ACK or PKT RESOURCE
REQ). */
if (d->dl_block->SP) {
uint32_t poll_fn = rrbp2fn(d->fn, d->dl_block->RRBP);
+ uint32_t next_blk = fn_next_block(poll_fn);
gprs_rlcmac_pdch_ulc_reserve(g_rlcmac_ctx->sched.ulc[d->ts_nr], poll_fn,
GPRS_RLCMAC_PDCH_ULC_POLL_UL_ASS,
ul_tbf_as_tbf(ctx->ul_tbf));
+ /* We need to wait at least until sending the PKT CTRL
+ * ACK (in the old CTRL TS) before completing the
+ * assignment and using the new TS assignment. */
+ if (!ctx->tbf_starting_time_exists && fn_cmp(ctx->tbf_starting_time,
next_blk) < 0) {
+ ctx->tbf_starting_time_exists = true;
+ ctx->tbf_starting_time = next_blk;
+ }
}
if (ctx->tbf_starting_time_exists &&
@@ -413,6 +422,7 @@
{
struct gprs_rlcmac_tbf_ul_ass_fsm_ctx *ctx = (struct gprs_rlcmac_tbf_ul_ass_fsm_ctx
*)fi->priv;
struct tbf_ul_ass_ev_rx_pkt_ul_ass_ctx *d;
+ struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *data_ctx;
int rc;
switch (event) {
@@ -425,9 +435,17 @@
/* If RRBP contains valid data, schedule a response (PKT CONTROL ACK or PKT RESOURCE
REQ). */
if (d->dl_block->SP) {
uint32_t poll_fn = rrbp2fn(d->fn, d->dl_block->RRBP);
+ uint32_t next_blk = fn_next_block(poll_fn);
gprs_rlcmac_pdch_ulc_reserve(g_rlcmac_ctx->sched.ulc[d->ts_nr], poll_fn,
GPRS_RLCMAC_PDCH_ULC_POLL_UL_ASS,
ul_tbf_as_tbf(ctx->ul_tbf));
+ /* We need to wait at least until sending the PKT CTRL
+ * ACK (in the old CTRL TS) before completing the
+ * assignment and using the new TS assignment. */
+ if (!ctx->tbf_starting_time_exists && fn_cmp(ctx->tbf_starting_time,
next_blk) < 0) {
+ ctx->tbf_starting_time_exists = true;
+ ctx->tbf_starting_time = next_blk;
+ }
}
if (ctx->tbf_starting_time_exists &&
@@ -440,6 +458,12 @@
case GPRS_RLCMAC_TBF_UL_ASS_EV_TBF_STARTING_TIME:
tbf_ul_ass_fsm_state_chg(fi, GPRS_RLCMAC_TBF_UL_ASS_ST_COMPL);
break;
+ case GPRS_RLCMAC_TBF_UL_ASS_EV_CREATE_RLCMAC_MSG:
+ data_ctx = (struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *)data;
+ data_ctx->msg =
gprs_rlcmac_gre_create_pkt_ctrl_ack(ul_tbf_as_tbf(ctx->ul_tbf)->gre);
+ if (!data_ctx->msg)
+ return;
+ break;
default:
OSMO_ASSERT(0);
}
@@ -517,7 +541,8 @@
[GPRS_RLCMAC_TBF_UL_ASS_ST_WAIT_TBF_STARTING_TIME2] = {
.in_event_mask =
X(GPRS_RLCMAC_TBF_UL_ASS_EV_RX_PKT_UL_ASS) |
- X(GPRS_RLCMAC_TBF_UL_ASS_EV_TBF_STARTING_TIME),
+ X(GPRS_RLCMAC_TBF_UL_ASS_EV_TBF_STARTING_TIME) |
+ X(GPRS_RLCMAC_TBF_UL_ASS_EV_CREATE_RLCMAC_MSG),
.out_state_mask =
X(GPRS_RLCMAC_TBF_UL_ASS_ST_SCHED_PKT_RES_REQ) |
X(GPRS_RLCMAC_TBF_UL_ASS_ST_WAIT_TBF_STARTING_TIME2) |
@@ -638,6 +663,10 @@
{
int rc;
ul_tbf->ul_ass_fsm.dl_tbf = dl_tbf;
+ /* FIXME: Ideally this should only be the TS where the PKT UL ASS was received... */
+ ul_tbf->ul_ass_fsm.phase1_alloc.num_ts = dl_tbf->cur_alloc.num_ts;
+ memcpy(&ul_tbf->ul_ass_fsm.phase1_alloc.ts[0], &dl_tbf->cur_alloc.ts[0],
+ sizeof(ul_tbf->ul_ass_fsm.phase1_alloc.ts));
rc = osmo_fsm_inst_dispatch(ul_tbf->ul_ass_fsm.fi,
GPRS_RLCMAC_TBF_UL_ASS_EV_START_FROM_DL_TBF,
NULL);
diff --git a/tests/rlcmac/rlcmac_prim_test.c b/tests/rlcmac/rlcmac_prim_test.c
index 410b266..6e317b1 100644
--- a/tests/rlcmac/rlcmac_prim_test.c
+++ b/tests/rlcmac/rlcmac_prim_test.c
@@ -262,20 +262,6 @@
}
#define clock_override_add(sec, usec) clock_override_add_debug(sec, usec, true)
-
-static inline unsigned fn2bn(unsigned fn)
-{
- return (fn % 52) / 4;
-}
-
-static inline unsigned fn_next_block(unsigned fn)
-{
- unsigned bn = fn2bn(fn) + 1;
- fn = fn - (fn % 52);
- fn += bn * 4 + bn / 3;
- return fn % GSM_MAX_FN;
-}
-
static struct osmo_gprs_rlcmac_prim *create_dl_ctrl_block_buf(uint8_t *buf, int
num_bytes, uint8_t tn, uint32_t fn)
{
struct osmo_gprs_rlcmac_prim *rlcmac_prim;
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/34167
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: I2c4e4c207203cc637c20eca931dd3ffd9cefab59
Gerrit-Change-Number: 34167
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange