aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-01-16 17:51:16 +0100
committerHarald Welte <laforge@gnumonks.org>2016-01-16 17:51:16 +0100
commit5e8d8a1e75959141d643c84cf061032f9469be0a (patch)
tree248ea6b01b24624adbfe0f6734a9d6eba07793f5
parent20e8770df08a8584df4ac91f4a8eb86dfe443cd4 (diff)
parentf9de18ea15a988afb13e487955811884beecd8c8 (diff)
Merge branch 'laforge/cleanup'
-rw-r--r--include/osmo-bts/gsm_data.h10
-rw-r--r--src/osmo-bts-sysmo/main.c7
-rw-r--r--src/osmo-bts-sysmo/tch.c7
-rw-r--r--src/osmo-bts-trx/gsm0503_coding.c23
-rw-r--r--src/osmo-bts-trx/l1_if.c16
-rw-r--r--src/osmo-bts-trx/l1_if.h24
-rw-r--r--src/osmo-bts-trx/main.c37
-rw-r--r--src/osmo-bts-trx/scheduler.c179
-rw-r--r--src/osmo-bts-trx/scheduler.h19
-rw-r--r--src/osmo-bts-trx/trx_if.c6
-rw-r--r--src/osmo-bts-trx/trx_vty.c4
-rw-r--r--tests/bursts/bursts_test.c7
12 files changed, 172 insertions, 167 deletions
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index 06115b33..82512380 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -8,6 +8,16 @@
#include <osmo-bts/paging.h>
#include <osmo-bts/tx_power.h>
+#define GSM_FR_BITS 260
+#define GSM_EFR_BITS 244
+
+#define GSM_FR_BYTES 33 /* TS 101318 Chapter 5.1: 260 bits + 4bit sig */
+#define GSM_HR_BYTES 14 /* TS 101318 Chapter 5.2: 112 bits, no sig */
+#define GSM_EFR_BYTES 31 /* TS 101318 Chapter 5.3: 244 bits + 4bit sig */
+
+#define GSM_SUPERFRAME (26*51) /* 1326 TDMA frames */
+#define GSM_HYPERFRAME (2048*GSM_SUPERFRAME) /* GSM_HYPERFRAME frames */
+
#define GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DEFAULT 41
#define GSM_BTS_AGCH_QUEUE_THRESH_LEVEL_DISABLE 999999
#define GSM_BTS_AGCH_QUEUE_LOW_LEVEL_DEFAULT 41
diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c
index 9984e3cf..72cd0ee6 100644
--- a/src/osmo-bts-sysmo/main.c
+++ b/src/osmo-bts-sysmo/main.c
@@ -61,6 +61,7 @@
int pcu_direct = 0;
+static int quit = 0;
static const char *config_file = "osmo-bts.cfg";
static int daemonize = 0;
static unsigned int dsp_trace = 0x00000000;
@@ -268,7 +269,9 @@ static void signal_handler(int signal)
switch (signal) {
case SIGINT:
//osmo_signal_dispatch(SS_GLOBAL, S_GLOBAL_SHUTDOWN, NULL);
- bts_shutdown(bts, "SIGINT");
+ if (!quit)
+ bts_shutdown(bts, "SIGINT");
+ quit++;
break;
case SIGABRT:
case SIGUSR1:
@@ -415,7 +418,7 @@ int main(int argc, char **argv)
}
}
- while (1) {
+ while (quit < 2) {
log_reset_context();
osmo_select_main(0);
}
diff --git a/src/osmo-bts-sysmo/tch.c b/src/osmo-bts-sysmo/tch.c
index a6ce0e15..fa21eb53 100644
--- a/src/osmo-bts-sysmo/tch.c
+++ b/src/osmo-bts-sysmo/tch.c
@@ -90,13 +90,6 @@ void osmo_nibble_shift_left_unal(uint8_t *out, const uint8_t *in,
}
-#define GSM_FR_BITS 260
-#define GSM_EFR_BITS 244
-
-#define GSM_FR_BYTES 33 /* TS 101318 Chapter 5.1: 260 bits + 4bit sig */
-#define GSM_HR_BYTES 14 /* TS 101318 Chapter 5.2: 112 bits, no sig */
-#define GSM_EFR_BYTES 31 /* TS 101318 Chapter 5.3: 244 bits + 4bit sig */
-
static struct msgb *l1_to_rtppayload_fr(uint8_t *l1_payload, uint8_t payload_len)
{
struct msgb *msg;
diff --git a/src/osmo-bts-trx/gsm0503_coding.c b/src/osmo-bts-trx/gsm0503_coding.c
index fea25f9c..fde020e1 100644
--- a/src/osmo-bts-trx/gsm0503_coding.c
+++ b/src/osmo-bts-trx/gsm0503_coding.c
@@ -30,6 +30,7 @@
#include <osmocom/codec/codec.h>
#include <osmo-bts/logging.h>
+#include <osmo-bts/gsm_data.h>
#include "gsm0503_conv.h"
#include "gsm0503_parity.h"
@@ -722,13 +723,13 @@ int tch_fr_decode(uint8_t *tch_data, sbit_t *bursts, int net_order, int efr,
tch_efr_reassemble(tch_data, s);
- len = 31;
+ len = GSM_EFR_BYTES;
} else {
tch_fr_d_to_b(w, d);
tch_fr_reassemble(tch_data, w, net_order);
- len = 33;
+ len = GSM_FR_BYTES;
}
return len;
@@ -741,7 +742,7 @@ int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, int net_order)
int i;
switch (len) {
- case 31: /* TCH EFR */
+ case GSM_EFR_BYTES: /* TCH EFR */
tch_efr_disassemble(s, tch_data);
@@ -754,7 +755,7 @@ int tch_fr_encode(ubit_t *bursts, uint8_t *tch_data, int len, int net_order)
tch_efr_w_to_d(d, w);
goto coding_efr_fr;
- case 33: /* TCH FR */
+ case GSM_FR_BYTES: /* TCH FR */
tch_fr_disassemble(w, tch_data, net_order);
tch_fr_b_to_d(d, w);
@@ -771,7 +772,7 @@ coding_efr_fr:
h = 0;
break;
- case 23: /* FACCH */
+ case GSM_MACBLOCK_LEN: /* FACCH */
_xcch_encode_cB(cB, tch_data);
h = 1;
@@ -825,7 +826,7 @@ int tch_hr_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
return -1;
}
- return 23;
+ return GSM_MACBLOCK_LEN;
}
for (i=0; i<4; i++)
@@ -883,7 +884,7 @@ int tch_hr_encode(ubit_t *bursts, uint8_t *tch_data, int len)
&h, i>>1);
break;
- case 23: /* FACCH */
+ case GSM_MACBLOCK_LEN: /* FACCH */
_xcch_encode_cB(cB, tch_data);
h = 1;
@@ -929,7 +930,7 @@ int tch_afs_decode(uint8_t *tch_data, sbit_t *bursts, int codec_mode_req,
return -1;
}
- return 23;
+ return GSM_MACBLOCK_LEN;
}
for (i=0; i<4; i++) {
@@ -1103,7 +1104,7 @@ int tch_afs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
int i;
uint8_t id;
- if (len == 23) { /* FACCH */
+ if (len == GSM_MACBLOCK_LEN) { /* FACCH */
_xcch_encode_cB(cB, tch_data);
h = 1;
@@ -1292,7 +1293,7 @@ int tch_ahs_decode(uint8_t *tch_data, sbit_t *bursts, int odd,
return -1;
}
- return 23;
+ return GSM_MACBLOCK_LEN;
}
for (i=0; i<4; i++)
@@ -1458,7 +1459,7 @@ int tch_ahs_encode(ubit_t *bursts, uint8_t *tch_data, int len,
int i;
uint8_t id;
- if (len == 23) { /* FACCH */
+ if (len == GSM_MACBLOCK_LEN) { /* FACCH */
_xcch_encode_cB(cB, tch_data);
h = 1;
diff --git a/src/osmo-bts-trx/l1_if.c b/src/osmo-bts-trx/l1_if.c
index f3cb5bf1..a45ba05b 100644
--- a/src/osmo-bts-trx/l1_if.c
+++ b/src/osmo-bts-trx/l1_if.c
@@ -111,7 +111,7 @@ static void check_transceiver_availability_trx(struct trx_l1h *l1h, int avail)
oml_mo_state_chg(&trx->bb_transc.mo, -1, NM_AVSTATE_OK);
oml_mo_tx_sw_act_rep(&trx->bb_transc.mo);
- for (tn = 0; tn < 8; tn++)
+ for (tn = 0; tn < TRX_NR_TS; tn++)
oml_mo_state_chg(&trx->ts[tn].mo, NM_OPSTATE_DISABLED,
(l1h->config.slotmask & (1 << tn)) ?
NM_AVSTATE_DEPENDENCY :
@@ -122,7 +122,7 @@ static void check_transceiver_availability_trx(struct trx_l1h *l1h, int avail)
oml_mo_state_chg(&trx->bb_transc.mo, NM_OPSTATE_DISABLED,
NM_AVSTATE_OFF_LINE);
- for (tn = 0; tn < 8; tn++)
+ for (tn = 0; tn < TRX_NR_TS; tn++)
oml_mo_state_chg(&trx->ts[tn].mo, NM_OPSTATE_DISABLED,
NM_AVSTATE_OFF_LINE);
}
@@ -188,7 +188,7 @@ int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
trx_if_cmd_setmaxdly(l1h, l1h->config.maxdly);
l1h->config.maxdly_sent = 1;
}
- for (tn = 0; tn < 8; tn++) {
+ for (tn = 0; tn < TRX_NR_TS; tn++) {
if (l1h->config.slottype_valid[tn]
&& !l1h->config.slottype_sent[tn]) {
trx_if_cmd_setslot(l1h, tn,
@@ -205,7 +205,7 @@ int l1if_provision_transceiver_trx(struct trx_l1h *l1h)
l1h->config.rxgain_sent = 0;
l1h->config.power_sent = 0;
l1h->config.maxdly_sent = 0;
- for (tn = 0; tn < 8; tn++)
+ for (tn = 0; tn < TRX_NR_TS; tn++)
l1h->config.slottype_sent[tn] = 0;
}
@@ -227,7 +227,7 @@ int l1if_provision_transceiver(struct gsm_bts *bts)
l1h->config.rxgain_sent = 0;
l1h->config.power_sent = 0;
l1h->config.maxdly_sent = 0;
- for (tn = 0; tn < 8; tn++)
+ for (tn = 0; tn < TRX_NR_TS; tn++)
l1h->config.slottype_sent[tn] = 0;
l1if_provision_transceiver_trx(l1h);
}
@@ -714,3 +714,9 @@ int bts_model_oml_estab(struct gsm_bts *bts)
return 0;
}
+int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm)
+{
+#warning "implement bts_model_change_power\n"
+ LOGP(DL1C, LOGL_NOTICE, "Setting TRX output power not supported!\n");
+ return 0;
+}
diff --git a/src/osmo-bts-trx/l1_if.h b/src/osmo-bts-trx/l1_if.h
index 278537e1..2c672cb9 100644
--- a/src/osmo-bts-trx/l1_if.h
+++ b/src/osmo-bts-trx/l1_if.h
@@ -87,8 +87,8 @@ struct trx_chan_state {
int dl_encr_algo; /* A5/x encry algo uplink */
int ul_encr_key_len;
int dl_encr_key_len;
- uint8_t ul_encr_key[8];
- uint8_t dl_encr_key[8];
+ uint8_t ul_encr_key[MAX_A5_KEY_LEN];
+ uint8_t dl_encr_key[MAX_A5_KEY_LEN];
/* measurements */
struct {
@@ -136,9 +136,9 @@ struct trx_config {
uint8_t slotmask;
- int slottype_valid[8];
- uint8_t slottype[8];
- int slottype_sent[8];
+ int slottype_valid[TRX_NR_TS];
+ uint8_t slottype[TRX_NR_TS];
+ int slottype_sent[TRX_NR_TS];
};
struct trx_l1h {
@@ -153,15 +153,15 @@ struct trx_l1h {
/* transceiver config */
struct trx_config config;
- uint8_t mf_index[8]; /* selected multiframe index */
- uint32_t mf_last_fn[8]; /* last received frame */
- uint8_t mf_period[8]; /* period of multiframe */
- struct trx_sched_frame *mf_frames[8]; /* pointer to frame layout */
+ uint8_t mf_index[TRX_NR_TS]; /* selected multiframe index */
+ uint32_t mf_last_fn[TRX_NR_TS]; /* last received frame */
+ uint8_t mf_period[TRX_NR_TS]; /* period of multiframe */
+ const struct trx_sched_frame *mf_frames[TRX_NR_TS]; /* pointer to frame layout */
/* Channel states for all channels on all timeslots */
- struct trx_chan_state chan_states[8][_TRX_CHAN_MAX];
- struct llist_head dl_prims[8]; /* Queue primitves for TX */
- uint8_t ho_rach_detect[8][8];
+ struct trx_chan_state chan_states[TRX_NR_TS][_TRX_CHAN_MAX];
+ struct llist_head dl_prims[TRX_NR_TS]; /* Queue primitves for TX */
+ uint8_t ho_rach_detect[TRX_NR_TS][TS_MAX_LCHAN];
};
struct trx_l1h *l1if_open(struct gsm_bts_trx *trx);
diff --git a/src/osmo-bts-trx/main.c b/src/osmo-bts-trx/main.c
index 6f2dd4bc..ae85abef 100644
--- a/src/osmo-bts-trx/main.c
+++ b/src/osmo-bts-trx/main.c
@@ -34,7 +34,6 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <net/if.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/application.h>
@@ -66,43 +65,9 @@ static char *gsmtap_ip = 0;
static int rt_prio = -1;
static int trx_num = 1;
char *software_version = "0.0";
-uint8_t abis_mac[6] = { 0, 1, 2, 3, 4, 5 };
char *bsc_host = "localhost";
char *bts_id = "1801/0";
-// FIXME this is a hack
-static void get_mac(void)
-{
- struct if_nameindex *ifn = if_nameindex();
- struct ifreq ifr;
- int sock;
- int ret;
-
- sock = socket(AF_INET, SOCK_STREAM, 0);
- if (sock < 0)
- return;
-
- memset(&ifr, 0, sizeof(ifr));
- if (!ifn)
- return;
- while (ifn->if_name) {
- strncpy(ifr.ifr_name, ifn->if_name, sizeof(ifr.ifr_name)-1);
- ret = ioctl(sock, SIOCGIFHWADDR, &ifr);
- if (ret == 0 && !!memcmp(ifr.ifr_hwaddr.sa_data,
- "\0\0\0\0\0\0", 6)) {
- memcpy(abis_mac, ifr.ifr_hwaddr.sa_data, 6);
- printf("Using MAC address of %s: "
- "'%02x:%02x:%02x:%02x:%02x:%02x'\n",
- ifn->if_name,
- abis_mac[0], abis_mac[1], abis_mac[2],
- abis_mac[3], abis_mac[4], abis_mac[5]);
- break;
- }
- ifn++;
- }
-// if_freenameindex(ifn);
-}
-
int bts_model_init(struct gsm_bts *bts)
{
void *l1h;
@@ -285,8 +250,6 @@ int main(int argc, char **argv)
printf("((*))\n |\n / \\ OsmoBTS\n");
- get_mac();
-
tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context");
tall_msgb_ctx = talloc_named_const(tall_bts_ctx, 1, "msgb");
msgb_set_talloc_ctx(tall_msgb_ctx);
diff --git a/src/osmo-bts-trx/scheduler.c b/src/osmo-bts-trx/scheduler.c
index 8d0c8343..1710b4e5 100644
--- a/src/osmo-bts-trx/scheduler.c
+++ b/src/osmo-bts-trx/scheduler.c
@@ -30,6 +30,8 @@
#include <osmocom/core/bits.h>
#include <osmocom/gsm/a5.h>
+#include <osmocom/netif/rtp.h>
+
#include <osmo-bts/gsm_data.h>
#include <osmo-bts/logging.h>
#include <osmo-bts/rsl.h>
@@ -109,7 +111,8 @@ static int rx_tchh_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
enum trx_chan_type chan, uint8_t bid, sbit_t *bits, int8_t rssi,
float toa);
-static ubit_t dummy_burst[148] = {
+/*! \brief Dummy Burst (TS 05.02 Chapter 5.2.6) */
+static const ubit_t dummy_burst[148] = {
0,0,0,
1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,0,0,0,0,0,1,0,1,0,0,1,0,0,1,1,1,0,
0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,0,
@@ -119,7 +122,8 @@ static ubit_t dummy_burst[148] = {
0,0,0,
};
-static ubit_t fcch_burst[148] = {
+/*! \brief FCCH Burst (TS 05.02 Chapter 5.2.4) */
+static const ubit_t fcch_burst[148] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
@@ -127,6 +131,7 @@ static ubit_t fcch_burst[148] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};
+/*! \brief Training Sequences (TS 05.02 Chapter 5.2.3) */
static const ubit_t tsc[8][26] = {
{ 0,0,1,0,0,1,0,1,1,1,0,0,0,0,1,0,0,0,1,0,0,1,0,1,1,1, },
{ 0,0,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,0,1,0,1,1,0,1,1,1, },
@@ -138,6 +143,7 @@ static const ubit_t tsc[8][26] = {
{ 1,1,1,0,1,1,1,1,0,0,0,1,0,0,1,0,1,1,1,0,1,1,1,1,0,0, },
};
+/*! \brief SCH trainign sequence (TS 05.02 Chapter 5.2.5) */
static const ubit_t sch_train[64] = {
1,0,1,1,1,0,0,1,0,1,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,
0,0,1,0,1,1,0,1,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,0,0,1,1,0,1,1,
@@ -148,17 +154,26 @@ static const ubit_t sch_train[64] = {
*/
struct trx_chan_desc {
+ /*! \brief Is this on a PDCH (PS) ? */
int pdch;
+ /*! \brief TRX Channel Type */
enum trx_chan_type chan;
+ /*! \brief Channel Number (like in RSL) */
uint8_t chan_nr;
+ /*! \brief Link ID (like in RSL) */
uint8_t link_id;
+ /*! \brief Human-readable name */
const char *name;
+ /*! \brief function to call when we want to generate RTS.req to L2 */
trx_sched_rts_func *rts_fn;
+ /*! \brief function to call when DATA.req received from L2 */
trx_sched_dl_func *dl_fn;
+ /*! \brief function to call when burst received from PHY */
trx_sched_ul_func *ul_fn;
+ /*! \breif is this channel automatically active at start? */
int auto_active;
};
-struct trx_chan_desc trx_chan_desc[_TRX_CHAN_MAX] = {
+static const struct trx_chan_desc trx_chan_desc[_TRX_CHAN_MAX] = {
{ 0, TRXC_IDLE, 0, 0, "IDLE", NULL, tx_idle_fn, NULL, 1 },
{ 0, TRXC_FCCH, 0, 0, "FCCH", NULL, tx_fcch_fn, NULL, 1 },
{ 0, TRXC_SCH, 0, 0, "SCH", NULL, tx_sch_fn, NULL, 1 },
@@ -173,7 +188,7 @@ struct trx_chan_desc trx_chan_desc[_TRX_CHAN_MAX] = {
{ 0, TRXC_SDCCH4_2, 0x30, 0x00, "SDCCH/4(2)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SDCCH4_3, 0x38, 0x00, "SDCCH/4(3)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SDCCH8_0, 0x40, 0x00, "SDCCH/8(0)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
- { 0, TRXC_SDCCH8_1, 0x48, 0x00, "SDCCH/8(1)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
+ { 0, TRXC_SDCCH8_1, 0x48, 0x00, "SDCCH/8(1)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SDCCH8_2, 0x50, 0x00, "SDCCH/8(2)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SDCCH8_3, 0x58, 0x00, "SDCCH/8(3)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SDCCH8_4, 0x60, 0x00, "SDCCH/8(4)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
@@ -187,7 +202,7 @@ struct trx_chan_desc trx_chan_desc[_TRX_CHAN_MAX] = {
{ 0, TRXC_SACCH4_1, 0x28, 0x40, "SACCH/4(1)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SACCH4_2, 0x30, 0x40, "SACCH/4(2)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SACCH4_3, 0x38, 0x40, "SACCH/4(3)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
- { 0, TRXC_SACCH8_0, 0x40, 0x40, "SACCH/8(0)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
+ { 0, TRXC_SACCH8_0, 0x40, 0x40, "SACCH/8(0)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SACCH8_1, 0x48, 0x40, "SACCH/8(1)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SACCH8_2, 0x50, 0x40, "SACCH/8(2)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
{ 0, TRXC_SACCH8_3, 0x58, 0x40, "SACCH/8(3)", rts_data_fn, tx_data_fn, rx_data_fn, 0 },
@@ -215,7 +230,7 @@ int trx_sched_init(struct trx_l1h *l1h)
/* hack to get bts */
bts = l1h->trx->bts;
- for (tn = 0; tn < 8; tn++) {
+ for (tn = 0; tn < TRX_NR_TS; tn++) {
l1h->mf_index[tn] = 0;
l1h->mf_last_fn[tn] = 0;
INIT_LLIST_HEAD(&l1h->dl_prims[tn]);
@@ -236,7 +251,7 @@ void trx_sched_exit(struct trx_l1h *l1h)
LOGP(DL1C, LOGL_NOTICE, "Exit scheduler for trx=%u\n", l1h->trx->nr);
- for (tn = 0; tn < 8; tn++) {
+ for (tn = 0; tn < TRX_NR_TS; tn++) {
msgb_queue_flush(&l1h->dl_prims[tn]);
for (i = 0; i < _TRX_CHAN_MAX; i++) {
chan_state = &l1h->chan_states[tn][i];
@@ -250,7 +265,7 @@ void trx_sched_exit(struct trx_l1h *l1h)
}
}
/* clear lchan channel states */
- for (i = 0; i < 8; i++)
+ for (i = 0; i < TRX_NR_TS; i++)
l1h->trx->ts[tn].lchan[i].state = LCHAN_S_NONE;
}
}
@@ -450,7 +465,7 @@ static ubit_t *tx_fcch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
LOGP(DL1C, LOGL_DEBUG, "Transmitting %s fn=%u ts=%u trx=%u\n",
trx_chan_desc[chan].name, fn, tn, l1h->trx->nr);
- return fcch_burst;
+ return (ubit_t *) fcch_burst;
}
static ubit_t *tx_sch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
@@ -460,7 +475,7 @@ static ubit_t *tx_sch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
uint8_t sb_info[4];
struct gsm_time t;
uint8_t t3p, bsic;
-
+
LOGP(DL1C, LOGL_DEBUG, "Transmitting %s fn=%u ts=%u trx=%u\n",
trx_chan_desc[chan].name, fn, tn, l1h->trx->nr);
@@ -518,12 +533,12 @@ free_msg:
case PRIM_PH_DATA:
chan_nr = l1sap->u.data.chan_nr;
link_id = l1sap->u.data.link_id;
- prim_fn = ((l1sap->u.data.fn + 2715648 - fn) % 2715648);
+ prim_fn = ((l1sap->u.data.fn + GSM_HYPERFRAME - fn) % GSM_HYPERFRAME);
break;
case PRIM_TCH:
chan_nr = l1sap->u.tch.chan_nr;
link_id = 0;
- prim_fn = ((l1sap->u.tch.fn + 2715648 - fn) % 2715648);
+ prim_fn = ((l1sap->u.tch.fn + GSM_HYPERFRAME - fn) % GSM_HYPERFRAME);
break;
default:
goto wrong_type;
@@ -632,7 +647,7 @@ static ubit_t *tx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
goto send_burst;
}
- /* get burst from queue */
+ /* get mac block from queue */
msg = dequeue_prim(l1h, tn, fn, chan);
if (msg)
goto got_msg;
@@ -651,7 +666,7 @@ no_msg:
got_msg:
/* check validity of message */
- if (msgb_l2len(msg) != 23) {
+ if (msgb_l2len(msg) != GSM_MACBLOCK_LEN) {
LOGP(DL1C, LOGL_FATAL, "Prim not 23 bytes, please FIX! "
"(len=%d)\n", msgb_l2len(msg));
/* free message */
@@ -717,7 +732,7 @@ static ubit_t *tx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
goto send_burst;
}
- /* get burst from queue */
+ /* get mac block from queue */
msg = dequeue_prim(l1h, tn, fn, chan);
if (msg)
goto got_msg;
@@ -785,7 +800,7 @@ static void tx_tch_common(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
/* handle loss detection of received TCH frames */
if (rsl_cmode == RSL_CMOD_SPD_SPEECH
&& ++(l1h->chan_states[tn][chan].lost) > 5) {
- uint8_t tch_data[33];
+ uint8_t tch_data[GSM_FR_BYTES];
int len;
LOGP(DL1C, LOGL_NOTICE, "Missing TCH bursts detected, sending "
@@ -800,14 +815,14 @@ static void tx_tch_common(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
len = 15;
break;
}
- memset(tch_data, 0, 33);
- len = 33;
+ memset(tch_data, 0, GSM_FR_BYTES);
+ len = GSM_FR_BYTES;
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
if (chan != TRXC_TCHF)
goto inval_mode1;
- memset(tch_data, 0, 31);
- len = 31;
+ memset(tch_data, 0, GSM_EFR_BYTES);
+ len = GSM_EFR_BYTES;
break;
case GSM48_CMODE_SPEECH_AMR: /* AMR */
len = amr_compose_payload(tch_data,
@@ -865,7 +880,7 @@ inval_mode1:
}
/* check validity of message */
- if (msg_facch && msgb_l2len(msg_facch) != 23) {
+ if (msg_facch && msgb_l2len(msg_facch) != GSM_MACBLOCK_LEN) {
LOGP(DL1C, LOGL_FATAL, "Prim not 23 bytes, please FIX! "
"(len=%d)\n", msgb_l2len(msg_facch));
/* free message */
@@ -903,7 +918,7 @@ inval_mode1:
}
break;
}
- len = 33;
+ len = GSM_FR_BYTES;
if (msgb_l2len(msg_tch) >= 1
&& (msg_tch->l2h[0] >> 4) != 0xd) {
LOGP(DL1C, LOGL_NOTICE, "%s Transmitting 'bad "
@@ -916,7 +931,7 @@ inval_mode1:
case GSM48_CMODE_SPEECH_EFR: /* EFR */
if (chan != TRXC_TCHF)
goto inval_mode2;
- len = 31;
+ len = GSM_EFR_BYTES;
if (msgb_l2len(msg_tch) >= 1
&& (msg_tch->l2h[0] >> 4) != 0xc) {
LOGP(DL1C, LOGL_NOTICE, "%s Transmitting 'bad "
@@ -1213,6 +1228,7 @@ static int rx_rach_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
return 0;
}
+/*! \brief a single burst was received by the PHY, process it */
static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
enum trx_chan_type chan, uint8_t bid, sbit_t *bits, int8_t rssi,
float toa)
@@ -1225,7 +1241,7 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
uint8_t *rssi_num = &chan_state->rssi_num;
float *toa_sum = &chan_state->toa_sum;
uint8_t *toa_num = &chan_state->toa_num;
- uint8_t l2[23], l2_len;
+ uint8_t l2[GSM_MACBLOCK_LEN], l2_len;
int n_errors, n_bits_total;
int rc;
@@ -1300,7 +1316,7 @@ static int rx_data_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
trx_chan_desc[chan].name);
l2_len = 0;
} else
- l2_len = 23;
+ l2_len = GSM_MACBLOCK_LEN;
/* Send uplnk measurement information to L2 */
l1if_process_meas_res(l1h->trx, tn, fn, trx_chan_desc[chan].chan_nr | tn,
@@ -1385,7 +1401,7 @@ static int rx_pdtch_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
l2[0] = 7; /* valid frame */
- return compose_ph_data_ind(l1h, tn, (fn + 2715648 - 3) % 2715648, chan,
+ return compose_ph_data_ind(l1h, tn, (fn + GSM_HYPERFRAME - 3) % GSM_HYPERFRAME, chan,
l2, rc + 1, *rssi_sum / *rssi_num);
}
@@ -1468,7 +1484,7 @@ static int rx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
(float)n_errors/(float)n_bits_total);
amr = 2; /* we store tch_data + 2 header bytes */
/* only good speech frames get rtp header */
- if (rc != 23 && rc >= 4) {
+ if (rc != GSM_MACBLOCK_LEN && rc >= 4) {
rc = amr_compose_payload(tch_data,
chan_state->codec[chan_state->ul_cmr],
chan_state->codec[chan_state->ul_ft], 0);
@@ -1499,20 +1515,20 @@ static int rx_tchf_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
}
/* FACCH */
- if (rc == 23) {
- compose_ph_data_ind(l1h, tn, (fn + 2715648 - 7) % 2715648, chan,
- tch_data + amr, 23, rssi);
+ if (rc == GSM_MACBLOCK_LEN) {
+ compose_ph_data_ind(l1h, tn, (fn + GSM_HYPERFRAME - 7) % GSM_HYPERFRAME, chan,
+ tch_data + amr, GSM_MACBLOCK_LEN, rssi);
bfi:
if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
/* indicate bad frame */
switch (tch_mode) {
case GSM48_CMODE_SPEECH_V1: /* FR */
- memset(tch_data, 0, 33);
- rc = 33;
+ memset(tch_data, 0, GSM_FR_BYTES);
+ rc = GSM_FR_BYTES;
break;
case GSM48_CMODE_SPEECH_EFR: /* EFR */
- memset(tch_data, 0, 31);
- rc = 31;
+ memset(tch_data, 0, GSM_EFR_BYTES);
+ rc = GSM_EFR_BYTES;
break;
case GSM48_CMODE_SPEECH_AMR: /* AMR */
rc = amr_compose_payload(tch_data,
@@ -1535,7 +1551,7 @@ bfi:
return 0;
/* TCH or BFI */
- return compose_tch_ind(l1h, tn, (fn + 2715648 - 7) % 2715648, chan,
+ return compose_tch_ind(l1h, tn, (fn + GSM_HYPERFRAME - 7) % GSM_HYPERFRAME, chan,
tch_data, rc);
}
@@ -1556,7 +1572,7 @@ static int rx_tchh_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
if (chan_state->ho_rach_detect == 1)
return rx_rach_fn(l1h, tn, fn, chan, bid, bits, rssi, toa);
- LOGP(DL1C, LOGL_DEBUG, "TCH/H received %s fn=%u ts=%u trx=%u bid=%u\n",
+ LOGP(DL1C, LOGL_DEBUG, "TCH/H received %s fn=%u ts=%u trx=%u bid=%u\n",
trx_chan_desc[chan].name, fn, tn, l1h->trx->nr, bid);
/* alloc burst memory, if not already */
@@ -1630,7 +1646,7 @@ static int rx_tchh_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
(float)n_errors/(float)n_bits_total);
amr = 2; /* we store tch_data + 2 two */
/* only good speech frames get rtp header */
- if (rc != 23 && rc >= 4) {
+ if (rc != GSM_MACBLOCK_LEN && rc >= 4) {
rc = amr_compose_payload(tch_data,
chan_state->codec[chan_state->ul_cmr],
chan_state->codec[chan_state->ul_ft], 0);
@@ -1662,11 +1678,11 @@ static int rx_tchh_fn(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
}
/* FACCH */
- if (rc == 23) {
+ if (rc == GSM_MACBLOCK_LEN) {
chan_state->ul_ongoing_facch = 1;
compose_ph_data_ind(l1h, tn,
- (fn + 2715648 - 10 - ((fn % 26) >= 19)) % 2715648, chan,
- tch_data + amr, 23, rssi);
+ (fn + GSM_HYPERFRAME - 10 - ((fn % 26) >= 19)) % GSM_HYPERFRAME, chan,
+ tch_data + amr, GSM_MACBLOCK_LEN, rssi);
bfi:
if (rsl_cmode == RSL_CMOD_SPD_SPEECH) {
/* indicate bad frame */
@@ -1703,7 +1719,7 @@ bfi:
* start of frame.
*/
return compose_tch_ind(l1h, tn,
- (fn + 2715648 - 10 - ((fn%26)==19) - ((fn%26)==20)) % 2715648,
+ (fn + GSM_HYPERFRAME - 10 - ((fn%26)==19) - ((fn%26)==20)) % GSM_HYPERFRAME,
chan, tch_data, rc);
}
@@ -1714,13 +1730,17 @@ bfi:
/* frame structures */
struct trx_sched_frame {
+ /*! \brief downlink TRX channel type */
enum trx_chan_type dl_chan;
+ /*! \brief downlink block ID */
uint8_t dl_bid;
+ /*! \breff uplink TRX channel type */
enum trx_chan_type ul_chan;
+ /*! \brief uplink block ID */
uint8_t ul_bid;
};
-static struct trx_sched_frame frame_bcch[51] = {
+static const struct trx_sched_frame frame_bcch[51] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_FCCH, 0, TRXC_RACH, 0 },
{ TRXC_SCH, 0, TRXC_RACH, 0 },
@@ -1745,7 +1765,7 @@ static struct trx_sched_frame frame_bcch[51] = {
{ TRXC_IDLE, 0, TRXC_RACH, 0 },
};
-static struct trx_sched_frame frame_bcch_sdcch4[102] = {
+static const struct trx_sched_frame frame_bcch_sdcch4[102] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_FCCH, 0, TRXC_SDCCH4_3, 0 },
{ TRXC_SCH, 0, TRXC_SDCCH4_3, 1 },
@@ -1852,7 +1872,7 @@ static struct trx_sched_frame frame_bcch_sdcch4[102] = {
{ TRXC_IDLE, 0, TRXC_SDCCH4_2, 3 },
};
-static struct trx_sched_frame frame_sdcch8[102] = {
+static const struct trx_sched_frame frame_sdcch8[102] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_SDCCH8_0, 0, TRXC_SACCH8_5, 0 },
{ TRXC_SDCCH8_0, 1, TRXC_SACCH8_5, 1 },
@@ -1959,7 +1979,7 @@ static struct trx_sched_frame frame_sdcch8[102] = {
{ TRXC_IDLE, 0, TRXC_SACCH8_4, 3 },
};
-static struct trx_sched_frame frame_tchf_ts0[104] = {
+static const struct trx_sched_frame frame_tchf_ts0[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -1995,7 +2015,7 @@ static struct trx_sched_frame frame_tchf_ts0[104] = {
{ TRXC_IDLE, 0, TRXC_IDLE, 0 },
};
-static struct trx_sched_frame frame_tchf_ts1[104] = {
+static const struct trx_sched_frame frame_tchf_ts1[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2031,7 +2051,7 @@ static struct trx_sched_frame frame_tchf_ts1[104] = {
{ TRXC_SACCHTF, 3, TRXC_SACCHTF, 3 },
};
-static struct trx_sched_frame frame_tchf_ts2[104] = {
+static const struct trx_sched_frame frame_tchf_ts2[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2067,7 +2087,7 @@ static struct trx_sched_frame frame_tchf_ts2[104] = {
{ TRXC_IDLE, 0, TRXC_IDLE, 0 },
};
-static struct trx_sched_frame frame_tchf_ts3[104] = {
+static const struct trx_sched_frame frame_tchf_ts3[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2103,7 +2123,7 @@ static struct trx_sched_frame frame_tchf_ts3[104] = {
{ TRXC_SACCHTF, 2, TRXC_SACCHTF, 2 },
};
-static struct trx_sched_frame frame_tchf_ts4[104] = {
+static const struct trx_sched_frame frame_tchf_ts4[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2139,7 +2159,7 @@ static struct trx_sched_frame frame_tchf_ts4[104] = {
{ TRXC_IDLE, 0, TRXC_IDLE, 0 },
};
-static struct trx_sched_frame frame_tchf_ts5[104] = {
+static const struct trx_sched_frame frame_tchf_ts5[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2175,7 +2195,7 @@ static struct trx_sched_frame frame_tchf_ts5[104] = {
{ TRXC_SACCHTF, 1, TRXC_SACCHTF, 1 },
};
-static struct trx_sched_frame frame_tchf_ts6[104] = {
+static const struct trx_sched_frame frame_tchf_ts6[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2211,7 +2231,7 @@ static struct trx_sched_frame frame_tchf_ts6[104] = {
{ TRXC_IDLE, 0, TRXC_IDLE, 0 },
};
-static struct trx_sched_frame frame_tchf_ts7[104] = {
+static const struct trx_sched_frame frame_tchf_ts7[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
{ TRXC_TCHF, 0, TRXC_TCHF, 0 }, { TRXC_TCHF, 1, TRXC_TCHF, 1 }, { TRXC_TCHF, 2, TRXC_TCHF, 2 }, { TRXC_TCHF, 3, TRXC_TCHF, 3 },
@@ -2247,7 +2267,7 @@ static struct trx_sched_frame frame_tchf_ts7[104] = {
{ TRXC_SACCHTF, 0, TRXC_SACCHTF, 0 },
};
-static struct trx_sched_frame frame_tchh_ts01[104] = {
+static const struct trx_sched_frame frame_tchh_ts01[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
@@ -2283,7 +2303,7 @@ static struct trx_sched_frame frame_tchh_ts01[104] = {
{ TRXC_SACCHTH_1, 3, TRXC_SACCHTH_1, 3 },
};
-static struct trx_sched_frame frame_tchh_ts23[104] = {
+static const struct trx_sched_frame frame_tchh_ts23[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
@@ -2319,7 +2339,7 @@ static struct trx_sched_frame frame_tchh_ts23[104] = {
{ TRXC_SACCHTH_1, 2, TRXC_SACCHTH_1, 2 },
};
-static struct trx_sched_frame frame_tchh_ts45[104] = {
+static const struct trx_sched_frame frame_tchh_ts45[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
@@ -2355,7 +2375,7 @@ static struct trx_sched_frame frame_tchh_ts45[104] = {
{ TRXC_SACCHTH_1, 1, TRXC_SACCHTH_1, 1 },
};
-static struct trx_sched_frame frame_tchh_ts67[104] = {
+static const struct trx_sched_frame frame_tchh_ts67[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
{ TRXC_TCHH_0, 0, TRXC_TCHH_0, 0 }, { TRXC_TCHH_1, 0, TRXC_TCHH_1, 0 }, { TRXC_TCHH_0, 1, TRXC_TCHH_0, 1 }, { TRXC_TCHH_1, 1, TRXC_TCHH_1, 1 },
@@ -2391,7 +2411,7 @@ static struct trx_sched_frame frame_tchh_ts67[104] = {
{ TRXC_SACCHTH_1, 0, TRXC_SACCHTH_1, 0 },
};
-static struct trx_sched_frame frame_pdch[104] = {
+static const struct trx_sched_frame frame_pdch[104] = {
/* dl_chan dl_bid ul_chan ul_bid */
{ TRXC_PDTCH, 0, TRXC_PDTCH, 0 }, { TRXC_PDTCH, 1, TRXC_PDTCH, 1 }, { TRXC_PDTCH, 2, TRXC_PDTCH, 2 }, { TRXC_PDTCH, 3, TRXC_PDTCH, 3 },
{ TRXC_PDTCH, 0, TRXC_PDTCH, 0 }, { TRXC_PDTCH, 1, TRXC_PDTCH, 1 }, { TRXC_PDTCH, 2, TRXC_PDTCH, 2 }, { TRXC_PDTCH, 3, TRXC_PDTCH, 3 },
@@ -2429,14 +2449,19 @@ static struct trx_sched_frame frame_pdch[104] = {
/* multiframe structure */
struct trx_sched_multiframe {
+ /*! \brief physical channel config (channel combination) */
enum gsm_phys_chan_config pchan;
+ /*! \brief applies to which timeslots? */
uint8_t slotmask;
+ /*! \brief repeats how many frames */
uint8_t period;
- struct trx_sched_frame *frames;
+ /*! \brief pointer to scheduling structure */
+ const struct trx_sched_frame *frames;
+ /*! \brife human-readable name */
const char *name;
};
-static struct trx_sched_multiframe trx_sched_multiframes[] = {
+static const struct trx_sched_multiframe trx_sched_multiframes[] = {
{ GSM_PCHAN_NONE, 0xff, 0, NULL, "NONE"},
{ GSM_PCHAN_CCCH, 0xff, 51, frame_bcch, "BCCH+CCCH" },
{ GSM_PCHAN_CCCH_SDCCH4, 0xff, 102, frame_bcch_sdcch4, "BCCH+CCCH+SDCCH/4+SACCH/4" },
@@ -2654,7 +2679,7 @@ int trx_sched_set_cipher(struct trx_l1h *l1h, uint8_t chan_nr, int downlink,
/* process ready-to-send */
static int trx_sched_rts(struct trx_l1h *l1h, uint8_t tn, uint32_t fn)
{
- struct trx_sched_frame *frame;
+ const struct trx_sched_frame *frame;
uint8_t offset, period, bid;
trx_sched_rts_func *func;
enum trx_chan_type chan;
@@ -2692,7 +2717,7 @@ static int trx_sched_rts(struct trx_l1h *l1h, uint8_t tn, uint32_t fn)
static const ubit_t *trx_sched_dl_burst(struct trx_l1h *l1h, uint8_t tn,
uint32_t fn)
{
- struct trx_sched_frame *frame;
+ const struct trx_sched_frame *frame;
uint8_t offset, period, bid;
trx_sched_dl_func *func;
enum trx_chan_type chan;
@@ -2705,7 +2730,7 @@ static const ubit_t *trx_sched_dl_burst(struct trx_l1h *l1h, uint8_t tn,
period = l1h->mf_period[tn];
offset = fn % period;
frame = l1h->mf_frames[tn] + offset;
-
+
chan = frame->dl_chan;
bid = frame->dl_bid;
func = trx_chan_desc[chan].dl_fn;
@@ -2738,7 +2763,7 @@ if (0) if (chan != TRXC_IDLE) // hack
LOGP(DL1C, LOGL_DEBUG, "No burst data for %s fn=%u ts=%u "
"burst=%d on C0, so filling with dummy burst\n",
trx_chan_desc[chan].name, fn, tn, bid);
- bits = dummy_burst;
+ bits = (ubit_t *) dummy_burst;
}
return bits;
@@ -2748,7 +2773,7 @@ if (0) if (chan != TRXC_IDLE) // hack
int trx_sched_ul_burst(struct trx_l1h *l1h, uint8_t tn, uint32_t current_fn,
sbit_t *bits, int8_t rssi, float toa)
{
- struct trx_sched_frame *frame;
+ const struct trx_sched_frame *frame;
uint8_t offset, period, bid;
trx_sched_ul_func *func;
enum trx_chan_type chan;
@@ -2758,12 +2783,12 @@ int trx_sched_ul_burst(struct trx_l1h *l1h, uint8_t tn, uint32_t current_fn,
return -EINVAL;
/* calculate how many frames have been elapsed */
- elapsed = (current_fn + 2715648 - l1h->mf_last_fn[tn]) % 2715648;
+ elapsed = (current_fn + GSM_HYPERFRAME - l1h->mf_last_fn[tn]) % GSM_HYPERFRAME;
/* start counting from last fn + 1, but only if not too many fn have
* been elapsed */
if (elapsed < 10)
- fn = (l1h->mf_last_fn[tn] + 1) % 2715648;
+ fn = (l1h->mf_last_fn[tn] + 1) % GSM_HYPERFRAME;
else
fn = current_fn;
@@ -2818,7 +2843,7 @@ next_frame:
if (fn == current_fn)
break;
- fn = (fn + 1) % 2715648;
+ fn = (fn + 1) % GSM_HYPERFRAME;
}
l1h->mf_last_fn[tn] = fn;
@@ -2840,7 +2865,7 @@ static int trx_sched_fn(uint32_t fn)
/* advance frame number, so the transceiver has more time until
* it must be transmitted. */
- fn = (fn + trx_clock_advance) % 2715648;
+ fn = (fn + trx_clock_advance) % GSM_HYPERFRAME;
/* process every TRX */
llist_for_each_entry(trx, &bts->trx_list, list) {
@@ -2851,24 +2876,18 @@ static int trx_sched_fn(uint32_t fn)
continue;
/* process every TS of TRX */
- for (tn = 0; tn < 8; tn++) {
+ for (tn = 0; tn < TRX_NR_TS; tn++) {
/* ignore disabled slots */
if (!(l1h->config.slotmask & (1 << tn)))
continue;
/* ready-to-send */
trx_sched_rts(l1h, tn,
- (fn + trx_rts_advance) % 2715648);
+ (fn + trx_rts_advance) % GSM_HYPERFRAME);
/* get burst for FN */
bits = trx_sched_dl_burst(l1h, tn, fn);
if (!bits) {
-#if 0
- /* if no bits, send dummy burst with no gain */
- bits = dummy_burst;
- gain = 128;
-#else
/* if no bits, send no burst */
continue;
-#endif
} else
gain = 0;
trx_if_data(l1h, tn, fn, gain, bits);
@@ -2937,7 +2956,7 @@ no_clock:
tv_clock->tv_sec++;
tv_clock->tv_usec -= 1000000;
}
- transceiver_last_fn = (transceiver_last_fn + 1) % 2715648;
+ transceiver_last_fn = (transceiver_last_fn + 1) % GSM_HYPERFRAME;
trx_sched_fn(transceiver_last_fn);
elapsed -= FRAME_DURATION_uS;
}
@@ -2997,9 +3016,9 @@ new_clock:
+ (tv_now.tv_usec - tv_clock->tv_usec);
/* how much frames have been elapsed since last fn processed */
- elapsed_fn = (fn + 2715648 - transceiver_last_fn) % 2715648;
+ elapsed_fn = (fn + GSM_HYPERFRAME - transceiver_last_fn) % GSM_HYPERFRAME;
if (elapsed_fn >= 135774)
- elapsed_fn -= 2715648;
+ elapsed_fn -= GSM_HYPERFRAME;
/* check for max clock skew */
if (elapsed_fn > MAX_FN_SKEW || elapsed_fn < -MAX_FN_SKEW) {
@@ -3031,7 +3050,7 @@ new_clock:
/* transmit what we still need to transmit */
while (fn != transceiver_last_fn) {
- transceiver_last_fn = (transceiver_last_fn + 1) % 2715648;
+ transceiver_last_fn = (transceiver_last_fn + 1) % GSM_HYPERFRAME;
trx_sched_fn(transceiver_last_fn);
}
diff --git a/src/osmo-bts-trx/scheduler.h b/src/osmo-bts-trx/scheduler.h
index ce7ddad8..3e306937 100644
--- a/src/osmo-bts-trx/scheduler.h
+++ b/src/osmo-bts-trx/scheduler.h
@@ -1,43 +1,52 @@
#ifndef TRX_SCHEDULER_H
#define TRX_SCHEDULER_H
+/*! \brief how many frame numbers in advance we should send bursts to PHY */
extern uint32_t trx_clock_advance;
+/*! \brief advance RTS.ind to L2 by that many clocks */
extern uint32_t trx_rts_advance;
+/*! \brief last frame number as received from PHY */
extern uint32_t transceiver_last_fn;
+/*! \brief Initialize the scheudler data structures */
int trx_sched_init(struct trx_l1h *l1h);
+/*! \brief De-initialize the scheudler data structures */
void trx_sched_exit(struct trx_l1h *l1h);
+/*! \brief Handle a PH-DATA.req from L2 down to L1 */
int trx_sched_ph_data_req(struct trx_l1h *l1h, struct osmo_phsap_prim *l1sap);
+/*! \brief Handle a PH-TCH.req from L2 down to L1 */
int trx_sched_tch_req(struct trx_l1h *l1h, struct osmo_phsap_prim *l1sap);
+/*! \brief PHY informs us of new (current) GSM freme nunmber */
int trx_sched_clock(uint32_t fn);
+/*! \brief handle an UL burst received by PHY */
int trx_sched_ul_burst(struct trx_l1h *l1h, uint8_t tn, uint32_t fn,
sbit_t *bits, int8_t rssi, float toa);
-/* set multiframe scheduler to given pchan */
+/*! \brief set multiframe scheduler to given physical channel config */
int trx_sched_set_pchan(struct trx_l1h *l1h, uint8_t tn,
enum gsm_phys_chan_config pchan);
-/* setting all logical channels given attributes to active/inactive */
+/*! \brief set all matching logical channels active/inactive */
int trx_sched_set_lchan(struct trx_l1h *l1h, uint8_t chan_nr, uint8_t link_id,
int active);
-/* setting all logical channels given attributes to active/inactive */
+/*! \brief set mode of all matching logical channels to given mode(s) */
int trx_sched_set_mode(struct trx_l1h *l1h, uint8_t chan_nr, uint8_t rsl_cmode,
uint8_t tch_mode, int codecs, uint8_t codec0, uint8_t codec1,
uint8_t codec2, uint8_t codec3, uint8_t initial_codec,
uint8_t handover);
-/* setting cipher on logical channels */
+/*! \brief set ciphering on given logical channels */
int trx_sched_set_cipher(struct trx_l1h *l1h, uint8_t chan_nr, int downlink,
int algo, uint8_t *key, int key_len);
-/* close all logical channels and reset timeslots */
+/* \brief close all logical channels and reset timeslots */
void trx_sched_reset(struct trx_l1h *l1h);
#endif /* TRX_SCHEDULER_H */
diff --git a/src/osmo-bts-trx/trx_if.c b/src/osmo-bts-trx/trx_if.c
index 69ad8415..419fea64 100644
--- a/src/osmo-bts-trx/trx_if.c
+++ b/src/osmo-bts-trx/trx_if.c
@@ -139,8 +139,8 @@ static int trx_clk_read_cb(struct osmo_fd *ofd, unsigned int what)
sscanf(buf, "IND CLOCK %u", &fn);
LOGP(DTRX, LOGL_INFO, "Clock indication: fn=%u\n", fn);
- if (fn >= 2715648) {
- fn %= 2715648;
+ if (fn >= GSM_HYPERFRAME) {
+ fn %= GSM_HYPERFRAME;
LOGP(DTRX, LOGL_ERROR, "Indicated clock's FN is not wrapping "
"correctly, correcting to fn=%u\n", fn);
}
@@ -437,7 +437,7 @@ static int trx_data_read_cb(struct osmo_fd *ofd, unsigned int what)
LOGP(DTRX, LOGL_ERROR, "Illegal TS %d\n", tn);
return -EINVAL;
}
- if (fn >= 2715648) {
+ if (fn >= GSM_HYPERFRAME) {
LOGP(DTRX, LOGL_ERROR, "Illegal FN %u\n", fn);
return -EINVAL;
}
diff --git a/src/osmo-bts-trx/trx_vty.c b/src/osmo-bts-trx/trx_vty.c
index e3e9c364..43c00f88 100644
--- a/src/osmo-bts-trx/trx_vty.c
+++ b/src/osmo-bts-trx/trx_vty.c
@@ -100,7 +100,7 @@ DEFUN(show_transceiver, show_transceiver_cmd, "show transceiver",
VTY_NEWLINE);
else
vty_out(vty, " maxdly : undefined%s", VTY_NEWLINE);
- for (tn = 0; tn < 8; tn++) {
+ for (tn = 0; tn < TRX_NR_TS; tn++) {
if (!((1 << tn) & l1h->config.slotmask))
vty_out(vty, " slot #%d: unsupported%s", tn,
VTY_NEWLINE);
@@ -299,7 +299,7 @@ DEFUN(cfg_trx_slotmask, cfg_trx_slotmask_cmd,
uint8_t tn;
l1h->config.slotmask = 0;
- for (tn = 0; tn < 8; tn++)
+ for (tn = 0; tn < TRX_NR_TS; tn++)
if (argv[tn][0] == '1')
l1h->config.slotmask |= (1 << tn);
diff --git a/tests/bursts/bursts_test.c b/tests/bursts/bursts_test.c
index cc0eacff..43764ab3 100644
--- a/tests/bursts/bursts_test.c
+++ b/tests/bursts/bursts_test.c
@@ -26,6 +26,7 @@
#include <osmocom/core/bits.h>
#include <osmocom/core/utils.h>
+#include <osmo-bts/gsm_data.h>
#include "../../src/osmo-bts-trx/gsm0503_coding.h"
@@ -184,7 +185,7 @@ static void test_sch(uint8_t *info)
static void test_fr(uint8_t *speech, int len)
{
- uint8_t result[33];
+ uint8_t result[GSM_FR_BYTES];
ubit_t bursts_u[116 * 8];
sbit_t bursts_s[116 * 8];
int n_errors, n_bits_total;
@@ -438,8 +439,8 @@ uint8_t test_macblock[][54] = {
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17 },
};
-uint8_t test_speech_fr[33];
-uint8_t test_speech_efr[31];
+uint8_t test_speech_fr[GSM_FR_BYTES];
+uint8_t test_speech_efr[GSM_EFR_BYTES];
uint8_t test_speech_hr[15];
int main(int argc, char **argv)