TBF: make poll state internal
* add functions/macros for setting TBF's poll state * add function for checking TBF's poll state Change-Id: I6db1c4e7bd0a49aeb5e391afe371c36b96c6a702 Related: OS#1539
This commit is contained in:
parent
088c7df571
commit
cac6b66638
|
@ -399,7 +399,7 @@ void BTS::send_gsmtap(enum pcu_gsmtap_category categ, bool uplink, uint8_t trx_n
|
|||
|
||||
static inline bool tbf_check(gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t trx_no, uint8_t ts)
|
||||
{
|
||||
if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) && tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
|
||||
if (tbf->state_is_not(GPRS_RLCMAC_RELEASING) && tbf->poll_scheduled()
|
||||
&& tbf->poll_fn == fn && tbf->trx->trx_no == trx_no && tbf->poll_ts == ts)
|
||||
return true;
|
||||
|
||||
|
@ -1010,7 +1010,7 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
|
|||
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
|
||||
|
||||
LOGPTBF(tbf, LOGL_DEBUG, "RX: [PCU <- BTS] Packet Control Ack\n");
|
||||
tbf->poll_state = GPRS_RLCMAC_POLL_NONE;
|
||||
TBF_POLL_SCHED_UNSET(tbf);
|
||||
|
||||
/* check if this control ack belongs to packet uplink ack */
|
||||
ul_tbf = as_ul_tbf(tbf);
|
||||
|
|
|
@ -49,8 +49,7 @@ static uint32_t sched_poll(BTS *bts,
|
|||
if (ul_tbf->trx->trx_no != trx || !ul_tbf->is_control_ts(ts))
|
||||
continue;
|
||||
/* polling for next uplink block */
|
||||
if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
|
||||
&& ul_tbf->poll_fn == poll_fn)
|
||||
if (ul_tbf->poll_scheduled() && ul_tbf->poll_fn == poll_fn)
|
||||
*poll_tbf = ul_tbf;
|
||||
if (ul_tbf->ul_ack_state_is(GPRS_RLCMAC_UL_ACK_SEND_ACK))
|
||||
*ul_ack_tbf = ul_tbf;
|
||||
|
@ -69,8 +68,7 @@ states? */
|
|||
if (dl_tbf->trx->trx_no != trx || !dl_tbf->is_control_ts(ts))
|
||||
continue;
|
||||
/* polling for next uplink block */
|
||||
if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED
|
||||
&& dl_tbf->poll_fn == poll_fn)
|
||||
if (dl_tbf->poll_scheduled() && dl_tbf->poll_fn == poll_fn)
|
||||
*poll_tbf = dl_tbf;
|
||||
if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
|
||||
*dl_ass_tbf = dl_tbf;
|
||||
|
|
|
@ -47,14 +47,14 @@ void PollController::expireTimedout(int frame_number, unsigned max_delay)
|
|||
|
||||
llist_for_each(pos, &m_bts.ul_tbfs()) {
|
||||
ul_tbf = as_ul_tbf(pos->entry());
|
||||
if (ul_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
|
||||
if (ul_tbf->poll_scheduled()) {
|
||||
if (elapsed_fn_check(max_delay, frame_number, ul_tbf->poll_fn))
|
||||
ul_tbf->poll_timeout();
|
||||
}
|
||||
}
|
||||
llist_for_each(pos, &m_bts.dl_tbfs()) {
|
||||
dl_tbf = as_dl_tbf(pos->entry());
|
||||
if (dl_tbf->poll_state == GPRS_RLCMAC_POLL_SCHED) {
|
||||
if (dl_tbf->poll_scheduled()) {
|
||||
if (elapsed_fn_check(max_delay, frame_number, dl_tbf->poll_fn))
|
||||
dl_tbf->poll_timeout();
|
||||
}
|
||||
|
|
|
@ -45,6 +45,12 @@ extern void *tall_pcu_ctx;
|
|||
|
||||
static void tbf_timer_cb(void *_tbf);
|
||||
|
||||
const struct value_string gprs_rlcmac_tbf_poll_state_names[] = {
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_POLL_NONE),
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_POLL_SCHED), /* a polling was scheduled */
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[] = {
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_DL_ASS_NONE),
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_DL_ASS_SEND_ASS),
|
||||
|
@ -172,7 +178,6 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
|
|||
first_ts(0),
|
||||
first_common_ts(0),
|
||||
control_ts(0xff),
|
||||
poll_state(GPRS_RLCMAC_POLL_NONE),
|
||||
poll_fn(0),
|
||||
poll_ts(0),
|
||||
n3105(0),
|
||||
|
@ -192,6 +197,7 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS *bts_, gprs_rlcmac_tbf_direction dir) :
|
|||
dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE),
|
||||
ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE),
|
||||
ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
|
||||
poll_state(GPRS_RLCMAC_POLL_NONE),
|
||||
m_list(this),
|
||||
m_ms_list(this),
|
||||
m_egprs_enabled(false)
|
||||
|
|
28
src/tbf.h
28
src/tbf.h
|
@ -64,6 +64,8 @@ enum gprs_rlcmac_tbf_poll_state {
|
|||
GPRS_RLCMAC_POLL_SCHED, /* a polling was scheduled */
|
||||
};
|
||||
|
||||
extern const struct value_string gprs_rlcmac_tbf_poll_state_names[];
|
||||
|
||||
enum gprs_rlcmac_tbf_dl_ass_state {
|
||||
GPRS_RLCMAC_DL_ASS_NONE = 0,
|
||||
GPRS_RLCMAC_DL_ASS_SEND_ASS, /* send downlink assignment on next RTS */
|
||||
|
@ -186,6 +188,8 @@ enum tbf_timers {
|
|||
#define TBF_SET_ASS_STATE_DL(t, st) do { t->set_ass_state_dl(st, __FILE__, __LINE__); } while(0)
|
||||
#define TBF_SET_ASS_STATE_UL(t, st) do { t->set_ass_state_ul(st, __FILE__, __LINE__); } while(0)
|
||||
#define TBF_SET_ACK_STATE(t, st) do { t->set_ack_state(st, __FILE__, __LINE__); } while(0)
|
||||
#define TBF_POLL_SCHED_SET(t) do { t->poll_sched_set(__FILE__, __LINE__); } while(0)
|
||||
#define TBF_POLL_SCHED_UNSET(t) do { t->poll_sched_unset(__FILE__, __LINE__); } while(0)
|
||||
#define TBF_SET_ASS_ON(t, fl, chk) do { t->set_assigned_on(fl, chk, __FILE__, __LINE__); } while(0)
|
||||
|
||||
struct gprs_rlcmac_tbf {
|
||||
|
@ -199,10 +203,13 @@ struct gprs_rlcmac_tbf {
|
|||
bool dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state rhs) const;
|
||||
bool ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const;
|
||||
bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const;
|
||||
bool poll_scheduled() const;
|
||||
void set_state(enum gprs_rlcmac_tbf_state new_state, const char *file, int line);
|
||||
void set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state new_state, const char *file, int line);
|
||||
void set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line);
|
||||
void set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line);
|
||||
void poll_sched_set(const char *file, int line);
|
||||
void poll_sched_unset(const char *file, int line);
|
||||
void check_pending_ass();
|
||||
bool check_n_clear(uint8_t state_flag);
|
||||
void set_assigned_on(uint8_t state_flag, bool check_ccch, const char *file, int line);
|
||||
|
@ -284,7 +291,6 @@ struct gprs_rlcmac_tbf {
|
|||
|
||||
gprs_llc m_llc;
|
||||
|
||||
enum gprs_rlcmac_tbf_poll_state poll_state;
|
||||
uint32_t poll_fn; /* frame number to poll */
|
||||
uint8_t poll_ts; /* TS to poll */
|
||||
|
||||
|
@ -347,6 +353,7 @@ private:
|
|||
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;
|
||||
|
@ -394,6 +401,11 @@ inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state r
|
|||
return ul_ack_state == rhs;
|
||||
}
|
||||
|
||||
inline bool gprs_rlcmac_tbf::poll_scheduled() const
|
||||
{
|
||||
return poll_state == GPRS_RLCMAC_POLL_SCHED;
|
||||
}
|
||||
|
||||
inline bool gprs_rlcmac_tbf::state_is_not(enum gprs_rlcmac_tbf_state rhs) const
|
||||
{
|
||||
return state != rhs;
|
||||
|
@ -452,6 +464,20 @@ inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new
|
|||
ul_ack_state = new_state;
|
||||
}
|
||||
|
||||
inline void gprs_rlcmac_tbf::poll_sched_set(const char *file, int line)
|
||||
{
|
||||
LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes poll state from %s to GPRS_RLCMAC_POLL_SCHED\n",
|
||||
tbf_name(this), get_value_string(gprs_rlcmac_tbf_poll_state_names, poll_state));
|
||||
poll_state = GPRS_RLCMAC_POLL_SCHED;
|
||||
}
|
||||
|
||||
inline void gprs_rlcmac_tbf::poll_sched_unset(const char *file, int line)
|
||||
{
|
||||
LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes poll state from %s to GPRS_RLCMAC_POLL_NONE\n",
|
||||
tbf_name(this), get_value_string(gprs_rlcmac_tbf_poll_state_names, poll_state));
|
||||
poll_state = GPRS_RLCMAC_POLL_NONE;
|
||||
}
|
||||
|
||||
inline void gprs_rlcmac_tbf::check_pending_ass()
|
||||
{
|
||||
if (ul_ass_state != GPRS_RLCMAC_UL_ASS_NONE)
|
||||
|
|
|
@ -635,7 +635,7 @@ bool gprs_rlcmac_dl_tbf::handle_ack_nack()
|
|||
/* reset N3105 */
|
||||
n3105 = 0;
|
||||
t_stop(T3191, "ACK/NACK received");
|
||||
poll_state = GPRS_RLCMAC_POLL_NONE;
|
||||
TBF_POLL_SCHED_UNSET(this);
|
||||
|
||||
return ack_recovered;
|
||||
}
|
||||
|
@ -1181,7 +1181,7 @@ void gprs_rlcmac_dl_tbf::request_dl_ack()
|
|||
|
||||
bool gprs_rlcmac_dl_tbf::need_control_ts() const
|
||||
{
|
||||
if (poll_state != GPRS_RLCMAC_POLL_NONE)
|
||||
if (poll_scheduled())
|
||||
return false;
|
||||
|
||||
return state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK) ||
|
||||
|
|
|
@ -123,8 +123,7 @@ struct msgb *gprs_rlcmac_ul_tbf::create_ul_ack(uint32_t fn, uint8_t ts)
|
|||
uint32_t new_poll_fn = 0;
|
||||
|
||||
if (final) {
|
||||
if (poll_state == GPRS_RLCMAC_POLL_SCHED &&
|
||||
ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) {
|
||||
if (poll_scheduled() && ul_ack_state_is(GPRS_RLCMAC_UL_ACK_WAIT_ACK)) {
|
||||
LOGPTBFUL(this, LOGL_DEBUG,
|
||||
"Polling is already scheduled, so we must wait for the final uplink ack...\n");
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue