aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-26 20:45:35 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-30 21:24:11 +0100
commit2db7e7e7dbb1f48bc2dbfe398449d3b0f4c367d1 (patch)
tree18cfc350fa47944d6f14b7830c8333d55a86cbfe /src
parent24c1a5ba29998d4293f7337a195a664d1845f673 (diff)
tbf: Move gprs_rlcmac_send_packet_downlink_assignment into the tbf
This method was called _send_packet_ but actually didn't do any sending at all. It just formated the right assignment. I replaced tbf-> with nothing.
Diffstat (limited to 'src')
-rw-r--r--src/gprs_rlcmac.h3
-rw-r--r--src/gprs_rlcmac_data.cpp92
-rw-r--r--src/gprs_rlcmac_sched.cpp2
-rw-r--r--src/tbf.cpp94
-rw-r--r--src/tbf.h2
5 files changed, 97 insertions, 96 deletions
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 80673792..94b2a4b1 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -99,9 +99,6 @@ int gprs_rlcmac_rcv_rach(struct gprs_rlcmac_bts *bts, uint8_t ra, uint32_t Fn, i
struct msgb *gprs_rlcmac_send_packet_uplink_assignment(
struct gprs_rlcmac_tbf *tbf, uint32_t fn);
-struct msgb *gprs_rlcmac_send_packet_downlink_assignment(
- struct gprs_rlcmac_tbf *tbf, uint32_t fn);
-
int gprs_rlcmac_downlink_ack(
struct gprs_rlcmac_tbf *tbf, uint8_t final,
uint8_t ssn, uint8_t *rbb);
diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp
index 004ac93f..3a0680ac 100644
--- a/src/gprs_rlcmac_data.cpp
+++ b/src/gprs_rlcmac_data.cpp
@@ -42,7 +42,6 @@ extern void *tall_pcu_ctx;
#define POLL_ACK_AFTER_FRAMES 20
/* If acknowledgement to uplink/downlink assignmentshould be polled */
-#define POLLING_ASSIGNMENT_DL 1
#define POLLING_ASSIGNMENT_UL 1
@@ -727,94 +726,3 @@ int gprs_rlcmac_downlink_ack(
}
-struct msgb *gprs_rlcmac_send_packet_downlink_assignment(
- struct gprs_rlcmac_tbf *tbf, uint32_t fn)
-{
- struct msgb *msg;
- struct gprs_rlcmac_tbf *new_tbf;
- gprs_rlcmac_bts *bts = tbf->bts->bts_data();
- int poll_ass_dl = POLLING_ASSIGNMENT_DL;
-
- if (poll_ass_dl && tbf->direction == GPRS_RLCMAC_DL_TBF
- && tbf->control_ts != tbf->first_common_ts) {
- LOGP(DRLCMAC, LOGL_NOTICE, "Cannot poll for downlink "
- "assigment, because MS cannot reply. (control TS=%d, "
- "first common TS=%d)\n", tbf->control_ts,
- tbf->first_common_ts);
- poll_ass_dl = 0;
- }
- if (poll_ass_dl) {
- if (tbf->poll_state != GPRS_RLCMAC_POLL_NONE) {
- LOGP(DRLCMAC, LOGL_DEBUG, "Polling is already sheduled "
- "for TBF=%d, so we must wait for downlink "
- "assignment...\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;
- }
- }
-
- /* on uplink TBF we get the downlink TBF to be assigned. */
- if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
- /* be sure to check first, if contention resolution is done,
- * otherwise we cannot send the assignment yet */
- if (!tbf->dir.ul.contention_resolution_done) {
- LOGP(DRLCMAC, LOGL_DEBUG, "Cannot assign DL TBF now, "
- "because contention resolution is not "
- "finished.\n");
- return NULL;
- }
- new_tbf = tbf->bts->tbf_by_tlli(tbf->tlli, GPRS_RLCMAC_DL_TBF);
- } else
- new_tbf = tbf;
- if (!new_tbf) {
- LOGP(DRLCMACDL, LOGL_ERROR, "We have a schedule for downlink "
- "assignment at uplink TBF=%d, but there is no downlink "
- "TBF\n", tbf->tfi);
- tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
- return NULL;
- }
-
- msg = msgb_alloc(23, "rlcmac_dl_ass");
- if (!msg)
- return NULL;
- bitvec *ass_vec = bitvec_alloc(23);
- if (!ass_vec) {
- msgb_free(msg);
- return NULL;
- }
- bitvec_unhex(ass_vec,
- "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
- LOGP(DRLCMAC, LOGL_INFO, "TBF: START TFI: %u TLLI: 0x%08x Packet Downlink Assignment (PACCH)\n", new_tbf->tfi, new_tbf->tlli);
- RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t);
- Encoding::write_packet_downlink_assignment(mac_control_block, tbf->tfi,
- (tbf->direction == GPRS_RLCMAC_DL_TBF), new_tbf,
- poll_ass_dl, bts->alpha, bts->gamma, -1, 0);
- LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Downlink Assignment +++++++++++++++++++++++++\n");
- encode_gsm_rlcmac_downlink(ass_vec, mac_control_block);
- LOGPC(DCSN1, LOGL_NOTICE, "\n");
- LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- TX : Packet Downlink Assignment -------------------------\n");
- bitvec_pack(ass_vec, msgb_put(msg, 23));
- bitvec_free(ass_vec);
- talloc_free(mac_control_block);
-
- if (poll_ass_dl) {
- tbf->poll_state = GPRS_RLCMAC_POLL_SCHED;
- tbf->poll_fn = (fn + 13) % 2715648;
- tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
- } else {
- tbf->dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
- tbf_new_state(new_tbf, GPRS_RLCMAC_FLOW);
- tbf_assign_control_ts(new_tbf);
- /* stop pending assignment timer */
- new_tbf->stop_timer();
-
- }
- debug_diagram(bts->bts, tbf->diag, "send DL-ASS");
-
- return msg;
-}
-
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index e2e38046..b1ac86e3 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -124,7 +124,7 @@ static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_bts *bts,
/* schedule PACKET DOWNLINK ASSIGNMENT (2nd priotiry) */
if (!msg && dl_ass_tbf) {
tbf = dl_ass_tbf;
- msg = gprs_rlcmac_send_packet_downlink_assignment(tbf, fn);
+ msg = tbf->create_dl_ass(fn);
}
/* schedule PACKET UPLINK ACK (3rd priority) */
if (!msg && ul_ack_tbf) {
diff --git a/src/tbf.cpp b/src/tbf.cpp
index f8e1dcb4..5bef5149 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -22,6 +22,7 @@
#include <bts.h>
#include <tbf.h>
#include <rlc.h>
+#include <encoding.h>
#include <gprs_rlcmac.h>
#include <gprs_debug.h>
@@ -33,6 +34,9 @@ extern "C" {
#include <errno.h>
#include <string.h>
+/* If acknowledgement to downlink assignment should be polled */
+#define POLLING_ASSIGNMENT_DL 1
+
extern "C" {
int bssgp_tx_llc_discarded(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
uint8_t num_frames, uint32_t num_octets);
@@ -879,6 +883,96 @@ int gprs_rlcmac_tbf::assemble_forward_llc(uint8_t *data, uint8_t len)
return 0;
}
+struct msgb *gprs_rlcmac_tbf::create_dl_ass(uint32_t fn)
+{
+ struct msgb *msg;
+ struct gprs_rlcmac_tbf *new_tbf;
+ int poll_ass_dl = POLLING_ASSIGNMENT_DL;
+
+ if (poll_ass_dl && direction == GPRS_RLCMAC_DL_TBF
+ && control_ts != first_common_ts) {
+ LOGP(DRLCMAC, LOGL_NOTICE, "Cannot poll for downlink "
+ "assigment, because MS cannot reply. (control TS=%d, "
+ "first common TS=%d)\n", control_ts,
+ first_common_ts);
+ poll_ass_dl = 0;
+ }
+ if (poll_ass_dl) {
+ if (poll_state != GPRS_RLCMAC_POLL_NONE) {
+ LOGP(DRLCMAC, LOGL_DEBUG, "Polling is already sheduled "
+ "for TBF=%d, so we must wait for downlink "
+ "assignment...\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;
+ }
+ }
+
+ /* on uplink TBF we get the downlink TBF to be assigned. */
+ if (direction == GPRS_RLCMAC_UL_TBF) {
+ /* be sure to check first, if contention resolution is done,
+ * otherwise we cannot send the assignment yet */
+ if (!dir.ul.contention_resolution_done) {
+ LOGP(DRLCMAC, LOGL_DEBUG, "Cannot assign DL TBF now, "
+ "because contention resolution is not "
+ "finished.\n");
+ return NULL;
+ }
+ #warning "THIS should probably go over the IMSI too"
+ new_tbf = bts->tbf_by_tlli(tlli, GPRS_RLCMAC_DL_TBF);
+ } else
+ new_tbf = this;
+ if (!new_tbf) {
+ LOGP(DRLCMACDL, LOGL_ERROR, "We have a schedule for downlink "
+ "assignment at uplink TBF=%d, but there is no downlink "
+ "TBF\n", tfi);
+ dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
+ return NULL;
+ }
+
+ msg = msgb_alloc(23, "rlcmac_dl_ass");
+ if (!msg)
+ return NULL;
+ bitvec *ass_vec = bitvec_alloc(23);
+ if (!ass_vec) {
+ msgb_free(msg);
+ return NULL;
+ }
+ bitvec_unhex(ass_vec,
+ "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
+ LOGP(DRLCMAC, LOGL_INFO, "TBF: START TFI: %u TLLI: 0x%08x Packet Downlink Assignment (PACCH)\n", new_tbf->tfi, new_tbf->tlli);
+ RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t);
+ Encoding::write_packet_downlink_assignment(mac_control_block, tfi,
+ (direction == GPRS_RLCMAC_DL_TBF), new_tbf,
+ poll_ass_dl, bts_data()->alpha, bts_data()->gamma, -1, 0);
+ LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Downlink Assignment +++++++++++++++++++++++++\n");
+ encode_gsm_rlcmac_downlink(ass_vec, mac_control_block);
+ LOGPC(DCSN1, LOGL_NOTICE, "\n");
+ LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- TX : Packet Downlink Assignment -------------------------\n");
+ bitvec_pack(ass_vec, msgb_put(msg, 23));
+ bitvec_free(ass_vec);
+ talloc_free(mac_control_block);
+
+ if (poll_ass_dl) {
+ poll_state = GPRS_RLCMAC_POLL_SCHED;
+ poll_fn = (fn + 13) % 2715648;
+ dl_ass_state = GPRS_RLCMAC_DL_ASS_WAIT_ACK;
+ } else {
+ dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
+ tbf_new_state(new_tbf, GPRS_RLCMAC_FLOW);
+ tbf_assign_control_ts(new_tbf);
+ /* stop pending assignment timer */
+ new_tbf->stop_timer();
+
+ }
+ debug_diagram(bts, diag, "send DL-ASS");
+
+ 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 4afc6498..598bb257 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -99,6 +99,8 @@ struct gprs_rlcmac_tbf {
/* TODO: extract LLC class? */
int assemble_forward_llc(uint8_t *data, uint8_t len);
+ struct msgb *create_dl_ass(uint32_t fn);
+
int rlcmac_diag();
int update();