pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-gprs/+/31757 )

Change subject: rlcmac: Implement DL TBF CCCH & PACCH allocation with TBF 
Starting Time
......................................................................

rlcmac: Implement DL TBF CCCH & PACCH allocation with TBF Starting Time

Change-Id: Idafb4e37971e93c7e8667b8669a29755485e95bb
---
M include/osmocom/gprs/rlcmac/Makefile.am
M include/osmocom/gprs/rlcmac/gre.h
A include/osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h
M src/rlcmac/Makefile.am
M src/rlcmac/gre.c
M src/rlcmac/misc.c
M src/rlcmac/rlcmac.c
M src/rlcmac/sched.c
A src/rlcmac/tbf_dl_ass_fsm.c
M tests/rlcmac/rlcmac_prim_test.err
10 files changed, 562 insertions(+), 31 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved




diff --git a/include/osmocom/gprs/rlcmac/Makefile.am 
b/include/osmocom/gprs/rlcmac/Makefile.am
index 81cfecd..a117a34 100644
--- a/include/osmocom/gprs/rlcmac/Makefile.am
+++ b/include/osmocom/gprs/rlcmac/Makefile.am
@@ -18,6 +18,7 @@
        tbf_ul.h \
        tbf_ul_fsm.h \
        tbf_ul_ass_fsm.h \
+       tbf_dl_ass_fsm.h \
        types_private.h \
        $(NULL)

diff --git a/include/osmocom/gprs/rlcmac/gre.h 
b/include/osmocom/gprs/rlcmac/gre.h
index f6397a6..8322cf7 100644
--- a/include/osmocom/gprs/rlcmac/gre.h
+++ b/include/osmocom/gprs/rlcmac/gre.h
@@ -3,6 +3,7 @@

 #include <osmocom/gprs/rlcmac/rlcmac.h>
 #include <osmocom/gprs/rlcmac/llc_queue.h>
+#include <osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h>

 struct gprs_rlcmac_dl_tbf;
 struct gprs_rlcmac_ul_tbf;
@@ -13,6 +14,9 @@

        struct gprs_rlcmac_llc_queue *llc_queue;

+       /* Manage TBF Starting Time delay during TBF assignment: */
+       struct gprs_rlcmac_tbf_dl_ass_fsm_ctx dl_tbf_dl_ass_fsm;
+
        struct gprs_rlcmac_dl_tbf *dl_tbf;
        struct gprs_rlcmac_ul_tbf *ul_tbf;
 };
diff --git a/include/osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h 
b/include/osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h
new file mode 100644
index 0000000..e45e488
--- /dev/null
+++ b/include/osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h
@@ -0,0 +1,62 @@
+/* DL TBF Assignment FSM, 3GPP TS 44.060 */
+#pragma once
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <osmocom/core/fsm.h>
+#include <osmocom/core/msgb.h>
+
+#include <osmocom/gprs/rlcmac/csn1_defs.h>
+#include <osmocom/gprs/rlcmac/rlcmac_private.h>
+#include <osmocom/gprs/rlcmac/rlcmac_dec.h>
+
+enum gprs_rlcmac_tbf_dl_ass_fsm_states {
+       GPRS_RLCMAC_TBF_DL_ASS_ST_IDLE = 0,     /* new created TBF */
+       GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME,       /* wait for 
Immediate Assignment */
+       GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL, /* Completed, will update TBF and 
return to IDLE state */
+};
+
+struct gprs_rlcmac_tbf_dl_ass_fsm_ctx {
+       struct osmo_fsm_inst *fi;
+       struct gprs_rlcmac_entity *gre; /* backpointer */
+       struct gprs_rlcmac_dl_tbf_allocation alloc;
+       union {
+               IA_RestOctets_t iaro; /* CCCH Imm Ass rest octets */
+               RlcMacDownlink_t dl_block; /* PACCH pkt dl ass */
+       };
+       bool tbf_starting_time_exists;
+       uint32_t tbf_starting_time;
+       uint8_t ts_nr;
+};
+
+enum tbf_dl_ass_fsm_event {
+       GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS, /* Start Downlink/Uplink 
assignment from CCCH Imm Ass (data: strcut tbf_start_ev_rx_ccch_imm_ass_ctx) */
+       GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS, /* Start Downlink/Uplink 
assignment from Pkt Dl/Ul Ass (data: strcut tbf_start_ev_rx_pacch_pkt_ass_ctx) 
*/
+       GPRS_RLCMAC_TBF_DL_ASS_EV_TBF_STARTING_TIME, /* TBF Starting Time 
reached */
+};
+
+struct tbf_start_ev_rx_ccch_imm_ass_ctx {
+       uint8_t ts_nr;
+       uint32_t fn;
+       const struct gsm48_imm_ass *ia;
+       const IA_RestOctets_t *iaro;
+};
+
+struct tbf_start_ev_rx_pacch_pkt_ass_ctx {
+       uint8_t ts_nr;
+       uint32_t fn;
+       const RlcMacDownlink_t *dl_block; /* decoded Pkt{Ul,Dl}Ass */
+};
+int gprs_rlcmac_tbf_dl_ass_fsm_init(void);
+void gprs_rlcmac_tbf_dl_ass_fsm_set_log_cat(int logcat);
+
+int gprs_rlcmac_tbf_dl_ass_fsm_constructor(struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx, struct gprs_rlcmac_entity *gre);
+void gprs_rlcmac_tbf_dl_ass_fsm_destructor(struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx);
+
+int gprs_rlcmac_tbf_start_from_ccch(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx 
*ctx, const struct tbf_start_ev_rx_ccch_imm_ass_ctx *d);
+int gprs_rlcmac_tbf_start_from_pacch(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx 
*ctx, const struct tbf_start_ev_rx_pacch_pkt_ass_ctx *d);
+
+bool gprs_rlcmac_tbf_start_pending(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx);
+void gprs_rlcmac_tbf_start_fn_tick(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx, 
uint32_t fn, uint8_t ts_nr);
+enum gprs_rlcmac_tbf_dl_ass_fsm_states gprs_rlcmac_tbf_start_state(const 
struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx);
diff --git a/src/rlcmac/Makefile.am b/src/rlcmac/Makefile.am
index 9133df0..78bf9ed 100644
--- a/src/rlcmac/Makefile.am
+++ b/src/rlcmac/Makefile.am
@@ -47,6 +47,7 @@
        tbf_ul.c \
        tbf_ul_fsm.c \
        tbf_ul_ass_fsm.c \
