diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-11-06 19:52:05 +0100 |
---|---|---|
committer | pespin <pespin@sysmocom.de> | 2020-11-16 09:14:28 +0000 |
commit | cb00c52b0727ae10086bdc8417060110f317900b (patch) | |
tree | 9d34228006e44cc24859eb68b7825b407aef21fd /library/RLCMAC_EncDec.cc | |
parent | 7a4fe8541e77205daae64f83d0cadd969c498822 (diff) |
pcu: Specify (M)CS to use when sending UL rlcmac data blocks
Apply padding and spare bits in the encoder according to CS/MCS format.
Change-Id: I918acac81f550077daeda3374b3de9b426ff3572
Diffstat (limited to 'library/RLCMAC_EncDec.cc')
-rw-r--r-- | library/RLCMAC_EncDec.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/library/RLCMAC_EncDec.cc b/library/RLCMAC_EncDec.cc index 4dba35ae..ea93de4b 100644 --- a/library/RLCMAC_EncDec.cc +++ b/library/RLCMAC_EncDec.cc @@ -438,6 +438,28 @@ static void put_egprs_data_block(const TTCN_Buffer& aligned_data_block_buffer, u dst_ttcn_buffer.increase_length(length_bytes); } +/* Append padding bytes and spare bits at the end of ttcn_buffer, based on requested CS */ +static void encode_trailing_padding_spb(TTCN_Buffer& ttcn_buffer, CodingScheme cs) +{ + uint8_t buf[256]; /* enough to fit any RLCMAC buffer*/ + uint32_t blk_len = RLCMAC__Templates::f__rlcmac__cs__mcs2block__len(cs); + uint32_t blk_len_no_spb = RLCMAC__Templates::f__rlcmac__cs__mcs2block__len__no__spare__bits(cs); + uint32_t data_len = ttcn_buffer.get_len(); + + if (data_len > blk_len_no_spb) { + fprintf(stderr, "Buffer too large for requested CS! %s (%s:%u)\n", __func__, __FILE__, __LINE__); + // TODO: throw exception? + } + + for (int i = 0; i < blk_len_no_spb - data_len; i++) + buf[i] = 0x2b; /* Padding bits if needed */ + for (int i = blk_len_no_spb - data_len; i < blk_len - data_len; i++) + buf[i] = 0x00; /* Spare bits if needed */ + + const OCTETSTRING& pad_octstr = OCTETSTRING(blk_len - data_len, buf); + ttcn_buffer.put_string(pad_octstr); +} + ///////////////////// // DECODE ///////////////////// @@ -970,6 +992,8 @@ OCTETSTRING enc__RlcmacDlDataBlock(const RlcmacDlDataBlock& si) } } + encode_trailing_padding_spb(ttcn_buffer, in.cs()); + ttcn_buffer.get_string(ret_val); return ret_val; } @@ -1040,6 +1064,8 @@ OCTETSTRING enc__RlcmacDlEgprsDataBlock(const RlcmacDlEgprsDataBlock& si) } } + encode_trailing_padding_spb(ttcn_buffer, in.mcs()); + ttcn_buffer.get_string(ret_val); return ret_val; } @@ -1133,6 +1159,8 @@ OCTETSTRING enc__RlcmacUlDataBlock(const RlcmacUlDataBlock& si) } } + encode_trailing_padding_spb(ttcn_buffer, in.cs()); + ttcn_buffer.get_string(ret_val); return ret_val; } @@ -1320,6 +1348,8 @@ OCTETSTRING enc__RlcmacUlEgprsDataBlock(const RlcmacUlEgprsDataBlock& si) put_egprs_data_block(aligned_buffer, data_block_offsets[0], data_block_bits, ttcn_buffer); //printbuffer("after merging data block", ttcn_buffer); + encode_trailing_padding_spb(ttcn_buffer, in.mcs()); + ttcn_buffer.get_string(ret_val); return ret_val; } |