From 46bcb8d59da735257093d8daaec144b248bbdb01 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sat, 26 Oct 2013 21:04:28 +0200 Subject: [PATCH] tbf: Move gprs_rlcmac_send_uplink_ack into the tbf The method was called send but didn't send anything. Move it to the tbf --- src/gprs_rlcmac.h | 4 --- src/gprs_rlcmac_data.cpp | 56 --------------------------------------- src/gprs_rlcmac_sched.cpp | 2 +- src/tbf.cpp | 53 ++++++++++++++++++++++++++++++++++++ src/tbf.h | 1 + 5 files changed, 55 insertions(+), 61 deletions(-) diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h index 487f3751..737f7c62 100644 --- a/src/gprs_rlcmac.h +++ b/src/gprs_rlcmac.h @@ -107,10 +107,6 @@ int gprs_rlcmac_paging_request(uint8_t *ptmsi, uint16_t ptmsi_len, struct msgb *gprs_rlcmac_send_data_block_acknowledged( struct gprs_rlcmac_tbf *tbf, uint32_t fn, uint8_t ts); -struct msgb *gprs_rlcmac_send_uplink_ack( - struct gprs_rlcmac_tbf *tbf, - uint32_t fn); - int gprs_rlcmac_rcv_rts_block(struct gprs_rlcmac_bts *bts, uint8_t trx, uint8_t ts, uint16_t arfcn, uint32_t fn, uint8_t block_nr); diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp index ae28a0b7..797b5250 100644 --- a/src/gprs_rlcmac_data.cpp +++ b/src/gprs_rlcmac_data.cpp @@ -49,62 +49,6 @@ extern void *tall_pcu_ctx; * UL data block flow */ -struct msgb *gprs_rlcmac_send_uplink_ack( - struct gprs_rlcmac_tbf *tbf, - uint32_t fn) -{ - int final = (tbf->state_is(GPRS_RLCMAC_FINISHED)); - gprs_rlcmac_bts *bts = tbf->bts->bts_data(); - struct msgb *msg; - - if (final) { - if (tbf->poll_state != GPRS_RLCMAC_POLL_NONE) { - LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already " - "sheduled for TBF=%d, so we must wait for " - "final uplink ack...\n", tbf->tfi); - return NULL; - } - if (tbf->bts->sba()->find(tbf->trx_no, tbf->control_ts, (fn + 13) % 2715648)) { - LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already " - "scheduled for single block allocation...\n"); - return NULL; - } - } - - msg = msgb_alloc(23, "rlcmac_ul_ack"); - if (!msg) - return NULL; - bitvec *ack_vec = bitvec_alloc(23); - if (!ack_vec) { - msgb_free(msg); - return NULL; - } - bitvec_unhex(ack_vec, - "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); - RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t); - Encoding::write_packet_uplink_ack(bts, mac_control_block, tbf, final); - encode_gsm_rlcmac_downlink(ack_vec, mac_control_block); - bitvec_pack(ack_vec, msgb_put(msg, 23)); - bitvec_free(ack_vec); - talloc_free(mac_control_block); - - /* now we must set this flag, so we are allowed to assign downlink - * TBF on PACCH. it is only allowed when TLLI is aknowledged. */ - tbf->dir.ul.contention_resolution_done = 1; - - if (final) { - tbf->poll_state = GPRS_RLCMAC_POLL_SCHED; - tbf->poll_fn = (fn + 13) % 2715648; - /* waiting for final acknowledge */ - tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK; - tbf->dir.ul.final_ack_sent = 1; - } else - tbf->ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE; - debug_diagram(bts->bts, tbf->diag, "send UL-ACK"); - - return msg; -} - struct msgb *gprs_rlcmac_send_packet_uplink_assignment( struct gprs_rlcmac_tbf *tbf, uint32_t fn) { diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp index b1ac86e3..c44036c6 100644 --- a/src/gprs_rlcmac_sched.cpp +++ b/src/gprs_rlcmac_sched.cpp @@ -129,7 +129,7 @@ static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_bts *bts, /* schedule PACKET UPLINK ACK (3rd priority) */ if (!msg && ul_ack_tbf) { tbf = ul_ack_tbf; - msg = gprs_rlcmac_send_uplink_ack(tbf, fn); + msg = tbf->create_ul_ack(fn); } /* any message */ if (msg) { diff --git a/src/tbf.cpp b/src/tbf.cpp index 5bef5149..b810a2d2 100644 --- a/src/tbf.cpp +++ b/src/tbf.cpp @@ -973,6 +973,59 @@ struct msgb *gprs_rlcmac_tbf::create_dl_ass(uint32_t fn) return msg; } +struct msgb *gprs_rlcmac_tbf::create_ul_ack(uint32_t fn) +{ + int final = (state_is(GPRS_RLCMAC_FINISHED)); + struct msgb *msg; + + if (final) { + if (poll_state != GPRS_RLCMAC_POLL_NONE) { + LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already " + "sheduled for TBF=%d, so we must wait for " + "final uplink ack...\n", tfi); + return NULL; + } + if (bts->sba()->find(trx_no, control_ts, (fn + 13) % 2715648)) { + LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already " + "scheduled for single block allocation...\n"); + return NULL; + } + } + + msg = msgb_alloc(23, "rlcmac_ul_ack"); + if (!msg) + return NULL; + bitvec *ack_vec = bitvec_alloc(23); + if (!ack_vec) { + msgb_free(msg); + return NULL; + } + bitvec_unhex(ack_vec, + "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b"); + RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t); + Encoding::write_packet_uplink_ack(bts_data(), mac_control_block, this, final); + encode_gsm_rlcmac_downlink(ack_vec, mac_control_block); + bitvec_pack(ack_vec, msgb_put(msg, 23)); + bitvec_free(ack_vec); + talloc_free(mac_control_block); + + /* now we must set this flag, so we are allowed to assign downlink + * TBF on PACCH. it is only allowed when TLLI is aknowledged. */ + dir.ul.contention_resolution_done = 1; + + if (final) { + poll_state = GPRS_RLCMAC_POLL_SCHED; + poll_fn = (fn + 13) % 2715648; + /* waiting for final acknowledge */ + ul_ack_state = GPRS_RLCMAC_UL_ACK_WAIT_ACK; + dir.ul.final_ack_sent = 1; + } else + ul_ack_state = GPRS_RLCMAC_UL_ACK_NONE; + debug_diagram(bts->bts, diag, "send UL-ACK"); + + return msg; +} + void gprs_rlcmac_tbf::free_all(struct gprs_rlcmac_trx *trx) { for (uint8_t tfi = 0; tfi < 32; tfi++) { diff --git a/src/tbf.h b/src/tbf.h index 598bb257..b871946a 100644 --- a/src/tbf.h +++ b/src/tbf.h @@ -100,6 +100,7 @@ struct gprs_rlcmac_tbf { int assemble_forward_llc(uint8_t *data, uint8_t len); struct msgb *create_dl_ass(uint32_t fn); + struct msgb *create_ul_ack(uint32_t fn); int rlcmac_diag();