tbf: Make tfi private and update the code
All logging code that used tbf->tfi is now using tbf_name to
print the the TBF. External code is now using tfi() which is
inlined and should result in the same code being generated as
before (+debug code that can be stripped).
diff --git a/src/bts.cpp b/src/bts.cpp
index 261b5d2..285c184 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -424,13 +424,14 @@
tbf_new_state(tbf, GPRS_RLCMAC_FLOW);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_CCCH);
tbf_timer_start(tbf, 3169, m_bts.t3169, 0);
- LOGP(DRLCMAC, LOGL_DEBUG, "TBF: [UPLINK] START TFI: %u\n",
- tbf->tfi);
- LOGP(DRLCMAC, LOGL_DEBUG, "RX: [PCU <- BTS] TFI: %u RACH "
- "qbit-ta=%d ra=0x%02x, Fn=%d (%d,%d,%d)\n", tbf->tfi,
+ LOGP(DRLCMAC, LOGL_DEBUG, "%s [UPLINK] START\n",
+ tbf_name(tbf));
+ LOGP(DRLCMAC, LOGL_DEBUG, "%s RX: [PCU <- BTS] RACH "
+ "qbit-ta=%d ra=0x%02x, Fn=%d (%d,%d,%d)\n",
+ tbf_name(tbf),
qta, ra, Fn, (Fn / (26 * 51)) % 32, Fn % 51, Fn % 26);
- LOGP(DRLCMAC, LOGL_INFO, "TX: START TFI: %u Immediate "
- "Assignment Uplink (AGCH)\n", tbf->tfi);
+ LOGP(DRLCMAC, LOGL_INFO, "%s TX: START Immediate "
+ "Assignment Uplink (AGCH)\n", tbf_name(tbf));
}
bitvec *immediate_assignment = bitvec_alloc(22) /* without plen */;
bitvec_unhex(immediate_assignment,
@@ -443,7 +444,7 @@
else
plen = Encoding::write_immediate_assignment(&m_bts, immediate_assignment, 0, ra,
Fn, tbf->ta, tbf->trx->arfcn, tbf->first_ts, tbf->tsc,
- tbf->tfi, tbf->dir.ul.usf[tbf->first_ts], 0, 0, 0, 0,
+ tbf->tfi(), tbf->dir.ul.usf[tbf->first_ts], 0, 0, 0, 0,
m_bts.alpha, m_bts.gamma, -1);
pcu_l1if_tx_agch(immediate_assignment, plen);
bitvec_free(immediate_assignment);
@@ -499,7 +500,7 @@
* so the assignment will not conflict with possible RACH requests. */
plen = Encoding::write_immediate_assignment(&m_bts, immediate_assignment, 1, 125,
(tbf->pdch[tbf->first_ts]->last_rts_fn + 21216) % 2715648, tbf->ta,
- tbf->trx->arfcn, tbf->first_ts, tbf->tsc, tbf->tfi, 0, tbf->tlli(), poll,
+ tbf->trx->arfcn, tbf->first_ts, tbf->tsc, tbf->tfi(), 0, tbf->tlli(), poll,
tbf->poll_fn, 0, m_bts.alpha, m_bts.gamma, -1);
pcu_l1if_tx_pch(immediate_assignment, plen, imsi);
bitvec_free(immediate_assignment);
@@ -712,9 +713,9 @@
"UL DATA TFI=%d.\n", tbf->tlli(), rh->tfi);
if ((dl_tbf = bts()->tbf_by_tlli(tbf->tlli(), GPRS_RLCMAC_DL_TBF))) {
LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
- "TLLI=0x%08x while DL TFI=%d still exists. "
+ "TLLI=0x%08x while %s still exists. "
"Killing pending DL TBF\n", tbf->tlli(),
- dl_tbf->tfi);
+ tbf_name(dl_tbf));
tbf_free(dl_tbf);
}
/* tbf_by_tlli will not find your TLLI, because it is not
@@ -920,7 +921,7 @@
tbf->state_flags &=
~(1 << GPRS_RLCMAC_FLAG_TO_DL_ASS);
LOGP(DRLCMAC, LOGL_NOTICE, "Recovered downlink "
- "assignment for DL TFI=%d\n", tbf->tfi);
+ "assignment for %s\n", tbf_name(tbf));
}
tbf_assign_control_ts(tbf);
return;
@@ -969,7 +970,7 @@
fn, tfi, trx_no(), ts_no);
return;
}
- if (tbf->tfi != tfi) {
+ if (tbf->tfi() != tfi) {
LOGP(DRLCMAC, LOGL_NOTICE, "PACKET DOWNLINK ACK with "
"wrong TFI=%d, ignoring!\n", tfi);
return;
@@ -978,7 +979,7 @@
if ((tbf->state_flags & (1 << GPRS_RLCMAC_FLAG_TO_DL_ACK))) {
tbf->state_flags &= ~(1 << GPRS_RLCMAC_FLAG_TO_DL_ACK);
LOGP(DRLCMAC, LOGL_NOTICE, "Recovered downlink ack "
- "for DL TFI=%d\n", tbf->tfi);
+ "for %s\n", tbf_name(tbf));
}
/* reset N3105 */
tbf->n3105 = 0;
@@ -1020,18 +1021,18 @@
tbf = bts()->tbf_by_tlli(tlli, GPRS_RLCMAC_UL_TBF);
if (tbf) {
LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
- "TLLI=0x%08x while UL TFI=%d still "
+ "TLLI=0x%08x while %s still "
"exists. Killing pending DL TBF\n",
- tlli, tbf->tfi);
+ tlli, tbf_name(tbf));
tbf_free(tbf);
tbf = NULL;
}
if ((dl_tbf = bts()->tbf_by_tlli(tlli, GPRS_RLCMAC_DL_TBF))) {
LOGP(DRLCMACUL, LOGL_NOTICE, "Got RACH from "
- "TLLI=0x%08x while DL TFI=%d still exists. "
+ "TLLI=0x%08x while %s still exists. "
"Killing pending DL TBF\n", tlli,
- dl_tbf->tfi);
+ tbf_name(dl_tbf));
tbf_free(dl_tbf);
}
LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF "
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 9eda8ef..4604cb8 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -219,7 +219,7 @@
bitvec_write_field(dest, wp,0x0,1); // USF_GRANULARITY
bitvec_write_field(dest, wp,0x1,1); // switch TFI : on
- bitvec_write_field(dest, wp,tbf->tfi,5);// TFI
+ bitvec_write_field(dest, wp,tbf->tfi(),5);// TFI
bitvec_write_field(dest, wp,0x0,1); //
bitvec_write_field(dest, wp,0x0,1); // TBF Starting Time = off
@@ -292,7 +292,7 @@
block->u.Packet_Downlink_Assignment.Frequency_Parameters.u.ARFCN = tbf->trx->arfcn; // ARFCN
block->u.Packet_Downlink_Assignment.Exist_DOWNLINK_TFI_ASSIGNMENT = 0x1; // DOWNLINK TFI ASSIGNMENT = on
- block->u.Packet_Downlink_Assignment.DOWNLINK_TFI_ASSIGNMENT = tbf->tfi; // TFI
+ block->u.Packet_Downlink_Assignment.DOWNLINK_TFI_ASSIGNMENT = tbf->tfi(); // TFI
block->u.Packet_Downlink_Assignment.Exist_Power_Control_Parameters = 0x1; // Power Control Parameters = on
block->u.Packet_Downlink_Assignment.Power_Control_Parameters.ALPHA = alpha; // ALPHA
@@ -366,8 +366,8 @@
uint16_t mod_sns_half = (tbf->sns >> 1) - 1;
char bit;
- LOGP(DRLCMACUL, LOGL_DEBUG, "Sending Ack/Nack for TFI=%d "
- "(final=%d)\n", tbf->tfi, final);
+ LOGP(DRLCMACUL, LOGL_DEBUG, "Encoding Ack/Nack for %s "
+ "(final=%d)\n", tbf_name(tbf), final);
block->PAYLOAD_TYPE = 0x1; // RLC/MAC control block that does not include the optional octets of the RLC/MAC control header
block->RRBP = 0x0; // N+13
@@ -376,7 +376,7 @@
block->u.Packet_Uplink_Ack_Nack.MESSAGE_TYPE = 0x9; // Packet Downlink Assignment
block->u.Packet_Uplink_Ack_Nack.PAGE_MODE = 0x0; // Normal Paging
- block->u.Packet_Uplink_Ack_Nack.UPLINK_TFI = tbf->tfi; // Uplink TFI
+ block->u.Packet_Uplink_Ack_Nack.UPLINK_TFI = tbf->tfi(); // Uplink TFI
block->u.Packet_Uplink_Ack_Nack.UnionType = 0x0; // PU_AckNack_GPRS = on
block->u.Packet_Uplink_Ack_Nack.u.PU_AckNack_GPRS_Struct.CHANNEL_CODING_COMMAND = bts->initial_cs_ul - 1; // CS1
diff --git a/src/gprs_rlcmac_sched.cpp b/src/gprs_rlcmac_sched.cpp
index 504f6b7..02330cb 100644
--- a/src/gprs_rlcmac_sched.cpp
+++ b/src/gprs_rlcmac_sched.cpp
@@ -134,9 +134,8 @@
/* any message */
if (msg) {
LOGP(DRLCMACSCHED, LOGL_DEBUG, "Scheduling control "
- "message at RTS for %s TFI=%d (TRX=%d, TS=%d)\n",
- (tbf->direction == GPRS_RLCMAC_UL_TBF)
- ? "UL" : "DL", tbf->tfi, trx, ts);
+ "message at RTS for %s (TRX=%d, TS=%d)\n",
+ tbf_name(tbf), trx, ts);
return msg;
}
/* schedule PACKET PAGING REQUEST */
@@ -240,10 +239,9 @@
if (poll_tbf)
LOGP(DRLCMACSCHED, LOGL_DEBUG, "Received RTS for PDCH: TRX=%d "
"TS=%d FN=%d block_nr=%d scheduling free USF for "
- "polling at FN=%d of %s TFI=%d\n", trx, ts, fn,
+ "polling at FN=%d of %s\n", trx, ts, fn,
block_nr, poll_fn,
- (poll_tbf->direction == GPRS_RLCMAC_UL_TBF)
- ? "UL" : "DL", poll_tbf->tfi);
+ tbf_name(poll_tbf));
/* use free USF */
/* else. check for sba */
else if ((sba_fn = bts->bts->sba()->sched(trx, ts, fn, block_nr) != 0xffffffff))
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index c92192c..8d8e7f0 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -120,8 +120,8 @@
struct gprs_rlcmac_pdch *pdch,
struct gprs_rlcmac_tbf *tbf, int8_t usf)
{
- tbf->trx->ul_tbf[tbf->tfi] = tbf;
- pdch->ul_tbf[tbf->tfi] = tbf;
+ tbf->trx->ul_tbf[tbf->tfi()] = tbf;
+ pdch->ul_tbf[tbf->tfi()] = tbf;
tbf->pdch[pdch->ts_no] = pdch;
tbf->dir.ul.usf[pdch->ts_no] = usf;
}
@@ -130,8 +130,8 @@
struct gprs_rlcmac_pdch *pdch,
struct gprs_rlcmac_tbf *tbf)
{
- tbf->trx->dl_tbf[tbf->tfi] = tbf;
- pdch->dl_tbf[tbf->tfi] = tbf;
+ tbf->trx->dl_tbf[tbf->tfi()] = tbf;
+ pdch->dl_tbf[tbf->tfi()] = tbf;
tbf->pdch[pdch->ts_no] = pdch;
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 9c61ca1..0e2481b 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -279,19 +279,19 @@
int ts;
if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
- tbf->trx->ul_tbf[tbf->tfi] = NULL;
+ tbf->trx->ul_tbf[tbf->tfi()] = NULL;
for (ts = 0; ts < 8; ts++) {
pdch = tbf->pdch[ts];
if (pdch)
- pdch->ul_tbf[tbf->tfi] = NULL;
+ pdch->ul_tbf[tbf->tfi()] = NULL;
tbf->pdch[ts] = NULL;
}
} else {
- tbf->trx->dl_tbf[tbf->tfi] = NULL;
+ tbf->trx->dl_tbf[tbf->tfi()] = NULL;
for (ts = 0; ts < 8; ts++) {
pdch = tbf->pdch[ts];
if (pdch)
- pdch->dl_tbf[tbf->tfi] = NULL;
+ pdch->dl_tbf[tbf->tfi()] = NULL;
tbf->pdch[ts] = NULL;
}
}
@@ -524,7 +524,8 @@
if ((state_flags & (1 << GPRS_RLCMAC_FLAG_CCCH))
&& !(state_flags & (1 << GPRS_RLCMAC_FLAG_DL_ACK))) {
LOGP(DRLCMAC, LOGL_DEBUG, "Re-send dowlink assignment "
- "for TFI=%d on PCH (IMSI=%s)\n", tfi,
+ "for %s on PCH (IMSI=%s)\n",
+ tbf_name(this),
dir.dl.imsi);
/* send immediate assignment */
bts->snd_dl_ass(this, 0, dir.dl.imsi);
@@ -577,7 +578,7 @@
tbf->diag = diagram_num;
#endif
tbf->direction = dir;
- tbf->tfi = tfi;
+ tbf->m_tfi = tfi;
tbf->trx = &bts->trx[trx];
tbf->ms_class = ms_class;
tbf->ws = 64;
@@ -926,8 +927,8 @@
uint16_t space, chunk;
int first_fin_ack = 0;
- LOGP(DRLCMACDL, LOGL_DEBUG, "DL DATA TFI=%d downlink (V(A)==%d .. "
- "V(S)==%d)\n", tfi, dir.dl.v_a, dir.dl.v_s);
+ LOGP(DRLCMACDL, LOGL_DEBUG, "%s downlink (V(A)==%d .. "
+ "V(S)==%d)\n", tbf_name(this), dir.dl.v_a, dir.dl.v_s);
do_resend:
/* check if there is a block with negative acknowledgement */
@@ -1015,7 +1016,7 @@
rh->rrbp = rh->s_p = 0; /* Polling, set later, if required */
rh->usf = 7; /* will be set at scheduler */
rh->pr = 0; /* FIXME: power reduction */
- rh->tfi = tfi; /* TFI */
+ rh->tfi = m_tfi; /* TFI */
rh->fbi = 0; /* Final Block Indicator, set late, if true */
rh->bsn = dir.dl.v_s; /* Block Sequence Number */
rh->e = 0; /* Extension bit, maybe set later */
@@ -1047,8 +1048,8 @@
"this is a final block, we don't add length "
"header, and we are done\n", chunk, space);
LOGP(DRLCMACDL, LOGL_INFO, "Complete DL frame for "
- "TFI=%d that fits precisely in last block: "
- "len=%d\n", tfi, llc_length);
+ "%s that fits precisely in last block: "
+ "len=%d\n", tbf_name(this), llc_length);
gprs_rlcmac_dl_bw(this, llc_length);
/* block is filled, so there is no extension */
*e_pointer |= 0x01;
@@ -1107,8 +1108,8 @@
memcpy(data, llc_frame + llc_index, chunk);
data += chunk;
space -= chunk;
- LOGP(DRLCMACDL, LOGL_INFO, "Complete DL frame for TFI=%d: "
- "len=%d\n", tfi, llc_length);
+ LOGP(DRLCMACDL, LOGL_INFO, "Complete DL frame for %s"
+ "len=%d\n", tbf_name(this), llc_length);
gprs_rlcmac_dl_bw(this, llc_length);
/* reset LLC frame */
llc_index = llc_length = 0;
@@ -1116,7 +1117,7 @@
msg = llc_dequeue(gprs_bssgp_pcu_current_bctx());
if (msg) {
LOGP(DRLCMACDL, LOGL_INFO, "- Dequeue next LLC for "
- "TFI=%d (len=%d)\n", tfi, msg->len);
+ "%s (len=%d)\n", tbf_name(this), msg->len);
update_llc_frame(msg);
msgb_free(msg);
}
@@ -1174,8 +1175,8 @@
/* scheduling not possible, because: */
if (poll_state != GPRS_RLCMAC_POLL_NONE)
LOGP(DRLCMAC, LOGL_DEBUG, "Polling is already "
- "sheduled for TFI=%d, so we must wait for "
- "requesting downlink ack\n", tfi);
+ "sheduled for %s, so we must wait for "
+ "requesting downlink ack\n", tbf_name(this));
else if (control_ts != ts)
LOGP(DRLCMAC, LOGL_DEBUG, "Polling cannot be "
"sheduled in this TS %d, waiting for "
@@ -1242,8 +1243,8 @@
if (poll_ass_dl) {
if (poll_state != GPRS_RLCMAC_POLL_NONE) {
LOGP(DRLCMAC, LOGL_DEBUG, "Polling is already sheduled "
- "for TFI=%d, so we must wait for downlink "
- "assignment...\n", tfi);
+ "for %s, so we must wait for downlink "
+ "assignment...\n", tbf_name(this));
return NULL;
}
if (bts->sba()->find(trx->trx_no, control_ts, (fn + 13) % 2715648)) {
@@ -1269,8 +1270,8 @@
new_tbf = this;
if (!new_tbf) {
LOGP(DRLCMACDL, LOGL_ERROR, "We have a schedule for downlink "
- "assignment at uplink TFI=%d, but there is no downlink "
- "TBF\n", tfi);
+ "assignment at uplink %s, but there is no downlink "
+ "TBF\n", tbf_name(this));
dl_ass_state = GPRS_RLCMAC_DL_ASS_NONE;
return NULL;
}
@@ -1287,7 +1288,7 @@
"2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
LOGP(DRLCMAC, LOGL_INFO, "%s start Packet Downlink Assignment (PACCH)\n", tbf_name(new_tbf));
RlcMacDownlink_t * mac_control_block = (RlcMacDownlink_t *)talloc_zero(tall_pcu_ctx, RlcMacDownlink_t);
- Encoding::write_packet_downlink_assignment(mac_control_block, tfi,
+ Encoding::write_packet_downlink_assignment(mac_control_block, m_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");
@@ -1323,8 +1324,8 @@
#if POLLING_ASSIGNMENT_UL == 1
if (poll_state != GPRS_RLCMAC_POLL_NONE) {
LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already "
- "sheduled for TFI=%d, so we must wait for uplink "
- "assignment...\n", tfi);
+ "sheduled for %s, so we must wait for uplink "
+ "assignment...\n", tbf_name(this));
return NULL;
}
if (bts->sba()->find(trx->trx_no, control_ts, (fn + 13) % 2715648)) {
@@ -1343,8 +1344,8 @@
if (!new_tbf) {
LOGP(DRLCMACUL, LOGL_ERROR, "We have a schedule for uplink "
- "assignment at downlink TFI=%d, but there is no uplink "
- "TBF\n", tfi);
+ "assignment at downlink %s, but there is no uplink "
+ "TBF\n", tbf_name(this));
ul_ass_state = GPRS_RLCMAC_UL_ASS_NONE;
return NULL;
}
@@ -1360,7 +1361,7 @@
}
bitvec_unhex(ass_vec,
"2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b");
- Encoding::write_packet_uplink_assignment(bts_data(), ass_vec, tfi,
+ Encoding::write_packet_uplink_assignment(bts_data(), ass_vec, m_tfi,
(direction == GPRS_RLCMAC_DL_TBF), m_tlli,
m_tlli_valid, new_tbf, POLLING_ASSIGNMENT_UL, bts_data()->alpha,
bts_data()->gamma, -1);
@@ -1395,8 +1396,8 @@
if (final) {
if (poll_state != GPRS_RLCMAC_POLL_NONE) {
LOGP(DRLCMACUL, LOGL_DEBUG, "Polling is already "
- "sheduled for TFI=%d, so we must wait for "
- "final uplink ack...\n", tfi);
+ "sheduled for %s, so we must wait for "
+ "final uplink ack...\n", tbf_name(this));
return NULL;
}
if (bts->sba()->find(trx->trx_no, control_ts, (fn + 13) % 2715648)) {
@@ -1452,7 +1453,7 @@
struct msgb *msg;
uint16_t lost = 0, received = 0;
- LOGP(DRLCMACDL, LOGL_DEBUG, "TFI=%d downlink acknowledge\n", tfi);
+ LOGP(DRLCMACDL, LOGL_DEBUG, "%s downlink acknowledge\n", tbf_name(this));
if (!final) {
/* show received array in debug (bit 64..1) */
@@ -1476,7 +1477,7 @@
* FIXME: we should implement polling for
* control ack!*/
LOGP(DRLCMACDL, LOGL_NOTICE, "- ack range is out of "
- "V(A)..V(S) range (DL TFI=%d) Free TBF!\n", tfi);
+ "V(A)..V(S) range %s Free TBF!\n", tbf_name(this));
return 1; /* indicate to free TBF */
}
/* SSN - 1 is in range V(A)..V(S)-1 */
@@ -1627,7 +1628,7 @@
{
static char buf[40];
snprintf(buf, sizeof(buf), "TBF(TFI=%d TLLI=0x%08x DIR=%s)",
- tbf->tfi, tbf->m_tlli,
+ tbf->m_tfi, tbf->m_tlli,
tbf->direction == GPRS_RLCMAC_UL_TBF ? "UL" : "DL");
buf[sizeof(buf) - 1] = '\0';
return buf;
diff --git a/src/tbf.h b/src/tbf.h
index 5d2a10b..e8b66c9 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -120,10 +120,11 @@
bool is_tlli_valid() const;
void tlli_mark_valid();
+ uint8_t tfi() const;
+
struct llist_head list;
uint32_t state_flags;
enum gprs_rlcmac_tbf_direction direction;
- uint8_t tfi;
struct gprs_rlcmac_trx *trx;
uint8_t tsc;
uint8_t first_ts; /* first TS used by TBF */
@@ -224,6 +225,7 @@
*/
uint32_t m_tlli;
uint8_t m_tlli_valid;
+ uint8_t m_tfi;
protected:
gprs_rlcmac_bts *bts_data() const;
@@ -280,4 +282,9 @@
return m_tlli_valid;
}
+inline uint8_t gprs_rlcmac_tbf::tfi() const
+{
+ return m_tfi;
+}
+
const char *tbf_name(gprs_rlcmac_tbf *tbf);