Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 1 | /* tbf_dl_ass_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. |
Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 15 | */ |
| 16 | #pragma once |
| 17 | |
| 18 | #include <osmocom/core/fsm.h> |
| 19 | #include <osmocom/core/tdef.h> |
| 20 | |
| 21 | #include <gprs_pcu.h> |
| 22 | |
| 23 | struct gprs_rlcmac_tbf; |
Pau Espin Pedrol | 106f2a0 | 2022-12-12 17:29:10 +0100 | [diff] [blame] | 24 | struct gprs_rlcmac_pdch; |
Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 25 | |
| 26 | enum tbf_dl_ass_fsm_event { |
| 27 | TBF_DL_ASS_EV_SCHED_ASS, /* Tx Uplink Assignment is pending */ |
| 28 | TBF_DL_ASS_EV_CREATE_RLCMAC_MSG, /* Scheduler wants to gen+Tx the Ass (rej): data=tbf_dl_ass_ev_create_rlcmac_msg_ctx */ |
| 29 | TBF_DL_ASS_EV_RX_ASS_CTRL_ACK, /* Received CTRL ACK answering poll set on Pkt Dl Ass */ |
| 30 | TBF_DL_ASS_EV_ASS_POLL_TIMEOUT, /* Pdch Ul Controller signals timeout for poll set on Pkt Dl Ass */ |
| 31 | }; |
| 32 | |
| 33 | enum tbf_dl_ass_fsm_states { |
| 34 | TBF_DL_ASS_NONE = 0, |
| 35 | TBF_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */ |
| 36 | TBF_DL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */ |
| 37 | }; |
| 38 | |
| 39 | struct tbf_dl_ass_fsm_ctx { |
| 40 | struct osmo_fsm_inst *fi; |
| 41 | struct gprs_rlcmac_tbf* tbf; /* back pointer */ |
| 42 | }; |
| 43 | |
| 44 | extern const struct osmo_tdef_state_timeout tbf_dl_ass_fsm_timeouts[32]; |
| 45 | /* Transition to a state, using the T timer defined in tbf_dl_ass_fsm_timeouts. |
| 46 | * The actual timeout value is in turn obtained from conn->T_defs. |
| 47 | * Assumes local variable fi exists. */ |
| 48 | #define tbf_dl_ass_fsm_state_chg(fi, NEXT_STATE) \ |
| 49 | osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \ |
| 50 | tbf_dl_ass_fsm_timeouts, \ |
| 51 | the_pcu->T_defs, \ |
| 52 | -1) |
| 53 | |
| 54 | extern struct osmo_fsm tbf_dl_ass_fsm; |
| 55 | |
| 56 | |
| 57 | /* passed as data in TBF_DL_ASS_EV_CREATE_RLCMAC_MSG */ |
| 58 | struct tbf_dl_ass_ev_create_rlcmac_msg_ctx { |
Pau Espin Pedrol | 5ba3ef9 | 2022-12-12 18:02:25 +0100 | [diff] [blame] | 59 | const struct gprs_rlcmac_pdch *pdch; /* TS where the created DL ctrl block is to be sent */ |
Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 60 | uint32_t fn; /* FN where the created DL ctrl block is to be sent */ |
Pau Espin Pedrol | 49a2f40 | 2021-07-27 17:33:07 +0200 | [diff] [blame] | 61 | struct msgb *msg; /* to be filled by FSM during event processing */ |
| 62 | }; |
| 63 | |
| 64 | |
Pau Espin Pedrol | 5ba3ef9 | 2022-12-12 18:02:25 +0100 | [diff] [blame] | 65 | struct msgb *tbf_dl_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf *tbf, |
| 66 | const struct gprs_rlcmac_pdch *pdch, |
| 67 | uint32_t fn); |
Pau Espin Pedrol | 106f2a0 | 2022-12-12 17:29:10 +0100 | [diff] [blame] | 68 | bool tbf_dl_ass_rts(const struct gprs_rlcmac_tbf *tbf, const struct gprs_rlcmac_pdch *pdch); |