Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/linuxlist.h> |
| 4 | #include <osmocom/core/select.h> |
| 5 | #include <osmocom/core/timer.h> |
| 6 | #include <osmocom/core/fsm.h> |
| 7 | |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 8 | #include <osmocom/gsm/gsm_utils.h> |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 9 | |
| 10 | #define TRXC_BUF_SIZE 1024 |
| 11 | #define TRXD_BUF_SIZE 512 |
| 12 | |
| 13 | /* Forward declaration to avoid mutual include */ |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 14 | struct l1sched_burst_req; |
| 15 | struct trxcon_inst; |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 16 | |
| 17 | enum trx_fsm_states { |
| 18 | TRX_STATE_OFFLINE = 0, |
| 19 | TRX_STATE_IDLE, |
| 20 | TRX_STATE_ACTIVE, |
| 21 | TRX_STATE_RSP_WAIT, |
| 22 | }; |
| 23 | |
| 24 | struct trx_instance { |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 25 | /* trxcon instance we belong to */ |
| 26 | struct trxcon_inst *trxcon; |
| 27 | |
Eric | a378a1d | 2022-07-19 21:12:58 +0200 | [diff] [blame] | 28 | struct osmo_fd trx_ofd_ctrl; |
| 29 | struct osmo_fd trx_ofd_data; |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 30 | |
| 31 | struct osmo_timer_list trx_ctrl_timer; |
| 32 | struct llist_head trx_ctrl_list; |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 33 | struct osmo_fsm_inst *fi; |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 34 | |
| 35 | /* HACK: we need proper state machines */ |
| 36 | uint32_t prev_state; |
| 37 | bool powered_up; |
| 38 | |
| 39 | /* GSM L1 specific */ |
| 40 | uint16_t pm_band_arfcn_start; |
| 41 | uint16_t pm_band_arfcn_stop; |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | struct trx_ctrl_msg { |
| 45 | struct llist_head list; |
| 46 | char cmd[TRXC_BUF_SIZE]; |
| 47 | int retry_cnt; |
| 48 | int critical; |
| 49 | int cmd_len; |
| 50 | }; |
| 51 | |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 52 | struct trx_instance *trx_if_open(struct trxcon_inst *trxcon, |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 53 | const char *local_host, const char *remote_host, uint16_t port); |
| 54 | void trx_if_flush_ctrl(struct trx_instance *trx); |
| 55 | void trx_if_close(struct trx_instance *trx); |
| 56 | |
| 57 | int trx_if_cmd_poweron(struct trx_instance *trx); |
| 58 | int trx_if_cmd_poweroff(struct trx_instance *trx); |
| 59 | int trx_if_cmd_echo(struct trx_instance *trx); |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 60 | |
| 61 | int trx_if_cmd_setta(struct trx_instance *trx, int8_t ta); |
| 62 | |
| 63 | int trx_if_cmd_rxtune(struct trx_instance *trx, uint16_t band_arfcn); |
| 64 | int trx_if_cmd_txtune(struct trx_instance *trx, uint16_t band_arfcn); |
| 65 | |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 66 | int trx_if_cmd_setslot(struct trx_instance *trx, uint8_t tn, |
| 67 | enum gsm_phys_chan_config pchan); |
| 68 | int trx_if_cmd_setfh(struct trx_instance *trx, uint8_t hsn, uint8_t maio, |
| 69 | const uint16_t *ma, size_t ma_len); |
Eric Wild | 901f689 | 2022-05-07 15:36:47 +0200 | [diff] [blame] | 70 | |
| 71 | int trx_if_cmd_measure(struct trx_instance *trx, |
| 72 | uint16_t band_arfcn_start, uint16_t band_arfcn_stop); |
| 73 | |
Eric | e29b3c8 | 2022-10-27 16:54:09 +0200 | [diff] [blame] | 74 | int trx_if_tx_burst(struct trx_instance *trx, |
| 75 | const struct l1sched_burst_req *br); |
Eric | 847de6d | 2022-10-27 16:54:53 +0200 | [diff] [blame] | 76 | int trx_if_cmd_sync(struct trx_instance *trx); |