Fix Channel Coding Command for MCS

Previously result of ".to_num() - 1" was used without any checks which
means that in case of to_num() returning zero we would effectively try
to encode (uint8_t)(-1).

Let's fix this by using proper mcs_chan_code() function which returns
Channel Coding Command for MCS without the need to further correct it
and adjust expected tests output accordingly.

Change-Id: I868062a81fffe6714a811c032215f25a79259905
This commit is contained in:
Max 2019-03-06 18:17:32 +01:00
parent 898dddb1d1
commit 6e96dd4665
4 changed files with 12 additions and 12 deletions

View File

@ -268,7 +268,7 @@ static int write_ia_rest_uplink_mba(const gprs_rlcmac_ul_tbf *tbf, bitvec *dest,
bitvec_write_field(dest, &wp, usf, 3); // USF
bitvec_write_field(dest, &wp, 0, 1); // USF_GRANULARITY
bitvec_write_field(dest, &wp, 0, 1); // "0" power control: Not Present
bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, &wp, 1, 1); // TLLI_BLOCK_CHANNEL_CODING
if (alpha) {
bitvec_write_field(dest, &wp, 0x1, 1); // ALPHA = present
@ -315,7 +315,7 @@ static int write_ia_rest_egprs_uplink_sba(const gprs_rlcmac_ul_tbf *tbf, bitvec
CHECK(rc);
/* 3GPP TS 44.060 §12.10d EGPRS Modulation and coding Scheme description: */
rc = bitvec_set_u64(dest, tbf->current_cs().to_num() - 1, 4, false); /* EGPRS CHANNEL_CODING_COMMAND */
rc = bitvec_set_u64(dest, mcs_chan_code(tbf->current_cs()), 4, false); /* EGPRS CHANNEL_CODING_COMMAND */
CHECK(rc);
/* TLLI_BLOCK_CHANNEL_CODING */
@ -571,7 +571,7 @@ void Encoding::write_packet_uplink_assignment(
if (!use_egprs) {
bitvec_write_field(dest, &wp,0x0,1); // Message escape
bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, &wp,0x1,1); // TLLI_BLOCK_CHANNEL_CODING
write_ta_ie(dest, wp,tbf->ta(), ta_idx, ta_ts);
} else { /* EPGRS */
@ -579,7 +579,7 @@ void Encoding::write_packet_uplink_assignment(
bitvec_write_field(dest, &wp,0x0,2); // EGPRS message contents
bitvec_write_field(dest, &wp,0x0,1); // No CONTENTION_RESOLUTION_TLLI
bitvec_write_field(dest, &wp,0x0,1); // No COMPACT reduced MA
bitvec_write_field(dest, &wp,tbf->current_cs().to_num()-1, 4); // EGPRS Modulation and Coding IE
bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 4); // EGPRS Modulation and Coding IE
/* 0: no RESEGMENT, 1: Segmentation*/
bitvec_write_field(dest, &wp, 0x1, 1);
write_ws(dest, &wp, tbf->window_size()); // EGPRS Window Size
@ -809,7 +809,7 @@ static void write_packet_uplink_ack_gprs(
struct gprs_rlcmac_ul_tbf *tbf, bool is_final)
{
bitvec_write_field(dest, &wp, tbf->current_cs().to_num() - 1, 2); // CHANNEL_CODING_COMMAND
bitvec_write_field(dest, &wp, mcs_chan_code(tbf->current_cs()), 2); // CHANNEL_CODING_COMMAND
write_packet_ack_nack_desc_gprs(bts, dest, wp, tbf->window(), is_final);
bitvec_write_field(dest, &wp, 1, 1); // 1: have CONTENTION_RESOLUTION_TLLI
@ -991,7 +991,7 @@ static void write_packet_uplink_ack_egprs(
bitvec_write_field(dest, &wp, 0, 2); // fixed 00
/* CHANNEL_CODING_COMMAND */
bitvec_write_field(dest, &wp,
tbf->current_cs().to_num() - 1, 4);
mcs_chan_code(tbf->current_cs()), 4);
/* 0: no RESEGMENT, 1: Segmentation*/
bitvec_write_field(dest, &wp, 1, 1);
bitvec_write_field(dest, &wp, 1, 1); // PRE_EMPTIVE_TRANSMISSION, TODO: This resembles GPRS, change it?

View File

@ -739,7 +739,7 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
struct msgb *msg1 = ul_tbf->create_ul_ack(*fn, ts_no);
static uint8_t exp1[] = { 0x40, 0x24, 0x01, 0x3f, 0x3e, 0x24, 0x46, 0x68, 0x90, 0x87, 0xb0, 0x06,
static uint8_t exp1[] = { 0x40, 0x24, 0x01, 0x03, 0x3e, 0x24, 0x46, 0x68, 0x90, 0x87, 0xb0, 0x06,
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b
};
@ -766,7 +766,7 @@ static gprs_rlcmac_ul_tbf *puan_urbb_len_issue(BTS *the_bts,
msg1 = ul_tbf->create_ul_ack(*fn, ts_no);
static uint8_t exp2[] = { 0x40, 0x24, 0x01, 0x3f, 0x3e, 0x24, 0x46, 0x68, 0x90, 0x88, 0xb0, 0x06, 0x8b,
static uint8_t exp2[] = { 0x40, 0x24, 0x01, 0x03, 0x3e, 0x24, 0x46, 0x68, 0x90, 0x88, 0xb0, 0x06, 0x8b,
0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b
};

View File

@ -497,7 +497,7 @@ void test_immediate_assign_ul0m()
0x23, /* TA */
0x00, /* 0-length §10.5.2.21 Mobile Allocation */
/* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */
0xc8, 0x02, 0x7b, 0xa0, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };
0xc8, 0x02, 0x1b, 0xa0, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };
check_imm_ass(tbf, false, GSM_L1_BURST_TYPE_ACCESS_0, res, sizeof(res), "ia_rest_uplink(MBA)");
}
@ -537,7 +537,7 @@ void test_immediate_assign_ul1s()
0x23, /* TA */
0x00, /* 0-length §10.5.2.21 Mobile Allocation */
/* ETSI TS 44.018 §10.5.2.16 IA Rest Octets */
0x46, 0xa0, 0x09, 0xe0, 0x17, 0x40, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };
0x46, 0xa0, 0x08, 0x00, 0x17, 0x40, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, 0x2b, };
check_imm_ass(tbf, false, GSM_L1_BURST_TYPE_ACCESS_1, res, sizeof(res), "ia_rest_egprs_uplink(SBA)");
}

View File

@ -9,13 +9,13 @@ show_rbb: IIRRIIIR
[11] DL Immediate Assignment <ia_rest_downlink>:
06 3f 30 0d 23 6d 7f 03 18 23 00 d0 00 00 00 08 17 47 08 0b 5b 2b 2b
[11] UL Immediate Assignment <ia_rest_uplink(MBA)>:
06 3f 10 0d 23 6d 0d 03 18 23 00 c8 02 7b a0 2b 2b 2b 2b 2b 2b 2b 2b
06 3f 10 0d 23 6d 0d 03 18 23 00 c8 02 1b a0 2b 2b 2b 2b 2b 2b 2b 2b
[11] UL Immediate Assignment <ia_rest_uplink(SBA)>:
06 3f 10 0d 23 6d 0d 03 18 23 00 c5 d1 08 0b 5b 2b 2b 2b 2b 2b 2b 2b
[11] UL Immediate Assignment <ia_rest_egprs_uplink(MBA)>:
06 3f 10 0d 23 6d 7f 03 18 23 00 46 97 40 0b 58 2b 2b 2b 2b 2b 2b 2b
[11] UL Immediate Assignment <ia_rest_egprs_uplink(SBA)>:
06 3f 10 0d 23 6d 7f 03 18 23 00 46 a0 09 e0 17 40 2b 2b 2b 2b 2b 2b
06 3f 10 0d 23 6d 7f 03 18 23 00 46 a0 08 00 17 40 2b 2b 2b 2b 2b 2b
assignment reject: 06 3a 10 7f 06 36 14 7f 06 36 14 7f 06 36 14 7f 06 36 14 c0 2b 2b
assignment reject: 06 3a 10 70 06 36 14 70 06 36 14 70 06 36 14 70 06 36 14 0b 2b 2b
Testing LBS utility...