fixeria has uploaded this change for review.

View Change

trxcon/l1sched: pre-populate MR cache during lchan allocation

Instead of checking if the MR cache is populated in prim_compose_mr()
and populating it there, let's do this during lchan allocation. Take
a chance to move lchan allocation logic into its own function.

Change-Id: I079074a402f9c27fff7e25b49bfd1dd409c0f8c3
---
M src/host/trxcon/src/sched_prim.c
M src/host/trxcon/src/sched_trx.c
2 files changed, 28 insertions(+), 30 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/02/41902/1
diff --git a/src/host/trxcon/src/sched_prim.c b/src/host/trxcon/src/sched_prim.c
index fa46d91..95be35e 100644
--- a/src/host/trxcon/src/sched_prim.c
+++ b/src/host/trxcon/src/sched_prim.c
@@ -86,7 +86,6 @@
{
struct l1sched_prim *prim;
struct msgb *msg;
- bool cached;

/* Allocate a new primitive */
msg = l1sched_prim_alloc(L1SCHED_PRIM_T_DATA, PRIM_OP_REQUEST);
@@ -98,13 +97,6 @@
.link_id = L1SCHED_CH_LID_SACCH,
};

- /* Check if the MR cache is populated (verify LAPDm header) */
- cached = (lchan->sacch.mr_cache[2] != 0x00
- && lchan->sacch.mr_cache[3] != 0x00
- && lchan->sacch.mr_cache[4] != 0x00);
- if (!cached) /* populate from the global UL SACCH cache (if needed) */
- l1sched_sacch_cache_read(lchan->ts->sched, lchan->sacch.mr_cache);
-
/* Compose a new Measurement Report primitive */
memcpy(msgb_put(msg, GSM_MACBLOCK_LEN),
&lchan->sacch.mr_cache[0],
diff --git a/src/host/trxcon/src/sched_trx.c b/src/host/trxcon/src/sched_trx.c
index 851d403..58d4c0a 100644
--- a/src/host/trxcon/src/sched_trx.c
+++ b/src/host/trxcon/src/sched_trx.c
@@ -252,13 +252,39 @@
l1sched_cfg_pchan_comb_ind(sched, tn, GSM_PCHAN_NONE);
}

+static struct l1sched_lchan_state *
+l1sched_ts_add_lchan(struct l1sched_ts *ts,
+ enum l1sched_lchan_type type)
+{
+ struct l1sched_lchan_state *lchan;
+
+ lchan = talloc_zero(ts, struct l1sched_lchan_state);
+ if (!lchan)
+ return NULL;
+
+ lchan->type = type;
+ lchan->ts = ts;
+
+ /* Init the Tx queue */
+ INIT_LLIST_HEAD(&lchan->tx_prims);
+ /* Pre-populate UL SACCH cache */
+ l1sched_sacch_cache_read(ts->sched, lchan->sacch.mr_cache);
+ /* Add to the list of channel states */
+ llist_add_tail(&lchan->list, &ts->lchans);
+
+ /* Enable channel automatically if required */
+ if (l1sched_lchan_desc[type].flags & L1SCHED_CH_FLAG_AUTO)
+ l1sched_activate_lchan(ts, type);
+
+ return lchan;
+}
+
#define LAYOUT_HAS_LCHAN(layout, lchan) \
(layout->lchan_mask & ((uint64_t) 0x01 << lchan))

int l1sched_configure_ts(struct l1sched_state *sched, int tn,
enum gsm_phys_chan_config config)
{
- struct l1sched_lchan_state *lchan;
enum l1sched_lchan_type type;
struct l1sched_ts *ts;

@@ -292,27 +318,7 @@
for (type = 0; type < _L1SCHED_CHAN_MAX; type++) {
if (!LAYOUT_HAS_LCHAN(ts->mf_layout, type))
continue;
-
- /* Allocate a channel state */
- lchan = talloc_zero(ts, struct l1sched_lchan_state);
- if (!lchan)
- return -ENOMEM;
-
- /* set backpointer */
- lchan->ts = ts;
-
- /* Set channel type */
- lchan->type = type;
-
- /* Init the Tx queue */
- INIT_LLIST_HEAD(&lchan->tx_prims);
-
- /* Add to the list of channel states */
- llist_add_tail(&lchan->list, &ts->lchans);
-
- /* Enable channel automatically if required */
- if (l1sched_lchan_desc[type].flags & L1SCHED_CH_FLAG_AUTO)
- l1sched_activate_lchan(ts, type);
+ l1sched_ts_add_lchan(ts, type);
}

/* Notify transceiver about TS activation */

To view, visit change 41902. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: I079074a402f9c27fff7e25b49bfd1dd409c0f8c3
Gerrit-Change-Number: 41902
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>