Harald Welte | 17a892f | 2020-12-07 21:39:03 +0100 | [diff] [blame] | 1 | #pragma once |
| 2 | #include <stdint.h> |
| 3 | |
| 4 | struct gprs_ns2_inst; |
| 5 | struct osmo_fsm_inst; |
| 6 | struct gprs_ra_id; |
Harald Welte | 1fcfce8 | 2020-12-08 21:15:45 +0100 | [diff] [blame] | 7 | struct bssgp2_flow_ctrl; |
Harald Welte | 17a892f | 2020-12-07 21:39:03 +0100 | [diff] [blame] | 8 | |
| 9 | enum bssp_ptp_bvc_fsm_state { |
| 10 | BSSGP_BVCFSM_S_NULL, |
| 11 | BSSGP_BVCFSM_S_BLOCKED, |
| 12 | BSSGP_BVCFSM_S_WAIT_RESET_ACK, |
| 13 | BSSGP_BVCFSM_S_UNBLOCKED, |
| 14 | }; |
| 15 | |
| 16 | enum bssgp_ptp_bvc_fsm_event { |
| 17 | /* Rx of BSSGP PDUs from the remote side; 'data' is 'struct tlv_parsed', and |
| 18 | * the assumption is that the caller has already validated all mandatory IEs |
| 19 | * are present and of sufficient length */ |
| 20 | BSSGP_BVCFSM_E_RX_BLOCK, |
| 21 | BSSGP_BVCFSM_E_RX_BLOCK_ACK, |
| 22 | BSSGP_BVCFSM_E_RX_UNBLOCK, |
| 23 | BSSGP_BVCFSM_E_RX_UNBLOCK_ACK, |
| 24 | BSSGP_BVCFSM_E_RX_RESET, |
| 25 | BSSGP_BVCFSM_E_RX_RESET_ACK, |
Harald Welte | 1fcfce8 | 2020-12-08 21:15:45 +0100 | [diff] [blame] | 26 | BSSGP_BVCFSM_E_RX_FC_BVC, |
| 27 | BSSGP_BVCFSM_E_RX_FC_BVC_ACK, |
Harald Welte | 17a892f | 2020-12-07 21:39:03 +0100 | [diff] [blame] | 28 | /* Requests of the local user */ |
| 29 | BSSGP_BVCFSM_E_REQ_BLOCK, /* data: uint8_t *cause */ |
| 30 | BSSGP_BVCFSM_E_REQ_UNBLOCK, |
| 31 | BSSGP_BVCFSM_E_REQ_RESET, /* data: uint8_t *cause */ |
Harald Welte | 1fcfce8 | 2020-12-08 21:15:45 +0100 | [diff] [blame] | 32 | BSSGP_BVCFSM_E_REQ_FC_BVC, /* data: struct bssgp2_flow_ctrl */ |
Harald Welte | 17a892f | 2020-12-07 21:39:03 +0100 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | struct bssgp_bvc_fsm_ops { |
| 36 | /* call-back notifying the user of a state change */ |
| 37 | void (*state_chg_notification)(uint16_t nsei, uint16_t bvci, int old_state, int new_state, |
| 38 | void *priv); |
| 39 | /* call-back notifying the user of a BVC-RESET event */ |
| 40 | void (*reset_notification)(uint16_t nsei, uint16_t bvci, const struct gprs_ra_id *ra_id, |
| 41 | uint16_t cell_id, uint8_t cause, void *priv); |
Harald Welte | 1fcfce8 | 2020-12-08 21:15:45 +0100 | [diff] [blame] | 42 | void (*rx_fc_bvc)(uint16_t nsei, uint16_t bvci, const struct bssgp2_flow_ctrl *fc, void *priv); |
Harald Welte | 17a892f | 2020-12-07 21:39:03 +0100 | [diff] [blame] | 43 | }; |
| 44 | |
| 45 | struct osmo_fsm_inst * |
| 46 | bssgp_bvc_fsm_alloc_sig_bss(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features); |
| 47 | |
| 48 | struct osmo_fsm_inst * |
| 49 | bssgp_bvc_fsm_alloc_ptp_bss(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci, |
| 50 | const struct gprs_ra_id *ra_id, uint16_t cell_id); |
| 51 | |
| 52 | struct osmo_fsm_inst * |
| 53 | bssgp_bvc_fsm_alloc_sig_sgsn(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint32_t features); |
| 54 | |
| 55 | struct osmo_fsm_inst * |
| 56 | bssgp_bvc_fsm_alloc_ptp_sgsn(void *ctx, struct gprs_ns2_inst *nsi, uint16_t nsei, uint16_t bvci); |
| 57 | |
| 58 | void bssgp_bvc_fsm_set_ops(struct osmo_fsm_inst *fi, const struct bssgp_bvc_fsm_ops *ops, void *ops_priv); |
| 59 | |
| 60 | bool bssgp_bvc_fsm_is_unblocked(struct osmo_fsm_inst *fi); |
| 61 | |
| 62 | uint8_t bssgp_bvc_fsm_get_block_cause(struct osmo_fsm_inst *fi); |
| 63 | |
Daniel Willmann | 4e5cdad | 2021-02-12 22:27:56 +0100 | [diff] [blame] | 64 | uint32_t bssgp_bvc_fsm_get_features_advertised(struct osmo_fsm_inst *fi); |
| 65 | uint32_t bssgp_bvc_fsm_get_features_received(struct osmo_fsm_inst *fi); |
| 66 | uint32_t bssgp_bvc_fsm_get_features_negotiated(struct osmo_fsm_inst *fi); |
Daniel Willmann | 1ff86f7 | 2021-01-25 17:02:25 +0100 | [diff] [blame] | 67 | |
| 68 | void bssgp_bvc_fsm_set_max_pdu_len(struct osmo_fsm_inst *fi, uint16_t max_pdu_len); |
| 69 | uint16_t bssgp_bvc_fsm_get_max_pdu_len(const struct osmo_fsm_inst *fi); |