2019-09-25 15:47:02 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 by Holger Hans Peter Freyther
|
|
|
|
* Copyright (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2020-05-15 14:57:48 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2019-09-25 15:47:02 +00:00
|
|
|
#include "tbf.h"
|
2021-07-29 16:39:16 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
#include <tbf_ul_ack_fsm.h>
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-09-25 15:47:02 +00:00
|
|
|
/*
|
|
|
|
* TBF instance
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum tbf_gprs_ul_counters {
|
|
|
|
TBF_CTR_GPRS_UL_CS1,
|
|
|
|
TBF_CTR_GPRS_UL_CS2,
|
|
|
|
TBF_CTR_GPRS_UL_CS3,
|
|
|
|
TBF_CTR_GPRS_UL_CS4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum tbf_egprs_ul_counters {
|
|
|
|
TBF_CTR_EGPRS_UL_MCS1,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS2,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS3,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS4,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS5,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS6,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS7,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS8,
|
|
|
|
TBF_CTR_EGPRS_UL_MCS9,
|
|
|
|
};
|
|
|
|
|
2021-03-24 12:14:09 +00:00
|
|
|
/* Used in ul_tbf->m_usf[] to flag unassigned USF on a given TS: */
|
|
|
|
#define USF_INVALID 0xFF
|
|
|
|
|
2019-09-25 15:47:02 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
|
2021-01-14 15:48:38 +00:00
|
|
|
gprs_rlcmac_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms);
|
2021-07-26 16:24:14 +00:00
|
|
|
~gprs_rlcmac_ul_tbf();
|
2020-10-23 19:00:23 +00:00
|
|
|
gprs_rlc_window *window();
|
2019-09-25 15:47:02 +00:00
|
|
|
/* blocks were acked */
|
|
|
|
int rcv_data_block_acknowledged(
|
|
|
|
const struct gprs_rlc_data_info *rlc,
|
|
|
|
uint8_t *data, struct pcu_l1_meas *meas);
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: extract LLC class? */
|
|
|
|
int assemble_forward_llc(const gprs_rlc_data *data);
|
|
|
|
int snd_ul_ud();
|
|
|
|
|
|
|
|
egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_spb(
|
|
|
|
const struct gprs_rlc_data_info *rlc,
|
|
|
|
struct gprs_rlc_data *block,
|
|
|
|
uint8_t *data, const uint8_t block_idx);
|
|
|
|
|
|
|
|
egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_first_seg(
|
|
|
|
const struct gprs_rlc_data_info *rlc,
|
|
|
|
struct gprs_rlc_data *block,
|
|
|
|
uint8_t *data, const uint8_t block_idx);
|
|
|
|
|
|
|
|
egprs_rlc_ul_reseg_bsn_state handle_egprs_ul_second_seg(
|
|
|
|
const struct gprs_rlc_data_info *rlc,
|
|
|
|
struct gprs_rlc_data *block,
|
|
|
|
uint8_t *data, const uint8_t block_idx);
|
|
|
|
|
|
|
|
uint16_t window_size() const;
|
|
|
|
void set_window_size();
|
|
|
|
void update_coding_scheme_counter_ul(enum CodingScheme cs);
|
2021-03-24 13:45:43 +00:00
|
|
|
void usf_timeout();
|
2021-05-10 16:54:52 +00:00
|
|
|
void contention_resolution_start();
|
|
|
|
void contention_resolution_success();
|
2019-09-25 15:47:02 +00:00
|
|
|
|
|
|
|
/* Please note that all variables here will be reset when changing
|
|
|
|
* from WAIT RELEASE back to FLOW state (re-use of TBF).
|
|
|
|
* All states that need reset must be in this struct, so this is why
|
|
|
|
* variables are in both (dl and ul) structs and not outside union.
|
|
|
|
*/
|
|
|
|
int32_t m_rx_counter; /* count all received blocks */
|
2021-03-24 12:14:09 +00:00
|
|
|
uint8_t m_usf[8]; /* list USFs per PDCH (timeslot), initialized to USF_INVALID */
|
2019-09-25 15:47:02 +00:00
|
|
|
uint8_t m_contention_resolution_done; /* set after done */
|
|
|
|
|
|
|
|
struct rate_ctr_group *m_ul_gprs_ctrs;
|
|
|
|
struct rate_ctr_group *m_ul_egprs_ctrs;
|
|
|
|
|
2021-07-29 16:39:16 +00:00
|
|
|
struct tbf_ul_ass_fsm_ctx ul_ack_fsm;
|
|
|
|
|
2019-09-25 15:47:02 +00:00
|
|
|
protected:
|
2020-05-15 14:57:48 +00:00
|
|
|
void maybe_schedule_uplink_acknack(const gprs_rlc_data_info *rlc, bool countdown_finished);
|
2019-09-25 15:47:02 +00:00
|
|
|
|
|
|
|
/* Please note that all variables below will be reset when changing
|
|
|
|
* from WAIT RELEASE back to FLOW state (re-use of TBF).
|
|
|
|
* All states that need reset must be in this struct, so this is why
|
|
|
|
* variables are in both (dl and ul) structs and not outside union.
|
|
|
|
*/
|
|
|
|
gprs_rlc_ul_window m_window;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline uint16_t gprs_rlcmac_ul_tbf::window_size() const
|
|
|
|
{
|
|
|
|
return m_window.ws();
|
|
|
|
}
|
|
|
|
|
2020-10-23 20:30:04 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, bool single_slot);
|
2021-05-10 15:10:37 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_pacch(struct gprs_rlcmac_bts *bts, GprsMs *ms,
|
|
|
|
int8_t use_trx, uint32_t tlli);
|
2021-05-10 15:21:03 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_ccch(struct gprs_rlcmac_bts *bts, struct GprsMs *ms);
|
2020-10-23 20:30:04 +00:00
|
|
|
struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
|
2021-04-26 14:48:34 +00:00
|
|
|
GprsMs *ms, uint8_t trx_no, uint8_t ts_no);
|
2020-10-23 20:30:04 +00:00
|
|
|
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
#else /* ifdef __cplusplus */
|
|
|
|
struct gprs_rlcmac_ul_tbf;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta);
|
|
|
|
void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta);
|
|
|
|
struct gprs_rlcmac_ul_tbf *as_ul_tbf(struct gprs_rlcmac_tbf *tbf);
|
2021-03-24 13:45:43 +00:00
|
|
|
void tbf_usf_timeout(struct gprs_rlcmac_ul_tbf *tbf);
|
2021-07-27 15:33:07 +00:00
|
|
|
bool ul_tbf_contention_resolution_done(const struct gprs_rlcmac_ul_tbf *tbf);
|
2021-07-29 16:39:16 +00:00
|
|
|
struct osmo_fsm_inst *tbf_ul_ack_fi(const struct gprs_rlcmac_ul_tbf *tbf);
|
|
|
|
void ul_tbf_contention_resolution_success(struct gprs_rlcmac_ul_tbf *tbf);
|
2021-07-27 10:27:08 +00:00
|
|
|
|
|
|
|
#define LOGPTBFUL(tbf, level, fmt, args...) LOGP(DTBFUL, level, "%s " fmt, tbf_name(tbf), ## args)
|
Convert GprsMS and helpers classes to C
As we integrate osmo-pcu more and more with libosmocore features, it
becomes really hard to use them since libosmocore relies heavily on C
specific compilation features, which are not available in old C++
compilers (such as designated initializers for complex types in FSMs).
GprsMs is right now a quite simple object since initial design of
osmo-pcu made it optional and most of the logic was placed and stored
duplicated in TBF objects. However, that's changing as we introduce more
features, with the GprsMS class getting more weight. Hence, let's move
it now to be a C struct in order to be able to easily use libosmocore
features there, such as FSMs.
Some helper classes which GprsMs uses are also mostly move to C since
they are mostly structs with methods, so there's no point in having
duplicated APIs for C++ and C for such simple cases.
For some more complex classes, like (ul_,dl_)tbf, C API bindings are
added where needed so that GprsMs can use functionalitites from that
class. Most of those APIs can be kept afterwards and drop the C++ ones
since they provide no benefit in general.
Change-Id: I0b50e3367aaad9dcada76da97b438e452c8b230c
2020-12-16 14:59:45 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2019-09-25 15:47:02 +00:00
|
|
|
#endif
|