This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
fixeria gerrit-no-reply at lists.osmocom.orgfixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bts/+/24178 )
Change subject: [VAMOS] osmo-bts-trx: move {chan,bid} to trx_{dl,ul}_burst_{req,ind}
......................................................................
[VAMOS] osmo-bts-trx: move {chan,bid} to trx_{dl,ul}_burst_{req,ind}
Change-Id: Ic5a02b074662b3e429bf18e05a982f3f3e7b7444
---
M include/osmo-bts/scheduler.h
M include/osmo-bts/scheduler_backend.h
M src/common/scheduler.c
M src/osmo-bts-trx/sched_lchan_fcch_sch.c
M src/osmo-bts-trx/sched_lchan_pdtch.c
M src/osmo-bts-trx/sched_lchan_rach.c
M src/osmo-bts-trx/sched_lchan_tchf.c
M src/osmo-bts-trx/sched_lchan_tchh.c
M src/osmo-bts-trx/sched_lchan_xcch.c
M src/osmo-bts-trx/scheduler_trx.c
M src/osmo-bts-virtual/scheduler_virtbts.c
11 files changed, 312 insertions(+), 353 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/78/24178/1
diff --git a/include/osmo-bts/scheduler.h b/include/osmo-bts/scheduler.h
index ad6e5c5..2d613e7 100644
--- a/include/osmo-bts/scheduler.h
+++ b/include/osmo-bts/scheduler.h
@@ -249,6 +249,10 @@
uint8_t tsc; /*!< Training Sequence Code */
int16_t ci_cb; /*!< Carrier-to-Interference ratio (in centiBels) */
+ /* Internally used by the scheduler */
+ enum trx_chan_type chan;
+ uint8_t bid;
+
/*! Burst soft-bits buffer */
sbit_t burst[EGPRS_BURST_LEN];
size_t burst_len;
@@ -260,6 +264,10 @@
uint8_t tn; /*!< TDMA timeslot number */
uint8_t att; /*!< Tx power attenuation */
+ /* Internally used by the scheduler */
+ enum trx_chan_type chan;
+ uint8_t bid;
+
/*! Burst hard-bits buffer */
ubit_t burst[EGPRS_BURST_LEN];
size_t burst_len;
diff --git a/include/osmo-bts/scheduler_backend.h b/include/osmo-bts/scheduler_backend.h
index e3326f6..13ca71b 100644
--- a/include/osmo-bts/scheduler_backend.h
+++ b/include/osmo-bts/scheduler_backend.h
@@ -6,14 +6,16 @@
gsm_ts_name(&(l1t)->trx->ts[tn]), \
chan >=0 ? trx_chan_desc[chan].name : "", ## args)
+/* Logging helper adding context from trx_{ul,dl}_burst_{ind,req} */
+#define LOGL1SB(subsys, level, l1t, b, fmt, args ...) \
+ LOGL1S(subsys, level, l1t, (b)->tn, (b)->chan, (b)->fn, fmt, ## args)
+
typedef int trx_sched_rts_func(struct l1sched_trx *l1t, uint8_t tn,
uint32_t fn, enum trx_chan_type chan);
-typedef int trx_sched_dl_func(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
+typedef int trx_sched_dl_func(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
-typedef int trx_sched_ul_func(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi);
+typedef int trx_sched_ul_func(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi);
struct trx_chan_desc {
/*! \brief Human-readable name */
@@ -40,8 +42,8 @@
extern const ubit_t _sched_egprs_tsc[8][78];
extern const ubit_t _sched_sch_train[64];
-struct msgb *_sched_dequeue_prim(struct l1sched_trx *l1t, int8_t tn, uint32_t fn,
- enum trx_chan_type chan);
+struct msgb *_sched_dequeue_prim(struct l1sched_trx *l1t,
+ const struct trx_dl_burst_req *br);
int _sched_compose_ph_data_ind(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
enum trx_chan_type chan, uint8_t *l2,
@@ -55,31 +57,19 @@
int16_t ta_offs_256bits, uint16_t ber10k, float rssi,
uint8_t is_sub);
-int tx_idle_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
-int tx_fcch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
-int tx_sch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
-int tx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
-int tx_pdtch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
-int tx_tchf_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
-int tx_tchh_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br);
+int tx_idle_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
+int tx_fcch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
+int tx_sch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
+int tx_data_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
+int tx_pdtch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
+int tx_tchf_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
+int tx_tchh_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
-int rx_rach_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi);
-int rx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi);
-int rx_pdtch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi);
-int rx_tchf_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi);
-int rx_tchh_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi);
+int rx_rach_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi);
+int rx_data_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi);
+int rx_pdtch_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi);
+int rx_tchf_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi);
+int rx_tchh_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi);
void _sched_dl_burst(struct l1sched_trx *l1t, struct trx_dl_burst_req *br);
int _sched_rts(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn);
diff --git a/src/common/scheduler.c b/src/common/scheduler.c
index c7c3e62..87a1f60 100644
--- a/src/common/scheduler.c
+++ b/src/common/scheduler.c
@@ -637,13 +637,13 @@
}
}
-struct msgb *_sched_dequeue_prim(struct l1sched_trx *l1t, int8_t tn, uint32_t fn,
- enum trx_chan_type chan)
+struct msgb *_sched_dequeue_prim(struct l1sched_trx *l1t,
+ const struct trx_dl_burst_req *br)
{
struct msgb *msg, *msg2;
uint32_t prim_fn, l1sap_fn;
uint8_t chan_nr, link_id;
- struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
+ struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
/* get prim of current fn from queue */
llist_for_each_entry_safe(msg, msg2, &l1ts->dl_prims, list) {
@@ -660,18 +660,18 @@
l1sap_fn = l1sap->u.tch.fn;
break;
default:
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Prim has wrong type.\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Prim has wrong type.\n");
goto free_msg;
}
- prim_fn = GSM_TDMA_FN_SUB(l1sap_fn, fn);
+ prim_fn = GSM_TDMA_FN_SUB(l1sap_fn, br->fn);
if (prim_fn > 100) { /* l1sap_fn < fn */
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br,
"Prim %u is out of range (%u vs exp %u), or channel %s with "
"type %s is already disabled. If this happens in "
"conjunction with PCU, increase 'rts-advance' by 5.\n",
- prim_fn, l1sap_fn, fn,
+ prim_fn, l1sap_fn, br->fn,
get_lchan_by_chan_nr(l1t->trx, chan_nr)->name,
- trx_chan_desc[chan].name);
+ trx_chan_desc[br->chan].name);
rate_ctr_inc2(l1ts->ctrs, L1SCHED_TS_CTR_DL_LATE);
/* unlink and free message */
llist_del(&msg->list);
@@ -682,11 +682,11 @@
break;
/* l1sap_fn == fn */
- if ((chan_nr ^ (trx_chan_desc[chan].chan_nr | tn))
- || ((link_id & 0xc0) ^ trx_chan_desc[chan].link_id)) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Prim has wrong chan_nr=0x%02x link_id=%02x, "
+ if ((chan_nr ^ (trx_chan_desc[br->chan].chan_nr | br->tn))
+ || ((link_id & 0xc0) ^ trx_chan_desc[br->chan].link_id)) {
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Prim has wrong chan_nr=0x%02x link_id=%02x, "
"expecting chan_nr=0x%02x link_id=%02x.\n", chan_nr, link_id,
- trx_chan_desc[chan].chan_nr | tn, trx_chan_desc[chan].link_id);
+ trx_chan_desc[br->chan].chan_nr | br->tn, trx_chan_desc[br->chan].link_id);
goto free_msg;
}
@@ -1209,9 +1209,8 @@
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct l1sched_chan_state *l1cs;
const struct trx_sched_frame *frame;
- uint8_t offset, period, bid;
+ uint8_t offset, period;
trx_sched_dl_func *func;
- enum trx_chan_type chan;
if (!l1ts->mf_index)
return;
@@ -1221,18 +1220,18 @@
offset = br->fn % period;
frame = l1ts->mf_frames + offset;
- chan = frame->dl_chan;
- bid = frame->dl_bid;
- func = trx_chan_desc[chan].dl_fn;
+ br->chan = frame->dl_chan;
+ br->bid = frame->dl_bid;
+ func = trx_chan_desc[br->chan].dl_fn;
- l1cs = &l1ts->chan_state[chan];
+ l1cs = &l1ts->chan_state[br->chan];
/* check if channel is active */
- if (!TRX_CHAN_IS_ACTIVE(l1cs, chan))
+ if (!TRX_CHAN_IS_ACTIVE(l1cs, br->chan))
return;
/* get burst from function */
- if (func(l1t, chan, bid, br) != 0)
+ if (func(l1t, br) != 0)
return;
/* BS Power reduction (in dB) per logical channel */
@@ -1253,9 +1252,9 @@
}
static int trx_sched_calc_frame_loss(struct l1sched_trx *l1t,
- struct l1sched_chan_state *l1cs, uint8_t tn, uint32_t fn)
+ struct l1sched_chan_state *l1cs,
+ const struct trx_ul_burst_ind *bi)
{
- const struct trx_sched_frame *frame_head;
const struct trx_sched_frame *frame;
struct l1sched_ts *l1ts;
uint32_t elapsed_fs;
@@ -1271,12 +1270,10 @@
return 0;
/* Get current TDMA frame info */
- l1ts = l1sched_trx_get_ts(l1t, tn);
- offset = fn % l1ts->mf_period;
- frame_head = l1ts->mf_frames + offset;
+ l1ts = l1sched_trx_get_ts(l1t, bi->tn);
/* Not applicable for some logical channels */
- switch (frame_head->ul_chan) {
+ switch (bi->chan) {
case TRXC_IDLE:
case TRXC_RACH:
case TRXC_PDTCH:
@@ -1289,9 +1286,9 @@
}
/* How many frames elapsed since the last one? */
- elapsed_fs = GSM_TDMA_FN_SUB(fn, l1cs->last_tdma_fn);
+ elapsed_fs = GSM_TDMA_FN_SUB(bi->fn, l1cs->last_tdma_fn);
if (elapsed_fs > l1ts->mf_period) { /* Too many! */
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, frame_head->ul_chan, fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"Too many (>%u) contiguous TDMA frames=%u elapsed "
"since the last processed fn=%u\n", l1ts->mf_period,
elapsed_fs, l1cs->last_tdma_fn);
@@ -1312,12 +1309,12 @@
offset = fn_i % l1ts->mf_period;
frame = l1ts->mf_frames + offset;
- if (frame->ul_chan == frame_head->ul_chan)
+ if (frame->ul_chan == bi->chan)
l1cs->lost_tdma_fs++;
}
if (l1cs->lost_tdma_fs > 0) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, frame_head->ul_chan, fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi,
"At least %u TDMA frames were lost since the last "
"processed fn=%u\n", l1cs->lost_tdma_fs, l1cs->last_tdma_fn);
@@ -1330,14 +1327,15 @@
trx_sched_ul_func *func;
/* Prepare dummy burst indication */
- struct trx_ul_burst_ind bi = {
+ struct trx_ul_burst_ind dbi = {
.flags = TRX_BI_F_NOPE_IND,
.burst_len = GSM_BURST_LEN,
.burst = { 0 },
.rssi = -128,
.toa256 = 0,
+ .chan = bi->chan,
/* TDMA FN is set below */
- .tn = tn,
+ .tn = bi->tn,
};
for (i = 1; i < elapsed_fs; i++) {
@@ -1346,15 +1344,16 @@
frame = l1ts->mf_frames + offset;
func = trx_chan_desc[frame->ul_chan].ul_fn;
- if (frame->ul_chan != frame_head->ul_chan)
+ if (frame->ul_chan != bi->chan)
continue;
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, frame->ul_chan, fn,
- "Substituting lost TDMA frame=%u by all-zero "
- "dummy burst\n", fn_i);
+ dbi.bid = frame->ul_bid;
+ dbi.fn = fn_i;
- bi.fn = fn_i;
- func(l1t, frame->ul_chan, frame->ul_bid, &bi);
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, &dbi,
+ "Substituting lost burst with NOPE.ind\n");
+
+ func(l1t, &dbi);
l1cs->lost_tdma_fs--;
}
@@ -1369,9 +1368,8 @@
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, bi->tn);
struct l1sched_chan_state *l1cs;
const struct trx_sched_frame *frame;
- uint8_t offset, period, bid;
+ uint8_t offset, period;
trx_sched_ul_func *func;
- enum trx_chan_type chan;
if (!l1ts->mf_index)
return -EINVAL;
@@ -1381,20 +1379,19 @@
offset = bi->fn % period;
frame = l1ts->mf_frames + offset;
- chan = frame->ul_chan;
- bid = frame->ul_bid;
- l1cs = &l1ts->chan_state[chan];
- func = trx_chan_desc[chan].ul_fn;
+ bi->chan = frame->ul_chan;
+ bi->bid = frame->ul_bid;
+ l1cs = &l1ts->chan_state[bi->chan];
+ func = trx_chan_desc[bi->chan].ul_fn;
/* TODO: handle noise measurements */
- if (chan == TRXC_IDLE && bi->flags & TRX_BI_F_NOPE_IND) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Rx noise measurement (%d)\n", bi->rssi);
+ if (bi->chan == TRXC_IDLE && bi->flags & TRX_BI_F_NOPE_IND) {
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Rx noise measurement (%d)\n", bi->rssi);
return -ENOTSUP;
}
/* check if channel is active */
- if (!TRX_CHAN_IS_ACTIVE(l1cs, chan))
+ if (!TRX_CHAN_IS_ACTIVE(l1cs, bi->chan))
return -EINVAL;
/* omit bursts which have no handler, like IDLE bursts */
@@ -1402,7 +1399,7 @@
return -EINVAL;
/* calculate how many TDMA frames were potentially lost */
- trx_sched_calc_frame_loss(l1t, l1cs, bi->tn, bi->fn);
+ trx_sched_calc_frame_loss(l1t, l1cs, bi);
/* update TDMA frame counters */
l1cs->last_tdma_fn = bi->fn;
@@ -1410,7 +1407,7 @@
/* handle NOPE indications */
if (bi->flags & TRX_BI_F_NOPE_IND) {
- switch (chan) {
+ switch (bi->chan) {
case TRXC_PTCCH:
case TRXC_RACH:
/* For some logical channel types NOPE.ind is valueless. */
@@ -1418,7 +1415,7 @@
default:
/* NOTE: Uplink burst handler must check bi->burst_len before
* accessing bi->burst to avoid uninitialized memory access. */
- return func(l1t, chan, bid, bi);
+ return func(l1t, bi);
}
}
@@ -1437,7 +1434,7 @@
}
/* Invoke the logical channel handler */
- func(l1t, chan, bid, bi);
+ func(l1t, bi);
return 0;
}
diff --git a/src/osmo-bts-trx/sched_lchan_fcch_sch.c b/src/osmo-bts-trx/sched_lchan_fcch_sch.c
index 2a5e482..4aac601 100644
--- a/src/osmo-bts-trx/sched_lchan_fcch_sch.c
+++ b/src/osmo-bts-trx/sched_lchan_fcch_sch.c
@@ -1,6 +1,7 @@
/*
* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
* (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
+ * Contributions by sysmocom - s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -35,10 +36,9 @@
#include <sched_utils.h>
/* obtain a to-be-transmitted FCCH (frequency correction channel) burst */
-int tx_fcch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_fcch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting FCCH\n");
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting FCCH\n");
/* A frequency correction burst is basically a sequence of zeros.
* Since br->burst is already zero-initialized, just set the length. */
@@ -48,15 +48,14 @@
}
/* obtain a to-be-transmitted SCH (synchronization channel) burst */
-int tx_sch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_sch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
ubit_t burst[78];
uint8_t sb_info[4];
struct gsm_time t;
uint8_t t3p, bsic;
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting SCH\n");
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting SCH\n");
/* BURST BYPASS */
diff --git a/src/osmo-bts-trx/sched_lchan_pdtch.c b/src/osmo-bts-trx/sched_lchan_pdtch.c
index d936f75..7ccc77a 100644
--- a/src/osmo-bts-trx/sched_lchan_pdtch.c
+++ b/src/osmo-bts-trx/sched_lchan_pdtch.c
@@ -1,6 +1,7 @@
/*
* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
* (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
+ * Contributions by sysmocom - s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -38,11 +39,10 @@
#define EGPRS_0503_MAX_BYTES 155
/*! \brief a single PDTCH burst was received by the PHY, process it */
-int rx_pdtch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_pdtch_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, bi->tn);
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
uint32_t first_fn;
uint8_t *mask = &chan_state->ul_mask;
@@ -55,8 +55,7 @@
int rc;
enum osmo_ph_pres_info_type presence_info;
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received PDTCH bid=%u\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received PDTCH bid=%u\n", bi->bid);
/* allocate burst memory, if not already */
if (!*bursts_p) {
@@ -67,13 +66,13 @@
}
/* clear burst */
- if (bid == 0) {
+ if (bi->bid == 0) {
memset(*bursts_p, 0, GSM0503_EGPRS_BURSTS_NBITS);
*mask = 0x0;
}
/* update mask */
- *mask |= (1 << bid);
+ *mask |= (1 << bi->bid);
/* store measurements */
trx_sched_meas_push(chan_state, bi);
@@ -81,26 +80,26 @@
/* copy burst to buffer of 4 bursts */
switch (bi->burst_len) {
case EGPRS_BURST_LEN:
- burst = *bursts_p + bid * 348;
+ burst = *bursts_p + bi->bid * 348;
memcpy(burst, bi->burst + 9, 174);
memcpy(burst + 174, bi->burst + 261, 174);
n_bursts_bits = GSM0503_EGPRS_BURSTS_NBITS;
break;
case GSM_BURST_LEN:
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + bi->bid * 116;
memcpy(burst, bi->burst + 3, 58);
memcpy(burst + 58, bi->burst + 87, 58);
n_bursts_bits = GSM0503_GPRS_BURSTS_NBITS;
break;
case 0:
/* NOPE.ind, assume GPRS? */
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + bi->bid * 116;
memset(burst, 0, 116);
n_bursts_bits = GSM0503_GPRS_BURSTS_NBITS;
}
/* wait until complete set of bursts */
- if (bid != 3)
+ if (bi->bid != 3)
return 0;
/* average measurements of the last 4 bursts */
@@ -108,8 +107,7 @@
/* check for complete set of bursts */
if ((*mask & 0xf) != 0xf) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received incomplete frame (%u/%u)\n",
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received incomplete frame (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
}
*mask = 0x0;
@@ -131,8 +129,7 @@
if (rc > 0) {
presence_info = PRES_INFO_BOTH;
} else {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received bad PDTCH (%u/%u)\n",
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received bad PDTCH (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
rc = 0;
presence_info = PRES_INFO_INVALID;
@@ -142,36 +139,35 @@
first_fn = GSM_TDMA_FN_SUB(bi->fn, 3);
return _sched_compose_ph_data_ind(l1t, bi->tn,
- first_fn, chan, l2, rc,
+ first_fn, bi->chan, l2, rc,
meas_avg.rssi, meas_avg.toa256,
meas_avg.ci_cb, ber10k,
presence_info);
}
/* obtain a to-be-transmitted PDTCH (packet data) burst */
-int tx_pdtch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_pdtch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct gsm_bts_trx_ts *ts = &l1t->trx->ts[br->tn];
struct msgb *msg = NULL; /* make GCC happy */
- ubit_t *burst, **bursts_p = &l1ts->chan_state[chan].dl_bursts;
- enum trx_mod_type *mod = &l1ts->chan_state[chan].dl_mod_type;
+ ubit_t *burst, **bursts_p = &l1ts->chan_state[br->chan].dl_bursts;
+ enum trx_mod_type *mod = &l1ts->chan_state[br->chan].dl_mod_type;
int rc = 0;
/* send burst, if we already got a frame */
- if (bid > 0) {
+ if (br->bid > 0) {
if (!*bursts_p)
return 0;
goto send_burst;
}
/* get mac block from queue */
- msg = _sched_dequeue_prim(l1t, br->tn, br->fn, chan);
+ msg = _sched_dequeue_prim(l1t, br);
if (msg)
goto got_msg;
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "No prim for transmit.\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "No prim for transmit.\n");
no_msg:
/* free burst memory */
@@ -199,7 +195,7 @@
/* check validity of message */
if (rc < 0) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, br->tn, chan, br->fn, "Prim invalid length, please FIX! "
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "Prim invalid length, please FIX! "
"(len=%ld)\n", (long)(msg->tail - msg->l2h));
/* free message */
msgb_free(msg);
@@ -216,7 +212,7 @@
send_burst:
/* compose burst */
if (*mod == TRX_MOD_T_8PSK) {
- burst = *bursts_p + bid * 348;
+ burst = *bursts_p + br->bid * 348;
memset(br->burst, 1, 9);
memcpy(br->burst + 9, burst, 174);
memcpy(br->burst + 183, _sched_egprs_tsc[gsm_ts_tsc(ts)], 78);
@@ -225,7 +221,7 @@
br->burst_len = EGPRS_BURST_LEN;
} else {
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + br->bid * 116;
memcpy(br->burst + 3, burst, 58);
memcpy(br->burst + 61, _sched_tsc[gsm_ts_tsc(ts)], 26);
memcpy(br->burst + 87, burst + 58, 58);
@@ -233,7 +229,7 @@
br->burst_len = GSM_BURST_LEN;
}
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting burst=%u.\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting burst=%u.\n", br->bid);
return 0;
}
diff --git a/src/osmo-bts-trx/sched_lchan_rach.c b/src/osmo-bts-trx/sched_lchan_rach.c
index fa50f14..ce9a46b 100644
--- a/src/osmo-bts-trx/sched_lchan_rach.c
+++ b/src/osmo-bts-trx/sched_lchan_rach.c
@@ -2,6 +2,7 @@
* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
* (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
* (C) 2019 by Vadim Yanitskiy <axilirator at gmail.com>
+ * Contributions by sysmocom - s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -101,8 +102,7 @@
return seq;
}
-int rx_rach_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_rach_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
struct osmo_phsap_prim l1sap;
int n_errors = 0;
@@ -123,16 +123,16 @@
/* If logical channel is not either of RACH, PDTCH or PTCCH, this is a
* handover Access Burst, which is always encoded as 8-bit and shall
* contain the generic training sequence (TS0). */
- if (chan == TRXC_RACH || chan == TRXC_PDTCH || chan == TRXC_PTCCH) {
+ if (bi->chan == TRXC_RACH || bi->chan == TRXC_PDTCH || bi->chan == TRXC_PTCCH) {
if (bi->flags & TRX_BI_F_TS_INFO)
synch_seq = (enum rach_synch_seq_t) bi->tsc;
else
synch_seq = rach_get_synch_seq((sbit_t *) bi->burst, &best_score);
}
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi,
"Received%s RACH (%s): rssi=%d toa256=%d",
- (chan != TRXC_RACH) ? " handover" : "",
+ (bi->chan != TRXC_RACH) ? " handover" : "",
get_value_string(rach_synch_seq_names, synch_seq),
bi->rssi, bi->toa256);
if (bi->flags & TRX_BI_F_CI_CB)
@@ -145,7 +145,7 @@
/* Compose a new L1SAP primitive */
memset(&l1sap, 0x00, sizeof(l1sap));
osmo_prim_init(&l1sap.oph, SAP_GSM_PH, PRIM_PH_RACH, PRIM_OP_INDICATION, NULL);
- l1sap.u.rach_ind.chan_nr = trx_chan_desc[chan].chan_nr | bi->tn;
+ l1sap.u.rach_ind.chan_nr = trx_chan_desc[bi->chan].chan_nr | bi->tn;
l1sap.u.rach_ind.acc_delay = (bi->toa256 >= 0) ? bi->toa256 / 256 : 0;
l1sap.u.rach_ind.acc_delay_256bits = bi->toa256;
l1sap.u.rach_ind.rssi = bi->rssi;
@@ -166,8 +166,7 @@
rc = gsm0503_rach_ext_decode_ber(&ra11, bi->burst + RACH_EXT_TAIL_LEN + RACH_SYNCH_SEQ_LEN,
l1t->trx->bts->bsic, &n_errors, &n_bits_total);
if (rc) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received bad Access Burst\n");
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received bad Access Burst\n");
return 0;
}
@@ -184,16 +183,14 @@
default:
/* Fall-back to the default TS0 if needed */
if (synch_seq != RACH_SYNCH_SEQ_TS0) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Falling-back to the default TS0\n");
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Falling-back to the default TS0\n");
synch_seq = RACH_SYNCH_SEQ_TS0;
}
rc = gsm0503_rach_decode_ber(&ra, bi->burst + RACH_EXT_TAIL_LEN + RACH_SYNCH_SEQ_LEN,
l1t->trx->bts->bsic, &n_errors, &n_bits_total);
if (rc) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received bad Access Burst\n");
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received bad Access Burst\n");
return 0;
}
diff --git a/src/osmo-bts-trx/sched_lchan_tchf.c b/src/osmo-bts-trx/sched_lchan_tchf.c
index b1453dc..8ace49e 100644
--- a/src/osmo-bts-trx/sched_lchan_tchf.c
+++ b/src/osmo-bts-trx/sched_lchan_tchf.c
@@ -1,6 +1,7 @@
/*
* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
* (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
+ * Contributions by sysmocom - s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -45,11 +46,10 @@
#include <loops.h>
/*! \brief a single TCH/F burst was received by the PHY, process it */
-int rx_tchf_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_tchf_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, bi->tn);
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
struct gsm_lchan *lchan = chan_state->lchan;
sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
uint8_t *mask = &chan_state->ul_mask;
@@ -70,10 +70,9 @@
/* If handover RACH detection is turned on, treat this burst as an Access Burst.
* Handle NOPE.ind as usually to ensure proper Uplink measurement reporting. */
if (chan_state->ho_rach_detect == 1 && ~bi->flags & TRX_BI_F_NOPE_IND)
- return rx_rach_fn(l1t, chan, bid, bi);
+ return rx_rach_fn(l1t, bi);
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received TCH/F, bid=%u\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received TCH/F, bid=%u\n", bi->bid);
/* allocate burst memory, if not already */
if (!*bursts_p) {
@@ -83,19 +82,19 @@
}
/* clear burst */
- if (bid == 0) {
+ if (bi->bid == 0) {
memset(*bursts_p + 464, 0, 464);
*mask = 0x0;
}
/* update mask */
- *mask |= (1 << bid);
+ *mask |= (1 << bi->bid);
/* store measurements */
trx_sched_meas_push(chan_state, bi);
/* copy burst to end of buffer of 8 bursts */
- burst = *bursts_p + bid * 116 + 464;
+ burst = *bursts_p + bi->bid * 116 + 464;
if (bi->burst_len > 0) {
memcpy(burst, bi->burst + 3, 58);
memcpy(burst + 58, bi->burst + 87, 58);
@@ -103,12 +102,12 @@
memset(burst, 0, 116);
/* wait until complete set of bursts */
- if (bid != 3)
+ if (bi->bid != 3)
return 0;
/* check for complete set of bursts */
if ((*mask & 0xf) != 0xf) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi,
"Received incomplete frame (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
}
@@ -153,8 +152,7 @@
/* Tag all frames that are not regular AMR voice frames as
* SUB-Frames */
if (chan_state->amr_last_dtx != AMR_OTHER) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received AMR SID frame: %s\n",
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received AMR SID frame: %s\n",
gsm0503_amr_dtx_frame_name(chan_state->amr_last_dtx));
is_sub = 1;
}
@@ -186,7 +184,7 @@
if (rc)
trx_loop_amr_input(l1t,
- trx_chan_desc[chan].chan_nr | bi->tn, chan_state,
+ trx_chan_desc[bi->chan].chan_nr | bi->tn, chan_state,
n_errors, n_bits_total);
/* only good speech frames get rtp header */
if (rc != GSM_MACBLOCK_LEN && rc >= 4) {
@@ -203,7 +201,7 @@
break;
default:
- LOGL1S(DL1P, LOGL_ERROR, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"TCH mode %u invalid, please fix!\n",
tch_mode);
return -EINVAL;
@@ -215,12 +213,11 @@
/* Check if the frame is bad */
if (rc < 0) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
- "Received bad data (%u/%u)\n",
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi, "Received bad data (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
bfi_flag = true;
} else if (rc < 4) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi,
"Received bad data (%u/%u) with invalid codec mode %d\n",
bi->fn % l1ts->mf_period, l1ts->mf_period, rc);
bfi_flag = true;
@@ -236,7 +233,7 @@
/* FACCH */
if (rc == GSM_MACBLOCK_LEN) {
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_F);
- _sched_compose_ph_data_ind(l1t, bi->tn, fn_begin, chan,
+ _sched_compose_ph_data_ind(l1t, bi->tn, fn_begin, bi->chan,
tch_data + amr, GSM_MACBLOCK_LEN,
meas_avg.rssi, meas_avg.toa256,
meas_avg.ci_cb, ber10k,
@@ -284,7 +281,7 @@
chan_state->codec[chan_state->dl_ft],
AMR_BAD);
if (rc < 2) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"Failed to encode AMR_BAD frame (rc=%d), "
"not sending BFI\n", rc);
return -EINVAL;
@@ -292,7 +289,7 @@
memset(tch_data + 2, 0, rc - 2);
break;
default:
- LOGL1S(DL1P, LOGL_ERROR, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"TCH mode %u invalid, please fix!\n", tch_mode);
return -EINVAL;
}
@@ -305,7 +302,7 @@
/* TCH or BFI */
compose_l1sap:
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_TCH_F);
- return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, chan, tch_data, rc,
+ return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, bi->chan, tch_data, rc,
/* FIXME: what should we use for BFI here? */
bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,
bfi_flag ? bi->rssi : meas_avg.rssi, is_sub);
@@ -313,13 +310,12 @@
/* common section for generation of TCH bursts (TCH/H and TCH/F).
* FIXME: this function is over-complicated, refactor / get rid of it. */
-void tx_tch_common(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, uint8_t bid,
+void tx_tch_common(struct l1sched_trx *l1t, struct trx_dl_burst_req *br,
struct msgb **_msg_tch, struct msgb **_msg_facch)
{
- struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
+ struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct msgb *msg1, *msg2, *msg_tch = NULL, *msg_facch = NULL;
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
uint8_t rsl_cmode = chan_state->rsl_cmode;
uint8_t tch_mode = chan_state->tch_mode;
struct osmo_phsap_prim *l1sap;
@@ -330,13 +326,12 @@
uint8_t tch_data[GSM_FR_BYTES];
int len;
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn,
- "Missing TCH bursts detected, sending BFI\n");
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br, "Missing TCH bursts detected, sending BFI\n");
/* indicate bad frame */
switch (tch_mode) {
case GSM48_CMODE_SPEECH_V1: /* FR / HR */
- if (chan != TRXC_TCHF) { /* HR */
+ if (br->chan != TRXC_TCHF) { /* HR */
tch_data[0] = 0x70; /* F = 0, FT = 111 */
memset(tch_data + 1, 0, 14);
len = 15;
@@ -346,7 +341,7 @@
len = GSM_FR_BYTES;
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
- if (chan != TRXC_TCHF)
+ if (br->chan != TRXC_TCHF)
goto inval_mode1;
memset(tch_data, 0, GSM_EFR_BYTES);
len = GSM_EFR_BYTES;
@@ -356,29 +351,30 @@
chan_state->codec[chan_state->dl_cmr],
chan_state->codec[chan_state->dl_ft], AMR_BAD);
if (len < 2) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn,
- "Failed to encode AMR_BAD frame (rc=%d), "
- "not sending BFI\n", len);
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br,
+ "Failed to encode AMR_BAD frame (rc=%d), "
+ "not sending BFI\n", len);
return;
}
memset(tch_data + 2, 0, len - 2);
break;
default:
inval_mode1:
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "TCH mode invalid, please fix!\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "TCH mode invalid, please fix!\n");
len = 0;
}
if (len) {
/* Note: RSSI/ToA256 is set to 0 to indicate to the higher
* layers that this is a faked tch_ind */
- _sched_compose_tch_ind(l1t, tn, fn, chan, tch_data, len, 0, 10000, 0, 0);
+ _sched_compose_tch_ind(l1t, br->tn, br->fn, br->chan,
+ tch_data, len, 0, 10000, 0, 0);
}
}
/* get frame and unlink from queue */
- msg1 = _sched_dequeue_prim(l1t, tn, fn, chan);
- msg2 = _sched_dequeue_prim(l1t, tn, fn, chan);
+ msg1 = _sched_dequeue_prim(l1t, br);
+ msg2 = _sched_dequeue_prim(l1t, br);
if (msg1) {
l1sap = msgb_l1sap_prim(msg1);
if (l1sap->oph.primitive == PRIM_TCH) {
@@ -386,8 +382,7 @@
if (msg2) {
l1sap = msgb_l1sap_prim(msg2);
if (l1sap->oph.primitive == PRIM_TCH) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, tn, chan, fn,
- "TCH twice, please FIX!\n");
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "TCH twice, please FIX!\n");
msgb_free(msg2);
} else
msg_facch = msg2;
@@ -397,8 +392,7 @@
if (msg2) {
l1sap = msgb_l1sap_prim(msg2);
if (l1sap->oph.primitive != PRIM_TCH) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, tn, chan, fn,
- "FACCH twice, please FIX!\n");
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "FACCH twice, please FIX!\n");
msgb_free(msg2);
} else
msg_tch = msg2;
@@ -414,8 +408,8 @@
/* check validity of message */
if (msg_facch && msgb_l2len(msg_facch) != GSM_MACBLOCK_LEN) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, tn, chan, fn, "Prim not 23 bytes, please FIX! "
- "(len=%d)\n", msgb_l2len(msg_facch));
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "Prim has odd len=%u != %u\n",
+ msgb_l2len(msg_facch), GSM_MACBLOCK_LEN);
/* free message */
msgb_free(msg_facch);
msg_facch = NULL;
@@ -431,20 +425,20 @@
int8_t sti, cmi;
if (rsl_cmode != RSL_CMOD_SPD_SPEECH) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Dropping speech frame, "
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br, "Dropping speech frame, "
"because we are not in speech mode\n");
goto free_bad_msg;
}
switch (tch_mode) {
case GSM48_CMODE_SPEECH_V1: /* FR / HR */
- if (chan != TRXC_TCHF) /* HR */
+ if (br->chan != TRXC_TCHF) /* HR */
len = 15;
else
len = GSM_FR_BYTES;
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
- if (chan != TRXC_TCHF)
+ if (br->chan != TRXC_TCHF)
goto inval_mode2;
len = GSM_EFR_BYTES;
break;
@@ -469,33 +463,32 @@
trx_loop_amr_set(chan_state, 1);
}
if (ft < 0) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br,
"Codec (FT = %d) of RTP frame not in list\n", ft_codec);
goto free_bad_msg;
}
- if (fn_is_codec_mode_request(fn) && chan_state->dl_ft != ft) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Codec (FT = %d) "
+ if (fn_is_codec_mode_request(br->fn) && chan_state->dl_ft != ft) {
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br, "Codec (FT = %d) "
" of RTP cannot be changed now, but in next frame\n", ft_codec);
goto free_bad_msg;
}
chan_state->dl_ft = ft;
if (bfi == AMR_BAD) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn,
- "Transmitting 'bad AMR frame'\n");
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br, "Transmitting 'bad AMR frame'\n");
goto free_bad_msg;
}
break;
default:
inval_mode2:
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "TCH mode invalid, please fix!\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "TCH mode invalid, please fix!\n");
goto free_bad_msg;
}
if (len < 0) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Cannot send invalid AMR payload\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Cannot send invalid AMR payload\n");
goto free_bad_msg;
}
if (msgb_l2len(msg_tch) != len) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Cannot send payload with "
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Cannot send payload with "
"invalid length! (expecting %d, received %d)\n",
len, msgb_l2len(msg_tch));
free_bad_msg:
@@ -512,24 +505,23 @@
}
/* obtain a to-be-transmitted TCH/F (Full Traffic Channel) burst */
-int tx_tchf_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_tchf_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct msgb *msg_tch = NULL, *msg_facch = NULL;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct gsm_bts_trx_ts *ts = &l1t->trx->ts[br->tn];
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
uint8_t tch_mode = chan_state->tch_mode;
ubit_t *burst, **bursts_p = &chan_state->dl_bursts;
/* send burst, if we already got a frame */
- if (bid > 0) {
+ if (br->bid > 0) {
if (!*bursts_p)
return 0;
goto send_burst;
}
- tx_tch_common(l1t, br->tn, br->fn, chan, bid, &msg_tch, &msg_facch);
+ tx_tch_common(l1t, br, &msg_tch, &msg_facch);
/* BURST BYPASS */
@@ -546,7 +538,7 @@
/* no message at all */
if (!msg_tch && !msg_facch) {
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "No TCH or FACCH prim for transmit.\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "No TCH or FACCH prim for transmit.\n");
goto send_burst;
}
@@ -574,14 +566,14 @@
send_burst:
/* compose burst */
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + br->bid * 116;
memcpy(br->burst + 3, burst, 58);
memcpy(br->burst + 61, _sched_tsc[gsm_ts_tsc(ts)], 26);
memcpy(br->burst + 87, burst + 58, 58);
br->burst_len = GSM_BURST_LEN;
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting burst=%u.\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting burst=%u.\n", br->bid);
return 0;
}
diff --git a/src/osmo-bts-trx/sched_lchan_tchh.c b/src/osmo-bts-trx/sched_lchan_tchh.c
index 378d47a..ca05844 100644
--- a/src/osmo-bts-trx/sched_lchan_tchh.c
+++ b/src/osmo-bts-trx/sched_lchan_tchh.c
@@ -1,6 +1,7 @@
/*
* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
* (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
+ * Contributions by sysmocom - s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -45,11 +46,10 @@
#include <loops.h>
/*! \brief a single TCH/H burst was received by the PHY, process it */
-int rx_tchh_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_tchh_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, bi->tn);
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
struct gsm_lchan *lchan = chan_state->lchan;
sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
uint8_t *mask = &chan_state->ul_mask;
@@ -77,10 +77,9 @@
/* If handover RACH detection is turned on, treat this burst as an Access Burst.
* Handle NOPE.ind as usually to ensure proper Uplink measurement reporting. */
if (chan_state->ho_rach_detect == 1 && ~bi->flags & TRX_BI_F_NOPE_IND)
- return rx_rach_fn(l1t, chan, bid, bi);
+ return rx_rach_fn(l1t, bi);
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received TCH/H, bid=%u\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received TCH/H, bid=%u\n", bi->bid);
/* allocate burst memory, if not already */
if (!*bursts_p) {
@@ -90,19 +89,19 @@
}
/* clear burst */
- if (bid == 0) {
+ if (bi->bid == 0) {
memset(*bursts_p + 464, 0, 232);
*mask = 0x0;
}
/* update mask */
- *mask |= (1 << bid);
+ *mask |= (1 << bi->bid);
/* store measurements */
trx_sched_meas_push(chan_state, bi);
/* copy burst to end of buffer of 6 bursts */
- burst = *bursts_p + bid * 116 + 464;
+ burst = *bursts_p + bi->bid * 116 + 464;
if (bi->burst_len > 0) {
memcpy(burst, bi->burst + 3, 58);
memcpy(burst + 58, bi->burst + 87, 58);
@@ -110,12 +109,12 @@
memset(burst, 0, 116);
/* wait until complete set of bursts */
- if (bid != 1)
+ if (bi->bid != 1)
return 0;
/* check for complete set of bursts */
if ((*mask & 0x3) != 0x3) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi,
"Received incomplete frame (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
}
@@ -176,9 +175,8 @@
/* Tag all frames that are not regular AMR voice frames
as SUB-Frames */
if (chan_state->amr_last_dtx != AMR_OTHER) {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received AMR SID frame: %s\n",
- gsm0503_amr_dtx_frame_name(chan_state->amr_last_dtx));
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received AMR SID frame: %s\n",
+ gsm0503_amr_dtx_frame_name(chan_state->amr_last_dtx));
is_sub = 1;
}
@@ -209,7 +207,7 @@
if (rc)
trx_loop_amr_input(l1t,
- trx_chan_desc[chan].chan_nr | bi->tn, chan_state,
+ trx_chan_desc[bi->chan].chan_nr | bi->tn, chan_state,
n_errors, n_bits_total);
/* only good speech frames get rtp header */
@@ -227,7 +225,7 @@
break;
default:
- LOGL1S(DL1P, LOGL_ERROR, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"TCH mode %u invalid, please fix!\n",
tch_mode);
return -EINVAL;
@@ -243,12 +241,11 @@
/* Check if the frame is bad */
if (rc < 0) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
- "Received bad data (%u/%u)\n",
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi, "Received bad data (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
bfi_flag = true;
} else if (rc < 4) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi,
"Received bad data (%u/%u) with invalid codec mode %d\n",
bi->fn % l1ts->mf_period, l1ts->mf_period, rc);
bfi_flag = true;
@@ -268,7 +265,7 @@
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H0);
else
fn_begin = gsm0502_fn_remap(bi->fn, FN_REMAP_FACCH_H1);
- _sched_compose_ph_data_ind(l1t, bi->tn, fn_begin, chan,
+ _sched_compose_ph_data_ind(l1t, bi->tn, fn_begin, bi->chan,
tch_data + amr, GSM_MACBLOCK_LEN,
meas_avg.rssi, meas_avg.toa256,
meas_avg.ci_cb, ber10k,
@@ -315,7 +312,7 @@
chan_state->codec[chan_state->dl_ft],
AMR_BAD);
if (rc < 2) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"Failed to encode AMR_BAD frame (rc=%d), "
"not sending BFI\n", rc);
return -EINVAL;
@@ -323,7 +320,7 @@
memset(tch_data + 2, 0, rc - 2);
break;
default:
- LOGL1S(DL1P, LOGL_ERROR, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, bi,
"TCH mode %u invalid, please fix!\n", tch_mode);
return -EINVAL;
}
@@ -367,7 +364,7 @@
chan_state->ber10k_facch = 0;
}
- return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, chan, tch_data, rc,
+ return _sched_compose_tch_ind(l1t, bi->tn, fn_begin, bi->chan, tch_data, rc,
/* FIXME: what should we use for BFI here? */
bfi_flag ? bi->toa256 : meas_avg.toa256, ber10k,
bfi_flag ? bi->rssi : meas_avg.rssi, is_sub);
@@ -375,35 +372,34 @@
/* common section for generation of TCH bursts (TCH/H and TCH/F).
* FIXME: this function is over-complicated, refactor / get rid of it. */
-extern void tx_tch_common(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, uint8_t bid,
+extern void tx_tch_common(struct l1sched_trx *l1t,
+ const struct trx_dl_burst_req *br,
struct msgb **_msg_tch, struct msgb **_msg_facch);
/* obtain a to-be-transmitted TCH/H (Half Traffic Channel) burst */
-int tx_tchh_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_tchh_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct msgb *msg_tch = NULL, *msg_facch = NULL;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct gsm_bts_trx_ts *ts = &l1t->trx->ts[br->tn];
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
uint8_t tch_mode = chan_state->tch_mode;
ubit_t *burst, **bursts_p = &chan_state->dl_bursts;
/* send burst, if we already got a frame */
- if (bid > 0) {
+ if (br->bid > 0) {
if (!*bursts_p)
return 0;
goto send_burst;
}
/* get TCH and/or FACCH */
- tx_tch_common(l1t, br->tn, br->fn, chan, bid, &msg_tch, &msg_facch);
+ tx_tch_common(l1t, br, &msg_tch, &msg_facch);
/* check for FACCH alignment */
if (msg_facch && ((((br->fn + 4) % 26) >> 2) & 1)) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, br->tn, chan, br->fn, "Cannot transmit FACCH starting on "
- "even frames, please fix RTS!\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br,
+ "Cannot transmit FACCH starting on even frames, please fix RTS!\n");
msgb_free(msg_facch);
msg_facch = NULL;
}
@@ -428,7 +424,7 @@
/* no message at all */
if (!msg_tch && !msg_facch && !chan_state->dl_ongoing_facch) {
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "No TCH or FACCH prim for transmit.\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "No TCH or FACCH prim for transmit.\n");
goto send_burst;
}
@@ -458,14 +454,14 @@
send_burst:
/* compose burst */
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + br->bid * 116;
memcpy(br->burst + 3, burst, 58);
memcpy(br->burst + 61, _sched_tsc[gsm_ts_tsc(ts)], 26);
memcpy(br->burst + 87, burst + 58, 58);
br->burst_len = GSM_BURST_LEN;
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting burst=%u.\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting burst=%u.\n", br->bid);
return 0;
}
diff --git a/src/osmo-bts-trx/sched_lchan_xcch.c b/src/osmo-bts-trx/sched_lchan_xcch.c
index 90f481a..ba0d612 100644
--- a/src/osmo-bts-trx/sched_lchan_xcch.c
+++ b/src/osmo-bts-trx/sched_lchan_xcch.c
@@ -1,6 +1,7 @@
/*
* (C) 2013 by Andreas Eversberg <jolly at eversberg.eu>
* (C) 2015-2017 by Harald Welte <laforge at gnumonks.org>
+ * Contributions by sysmocom - s.f.m.c. GmbH
*
* All Rights Reserved
*
@@ -46,11 +47,10 @@
}
/*! \brief a single (SDCCH/SACCH) burst was received by the PHY, process it */
-int rx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_data_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, bi->tn);
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[bi->chan];
sbit_t *burst, **bursts_p = &chan_state->ul_bursts;
uint32_t *first_fn = &chan_state->ul_first_fn;
uint8_t *mask = &chan_state->ul_mask;
@@ -61,15 +61,14 @@
uint16_t ber10k;
int rc;
struct gsm_lchan *lchan = chan_state->lchan;
- bool rep_sacch = L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id) && lchan->repeated_ul_sacch_active;
+ bool rep_sacch = L1SAP_IS_LINK_SACCH(trx_chan_desc[bi->chan].link_id) && lchan->repeated_ul_sacch_active;
/* If handover RACH detection is turned on, treat this burst as an Access Burst.
* Handle NOPE.ind as usually to ensure proper Uplink measurement reporting. */
if (chan_state->ho_rach_detect == 1 && ~bi->flags & TRX_BI_F_NOPE_IND)
- return rx_rach_fn(l1t, chan, bid, bi);
+ return rx_rach_fn(l1t, bi);
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
- "Received Data, bid=%u\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi, "Received Data, bid=%u\n", bi->bid);
/* allocate burst memory, if not already */
if (!*bursts_p) {
@@ -80,28 +79,28 @@
/* UL-SACCH requires additional memory to keep a copy of each previous
* burst set. */
- if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id) && !chan_state->ul_bursts_prev) {
+ if (L1SAP_IS_LINK_SACCH(trx_chan_desc[bi->chan].link_id) && !chan_state->ul_bursts_prev) {
chan_state->ul_bursts_prev = talloc_zero_size(tall_bts_ctx, 464);
if (!chan_state->ul_bursts_prev)
return -ENOMEM;
}
/* clear burst & store frame number of first burst */
- if (bid == 0) {
+ if (bi->bid == 0) {
memset(*bursts_p, 0, 464);
*mask = 0x0;
*first_fn = bi->fn;
}
/* update mask */
- *mask |= (1 << bid);
+ *mask |= (1 << bi->bid);
/* store measurements */
trx_sched_meas_push(chan_state, bi);
/* Copy burst to buffer of 4 bursts. If the burst indication contains
* no data, ensure that the buffer does not stay uninitialized */
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + bi->bid * 116;
if (bi->burst_len > 0) {
memcpy(burst, bi->burst + 3, 58);
memcpy(burst + 58, bi->burst + 87, 58);
@@ -109,7 +108,7 @@
memset(burst, 0, 58 * 2);
/* wait until complete set of bursts */
- if (bid != 3)
+ if (bi->bid != 3)
return 0;
/* average measurements of the last 4 bursts */
@@ -117,8 +116,7 @@
/* check for complete set of bursts */
if ((*mask & 0xf) != 0xf) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
- "Received incomplete data (%u/%u)\n",
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi, "Received incomplete data (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
/* we require first burst to have correct FN */
@@ -132,8 +130,7 @@
/* decode */
rc = gsm0503_xcch_decode(l2, *bursts_p, &n_errors, &n_bits_total);
if (rc) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
- "Received bad data (%u/%u)\n",
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi, "Received bad data (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
l2_len = 0;
@@ -145,11 +142,11 @@
add_sbits(*bursts_p, chan_state->ul_bursts_prev);
rc = gsm0503_xcch_decode(l2, *bursts_p, &n_errors, &n_bits_total);
if (rc) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, bi,
"Combining current SACCH block with previous SACCH block also yields bad data (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
} else {
- LOGL1S(DL1P, LOGL_DEBUG, l1t, bi->tn, chan, bi->fn,
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, bi,
"Combining current SACCH block with previous SACCH block yields good data (%u/%u)\n",
bi->fn % l1ts->mf_period, l1ts->mf_period);
l2_len = GSM_MACBLOCK_LEN;
@@ -165,34 +162,33 @@
memcpy(chan_state->ul_bursts_prev, *bursts_p, 464);
return _sched_compose_ph_data_ind(l1t, bi->tn, *first_fn,
- chan, l2, l2_len,
+ bi->chan, l2, l2_len,
meas_avg.rssi, meas_avg.toa256,
meas_avg.ci_cb, ber10k,
PRES_INFO_UNKNOWN);
}
/* obtain a to-be-transmitted xCCH (e.g SACCH or SDCCH) burst */
-int tx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_data_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct gsm_bts_trx_ts *ts = &l1t->trx->ts[br->tn];
struct msgb *msg = NULL; /* make GCC happy */
- ubit_t *burst, **bursts_p = &l1ts->chan_state[chan].dl_bursts;
+ ubit_t *burst, **bursts_p = &l1ts->chan_state[br->chan].dl_bursts;
/* send burst, if we already got a frame */
- if (bid > 0) {
+ if (br->bid > 0) {
if (!*bursts_p)
return 0;
goto send_burst;
}
/* get mac block from queue */
- msg = _sched_dequeue_prim(l1t, br->tn, br->fn, chan);
+ msg = _sched_dequeue_prim(l1t, br);
if (msg)
goto got_msg;
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "No prim for transmit.\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "No prim for transmit.\n");
no_msg:
/* free burst memory */
@@ -205,8 +201,8 @@
got_msg:
/* check validity of message */
if (msgb_l2len(msg) != GSM_MACBLOCK_LEN) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, br->tn, chan, br->fn, "Prim not 23 bytes, please FIX! "
- "(len=%d)\n", msgb_l2len(msg));
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "Prim has odd len=%u != %u\n",
+ msgb_l2len(msg), GSM_MACBLOCK_LEN);
/* free message */
msgb_free(msg);
goto no_msg;
@@ -215,15 +211,15 @@
/* BURST BYPASS */
/* handle loss detection of SACCH */
- if (L1SAP_IS_LINK_SACCH(trx_chan_desc[chan].link_id)) {
+ if (L1SAP_IS_LINK_SACCH(trx_chan_desc[br->chan].link_id)) {
/* count and send BFI */
- if (++(l1ts->chan_state[chan].lost_frames) > 1) {
+ if (++(l1ts->chan_state[br->chan].lost_frames) > 1) {
/* TODO: Should we pass old TOA here? Otherwise we risk
* unnecessary decreasing TA */
/* Note: RSSI is set to 0 to indicate to the higher
* layers that this is a faked ph_data_ind */
- _sched_compose_ph_data_ind(l1t, br->tn, 0, chan, NULL, 0,
+ _sched_compose_ph_data_ind(l1t, br->tn, 0, br->chan, NULL, 0,
0, 0, 0, 10000,
PRES_INFO_INVALID);
}
@@ -244,14 +240,14 @@
send_burst:
/* compose burst */
- burst = *bursts_p + bid * 116;
+ burst = *bursts_p + br->bid * 116;
memcpy(br->burst + 3, burst, 58);
memcpy(br->burst + 61, _sched_tsc[gsm_ts_tsc(ts)], 26);
memcpy(br->burst + 87, burst + 58, 58);
br->burst_len = GSM_BURST_LEN;
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting burst=%u.\n", bid);
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting burst=%u.\n", br->bid);
return 0;
}
diff --git a/src/osmo-bts-trx/scheduler_trx.c b/src/osmo-bts-trx/scheduler_trx.c
index c173f5b..bfe8d5c 100644
--- a/src/osmo-bts-trx/scheduler_trx.c
+++ b/src/osmo-bts-trx/scheduler_trx.c
@@ -53,10 +53,9 @@
(ts)->hopping.hsn, (ts)->hopping.maio, (ts)->hopping.arfcn_num
/* an IDLE burst returns nothing. on C0 it is replaced by dummy burst */
-int tx_idle_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_idle_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
- LOGL1S(DL1P, LOGL_DEBUG, l1t, br->tn, chan, br->fn, "Transmitting IDLE\n");
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br, "Transmitting IDLE\n");
return 0;
}
diff --git a/src/osmo-bts-virtual/scheduler_virtbts.c b/src/osmo-bts-virtual/scheduler_virtbts.c
index 466e864..bbc2c4e 100644
--- a/src/osmo-bts-virtual/scheduler_virtbts.c
+++ b/src/osmo-bts-virtual/scheduler_virtbts.c
@@ -50,12 +50,12 @@
/**
* Send a message over the virtual um interface.
* This will at first wrap the msg with a GSMTAP header and then write it to the declared multicast socket.
- * TODO: we might want to remove unused argument uint8_t tn
*/
-static void _tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, struct msgb *msg, bool is_voice_frame)
+static void _tx_to_virt_um(struct l1sched_trx *l1t,
+ struct trx_dl_burst_req *br,
+ struct msgb *msg, bool is_voice_frame)
{
- const struct trx_chan_desc *chdesc = &trx_chan_desc[chan];
+ const struct trx_chan_desc *chdesc = &trx_chan_desc[br->chan];
struct msgb *outmsg; /* msg to send with gsmtap header prepended */
uint16_t arfcn = l1t->trx->arfcn; /* ARFCN of the transceiver the message is send with */
uint8_t signal_dbm = 63; /* signal strength, 63 is best */
@@ -69,17 +69,17 @@
rsl_dec_chan_nr(chdesc->chan_nr, &rsl_chantype, &subslot, ×lot);
/* the timeslot is not encoded in the chan_nr of the chdesc, and so has to be overwritten */
- timeslot = tn;
+ timeslot = br->tn;
/* in Osmocom, AGCH is only sent on ccch block 0. no idea why. this seems to cause false GSMTAP channel
* types for agch and pch. */
if (rsl_chantype == RSL_CHAN_PCH_AGCH &&
- l1sap_fn2ccch_block(fn) >= num_agch(l1t->trx, "PH-DATA-REQ"))
+ l1sap_fn2ccch_block(br->fn) >= num_agch(l1t->trx, "PH-DATA-REQ"))
gsmtap_chantype = GSMTAP_CHANNEL_PCH;
else
gsmtap_chantype = chantype_rsl2gsmtap2(rsl_chantype, chdesc->link_id, is_voice_frame); /* the logical channel type */
if (gsmtap_chantype == GSMTAP_CHANNEL_UNKNOWN) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Tx GSMTAP for RSL channel type 0x%02x: cannot send, this"
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Tx GSMTAP for RSL channel type 0x%02x: cannot send, this"
" channel type is unknown in GSMTAP\n", rsl_chantype);
msgb_free(msg);
return;
@@ -87,10 +87,10 @@
#if MODULO_HYPERFRAME
/* Restart fn after every superframe (26 * 51 frames) to simulate hyperframe overflow each 6 seconds. */
- fn %= 26 * 51;
+ br->fn %= 26 * 51;
#endif
- outmsg = gsmtap_makemsg(arfcn, timeslot, gsmtap_chantype, subslot, fn, signal_dbm, snr, data, data_len);
+ outmsg = gsmtap_makemsg(arfcn, timeslot, gsmtap_chantype, subslot, br->fn, signal_dbm, snr, data, data_len);
if (outmsg) {
struct phy_instance *pinst = trx_phy_instance(l1t->trx);
@@ -98,24 +98,25 @@
rc = virt_um_write_msg(pinst->phy_link->u.virt.virt_um, outmsg);
if (rc < 0)
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br,
"GSMTAP msg could not send to virtual Um: %s\n", strerror(-rc));
else if (rc == 0)
bts_shutdown(l1t->trx->bts, "VirtPHY write socket died\n");
else
- LOGL1S(DL1P, LOGL_DEBUG, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_DEBUG, l1t, br,
"Sending GSMTAP message to virtual Um\n");
} else
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "GSMTAP msg could not be created!\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "GSMTAP msg could not be created!\n");
/* free incoming message */
msgb_free(msg);
}
-static void tx_to_virt_um(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, struct msgb *msg)
+static void tx_to_virt_um(struct l1sched_trx *l1t,
+ struct trx_dl_burst_req *br,
+ struct msgb *msg)
{
- _tx_to_virt_um(l1t, tn, fn, chan, msg, false);
+ _tx_to_virt_um(l1t, br, msg, false);
}
@@ -151,10 +152,11 @@
}
}
-static void tx_to_virt_um_voice_frame(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, struct msgb *msg)
+static void tx_to_virt_um_voice_frame(struct l1sched_trx *l1t,
+ struct trx_dl_burst_req *br,
+ struct msgb *msg)
{
- struct gsm_lchan *lchan = lchan_from_l1t(l1t, tn, chan);
+ struct gsm_lchan *lchan = lchan_from_l1t(l1t, br->tn, br->chan);
int um_voice_type;
OSMO_ASSERT(lchan);
@@ -168,7 +170,7 @@
msgb_pull_to_l2(msg);
msgb_push_u8(msg, um_voice_type);
msg->l2h = msg->data;
- _tx_to_virt_um(l1t, tn, fn, chan, msg, true);
+ _tx_to_virt_um(l1t, br, msg, true);
}
/*
@@ -176,42 +178,38 @@
*/
/* an IDLE burst returns nothing. on C0 it is replaced by dummy burst */
-int tx_idle_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_idle_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
return 0;
}
-int tx_fcch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_fcch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
return 0;
}
-int tx_sch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_sch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
return 0;
}
-int tx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_data_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct msgb *msg;
- if (bid > 0)
+ if (br->bid > 0)
return 0;
/* get mac block from queue */
- msg = _sched_dequeue_prim(l1t, br->tn, br->fn, chan);
+ msg = _sched_dequeue_prim(l1t, br);
if (!msg) {
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "has not been served !! No prim\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "has not been served !! No prim\n");
return -ENODEV;
}
/* check validity of message */
if (msgb_l2len(msg) != GSM_MACBLOCK_LEN) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, br->tn, chan, br->fn, "Prim not 23 bytes, please FIX! (len=%d)\n",
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "Prim not 23 bytes, please FIX! (len=%d)\n",
msgb_l2len(msg));
/* free message */
msgb_free(msg);
@@ -219,38 +217,38 @@
}
/* transmit the msg received on dl from bsc to layer1 (virt Um) */
- tx_to_virt_um(l1t, br->tn, br->fn, chan, msg);
+ tx_to_virt_um(l1t, br, msg);
return 0;
}
-int tx_pdtch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_pdtch_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct msgb *msg = NULL; /* make GCC happy */
- if (bid > 0)
+ if (br->bid > 0)
return 0;
/* get mac block from queue */
- msg = _sched_dequeue_prim(l1t, br->tn, br->fn, chan);
+ msg = _sched_dequeue_prim(l1t, br);
if (!msg) {
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "has not been served !! No prim\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "has not been served !! No prim\n");
return -ENODEV;
}
- tx_to_virt_um(l1t, br->tn, br->fn, chan, msg);
+ tx_to_virt_um(l1t, br, msg);
return 0;
}
-static void tx_tch_common(struct l1sched_trx *l1t, uint8_t tn, uint32_t fn,
- enum trx_chan_type chan, uint8_t bid, struct msgb **_msg_tch,
- struct msgb **_msg_facch, int codec_mode_request)
+static void tx_tch_common(struct l1sched_trx *l1t,
+ const struct trx_dl_burst_req *br,
+ struct msgb **_msg_tch, struct msgb **_msg_facch,
+ int codec_mode_request)
{
- struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, tn);
+ struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
struct msgb *msg1, *msg2, *msg_tch = NULL, *msg_facch = NULL;
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
uint8_t rsl_cmode = chan_state->rsl_cmode;
uint8_t tch_mode = chan_state->tch_mode;
struct osmo_phsap_prim *l1sap;
@@ -261,13 +259,13 @@
uint8_t tch_data[GSM_FR_BYTES];
int len;
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Missing TCH bursts detected, sending "
- "BFI for %s\n", trx_chan_desc[chan].name);
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br, "Missing TCH bursts detected, sending "
+ "BFI for %s\n", trx_chan_desc[br->chan].name);
/* indicate bad frame */
switch (tch_mode) {
case GSM48_CMODE_SPEECH_V1: /* FR / HR */
- if (chan != TRXC_TCHF) { /* HR */
+ if (br->chan != TRXC_TCHF) { /* HR */
tch_data[0] = 0x70; /* F = 0, FT = 111 */
memset(tch_data + 1, 0, 14);
len = 15;
@@ -277,7 +275,7 @@
len = GSM_FR_BYTES;
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
- if (chan != TRXC_TCHF)
+ if (br->chan != TRXC_TCHF)
goto inval_mode1;
memset(tch_data, 0, GSM_EFR_BYTES);
len = GSM_EFR_BYTES;
@@ -289,7 +287,7 @@
if (len < 2)
break;
memset(tch_data + 2, 0, len - 2);
- _sched_compose_tch_ind(l1t, tn, 0, chan, tch_data, len);
+ _sched_compose_tch_ind(l1t, br->tn, 0, br->chan, tch_data, len);
break;
default:
inval_mode1:
@@ -298,13 +296,13 @@
len = 0;
}
if (len)
- _sched_compose_tch_ind(l1t, tn, 0, chan, tch_data, len);
+ _sched_compose_tch_ind(l1t, br->tn, 0, br->chan, tch_data, len);
}
#endif
/* get frame and unlink from queue */
- msg1 = _sched_dequeue_prim(l1t, tn, fn, chan);
- msg2 = _sched_dequeue_prim(l1t, tn, fn, chan);
+ msg1 = _sched_dequeue_prim(l1t, br);
+ msg2 = _sched_dequeue_prim(l1t, br);
if (msg1) {
l1sap = msgb_l1sap_prim(msg1);
if (l1sap->oph.primitive == PRIM_TCH) {
@@ -312,8 +310,8 @@
if (msg2) {
l1sap = msgb_l1sap_prim(msg2);
if (l1sap->oph.primitive == PRIM_TCH) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, tn, chan, fn,
- "TCH twice, please FIX! ");
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br,
+ "TCH twice, please FIX!\n");
msgb_free(msg2);
} else
msg_facch = msg2;
@@ -323,8 +321,8 @@
if (msg2) {
l1sap = msgb_l1sap_prim(msg2);
if (l1sap->oph.primitive != PRIM_TCH) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, tn, chan, fn,
- "FACCH twice, please FIX! ");
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br,
+ "FACCH twice, please FIX!\n");
msgb_free(msg2);
} else
msg_tch = msg2;
@@ -340,8 +338,8 @@
/* check validity of message */
if (msg_facch && msgb_l2len(msg_facch) != GSM_MACBLOCK_LEN) {
- LOGL1S(DL1P, LOGL_FATAL, l1t, tn, chan, fn, "Prim not 23 bytes, please FIX! (len=%d)\n",
- msgb_l2len(msg_facch));
+ LOGL1SB(DL1P, LOGL_FATAL, l1t, br, "Prim has odd len=%u != %u\n",
+ msgb_l2len(msg_facch), GSM_MACBLOCK_LEN);
/* free message */
msgb_free(msg_facch);
msg_facch = NULL;
@@ -356,18 +354,18 @@
#endif
if (rsl_cmode != RSL_CMOD_SPD_SPEECH) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn, "Dropping speech frame, "
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br, "Dropping speech frame, "
"because we are not in speech mode\n");
goto free_bad_msg;
}
switch (tch_mode) {
case GSM48_CMODE_SPEECH_V1: /* FR / HR */
- if (chan != TRXC_TCHF) { /* HR */
+ if (br->chan != TRXC_TCHF) { /* HR */
len = 15;
if (msgb_l2len(msg_tch) >= 1
&& (msg_tch->l2h[0] & 0xf0) != 0x00) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br,
"Transmitting 'bad HR frame'\n");
goto free_bad_msg;
}
@@ -376,18 +374,18 @@
len = GSM_FR_BYTES;
if (msgb_l2len(msg_tch) >= 1
&& (msg_tch->l2h[0] >> 4) != 0xd) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br,
"Transmitting 'bad FR frame'\n");
goto free_bad_msg;
}
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
- if (chan != TRXC_TCHF)
+ if (br->chan != TRXC_TCHF)
goto inval_mode2;
len = GSM_EFR_BYTES;
if (msgb_l2len(msg_tch) >= 1
&& (msg_tch->l2h[0] >> 4) != 0xc) {
- LOGL1S(DL1P, LOGL_NOTICE, l1t, tn, chan, fn,
+ LOGL1SB(DL1P, LOGL_NOTICE, l1t, br,
"Transmitting 'bad EFR frame'\n");
goto free_bad_msg;
}
@@ -398,15 +396,15 @@
break;
default:
inval_mode2:
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "TCH mode invalid, please fix!\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "TCH mode invalid, please fix!\n");
goto free_bad_msg;
}
if (len < 0) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Cannot send invalid AMR payload\n");
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Cannot send invalid AMR payload\n");
goto free_bad_msg;
}
if (msgb_l2len(msg_tch) != len) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, tn, chan, fn, "Cannot send payload with "
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Cannot send payload with "
"invalid length! (expecing %d, received %d)\n", len, msgb_l2len(msg_tch));
free_bad_msg:
/* free message */
@@ -421,51 +419,47 @@
*_msg_facch = msg_facch;
}
-int tx_tchf_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_tchf_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct msgb *msg_tch = NULL, *msg_facch = NULL;
- if (bid > 0)
+ if (br->bid > 0)
return 0;
- tx_tch_common(l1t, br->tn, br->fn, chan, bid, &msg_tch, &msg_facch,
- (((br->fn + 4) % 26) >> 2) & 1);
+ tx_tch_common(l1t, br, &msg_tch, &msg_facch, (((br->fn + 4) % 26) >> 2) & 1);
/* no message at all */
if (!msg_tch && !msg_facch) {
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "has not been served !! No prim\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "has not been served !! No prim\n");
return -ENODEV;
}
if (msg_facch) {
- tx_to_virt_um(l1t, br->tn, br->fn, chan, msg_facch);
+ tx_to_virt_um(l1t, br, msg_facch);
msgb_free(msg_tch);
} else if (msg_tch)
- tx_to_virt_um_voice_frame(l1t, br->tn, br->fn, chan, msg_tch);
+ tx_to_virt_um_voice_frame(l1t, br, msg_tch);
return 0;
}
-int tx_tchh_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, struct trx_dl_burst_req *br)
+int tx_tchh_fn(struct l1sched_trx *l1t, struct trx_dl_burst_req *br)
{
struct msgb *msg_tch = NULL, *msg_facch = NULL;
struct l1sched_ts *l1ts = l1sched_trx_get_ts(l1t, br->tn);
- struct l1sched_chan_state *chan_state = &l1ts->chan_state[chan];
+ struct l1sched_chan_state *chan_state = &l1ts->chan_state[br->chan];
//uint8_t tch_mode = chan_state->tch_mode;
/* send burst, if we already got a frame */
- if (bid > 0)
+ if (br->bid > 0)
return 0;
/* get TCH and/or FACCH */
- tx_tch_common(l1t, br->tn, br->fn, chan, bid, &msg_tch, &msg_facch,
- (((br->fn + 4) % 26) >> 2) & 1);
+ tx_tch_common(l1t, br, &msg_tch, &msg_facch, (((br->fn + 4) % 26) >> 2) & 1);
/* check for FACCH alignment */
if (msg_facch && ((((br->fn + 4) % 26) >> 2) & 1)) {
- LOGL1S(DL1P, LOGL_ERROR, l1t, br->tn, chan, br->fn, "Cannot transmit FACCH starting on "
+ LOGL1SB(DL1P, LOGL_ERROR, l1t, br, "Cannot transmit FACCH starting on "
"even frames, please fix RTS!\n");
msgb_free(msg_facch);
msg_facch = NULL;
@@ -473,15 +467,15 @@
/* no message at all */
if (!msg_tch && !msg_facch && !chan_state->dl_ongoing_facch) {
- LOGL1S(DL1P, LOGL_INFO, l1t, br->tn, chan, br->fn, "has not been served !! No prim\n");
+ LOGL1SB(DL1P, LOGL_INFO, l1t, br, "has not been served !! No prim\n");
return -ENODEV;
}
if (msg_facch) {
- tx_to_virt_um(l1t, br->tn, br->fn, chan, msg_facch);
+ tx_to_virt_um(l1t, br, msg_facch);
msgb_free(msg_tch);
} else if (msg_tch)
- tx_to_virt_um_voice_frame(l1t, br->tn, br->fn, chan, msg_tch);
+ tx_to_virt_um_voice_frame(l1t, br, msg_tch);
return 0;
}
@@ -495,33 +489,28 @@
* directly into the L1SAP, bypassing the TDMA multiplex logic oriented
* towards receiving bursts */
-int rx_rach_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_rach_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
return 0;
}
/*! \brief a single burst was received by the PHY, process it */
-int rx_data_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_data_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
return 0;
}
-int rx_pdtch_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_pdtch_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
return 0;
}
-int rx_tchf_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_tchf_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
return 0;
}
-int rx_tchh_fn(struct l1sched_trx *l1t, enum trx_chan_type chan,
- uint8_t bid, const struct trx_ul_burst_ind *bi)
+int rx_tchh_fn(struct l1sched_trx *l1t, const struct trx_ul_burst_ind *bi)
{
return 0;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-bts/+/24178
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: Ic5a02b074662b3e429bf18e05a982f3f3e7b7444
Gerrit-Change-Number: 24178
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210508/118b9cdb/attachment.htm>