forked from cellular-infrastructure/osmo-pcu
Replace ul_ass_state with osmocom FSM
Related: OS#2709 Change-Id: Id414eafe9c04a9a8759c6fb1a483bf2ee093a4d2
This commit is contained in:
parent
b0ead922a1
commit
6ad11a6990
|
@ -60,6 +60,7 @@ libgprs_la_SOURCES = \
|
|||
tbf.cpp \
|
||||
tbf_fsm.c \
|
||||
tbf_ul.cpp \
|
||||
tbf_ul_ass_fsm.c \
|
||||
tbf_dl.cpp \
|
||||
bts.cpp \
|
||||
bts_pch_timer.c \
|
||||
|
@ -100,6 +101,7 @@ noinst_HEADERS = \
|
|||
tbf.h \
|
||||
tbf_fsm.h \
|
||||
tbf_ul.h \
|
||||
tbf_ul_ass_fsm.h \
|
||||
tbf_dl.h \
|
||||
bts.h \
|
||||
bts_pch_timer.h \
|
||||
|
|
|
@ -589,8 +589,7 @@ static void gen_freq_params(Frequency_Parameters_t *freq_params,
|
|||
|
||||
/* Generate Packet Uplink Assignment as per 3GPP TS 44.060, section 11.2.29.
|
||||
* NOTE: 'block' is expected to be zero-initialized by the caller. */
|
||||
void Encoding::write_packet_uplink_assignment(
|
||||
RlcMacDownlink_t * block, uint8_t old_tfi,
|
||||
void write_packet_uplink_assignment(RlcMacDownlink_t *block, uint8_t old_tfi,
|
||||
uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
|
||||
const struct gprs_rlcmac_ul_tbf *tbf, uint8_t poll, uint8_t rrbp, uint8_t alpha,
|
||||
uint8_t gamma, int8_t ta_idx, bool use_egprs)
|
||||
|
@ -1737,8 +1736,7 @@ void Encoding::rlc_data_to_dl_append_egprs_li_padding(
|
|||
* section 7.1.3.2.1 On receipt of a PACKET RESOURCE REQUEST message
|
||||
* 8.1.2.5 Establishment of uplink TBF
|
||||
*/
|
||||
void Encoding::write_packet_access_reject(
|
||||
bitvec * dest, uint32_t tlli, unsigned long t3172_ms)
|
||||
void write_packet_access_reject(struct bitvec *dest, uint32_t tlli, unsigned long t3172_ms)
|
||||
{
|
||||
unsigned wp = 0;
|
||||
|
||||
|
|
|
@ -63,13 +63,6 @@ public:
|
|||
uint8_t t3142
|
||||
);
|
||||
|
||||
static void write_packet_uplink_assignment(
|
||||
RlcMacDownlink_t * block, uint8_t old_tfi,
|
||||
uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
|
||||
const struct gprs_rlcmac_ul_tbf *tbf, uint8_t poll, uint8_t rrbp,
|
||||
uint8_t alpha, uint8_t gamma, int8_t ta_idx,
|
||||
bool use_egprs);
|
||||
|
||||
static void write_packet_downlink_assignment(RlcMacDownlink_t * block,
|
||||
bool old_tfi_is_valid, uint8_t old_tfi, uint8_t old_downlink,
|
||||
const struct gprs_rlcmac_dl_tbf *tbf, uint8_t poll, uint8_t rrbp,
|
||||
|
@ -78,9 +71,6 @@ public:
|
|||
|
||||
static void encode_rbb(const char *show_rbb, uint8_t *rbb);
|
||||
|
||||
static void write_packet_access_reject(bitvec * dest, uint32_t tlli,
|
||||
unsigned long t3172_ms);
|
||||
|
||||
static void write_packet_uplink_ack(
|
||||
bitvec * dest, struct gprs_rlcmac_ul_tbf *tbf, bool is_final,
|
||||
uint8_t rrbp);
|
||||
|
@ -121,6 +111,13 @@ public:
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
void write_packet_access_reject(struct bitvec *dest, uint32_t tlli, unsigned long t3172_ms);
|
||||
void write_packet_uplink_assignment(RlcMacDownlink_t *block, uint8_t old_tfi,
|
||||
uint8_t old_downlink, uint32_t tlli, uint8_t use_tlli,
|
||||
const struct gprs_rlcmac_ul_tbf *tbf, uint8_t poll,
|
||||
uint8_t rrbp, uint8_t alpha, uint8_t gamma, int8_t ta_idx,
|
||||
bool use_egprs);
|
||||
|
||||
void write_packet_neighbour_cell_data(RlcMacDownlink_t *block,
|
||||
bool tfi_is_dl, uint8_t tfi, uint8_t container_id,
|
||||
uint8_t container_idx, PNCDContainer_t *container);
|
||||
|
|
|
@ -58,8 +58,7 @@ static void get_ctrl_msg_tbf_candidates(const struct gprs_rlcmac_pdch *pdch,
|
|||
tbf_cand->ul_ack = ul_tbf;
|
||||
if (ul_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
|
||||
tbf_cand->dl_ass = ul_tbf;
|
||||
if (ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
|
||||
|| ul_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
|
||||
if (tbf_ul_ass_rts(ul_tbf))
|
||||
tbf_cand->ul_ass = ul_tbf;
|
||||
/* NACC ready to send. TFI assigned is needed to send messages */
|
||||
if (ul_tbf->is_tfi_assigned() && ms_nacc_rts(ul_tbf->ms()))
|
||||
|
@ -75,8 +74,7 @@ states? */
|
|||
continue;
|
||||
if (dl_tbf->dl_ass_state_is(GPRS_RLCMAC_DL_ASS_SEND_ASS))
|
||||
tbf_cand->dl_ass = dl_tbf;
|
||||
if (dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS)
|
||||
|| dl_tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
|
||||
if (tbf_ul_ass_rts(dl_tbf))
|
||||
tbf_cand->ul_ass = dl_tbf;
|
||||
/* NACC ready to send. TFI assigned is needed to send messages */
|
||||
if (dl_tbf->is_tfi_assigned() && ms_nacc_rts(dl_tbf->ms()))
|
||||
|
@ -168,10 +166,10 @@ static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_pdch *pdch, uint32_
|
|||
* because they may kill the TBF when the CONTROL ACK is
|
||||
* received, thus preventing the others from being processed.
|
||||
*/
|
||||
if (tbf == tbfs->ul_ass && tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ))
|
||||
msg = tbfs->ul_ass->create_packet_access_reject();
|
||||
if (tbf == tbfs->ul_ass && tbf->ul_ass_state_is(TBF_UL_ASS_SEND_ASS_REJ))
|
||||
msg = tbf_ul_ass_create_rlcmac_msg(tbfs->ul_ass, fn, ts);
|
||||
else if (tbf == tbfs->ul_ass && tbf->direction == GPRS_RLCMAC_DL_TBF)
|
||||
msg = tbfs->ul_ass->create_ul_ass(fn, ts);
|
||||
msg = tbf_ul_ass_create_rlcmac_msg(tbfs->ul_ass, fn, ts);
|
||||
else if (tbf == tbfs->dl_ass && tbf->direction == GPRS_RLCMAC_UL_TBF)
|
||||
msg = tbfs->dl_ass->create_dl_ass(fn, ts);
|
||||
else if (tbf == tbfs->ul_ack)
|
||||
|
@ -201,7 +199,7 @@ static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_pdch *pdch, uint32_
|
|||
msg = tbfs->dl_ass->create_dl_ass(fn, ts);
|
||||
} else if (tbfs->ul_ass) {
|
||||
tbf = tbfs->ul_ass;
|
||||
msg = tbfs->ul_ass->create_ul_ass(fn, ts);
|
||||
msg = tbf_ul_ass_create_rlcmac_msg(tbfs->ul_ass, fn, ts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
src/pdch.cpp
10
src/pdch.cpp
|
@ -124,10 +124,10 @@ static inline void sched_ul_ass_or_rej(struct gprs_rlcmac_bts *bts, struct gprs_
|
|||
/* schedule uplink assignment or reject */
|
||||
if (ul_tbf) {
|
||||
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack message, so we provide one:\n");
|
||||
TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS);
|
||||
osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS, NULL);
|
||||
} else {
|
||||
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack message, so we packet access reject:\n");
|
||||
TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
|
||||
osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,11 +377,11 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
|
|||
tbf_assign_control_ts(new_tbf);
|
||||
return;
|
||||
}
|
||||
if (tbf->ul_ass_state_is(GPRS_RLCMAC_UL_ASS_WAIT_ACK)) {
|
||||
if (tbf->ul_ass_state_is(TBF_UL_ASS_WAIT_ACK)) {
|
||||
LOGPTBF(tbf, LOGL_DEBUG, "[DOWNLINK] UPLINK ASSIGNED\n");
|
||||
/* reset N3105 */
|
||||
tbf->n_reset(N3105);
|
||||
TBF_SET_ASS_STATE_UL(tbf, GPRS_RLCMAC_UL_ASS_NONE);
|
||||
osmo_fsm_inst_dispatch(tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_RX_ASS_CTRL_ACK, NULL);
|
||||
|
||||
new_tbf = ms_ul_tbf(ms);
|
||||
if (!new_tbf) {
|
||||
|
@ -695,7 +695,7 @@ void gprs_rlcmac_pdch::rcv_resource_request(Packet_Resource_Request_t *request,
|
|||
|
||||
ul_tbf->control_ts = ts_no;
|
||||
/* schedule uplink assignment */
|
||||
TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS);
|
||||
osmo_fsm_inst_dispatch(ul_tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS, NULL);
|
||||
|
||||
/* get measurements */
|
||||
get_meas(meas, request);
|
||||
|
|
147
src/tbf.cpp
147
src/tbf.cpp
|
@ -68,14 +68,6 @@ const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[] = {
|
|||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const struct value_string gprs_rlcmac_tbf_ul_ass_state_names[] = {
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ASS_NONE),
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ASS_SEND_ASS),
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ),
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ASS_WAIT_ACK),
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
const struct value_string gprs_rlcmac_tbf_ul_ack_state_names[] = {
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_NONE),
|
||||
OSMO_VALUE_STRING(GPRS_RLCMAC_UL_ACK_SEND_ACK), /* send acknowledge on next RTS */
|
||||
|
@ -133,7 +125,6 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
|
|||
m_ctrs(NULL),
|
||||
m_ms(ms),
|
||||
dl_ass_state(GPRS_RLCMAC_DL_ASS_NONE),
|
||||
ul_ass_state(GPRS_RLCMAC_UL_ASS_NONE),
|
||||
ul_ack_state(GPRS_RLCMAC_UL_ACK_NONE),
|
||||
m_egprs_enabled(false)
|
||||
{
|
||||
|
@ -153,6 +144,10 @@ gprs_rlcmac_tbf::gprs_rlcmac_tbf(struct gprs_rlcmac_bts *bts_, GprsMs *ms, gprs_
|
|||
state_fsm.tbf = this;
|
||||
state_fsm.fi = osmo_fsm_inst_alloc(&tbf_fsm, this, &state_fsm, LOGL_INFO, NULL);
|
||||
|
||||
memset(&ul_ass_fsm, 0, sizeof(ul_ass_fsm));
|
||||
ul_ass_fsm.tbf = this;
|
||||
ul_ass_fsm.fi = osmo_fsm_inst_alloc(&tbf_ul_ass_fsm, this, &ul_ass_fsm, LOGL_INFO, NULL);
|
||||
|
||||
m_rlc.init();
|
||||
m_llc.init();
|
||||
|
||||
|
@ -164,6 +159,10 @@ gprs_rlcmac_tbf::~gprs_rlcmac_tbf()
|
|||
{
|
||||
osmo_fsm_inst_free(state_fsm.fi);
|
||||
state_fsm.fi = NULL;
|
||||
|
||||
osmo_fsm_inst_free(ul_ass_fsm.fi);
|
||||
ul_ass_fsm.fi = NULL;
|
||||
|
||||
rate_ctr_group_free(m_ctrs);
|
||||
}
|
||||
|
||||
|
@ -573,8 +572,6 @@ void gprs_rlcmac_tbf::set_polling(uint32_t new_poll_fn, uint8_t ts, enum pdch_ul
|
|||
|
||||
switch (reason) {
|
||||
case PDCH_ULC_POLL_UL_ASS:
|
||||
ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
|
||||
|
||||
LOGPTBFDL(this, LOGL_INFO, "Scheduled UL Assignment polling on %s (FN=%d, TS=%d)\n",
|
||||
chan, new_poll_fn, ts);
|
||||
break;
|
||||
|
@ -627,14 +624,13 @@ void gprs_rlcmac_tbf::poll_timeout(struct gprs_rlcmac_pdch *pdch, uint32_t poll_
|
|||
ul_tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_SEND_ACK;
|
||||
}
|
||||
|
||||
} else if (ul_ass_state == GPRS_RLCMAC_UL_ASS_WAIT_ACK) {
|
||||
} else if (ul_ass_state_is(TBF_UL_ASS_WAIT_ACK)) {
|
||||
if (!(state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_TO_UL_ASS))) {
|
||||
LOGPTBF(this, LOGL_NOTICE,
|
||||
"Timeout for polling PACKET CONTROL ACK for PACKET UPLINK ASSIGNMENT: %s\n",
|
||||
rlcmac_diag().c_str());
|
||||
state_fsm.state_flags |= (1 << GPRS_RLCMAC_FLAG_TO_UL_ASS);
|
||||
}
|
||||
ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
|
||||
bts_do_rate_ctr_inc(bts, CTR_RLC_ASS_TIMEDOUT);
|
||||
bts_do_rate_ctr_inc(bts, CTR_PUA_POLL_TIMEDOUT);
|
||||
if (n_inc(N3105)) {
|
||||
|
@ -643,8 +639,8 @@ void gprs_rlcmac_tbf::poll_timeout(struct gprs_rlcmac_pdch *pdch, uint32_t poll_
|
|||
bts_do_rate_ctr_inc(bts, CTR_PUA_POLL_FAILED);
|
||||
return;
|
||||
}
|
||||
/* reschedule UL assignment */
|
||||
ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
|
||||
/* Signal timeout to FSM to reschedule UL assignment */
|
||||
osmo_fsm_inst_dispatch(this->ul_ass_fsm.fi, TBF_UL_ASS_EV_ASS_POLL_TIMEOUT, NULL);
|
||||
} else if (dl_ass_state == GPRS_RLCMAC_DL_ASS_WAIT_ACK) {
|
||||
if (!(state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ASS))) {
|
||||
LOGPTBF(this, LOGL_NOTICE,
|
||||
|
@ -764,7 +760,7 @@ void gprs_rlcmac_tbf::handle_timeout()
|
|||
|
||||
LOGPTBF(this, LOGL_DEBUG, "timer 0 expired. cur_fn=%d\n", current_fn);
|
||||
|
||||
/* PACCH assignment timeout (see timers X2000, X2001) */
|
||||
/* PACCH assignment timeout (see timer X2001) */
|
||||
if ((state_fsm.state_flags & (1 << GPRS_RLCMAC_FLAG_PACCH))) {
|
||||
if (state_is(TBF_ST_ASSIGN)) {
|
||||
LOGPTBF(this, LOGL_NOTICE, "releasing due to PACCH assignment timeout.\n");
|
||||
|
@ -838,7 +834,7 @@ struct msgb *gprs_rlcmac_tbf::create_dl_ass(uint32_t fn, uint8_t ts)
|
|||
/* We only use this function in control TS (PACCH) so that MS can always answer the poll */
|
||||
OSMO_ASSERT(is_control_ts(ts));
|
||||
|
||||
if (ul_ass_state == GPRS_RLCMAC_UL_ASS_WAIT_ACK)
|
||||
if (ul_ass_state_is(TBF_UL_ASS_WAIT_ACK))
|
||||
{
|
||||
LOGPTBF(this, LOGL_DEBUG,
|
||||
"Polling is already scheduled, so we must wait for the uplink assignment...\n");
|
||||
|
@ -921,102 +917,6 @@ free_ret:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
struct msgb *gprs_rlcmac_tbf::create_packet_access_reject()
|
||||
{
|
||||
struct msgb *msg;
|
||||
|
||||
msg = msgb_alloc(GSM_MACBLOCK_LEN, "rlcmac_ul_ass_rej");
|
||||
|
||||
bitvec *packet_access_rej = bitvec_alloc(GSM_MACBLOCK_LEN, tall_pcu_ctx);
|
||||
|
||||
bitvec_unhex(packet_access_rej, DUMMY_VEC);
|
||||
|
||||
Encoding::write_packet_access_reject(packet_access_rej, tlli(),
|
||||
osmo_tdef_get(bts->T_defs_bts, 3172, OSMO_TDEF_MS, -1));
|
||||
|
||||
bts_do_rate_ctr_inc(bts, CTR_PKT_ACCESS_REJ);
|
||||
|
||||
bitvec_pack(packet_access_rej, msgb_put(msg, GSM_MACBLOCK_LEN));
|
||||
|
||||
bitvec_free(packet_access_rej);
|
||||
ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
|
||||
|
||||
/* Start release only if it is UL TBF */
|
||||
if (direction == GPRS_RLCMAC_UL_TBF) {
|
||||
/* tbf_free() called in gprs_rlcmac_tbf::handle_timeout */
|
||||
T_START(this, T0, -2000, "reject (PACCH)", true);
|
||||
}
|
||||
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
struct msgb *gprs_rlcmac_tbf::create_ul_ass(uint32_t fn, uint8_t ts)
|
||||
{
|
||||
struct msgb *msg = NULL;
|
||||
struct gprs_rlcmac_ul_tbf *new_tbf = NULL;
|
||||
RlcMacDownlink_t *mac_control_block = NULL;
|
||||
int rc;
|
||||
unsigned int rrbp;
|
||||
uint32_t new_poll_fn;
|
||||
|
||||
if (ul_ass_state == GPRS_RLCMAC_UL_ASS_WAIT_ACK) {
|
||||
LOGPTBFUL(this, LOGL_DEBUG,
|
||||
"Polling is already scheduled, so we must wait for the uplink assignment...\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rc = check_polling(fn, ts, &new_poll_fn, &rrbp);
|
||||
if (rc < 0)
|
||||
return NULL;
|
||||
|
||||
if (ms())
|
||||
new_tbf = ms_ul_tbf(ms());
|
||||
if (!new_tbf) {
|
||||
LOGPTBFUL(this, LOGL_ERROR,
|
||||
"We have a schedule for uplink assignment, but there is no uplink TBF\n");
|
||||
ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msg = msgb_alloc(GSM_MACBLOCK_LEN, "rlcmac_ul_ass");
|
||||
if (!msg)
|
||||
return NULL;
|
||||
|
||||
/* Initialize a bit vector that uses allocated msgb as the data buffer.
|
||||
* Old G++ does not support non-trivial designated initializers. Sigh. */
|
||||
struct bitvec bv = { };
|
||||
bv.data = msgb_put(msg, GSM_MACBLOCK_LEN);
|
||||
bv.data_len = GSM_MACBLOCK_LEN;
|
||||
bitvec_unhex(&bv, DUMMY_VEC);
|
||||
|
||||
LOGPTBF(new_tbf, LOGL_INFO, "start Packet Uplink Assignment (PACCH)\n");
|
||||
mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t);
|
||||
Encoding::write_packet_uplink_assignment(mac_control_block, m_tfi,
|
||||
(direction == GPRS_RLCMAC_DL_TBF), tlli(),
|
||||
is_tlli_valid(), new_tbf, 1, rrbp, bts_get_ms_pwr_alpha(new_tbf->bts),
|
||||
the_pcu->vty.gamma, -1, is_egprs_enabled());
|
||||
|
||||
LOGP(DTBF, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Uplink Assignment +++++++++++++++++++++++++\n");
|
||||
rc = encode_gsm_rlcmac_downlink(&bv, mac_control_block);
|
||||
if (rc < 0) {
|
||||
LOGP(DTBF, LOGL_ERROR, "Encoding of Packet Uplink Ass failed (%d)\n", rc);
|
||||
goto free_ret;
|
||||
}
|
||||
LOGP(DTBF, LOGL_DEBUG, "------------------------- TX : Packet Uplink Assignment -------------------------\n");
|
||||
bts_do_rate_ctr_inc(bts, CTR_PKT_UL_ASSIGNMENT);
|
||||
|
||||
set_polling(new_poll_fn, ts, PDCH_ULC_POLL_UL_ASS);
|
||||
|
||||
talloc_free(mac_control_block);
|
||||
return msg;
|
||||
|
||||
free_ret:
|
||||
talloc_free(mac_control_block);
|
||||
msgb_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int gprs_rlcmac_tbf::establish_dl_tbf_on_pacch()
|
||||
{
|
||||
struct gprs_rlcmac_dl_tbf *new_tbf = NULL;
|
||||
|
@ -1057,9 +957,14 @@ const char *gprs_rlcmac_tbf::name() const
|
|||
|
||||
void tbf_update_state_fsm_name(struct gprs_rlcmac_tbf *tbf)
|
||||
{
|
||||
osmo_fsm_inst_update_id_f_sanitize(tbf->state_fsm.fi, '_', "%s-TFI_%d",
|
||||
tbf_direction(tbf) == GPRS_RLCMAC_UL_TBF ? "UL" : "DL",
|
||||
tbf_tfi(tbf));
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "%s-TFI_%d",
|
||||
tbf_direction(tbf) == GPRS_RLCMAC_UL_TBF ? "UL" : "DL",
|
||||
tbf_tfi(tbf));
|
||||
osmo_identifier_sanitize_buf(buf, NULL, '_');
|
||||
|
||||
osmo_fsm_inst_update_id(tbf->state_fsm.fi, buf);
|
||||
osmo_fsm_inst_update_id(tbf->ul_ass_fsm.fi, buf);
|
||||
}
|
||||
|
||||
void gprs_rlcmac_tbf::rotate_in_list()
|
||||
|
@ -1123,6 +1028,11 @@ enum tbf_fsm_states tbf_state(const struct gprs_rlcmac_tbf *tbf)
|
|||
return (enum tbf_fsm_states)tbf->state_fsm.fi->state;
|
||||
}
|
||||
|
||||
struct osmo_fsm_inst *tbf_ul_ass_fi(const struct gprs_rlcmac_tbf *tbf)
|
||||
{
|
||||
return tbf->ul_ass_fsm.fi;
|
||||
}
|
||||
|
||||
enum gprs_rlcmac_tbf_direction tbf_direction(const struct gprs_rlcmac_tbf *tbf)
|
||||
{
|
||||
return tbf->direction;
|
||||
|
@ -1182,6 +1092,11 @@ uint8_t tbf_tfi(const struct gprs_rlcmac_tbf *tbf)
|
|||
return tbf->tfi();
|
||||
}
|
||||
|
||||
bool tbf_is_egprs_enabled(const struct gprs_rlcmac_tbf *tbf)
|
||||
{
|
||||
return tbf->is_egprs_enabled();
|
||||
}
|
||||
|
||||
int tbf_check_polling(const struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts, uint32_t *poll_fn, unsigned int *rrbp)
|
||||
{
|
||||
return tbf->check_polling(fn, ts, poll_fn, rrbp);
|
||||
|
|
34
src/tbf.h
34
src/tbf.h
|
@ -48,6 +48,7 @@ extern "C" {
|
|||
#include "coding_scheme.h"
|
||||
#include <pdch_ul_controller.h>
|
||||
#include <tbf_fsm.h>
|
||||
#include <tbf_ul_ass_fsm.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -64,15 +65,6 @@ enum gprs_rlcmac_tbf_dl_ass_state {
|
|||
|
||||
extern const struct value_string gprs_rlcmac_tbf_dl_ass_state_names[];
|
||||
|
||||
enum gprs_rlcmac_tbf_ul_ass_state {
|
||||
GPRS_RLCMAC_UL_ASS_NONE = 0,
|
||||
GPRS_RLCMAC_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
|
||||
GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */
|
||||
GPRS_RLCMAC_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
|
||||
};
|
||||
|
||||
extern const struct value_string gprs_rlcmac_tbf_ul_ass_state_names[];
|
||||
|
||||
enum gprs_rlcmac_tbf_ul_ack_state {
|
||||
GPRS_RLCMAC_UL_ACK_NONE = 0,
|
||||
GPRS_RLCMAC_UL_ACK_SEND_ACK, /* send acknowledge on next RTS */
|
||||
|
@ -153,7 +145,6 @@ enum tbf_counters { /* TBF counters from 3GPP TS 44.060 §13.4 */
|
|||
#define T_START(tbf, t, T, r, f) tbf->t_start(t, T, r, f, __FILE__, __LINE__)
|
||||
|
||||
#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)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -162,6 +153,7 @@ extern "C" {
|
|||
struct gprs_rlcmac_tbf;
|
||||
const char *tbf_name(const struct gprs_rlcmac_tbf *tbf);
|
||||
enum tbf_fsm_states tbf_state(const struct gprs_rlcmac_tbf *tbf);
|
||||
struct osmo_fsm_inst *tbf_ul_ass_fi(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);
|
||||
|
@ -175,6 +167,7 @@ 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);
|
||||
uint8_t tbf_tfi(const struct gprs_rlcmac_tbf *tbf);
|
||||
bool tbf_is_egprs_enabled(const struct gprs_rlcmac_tbf *tbf);
|
||||
int tbf_assign_control_ts(struct gprs_rlcmac_tbf *tbf);
|
||||
int tbf_check_polling(const struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts, uint32_t *poll_fn, unsigned int *rrbp);
|
||||
void tbf_set_polling(struct gprs_rlcmac_tbf *tbf, uint32_t new_poll_fn, uint8_t ts, enum pdch_ulc_tbf_poll_reason t);
|
||||
|
@ -196,10 +189,9 @@ struct gprs_rlcmac_tbf {
|
|||
bool state_is(enum tbf_fsm_states rhs) const;
|
||||
bool state_is_not(enum tbf_fsm_states rhs) const;
|
||||
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_ass_state_is(enum tbf_ul_ass_fsm_states rhs) const;
|
||||
bool ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const;
|
||||
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);
|
||||
|
@ -209,8 +201,6 @@ struct gprs_rlcmac_tbf {
|
|||
const char *name() const;
|
||||
|
||||
struct msgb *create_dl_ass(uint32_t fn, uint8_t ts);
|
||||
struct msgb *create_ul_ass(uint32_t fn, uint8_t ts);
|
||||
struct msgb *create_packet_access_reject();
|
||||
|
||||
GprsMs *ms() const;
|
||||
void set_ms(GprsMs *ms);
|
||||
|
@ -305,6 +295,8 @@ struct gprs_rlcmac_tbf {
|
|||
|
||||
struct rate_ctr_group *m_ctrs;
|
||||
struct tbf_fsm_ctx state_fsm;
|
||||
struct tbf_ul_ass_fsm_ctx ul_ass_fsm;
|
||||
|
||||
struct llist_item m_ms_list;
|
||||
struct llist_item m_trx_list;
|
||||
|
||||
|
@ -318,7 +310,6 @@ protected:
|
|||
private:
|
||||
void enable_egprs();
|
||||
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;
|
||||
bool m_egprs_enabled;
|
||||
struct osmo_timer_list Tarr[T_MAX];
|
||||
|
@ -336,9 +327,9 @@ inline bool gprs_rlcmac_tbf::dl_ass_state_is(enum gprs_rlcmac_tbf_dl_ass_state r
|
|||
return dl_ass_state == rhs;
|
||||
}
|
||||
|
||||
inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum gprs_rlcmac_tbf_ul_ass_state rhs) const
|
||||
inline bool gprs_rlcmac_tbf::ul_ass_state_is(enum tbf_ul_ass_fsm_states rhs) const
|
||||
{
|
||||
return ul_ass_state == rhs;
|
||||
return tbf_ul_ass_fi(this)->state == rhs;
|
||||
}
|
||||
|
||||
inline bool gprs_rlcmac_tbf::ul_ack_state_is(enum gprs_rlcmac_tbf_ul_ack_state rhs) const
|
||||
|
@ -366,15 +357,6 @@ inline void gprs_rlcmac_tbf::set_ass_state_dl(enum gprs_rlcmac_tbf_dl_ass_state
|
|||
dl_ass_state = new_state;
|
||||
}
|
||||
|
||||
inline void gprs_rlcmac_tbf::set_ass_state_ul(enum gprs_rlcmac_tbf_ul_ass_state new_state, const char *file, int line)
|
||||
{
|
||||
LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ASS state from %s to %s\n",
|
||||
tbf_name(this),
|
||||
get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, ul_ass_state),
|
||||
get_value_string(gprs_rlcmac_tbf_ul_ass_state_names, new_state));
|
||||
ul_ass_state = new_state;
|
||||
}
|
||||
|
||||
inline void gprs_rlcmac_tbf::set_ack_state(enum gprs_rlcmac_tbf_ul_ack_state new_state, const char *file, int line)
|
||||
{
|
||||
LOGPSRC(DTBF, LOGL_DEBUG, file, line, "%s changes UL ACK state from %s to %s\n",
|
||||
|
|
|
@ -222,7 +222,7 @@ struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
|
|||
llist_add(tbf_trx_list((struct gprs_rlcmac_tbf *)ul_tbf), &trx->ul_tbfs);
|
||||
bts_do_rate_ctr_inc(ul_tbf->bts, CTR_TBF_UL_ALLOCATED);
|
||||
osmo_fsm_inst_dispatch(ul_tbf->state_fsm.fi, TBF_EV_ASSIGN_ADD_PACCH, NULL);
|
||||
TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
|
||||
osmo_fsm_inst_dispatch(ul_tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL);
|
||||
|
||||
return ul_tbf;
|
||||
}
|
||||
|
|
|
@ -50,8 +50,6 @@ enum tbf_egprs_ul_counters {
|
|||
/* Used in ul_tbf->m_usf[] to flag unassigned USF on a given TS: */
|
||||
#define USF_INVALID 0xFF
|
||||
|
||||
#define LOGPTBFUL(tbf, level, fmt, args...) LOGP(DTBFUL, level, "%s " fmt, tbf_name(tbf), ## args)
|
||||
|
||||
struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
|
||||
gprs_rlcmac_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms);
|
||||
~gprs_rlcmac_ul_tbf();
|
||||
|
@ -139,6 +137,8 @@ void update_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, int8_t ta_delta);
|
|||
void set_tbf_ta(struct gprs_rlcmac_ul_tbf *tbf, uint8_t ta);
|
||||
struct gprs_rlcmac_ul_tbf *as_ul_tbf(struct gprs_rlcmac_tbf *tbf);
|
||||
void tbf_usf_timeout(struct gprs_rlcmac_ul_tbf *tbf);
|
||||
|
||||
#define LOGPTBFUL(tbf, level, fmt, args...) LOGP(DTBFUL, level, "%s " fmt, tbf_name(tbf), ## args)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,309 @@
|
|||
/* tbf_ul_ass_fsm.c
|
||||
*
|
||||
* Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
* Author: Pau Espin Pedrol <pespin@sysmocom.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <talloc.h>
|
||||
|
||||
#include <osmocom/core/bitvec.h>
|
||||
|
||||
#include <tbf_ul_ass_fsm.h>
|
||||
#include <gprs_rlcmac.h>
|
||||
#include <gprs_debug.h>
|
||||
#include <gprs_ms.h>
|
||||
#include <encoding.h>
|
||||
#include <bts.h>
|
||||
#include <tbf.h>
|
||||
#include <tbf_ul.h>
|
||||
|
||||
#define X(s) (1 << (s))
|
||||
|
||||
const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32] = {
|
||||
[TBF_UL_ASS_NONE] = {},
|
||||
[TBF_UL_ASS_SEND_ASS] = {},
|
||||
[TBF_UL_ASS_SEND_ASS_REJ] = {},
|
||||
[TBF_UL_ASS_WAIT_ACK] = {},
|
||||
};
|
||||
|
||||
const struct value_string tbf_ul_ass_fsm_event_names[] = {
|
||||
{ TBF_UL_ASS_EV_SCHED_ASS, "SCHED_ASS" },
|
||||
{ TBF_UL_ASS_EV_SCHED_ASS_REJ, "SCHED_ASS_REJ" },
|
||||
{ TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, "CREATE_RLCMAC_MSG" },
|
||||
{ TBF_UL_ASS_EV_RX_ASS_CTRL_ACK, "RX_ASS_CTRL_ACK" },
|
||||
{ TBF_UL_ASS_EV_ASS_POLL_TIMEOUT, "ASS_POLL_TIMEOUT" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
static struct msgb *create_packet_access_reject(const struct tbf_ul_ass_fsm_ctx *ctx)
|
||||
{
|
||||
struct msgb *msg;
|
||||
struct GprsMs *ms = tbf_ms(ctx->tbf);
|
||||
|
||||
msg = msgb_alloc(GSM_MACBLOCK_LEN, "rlcmac_ul_ass_rej");
|
||||
|
||||
struct bitvec *packet_access_rej = bitvec_alloc(GSM_MACBLOCK_LEN, ctx->tbf);
|
||||
|
||||
bitvec_unhex(packet_access_rej, DUMMY_VEC);
|
||||
|
||||
write_packet_access_reject(packet_access_rej, ms_tlli(ms),
|
||||
osmo_tdef_get(ms->bts->T_defs_bts, 3172, OSMO_TDEF_MS, -1));
|
||||
|
||||
bts_do_rate_ctr_inc(ms->bts, CTR_PKT_ACCESS_REJ);
|
||||
|
||||
bitvec_pack(packet_access_rej, msgb_put(msg, GSM_MACBLOCK_LEN));
|
||||
|
||||
bitvec_free(packet_access_rej);
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
struct msgb *create_packet_ul_assign(const struct tbf_ul_ass_fsm_ctx *ctx,
|
||||
const struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *d)
|
||||
{
|
||||
struct msgb *msg = NULL;
|
||||
struct gprs_rlcmac_ul_tbf *new_tbf = NULL;
|
||||
RlcMacDownlink_t *mac_control_block = NULL;
|
||||
struct GprsMs *ms = tbf_ms(ctx->tbf);
|
||||
uint32_t tlli;
|
||||
int rc;
|
||||
unsigned int rrbp;
|
||||
uint32_t new_poll_fn;
|
||||
|
||||
rc = tbf_check_polling(ctx->tbf, d->fn, d->ts, &new_poll_fn, &rrbp);
|
||||
if (rc < 0)
|
||||
return NULL;
|
||||
|
||||
new_tbf = ms_ul_tbf(ms);
|
||||
if (!new_tbf) {
|
||||
LOGPTBF(ctx->tbf, LOGL_ERROR,
|
||||
"We have a schedule for uplink assignment, but there is no uplink TBF\n");
|
||||
tbf_ul_ass_fsm_state_chg(ctx->fi, TBF_UL_ASS_NONE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msg = msgb_alloc(GSM_MACBLOCK_LEN, "rlcmac_ul_ass");
|
||||
if (!msg)
|
||||
return NULL;
|
||||
|
||||
/* Initialize a bit vector that uses allocated msgb as the data buffer. */
|
||||
struct bitvec bv = {
|
||||
.data = msgb_put(msg, GSM_MACBLOCK_LEN),
|
||||
.data_len = GSM_MACBLOCK_LEN,
|
||||
};
|
||||
bitvec_unhex(&bv, DUMMY_VEC);
|
||||
|
||||
LOGPTBFUL((const struct gprs_rlcmac_tbf *)new_tbf, LOGL_INFO, "start Packet Uplink Assignment (PACCH)\n");
|
||||
mac_control_block = (RlcMacDownlink_t *)talloc_zero(ctx->tbf, RlcMacDownlink_t);
|
||||
tlli = ms_tlli(ms);
|
||||
write_packet_uplink_assignment(mac_control_block, tbf_tfi(ctx->tbf),
|
||||
(tbf_direction(ctx->tbf) == GPRS_RLCMAC_DL_TBF), ms_tlli(ms),
|
||||
tlli != GSM_RESERVED_TMSI, new_tbf, 1, rrbp, bts_get_ms_pwr_alpha(ms->bts),
|
||||
the_pcu->vty.gamma, -1, tbf_is_egprs_enabled(ctx->tbf));
|
||||
|
||||
LOGP(DTBF, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Uplink Assignment +++++++++++++++++++++++++\n");
|
||||
rc = encode_gsm_rlcmac_downlink(&bv, mac_control_block);
|
||||
if (rc < 0) {
|
||||
LOGP(DTBF, LOGL_ERROR, "Encoding of Packet Uplink Ass failed (%d)\n", rc);
|
||||
goto free_ret;
|
||||
}
|
||||
LOGP(DTBF, LOGL_DEBUG, "------------------------- TX : Packet Uplink Assignment -------------------------\n");
|
||||
bts_do_rate_ctr_inc(ms->bts, CTR_PKT_UL_ASSIGNMENT);
|
||||
|
||||
tbf_set_polling(ctx->tbf, new_poll_fn, d->ts, PDCH_ULC_POLL_UL_ASS);
|
||||
|
||||
talloc_free(mac_control_block);
|
||||
return msg;
|
||||
|
||||
free_ret:
|
||||
talloc_free(mac_control_block);
|
||||
msgb_free(msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void st_none_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
|
||||
{
|
||||
struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
|
||||
unsigned long val;
|
||||
unsigned int sec, micro;
|
||||
|
||||
/* Start release after rejecting only if it is UL TBF */
|
||||
if (prev_state == TBF_UL_ASS_SEND_ASS_REJ &&
|
||||
tbf_direction(ctx->tbf) == GPRS_RLCMAC_UL_TBF) {
|
||||
/* tbf_free() called upon trigger */
|
||||
fi->T = -2000;
|
||||
val = osmo_tdef_get(the_pcu->T_defs, fi->T, OSMO_TDEF_MS, -1);
|
||||
sec = val / 1000;
|
||||
micro = (val % 1000) * 1000;
|
||||
LOGPTBF(ctx->tbf, LOGL_DEBUG, "starting timer X2000 [reject (PACCH)] with %u sec. %u microsec\n",
|
||||
sec, micro);
|
||||
osmo_timer_schedule(&fi->timer, sec, micro);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void st_none(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||
{
|
||||
switch (event) {
|
||||
case TBF_UL_ASS_EV_SCHED_ASS:
|
||||
tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_SEND_ASS);
|
||||
break;
|
||||
case TBF_UL_ASS_EV_SCHED_ASS_REJ:
|
||||
tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_SEND_ASS_REJ);
|
||||
break;
|
||||
default:
|
||||
OSMO_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void st_send_ass(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||
{
|
||||
struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
|
||||
struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *data_ctx;
|
||||
|
||||
switch (event) {
|
||||
case TBF_UL_ASS_EV_CREATE_RLCMAC_MSG:
|
||||
data_ctx = (struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *)data;
|
||||
data_ctx->msg = create_packet_ul_assign(ctx, data_ctx);
|
||||
if (!data_ctx->msg)
|
||||
return;
|
||||
tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_WAIT_ACK);
|
||||
break;
|
||||
default:
|
||||
OSMO_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void st_send_ass_rej(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||
{
|
||||
struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
|
||||
struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *data_ctx;
|
||||
|
||||
switch (event) {
|
||||
case TBF_UL_ASS_EV_CREATE_RLCMAC_MSG:
|
||||
data_ctx = (struct tbf_ul_ass_ev_create_rlcmac_msg_ctx *)data;
|
||||
data_ctx->msg = create_packet_access_reject(ctx);
|
||||
if (!data_ctx->msg)
|
||||
return;
|
||||
tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_NONE);
|
||||
break;
|
||||
default:
|
||||
OSMO_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
static void st_wait_ack(struct osmo_fsm_inst *fi, uint32_t event, void *data)
|
||||
{
|
||||
switch (event) {
|
||||
case TBF_UL_ASS_EV_RX_ASS_CTRL_ACK:
|
||||
tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_NONE);
|
||||
break;
|
||||
case TBF_UL_ASS_EV_ASS_POLL_TIMEOUT:
|
||||
/* Reschedule Pkt Ul Ass */
|
||||
tbf_ul_ass_fsm_state_chg(fi, TBF_UL_ASS_SEND_ASS);
|
||||
break;
|
||||
default:
|
||||
OSMO_ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
static int tbf_ul_ass_fsm_timer_cb(struct osmo_fsm_inst *fi)
|
||||
{
|
||||
struct tbf_ul_ass_fsm_ctx *ctx = (struct tbf_ul_ass_fsm_ctx *)fi->priv;
|
||||
switch (fi->T) {
|
||||
case -2000:
|
||||
tbf_free(ctx->tbf);
|
||||
break;
|
||||
default:
|
||||
OSMO_ASSERT(0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct osmo_fsm_state tbf_ul_ass_fsm_states[] = {
|
||||
[TBF_UL_ASS_NONE] = {
|
||||
.in_event_mask =
|
||||
X(TBF_UL_ASS_EV_SCHED_ASS) |
|
||||
X(TBF_UL_ASS_EV_SCHED_ASS_REJ),
|
||||
.out_state_mask =
|
||||
X(TBF_UL_ASS_SEND_ASS) |
|
||||
X(TBF_UL_ASS_SEND_ASS_REJ),
|
||||
.name = "NONE",
|
||||
.action = st_none,
|
||||
.onenter = st_none_on_enter,
|
||||
},
|
||||
[TBF_UL_ASS_SEND_ASS] = {
|
||||
.in_event_mask = X(TBF_UL_ASS_EV_CREATE_RLCMAC_MSG),
|
||||
.out_state_mask = X(TBF_UL_ASS_WAIT_ACK),
|
||||
.name = "SEND_ASS",
|
||||
.action = st_send_ass,
|
||||
},
|
||||
[TBF_UL_ASS_SEND_ASS_REJ] = {
|
||||
.in_event_mask = X(TBF_UL_ASS_EV_CREATE_RLCMAC_MSG),
|
||||
.out_state_mask = X(TBF_UL_ASS_NONE),
|
||||
.name = "SEND_ASS_REJ",
|
||||
.action = st_send_ass_rej,
|
||||
},
|
||||
[TBF_UL_ASS_WAIT_ACK] = {
|
||||
.in_event_mask =
|
||||
X(TBF_UL_ASS_EV_RX_ASS_CTRL_ACK) |
|
||||
X(TBF_UL_ASS_EV_ASS_POLL_TIMEOUT),
|
||||
.out_state_mask =
|
||||
X(TBF_UL_ASS_NONE) |
|
||||
X(TBF_UL_ASS_SEND_ASS),
|
||||
.name = "WAIT_ACK",
|
||||
.action = st_wait_ack,
|
||||
},
|
||||
};
|
||||
|
||||
struct osmo_fsm tbf_ul_ass_fsm = {
|
||||
.name = "UL_ASS_TBF",
|
||||
.states = tbf_ul_ass_fsm_states,
|
||||
.num_states = ARRAY_SIZE(tbf_ul_ass_fsm_states),
|
||||
.timer_cb = tbf_ul_ass_fsm_timer_cb,
|
||||
.log_subsys = DTBF,
|
||||
.event_names = tbf_ul_ass_fsm_event_names,
|
||||
};
|
||||
|
||||
static __attribute__((constructor)) void tbf_ul_ass_fsm_init(void)
|
||||
{
|
||||
OSMO_ASSERT(osmo_fsm_register(&tbf_ul_ass_fsm) == 0);
|
||||
}
|
||||
|
||||
|
||||
struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts)
|
||||
{
|
||||
int rc;
|
||||
struct tbf_ul_ass_ev_create_rlcmac_msg_ctx data_ctx = {
|
||||
.fn = fn,
|
||||
.ts = ts,
|
||||
.msg = NULL,
|
||||
};
|
||||
|
||||
rc = osmo_fsm_inst_dispatch(tbf_ul_ass_fi(tbf), TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, &data_ctx);
|
||||
if (rc != 0 || !data_ctx.msg)
|
||||
return NULL;
|
||||
return data_ctx.msg;
|
||||
}
|
||||
|
||||
bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf)
|
||||
{
|
||||
struct osmo_fsm_inst *fi = tbf_ul_ass_fi(tbf);
|
||||
return fi->state == TBF_UL_ASS_SEND_ASS || fi->state == TBF_UL_ASS_SEND_ASS_REJ;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/* tbf_ul_ass_fsm.h
|
||||
*
|
||||
* Copyright (C) 2021 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
|
||||
* Author: Pau Espin Pedrol <pespin@sysmocom.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <osmocom/core/fsm.h>
|
||||
#include <osmocom/core/tdef.h>
|
||||
|
||||
#include <gprs_pcu.h>
|
||||
|
||||
struct gprs_rlcmac_tbf;
|
||||
|
||||
enum tbf_ul_ass_fsm_event {
|
||||
TBF_UL_ASS_EV_SCHED_ASS, /* Tx Uplink Assignment is pending */
|
||||
TBF_UL_ASS_EV_SCHED_ASS_REJ, /* Tx Uplink Assignment is pending */
|
||||
TBF_UL_ASS_EV_CREATE_RLCMAC_MSG, /* Scheduler wants to gen+Tx the Ass (rej): data=tbf_ul_ass_ev_create_rlcmac_msg_ctx */
|
||||
TBF_UL_ASS_EV_RX_ASS_CTRL_ACK, /* Received CTRL ACK answering poll set on Pkt Ul Ass */
|
||||
TBF_UL_ASS_EV_ASS_POLL_TIMEOUT, /* Pdch Ul Controller signals timeout for poll set on Pkt Ul Ass */
|
||||
};
|
||||
|
||||
enum tbf_ul_ass_fsm_states {
|
||||
TBF_UL_ASS_NONE = 0,
|
||||
TBF_UL_ASS_SEND_ASS, /* send uplink assignment on next RTS */
|
||||
TBF_UL_ASS_SEND_ASS_REJ, /* send assignment reject next RTS */
|
||||
TBF_UL_ASS_WAIT_ACK, /* wait for PACKET CONTROL ACK */
|
||||
};
|
||||
|
||||
struct tbf_ul_ass_fsm_ctx {
|
||||
struct osmo_fsm_inst *fi;
|
||||
struct gprs_rlcmac_tbf* tbf; /* back pointer */
|
||||
};
|
||||
|
||||
extern const struct osmo_tdef_state_timeout tbf_ul_ass_fsm_timeouts[32];
|
||||
/* Transition to a state, using the T timer defined in tbf_ul_ass_fsm_timeouts.
|
||||
* The actual timeout value is in turn obtained from conn->T_defs.
|
||||
* Assumes local variable fi exists. */
|
||||
#define tbf_ul_ass_fsm_state_chg(fi, NEXT_STATE) \
|
||||
osmo_tdef_fsm_inst_state_chg(fi, NEXT_STATE, \
|
||||
tbf_ul_ass_fsm_timeouts, \
|
||||
the_pcu->T_defs, \
|
||||
-1)
|
||||
|
||||
extern struct osmo_fsm tbf_ul_ass_fsm;
|
||||
|
||||
|
||||
/* passed as data in TBF_UL_ASS_EV_CREATE_RLCMAC_MSG */
|
||||
struct tbf_ul_ass_ev_create_rlcmac_msg_ctx {
|
||||
uint32_t fn; /* FN where the created DL ctrl block is to be sent */
|
||||
uint8_t ts; /* TS where the created DL ctrl block is to be sent */
|
||||
struct msgb *msg; /* to be filled by FSM during event processing */
|
||||
};
|
||||
|
||||
|
||||
struct msgb *tbf_ul_ass_create_rlcmac_msg(const struct gprs_rlcmac_tbf* tbf, uint32_t fn, uint8_t ts);
|
||||
bool tbf_ul_ass_rts(const struct gprs_rlcmac_tbf* tbf);
|
File diff suppressed because it is too large
Load Diff
|
@ -3295,7 +3295,8 @@ void test_packet_access_rej_epdan()
|
|||
|
||||
dl_tbf->update_ms(tlli, GPRS_RLCMAC_DL_TBF);
|
||||
|
||||
struct msgb *msg = dl_tbf->create_packet_access_reject();
|
||||
osmo_fsm_inst_dispatch(dl_tbf->ul_ass_fsm.fi, TBF_UL_ASS_EV_SCHED_ASS_REJ, NULL);
|
||||
struct msgb *msg = tbf_ul_ass_create_rlcmac_msg((const struct gprs_rlcmac_tbf*)dl_tbf, 0, 0);
|
||||
|
||||
fprintf(stderr, "packet reject: %s\n",
|
||||
osmo_hexdump(msg->data, 23));
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,19 +1,23 @@
|
|||
MS(TLLI=0xffffffff, IMSI=, TA=220, 1/0,) Allocating DL TBF
|
||||
TBF{NULL}: Allocated
|
||||
UL_ASS_TBF{NONE}: Allocated
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=NULL) Setting Control TS 2
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=DL STATE=NULL) Allocated: trx = 0, ul_slots = 04, dl_slots = 04
|
||||
MS(TLLI=0xffffffff, IMSI=, TA=220, 1/0,) Allocating UL TBF
|
||||
TBF{NULL}: Allocated
|
||||
UL_ASS_TBF{NONE}: Allocated
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL) Setting Control TS 4
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL) Allocated: trx = 0, ul_slots = 10, dl_slots = 00
|
||||
MS(TLLI=0xffffffff, IMSI=, TA=220, 1/1,) Allocating UL TBF
|
||||
TBF{NULL}: Allocated
|
||||
UL_ASS_TBF{NONE}: Allocated
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL EGPRS) Setting Control TS 1
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL EGPRS) Allocated: trx = 0, ul_slots = 02, dl_slots = 00
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL EGPRS) setting EGPRS UL window size to 64, base(64) slots(1) ws_pdch(0)
|
||||
############## test_egprs_ul_ack_nack
|
||||
MS(TLLI=0xffffffff, IMSI=, TA=220, 1/1,) Allocating UL TBF
|
||||
TBF{NULL}: Allocated
|
||||
UL_ASS_TBF{NONE}: Allocated
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL EGPRS) Setting Control TS 4
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL EGPRS) Allocated: trx = 0, ul_slots = 10, dl_slots = 00
|
||||
TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=NULL EGPRS) setting EGPRS UL window size to 64, base(64) slots(1) ws_pdch(0)
|
||||
|
|
Loading…
Reference in New Issue