+       tbf_dl_ass_fsm.c \
        ts_44_060.c \
        ts_44_064.c \
        misc.c \
diff --git a/src/rlcmac/gre.c b/src/rlcmac/gre.c
index 53d53c7..87953c1 100644
--- a/src/rlcmac/gre.c
+++ b/src/rlcmac/gre.c
@@ -25,6 +25,7 @@
 #include <osmocom/gprs/rlcmac/rlcmac_prim.h>
 #include <osmocom/gprs/rlcmac/rlcmac_private.h>
 #include <osmocom/gprs/rlcmac/tbf_dl.h>
+#include <osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h>
 #include <osmocom/gprs/rlcmac/tbf_ul_fsm.h>
 #include <osmocom/gprs/rlcmac/tbf_ul.h>
 #include <osmocom/gprs/rlcmac/gre.h>
@@ -32,6 +33,7 @@
 struct gprs_rlcmac_entity *gprs_rlcmac_entity_alloc(uint32_t tlli)
 {
        struct gprs_rlcmac_entity *gre;
+       int rc;

        gre = talloc_zero(g_ctx, struct gprs_rlcmac_entity);
        if (!gre)
@@ -44,6 +46,10 @@
                                               g_ctx->cfg.codel.use,
                                               g_ctx->cfg.codel.interval_msec);

+       rc = gprs_rlcmac_tbf_dl_ass_fsm_constructor(&gre->dl_tbf_dl_ass_fsm, 
gre);
+       if (rc < 0)
+               goto err_free_gre;
+
        gre->tlli = tlli;
        llist_add_tail(&gre->entry, &g_ctx->gre_list);

@@ -59,6 +65,7 @@
        if (!gre)
                return;

+       gprs_rlcmac_tbf_dl_ass_fsm_destructor(&gre->dl_tbf_dl_ass_fsm);
        gprs_rlcmac_dl_tbf_free(gre->dl_tbf);
        gprs_rlcmac_ul_tbf_free(gre->ul_tbf);
        gprs_rlcmac_llc_queue_free(gre->llc_queue);
diff --git a/src/rlcmac/misc.c b/src/rlcmac/misc.c
index 7317bd1..fb3d25b 100644
--- a/src/rlcmac/misc.c
+++ b/src/rlcmac/misc.c
@@ -21,6 +21,7 @@
 #include <osmocom/gprs/rlcmac/tbf_dl_fsm.h>
 #include <osmocom/gprs/rlcmac/tbf_ul_fsm.h>
 #include <osmocom/gprs/rlcmac/tbf_ul_ass_fsm.h>
