2016-07-23 19:40:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <osmocom/core/linuxlist.h>
|
|
|
|
#include <osmocom/core/select.h>
|
|
|
|
#include <osmocom/core/timer.h>
|
2017-05-31 02:28:40 +00:00
|
|
|
#include <osmocom/core/fsm.h>
|
|
|
|
|
2022-07-04 15:25:27 +00:00
|
|
|
#include <osmocom/bb/trxcon/l1sched.h>
|
2017-06-09 13:53:20 +00:00
|
|
|
|
2020-05-15 10:29:04 +00:00
|
|
|
#define TRXC_BUF_SIZE 1024
|
|
|
|
#define TRXD_BUF_SIZE 512
|
|
|
|
|
2017-07-08 11:16:42 +00:00
|
|
|
/* Forward declaration to avoid mutual include */
|
|
|
|
struct l1ctl_link;
|
|
|
|
|
2017-05-31 02:28:40 +00:00
|
|
|
enum trx_fsm_states {
|
|
|
|
TRX_STATE_OFFLINE = 0,
|
|
|
|
TRX_STATE_IDLE,
|
|
|
|
TRX_STATE_ACTIVE,
|
|
|
|
TRX_STATE_RSP_WAIT,
|
|
|
|
};
|
2016-07-23 19:40:41 +00:00
|
|
|
|
|
|
|
struct trx_instance {
|
|
|
|
struct osmo_fd trx_ofd_ctrl;
|
|
|
|
struct osmo_fd trx_ofd_data;
|
|
|
|
|
|
|
|
struct osmo_timer_list trx_ctrl_timer;
|
|
|
|
struct llist_head trx_ctrl_list;
|
2017-05-31 02:28:40 +00:00
|
|
|
struct osmo_fsm_inst *fsm;
|
2019-05-30 13:21:45 +00:00
|
|
|
|
|
|
|
/* HACK: we need proper state machines */
|
2017-05-31 02:28:40 +00:00
|
|
|
uint32_t prev_state;
|
2019-05-30 13:21:45 +00:00
|
|
|
bool powered_up;
|
2017-07-12 10:54:09 +00:00
|
|
|
|
|
|
|
/* GSM L1 specific */
|
2018-09-05 18:47:50 +00:00
|
|
|
uint16_t pm_band_arfcn_start;
|
|
|
|
uint16_t pm_band_arfcn_stop;
|
2017-07-06 04:50:34 +00:00
|
|
|
uint16_t band_arfcn;
|
2017-07-26 14:28:53 +00:00
|
|
|
uint8_t tx_power;
|
2017-07-12 10:54:09 +00:00
|
|
|
uint8_t bsic;
|
2017-07-16 09:52:57 +00:00
|
|
|
uint8_t tsc;
|
2017-07-26 14:28:53 +00:00
|
|
|
int8_t ta;
|
2017-06-09 13:53:20 +00:00
|
|
|
|
|
|
|
/* Scheduler stuff */
|
2022-07-01 18:42:26 +00:00
|
|
|
struct l1sched_state sched;
|
|
|
|
struct l1sched_ts *ts_list[TRX_TS_COUNT];
|
2017-07-08 11:16:42 +00:00
|
|
|
|
|
|
|
/* Bind L1CTL link */
|
|
|
|
struct l1ctl_link *l1l;
|
2016-07-23 19:40:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct trx_ctrl_msg {
|
|
|
|
struct llist_head list;
|
2020-05-15 10:29:04 +00:00
|
|
|
char cmd[TRXC_BUF_SIZE];
|
2017-05-31 02:28:40 +00:00
|
|
|
int retry_cnt;
|
2016-07-23 19:40:41 +00:00
|
|
|
int critical;
|
|
|
|
int cmd_len;
|
|
|
|
};
|
|
|
|
|
2019-01-17 04:03:48 +00:00
|
|
|
struct trx_instance *trx_if_open(void *tall_ctx,
|
|
|
|
const char *local_host, const char *remote_host, uint16_t port);
|
2017-05-31 02:28:40 +00:00
|
|
|
void trx_if_flush_ctrl(struct trx_instance *trx);
|
2016-07-23 19:40:41 +00:00
|
|
|
void trx_if_close(struct trx_instance *trx);
|
|
|
|
|
|
|
|
int trx_if_cmd_poweron(struct trx_instance *trx);
|
|
|
|
int trx_if_cmd_poweroff(struct trx_instance *trx);
|
2017-06-03 12:02:20 +00:00
|
|
|
int trx_if_cmd_echo(struct trx_instance *trx);
|
2016-07-23 19:40:41 +00:00
|
|
|
|
2017-12-04 16:49:29 +00:00
|
|
|
int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta);
|
|
|
|
|
2018-09-05 18:47:50 +00:00
|
|
|
int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t band_arfcn);
|
|
|
|
int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t band_arfcn);
|
2016-07-23 19:40:41 +00:00
|
|
|
|
|
|
|
int trx_if_cmd_setslot(struct trx_instance *trx, uint8_t tn, uint8_t type);
|
2018-09-06 18:14:14 +00:00
|
|
|
int trx_if_cmd_setfh(struct trx_instance *trx, uint8_t hsn,
|
|
|
|
uint8_t maio, uint16_t *ma, size_t ma_len);
|
2017-07-12 10:49:43 +00:00
|
|
|
|
2017-07-13 21:10:41 +00:00
|
|
|
int trx_if_cmd_measure(struct trx_instance *trx,
|
2018-09-05 18:47:50 +00:00
|
|
|
uint16_t band_arfcn_start, uint16_t band_arfcn_stop);
|
2017-07-13 21:10:41 +00:00
|
|
|
|
2021-06-14 21:14:34 +00:00
|
|
|
int trx_if_tx_burst(struct trx_instance *trx,
|
2022-07-01 18:42:26 +00:00
|
|
|
const struct l1sched_burst_req *br);
|