Pau Espin Pedrol | ea8dbdd | 2021-07-29 18:39:16 +0200 | [diff] [blame] | 1 | /* tbf_ul_ack_fsm.h |
| 2 | * |
| 3 | * Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de> |
| 4 | * Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version 2 |
| 9 | * of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | #pragma once |
| 21 | |
| 22 | #include <osmocom/core/fsm.h> |
| 23 | #include <osmocom/core/tdef.h> |
| 24 | |
| 25 | #include <gprs_pcu.h> |
| 26 | |
| 27 | struct gprs_rlcmac_tbf; |
| 28 | struct gprs_rlcmac_ul_tbf; |
| 29 | |
| 30 | enum tbf_ul_ack_fsm_event { |
| 31 | TBF_UL_ACK_EV_SCHED_ACK, /* Tx UL ACK/NACK is pending */ |
| 32 | TBF_UL_ACK_EV_CREATE_RLCMAC_MSG, /* Scheduler wants to gen+Tx the Ass (rej): data=tbf_ul_ack_ev_create_rlcmac_msg_ctx */ |
| 33 | TBF_UL_ACK_EV_RX_CTRL_ACK, /* Received CTRL ACK answering poll set on UL ACK/NACK */ |
| 34 | TBF_UL_ACK_EV_POLL_TIMEOUT, /* Pdch Ul Controller signals timeout for poll set on UL ACK/NACK */ |
| 35 | }; |
| 36 | |
| 37 | enum tbf_ul_ack_fsm_states { |
| 38 | TBF_UL_ACK_ST_NONE = 0, |
| 39 | TBF_UL_ACK_ST_SCHED_UL_ACK, /* send UL ACK/NACK on next RTS */ |
| 40 | TBF_UL_ACK_ST_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 41 | }; |
| 42 | |
| 43 | struct tbf_ul_ack_fsm_ctx { |
| 44 | struct osmo_fsm_inst *fi; |
| 45 | struct gprs_rlcmac_ul_tbf *tbf; /* back pointer */ |
| 46 | }; |
| 47 | |
| 48 | extern const struct osmo_tdef_state_timeout tbf_ul_ack_fsm_timeouts[32]; |
| 49 | /* Transition to a state, using the T timer defined in tbf_ul_ack_fsm_timeouts. |
| 50 | * The actual timeout value is in turn obtained from conn->T_defs. |
| 51 | * Assumes local variable fi exists. */ |
| 52 | #define tbf_ul_ack_fsm_state_chg(fi, NEXT_STATE) \ |
| 53 | osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \ |
| 54 | tbf_ul_ack_fsm_timeouts, \ |
| 55 | the_pcu->T_defs, \ |
| 56 | -1) |
| 57 | |
| 58 | extern struct osmo_fsm tbf_ul_ack_fsm; |
| 59 | |
| 60 | |
| 61 | /* passed as data in TBF_UL_ACK_EV_CREATE_RLCMAC_MSG */ |
| 62 | struct tbf_ul_ack_ev_create_rlcmac_msg_ctx { |
| 63 | uint32_t fn; /* FN where the created DL ctrl block is to be sent */ |
| 64 | uint8_t ts; /* TS where the created DL ctrl block is to be sent */ |
| 65 | struct msgb *msg; /* to be filled by FSM during event processing */ |
| 66 | }; |
| 67 | |
| 68 | |
| 69 | struct msgb *tbf_ul_ack_create_rlcmac_msg(const struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts); |
| 70 | bool tbf_ul_ack_rts(const struct gprs_rlcmac_tbf *tbf); |
| 71 | bool tbf_ul_ack_waiting_cnf_final_ack(const struct gprs_rlcmac_tbf *tbf); |
| 72 | bool tbf_ul_ack_exp_ctrl_ack(const struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts); |