Neels Hofmeyr | 31f525e | 2018-05-14 18:14:15 +0200 | [diff] [blame] | 1 | /* osmo-bsc API to manage timeslot status: init and switch of dynamic PDCH. */ |
| 2 | #pragma once |
| 3 | |
| 4 | #include <osmocom/bsc/gsm_data.h> |
| 5 | |
| 6 | /* This macro automatically includes a final \n, if omitted. */ |
| 7 | #define LOG_TS(ts, level, fmt, args...) do { \ |
| 8 | if (ts->fi) \ |
| 9 | LOGPFSML(ts->fi, level, "%s%s%s" fmt "%s", \ |
| 10 | ts->pchan_is != ts->pchan_from_config ? "(pchan_is=" : "", \ |
| 11 | ts->pchan_is != ts->pchan_from_config ? gsm_pchan_name(ts->pchan_is) : "", \ |
| 12 | ts->pchan_is != ts->pchan_from_config ? ") " : "", \ |
| 13 | ## args, \ |
| 14 | (!fmt || !*fmt || fmt[strlen(fmt)-1] != '\n') ? "\n" : ""); \ |
| 15 | else \ |
| 16 | LOGP(DRSL, level, "%s" fmt "%s", \ |
| 17 | gsm_ts_name(ts), \ |
| 18 | ## args, \ |
| 19 | (!fmt || !*fmt || fmt[strlen(fmt)-1] != '\n') ? "\n" : ""); \ |
| 20 | } while(0) |
| 21 | |
| 22 | enum ts_fsm_state { |
| 23 | TS_ST_NOT_INITIALIZED, |
| 24 | TS_ST_UNUSED, |
| 25 | TS_ST_WAIT_PDCH_ACT, |
| 26 | TS_ST_PDCH, |
| 27 | TS_ST_WAIT_PDCH_DEACT, |
| 28 | TS_ST_IN_USE, |
| 29 | TS_ST_BORKEN, |
| 30 | }; |
| 31 | |
| 32 | enum ts_fsm_event { |
| 33 | TS_EV_OML_READY, |
| 34 | TS_EV_OML_DOWN, |
| 35 | TS_EV_RSL_READY, |
| 36 | TS_EV_RSL_DOWN, |
| 37 | TS_EV_LCHAN_REQUESTED, |
| 38 | TS_EV_LCHAN_UNUSED, |
| 39 | TS_EV_PDCH_ACT_ACK, |
| 40 | TS_EV_PDCH_ACT_NACK, |
| 41 | TS_EV_PDCH_DEACT_ACK, |
| 42 | TS_EV_PDCH_DEACT_NACK, |
| 43 | }; |
| 44 | |
| 45 | void ts_fsm_init(); |
| 46 | |
| 47 | void ts_fsm_alloc(struct gsm_bts_trx_ts *ts); |
| 48 | |
| 49 | bool ts_is_capable_of_pchan(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config pchan); |
| 50 | bool ts_is_capable_of_lchant(struct gsm_bts_trx_ts *ts, enum gsm_chan_t type); |
| 51 | bool ts_is_lchan_waiting_for_pchan(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config *target_pchan); |
| 52 | bool ts_is_pchan_switching(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config *target_pchan); |
| 53 | bool ts_usable_as_pchan(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config as_pchan); |