tbf, bts: Use tbf set_state method instead of tbf_new_state function
All the function did was add debug output and call the set_state method.
Move the debugging into the method and remove the function.
Ticket: SYS#389
Sponsored by: On-Waves ehf
diff --git a/src/bts.cpp b/src/bts.cpp
index 73344a3..8665962 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -467,7 +467,7 @@
return -EBUSY;
}
tbf->ta = qta >> 2;
- tbf_new_state(tbf, GPRS_RLCMAC_FLOW);
+ tbf->set_state(GPRS_RLCMAC_FLOW);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
tbf_timer_start(tbf, 3169, m_bts.t3169, 0);
LOGP(DRLCMAC, LOGL_DEBUG, "%s [UPLINK] START\n",
@@ -515,7 +515,7 @@
dl_tbf->ta = old_tbf->ta;
dl_tbf->was_releasing = dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE);
/* change state */
- tbf_new_state(dl_tbf, GPRS_RLCMAC_ASSIGN);
+ dl_tbf->set_state(GPRS_RLCMAC_ASSIGN);
dl_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
/* start timer */
tbf_timer_start(dl_tbf, 0, Tassign_pacch);
@@ -527,7 +527,7 @@
}
dl_tbf->was_releasing = dl_tbf->state_is(GPRS_RLCMAC_WAIT_RELEASE);
/* change state */
- tbf_new_state(dl_tbf, GPRS_RLCMAC_ASSIGN);
+ dl_tbf->set_state(GPRS_RLCMAC_ASSIGN);
dl_tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
dl_tbf->assign_imsi(imsi);
/* send immediate assignment */
@@ -774,7 +774,7 @@
"TBF is gone TLLI=0x%08x\n", tlli);
return;
}
- tbf_new_state(tbf, GPRS_RLCMAC_FLOW);
+ tbf->set_state(GPRS_RLCMAC_FLOW);
/* stop pending assignment timer */
tbf->stop_timer();
if ((tbf->state_flags &
@@ -800,7 +800,7 @@
"TBF is gone TLLI=0x%08x\n", tlli);
return;
}
- tbf_new_state(tbf, GPRS_RLCMAC_FLOW);
+ tbf->set_state(GPRS_RLCMAC_FLOW);
if ((tbf->state_flags &
(1 << GPRS_RLCMAC_FLAG_TO_UL_ASS))) {
tbf->state_flags &=
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 647710c..98f6640 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -242,7 +242,7 @@
tbf->m_tlli_valid = 1; /* no contention resolution */
tbf->m_contention_resolution_done = 1;
tbf->ta = ta; /* use current TA */
- tbf_new_state(tbf, GPRS_RLCMAC_ASSIGN);
+ tbf->set_state(GPRS_RLCMAC_ASSIGN);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
tbf_timer_start(tbf, 3169, bts->t3169, 0);
@@ -338,7 +338,7 @@
return 0;
}
-static const char *tbf_state_name[] = {
+const char *gprs_rlcmac_tbf::tbf_state_name[] = {
"NULL",
"ASSIGN",
"FLOW",
@@ -347,15 +347,6 @@
"RELEASING",
};
-void tbf_new_state(struct gprs_rlcmac_tbf *tbf,
- enum gprs_rlcmac_tbf_state state)
-{
- LOGP(DRLCMAC, LOGL_DEBUG, "%s changes state from %s to %s\n",
- tbf_name(tbf),
- tbf_state_name[tbf->state], tbf_state_name[state]);
- tbf->set_state(state);
-}
-
void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T,
unsigned int seconds, unsigned int microseconds)
{
@@ -412,7 +403,7 @@
if (ul_tbf->m_n3103 == ul_tbf->bts->bts_data()->n3103) {
LOGP(DRLCMAC, LOGL_NOTICE,
"- N3103 exceeded\n");
- tbf_new_state(ul_tbf, GPRS_RLCMAC_RELEASING);
+ ul_tbf->set_state(GPRS_RLCMAC_RELEASING);
tbf_timer_start(ul_tbf, 3169, ul_tbf->bts->bts_data()->t3169, 0);
return;
}
@@ -431,7 +422,7 @@
n3105++;
if (n3105 == bts_data()->n3105) {
LOGP(DRLCMAC, LOGL_NOTICE, "- N3105 exceeded\n");
- tbf_new_state(this, GPRS_RLCMAC_RELEASING);
+ set_state(GPRS_RLCMAC_RELEASING);
tbf_timer_start(this, 3195, bts_data()->t3195, 0);
return;
}
@@ -449,7 +440,7 @@
n3105++;
if (n3105 == bts->bts_data()->n3105) {
LOGP(DRLCMAC, LOGL_NOTICE, "- N3105 exceeded\n");
- tbf_new_state(this, GPRS_RLCMAC_RELEASING);
+ set_state(GPRS_RLCMAC_RELEASING);
tbf_timer_start(this, 3195, bts_data()->t3195, 0);
return;
}
@@ -467,7 +458,7 @@
dl_tbf->n3105++;
if (dl_tbf->n3105 == dl_tbf->bts->bts_data()->n3105) {
LOGP(DRLCMAC, LOGL_NOTICE, "- N3105 exceeded\n");
- tbf_new_state(dl_tbf, GPRS_RLCMAC_RELEASING);
+ dl_tbf->set_state(GPRS_RLCMAC_RELEASING);
tbf_timer_start(dl_tbf, 3195, dl_tbf->bts_data()->t3195, 0);
return;
}
@@ -632,7 +623,7 @@
if (!dl_tbf->upgrade_to_multislot) {
/* change state to FLOW, so scheduler
* will start transmission */
- tbf_new_state(dl_tbf, GPRS_RLCMAC_FLOW);
+ dl_tbf->set_state(GPRS_RLCMAC_FLOW);
break;
}
@@ -1037,7 +1028,7 @@
m_llc.reset();
/* final block */
rh->fbi = 1; /* we indicate final block */
- tbf_new_state(this, GPRS_RLCMAC_FINISHED);
+ set_state(GPRS_RLCMAC_FINISHED);
/* return data block as message */
break;
}
@@ -1110,7 +1101,7 @@
rh->fbi = 1; /* we indicate final block */
first_fin_ack = true;
/* + 1 indicates: first final ack */
- tbf_new_state(this, GPRS_RLCMAC_FINISHED);
+ set_state(GPRS_RLCMAC_FINISHED);
break;
}
/* we have no space left */
@@ -1284,7 +1275,7 @@
dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
} else {
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
- tbf_new_state(new_dl_tbf, GPRS_RLCMAC_FLOW);
+ new_dl_tbf->set_state(GPRS_RLCMAC_FLOW);
tbf_assign_control_ts(new_dl_tbf);
/* stop pending assignment timer */
new_dl_tbf->stop_timer();
@@ -1476,7 +1467,7 @@
/* report all outstanding packets as received */
gprs_rlcmac_received_lost(this, received, 0);
- tbf_new_state(this, GPRS_RLCMAC_WAIT_RELEASE);
+ set_state(GPRS_RLCMAC_WAIT_RELEASE);
/* check for LLC PDU in the LLC Queue */
msg = llc_dequeue(gprs_bssgp_pcu_current_bctx());
@@ -1707,7 +1698,7 @@
if (last_rh->cv == 0) {
LOGP(DRLCMACUL, LOGL_DEBUG, "- Finished with UL "
"TBF\n");
- tbf_new_state(this, GPRS_RLCMAC_FINISHED);
+ set_state(GPRS_RLCMAC_FINISHED);
/* Reset N3103 counter. */
this->m_n3103 = 0;
}
diff --git a/src/tbf.h b/src/tbf.h
index 54781c0..7172163 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -23,6 +23,7 @@
#include "gprs_rlcmac.h"
#include "llc.h"
#include "rlc.h"
+#include <gprs_debug.h>
#include <stdint.h>
@@ -217,6 +218,7 @@
int extract_tlli(const uint8_t *data, const size_t len);
+ static const char *tbf_state_name[6];
};
@@ -238,9 +240,6 @@
int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf);
-void tbf_new_state(struct gprs_rlcmac_tbf *tbf,
- enum gprs_rlcmac_tbf_state state);
-
void tbf_timer_start(struct gprs_rlcmac_tbf *tbf, unsigned int T,
unsigned int seconds, unsigned int microseconds);
@@ -254,8 +253,13 @@
return state != rhs;
}
+const char *tbf_name(gprs_rlcmac_tbf *tbf);
+
inline void gprs_rlcmac_tbf::set_state(enum gprs_rlcmac_tbf_state new_state)
{
+ LOGP(DRLCMAC, LOGL_DEBUG, "%s changes state from %s to %s\n",
+ tbf_name(this),
+ tbf_state_name[state], tbf_state_name[new_state]);
state = new_state;
}
@@ -279,8 +283,6 @@
return m_imsi;
}
-const char *tbf_name(gprs_rlcmac_tbf *tbf);
-
inline time_t gprs_rlcmac_tbf::created_ts() const
{
return m_created_ts;