aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf.h
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@espeweb.net>2020-12-16 15:59:45 +0100
committerpespin <pespin@sysmocom.de>2021-01-05 10:34:25 +0000
commitda971ee5026479e869ed75d944404d398c548497 (patch)
tree30bf447c2d828264e51d09f5422ea05421c48d47 /src/tbf.h
parent86fad1ec4e246110b9d8ae66fd7bc30e1cedb5de (diff)
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
Diffstat (limited to 'src/tbf.h')
-rw-r--r--src/tbf.h54
1 files changed, 36 insertions, 18 deletions
diff --git a/src/tbf.h b/src/tbf.h
index c97477bc..4bbfea2b 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -25,11 +25,21 @@
#include "llc.h"
#include "rlc.h"
#include "cxx_linuxlist.h"
+#include "pcu_utils.h"
#include <gprs_debug.h>
#include <gsm_timer.h>
#include <stdint.h>
+struct bssgp_bvc_ctx;
+struct gprs_rlcmac_bts;
+
+#endif
+
+struct GprsMs;
+
+#ifdef __cplusplus
extern "C" {
+#endif
#include <osmocom/core/utils.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/logging.h>
@@ -37,12 +47,8 @@ extern "C" {
#include <osmocom/gsm/gsm48.h>
#include "coding_scheme.h"
+#ifdef __cplusplus
}
-
-struct bssgp_bvc_ctx;
-class GprsMs;
-struct gprs_rlcmac_bts;
-
#endif
/*
@@ -182,6 +188,28 @@ enum tbf_counters { /* TBF counters from 3GPP TS 44.060 ยง13.4 */
#define TBF_ASS_TYPE_UNSET(t, kind) do { t->ass_type_mod(kind, true, __FILE__, __LINE__); } while(0)
#ifdef __cplusplus
+extern "C" {
+#endif
+struct gprs_rlcmac_tbf;
+const char *tbf_name(struct gprs_rlcmac_tbf *tbf);
+enum gprs_rlcmac_tbf_state tbf_state(const struct gprs_rlcmac_tbf *tbf);
+enum gprs_rlcmac_tbf_direction tbf_direction(const struct gprs_rlcmac_tbf *tbf);
+void tbf_set_ms(struct gprs_rlcmac_tbf *tbf, struct GprsMs *ms);
+struct llist_head *tbf_ms_list(struct gprs_rlcmac_tbf *tbf);
+struct GprsMs *tbf_ms(struct gprs_rlcmac_tbf *tbf);
+bool tbf_timers_pending(struct gprs_rlcmac_tbf *tbf, enum tbf_timers t);
+void tbf_free(struct gprs_rlcmac_tbf *tbf);
+struct gprs_llc *tbf_llc(struct gprs_rlcmac_tbf *tbf);
+uint8_t tbf_first_common_ts(const struct gprs_rlcmac_tbf *tbf);
+uint8_t tbf_dl_slots(const struct gprs_rlcmac_tbf *tbf);
+uint8_t tbf_ul_slots(const struct gprs_rlcmac_tbf *tbf);
+bool tbf_is_tfi_assigned(const struct gprs_rlcmac_tbf *tbf);
+int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf);
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef __cplusplus
struct gprs_rlcmac_tbf {
gprs_rlcmac_tbf(BTS *bts_, GprsMs *ms, gprs_rlcmac_tbf_direction dir);
@@ -255,7 +283,6 @@ struct gprs_rlcmac_tbf {
void set_ta(uint8_t);
uint8_t ms_class() const;
enum CodingScheme current_cs() const;
- size_t llc_queue_size() const;
time_t created_ts() const;
uint8_t dl_slots() const;
@@ -269,9 +296,6 @@ struct gprs_rlcmac_tbf {
/* attempt to make things a bit more fair */
void rotate_in_list();
- LListHead<gprs_rlcmac_tbf>& ms_list() {return this->m_ms_list;}
- const LListHead<gprs_rlcmac_tbf>& ms_list() const {return this->m_ms_list;}
-
LListHead<gprs_rlcmac_tbf>& list();
const LListHead<gprs_rlcmac_tbf>& list() const;
@@ -321,6 +345,8 @@ struct gprs_rlcmac_tbf {
time_t m_created_ts;
struct rate_ctr_group *m_ctrs;
+ enum gprs_rlcmac_tbf_state state;
+ struct llist_item m_ms_list;
protected:
gprs_rlcmac_bts *bts_data() const;
@@ -331,26 +357,20 @@ protected:
static const char *tbf_state_name[6];
- class GprsMs *m_ms;
+ struct GprsMs *m_ms;
private:
void enable_egprs();
- enum gprs_rlcmac_tbf_state state;
enum gprs_rlcmac_tbf_dl_ass_state dl_ass_state;
enum gprs_rlcmac_tbf_ul_ass_state ul_ass_state;
enum gprs_rlcmac_tbf_ul_ack_state ul_ack_state;
enum gprs_rlcmac_tbf_poll_state poll_state;
LListHead<gprs_rlcmac_tbf> m_list;
- LListHead<gprs_rlcmac_tbf> m_ms_list;
bool m_egprs_enabled;
struct osmo_timer_list Tarr[T_MAX];
uint8_t Narr[N_MAX];
mutable char m_name_buf[60];
};
-void tbf_free(struct gprs_rlcmac_tbf *tbf);
-
-int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf);
-
inline bool gprs_rlcmac_tbf::state_is(enum gprs_rlcmac_tbf_state rhs) const
{
return state == rhs;
@@ -381,8 +401,6 @@ inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const
return state != rhs;
}
-const char *tbf_name(gprs_rlcmac_tbf *tbf);
-
inline const char *gprs_rlcmac_tbf::state_name() const
{
return tbf_state_name[state];