MCS: add mcs_is_*() helpers
In preparation for Channel Coding Command encoder in follow-up patches let's add necessary helpers. Those are similar to previously used helpers from GprsCodingScheme class but without CamelCase and with less typo chances between Gprs and Egprs cases. Change-Id: I6699cbc8d7ae766fa4d2b3d37e5f9ff1cf158b7e
This commit is contained in:
parent
fb3fd09353
commit
8a8e0fb267
|
@ -46,6 +46,24 @@ const char *mcs_name(enum CodingScheme val) {
|
|||
return get_value_string(mcs_names, val);
|
||||
}
|
||||
|
||||
bool mcs_is_gprs(enum CodingScheme cs)
|
||||
{
|
||||
return CS1 <= cs && cs <= CS4;
|
||||
}
|
||||
|
||||
bool mcs_is_edge(enum CodingScheme cs)
|
||||
{
|
||||
return MCS1 <= cs && cs <= MCS9;
|
||||
}
|
||||
|
||||
bool mcs_is_edge_gmsk(enum CodingScheme cs)
|
||||
{
|
||||
if (mcs_is_edge(cs))
|
||||
return cs <= MCS4;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static struct {
|
||||
struct {
|
||||
uint8_t data_header_bits;
|
||||
|
|
|
@ -33,6 +33,10 @@ enum CodingScheme {
|
|||
extern const struct value_string mcs_names[];
|
||||
const char *mcs_name(enum CodingScheme val);
|
||||
|
||||
bool mcs_is_gprs(enum CodingScheme cs);
|
||||
bool mcs_is_edge(enum CodingScheme cs);
|
||||
bool mcs_is_edge_gmsk(enum CodingScheme cs);
|
||||
|
||||
enum HeaderType {
|
||||
HEADER_INVALID,
|
||||
HEADER_GPRS_CONTROL,
|
||||
|
|
|
@ -215,7 +215,7 @@ int Decoding::rlc_data_from_ul_data(
|
|||
"but no more chunks possible\n");
|
||||
return -ENOSPC;
|
||||
}
|
||||
} else if (cs.isEgprs()) {
|
||||
} else if (mcs_is_edge(cs)) {
|
||||
/* if E is not set (LI follows), EGPRS */
|
||||
num_chunks = parse_extensions_egprs(data, data_len, &offs,
|
||||
is_last_block,
|
||||
|
@ -240,7 +240,7 @@ int Decoding::rlc_data_from_ul_data(
|
|||
}
|
||||
|
||||
memcpy(&tlli_enc, data + offs, sizeof(tlli_enc));
|
||||
if (cs.isGprs())
|
||||
if (mcs_is_gprs(cs))
|
||||
/* The TLLI is encoded in big endian for GPRS (see
|
||||
* TS 44.060, figure 10.2.2.1, note) */
|
||||
*tlli = be32toh(tlli_enc);
|
||||
|
|
|
@ -1605,12 +1605,12 @@ Encoding::AppendResult Encoding::rlc_data_to_dl_append(
|
|||
gprs_llc *llc, int *offset, int *num_chunks,
|
||||
uint8_t *data_block, bool is_final, int *count_payload)
|
||||
{
|
||||
if (cs.isGprs())
|
||||
if (mcs_is_gprs(cs))
|
||||
return rlc_data_to_dl_append_gprs(rdbi,
|
||||
llc, offset, num_chunks, data_block, is_final,
|
||||
count_payload);
|
||||
|
||||
if (cs.isEgprs())
|
||||
if (mcs_is_edge(cs))
|
||||
return rlc_data_to_dl_append_egprs(rdbi,
|
||||
llc, offset, num_chunks, data_block, is_final,
|
||||
count_payload);
|
||||
|
|
|
@ -228,10 +228,10 @@ void GprsCodingScheme::dec(enum mcs_kind mode)
|
|||
|
||||
void GprsCodingScheme::inc()
|
||||
{
|
||||
if (isGprs() && m_scheme == CS4)
|
||||
if (mcs_is_gprs(m_scheme) && m_scheme == CS4)
|
||||
return;
|
||||
|
||||
if (isEgprs() && m_scheme == MCS9)
|
||||
if (mcs_is_edge(m_scheme) && m_scheme == MCS9)
|
||||
return;
|
||||
|
||||
if (!isValid())
|
||||
|
@ -242,10 +242,10 @@ void GprsCodingScheme::inc()
|
|||
|
||||
void GprsCodingScheme::dec()
|
||||
{
|
||||
if (isGprs() && m_scheme == CS1)
|
||||
if (mcs_is_gprs(m_scheme) && m_scheme == CS1)
|
||||
return;
|
||||
|
||||
if (isEgprs() && m_scheme == MCS1)
|
||||
if (mcs_is_edge(m_scheme) && m_scheme == MCS1)
|
||||
return;
|
||||
|
||||
if (!isValid())
|
||||
|
|
|
@ -45,9 +45,7 @@ public:
|
|||
GprsCodingScheme& operator =(GprsCodingScheme o);
|
||||
|
||||
bool isValid() const {return UNKNOWN <= m_scheme && m_scheme <= MCS9;}
|
||||
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(enum mcs_kind mode) const;
|
||||
bool isCompatible(GprsCodingScheme o) const;
|
||||
bool isFamilyCompatible(GprsCodingScheme o) const;
|
||||
|
@ -86,10 +84,10 @@ private:
|
|||
|
||||
inline uint8_t GprsCodingScheme::to_num() const
|
||||
{
|
||||
if (isGprs())
|
||||
if (mcs_is_gprs(m_scheme))
|
||||
return (m_scheme - CS1) + 1;
|
||||
|
||||
if (isEgprs())
|
||||
if (mcs_is_edge(m_scheme))
|
||||
return (m_scheme - MCS1) + 1;
|
||||
|
||||
return 0;
|
||||
|
@ -98,9 +96,9 @@ inline uint8_t GprsCodingScheme::to_num() const
|
|||
inline bool GprsCodingScheme::isCompatible(enum mcs_kind mode) const
|
||||
{
|
||||
switch (mode) {
|
||||
case GPRS: return isGprs();
|
||||
case EGPRS_GMSK: return isEgprsGmsk();
|
||||
case EGPRS: return isEgprs();
|
||||
case GPRS: return mcs_is_gprs(m_scheme);
|
||||
case EGPRS_GMSK: return mcs_is_edge_gmsk(m_scheme);
|
||||
case EGPRS: return mcs_is_edge(m_scheme);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -108,7 +106,7 @@ inline bool GprsCodingScheme::isCompatible(enum mcs_kind mode) const
|
|||
|
||||
inline bool GprsCodingScheme::isCompatible(GprsCodingScheme o) const
|
||||
{
|
||||
return (isGprs() && o.isGprs()) || (isEgprs() && o.isEgprs());
|
||||
return (mcs_is_gprs(m_scheme) && mcs_is_gprs(o)) || (mcs_is_edge(m_scheme) && mcs_is_edge(o));
|
||||
}
|
||||
|
||||
inline GprsCodingScheme::GprsCodingScheme(CodingScheme s)
|
||||
|
|
|
@ -222,13 +222,13 @@ void GprsMs::set_mode(enum mcs_kind mode)
|
|||
|
||||
switch (m_mode) {
|
||||
case GPRS:
|
||||
if (!m_current_cs_ul.isGprs()) {
|
||||
if (!mcs_is_gprs(m_current_cs_ul)) {
|
||||
m_current_cs_ul = GprsCodingScheme::getGprsByNum(
|
||||
m_bts->bts_data()->initial_cs_ul);
|
||||
if (!m_current_cs_ul.isValid())
|
||||
m_current_cs_ul = CS1;
|
||||
}
|
||||
if (!m_current_cs_dl.isGprs()) {
|
||||
if (!mcs_is_gprs(m_current_cs_dl)) {
|
||||
m_current_cs_dl = GprsCodingScheme::getGprsByNum(
|
||||
m_bts->bts_data()->initial_cs_dl);
|
||||
if (!m_current_cs_dl.isValid())
|
||||
|
@ -238,13 +238,13 @@ void GprsMs::set_mode(enum mcs_kind mode)
|
|||
|
||||
case EGPRS_GMSK:
|
||||
case EGPRS:
|
||||
if (!m_current_cs_ul.isEgprs()) {
|
||||
if (!mcs_is_edge(m_current_cs_ul)) {
|
||||
m_current_cs_ul = GprsCodingScheme::getEgprsByNum(
|
||||
m_bts->bts_data()->initial_mcs_ul);
|
||||
if (!m_current_cs_ul.isValid())
|
||||
m_current_cs_ul = MCS1;
|
||||
}
|
||||
if (!m_current_cs_dl.isEgprs()) {
|
||||
if (!mcs_is_edge(m_current_cs_dl)) {
|
||||
m_current_cs_dl = GprsCodingScheme::getEgprsByNum(
|
||||
m_bts->bts_data()->initial_mcs_dl);
|
||||
if (!m_current_cs_dl.isValid())
|
||||
|
@ -564,14 +564,14 @@ GprsCodingScheme GprsMs::max_cs_ul() const
|
|||
OSMO_ASSERT(m_bts != NULL);
|
||||
bts_data = m_bts->bts_data();
|
||||
|
||||
if (m_current_cs_ul.isGprs()) {
|
||||
if (mcs_is_gprs(m_current_cs_ul)) {
|
||||
if (!bts_data->max_cs_ul)
|
||||
return GprsCodingScheme(CS4);
|
||||
|
||||
return GprsCodingScheme::getGprsByNum(bts_data->max_cs_ul);
|
||||
}
|
||||
|
||||
if (!m_current_cs_ul.isEgprs())
|
||||
if (!mcs_is_edge(m_current_cs_ul))
|
||||
return GprsCodingScheme(); /* UNKNOWN */
|
||||
|
||||
if (bts_data->max_mcs_ul)
|
||||
|
@ -594,14 +594,14 @@ GprsCodingScheme GprsMs::max_cs_dl() const
|
|||
OSMO_ASSERT(m_bts != NULL);
|
||||
bts_data = m_bts->bts_data();
|
||||
|
||||
if (m_current_cs_dl.isGprs()) {
|
||||
if (mcs_is_gprs(m_current_cs_dl)) {
|
||||
if (!bts_data->max_cs_dl)
|
||||
return GprsCodingScheme(CS4);
|
||||
|
||||
return GprsCodingScheme::getGprsByNum(bts_data->max_cs_dl);
|
||||
}
|
||||
|
||||
if (!m_current_cs_dl.isEgprs())
|
||||
if (!mcs_is_edge(m_current_cs_dl))
|
||||
return GprsCodingScheme(); /* UNKNOWN */
|
||||
|
||||
if (bts_data->max_mcs_dl)
|
||||
|
@ -650,12 +650,12 @@ void GprsMs::update_cs_ul(const pcu_l1_meas *meas)
|
|||
|
||||
old_link_qual = meas->link_qual;
|
||||
|
||||
if (m_current_cs_ul.isGprs()) {
|
||||
if (mcs_is_gprs(m_current_cs_ul)) {
|
||||
if (current_cs_num > MAX_GPRS_CS)
|
||||
current_cs_num = MAX_GPRS_CS;
|
||||
low = bts_data->cs_lqual_ranges[current_cs_num-1].low;
|
||||
high = bts_data->cs_lqual_ranges[current_cs_num-1].high;
|
||||
} else if (m_current_cs_ul.isEgprs()) {
|
||||
} else if (mcs_is_edge(m_current_cs_ul)) {
|
||||
if (current_cs_num > MAX_EDGE_MCS)
|
||||
current_cs_num = MAX_EDGE_MCS;
|
||||
low = bts_data->mcs_lqual_ranges[current_cs_num-1].low;
|
||||
|
|
|
@ -741,10 +741,10 @@ int gprs_rlcmac_pdch::rcv_block(uint8_t *data, uint8_t len, uint32_t fn,
|
|||
LOGP(DRLCMACUL, LOGL_DEBUG, "Got RLC block, coding scheme: %s, "
|
||||
"length: %d (%d))\n", mcs_name(cs), len, cs.usedSizeUL());
|
||||
|
||||
if (cs.isGprs())
|
||||
if (mcs_is_gprs(cs))
|
||||
return rcv_block_gprs(data, len, fn, meas, cs);
|
||||
|
||||
if (cs.isEgprs())
|
||||
if (mcs_is_edge(cs))
|
||||
return rcv_data_block(data, len, fn, meas, cs);
|
||||
|
||||
bts()->decode_error();
|
||||
|
@ -765,7 +765,7 @@ int gprs_rlcmac_pdch::rcv_data_block(uint8_t *data, uint8_t data_len, uint32_t f
|
|||
/* These are always data blocks, since EGPRS still uses CS-1 for
|
||||
* control blocks (see 44.060, section 10.3, 1st par.)
|
||||
*/
|
||||
if (cs.isEgprs()) {
|
||||
if (mcs_is_edge(cs)) {
|
||||
if (!bts()->bts_data()->egprs_enabled) {
|
||||
LOGP(DRLCMACUL, LOGL_ERROR,
|
||||
"Got %s RLC block but EGPRS is not enabled\n",
|
||||
|
|
|
@ -952,8 +952,8 @@ static int ul_tbf_dtor(struct gprs_rlcmac_ul_tbf *tbf)
|
|||
|
||||
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() &&
|
||||
if (mcs_is_edge_gmsk(GprsCodingScheme::getEgprsByNum(bts->max_mcs_ul)) &&
|
||||
mcs_is_edge_gmsk(GprsCodingScheme::getEgprsByNum(bts->max_mcs_dl)) &&
|
||||
ms->mode() != EGPRS)
|
||||
{
|
||||
ms->set_mode(EGPRS_GMSK);
|
||||
|
|
|
@ -363,7 +363,7 @@ int gprs_rlcmac_dl_tbf::take_next_bsn(uint32_t fn,
|
|||
|
||||
if (previous_bsn >= 0) {
|
||||
force_cs = m_rlc.block(previous_bsn)->cs_current_trans;
|
||||
if (!force_cs.isEgprs())
|
||||
if (!mcs_is_edge(force_cs))
|
||||
return -1;
|
||||
force_data_len = m_rlc.block(previous_bsn)->len;
|
||||
}
|
||||
|
@ -765,7 +765,7 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
|
|||
m_rlc.block(bsn)->next_ps,
|
||||
m_rlc.block(bsn)->cs_last, cs, spb);
|
||||
|
||||
if (cs.isEgprs()) {
|
||||
if (mcs_is_edge(cs)) {
|
||||
OSMO_ASSERT(m_rlc.block(bsn)->next_ps >= EGPRS_PS_1);
|
||||
OSMO_ASSERT(m_rlc.block(bsn)->next_ps <= EGPRS_PS_3);
|
||||
}
|
||||
|
@ -812,7 +812,7 @@ struct msgb *gprs_rlcmac_dl_tbf::create_dl_acked_block(
|
|||
}
|
||||
|
||||
/* Calculate CPS only for EGPRS case */
|
||||
if (cs.isEgprs())
|
||||
if (mcs_is_edge(cs))
|
||||
rlc.cps = gprs_rlc_mcs_cps(cs, punct[0], punct[1], need_padding);
|
||||
|
||||
/* If the TBF has just started, relate frames_since_last_poll to the
|
||||
|
@ -1369,7 +1369,7 @@ void gprs_rlcmac_dl_tbf::update_coding_scheme_counter_dl(const GprsCodingScheme
|
|||
uint8_t coding_scheme = 0;
|
||||
|
||||
coding_scheme = CodingScheme(cs);
|
||||
if (cs.isGprs()) {
|
||||
if (mcs_is_gprs(cs)) {
|
||||
switch (coding_scheme) {
|
||||
case CS1 :
|
||||
bts->gprs_dl_cs1();
|
||||
|
|
|
@ -530,7 +530,7 @@ void gprs_rlcmac_ul_tbf::update_coding_scheme_counter_ul(const GprsCodingScheme
|
|||
uint8_t coding_scheme = 0;
|
||||
|
||||
coding_scheme = CodingScheme(cs);
|
||||
if (cs.isGprs()) {
|
||||
if (mcs_is_gprs(cs)) {
|
||||
switch (coding_scheme) {
|
||||
case CS1 :
|
||||
bts->gprs_ul_cs1();
|
||||
|
|
|
@ -59,14 +59,14 @@ static void check_coding_scheme(GprsCodingScheme& cs, enum mcs_kind mode)
|
|||
|
||||
/* Check static getBySizeUL() */
|
||||
expected_size = cs.usedSizeUL();
|
||||
if (cs.spareBitsUL() > 0 && cs.isGprs())
|
||||
if (cs.spareBitsUL() > 0 && mcs_is_gprs(cs))
|
||||
expected_size += 1;
|
||||
OSMO_ASSERT(expected_size == cs.sizeUL());
|
||||
OSMO_ASSERT(cs == GprsCodingScheme::getBySizeUL(expected_size));
|
||||
|
||||
/* Check static sizeUL() */
|
||||
expected_size = cs.usedSizeDL();
|
||||
if (cs.spareBitsDL() > 0 && cs.isGprs())
|
||||
if (cs.spareBitsDL() > 0 && mcs_is_gprs(cs))
|
||||
expected_size += 1;
|
||||
OSMO_ASSERT(expected_size == cs.sizeDL());
|
||||
|
||||
|
@ -157,9 +157,9 @@ static void test_coding_scheme()
|
|||
|
||||
for (i = 0; i < ARRAY_SIZE(gprs_schemes); i++) {
|
||||
GprsCodingScheme current_cs(gprs_schemes[i]);
|
||||
OSMO_ASSERT(current_cs.isGprs());
|
||||
OSMO_ASSERT(!current_cs.isEgprs());
|
||||
OSMO_ASSERT(!current_cs.isEgprsGmsk());
|
||||
OSMO_ASSERT(mcs_is_gprs(current_cs));
|
||||
OSMO_ASSERT(!mcs_is_edge(current_cs));
|
||||
OSMO_ASSERT(!mcs_is_edge_gmsk(current_cs));
|
||||
OSMO_ASSERT(CodingScheme(current_cs) == gprs_schemes[i]);
|
||||
OSMO_ASSERT(current_cs == GprsCodingScheme(gprs_schemes[i]));
|
||||
|
||||
|
@ -179,9 +179,9 @@ static void test_coding_scheme()
|
|||
|
||||
for (i = 0; i < ARRAY_SIZE(egprs_schemes); i++) {
|
||||
GprsCodingScheme current_cs(egprs_schemes[i].s);
|
||||
OSMO_ASSERT(!current_cs.isGprs());
|
||||
OSMO_ASSERT(current_cs.isEgprs());
|
||||
OSMO_ASSERT(!!current_cs.isEgprsGmsk() == !!egprs_schemes[i].is_gmsk);
|
||||
OSMO_ASSERT(!mcs_is_gprs(current_cs));
|
||||
OSMO_ASSERT(mcs_is_edge(current_cs));
|
||||
OSMO_ASSERT(mcs_is_edge_gmsk(current_cs) == !!egprs_schemes[i].is_gmsk);
|
||||
OSMO_ASSERT(CodingScheme(current_cs) == egprs_schemes[i].s);
|
||||
OSMO_ASSERT(current_cs == GprsCodingScheme(egprs_schemes[i].s));
|
||||
|
||||
|
|
Loading…
Reference in New Issue