aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gprs_rlcmac.h3
-rw-r--r--src/gprs_rlcmac_data.cpp75
-rw-r--r--src/gprs_rlcmac_sched.cpp2
-rw-r--r--src/tbf.cpp73
-rw-r--r--src/tbf.h1
5 files changed, 75 insertions, 79 deletions
diff --git a/src/gprs_rlcmac.h b/src/gprs_rlcmac.h
index 737f7c6..0e09f3f 100644
--- a/src/gprs_rlcmac.h
+++ b/src/gprs_rlcmac.h
@@ -94,9 +94,6 @@ enum gprs_rlcmac_block_type {
int gprs_rlcmac_tx_ul_ud(gprs_rlcmac_tbf *tbf);
-struct msgb *gprs_rlcmac_send_packet_uplink_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 797b525..aa5bfda 100644
--- a/src/gprs_rlcmac_data.cpp
+++ b/src/gprs_rlcmac_data.cpp
@@ -41,87 +41,12 @@ extern void *tall_pcu_ctx;
/* After sending these frames, we poll for ack/nack. */
#define POLL_ACK_AFTER_FRAMES 20
-/* If acknowledgement to uplink/downlink assignmentshould be polled */
-#define POLLING_ASSIGNMENT_UL 1
/*
* UL data block flow
*/
-struct msgb *gprs_rlcmac_send_packet_uplink_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();
-
-#if POLLING_ASSIGNMENT_UL == 1
- if (tbf->poll_state != GPRS_RLCMAC_POLL_NONE) {
- LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already "
- "sheduled for TBF=%d, so we must wait for uplink "
- "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;
- }
-#endif
-
- /* on down TBF we get the uplink TBF to be assigned. */
- if (tbf->direction == GPRS_RLCMAC_DL_TBF)
- new_tbf = tbf->bts->tbf_by_tlli(tbf->tlli, GPRS_RLCMAC_UL_TBF);
- else
- new_tbf = tbf;
-
- if (!new_tbf) {
- LOGP(DRLCMACUL, LOGL_ERROR, "We have a schedule for uplink "
- "assignment at downlink TBF=%d, but there is no uplink "
- "TBF\n", tbf->tfi);
- tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
- return NULL;
- }
-
- msg = msgb_alloc(23, "rlcmac_ul_ass");
- if (!msg)
- return NULL;
- LOGP(DRLCMAC, LOGL_INFO, "TBF: START TFI: %u TLLI: 0x%08x Packet Uplink Assignment (PACCH)\n", new_tbf->tfi, new_tbf->tlli);
- bitvec *ass_vec = bitvec_alloc(23);
- if (!ass_vec) {
- msgb_free(msg);
- return NULL;
- }
- bitvec_unhex(ass_vec,
- "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
- Encoding::write_packet_uplink_assignment(bts, ass_vec, tbf->tfi,
- (tbf->direction == GPRS_RLCMAC_DL_TBF), tbf->tlli,
- tbf->tlli_valid, new_tbf, POLLING_ASSIGNMENT_UL, bts->alpha,
- bts->gamma, -1);
- bitvec_pack(ass_vec, msgb_put(msg, 23));
- RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t);
- LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Uplink Assignment +++++++++++++++++++++++++\n");
- decode_gsm_rlcmac_downlink(ass_vec, mac_control_block);
- LOGPC(DCSN1, LOGL_NOTICE, "\n");
- LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- TX : Packet Uplink Assignment -------------------------\n");
- bitvec_free(ass_vec);
- talloc_free(mac_control_block);
-
-#if POLLING_ASSIGNMENT_UL == 1
- tbf->poll_state = GPRS_RLCMAC_POLL_SCHED;
- tbf->poll_fn = (fn + 13) % 2715648;
- tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
-#else
- tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
- tbf_new_state(new_tbf, GPRS_RLCMAC_FLOW);
- tbf_assign_control_ts(new_tbf);
-#endif
- debug_diagram(bts->bts, tbf->diag, "send UL-ASS");
-
- return msg;
-}
-
/* send DL data block
*
* The messages are fragmented and forwarded as data blocks.
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index c44036c..11a9630 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -119,7 +119,7 @@ static struct msgb *sched_select_ctrl_msg(struct gprs_rlcmac_bts *bts,
/* schedule PACKET UPLINK ASSIGNMENT (1st priority) */
if (ul_ass_tbf) {
tbf = ul_ass_tbf;
- msg = gprs_rlcmac_send_packet_uplink_assignment(tbf, fn);
+ msg = tbf->create_ul_ass(fn);
}
/* schedule PACKET DOWNLINK ASSIGNMENT (2nd priotiry) */
if (!msg && dl_ass_tbf) {
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 53117bf..c640c8d 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -36,6 +36,7 @@ extern "C" {
/* If acknowledgement to downlink assignment should be polled */
#define POLLING_ASSIGNMENT_DL 1
+#define POLLING_ASSIGNMENT_UL 1
extern "C" {
int bssgp_tx_llc_discarded(struct bssgp_bvc_ctx *bctx, uint32_t tlli,
@@ -973,6 +974,78 @@ struct msgb *gprs_rlcmac_tbf::create_dl_ass(uint32_t fn)
return msg;
}
+struct msgb *gprs_rlcmac_tbf::create_ul_ass(uint32_t fn)
+{
+ struct msgb *msg;
+ struct gprs_rlcmac_tbf *new_tbf;
+
+#if POLLING_ASSIGNMENT_UL == 1
+ if (poll_state != GPRS_RLCMAC_POLL_NONE) {
+ LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already "
+ "sheduled for TBF=%d, so we must wait for uplink "
+ "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;
+ }
+#endif
+
+ /* on down TBF we get the uplink TBF to be assigned. */
+#warning "Probably want to find by IMSI too"
+ if (direction == GPRS_RLCMAC_DL_TBF)
+ new_tbf = bts->tbf_by_tlli(tlli, GPRS_RLCMAC_UL_TBF);
+ else
+ new_tbf = this;
+
+ if (!new_tbf) {
+ LOGP(DRLCMACUL, LOGL_ERROR, "We have a schedule for uplink "
+ "assignment at downlink TBF=%d, but there is no uplink "
+ "TBF\n", tfi);
+ ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
+ return NULL;
+ }
+
+ msg = msgb_alloc(23, "rlcmac_ul_ass");
+ if (!msg)
+ return NULL;
+ LOGP(DRLCMAC, LOGL_INFO, "TBF: START TFI: %u TLLI: 0x%08x Packet Uplink Assignment (PACCH)\n", new_tbf->tfi, new_tbf->tlli);
+ bitvec *ass_vec = bitvec_alloc(23);
+ if (!ass_vec) {
+ msgb_free(msg);
+ return NULL;
+ }
+ bitvec_unhex(ass_vec,
+ "2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
+ Encoding::write_packet_uplink_assignment(bts_data(), ass_vec, tfi,
+ (direction == GPRS_RLCMAC_DL_TBF), tlli,
+ tlli_valid, new_tbf, POLLING_ASSIGNMENT_UL, bts_data()->alpha,
+ bts_data()->gamma, -1);
+ bitvec_pack(ass_vec, msgb_put(msg, 23));
+ RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t);
+ LOGP(DRLCMAC, LOGL_DEBUG, "+++++++++++++++++++++++++ TX : Packet Uplink Assignment +++++++++++++++++++++++++\n");
+ decode_gsm_rlcmac_downlink(ass_vec, mac_control_block);
+ LOGPC(DCSN1, LOGL_NOTICE, "\n");
+ LOGP(DRLCMAC, LOGL_DEBUG, "------------------------- TX : Packet Uplink Assignment -------------------------\n");
+ bitvec_free(ass_vec);
+ talloc_free(mac_control_block);
+
+#if POLLING_ASSIGNMENT_UL == 1
+ poll_state = GPRS_RLCMAC_POLL_SCHED;
+ poll_fn = (fn + 13) % 2715648;
+ ul_ass_state = GPRS_RLCMAC_UL_ASS_WAIT_ACK;
+#else
+ ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
+ tbf_new_state(new_tbf, GPRS_RLCMAC_FLOW);
+ tbf_assign_control_ts(new_tbf);
+#endif
+ debug_diagram(bts, diag, "send UL-ASS");
+
+ return msg;
+}
+
struct msgb *gprs_rlcmac_tbf::create_ul_ack(uint32_t fn)
{
int final = (state_is(GPRS_RLCMAC_FINISHED));
diff --git a/src/tbf.h b/src/tbf.h
index b871946..57fe3b9 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_ass(uint32_t fn);
struct msgb *create_ul_ack(uint32_t fn);
int rlcmac_diag();