mac_sch_pdu_nr: add support for contention resolution CE

master
Andre Puschmann 3 years ago
parent 4dcbc70131
commit 062cba5bd5

@ -94,6 +94,11 @@ public:
};
ta_t get_ta();
// UE contention resolution identity CE
static const uint8_t ue_con_res_id_len = 6;
typedef std::array<uint8_t, ue_con_res_id_len> ue_con_res_id_t;
ue_con_res_id_t get_ue_con_res_id_ce();
// setters
void set_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_);
void set_padding(const uint32_t len_);
@ -101,6 +106,7 @@ public:
void set_se_phr(const uint8_t phr_, const uint8_t pcmax_);
void set_sbsr(const lcg_bsr_t bsr_);
void set_lbsr(const std::array<mac_sch_subpdu_nr::lcg_bsr_t, max_num_lcg_lbsr> bsr_);
void set_ue_con_res_id_ce(const ue_con_res_id_t id);
uint32_t write_subpdu(const uint8_t* start_);
@ -203,6 +209,7 @@ public:
uint32_t add_se_phr_ce(const uint8_t phr_, const uint8_t pcmax_);
uint32_t add_sbsr_ce(const mac_sch_subpdu_nr::lcg_bsr_t bsr_);
uint32_t add_lbsr_ce(const std::array<mac_sch_subpdu_nr::lcg_bsr_t, mac_sch_subpdu_nr::max_num_lcg_lbsr> bsr_);
uint32_t add_ue_con_res_id_ce(const mac_sch_subpdu_nr::ue_con_res_id_t id);
uint32_t get_remaing_len();

@ -47,12 +47,18 @@ bool mac_sch_subpdu_nr::is_valid_lcid()
bool mac_sch_subpdu_nr::is_var_len_ce(uint32_t lcid)
{
switch (lcid) {
case LONG_TRUNC_BSR:
case LONG_BSR:
return true;
default:
return false;
if (parent->is_ulsch()) {
// UL fixed-size CE
switch (lcid) {
case LONG_TRUNC_BSR:
case LONG_BSR:
return true;
default:
return false;
}
} else {
// all currently supported CEs in the DL are fixed-size
return false;
}
}
@ -153,6 +159,18 @@ void mac_sch_subpdu_nr::set_sbsr(const lcg_bsr_t bsr_)
// Turn a subPDU into a long BSR with variable size
void mac_sch_subpdu_nr::set_lbsr(const std::array<mac_sch_subpdu_nr::lcg_bsr_t, max_num_lcg_lbsr> bsr_) {}
// Turn subPDU into a Con
void mac_sch_subpdu_nr::set_ue_con_res_id_ce(const mac_sch_subpdu_nr::ue_con_res_id_t id)
{
lcid = CON_RES_ID;
header_length = 1;
sdu_length = sizeof_ce(lcid, parent->is_ulsch());
uint8_t* ptr = sdu.use_internal_storage();
for (int32_t i = 0; i < sdu_length; ++i) {
ptr[i] = id.at(i);
}
}
// Section 6.1.2
uint32_t mac_sch_subpdu_nr::write_subpdu(const uint8_t* start_)
{
@ -303,6 +321,16 @@ mac_sch_subpdu_nr::lbsr_t mac_sch_subpdu_nr::get_lbsr() const
return lbsr;
}
mac_sch_subpdu_nr::ue_con_res_id_t mac_sch_subpdu_nr::get_ue_con_res_id_ce()
{
mac_sch_subpdu_nr::ue_con_res_id_t id;
if (!parent->is_ulsch() && lcid == CON_RES_ID) {
const uint8_t* ptr = sdu.ptr();
memcpy(id.data(), ptr, id.size());
}
return id;
}
uint32_t mac_sch_subpdu_nr::sizeof_ce(uint32_t lcid, bool is_ul)
{
if (is_ul) {
@ -389,9 +417,17 @@ void mac_sch_subpdu_nr::to_string(fmt::memory_buffer& buffer)
case mac_sch_subpdu_nr::TA_CMD:
fmt::format_to(buffer, " TA: id={} command={}", get_ta().tag_id, get_ta().ta_command);
break;
case mac_sch_subpdu_nr::CON_RES_ID:
fmt::format_to(buffer, " CONRES: len={}", get_total_length());
break;
case mac_sch_subpdu_nr::CON_RES_ID: {
ue_con_res_id_t id = get_ue_con_res_id_ce();
fmt::format_to(buffer,
" CON_RES: id={:x}{:x}{:x}{:x}{:x}{:x}",
id.at(0),
id.at(1),
id.at(2),
id.at(3),
id.at(4),
id.at(5));
} break;
case mac_sch_subpdu_nr::PADDING:
fmt::format_to(buffer, " PAD: len={}", get_sdu_length());
break;
@ -537,6 +573,13 @@ mac_sch_pdu_nr::add_lbsr_ce(const std::array<mac_sch_subpdu_nr::lcg_bsr_t, mac_s
return add_sudpdu(ce);
}
uint32_t mac_sch_pdu_nr::add_ue_con_res_id_ce(const mac_sch_subpdu_nr::ue_con_res_id_t id)
{
mac_sch_subpdu_nr ce(this);
ce.set_ue_con_res_id_ce(id);
return add_sudpdu(ce);
}
uint32_t mac_sch_pdu_nr::add_sudpdu(mac_sch_subpdu_nr& subpdu)
{
uint32_t subpdu_len = subpdu.get_total_length();

Loading…
Cancel
Save