MCS: move Mode enum outside of class definition
Move Mode (EDGE/GPRS) definition and related functions outside of GprsCodingScheme class. This allows us to use standard libosmocore value_string functions. Change-Id: I3baaac7f1ca3f5b88917a23c1679d63847455f47
This commit is contained in:
parent
02fbfc15c7
commit
a4de02db5d
|
@ -85,3 +85,14 @@ uint8_t num_data_block_header_bits(enum HeaderType ht)
|
|||
OSMO_ASSERT(ht < NUM_HEADER_TYPES);
|
||||
return hdr_type_info[ht].data_block_header_bits;
|
||||
}
|
||||
|
||||
const struct value_string mode_names[] = {
|
||||
{ GPRS, "GPRS" },
|
||||
{ EGPRS_GMSK, "EGPRS_GMSK-only"},
|
||||
{ EGPRS, "EGPRS"},
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const char *mode_name(enum mcs_kind val) {
|
||||
return get_value_string(mode_names, val);
|
||||
}
|
||||
|
|
|
@ -49,3 +49,11 @@ uint8_t num_data_blocks(enum HeaderType ht);
|
|||
uint8_t num_data_header_bits_UL(enum HeaderType ht);
|
||||
uint8_t num_data_header_bits_DL(enum HeaderType ht);
|
||||
uint8_t num_data_block_header_bits(enum HeaderType ht);
|
||||
|
||||
enum mcs_kind {
|
||||
GPRS,
|
||||
EGPRS_GMSK,
|
||||
EGPRS,
|
||||
};
|
||||
|
||||
const char *mode_name(enum mcs_kind val);
|
||||
|
|
|
@ -198,7 +198,7 @@ enum HeaderType GprsCodingScheme::headerTypeData() const
|
|||
return mcs_info[m_scheme].data_hdr;
|
||||
}
|
||||
|
||||
void GprsCodingScheme::inc(Mode mode)
|
||||
void GprsCodingScheme::inc(enum mcs_kind mode)
|
||||
{
|
||||
if (!isCompatible(mode))
|
||||
/* This should not happen. TODO: Use assert? */
|
||||
|
@ -212,7 +212,7 @@ void GprsCodingScheme::inc(Mode mode)
|
|||
m_scheme = new_cs;
|
||||
}
|
||||
|
||||
void GprsCodingScheme::dec(Mode mode)
|
||||
void GprsCodingScheme::dec(enum mcs_kind mode)
|
||||
{
|
||||
if (!isCompatible(mode))
|
||||
/* This should not happen. TODO: Use assert? */
|
||||
|
@ -254,16 +254,6 @@ void GprsCodingScheme::dec()
|
|||
m_scheme = CodingScheme(m_scheme - 1);
|
||||
}
|
||||
|
||||
const char *GprsCodingScheme::modeName(Mode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case GPRS: return "GPRS";
|
||||
case EGPRS_GMSK: return "EGPRS_GMSK-only";
|
||||
case EGPRS: return "EGPRS";
|
||||
default: return "???";
|
||||
}
|
||||
}
|
||||
|
||||
bool GprsCodingScheme::isFamilyCompatible(GprsCodingScheme o) const
|
||||
{
|
||||
if (*this == o)
|
||||
|
|
|
@ -34,12 +34,6 @@ public:
|
|||
#define EGPRS_ARQ1 0x0
|
||||
#define EGPRS_ARQ2 0x1
|
||||
|
||||
enum Mode {
|
||||
GPRS,
|
||||
EGPRS_GMSK,
|
||||
EGPRS,
|
||||
};
|
||||
|
||||
GprsCodingScheme(CodingScheme s = UNKNOWN);
|
||||
|
||||
operator bool() const {return m_scheme != UNKNOWN;}
|
||||
|
@ -54,12 +48,12 @@ public:
|
|||
bool isGprs() const {return CS1 <= m_scheme && m_scheme <= CS4;}
|
||||
bool isEgprs() const {return m_scheme >= MCS1;}
|
||||
bool isEgprsGmsk() const {return isEgprs() && m_scheme <= MCS4;}
|
||||
bool isCompatible(Mode mode) const;
|
||||
bool isCompatible(enum mcs_kind mode) const;
|
||||
bool isCompatible(GprsCodingScheme o) const;
|
||||
bool isFamilyCompatible(GprsCodingScheme o) const;
|
||||
|
||||
void inc(Mode mode);
|
||||
void dec(Mode mode);
|
||||
void inc(enum mcs_kind mode);
|
||||
void dec(enum mcs_kind mode);
|
||||
void inc();
|
||||
void dec();
|
||||
void decToSingleBlock(bool *needStuffing);
|
||||
|
@ -81,7 +75,6 @@ public:
|
|||
static GprsCodingScheme getGprsByNum(unsigned num);
|
||||
static GprsCodingScheme getEgprsByNum(unsigned num);
|
||||
|
||||
static const char *modeName(Mode mode);
|
||||
static CodingScheme get_retx_mcs(const GprsCodingScheme mcs,
|
||||
const GprsCodingScheme retx_mcs,
|
||||
const unsigned arq_type);
|
||||
|
@ -102,7 +95,7 @@ inline uint8_t GprsCodingScheme::to_num() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
inline bool GprsCodingScheme::isCompatible(Mode mode) const
|
||||
inline bool GprsCodingScheme::isCompatible(enum mcs_kind mode) const
|
||||
{
|
||||
switch (mode) {
|
||||
case GPRS: return isGprs();
|
||||
|
|
|
@ -110,7 +110,7 @@ GprsMs::GprsMs(BTS *bts, uint32_t tlli) :
|
|||
m_reserved_ul_slots(0),
|
||||
m_current_trx(NULL),
|
||||
m_codel_state(NULL),
|
||||
m_mode(GprsCodingScheme::GPRS),
|
||||
m_mode(GPRS),
|
||||
m_dl_ctrl_msg(0)
|
||||
{
|
||||
int codel_interval = LLC_CODEL_USE_DEFAULT;
|
||||
|
@ -213,7 +213,7 @@ void GprsMs::stop_timer()
|
|||
unref();
|
||||
}
|
||||
|
||||
void GprsMs::set_mode(GprsCodingScheme::Mode mode)
|
||||
void GprsMs::set_mode(enum mcs_kind mode)
|
||||
{
|
||||
m_mode = mode;
|
||||
|
||||
|
@ -221,7 +221,7 @@ void GprsMs::set_mode(GprsCodingScheme::Mode mode)
|
|||
return;
|
||||
|
||||
switch (m_mode) {
|
||||
case GprsCodingScheme::GPRS:
|
||||
case GPRS:
|
||||
if (!m_current_cs_ul.isGprs()) {
|
||||
m_current_cs_ul = GprsCodingScheme::getGprsByNum(
|
||||
m_bts->bts_data()->initial_cs_ul);
|
||||
|
@ -236,8 +236,8 @@ void GprsMs::set_mode(GprsCodingScheme::Mode mode)
|
|||
}
|
||||
break;
|
||||
|
||||
case GprsCodingScheme::EGPRS_GMSK:
|
||||
case GprsCodingScheme::EGPRS:
|
||||
case EGPRS_GMSK:
|
||||
case EGPRS:
|
||||
if (!m_current_cs_ul.isEgprs()) {
|
||||
m_current_cs_ul = GprsCodingScheme::getEgprsByNum(
|
||||
m_bts->bts_data()->initial_mcs_ul);
|
||||
|
|
|
@ -74,8 +74,8 @@ public:
|
|||
bool check_tlli(uint32_t tlli);
|
||||
|
||||
void reset();
|
||||
GprsCodingScheme::Mode mode() const;
|
||||
void set_mode(GprsCodingScheme::Mode mode);
|
||||
enum mcs_kind mode() const;
|
||||
void set_mode(enum mcs_kind mode);
|
||||
|
||||
const char *imsi() const;
|
||||
void set_imsi(const char *imsi);
|
||||
|
@ -181,7 +181,7 @@ private:
|
|||
gprs_rlcmac_trx *m_current_trx;
|
||||
|
||||
struct gprs_codel *m_codel_state;
|
||||
GprsCodingScheme::Mode m_mode;
|
||||
enum mcs_kind m_mode;
|
||||
|
||||
unsigned m_dl_ctrl_msg;
|
||||
};
|
||||
|
@ -237,7 +237,7 @@ inline GprsCodingScheme GprsMs::current_cs_ul() const
|
|||
return m_current_cs_ul;
|
||||
}
|
||||
|
||||
inline GprsCodingScheme::Mode GprsMs::mode() const
|
||||
inline enum mcs_kind GprsMs::mode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf)
|
|||
ul_tbf->window_size(), win->v_q(), win->v_r());
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
vty_out(vty, " TBF Statistics:%s", VTY_NEWLINE);
|
||||
if(GprsCodingScheme::GPRS == tbf->ms()->mode()) {
|
||||
if(GPRS == tbf->ms()->mode()) {
|
||||
vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_gprs_ctrs);
|
||||
} else {
|
||||
vty_out_rate_ctr_group(vty, " ", ul_tbf->m_ul_egprs_ctrs);
|
||||
|
@ -92,7 +92,7 @@ static void tbf_print_vty_info(struct vty *vty, gprs_rlcmac_tbf *tbf)
|
|||
win->window_stalled() ? " STALLED" : "");
|
||||
vty_out(vty, "%s", VTY_NEWLINE);
|
||||
vty_out_rate_ctr_group(vty, " ", tbf->m_ctrs);
|
||||
if(GprsCodingScheme::GPRS == tbf->ms()->mode()) {
|
||||
if(GPRS == tbf->ms()->mode()) {
|
||||
vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_gprs_ctrs);
|
||||
} else {
|
||||
vty_out_rate_ctr_group(vty, " ", dl_tbf->m_dl_egprs_ctrs);
|
||||
|
@ -153,8 +153,7 @@ static int show_ms(struct vty *vty, GprsMs *ms)
|
|||
VTY_NEWLINE);
|
||||
vty_out(vty, " Coding scheme downlink: %s%s", mcs_name(ms->current_cs_dl()),
|
||||
VTY_NEWLINE);
|
||||
vty_out(vty, " Mode: %s%s",
|
||||
GprsCodingScheme::modeName(ms->mode()), VTY_NEWLINE);
|
||||
vty_out(vty, " Mode: %s%s", mode_name(ms->mode()), VTY_NEWLINE);
|
||||
vty_out(vty, " MS class: %d%s", ms->ms_class(), VTY_NEWLINE);
|
||||
vty_out(vty, " EGPRS MS class: %d%s", ms->egprs_ms_class(), VTY_NEWLINE);
|
||||
vty_out(vty, " PACCH: ");
|
||||
|
|
14
src/tbf.cpp
14
src/tbf.cpp
|
@ -897,7 +897,7 @@ static int setup_tbf(struct gprs_rlcmac_tbf *tbf, GprsMs *ms, int8_t use_trx, ui
|
|||
|
||||
bts = tbf->bts->bts_data();
|
||||
|
||||
if (ms->mode() == GprsCodingScheme::EGPRS)
|
||||
if (ms->mode() == EGPRS)
|
||||
ms_class = egprs_ms_class;
|
||||
|
||||
tbf->m_created_ts = time(NULL);
|
||||
|
@ -954,11 +954,11 @@ static void setup_egprs_mode(gprs_rlcmac_bts *bts, GprsMs *ms)
|
|||
{
|
||||
if (GprsCodingScheme::getEgprsByNum(bts->max_mcs_ul).isEgprsGmsk() &&
|
||||
GprsCodingScheme::getEgprsByNum(bts->max_mcs_dl).isEgprsGmsk() &&
|
||||
ms->mode() != GprsCodingScheme::EGPRS)
|
||||
ms->mode() != EGPRS)
|
||||
{
|
||||
ms->set_mode(GprsCodingScheme::EGPRS_GMSK);
|
||||
ms->set_mode(EGPRS_GMSK);
|
||||
} else {
|
||||
ms->set_mode(GprsCodingScheme::EGPRS);
|
||||
ms->set_mode(EGPRS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -992,8 +992,7 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs
|
|||
if (egprs_ms_class > 0 && bts->egprs_enabled) {
|
||||
tbf->enable_egprs();
|
||||
setup_egprs_mode(bts, ms);
|
||||
LOGPTBF(tbf, LOGL_INFO, "Enabled EGPRS, mode %s\n",
|
||||
GprsCodingScheme::modeName(ms->mode()));
|
||||
LOGPTBF(tbf, LOGL_INFO, "Enabled EGPRS, mode %s\n", mode_name(ms->mode()));
|
||||
}
|
||||
|
||||
rc = setup_tbf(tbf, ms, use_trx, ms_class, egprs_ms_class, single_slot);
|
||||
|
@ -1085,8 +1084,7 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts, GprsMs
|
|||
if (egprs_ms_class > 0 && bts->egprs_enabled) {
|
||||
tbf->enable_egprs();
|
||||
setup_egprs_mode(bts, ms);
|
||||
LOGPTBF(tbf, LOGL_INFO, "Enabled EGPRS, mode %s\n",
|
||||
GprsCodingScheme::modeName(ms->mode()));
|
||||
LOGPTBF(tbf, LOGL_INFO, "Enabled EGPRS, mode %s\n", mode_name(ms->mode()));
|
||||
}
|
||||
|
||||
rc = setup_tbf(tbf, ms, use_trx, ms_class, 0, single_slot);
|
||||
|
|
|
@ -48,7 +48,7 @@ void *tall_pcu_ctx;
|
|||
int16_t spoof_mnc = 0, spoof_mcc = 0;
|
||||
bool spoof_mnc_3_digits = false;
|
||||
|
||||
static void check_coding_scheme(GprsCodingScheme& cs, GprsCodingScheme::Mode mode)
|
||||
static void check_coding_scheme(GprsCodingScheme& cs, enum mcs_kind mode)
|
||||
{
|
||||
volatile unsigned expected_size;
|
||||
bool need_padding;
|
||||
|
@ -148,9 +148,9 @@ static void test_coding_scheme()
|
|||
OSMO_ASSERT(!cs);
|
||||
OSMO_ASSERT(CodingScheme(cs) == UNKNOWN);
|
||||
OSMO_ASSERT(cs == GprsCodingScheme(UNKNOWN));
|
||||
OSMO_ASSERT(!cs.isCompatible(GprsCodingScheme::GPRS));
|
||||
OSMO_ASSERT(!cs.isCompatible(GprsCodingScheme::EGPRS_GMSK));
|
||||
OSMO_ASSERT(!cs.isCompatible(GprsCodingScheme::EGPRS));
|
||||
OSMO_ASSERT(!cs.isCompatible(GPRS));
|
||||
OSMO_ASSERT(!cs.isCompatible(EGPRS_GMSK));
|
||||
OSMO_ASSERT(!cs.isCompatible(EGPRS));
|
||||
|
||||
last_size_UL = 0;
|
||||
last_size_DL = 0;
|
||||
|
@ -170,7 +170,7 @@ static void test_coding_scheme()
|
|||
/* Check header types */
|
||||
OSMO_ASSERT(current_cs.headerTypeData() == HEADER_GPRS_DATA);
|
||||
|
||||
check_coding_scheme(current_cs, GprsCodingScheme::GPRS);
|
||||
check_coding_scheme(current_cs, GPRS);
|
||||
}
|
||||
OSMO_ASSERT(i == 4);
|
||||
|
||||
|
@ -190,8 +190,8 @@ static void test_coding_scheme()
|
|||
last_size_DL = current_cs.maxBytesDL();
|
||||
|
||||
if (egprs_schemes[i].is_gmsk)
|
||||
check_coding_scheme(current_cs, GprsCodingScheme::EGPRS_GMSK);
|
||||
check_coding_scheme(current_cs, GprsCodingScheme::EGPRS);
|
||||
check_coding_scheme(current_cs, EGPRS_GMSK);
|
||||
check_coding_scheme(current_cs, EGPRS);
|
||||
}
|
||||
OSMO_ASSERT(i == 9);
|
||||
|
||||
|
|
Loading…
Reference in New Issue