+#include <osmocom/gprs/rlcmac/tbf_dl_ass_fsm.h>

 int g_rlcmac_log_cat[_OSMO_GPRS_RLCMAC_LOGC_MAX] = {
        [0 ... _OSMO_GPRS_RLCMAC_LOGC_MAX - 1] = DLGLOBAL
@@ -32,6 +33,9 @@
        g_rlcmac_log_cat[logc] = logc_num;

        switch (logc) {
+       case OSMO_GPRS_RLCMAC_LOGC_RLCMAC:
+               gprs_rlcmac_tbf_dl_ass_fsm_set_log_cat(logc_num);
+               break;
        case OSMO_GPRS_RLCMAC_LOGC_TBFUL:
                gprs_rlcmac_tbf_ul_fsm_set_log_cat(logc_num);
                gprs_rlcmac_tbf_ul_ass_fsm_set_log_cat(logc_num);
diff --git a/src/rlcmac/rlcmac.c b/src/rlcmac/rlcmac.c
index 4647fff..8ff6c68 100644
--- a/src/rlcmac/rlcmac.c
+++ b/src/rlcmac/rlcmac.c
@@ -86,6 +86,11 @@
        osmo_tdefs_reset(g_ctx->T_defs);

        if (first_init) {
+               rc = gprs_rlcmac_tbf_dl_ass_fsm_init();
+               if (rc != 0) {
+                       TALLOC_FREE(g_ctx);
+                       return rc;
+               }
                rc = gprs_rlcmac_tbf_dl_fsm_init();
                if (rc != 0) {
                        TALLOC_FREE(g_ctx);
@@ -195,8 +200,8 @@
 {
        int rc;
        struct gprs_rlcmac_entity *gre;
-       struct gprs_rlcmac_dl_tbf *dl_tbf;
        const Packet_Downlink_ImmAssignment_t *pkdlass;
+       struct tbf_start_ev_rx_ccch_imm_ass_ctx ev_data;

        if (iaro->UnionType == 1) {
                /* TODO */
@@ -211,17 +216,13 @@
                return -ENOENT;
        }

-       LOGGRE(gre, LOGL_INFO, "Got PCH IMM_ASS (DL_TBF): DL_TFI=%u TS=%u\n",
-              pkdlass->TFI_ASSIGNMENT, ts_nr);
-       dl_tbf = gprs_rlcmac_dl_tbf_alloc(gre);
-       dl_tbf->cur_alloc.dl_tfi = pkdlass->TFI_ASSIGNMENT;
-       dl_tbf->cur_alloc.ts[ts_nr].allocated = true;
-
-       /* replace old DL TBF with new one: */
-       gprs_rlcmac_dl_tbf_free(gre->dl_tbf);
-       gre->dl_tbf = dl_tbf;
-
-       rc = osmo_fsm_inst_dispatch(dl_tbf->state_fsm.fi, 
GPRS_RLCMAC_TBF_UL_EV_DL_ASS_COMPL, NULL);
+       ev_data = (struct tbf_start_ev_rx_ccch_imm_ass_ctx) {
+               .ts_nr = ts_nr,
+               .fn = fn,
+               .ia = ia,
+               .iaro = iaro,
+       };
+       rc = gprs_rlcmac_tbf_start_from_ccch(&gre->dl_tbf_dl_ass_fsm, &ev_data);
        return rc;
 }

@@ -333,6 +334,82 @@
        return rc;
 }

+static struct gprs_rlcmac_tbf *find_tbf_by_global_tfi(const Global_TFI_t *gtfi)
+{
+       struct gprs_rlcmac_ul_tbf *ul_tbf;
+       struct gprs_rlcmac_dl_tbf *dl_tbf;
+       switch (gtfi->UnionType) {
+       case 0: /* UL TFI */
+               ul_tbf = gprs_rlcmac_find_ul_tbf_by_tfi(gtfi->u.UPLINK_TFI);
+               if (ul_tbf)
+                       return ul_tbf_as_tbf(ul_tbf);
+               break;
+       case 1: /* DL TFI */
+               dl_tbf = gprs_rlcmac_find_dl_tbf_by_tfi(gtfi->u.DOWNLINK_TFI);
+               if (dl_tbf)
+                       return dl_tbf_as_tbf(dl_tbf);
+               break;
+       default:
+               OSMO_ASSERT(0);
+       }
+       return NULL;
+}
+
+static struct gprs_rlcmac_entity *find_gre_by_global_tfi(const Global_TFI_t 
*gtfi)
+{
+       struct gprs_rlcmac_tbf *tbf = find_tbf_by_global_tfi(gtfi);
+       if (tbf)
+               return tbf->gre;
+       return NULL;
+}
+
+
+static int gprs_rlcmac_handle_pkt_dl_ass(const struct osmo_gprs_rlcmac_prim 
*rlcmac_prim, const RlcMacDownlink_t *dl_block)
+{
+       struct gprs_rlcmac_tbf *tbf = NULL;
+       struct gprs_rlcmac_entity *gre = NULL;
+       const Packet_Downlink_Assignment_t *dlass = 
&dl_block->u.Packet_Downlink_Assignment;
+       struct tbf_start_ev_rx_pacch_pkt_ass_ctx ev_data;
+       int rc;
+
+       /* Attempt to find relevant MS in assignment state from ID (set "gre" 
ptr): */
+       switch (dlass->ID.UnionType) {
+       case 0: /* GLOBAL_TFI: */
+               tbf = find_tbf_by_global_tfi(&dlass->ID.u.Global_TFI);
+               if (tbf)
+                       gre = tbf->gre;
+               break;
+       case 1: /* TLLI */
+               gre = gprs_rlcmac_find_entity_by_tlli(dlass->ID.u.TLLI);
+               break;
+       default:
+               OSMO_ASSERT(0);
+       }
+
+       if (!gre) {
+               LOGRLCMAC(LOGL_INFO, "TS=%u FN=%u Rx Pkt DL ASS: MS not 
found\n",
+                         rlcmac_prim->l1ctl.pdch_data_ind.ts_nr,
+                         rlcmac_prim->l1ctl.pdch_data_ind.fn);
+               return -ENOENT;
+       }
+
+       ev_data = (struct tbf_start_ev_rx_pacch_pkt_ass_ctx) {
+               .ts_nr = rlcmac_prim->l1ctl.pdch_data_ind.ts_nr,
+               .fn = rlcmac_prim->l1ctl.pdch_data_ind.fn,
+               .dl_block = dl_block,
+       };
+       rc = gprs_rlcmac_tbf_start_from_pacch(&gre->dl_tbf_dl_ass_fsm, 
&ev_data);
+
+       if (tbf && dl_block->SP) {
+               uint32_t poll_fn = rrbp2fn(rlcmac_prim->l1ctl.pdch_data_ind.fn, 
dl_block->RRBP);
+               
gprs_rlcmac_pdch_ulc_reserve(g_ctx->sched.ulc[rlcmac_prim->l1ctl.pdch_data_ind.ts_nr],
+                                            poll_fn,
+                                            GPRS_RLCMAC_PDCH_ULC_POLL_DL_ASS,
+                                            tbf);
+       }
+       return rc;
+}
+
 static int gprs_rlcmac_handle_pkt_ul_ack_nack(const struct 
osmo_gprs_rlcmac_prim *rlcmac_prim, const RlcMacDownlink_t *dl_block)
 {
        struct gprs_rlcmac_ul_tbf *ul_tbf;
@@ -362,28 +439,13 @@
 static int gprs_rlcmac_handle_pkt_ul_ass(const struct osmo_gprs_rlcmac_prim 
*rlcmac_prim, const RlcMacDownlink_t *dl_block)
 {
        struct gprs_rlcmac_entity *gre = NULL;
-       struct gprs_rlcmac_ul_tbf *ul_tbf = NULL;
-       struct gprs_rlcmac_dl_tbf *dl_tbf;
        const Packet_Uplink_Assignment_t *ulass = 
&dl_block->u.Packet_Uplink_Assignment;
        int rc;

        /* Attempt to find relevant MS owning UL TBF in assignment state from 
ID (set "gre" ptr): */
        switch (ulass->ID.UnionType) {
        case 0: /* GLOBAL_TFI: */
-               switch (ulass->ID.u.Global_TFI.UnionType) {
-               case 0: /* UL TFI */
-                       ul_tbf = 
gprs_rlcmac_find_ul_tbf_by_tfi(ulass->ID.u.Global_TFI.u.UPLINK_TFI);
-                       if (ul_tbf)
-                               gre = ul_tbf->tbf.gre;
-                       break;
-               case 1: /* DL TFI */
-                       dl_tbf = 
gprs_rlcmac_find_dl_tbf_by_tfi(ulass->ID.u.Global_TFI.u.DOWNLINK_TFI);
-                       if (dl_tbf)
-                               gre = dl_tbf->tbf.gre;
-                       break;
-               default:
-                       OSMO_ASSERT(0);
-               }
+               gre = find_gre_by_global_tfi(&ulass->ID.u.Global_TFI);
                break;
        case 1: /* TLLI */
                gre = gprs_rlcmac_find_entity_by_tlli(ulass->ID.u.TLLI);
@@ -443,6 +505,9 @@
                  get_value_string(osmo_gprs_rlcmac_dl_msg_type_names, 
dl_ctrl_block->u.MESSAGE_TYPE));

        switch (dl_ctrl_block->u.MESSAGE_TYPE) {
+       case OSMO_GPRS_RLCMAC_DL_MSGT_PACKET_DOWNLINK_ASSIGNMENT:
+               rc = gprs_rlcmac_handle_pkt_dl_ass(rlcmac_prim, dl_ctrl_block);
+               break;
        case OSMO_GPRS_RLCMAC_DL_MSGT_PACKET_UPLINK_ACK_NACK:
                rc = gprs_rlcmac_handle_pkt_ul_ack_nack(rlcmac_prim, 
dl_ctrl_block);
                break;
diff --git a/src/rlcmac/sched.c b/src/rlcmac/sched.c
index f77deab..46e43ab 100644
--- a/src/rlcmac/sched.c
+++ b/src/rlcmac/sched.c
@@ -38,6 +38,7 @@
        struct gprs_rlcmac_ul_tbf *poll_ul_ack_new_ul_tbf; /* 9.3.2.4.2  
(answer with PKT RES REQ) */
        struct gprs_rlcmac_ul_tbf *poll_ul_ack; /* 11.2.2 (answer with PKT CTRL 
ACK) */
        struct gprs_rlcmac_ul_tbf *poll_ul_ass; /* (answer Pkt UL ASS with PKT 
CTRL ACK) */
+       struct gprs_rlcmac_tbf *poll_dl_ass; /* (answer Pkt DL ASS with PKT 
CTRL ACK) */
        struct gprs_rlcmac_ul_tbf *ul_ass;      /* PCU grants USF/SBA: transmit 
Pkt Res Req (2phase access)*/
 };

@@ -79,7 +80,7 @@
                        tbfs->poll_ul_ass = tbf_as_ul_tbf(node->tbf);
                        break;
                case GPRS_RLCMAC_PDCH_ULC_POLL_DL_ASS:
-                       /* TODO */
+                       tbfs->poll_dl_ass = node->tbf;
                        break;
                case GPRS_RLCMAC_PDCH_ULC_POLL_UL_ACK:
                        /* TS 44.060: 9.3.2.4.2 If the PACKET UPLINK ACK/NACK 
message
@@ -203,6 +204,13 @@
                gprs_rlcmac_ul_tbf_free(tbfs->poll_ul_ack);
                return msg;
        }
+       if (tbfs->poll_dl_ass) {
+               LOGRLCMAC(LOGL_DEBUG, "(ts=%u,fn=%u,usf=%u) Tx Pkt Control Ack 
(DL ASS poll)\n",
+                         bi->ts, bi->fn, bi->usf);
+               msg = gprs_rlcmac_tbf_create_pkt_ctrl_ack(tbfs->poll_dl_ass);
+               if (msg)
+                       return msg;
+       }
        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);
@@ -259,9 +267,12 @@
 static void rts_tick(const struct gprs_rlcmac_rts_block_ind *bi)
 {
        struct gprs_rlcmac_entity *gre;
+
        llist_for_each_entry(gre, &g_ctx->gre_list, entry) {
                if (gre->ul_tbf && 
gprs_rlcmac_tbf_ul_ass_waiting_tbf_starting_time(gre->ul_tbf))
                        gprs_rlcmac_tbf_ul_ass_fn_tick(gre->ul_tbf, bi->fn, 
bi->ts);
+               if (gprs_rlcmac_tbf_start_pending(&gre->dl_tbf_dl_ass_fsm))
+                       gprs_rlcmac_tbf_start_fn_tick(&gre->dl_tbf_dl_ass_fsm, 
bi->fn, bi->ts);
        }
 }

diff --git a/src/rlcmac/tbf_dl_ass_fsm.c b/src/rlcmac/tbf_dl_ass_fsm.c
new file mode 100644
index 0000000..9f13e75
--- /dev/null
+++ b/src/rlcmac/tbf_dl_ass_fsm.c
@@ -0,0 +1,343 @@
+/* TBF as per 3GPP TS 44.064 */
+/*
+ * (C) 2023 by sysmocom - s.f.m.c. GmbH <[email protected]>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <errno.h>
+#include <talloc.h>
+#include <osmocom/core/tdef.h>
+#include <osmocom/core/fsm.h>
+#include <osmocom/core/bitvec.h>
+
+#include <osmocom/gprs/rlcmac/types.h>
+#include <osmocom/gprs/rlcmac/tbf_dl_ass_fsm.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>
+#include <osmocom/gprs/rlcmac/rlcmac_enc.h>
+#include <osmocom/gprs/rlcmac/pdch_ul_controller.h>
+
+#define X(s) (1 << (s))
+
+static const struct value_string tbf_dl_ass_fsm_event_names[] = {
+       { GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS,    "RX_CCCH_IMM_ASS" },
+       { GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS,   "RX_PACCH_PKT_ASS" },
+       { GPRS_RLCMAC_TBF_DL_ASS_EV_TBF_STARTING_TIME,  "TBF_STARTING_TIME" },
+       { 0, NULL }
+};
+
+static const struct osmo_tdef_state_timeout tbf_dl_ass_fsm_timeouts[32] = {
+       [GPRS_RLCMAC_TBF_DL_ASS_ST_IDLE] = { },
+       [GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME] = { },
+       [GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL] = { },
+};
+
+/* Transition to a state, using the T timer defined in tbf_fsm_timeouts.
+ * The actual timeout value is in turn obtained from conn->T_defs.
+ * Assumes local variable fi exists. */
+ #define tbf_dl_ass_fsm_state_chg(fi, NEXT_STATE) \
+       osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \
+                                    tbf_dl_ass_fsm_timeouts, \
+                                    g_ctx->T_defs, \
+                                    -1)
+
+static int handle_imm_ass(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx, const 
struct tbf_start_ev_rx_ccch_imm_ass_ctx *d)
+{
+       const Packet_Downlink_ImmAssignment_t *pkdlass;
+
+       switch (d->iaro->UnionType) {
+       case 1: /* d->iaro->u.lh.* (IA_RestOctetsLH_t) */
+               switch (d->iaro->u.lh.lh0x.UnionType) {
+               case 1: /* d->iaro->u.ll.lh0x.MultiBlock_PktDlAss.* 
(IA_MultiBlock_PktDlAss_t) */
+                       return -ENOTSUP; /* TODO */
+               }
+       case 3: /* d->iaro->u.hh.* (IA_RestOctetsHH_t) */
+               switch (d->iaro->u.hh.UnionType) {
+               case 0: /* d->iaro->u.hh.u.UplinkDownlinkAssignment.* 
(IA_PacketAssignment_UL_DL_t) */
+                       switch 
(d->iaro->u.hh.u.UplinkDownlinkAssignment.UnionType) {
+                       case 1: /* 
d->iaro->u.hh.u.UplinkDownlinkAssignment.ul_dl.Packet_Downlink_ImmAssignment.* 
(Packet_Downlink_ImmAssignment_t) */
+                               pkdlass = 
&d->iaro->u.hh.u.UplinkDownlinkAssignment.ul_dl.Packet_Downlink_ImmAssignment;
+                               ctx->alloc.dl_tfi = pkdlass->TFI_ASSIGNMENT;
+
+                               ctx->tbf_starting_time_exists = 
pkdlass->Exist_TBF_STARTING_TIME;
+                               if (ctx->tbf_starting_time_exists)
+                                       ctx->tbf_starting_time = 
TBF_StartingTime_to_fn(&pkdlass->TBF_STARTING_TIME, d->fn);
+
+                               ctx->alloc.num_ts = 1;
+                               ctx->alloc.ts[d->ts_nr].allocated = true;
+                               LOGPFSML(ctx->fi, LOGL_INFO, "Got PCH IMM_ASS 
(DL_TBF): DL_TFI=%u TS=%u\n",
+                                       pkdlass->TFI_ASSIGNMENT, d->ts_nr);
+                               return 0;
+                       }
+               }
+               break;
+       }
+
+       OSMO_ASSERT(0);
+       return -EFAULT;
+}
+
+static int handle_pkt_dl_ass(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx, const 
struct tbf_start_ev_rx_pacch_pkt_ass_ctx *d)
+{
+
+       const Packet_Downlink_Assignment_t *dlass = 
&d->dl_block->u.Packet_Downlink_Assignment;
+       unsigned int i;
+
+       if (dlass->Exist_DOWNLINK_TFI_ASSIGNMENT)
+               ctx->alloc.dl_tfi = dlass->DOWNLINK_TFI_ASSIGNMENT;
+       else
+               ctx->alloc.dl_tfi = 0xff;
+
+       ctx->tbf_starting_time_exists = dlass->Exist_TBF_Starting_Time;
+       if (ctx->tbf_starting_time_exists)
+               ctx->tbf_starting_time = 
TBF_Starting_Frame_Number_to_fn(&dlass->TBF_Starting_Time, d->fn);
+
+       ctx->alloc.num_ts = 0;
+       for (i = 0; i < 8; i++) {
+               ctx->alloc.ts[i].allocated = (dlass->TIMESLOT_ALLOCATION >> i) 
& 0x01;
+               if (ctx->alloc.ts[i].allocated)
+                       ctx->alloc.num_ts++;
+       }
+       return 0;
+}
+
+static void st_idle_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+       struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx = (struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *)fi->priv;
+
+       /* Reset state: */
+       ctx->tbf_starting_time_exists = false;
+       ctx->tbf_starting_time = 0;
+       ctx->ts_nr = 0;
+       memset(&ctx->alloc, 0, sizeof(ctx->alloc));
+}
+
+static void st_idle(struct osmo_fsm_inst *fi, uint32_t event, void *data)
+{
+       struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx = (struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *)fi->priv;
+       struct tbf_start_ev_rx_ccch_imm_ass_ctx *ev_ccch_imm_ass;
+       struct tbf_start_ev_rx_pacch_pkt_ass_ctx *ev_pacch_pkt_ass;
+
+       switch (event) {
+       case GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS:
+               ev_ccch_imm_ass = (struct tbf_start_ev_rx_ccch_imm_ass_ctx 
*)data;
+               if (handle_imm_ass(ctx, ev_ccch_imm_ass) < 0)
+                       return;
+               memcpy(&ctx->iaro, ev_ccch_imm_ass->iaro, sizeof(ctx->iaro));
+               if (ctx->tbf_starting_time_exists &&
+                   fn_cmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) > 0)
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
+               else
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
+               break;
+       case GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS:
+               ev_pacch_pkt_ass = (struct tbf_start_ev_rx_pacch_pkt_ass_ctx 
*)data;
+               if (handle_pkt_dl_ass(ctx, ev_pacch_pkt_ass) < 0)
+                       return;
+               memcpy(&ctx->dl_block, ev_pacch_pkt_ass->dl_block, 
sizeof(ctx->dl_block));
+               if (ctx->tbf_starting_time_exists &&
+                   fn_cmp(ctx->tbf_starting_time, ev_pacch_pkt_ass->fn) > 0)
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
+               else
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
+               break;
+       default:
+               OSMO_ASSERT(0);
+       }
+}
+
+static void st_wait_tbf_starting_time(struct osmo_fsm_inst *fi, uint32_t 
event, void *data)
+{
+       struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx = (struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *)fi->priv;
+       const struct tbf_start_ev_rx_ccch_imm_ass_ctx *ev_ccch_imm_ass;
+       struct tbf_start_ev_rx_pacch_pkt_ass_ctx *ev_pacch_pkt_ass;
+
+       switch (event) {
+       case GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS:
+               ev_ccch_imm_ass = (struct tbf_start_ev_rx_ccch_imm_ass_ctx 
*)data;
+               if (handle_imm_ass(ctx, ev_ccch_imm_ass) < 0)
+                       return;
+               memcpy(&ctx->iaro, ev_ccch_imm_ass->iaro, sizeof(ctx->iaro));
+               if (ctx->tbf_starting_time_exists &&
+                   fn_cmp(ctx->tbf_starting_time, ev_ccch_imm_ass->fn) > 0)
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
+               else
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
+               break;
+       case GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS:
+               ev_pacch_pkt_ass = (struct tbf_start_ev_rx_pacch_pkt_ass_ctx 
*)data;
+               if (handle_pkt_dl_ass(ctx, ev_pacch_pkt_ass) < 0)
+                       return;
+               memcpy(&ctx->dl_block, ev_pacch_pkt_ass->dl_block, 
sizeof(ctx->dl_block));
+               if (ctx->tbf_starting_time_exists &&
+                   fn_cmp(ctx->tbf_starting_time, ev_pacch_pkt_ass->fn) > 0)
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME);
+               else
+                       tbf_dl_ass_fsm_state_chg(fi, 
GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
+               break;
+       case GPRS_RLCMAC_TBF_DL_ASS_EV_TBF_STARTING_TIME:
+               tbf_dl_ass_fsm_state_chg(fi, GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL);
+               break;
+       default:
+               OSMO_ASSERT(0);
+       }
+}
+
+static void st_compl_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
+{
+       struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx = (struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *)fi->priv;
+       struct gprs_rlcmac_dl_tbf *dl_tbf;
+
+       dl_tbf = gprs_rlcmac_dl_tbf_alloc(ctx->gre);
+
+       /* Update TBF with allocated content: */
+       memcpy(&dl_tbf->cur_alloc, &ctx->alloc, sizeof(ctx->alloc));
+
+       /* Replace old DL TBF with new one. 8.1.1.1.3: "the mobile station shall
+        * release all ongoing downlink TBFs not addressed by this message and
+        * shall act on the message. All ongoing uplink TBFs shall be 
maintained;"
+        */
+       gprs_rlcmac_dl_tbf_free(ctx->gre->dl_tbf);
+       ctx->gre->dl_tbf = dl_tbf;
+
+       /* Inform the main TBF state about the assignment completed: */
+       osmo_fsm_inst_dispatch(dl_tbf->state_fsm.fi, 
GPRS_RLCMAC_TBF_UL_EV_DL_ASS_COMPL, NULL);
+       /* Go back to IDLE state. */
+       tbf_dl_ass_fsm_state_chg(fi, GPRS_RLCMAC_TBF_DL_ASS_ST_IDLE);
+}
+
+static struct osmo_fsm_state tbf_dl_ass_fsm_states[] = {
+       [GPRS_RLCMAC_TBF_DL_ASS_ST_IDLE] = {
+               .in_event_mask =
+                       X(GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS) |
+                       X(GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS),
+               .out_state_mask =
+                       X(GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME) |
+                       X(GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL),
+               .name = "IDLE",
+               .onenter = st_idle_on_enter,
+               .action = st_idle,
+       },
+       [GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME] = {
+               .in_event_mask =
+                       X(GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS) |
+                       X(GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS) |
+                       X(GPRS_RLCMAC_TBF_DL_ASS_EV_TBF_STARTING_TIME),
+               .out_state_mask =
+                       X(GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME) |
+                       X(GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL),
+               .name = "WAIT_TBF_STARTING_TIME",
+               .action = st_wait_tbf_starting_time,
+       },
+       [GPRS_RLCMAC_TBF_DL_ASS_ST_COMPL] = {
+               .in_event_mask = 0,
+               .out_state_mask =
+                       X(GPRS_RLCMAC_TBF_DL_ASS_ST_IDLE),
+               .name = "COMPLETED",
+               .onenter = st_compl_on_enter,
+       },
+};
+
+
+static int tbf_dl_ass_fsm_timer_cb(struct osmo_fsm_inst *fi)
+{
+       //struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx = (struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *)fi->priv;
+       switch (fi->T) {
+       default:
+               OSMO_ASSERT(0);
+       }
+       return 0;
+}
+
+static struct osmo_fsm tbf_dl_ass_fsm = {
+       .name = "DL_TBF_ASS",
+       .states = tbf_dl_ass_fsm_states,
+       .num_states = ARRAY_SIZE(tbf_dl_ass_fsm_states),
+       .timer_cb = tbf_dl_ass_fsm_timer_cb,
+       .log_subsys = DLGLOBAL, /* updated dynamically through 
gprs_rlcmac_tbf_dl_ass_fsm_set_log_cat() */
+       .event_names = tbf_dl_ass_fsm_event_names,
+};
+
+int gprs_rlcmac_tbf_dl_ass_fsm_init(void)
+{
+       return osmo_fsm_register(&tbf_dl_ass_fsm);
+}
+
+void gprs_rlcmac_tbf_dl_ass_fsm_set_log_cat(int logcat)
+{
+       tbf_dl_ass_fsm.log_subsys = logcat;
+}
+
+int gprs_rlcmac_tbf_dl_ass_fsm_constructor(struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx, struct gprs_rlcmac_entity *gre)
+{
+       ctx->gre = gre;
+       ctx->fi = osmo_fsm_inst_alloc(&tbf_dl_ass_fsm, gre, ctx, LOGL_INFO, 
NULL);
+       if (!ctx->fi)
+               return -ENODATA;
+
+       return 0;
+}
+
+void gprs_rlcmac_tbf_dl_ass_fsm_destructor(struct 
gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx)
+{
+       osmo_fsm_inst_free(ctx->fi);
+       ctx->fi = NULL;
+}
+
+/* A DL TBF assaigned was received over CCCH. */
+int gprs_rlcmac_tbf_start_from_ccch(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx 
*ctx, const struct tbf_start_ev_rx_ccch_imm_ass_ctx *d)
+{
+       int rc;
+       rc = osmo_fsm_inst_dispatch(ctx->fi,
+                                   GPRS_RLCMAC_TBF_DL_ASS_EV_RX_CCCH_IMM_ASS,
+                                   (void *)d);
+       return rc;
+}
+
+/* A DL TBF assaigned was received over PACCH (of an UL TBF or previous DL 
TBF). */
+int gprs_rlcmac_tbf_start_from_pacch(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx 
*ctx, const struct tbf_start_ev_rx_pacch_pkt_ass_ctx *d)
+{
+       int rc;
+       rc = osmo_fsm_inst_dispatch(ctx->fi,
+                                   GPRS_RLCMAC_TBF_DL_ASS_EV_RX_PACCH_PKT_ASS,
+                                   (void *)d);
+       return rc;
+}
+
+bool gprs_rlcmac_tbf_start_pending(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx)
+{
+       return ctx->fi->state == 
GPRS_RLCMAC_TBF_DL_ASS_ST_WAIT_TBF_STARTING_TIME;
+}
+
+/* The scheduled ticks the new FN, which may trigger changes internally if TBF 
Starting Time is reached */
+void gprs_rlcmac_tbf_start_fn_tick(struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx, 
uint32_t fn, uint8_t ts_nr)
+{
+       OSMO_ASSERT(gprs_rlcmac_tbf_start_pending(ctx));
+       if (fn != ctx->tbf_starting_time ||
+           ts_nr != ctx->ts_nr)
+               return;
+
+       osmo_fsm_inst_dispatch(ctx->fi, 
GPRS_RLCMAC_TBF_DL_ASS_EV_TBF_STARTING_TIME, NULL);
+}
+
+enum gprs_rlcmac_tbf_dl_ass_fsm_states gprs_rlcmac_tbf_start_state(const 
struct gprs_rlcmac_tbf_dl_ass_fsm_ctx *ctx)
+{
+       return ctx->fi->state;
+}
diff --git a/tests/rlcmac/rlcmac_prim_test.err 
b/tests/rlcmac/rlcmac_prim_test.err
index 1aedd64..f0b55d0 100644
--- a/tests/rlcmac/rlcmac_prim_test.err
+++ b/tests/rlcmac/rlcmac_prim_test.err
@@ -1,5 +1,6 @@
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -64,8 +65,10 @@
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{RELEASING}: Deallocated
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-PDCH_DATA.request
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -152,8 +155,10 @@
 DLGLOBAL NOTICE UL_TBF{FLOW}: TBF establishment failure (T3164 timeout 
attempts=4)
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{FLOW}: Deallocated
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -287,10 +292,12 @@
 DLGLOBAL NOTICE UL_TBF{FLOW}: TBF establishment failure (T3166 timeout 
attempts=4)
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{FLOW}: Deallocated
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL DEBUG Rx from lower layers: L1CTL-CCCH_DATA.indication
 DLGLOBAL DEBUG Rx SI13 from lower layers
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -423,10 +430,12 @@
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-CFG_UL_TBF.request
 DLGLOBAL INFO UL_TBF{ASSIGN}: state_chg to FLOW
 DLGLOBAL INFO UL_TBF_ASS{COMPLETED}: state_chg to IDLE
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{FLOW}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -484,8 +493,10 @@
 DLGLOBAL INFO UL_TBF{FINISHED}: Timeout of T3182
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{FINISHED}: Deallocated
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -587,8 +598,10 @@
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{FINISHED}: Deallocated
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-PDCH_DATA.request
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GRR-UNITDATA.request
 DLGLOBAL INFO TLLI=0x00002342 not found, creating entity on the fly
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF{NEW}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Received Event START
@@ -650,17 +663,22 @@
 DLGLOBAL INFO UL_TBF_ASS{SCHED_PKT_RES_REQ}: Received Event CREATE_RLCMAC_MSG
 DLGLOBAL INFO UL_TBF_ASS{SCHED_PKT_RES_REQ}: state_chg to WAIT_PKT_UL_ASS
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-PDCH_DATA.request
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF_ASS{WAIT_PKT_UL_ASS}: Deallocated
 DLGLOBAL INFO UL_TBF{ASSIGN}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GMMRR-ASSIGN.request
 DLGLOBAL INFO GMMRR-ASSIGN.req: creating new entity TLLI=0x00000001
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL DEBUG Rx from lower layers: L1CTL-CCCH_DATA.indication
-DLGLOBAL INFO GRE(00000001) Got PCH IMM_ASS (DL_TBF): DL_TFI=0 TS=7
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Received Event RX_CCCH_IMM_ASS
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Got PCH IMM_ASS (DL_TBF): DL_TFI=0 TS=7
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: state_chg to COMPLETED
 DLGLOBAL INFO DL_TBF{NEW}: Allocated
 DLGLOBAL INFO DL_TBF{NEW}: Received Event DL_ASS_COMPL
 DLGLOBAL INFO TBF(DL:NR-0:TLLI-00000001) Send L1CTL-CF_DL_TBF.req 
dl_slotmask=0x80 dl_tfi=0
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-CFG_DL_TBF.request
 DLGLOBAL INFO DL_TBF{NEW}: state_chg to FLOW
+DLGLOBAL INFO DL_TBF_ASS{COMPLETED}: state_chg to IDLE
 DLGLOBAL DEBUG Rx from lower layers: L1CTL-PDCH_DATA.indication
 DLGLOBAL DEBUG TBF(DL:NR-0:TLLI-00000001) Rx new DL data
 DLGLOBAL DEBUG TBF(DL:NR-0:TLLI-00000001) DL DATA TFI=0 received (V(Q)=0 .. 
V(R)=0)
@@ -682,16 +700,21 @@
 DLGLOBAL DEBUG (ts=7,fn=21,usf=0) Tx DL ACK/NACK FinalAck=1
 DLGLOBAL DEBUG TBF(DL:NR-0:TLLI-00000001) - V(N): 
"IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIR" R=Received 
I=Invalid
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-PDCH_DATA.request
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO DL_TBF{FINISHED}: Deallocated
 DLGLOBAL INFO Rx from upper layers: GMMRR-ASSIGN.request
 DLGLOBAL INFO GMMRR-ASSIGN.req: creating new entity TLLI=0x00000001
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Allocated
 DLGLOBAL DEBUG Rx from lower layers: L1CTL-CCCH_DATA.indication
-DLGLOBAL INFO GRE(00000001) Got PCH IMM_ASS (DL_TBF): DL_TFI=0 TS=7
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Received Event RX_CCCH_IMM_ASS
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Got PCH IMM_ASS (DL_TBF): DL_TFI=0 TS=7
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: state_chg to COMPLETED
 DLGLOBAL INFO DL_TBF{NEW}: Allocated
 DLGLOBAL INFO DL_TBF{NEW}: Received Event DL_ASS_COMPL
 DLGLOBAL INFO TBF(DL:NR-0:TLLI-00000001) Send L1CTL-CF_DL_TBF.req 
dl_slotmask=0x80 dl_tfi=0
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-CFG_DL_TBF.request
 DLGLOBAL INFO DL_TBF{NEW}: state_chg to FLOW
+DLGLOBAL INFO DL_TBF_ASS{COMPLETED}: state_chg to IDLE
 DLGLOBAL DEBUG Rx from lower layers: L1CTL-PDCH_DATA.indication
 DLGLOBAL DEBUG TBF(DL:NR-0:TLLI-00000001) Rx new DL data
 DLGLOBAL DEBUG TBF(DL:NR-0:TLLI-00000001) DL DATA TFI=0 received (V(Q)=0 .. 
V(R)=0)
@@ -751,6 +774,7 @@
 DLGLOBAL INFO UL_TBF{FLOW}: Last UL block sent (CV=0), start T3182
 DLGLOBAL INFO UL_TBF{FLOW}: state_chg to FINISHED
 DLGLOBAL DEBUG Tx to lower layers: L1CTL-PDCH_DATA.request
+DLGLOBAL INFO DL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO DL_TBF{FINISHED}: Deallocated
 DLGLOBAL INFO UL_TBF_ASS{IDLE}: Deallocated
 DLGLOBAL INFO UL_TBF{FINISHED}: Deallocated

--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/31757
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Idafb4e37971e93c7e8667b8669a29755485e95bb
Gerrit-Change-Number: 31757
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to