summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-07-31 13:27:30 +0600
committerVadim Yanitskiy <axilirator@gmail.com>2017-10-23 22:05:49 +0330
commit8cab4406da7bd6406b788fe7b7a53bd9e61e5669 (patch)
treefb8c0080f9ac7718ec7391928093d20647ef774a
parent49708647b2821e96f3bd50a4953b34e26e99d111 (diff)
host/trxcon/scheduler: pass trx_lchan_state to lchan handlers
It's better to pass a trx_lchan_state instance directly from caller to lchan handler instead of passing trx_lchan_type. This way a handler wouldn't need to find lchan itself. Change-Id: I47a40542b03ab31da12b0abb1c263c83662ff018
-rw-r--r--src/host/trxcon/sched_lchan_desc.c8
-rw-r--r--src/host/trxcon/sched_lchan_rach.c2
-rw-r--r--src/host/trxcon/sched_lchan_sch.c6
-rw-r--r--src/host/trxcon/sched_lchan_xcch.c36
-rw-r--r--src/host/trxcon/sched_trx.c10
-rw-r--r--src/host/trxcon/sched_trx.h13
6 files changed, 36 insertions, 39 deletions
diff --git a/src/host/trxcon/sched_lchan_desc.c b/src/host/trxcon/sched_lchan_desc.c
index e3998fa..dee8f6a 100644
--- a/src/host/trxcon/sched_lchan_desc.c
+++ b/src/host/trxcon/sched_lchan_desc.c
@@ -39,19 +39,19 @@
/* Forward declaration of handlers */
int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan, uint8_t bid,
+ struct trx_lchan_state *lchan, uint32_t fn, uint8_t bid,
sbit_t *bits, uint16_t nbits, int8_t rssi, float toa);
int tx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan,
+ struct trx_lchan_state *lchan, uint32_t fn,
uint8_t bid, uint16_t *nbits);
int rx_sch_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan, uint8_t bid,
+ struct trx_lchan_state *lchan, uint32_t fn, uint8_t bid,
sbit_t *bits, uint16_t nbits, int8_t rssi, float toa);
int tx_rach_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan,
+ struct trx_lchan_state *lchan, uint32_t fn,
uint8_t bid, uint16_t *nbits);
const struct trx_lchan_desc trx_lchan_desc[_TRX_CHAN_MAX] = {
diff --git a/src/host/trxcon/sched_lchan_rach.c b/src/host/trxcon/sched_lchan_rach.c
index 0e8d2e8..6a10ab8 100644
--- a/src/host/trxcon/sched_lchan_rach.c
+++ b/src/host/trxcon/sched_lchan_rach.c
@@ -58,7 +58,7 @@ static ubit_t rach_synch_seq[] = {
/* Obtain a to-be-transmitted RACH burst */
int tx_rach_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan,
+ struct trx_lchan_state *lchan, uint32_t fn,
uint8_t bid, uint16_t *nbits)
{
struct trx_ts_prim *prim;
diff --git a/src/host/trxcon/sched_lchan_sch.c b/src/host/trxcon/sched_lchan_sch.c
index 9e854bb..aff8fb6 100644
--- a/src/host/trxcon/sched_lchan_sch.c
+++ b/src/host/trxcon/sched_lchan_sch.c
@@ -73,7 +73,7 @@ static void decode_sb(struct gsm_time *time, uint8_t *bsic, uint8_t *sb_info)
}
int rx_sch_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan, uint8_t bid,
+ struct trx_lchan_state *lchan, uint32_t fn, uint8_t bid,
sbit_t *bits, uint16_t nbits, int8_t rssi, float toa)
{
sbit_t payload[2 * 39];
@@ -117,8 +117,8 @@ int rx_sch_fn(struct trx_instance *trx, struct trx_ts *ts,
return -ENOMEM;
/* Fill in some downlink info */
- data->chan_nr = trx_lchan_desc[chan].chan_nr | ts->index;
- data->link_id = trx_lchan_desc[chan].link_id;
+ data->chan_nr = trx_lchan_desc[lchan->type].chan_nr | ts->index;
+ data->link_id = trx_lchan_desc[lchan->type].link_id;
data->band_arfcn = htons(trx->band_arfcn);
data->frame_nr = htonl(fn);
data->rx_level = -rssi;
diff --git a/src/host/trxcon/sched_lchan_xcch.c b/src/host/trxcon/sched_lchan_xcch.c
index 81bd305..aa95656 100644
--- a/src/host/trxcon/sched_lchan_xcch.c
+++ b/src/host/trxcon/sched_lchan_xcch.c
@@ -83,26 +83,19 @@ static const uint8_t nb_training_bits[8][26] = {
};
int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan, uint8_t bid,
+ struct trx_lchan_state *lchan, uint32_t fn, uint8_t bid,
sbit_t *bits, uint16_t nbits, int8_t rssi, float toa)
{
+ const struct trx_lchan_desc *lchan_desc;
int n_errors, n_bits_total, rc;
- struct trx_lchan_state *lchan;
uint8_t *rssi_num, *toa_num;
float *rssi_sum, *toa_sum;
sbit_t *buffer, *offset;
uint8_t l2[23], *mask;
uint32_t *first_fn;
- LOGP(DSCH, LOGL_DEBUG, "Data received on %s: fn=%u ts=%u bid=%u\n",
- trx_lchan_desc[chan].name, fn, ts->index, bid);
-
- /* Find required channel state */
- lchan = sched_trx_find_lchan(ts, chan);
- if (lchan == NULL)
- return -EINVAL;
-
/* Set up pointers */
+ lchan_desc = &trx_lchan_desc[lchan->type];
first_fn = &lchan->rx_first_fn;
mask = &lchan->rx_burst_mask;
buffer = lchan->rx_bursts;
@@ -112,6 +105,9 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
toa_sum = &lchan->toa_sum;
toa_num = &lchan->toa_num;
+ LOGP(DSCH, LOGL_DEBUG, "Data received on %s: fn=%u ts=%u bid=%u\n",
+ lchan_desc->name, fn, ts->index, bid);
+
/* Clear buffer & store frame number of first burst */
if (bid == 0) {
memset(buffer, 0, 464);
@@ -147,7 +143,7 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
"fn=%u (%u/%u) for %s\n", *first_fn,
(*first_fn) % ts->mf_layout->period,
ts->mf_layout->period,
- trx_lchan_desc[chan].name);
+ lchan_desc->name);
return -1;
}
@@ -159,7 +155,7 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
"(%u/%u) for %s\n", *first_fn,
(*first_fn) % ts->mf_layout->period,
ts->mf_layout->period,
- trx_lchan_desc[chan].name);
+ lchan_desc->name);
return rc;
}
@@ -170,8 +166,8 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
return -ENOMEM;
/* Fill in some downlink info */
- data->chan_nr = trx_lchan_desc[chan].chan_nr | ts->index;
- data->link_id = trx_lchan_desc[chan].link_id;
+ data->chan_nr = lchan_desc->chan_nr | ts->index;
+ data->link_id = lchan_desc->link_id;
data->band_arfcn = htons(trx->band_arfcn);
data->frame_nr = htonl(*first_fn);
data->rx_level = -(*rssi_sum / *rssi_num);
@@ -193,10 +189,10 @@ int rx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
}
int tx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan,
+ struct trx_lchan_state *lchan, uint32_t fn,
uint8_t bid, uint16_t *nbits)
{
- struct trx_lchan_state *lchan;
+ const struct trx_lchan_desc *lchan_desc;
struct trx_ts_prim *prim;
struct l1ctl_info_ul *ul;
ubit_t burst[GSM_BURST_LEN];
@@ -205,12 +201,8 @@ int tx_data_fn(struct trx_instance *trx, struct trx_ts *ts,
const uint8_t *tsc;
int rc;
- /* Find required channel state */
- lchan = sched_trx_find_lchan(ts, chan);
- if (lchan == NULL)
- return -EINVAL;
-
/* Set up pointers */
+ lchan_desc = &trx_lchan_desc[lchan->type];
mask = &lchan->tx_burst_mask;
buffer = lchan->tx_bursts;
@@ -262,7 +254,7 @@ send_burst:
*nbits = GSM_BURST_LEN;
LOGP(DSCH, LOGL_DEBUG, "Transmitting %s fn=%u ts=%u burst=%u\n",
- trx_lchan_desc[chan].name, fn, ts->index, bid);
+ lchan_desc->name, fn, ts->index, bid);
/* Send burst to transceiver */
rc = trx_if_tx_burst(trx, ts->index, fn, 10, burst);
diff --git a/src/host/trxcon/sched_trx.c b/src/host/trxcon/sched_trx.c
index 40d1446..b9f1889 100644
--- a/src/host/trxcon/sched_trx.c
+++ b/src/host/trxcon/sched_trx.c
@@ -49,6 +49,7 @@ static void sched_frame_clck_cb(struct trx_sched *sched)
{
struct trx_instance *trx = (struct trx_instance *) sched->data;
const struct trx_frame *frame;
+ struct trx_lchan_state *lchan;
trx_lchan_tx_func *handler;
struct trx_ts_prim *prim;
enum trx_lchan_type chan;
@@ -86,12 +87,17 @@ static void sched_frame_clck_cb(struct trx_sched *sched)
if (!handler)
continue;
+ /* Make sure that lchan was allocated and activated */
+ lchan = sched_trx_find_lchan(ts, chan);
+ if (lchan == NULL)
+ continue;
+
/* Get a message from TX queue */
prim = llist_entry(ts->tx_prims.next, struct trx_ts_prim, list);
/* Poke lchan handler */
if (prim->chan == chan)
- handler(trx, ts, fn, chan, bid, NULL);
+ handler(trx, ts, lchan, fn, bid, NULL);
}
}
@@ -500,7 +506,7 @@ int sched_trx_handle_rx_burst(struct trx_instance *trx, uint8_t tn,
/* Put burst to handler */
if (fn == burst_fn) {
/* TODO: decrypt if required */
- handler(trx, ts, fn, chan, bid, bits, nbits, rssi, toa);
+ handler(trx, ts, lchan, fn, bid, bits, nbits, rssi, toa);
}
next_frame:
diff --git a/src/host/trxcon/sched_trx.h b/src/host/trxcon/sched_trx.h
index 7ebfa15..f8a8b53 100644
--- a/src/host/trxcon/sched_trx.h
+++ b/src/host/trxcon/sched_trx.h
@@ -23,6 +23,7 @@
#define MAX_A5_KEY_LEN (128 / 8)
/* Forward declaration to avoid mutual include */
+struct trx_lchan_state;
struct trx_instance;
struct trx_ts;
@@ -78,15 +79,13 @@ enum trx_lchan_type {
};
typedef int trx_lchan_rx_func(struct trx_instance *trx,
- struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan,
- uint8_t bid, sbit_t *bits, uint16_t nbits,
- int8_t rssi, float toa);
+ struct trx_ts *ts, struct trx_lchan_state *lchan,
+ uint32_t fn, uint8_t bid, sbit_t *bits,
+ uint16_t nbits, int8_t rssi, float toa);
typedef int trx_lchan_tx_func(struct trx_instance *trx,
- struct trx_ts *ts,
- uint32_t fn, enum trx_lchan_type chan,
- uint8_t bid, uint16_t *nbits);
+ struct trx_ts *ts, struct trx_lchan_state *lchan,
+ uint32_t fn, uint8_t bid, uint16_t *nbits);
struct trx_lchan_desc {
/*! \brief TRX Channel Type */