encoding: pass pdch slot directly to encoding functions
In order to be able to encode frequency hopping parameters, let's
pass a const pointer to 'gprs_rlcmac_pdch' (PDCH slot) directly,
instead of passing all related parameters separately.
Change-Id: I6bccad508f0fdccc4a763211008dd847a9111a8d
Related: SYS#4868, OS#4547
diff --git a/src/bts.cpp b/src/bts.cpp
index 76ca1b0..5cd2b1d 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -899,8 +899,9 @@
trx_no, m_bts.trx[trx_no].arfcn & ~ARFCN_FLAG_MASK,
ts_no, ta, tsc, tbf ? tbf->tfi() : -1, usf);
plen = Encoding::write_immediate_assignment(
- tbf, bv, false, rip->ra, Fn, ta, m_bts.trx[trx_no].arfcn,
- ts_no, tsc, usf, false, sb_fn, m_bts.alpha, m_bts.gamma, -1,
+ &m_bts.trx[trx_no].pdch[ts_no], tbf, bv,
+ false, rip->ra, Fn, ta, usf, false, sb_fn,
+ m_bts.alpha, m_bts.gamma, -1,
rip->burst_type);
do_rate_ctr_inc(CTR_IMMEDIATE_ASSIGN_UL_TBF);
}
@@ -967,8 +968,9 @@
void BTS::snd_dl_ass(gprs_rlcmac_tbf *tbf, bool poll, uint16_t pgroup)
{
+ uint8_t trx_no = tbf->trx->trx_no;
+ uint8_t ts_no = tbf->first_ts;
int plen;
- unsigned int ts = tbf->first_ts;
LOGPTBF(tbf, LOGL_INFO, "TX: START Immediate Assignment Downlink (PCH)\n");
bitvec *immediate_assignment = bitvec_alloc(22, tall_pcu_ctx); /* without plen */
@@ -976,12 +978,12 @@
/* use request reference that has maximum distance to current time,
* so the assignment will not conflict with possible RACH requests. */
LOGP(DRLCMAC, LOGL_DEBUG, " - TRX=%d (%d) TS=%d TA=%d pollFN=%d\n",
- tbf->trx->trx_no, tbf->trx->arfcn,
- ts, tbf->ta(), poll ? tbf->poll_fn : -1);
- plen = Encoding::write_immediate_assignment(tbf, immediate_assignment, true, 125,
- (tbf->pdch[ts]->last_rts_fn + 21216) % GSM_MAX_FN, tbf->ta(),
- tbf->trx->arfcn, ts, tbf->tsc(), 7, poll,
- tbf->poll_fn, m_bts.alpha, m_bts.gamma, -1,
+ trx_no, tbf->trx->arfcn, ts_no, tbf->ta(), poll ? tbf->poll_fn : -1);
+ plen = Encoding::write_immediate_assignment(&m_bts.trx[trx_no].pdch[ts_no],
+ tbf, immediate_assignment, true, 125,
+ (tbf->pdch[ts_no]->last_rts_fn + 21216) % GSM_MAX_FN,
+ tbf->ta(), 7, poll, tbf->poll_fn,
+ m_bts.alpha, m_bts.gamma, -1,
GSM_L1_BURST_TYPE_ACCESS_0);
if (plen >= 0) {
do_rate_ctr_inc(CTR_IMMEDIATE_ASSIGN_DL_TBF);
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 15de6d7..76a1cec 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -439,9 +439,10 @@
* see GSM 04.08, 9.1.18 and GSM 44.018, 9.1.18 + 10.5.2.16
*/
int Encoding::write_immediate_assignment(
+ const struct gprs_rlcmac_pdch *pdch,
struct gprs_rlcmac_tbf *tbf,
bitvec * dest, bool downlink, uint16_t ra,
- uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts, uint8_t tsc,
+ uint32_t ref_fn, uint8_t ta,
uint8_t usf, bool polling, uint32_t fn, uint8_t alpha,
uint8_t gamma, int8_t ta_idx, enum ph_burst_type burst_type)
{
@@ -462,11 +463,12 @@
bitvec_write_field(dest, &wp,0x0,4); // Page Mode
// GSM 04.08 10.5.2.25a Packet Channel Description
- bitvec_write_field(dest, &wp,0x1,5); // Channel type
- bitvec_write_field(dest, &wp,ts,3); // TN
- bitvec_write_field(dest, &wp,tsc,3); // TSC
- bitvec_write_field(dest, &wp,0x0,3); // non-hopping RF channel configuraion
- bitvec_write_field(dest, &wp,arfcn,10); // ARFCN
+ bitvec_write_field(dest, &wp, 0x01, 5); // Channel type
+ bitvec_write_field(dest, &wp, pdch->ts_no, 3); // TN
+ bitvec_write_field(dest, &wp, pdch->tsc, 3); // TSC
+
+ bitvec_write_field(dest, &wp, 0x00, 3); // spare (non-hopping RF channel configuraion)
+ bitvec_write_field(dest, &wp, pdch->trx->arfcn, 10); // ARFCN
//10.5.2.30 Request Reference
if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
diff --git a/src/encoding.h b/src/encoding.h
index a556687..18392f7 100644
--- a/src/encoding.h
+++ b/src/encoding.h
@@ -42,10 +42,11 @@
class Encoding {
public:
static int write_immediate_assignment(
+ const struct gprs_rlcmac_pdch *pdch,
struct gprs_rlcmac_tbf *tbf,
bitvec * dest, bool downlink, uint16_t ra,
- uint32_t ref_fn, uint8_t ta, uint16_t arfcn, uint8_t ts,
- uint8_t tsc, uint8_t usf, bool polling,
+ uint32_t ref_fn, uint8_t ta,
+ uint8_t usf, bool polling,
uint32_t fn, uint8_t alpha, uint8_t gamma,
int8_t ta_idx,
enum ph_burst_type burst_type);
diff --git a/tests/types/TypesTest.cpp b/tests/types/TypesTest.cpp
index e1c894d..353d821 100644
--- a/tests/types/TypesTest.cpp
+++ b/tests/types/TypesTest.cpp
@@ -728,17 +728,25 @@
static void check_imm_ass(struct gprs_rlcmac_tbf *tbf, bool dl, enum ph_burst_type bt, const uint8_t *exp, uint8_t len,
const char *kind)
{
- uint8_t alpha = 7, gamma = 8, ta = 35, ts = 5, tsc = 1, usf = 1, sz = sizeof(DUMMY_VEC) / 2, plen;
+ uint8_t alpha = 7, gamma = 8, ta = 35, usf = 1, sz = sizeof(DUMMY_VEC) / 2, plen;
bitvec *immediate_assignment = bitvec_alloc(sz, tall_pcu_ctx);
struct msgb *m = msgb_alloc(80, "test");
bool poll = true;
- uint16_t ra = 13, arfcn = 877;
+ uint16_t ra = 13;
uint32_t ref_fn = 24, fn = 11;
int8_t ta_idx = 0;
+ /* HACK: tbf can be NULL, so we cannot use tbf->trx here */
+ struct gprs_rlcmac_trx trx = { };
+ trx.pdch[5].trx = &trx;
+ trx.pdch[5].ts_no = 5;
+ trx.pdch[5].tsc = 1;
+ trx.arfcn = 877;
+
bitvec_unhex(immediate_assignment, DUMMY_VEC);
- plen = Encoding::write_immediate_assignment(tbf, immediate_assignment, dl,
- ra, ref_fn, ta, arfcn, ts, tsc, usf,
+ plen = Encoding::write_immediate_assignment(&trx.pdch[5], tbf,
+ immediate_assignment,
+ dl, ra, ref_fn, ta, usf,
poll, fn, alpha, gamma, ta_idx, bt);
printf("[%u] %s Immediate Assignment <%s>:\n\t%s\n", plen, dl ? "DL" : "UL", kind,
osmo_hexdump(immediate_assignment->data, sz));