pdch: refactor rcv_control_ack() with a switch statement
This clarifies the different paths and uniforms them. Makes code far easier to read and debug. New improved verification already found some misehavior in some tests. Change-Id: I7e4a88d6e004bbb7974595320ed73742162c7ad7
This commit is contained in:
parent
422636d752
commit
c8d2166b86
85
src/pdch.cpp
85
src/pdch.cpp
|
@ -344,37 +344,28 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
|
||||||
fn, get_value_string(pdch_ulc_tbf_poll_reason_names, reason));
|
fn, get_value_string(pdch_ulc_tbf_poll_reason_names, reason));
|
||||||
pdch_ulc_release_fn(ulc, fn);
|
pdch_ulc_release_fn(ulc, fn);
|
||||||
|
|
||||||
/* check if this control ack belongs to packet uplink ack */
|
switch (reason) {
|
||||||
ul_tbf = as_ul_tbf(tbf);
|
case PDCH_ULC_POLL_UL_ACK:
|
||||||
if (ul_tbf && reason == PDCH_ULC_POLL_UL_ACK && tbf_ul_ack_exp_ctrl_ack(ul_tbf, fn, ts_no)) {
|
ul_tbf = as_ul_tbf(tbf);
|
||||||
|
OSMO_ASSERT(ul_tbf);
|
||||||
|
if (!tbf_ul_ack_exp_ctrl_ack(ul_tbf, fn, ts_no)) {
|
||||||
|
LOGPTBF(tbf, LOGL_NOTICE, "FN=%d, TS=%d (curr FN %d): POLL_UL_ACK not expected!\n",
|
||||||
|
fn, ts_no, bts_current_frame_number(tbf->bts));
|
||||||
|
return;
|
||||||
|
}
|
||||||
osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_RX_CTRL_ACK, NULL);
|
osmo_fsm_inst_dispatch(ul_tbf->ul_ack_fsm.fi, TBF_UL_ACK_EV_RX_CTRL_ACK, NULL);
|
||||||
/* We can free since we only set polling on final UL ACK/NACK */
|
/* We can free since we only set polling on final UL ACK/NACK */
|
||||||
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] END\n");
|
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] END\n");
|
||||||
tbf_free(tbf);
|
tbf_free(tbf);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (tbf->dl_ass_state_is(TBF_DL_ASS_WAIT_ACK)) {
|
|
||||||
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] DOWNLINK ASSIGNED\n");
|
|
||||||
/* reset N3105 */
|
|
||||||
tbf->n_reset(N3105);
|
|
||||||
osmo_fsm_inst_dispatch(tbf->dl_ass_fsm.fi, TBF_DL_ASS_EV_RX_ASS_CTRL_ACK, NULL);
|
|
||||||
|
|
||||||
new_tbf = ms_dl_tbf(ms);
|
case PDCH_ULC_POLL_UL_ASS:
|
||||||
if (!new_tbf) {
|
if (!tbf->ul_ass_state_is(TBF_UL_ASS_WAIT_ACK)) {
|
||||||
LOGPDCH(this, DRLCMAC, LOGL_ERROR, "Got ACK, but DL "
|
LOGPTBF(tbf, LOGL_NOTICE, "FN=%d, TS=%d (curr FN %d): POLL_UL_ASS not expected! state is %s\n",
|
||||||
"TBF is gone TLLI=0x%08x\n", tlli);
|
fn, ts_no, bts_current_frame_number(tbf->bts),
|
||||||
|
osmo_fsm_inst_state_name(tbf_ul_ass_fi(tbf)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tbf->state_is(TBF_ST_WAIT_RELEASE) &&
|
|
||||||
tbf->direction == new_tbf->direction)
|
|
||||||
tbf_free(tbf);
|
|
||||||
|
|
||||||
osmo_fsm_inst_dispatch(new_tbf->state_fsm.fi, TBF_EV_ASSIGN_ACK_PACCH, NULL);
|
|
||||||
|
|
||||||
tbf_assign_control_ts(new_tbf);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (tbf->ul_ass_state_is(TBF_UL_ASS_WAIT_ACK)) {
|
|
||||||
LOGPTBF(tbf, LOGL_DEBUG, "[DOWNLINK] UPLINK ASSIGNED\n");
|
LOGPTBF(tbf, LOGL_DEBUG, "[DOWNLINK] UPLINK ASSIGNED\n");
|
||||||
/* reset N3105 */
|
/* reset N3105 */
|
||||||
tbf->n_reset(N3105);
|
tbf->n_reset(N3105);
|
||||||
|
@ -398,10 +389,41 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
|
||||||
* established */
|
* established */
|
||||||
if (ms_need_dl_tbf(new_tbf->ms()))
|
if (ms_need_dl_tbf(new_tbf->ms()))
|
||||||
new_tbf->establish_dl_tbf_on_pacch();
|
new_tbf->establish_dl_tbf_on_pacch();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
if (ms->nacc && nacc_fsm_exp_ctrl_ack(ms->nacc, fn, ts_no)) {
|
case PDCH_ULC_POLL_DL_ASS:
|
||||||
|
if (!tbf->dl_ass_state_is(TBF_DL_ASS_WAIT_ACK)) {
|
||||||
|
LOGPTBF(tbf, LOGL_NOTICE, "FN=%d, TS=%d (curr FN %d): POLL_DL_ASS not expected! state is %s\n",
|
||||||
|
fn, ts_no, bts_current_frame_number(tbf->bts),
|
||||||
|
osmo_fsm_inst_state_name(tbf_dl_ass_fi(tbf)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOGPTBF(tbf, LOGL_DEBUG, "[UPLINK] DOWNLINK ASSIGNED\n");
|
||||||
|
/* reset N3105 */
|
||||||
|
tbf->n_reset(N3105);
|
||||||
|
osmo_fsm_inst_dispatch(tbf->dl_ass_fsm.fi, TBF_DL_ASS_EV_RX_ASS_CTRL_ACK, NULL);
|
||||||
|
|
||||||
|
new_tbf = ms_dl_tbf(ms);
|
||||||
|
if (!new_tbf) {
|
||||||
|
LOGPDCH(this, DRLCMAC, LOGL_ERROR, "Got ACK, but DL "
|
||||||
|
"TBF is gone TLLI=0x%08x\n", tlli);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tbf->state_is(TBF_ST_WAIT_RELEASE) &&
|
||||||
|
tbf->direction == new_tbf->direction)
|
||||||
|
tbf_free(tbf);
|
||||||
|
|
||||||
|
osmo_fsm_inst_dispatch(new_tbf->state_fsm.fi, TBF_EV_ASSIGN_ACK_PACCH, NULL);
|
||||||
|
|
||||||
|
tbf_assign_control_ts(new_tbf);
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PDCH_ULC_POLL_CELL_CHG_CONTINUE:
|
||||||
|
if (!ms->nacc || !nacc_fsm_exp_ctrl_ack(ms->nacc, fn, ts_no)) {
|
||||||
|
LOGPTBF(tbf, LOGL_NOTICE, "FN=%d, TS=%d (curr FN %d): POLL_CELL_CHG_CONTINUE not expected!\n",
|
||||||
|
fn, ts_no, bts_current_frame_number(tbf->bts));
|
||||||
|
return;
|
||||||
|
}
|
||||||
osmo_fsm_inst_dispatch(ms->nacc->fi, NACC_EV_RX_CELL_CHG_CONTINUE_ACK, NULL);
|
osmo_fsm_inst_dispatch(ms->nacc->fi, NACC_EV_RX_CELL_CHG_CONTINUE_ACK, NULL);
|
||||||
/* Don't assume MS is no longer reachable (hence don't free) after this: TS 44.060
|
/* Don't assume MS is no longer reachable (hence don't free) after this: TS 44.060
|
||||||
* "When the mobile station receives the PACKET CELL CHANGE ORDER
|
* "When the mobile station receives the PACKET CELL CHANGE ORDER
|
||||||
|
@ -412,10 +434,15 @@ void gprs_rlcmac_pdch::rcv_control_ack(Packet_Control_Acknowledgement_t *packet,
|
||||||
* switch to a new cell."
|
* switch to a new cell."
|
||||||
*/
|
*/
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case PDCH_ULC_POLL_DL_ACK:
|
||||||
|
/* Handled in rcv_control_dl_ack_nack() upon receival of DL ACK/NACK as a response to our POLL. */
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
LOGPDCH(this, DRLCMAC, LOGL_ERROR, "FN=%" PRIu32 " "
|
||||||
|
"Error: received PACKET CONTROL ACK at no request (reason=%s)\n", fn,
|
||||||
|
get_value_string(pdch_ulc_tbf_poll_reason_names, reason));
|
||||||
}
|
}
|
||||||
LOGPDCH(this, DRLCMAC, LOGL_ERROR, "FN=%" PRIu32 " "
|
|
||||||
"Error: received PACKET CONTROL ACK at no request (reason=%s)\n", fn,
|
|
||||||
get_value_string(pdch_ulc_tbf_poll_reason_names, reason));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gprs_rlcmac_pdch::rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *ack_nack, uint32_t fn, struct pcu_l1_meas *meas)
|
void gprs_rlcmac_pdch::rcv_control_dl_ack_nack(Packet_Downlink_Ack_Nack_t *ack_nack, uint32_t fn, struct pcu_l1_meas *meas)
|
||||||
|
|
Loading…
Reference in New Issue