Revert "Rewrite Packet Downlink Assignment"

This reverts commit 896574e92b,
I52ec9b07413daabba8cd5f1fba5c7b3af6a33389.

This commit was found (empirically) to be a regression, rendering GPRS service
fatally unreliable.

Related: OS#3013
Change-Id: Idcba0381f70eb7f7c9aefdee9dfeafd5de96a9be
This commit is contained in:
Neels Hofmeyr 2018-02-27 22:41:07 +01:00 committed by Harald Welte
parent 782da2cf95
commit 39f845848c
1 changed files with 48 additions and 73 deletions

View File

@ -44,21 +44,6 @@ extern "C" {
#define set_H(bv) set_x(bv, H) #define set_H(bv) set_x(bv, H)
/* { 0 | 1 < TIMING_ADVANCE_INDEX : bit (4) > } */ /* { 0 | 1 < TIMING_ADVANCE_INDEX : bit (4) > } */
static inline int write_ta_index(bitvec *dest, int8_t tai)
{
int rc;
if (tai < 0) /* No TIMING_ADVANCE_INDEX: */
set_0(dest);
/* TIMING_ADVANCE_INDEX: */
set_1(dest);
rc = bitvec_set_u64(dest, tai, 4, false);
check(rc);
return 0;
}
static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai) static inline bool write_tai(bitvec *dest, unsigned& wp, int8_t tai)
{ {
if (tai < 0) { /* No TIMING_ADVANCE_INDEX: */ if (tai < 0) { /* No TIMING_ADVANCE_INDEX: */
@ -174,58 +159,52 @@ static inline int write_tfi_usf(bitvec *dest, const gprs_rlcmac_ul_tbf *tbf, uin
return 0; return 0;
} }
/* 3GPP TS 44.018 §10.5.2.16 IA Rest Octets ::= Packet Downlink Assignment */ static int write_ia_rest_downlink(
static inline int write_ia_rest_downlink(const gprs_rlcmac_dl_tbf *tbf, bitvec *dest, gprs_rlcmac_dl_tbf *tbf,
bool polling, bool ta_valid, uint32_t fn, bitvec * dest, unsigned& wp,
uint8_t alpha, uint8_t gamma, int8_t ta_idx) uint8_t polling, bool ta_valid, uint32_t fn,
uint8_t alpha, uint8_t gamma, int8_t ta_idx)
{ {
int rc; if (!tbf) {
LOGP(DRLCMACDL, LOGL_ERROR,
set_H(dest); set_H(dest); "Cannot encode DL IMMEDIATE ASSIGNMENT without TBF\n");
set_0(dest); set_1(dest); /* 00 Packet Downlink Assignment */ return -EINVAL;
}
rc = bitvec_set_u64(dest, tbf->tlli(), 32, false); /* TLLI */ // GSM 04.08 10.5.2.16 IA Rest Octets
check(rc); bitvec_write_field(dest, &wp, 3, 2); // "HH"
bitvec_write_field(dest, &wp, 1, 2); // "01" Packet Downlink Assignment
set_1(dest); bitvec_write_field(dest, &wp,tbf->tlli(),32); // TLLI
rc = bitvec_set_u64(dest, tbf->tfi(), 5, false); /* TFI_ASSIGNMENT */ bitvec_write_field(dest, &wp,0x1,1); // switch TFI : on
check(rc); bitvec_write_field(dest, &wp,tbf->tfi(),5); // TFI
bitvec_write_field(dest, &wp,0x0,1); // RLC acknowledged mode
/* RLC acknowledged mode */ if (alpha) {
set_0(dest); /* RLC_MODE */ bitvec_write_field(dest, &wp,0x1,1); // ALPHA = present
bitvec_write_field(dest, &wp,alpha,4); // ALPHA
rc = write_alpha_gamma(dest, alpha, gamma); /* ALPHA and GAMMA */ } else {
check(rc); bitvec_write_field(dest, &wp,0x0,1); // ALPHA = not present
}
rc = bitvec_set_bit(dest, (bit_value)polling); /* POLLING */ bitvec_write_field(dest, &wp,gamma,5); // GAMMA power control parameter
check(rc); bitvec_write_field(dest, &wp,polling,1); // Polling Bit
bitvec_write_field(dest, &wp, ta_valid, 1); // N. B: NOT related to TAI!
/* N. B: NOT related to TAI! */ write_tai(dest, wp, ta_idx);
rc = bitvec_set_bit(dest, (bit_value)ta_valid); /* TA_VALID */
check(rc);
rc = write_ta_index(dest, ta_idx);
check(rc);
if (polling) { if (polling) {
set_1(dest); bitvec_write_field(dest, &wp,0x1,1); // TBF Starting TIME present
rc = write_tbf_start_time(dest, fn); /* TBF_STARTING_TIME */ bitvec_write_field(dest, &wp,(fn / (26 * 51)) % 32,5); // T1'
check(rc); bitvec_write_field(dest, &wp,fn % 51,6); // T3
} else bitvec_write_field(dest, &wp,fn % 26,5); // T2
set_0(dest); /* No TBF_STARTING_TIME */ } else {
bitvec_write_field(dest, &wp,0x0,1); // TBF Starting TIME present
set_0(dest); /* No P0 nor PR_MODE */ }
bitvec_write_field(dest, &wp,0x0,1); // P0 not present
// bitvec_write_field(dest, &wp,0x1,1); // P0 not present
// bitvec_write_field(dest, &wp,,0xb,4);
if (tbf->is_egprs_enabled()) { if (tbf->is_egprs_enabled()) {
set_H(dest); /* see GMS 44.018, 10.5.2.16 */
rc = bitvec_set_u64(dest, enc_ws(tbf->window_size()), 5, false); /* EGPRS Window Size */ bitvec_write_field(dest, &wp, 1, 1); // "H"
check(rc); write_ws(dest, &wp, tbf->window_size()); // EGPRS Window Size
bitvec_write_field(dest, &wp, 0x0, 2); // LINK_QUALITY_MEASUREMENT_MODE
/* The mobile station shall not report measurements: (see 3GPP TS 44.060 Table 11.2.7.1) */ bitvec_write_field(dest, &wp, 0, 1); // BEP_PERIOD2 not present
set_0(dest); set_0(dest); /* LINK_QUALITY_MEASUREMENT_MODE */ }
set_1(dest); /* No BEP_PERIOD2 */
} else
set_L(dest); /* No Additions for Rel-6 */
return 0; return 0;
} }
@ -481,15 +460,11 @@ int Encoding::write_immediate_assignment(
plen = wp / 8; plen = wp / 8;
if (downlink) { if (downlink)
if (!as_dl_tbf(tbf)) { rc = write_ia_rest_downlink(as_dl_tbf(tbf), dest, wp,
LOGP(DRLCMACDL, LOGL_ERROR, "Cannot encode DL IMMEDIATE ASSIGNMENT without TBF\n"); polling, gsm48_ta_is_valid(ta), fn,
return -EINVAL; alpha, gamma, ta_idx);
} else if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
dest->cur_bit = wp;
rc = write_ia_rest_downlink(as_dl_tbf(tbf), dest, polling, gsm48_ta_is_valid(ta), fn,
alpha, gamma, ta_idx);
} else if (((burst_type == GSM_L1_BURST_TYPE_ACCESS_1) ||
(burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) { (burst_type == GSM_L1_BURST_TYPE_ACCESS_2))) {
dest->cur_bit = wp; dest->cur_bit = wp;
rc = write_ia_rest_egprs_uplink(as_ul_tbf(tbf), dest, usf, fn, alpha, gamma, ta_idx, burst_type, ra); rc = write_ia_rest_egprs_uplink(as_ul_tbf(tbf), dest, usf, fn, alpha, gamma, ta_idx, burst_type, ra);