encoding: pass RFN to write_immediate_assignment(_reject)()
Those function don't really require the full FN, hence let's pass only the required information. This makes the implementation here less dependent on how/if we are able to calculate full FNs based on RFN: We get an RFN, and we have to encode so that the RFN can be derived again, so feels less cumbersome having to go through RFN->FN->RFN which may only cause possible issues if there's some FN timing bug. 3GPP TS 44.018 10.5.2.30 Request Reference: "The purpose of the Request Reference information element is to provide the random access information used in the channel request and the frame number, FN modulo 42432" 3GPP TS 44.018 10.5.2.38 Starting Time: "The purpose of the Starting Time information element is to provide the start TDMA frame number, FN modulo 42432." Change-Id: If9b758434c00f2a3868534d5be84946809c989a9
This commit is contained in:
parent
636d7fdb72
commit
bd461e62b5
|
@ -1022,7 +1022,7 @@ int bts_rcv_rach(struct gprs_rlcmac_bts *bts, const struct rach_ind_params *rip)
|
|||
trx->trx_no, trx->arfcn & ~ARFCN_FLAG_MASK,
|
||||
pdch->ts_no, ta, pdch->tsc, tbf ? tbf->tfi() : -1, usf);
|
||||
plen = Encoding::write_immediate_assignment(pdch, tbf, bv,
|
||||
false, rip->ra, Fn, ta, usf, false, sb_fn,
|
||||
false, rip->ra, rip->rfn, ta, usf, false, fn2rfn(sb_fn),
|
||||
bts_get_ms_pwr_alpha(bts), bts->pcu->vty.gamma, -1,
|
||||
rip->burst_type);
|
||||
bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_UL_TBF);
|
||||
|
@ -1038,7 +1038,7 @@ int bts_rcv_rach(struct gprs_rlcmac_bts *bts, const struct rach_ind_params *rip)
|
|||
send_imm_ass_rej:
|
||||
LOGP(DRLCMAC, LOGL_DEBUG, "Tx Immediate Assignment Reject on AGCH\n");
|
||||
plen = Encoding::write_immediate_assignment_reject(
|
||||
bv, rip->ra, Fn, rip->burst_type,
|
||||
bv, rip->ra, rip->rfn, rip->burst_type,
|
||||
(uint8_t)osmo_tdef_get(bts->T_defs_bts, 3142, OSMO_TDEF_S, -1));
|
||||
bts_do_rate_ctr_inc(bts, CTR_IMMEDIATE_ASSIGN_REJ);
|
||||
if (plen >= 0)
|
||||
|
@ -1118,7 +1118,7 @@ void bts_snd_dl_ass(struct gprs_rlcmac_bts *bts, const struct gprs_rlcmac_dl_tbf
|
|||
tbf->trx->trx_no, tbf->trx->arfcn, pdch->ts_no, tbf->ta());
|
||||
plen = Encoding::write_immediate_assignment(pdch,
|
||||
tbf, immediate_assignment, true, 125,
|
||||
GSM_TDMA_FN_SUM(pdch->last_rts_fn, 21216),
|
||||
fn2rfn(GSM_TDMA_FN_SUM(pdch->last_rts_fn, 21216)),
|
||||
tbf->ta(), 7, false, 0,
|
||||
bts_get_ms_pwr_alpha(bts), bts->pcu->vty.gamma, -1,
|
||||
GSM_L1_BURST_TYPE_ACCESS_0);
|
||||
|
|
|
@ -63,22 +63,22 @@ static int write_alpha_gamma(bitvec *dest, uint8_t alpha, uint8_t gamma)
|
|||
}
|
||||
|
||||
/* TBF_STARTING_TIME -- same as 3GPP TS 44.018 §10.5.2.38 Starting Time without tag: */
|
||||
static int write_tbf_start_time(bitvec *dest, uint32_t fn)
|
||||
static int write_tbf_start_time(bitvec *dest, uint16_t rfn)
|
||||
{
|
||||
int rc;
|
||||
|
||||
/* Set values according to 3GPP TS 44.018 Table 10.5.2.38.1 */
|
||||
|
||||
/* T1' */
|
||||
rc = bitvec_set_u64(dest, (fn / (26 * 51)) % 32, 5, false);
|
||||
rc = bitvec_set_u64(dest, (rfn / (26 * 51)) % 32, 5, false);
|
||||
CHECK(rc);
|
||||
|
||||
/* T3 */
|
||||
rc = bitvec_set_u64(dest, fn % 51, 6, false);
|
||||
rc = bitvec_set_u64(dest, rfn % 51, 6, false);
|
||||
CHECK(rc);
|
||||
|
||||
/* T2 */
|
||||
rc = bitvec_set_u64(dest, fn % 26, 5, false);
|
||||
rc = bitvec_set_u64(dest, rfn % 26, 5, false);
|
||||
CHECK(rc);
|
||||
|
||||
return rc;
|
||||
|
@ -180,7 +180,7 @@ static inline void write_ta_ie(bitvec *dest, unsigned& wp,
|
|||
}
|
||||
|
||||
static int write_ia_rest_downlink(const gprs_rlcmac_dl_tbf *tbf, bitvec * dest, bool polling, bool ta_valid,
|
||||
uint32_t fn, uint8_t alpha, uint8_t gamma, int8_t ta_idx)
|
||||
uint16_t rfn, uint8_t alpha, uint8_t gamma, int8_t ta_idx)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
@ -213,7 +213,7 @@ static int write_ia_rest_downlink(const gprs_rlcmac_dl_tbf *tbf, bitvec * dest,
|
|||
|
||||
if (polling) {
|
||||
SET_1(dest);
|
||||
rc = write_tbf_start_time(dest, fn);
|
||||
rc = write_tbf_start_time(dest, rfn);
|
||||
CHECK(rc);
|
||||
} else
|
||||
SET_0(dest);
|
||||
|
@ -235,7 +235,7 @@ static int write_ia_rest_downlink(const gprs_rlcmac_dl_tbf *tbf, bitvec * dest,
|
|||
}
|
||||
|
||||
/* 3GPP TS 44.018 Table 10.5.2.16.1 < Packet Uplink Assignment > -- Single Block Allocation */
|
||||
static int write_ia_rest_uplink_sba(bitvec *dest, uint32_t fn, uint8_t alpha, uint8_t gamma)
|
||||
static int write_ia_rest_uplink_sba(bitvec *dest, uint32_t rfn, uint8_t alpha, uint8_t gamma)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
@ -248,7 +248,7 @@ static int write_ia_rest_uplink_sba(bitvec *dest, uint32_t fn, uint8_t alpha, ui
|
|||
SET_0(dest);
|
||||
SET_1(dest);
|
||||
|
||||
rc = write_tbf_start_time(dest, fn);
|
||||
rc = write_tbf_start_time(dest, rfn);
|
||||
CHECK(rc);
|
||||
|
||||
/* No P0 nor PR_MODE */
|
||||
|
@ -292,7 +292,7 @@ static int write_ia_rest_uplink_mba(const gprs_rlcmac_ul_tbf *tbf, bitvec *dest,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int write_ia_rest_egprs_uplink_mba(bitvec * dest, uint32_t fn, uint8_t alpha, uint8_t gamma)
|
||||
static int write_ia_rest_egprs_uplink_mba(bitvec * dest, uint32_t rfn, uint8_t alpha, uint8_t gamma)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
|
@ -301,7 +301,7 @@ static int write_ia_rest_egprs_uplink_mba(bitvec * dest, uint32_t fn, uint8_t al
|
|||
rc = write_alpha_gamma(dest, alpha, gamma);
|
||||
CHECK(rc);
|
||||
|
||||
rc = write_tbf_start_time(dest, fn);
|
||||
rc = write_tbf_start_time(dest, rfn);
|
||||
CHECK(rc);
|
||||
|
||||
SET_0(dest); /* NUMBER OF RADIO BLOCKS ALLOCATED: */
|
||||
|
@ -358,7 +358,7 @@ static int write_ia_rest_egprs_uplink_sba(const gprs_rlcmac_ul_tbf *tbf, bitvec
|
|||
* see GSM 44.018, 9.1.20 + 10.5.2.30
|
||||
*/
|
||||
int Encoding::write_immediate_assignment_reject(bitvec *dest, uint16_t ra,
|
||||
uint32_t ref_fn, enum ph_burst_type burst_type, uint8_t t3142)
|
||||
uint16_t ref_rfn, enum ph_burst_type burst_type, uint8_t t3142)
|
||||
{
|
||||
unsigned wp = 0;
|
||||
int plen;
|
||||
|
@ -394,9 +394,9 @@ int Encoding::write_immediate_assignment_reject(bitvec *dest, uint16_t ra,
|
|||
}
|
||||
|
||||
bitvec_write_field(dest, &wp,
|
||||
(ref_fn / (26 * 51)) % 32, 5); // T1'
|
||||
bitvec_write_field(dest, &wp, ref_fn % 51, 6); // T3
|
||||
bitvec_write_field(dest, &wp, ref_fn % 26, 5); // T2
|
||||
(ref_rfn / (26 * 51)) % 32, 5); // T1'
|
||||
bitvec_write_field(dest, &wp, ref_rfn % 51, 6); // T3
|
||||
bitvec_write_field(dest, &wp, ref_rfn % 26, 5); // T2
|
||||
|
||||
/* 10.5.2.43 Wait Indication */
|
||||
bitvec_write_field(dest, &wp, t3142, 8);
|
||||
|
@ -437,8 +437,8 @@ int Encoding::write_immediate_assignment(
|
|||
const struct gprs_rlcmac_pdch *pdch,
|
||||
const struct gprs_rlcmac_tbf *tbf,
|
||||
bitvec * dest, bool downlink, uint16_t ra,
|
||||
uint32_t ref_fn, uint8_t ta,
|
||||
uint8_t usf, bool polling, uint32_t fn, uint8_t alpha,
|
||||
uint16_t ref_rfn, uint8_t ta,
|
||||
uint8_t usf, bool polling, uint16_t rfn, uint8_t alpha,
|
||||
uint8_t gamma, int8_t ta_idx, enum ph_burst_type burst_type)
|
||||
{
|
||||
unsigned wp = 0;
|
||||
|
@ -480,9 +480,9 @@ int Encoding::write_immediate_assignment(
|
|||
bitvec_write_field(dest, &wp, ra, 8); /* RACH value */
|
||||
}
|
||||
|
||||
bitvec_write_field(dest, &wp, (ref_fn / (26 * 51)) % 32, 5); // T1'
|
||||
bitvec_write_field(dest, &wp, ref_fn % 51, 6); // T3
|
||||
bitvec_write_field(dest, &wp, ref_fn % 26, 5); // T2
|
||||
bitvec_write_field(dest, &wp, (ref_rfn / (26 * 51)) % 32, 5); // T1'
|
||||
bitvec_write_field(dest, &wp, ref_rfn % 51, 6); // T3
|
||||
bitvec_write_field(dest, &wp, ref_rfn % 26, 5); // T2
|
||||
|
||||
// 10.5.2.40 Timing Advance
|
||||
bitvec_write_field(dest, &wp, 0x0, 2); // spare
|
||||
|
@ -508,7 +508,7 @@ int Encoding::write_immediate_assignment(
|
|||
if (downlink) {
|
||||
OSMO_ASSERT(tbf_as_dl_tbf_const(tbf) != NULL);
|
||||
|
||||
rc = write_ia_rest_downlink(tbf_as_dl_tbf_const(tbf), dest, polling, gsm48_ta_is_valid(ta), fn, alpha, gamma,
|
||||
rc = write_ia_rest_downlink(tbf_as_dl_tbf_const(tbf), dest, polling, gsm48_ta_is_valid(ta), rfn, alpha, gamma,
|
||||
ta_idx);
|
||||
} else if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) || (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) {
|
||||
SET_L(dest); SET_H(dest); // "LH"
|
||||
|
@ -521,7 +521,7 @@ int Encoding::write_immediate_assignment(
|
|||
if (tbf_as_ul_tbf_const(tbf) != NULL)
|
||||
rc = write_ia_rest_egprs_uplink_sba(tbf_as_ul_tbf_const(tbf), dest, usf, alpha, gamma, ta_idx);
|
||||
else
|
||||
rc = write_ia_rest_egprs_uplink_mba(dest, fn, alpha, gamma);
|
||||
rc = write_ia_rest_egprs_uplink_mba(dest, rfn, alpha, gamma);
|
||||
} else {
|
||||
OSMO_ASSERT(!tbf || !tbf->is_egprs_enabled());
|
||||
|
||||
|
@ -531,7 +531,7 @@ int Encoding::write_immediate_assignment(
|
|||
if (tbf_as_ul_tbf_const(tbf) != NULL)
|
||||
rc = write_ia_rest_uplink_mba(tbf_as_ul_tbf_const(tbf), dest, usf, alpha, gamma, ta_idx);
|
||||
else
|
||||
rc = write_ia_rest_uplink_sba(dest, fn, alpha, gamma);
|
||||
rc = write_ia_rest_uplink_sba(dest, rfn, alpha, gamma);
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
|
|
|
@ -46,15 +46,15 @@ public:
|
|||
const struct gprs_rlcmac_pdch *pdch,
|
||||
const struct gprs_rlcmac_tbf *tbf,
|
||||
bitvec * dest, bool downlink, uint16_t ra,
|
||||
uint32_t ref_fn, uint8_t ta,
|
||||
uint16_t ref_rfn, uint8_t ta,
|
||||
uint8_t usf, bool polling,
|
||||
uint32_t fn, uint8_t alpha, uint8_t gamma,
|
||||
uint16_t rfn, uint8_t alpha, uint8_t gamma,
|
||||
int8_t ta_idx,
|
||||
enum ph_burst_type burst_type);
|
||||
|
||||
static int write_immediate_assignment_reject(
|
||||
bitvec *dest, uint16_t ra,
|
||||
uint32_t ref_fn,
|
||||
uint16_t ref_rfn,
|
||||
enum ph_burst_type burst_type,
|
||||
uint8_t t3142
|
||||
);
|
||||
|
|
|
@ -753,7 +753,7 @@ static void check_imm_ass(struct gprs_rlcmac_tbf *tbf, bool dl, enum ph_burst_ty
|
|||
struct msgb *m = msgb_alloc(80, "test");
|
||||
bool poll = true;
|
||||
uint16_t ra = 13;
|
||||
uint32_t ref_fn = 24, fn = 11;
|
||||
uint32_t ref_rfn = 24, rfn = 11;
|
||||
int8_t ta_idx = 0;
|
||||
|
||||
/* HACK: tbf can be NULL, so we cannot use tbf->trx here */
|
||||
|
@ -766,8 +766,8 @@ static void check_imm_ass(struct gprs_rlcmac_tbf *tbf, bool dl, enum ph_burst_ty
|
|||
bitvec_unhex(immediate_assignment, DUMMY_VEC);
|
||||
plen = Encoding::write_immediate_assignment(&trx.pdch[5], tbf,
|
||||
immediate_assignment,
|
||||
dl, ra, ref_fn, ta, usf,
|
||||
poll, fn, alpha, gamma, ta_idx, bt);
|
||||
dl, ra, ref_rfn, ta, usf,
|
||||
poll, rfn, 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));
|
||||
|
||||
|
|
Loading…
Reference in New Issue