mac_pdu_nr: rename MAC PDU class for NR to adhere naming conventions

* mainly to have _nr as trailing name for filename and class
* also add "sch" to class and filename (RAR PDU will have extra class)
master
Andre Puschmann 4 years ago
parent 6b4a17dc66
commit da9e3363f1

@ -10,8 +10,8 @@
* *
*/ */
#ifndef SRSLTE_MAC_NR_PDU_H #ifndef SRSLTE_MAC_SCH_PDU_NR_H
#define SRSLTE_MAC_NR_PDU_H #define SRSLTE_MAC_SCH_PDU_NR_H
#include "srslte/common/common.h" #include "srslte/common/common.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
@ -22,9 +22,9 @@
namespace srslte { namespace srslte {
class mac_nr_sch_pdu; class mac_sch_pdu_nr;
class mac_nr_sch_subpdu class mac_sch_subpdu_nr
{ {
public: public:
// 3GPP 38.321 v15.3.0 Combined Tables 6.2.1-1, 6.2.1-2 // 3GPP 38.321 v15.3.0 Combined Tables 6.2.1-1, 6.2.1-2
@ -49,7 +49,7 @@ public:
PADDING = 0b111111, PADDING = 0b111111,
} nr_lcid_sch_t; } nr_lcid_sch_t;
mac_nr_sch_subpdu(mac_nr_sch_pdu* parent_); mac_sch_subpdu_nr(mac_sch_pdu_nr* parent_);
nr_lcid_sch_t get_type(); nr_lcid_sch_t get_type();
bool is_sdu(); bool is_sdu();
@ -79,19 +79,19 @@ private:
bool F_bit = false; bool F_bit = false;
uint8_t* sdu = nullptr; uint8_t* sdu = nullptr;
mac_nr_sch_pdu* parent = nullptr; mac_sch_pdu_nr* parent = nullptr;
srslte::log_ref log_h; srslte::log_ref log_h;
}; };
class mac_nr_sch_pdu class mac_sch_pdu_nr
{ {
public: public:
mac_nr_sch_pdu(bool ulsch_ = false) : ulsch(ulsch_) {} mac_sch_pdu_nr(bool ulsch_ = false) : ulsch(ulsch_) {}
void pack(); void pack();
void unpack(const uint8_t* payload, const uint32_t& len); void unpack(const uint8_t* payload, const uint32_t& len);
uint32_t get_num_subpdus(); uint32_t get_num_subpdus();
const mac_nr_sch_subpdu& get_subpdu(const uint32_t& index); const mac_sch_subpdu_nr& get_subpdu(const uint32_t& index);
bool is_ulsch(); bool is_ulsch();
void init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool is_ulsch_ = false); void init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool is_ulsch_ = false);
@ -105,7 +105,7 @@ private:
uint32_t size_header_sdu(const uint32_t lcid_, const uint32_t nbytes); uint32_t size_header_sdu(const uint32_t lcid_, const uint32_t nbytes);
bool ulsch = false; bool ulsch = false;
std::vector<mac_nr_sch_subpdu> subpdus; std::vector<mac_sch_subpdu_nr> subpdus;
byte_buffer_t* buffer = nullptr; byte_buffer_t* buffer = nullptr;
uint32_t pdu_len = 0; uint32_t pdu_len = 0;
@ -114,4 +114,4 @@ private:
} // namespace srslte } // namespace srslte
#endif // SRSLTE_MAC_NR_PDU_H #endif // SRSLTE_MAC_SCH_PDU_NR_H

@ -9,7 +9,7 @@
SET(SOURCES pdu.cc pdu_queue.cc) SET(SOURCES pdu.cc pdu_queue.cc)
if (ENABLE_5GNR) if (ENABLE_5GNR)
set(SOURCES ${SOURCES} mac_nr_pdu.cc) set(SOURCES ${SOURCES} mac_sch_pdu_nr.cc)
endif(ENABLE_5GNR) endif(ENABLE_5GNR)
add_library(srslte_mac STATIC ${SOURCES}) add_library(srslte_mac STATIC ${SOURCES})

@ -10,13 +10,13 @@
* *
*/ */
#include "srslte/mac/mac_nr_pdu.h" #include "srslte/mac/mac_sch_pdu_nr.h"
namespace srslte { namespace srslte {
mac_nr_sch_subpdu::mac_nr_sch_subpdu(mac_nr_sch_pdu* parent_) : parent(parent_), log_h("MAC") {} mac_sch_subpdu_nr::mac_sch_subpdu_nr(mac_sch_pdu_nr* parent_) : parent(parent_), log_h("MAC") {}
mac_nr_sch_subpdu::nr_lcid_sch_t mac_nr_sch_subpdu::get_type() mac_sch_subpdu_nr::nr_lcid_sch_t mac_sch_subpdu_nr::get_type()
{ {
if (lcid >= 32) { if (lcid >= 32) {
return (nr_lcid_sch_t)lcid; return (nr_lcid_sch_t)lcid;
@ -25,25 +25,25 @@ mac_nr_sch_subpdu::nr_lcid_sch_t mac_nr_sch_subpdu::get_type()
return CCCH; return CCCH;
} }
bool mac_nr_sch_subpdu::is_sdu() bool mac_sch_subpdu_nr::is_sdu()
{ {
// for UL-SCH LCID 52 is also valid for carrying SDUs // for UL-SCH LCID 52 is also valid for carrying SDUs
return (lcid <= 32 || (parent->is_ulsch() && lcid == 52)); return (lcid <= 32 || (parent->is_ulsch() && lcid == 52));
} }
// returns false for all reserved values in Table 6.2.1-1 and 6.2.1-2 // returns false for all reserved values in Table 6.2.1-1 and 6.2.1-2
bool mac_nr_sch_subpdu::is_valid_lcid() bool mac_sch_subpdu_nr::is_valid_lcid()
{ {
return (lcid <= 63 && ((parent->is_ulsch() && (lcid <= 32 || lcid >= 52)) || (lcid <= 32 || lcid >= 47))); return (lcid <= 63 && ((parent->is_ulsch() && (lcid <= 32 || lcid >= 52)) || (lcid <= 32 || lcid >= 47)));
} }
bool mac_nr_sch_subpdu::is_var_len_ce() bool mac_sch_subpdu_nr::is_var_len_ce()
{ {
return false; return false;
} }
// return length of PDU (or SRSLTE_ERROR otherwise) // return length of PDU (or SRSLTE_ERROR otherwise)
int32_t mac_nr_sch_subpdu::read_subheader(const uint8_t* ptr) int32_t mac_sch_subpdu_nr::read_subheader(const uint8_t* ptr)
{ {
// Skip R, read F bit and LCID // Skip R, read F bit and LCID
F_bit = (bool)(*ptr & 0x40) ? true : false; F_bit = (bool)(*ptr & 0x40) ? true : false;
@ -75,7 +75,7 @@ int32_t mac_nr_sch_subpdu::read_subheader(const uint8_t* ptr)
return header_length; return header_length;
} }
void mac_nr_sch_subpdu::set_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_) void mac_sch_subpdu_nr::set_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_)
{ {
lcid = lcid_; lcid = lcid_;
sdu = const_cast<uint8_t*>(payload_); sdu = const_cast<uint8_t*>(payload_);
@ -95,7 +95,7 @@ void mac_nr_sch_subpdu::set_sdu(const uint32_t lcid_, const uint8_t* payload_, c
} }
} }
void mac_nr_sch_subpdu::set_padding(const uint32_t len_) void mac_sch_subpdu_nr::set_padding(const uint32_t len_)
{ {
lcid = PADDING; lcid = PADDING;
// 1 Byte R/LCID MAC subheader // 1 Byte R/LCID MAC subheader
@ -104,7 +104,7 @@ void mac_nr_sch_subpdu::set_padding(const uint32_t len_)
} }
// Section 6.1.2 // Section 6.1.2
uint32_t mac_nr_sch_subpdu::write_subpdu(const uint8_t* start_) uint32_t mac_sch_subpdu_nr::write_subpdu(const uint8_t* start_)
{ {
uint8_t* ptr = const_cast<uint8_t*>(start_); uint8_t* ptr = const_cast<uint8_t*>(start_);
*ptr = (uint8_t)((F_bit ? 1 : 0) << 6) | ((uint8_t)lcid & 0x3f); *ptr = (uint8_t)((F_bit ? 1 : 0) << 6) | ((uint8_t)lcid & 0x3f);
@ -141,27 +141,27 @@ uint32_t mac_nr_sch_subpdu::write_subpdu(const uint8_t* start_)
return ptr - start_; return ptr - start_;
} }
uint32_t mac_nr_sch_subpdu::get_total_length() uint32_t mac_sch_subpdu_nr::get_total_length()
{ {
return (header_length + sdu_length); return (header_length + sdu_length);
} }
uint32_t mac_nr_sch_subpdu::get_sdu_length() uint32_t mac_sch_subpdu_nr::get_sdu_length()
{ {
return sdu_length; return sdu_length;
} }
uint32_t mac_nr_sch_subpdu::get_lcid() uint32_t mac_sch_subpdu_nr::get_lcid()
{ {
return lcid; return lcid;
} }
uint8_t* mac_nr_sch_subpdu::get_sdu() uint8_t* mac_sch_subpdu_nr::get_sdu()
{ {
return sdu; return sdu;
} }
uint32_t mac_nr_sch_subpdu::sizeof_ce(uint32_t lcid, bool is_ul) uint32_t mac_sch_subpdu_nr::sizeof_ce(uint32_t lcid, bool is_ul)
{ {
if (is_ul) { if (is_ul) {
switch (lcid) { switch (lcid) {
@ -193,16 +193,16 @@ uint32_t mac_nr_sch_subpdu::sizeof_ce(uint32_t lcid, bool is_ul)
return 0; return 0;
} }
inline bool mac_nr_sch_subpdu::is_ul_ccch() inline bool mac_sch_subpdu_nr::is_ul_ccch()
{ {
return (parent->is_ulsch() && (lcid == CCCH_SIZE_48 || lcid == CCCH_SIZE_64)); return (parent->is_ulsch() && (lcid == CCCH_SIZE_48 || lcid == CCCH_SIZE_64));
} }
void mac_nr_sch_pdu::pack() void mac_sch_pdu_nr::pack()
{ {
// SDUs are written in place, only add padding if needed // SDUs are written in place, only add padding if needed
if (remaining_len) { if (remaining_len) {
mac_nr_sch_subpdu padding_subpdu(this); mac_sch_subpdu_nr padding_subpdu(this);
padding_subpdu.set_padding(remaining_len); padding_subpdu.set_padding(remaining_len);
padding_subpdu.write_subpdu(buffer->msg + buffer->N_bytes); padding_subpdu.write_subpdu(buffer->msg + buffer->N_bytes);
@ -213,17 +213,17 @@ void mac_nr_sch_pdu::pack()
} }
} }
void mac_nr_sch_pdu::unpack(const uint8_t* payload, const uint32_t& len) void mac_sch_pdu_nr::unpack(const uint8_t* payload, const uint32_t& len)
{ {
uint32_t offset = 0; uint32_t offset = 0;
while (offset < len) { while (offset < len) {
mac_nr_sch_subpdu sch_pdu(this); mac_sch_subpdu_nr sch_pdu(this);
if (sch_pdu.read_subheader(payload + offset) == SRSLTE_ERROR) { if (sch_pdu.read_subheader(payload + offset) == SRSLTE_ERROR) {
fprintf(stderr, "Error parsing NR MAC PDU (len=%d, offset=%d)\n", len, offset); fprintf(stderr, "Error parsing NR MAC PDU (len=%d, offset=%d)\n", len, offset);
return; return;
} }
offset += sch_pdu.get_total_length(); offset += sch_pdu.get_total_length();
if (sch_pdu.get_lcid() == mac_nr_sch_subpdu::PADDING) { if (sch_pdu.get_lcid() == mac_sch_subpdu_nr::PADDING) {
// set SDU length to rest of PDU // set SDU length to rest of PDU
sch_pdu.set_padding(len - offset + 1); // One byte for Padding header will be substracted again sch_pdu.set_padding(len - offset + 1); // One byte for Padding header will be substracted again
// skip remaining bytes // skip remaining bytes
@ -236,22 +236,22 @@ void mac_nr_sch_pdu::unpack(const uint8_t* payload, const uint32_t& len)
} }
} }
uint32_t mac_nr_sch_pdu::get_num_subpdus() uint32_t mac_sch_pdu_nr::get_num_subpdus()
{ {
return subpdus.size(); return subpdus.size();
} }
const mac_nr_sch_subpdu& mac_nr_sch_pdu::get_subpdu(const uint32_t& index) const mac_sch_subpdu_nr& mac_sch_pdu_nr::get_subpdu(const uint32_t& index)
{ {
return subpdus.at(index); return subpdus.at(index);
} }
bool mac_nr_sch_pdu::is_ulsch() bool mac_sch_pdu_nr::is_ulsch()
{ {
return ulsch; return ulsch;
} }
void mac_nr_sch_pdu::init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool ulsch_) void mac_sch_pdu_nr::init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool ulsch_)
{ {
buffer = buffer_; buffer = buffer_;
subpdus.clear(); subpdus.clear();
@ -260,7 +260,7 @@ void mac_nr_sch_pdu::init_tx(byte_buffer_t* buffer_, uint32_t pdu_len_, bool uls
ulsch = ulsch_; ulsch = ulsch_;
} }
void mac_nr_sch_pdu::init_rx(bool ulsch_) void mac_sch_pdu_nr::init_rx(bool ulsch_)
{ {
buffer = nullptr; buffer = nullptr;
subpdus.clear(); subpdus.clear();
@ -269,9 +269,9 @@ void mac_nr_sch_pdu::init_rx(bool ulsch_)
ulsch = ulsch_; ulsch = ulsch_;
} }
uint32_t mac_nr_sch_pdu::size_header_sdu(const uint32_t lcid, const uint32_t nbytes) uint32_t mac_sch_pdu_nr::size_header_sdu(const uint32_t lcid, const uint32_t nbytes)
{ {
if (ulsch && (lcid == mac_nr_sch_subpdu::CCCH_SIZE_48 || lcid == mac_nr_sch_subpdu::CCCH_SIZE_64)) { if (ulsch && (lcid == mac_sch_subpdu_nr::CCCH_SIZE_48 || lcid == mac_sch_subpdu_nr::CCCH_SIZE_64)) {
return 1; return 1;
} else { } else {
if (nbytes < 256) { if (nbytes < 256) {
@ -282,12 +282,12 @@ uint32_t mac_nr_sch_pdu::size_header_sdu(const uint32_t lcid, const uint32_t nby
} }
} }
uint32_t mac_nr_sch_pdu::get_remaing_len() uint32_t mac_sch_pdu_nr::get_remaing_len()
{ {
return remaining_len; return remaining_len;
} }
uint32_t mac_nr_sch_pdu::add_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_) uint32_t mac_sch_pdu_nr::add_sdu(const uint32_t lcid_, const uint8_t* payload_, const uint32_t len_)
{ {
int header_size = size_header_sdu(lcid_, len_); int header_size = size_header_sdu(lcid_, len_);
@ -296,7 +296,7 @@ uint32_t mac_nr_sch_pdu::add_sdu(const uint32_t lcid_, const uint8_t* payload_,
return SRSLTE_ERROR; return SRSLTE_ERROR;
} }
mac_nr_sch_subpdu sch_pdu(this); mac_sch_subpdu_nr sch_pdu(this);
sch_pdu.set_sdu(lcid_, payload_, len_); sch_pdu.set_sdu(lcid_, payload_, len_);
uint32_t length = sch_pdu.write_subpdu(buffer->msg + buffer->N_bytes); uint32_t length = sch_pdu.write_subpdu(buffer->msg + buffer->N_bytes);

@ -15,7 +15,7 @@ target_link_libraries(mac_pcap_test srslte_common srslte_mac ${SCTP_LIBRARIES} $
add_test(mac_pcap_test mac_pcap_test) add_test(mac_pcap_test mac_pcap_test)
if (ENABLE_5GNR) if (ENABLE_5GNR)
add_executable(mac_nr_pdu_test mac_nr_pdu_test.cc) add_executable(mac_pdu_nr_test mac_pdu_nr_test.cc)
target_link_libraries(mac_nr_pdu_test srslte_phy srslte_mac srslte_common ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(mac_pdu_nr_test srslte_phy srslte_mac srslte_common ${CMAKE_THREAD_LIBS_INIT})
add_test(mac_nr_pdu_test mac_nr_pdu_test) add_test(mac_pdu_nr_test mac_pdu_nr_test)
endif (ENABLE_5GNR) endif (ENABLE_5GNR)

@ -13,7 +13,7 @@
#include "srslte/common/log_filter.h" #include "srslte/common/log_filter.h"
#include "srslte/common/mac_nr_pcap.h" #include "srslte/common/mac_nr_pcap.h"
#include "srslte/config.h" #include "srslte/config.h"
#include "srslte/mac/mac_nr_pdu.h" #include "srslte/mac/mac_sch_pdu_nr.h"
#include <array> #include <array>
#include <iostream> #include <iostream>
@ -51,11 +51,11 @@ int mac_dl_sch_pdu_unpack_and_pack_test1()
pcap_handle->write_dl_crnti(mac_dl_sch_pdu_1, sizeof(mac_dl_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_dl_crnti(mac_dl_sch_pdu_1, sizeof(mac_dl_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu; srslte::mac_sch_pdu_nr pdu;
pdu.unpack(mac_dl_sch_pdu_1, sizeof(mac_dl_sch_pdu_1)); pdu.unpack(mac_dl_sch_pdu_1, sizeof(mac_dl_sch_pdu_1));
TESTASSERT(pdu.get_num_subpdus() == 1); TESTASSERT(pdu.get_num_subpdus() == 1);
mac_nr_sch_subpdu subpdu = pdu.get_subpdu(0); mac_sch_subpdu_nr subpdu = pdu.get_subpdu(0);
TESTASSERT(subpdu.get_total_length() == 10); TESTASSERT(subpdu.get_total_length() == 10);
TESTASSERT(subpdu.get_sdu_length() == 8); TESTASSERT(subpdu.get_sdu_length() == 8);
TESTASSERT(subpdu.get_lcid() == 0); TESTASSERT(subpdu.get_lcid() == 0);
@ -63,7 +63,7 @@ int mac_dl_sch_pdu_unpack_and_pack_test1()
// pack PDU again // pack PDU again
byte_buffer_t tx_buffer; byte_buffer_t tx_buffer;
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, sizeof(mac_dl_sch_pdu_1)); tx_pdu.init_tx(&tx_buffer, sizeof(mac_dl_sch_pdu_1));
// Add SDU part of TV from above // Add SDU part of TV from above
@ -103,10 +103,10 @@ int mac_dl_sch_pdu_unpack_test2()
pcap_handle->write_dl_crnti(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_dl_crnti(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu; srslte::mac_sch_pdu_nr pdu;
pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2)); pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2));
TESTASSERT(pdu.get_num_subpdus() == 1); TESTASSERT(pdu.get_num_subpdus() == 1);
mac_nr_sch_subpdu subpdu = pdu.get_subpdu(0); mac_sch_subpdu_nr subpdu = pdu.get_subpdu(0);
TESTASSERT(subpdu.get_total_length() == 11); TESTASSERT(subpdu.get_total_length() == 11);
TESTASSERT(subpdu.get_sdu_length() == 8); TESTASSERT(subpdu.get_sdu_length() == 8);
TESTASSERT(subpdu.get_lcid() == 2); TESTASSERT(subpdu.get_lcid() == 2);
@ -133,7 +133,7 @@ int mac_dl_sch_pdu_pack_test3()
// pack buffer // pack buffer
byte_buffer_t tx_buffer; byte_buffer_t tx_buffer;
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, 1024); tx_pdu.init_tx(&tx_buffer, 1024);
// Add SDU // Add SDU
@ -171,7 +171,7 @@ int mac_dl_sch_pdu_pack_test4()
// modify buffer (to be nulled during PDU packing // modify buffer (to be nulled during PDU packing
tx_buffer.msg[4] = 0xaa; tx_buffer.msg[4] = 0xaa;
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, pdu_size); tx_pdu.init_tx(&tx_buffer, pdu_size);
TESTASSERT(tx_pdu.get_remaing_len() == pdu_size); TESTASSERT(tx_pdu.get_remaing_len() == pdu_size);
@ -211,7 +211,7 @@ int mac_dl_sch_pdu_pack_test5()
byte_buffer_t tx_buffer; byte_buffer_t tx_buffer;
tx_buffer.clear(); tx_buffer.clear();
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, pdu_size); tx_pdu.init_tx(&tx_buffer, pdu_size);
// Add SDU part of TV from above // Add SDU part of TV from above
@ -253,7 +253,7 @@ int mac_dl_sch_pdu_unpack_test6()
pcap_handle->write_dl_crnti(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_dl_crnti(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu; srslte::mac_sch_pdu_nr pdu;
pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2)); pdu.unpack(mac_dl_sch_pdu_2, sizeof(mac_dl_sch_pdu_2));
TESTASSERT(pdu.get_num_subpdus() == 0); TESTASSERT(pdu.get_num_subpdus() == 0);
@ -282,19 +282,19 @@ int mac_ul_sch_pdu_unpack_test1()
pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu(true); srslte::mac_sch_pdu_nr pdu(true);
pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1));
TESTASSERT(pdu.get_num_subpdus() == 2); TESTASSERT(pdu.get_num_subpdus() == 2);
// First subpdu is C-RNTI CE // First subpdu is C-RNTI CE
mac_nr_sch_subpdu subpdu0 = pdu.get_subpdu(0); mac_sch_subpdu_nr subpdu0 = pdu.get_subpdu(0);
TESTASSERT(subpdu0.get_total_length() == 3); TESTASSERT(subpdu0.get_total_length() == 3);
TESTASSERT(subpdu0.get_sdu_length() == 2); TESTASSERT(subpdu0.get_sdu_length() == 2);
TESTASSERT(subpdu0.get_lcid() == mac_nr_sch_subpdu::CRNTI); TESTASSERT(subpdu0.get_lcid() == mac_sch_subpdu_nr::CRNTI);
TESTASSERT(memcmp(subpdu0.get_sdu(), (uint8_t*)&ul_sch_crnti, sizeof(ul_sch_crnti)) == 0); TESTASSERT(memcmp(subpdu0.get_sdu(), (uint8_t*)&ul_sch_crnti, sizeof(ul_sch_crnti)) == 0);
// Second subpdu is UL-SCH // Second subpdu is UL-SCH
mac_nr_sch_subpdu subpdu1 = pdu.get_subpdu(1); mac_sch_subpdu_nr subpdu1 = pdu.get_subpdu(1);
TESTASSERT(subpdu1.get_total_length() == 7); TESTASSERT(subpdu1.get_total_length() == 7);
TESTASSERT(subpdu1.get_sdu_length() == 4); TESTASSERT(subpdu1.get_sdu_length() == 4);
TESTASSERT(subpdu1.get_lcid() == 3); TESTASSERT(subpdu1.get_lcid() == 3);
@ -316,11 +316,11 @@ int mac_ul_sch_pdu_unpack_and_pack_test2()
pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu(true); srslte::mac_sch_pdu_nr pdu(true);
pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1));
TESTASSERT(pdu.get_num_subpdus() == 1); TESTASSERT(pdu.get_num_subpdus() == 1);
mac_nr_sch_subpdu subpdu = pdu.get_subpdu(0); mac_sch_subpdu_nr subpdu = pdu.get_subpdu(0);
TESTASSERT(subpdu.get_total_length() == 9); TESTASSERT(subpdu.get_total_length() == 9);
TESTASSERT(subpdu.get_sdu_length() == 8); TESTASSERT(subpdu.get_sdu_length() == 8);
TESTASSERT(subpdu.get_lcid() == 0); TESTASSERT(subpdu.get_lcid() == 0);
@ -328,7 +328,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test2()
// pack PDU again // pack PDU again
byte_buffer_t tx_buffer; byte_buffer_t tx_buffer;
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true); tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true);
// Add SDU part of TV from above // Add SDU part of TV from above
@ -365,11 +365,11 @@ int mac_ul_sch_pdu_unpack_and_pack_test3()
pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu(true); srslte::mac_sch_pdu_nr pdu(true);
pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1));
TESTASSERT(pdu.get_num_subpdus() == 1); TESTASSERT(pdu.get_num_subpdus() == 1);
mac_nr_sch_subpdu subpdu = pdu.get_subpdu(0); mac_sch_subpdu_nr subpdu = pdu.get_subpdu(0);
TESTASSERT(subpdu.get_total_length() == 12); TESTASSERT(subpdu.get_total_length() == 12);
TESTASSERT(subpdu.get_sdu_length() == 10); TESTASSERT(subpdu.get_sdu_length() == 10);
TESTASSERT(subpdu.get_lcid() == 2); TESTASSERT(subpdu.get_lcid() == 2);
@ -377,7 +377,7 @@ int mac_ul_sch_pdu_unpack_and_pack_test3()
// pack PDU again // pack PDU again
byte_buffer_t tx_buffer; byte_buffer_t tx_buffer;
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true); tx_pdu.init_tx(&tx_buffer, sizeof(mac_ul_sch_pdu_1), true);
// Add SDU part of TV from above // Add SDU part of TV from above
@ -418,7 +418,7 @@ int mac_ul_sch_pdu_pack_test4()
// pack PDU again // pack PDU again
byte_buffer_t tx_buffer; byte_buffer_t tx_buffer;
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
tx_pdu.init_tx(&tx_buffer, sizeof(sdu) + 3, true); tx_pdu.init_tx(&tx_buffer, sizeof(sdu) + 3, true);
// Add SDU part of TV from above // Add SDU part of TV from above
@ -454,7 +454,7 @@ int mac_ul_sch_pdu_unpack_test5()
pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI); pcap_handle->write_ul_crnti(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1), PCAP_CRNTI, true, PCAP_TTI);
} }
srslte::mac_nr_sch_pdu pdu(true); srslte::mac_sch_pdu_nr pdu(true);
pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1)); pdu.unpack(mac_ul_sch_pdu_1, sizeof(mac_ul_sch_pdu_1));
TESTASSERT(pdu.get_num_subpdus() == 0); TESTASSERT(pdu.get_num_subpdus() == 0);

@ -16,7 +16,7 @@
#include "srslte/common/block_queue.h" #include "srslte/common/block_queue.h"
#include "srslte/common/logmap.h" #include "srslte/common/logmap.h"
#include "srslte/common/mac_nr_pcap.h" #include "srslte/common/mac_nr_pcap.h"
#include "srslte/mac/mac_nr_pdu.h" #include "srslte/mac/mac_sch_pdu_nr.h"
#include "srsenb/hdr/stack/enb_stack_base.h" #include "srsenb/hdr/stack/enb_stack_base.h"
#include "srslte/interfaces/enb_metrics_interface.h" #include "srslte/interfaces/enb_metrics_interface.h"
@ -100,14 +100,14 @@ private:
srslte::unique_byte_buffer_t bcch_bch_payload = nullptr; srslte::unique_byte_buffer_t bcch_bch_payload = nullptr;
// UE-specific buffer // UE-specific buffer
srslte::mac_nr_sch_pdu ue_tx_pdu; srslte::mac_sch_pdu_nr ue_tx_pdu;
std::vector<srslte::unique_byte_buffer_t> ue_tx_buffer; std::vector<srslte::unique_byte_buffer_t> ue_tx_buffer;
srslte::block_queue<srslte::unique_byte_buffer_t> srslte::block_queue<srslte::unique_byte_buffer_t>
ue_rx_pdu_queue; ///< currently only DCH PDUs supported (add BCH, PCH, etc) ue_rx_pdu_queue; ///< currently only DCH PDUs supported (add BCH, PCH, etc)
srslte::unique_byte_buffer_t ue_rlc_buffer; srslte::unique_byte_buffer_t ue_rlc_buffer;
srslte::mac_nr_sch_pdu ue_rx_pdu; srslte::mac_sch_pdu_nr ue_rx_pdu;
}; };
} // namespace srsenb } // namespace srsenb

@ -222,7 +222,7 @@ int mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu)
ue_rx_pdu.unpack(pdu->msg, pdu->N_bytes); ue_rx_pdu.unpack(pdu->msg, pdu->N_bytes);
for (uint32_t i = 0; i < ue_rx_pdu.get_num_subpdus(); ++i) { for (uint32_t i = 0; i < ue_rx_pdu.get_num_subpdus(); ++i) {
srslte::mac_nr_sch_subpdu subpdu = ue_rx_pdu.get_subpdu(i); srslte::mac_sch_subpdu_nr subpdu = ue_rx_pdu.get_subpdu(i);
log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d\n", log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d\n",
i, i,
ue_rx_pdu.get_num_subpdus(), ue_rx_pdu.get_num_subpdus(),

@ -18,7 +18,7 @@
#include "srslte/common/mac_nr_pcap.h" #include "srslte/common/mac_nr_pcap.h"
#include "srslte/interfaces/mac_interface_types.h" #include "srslte/interfaces/mac_interface_types.h"
#include "srslte/interfaces/ue_nr_interfaces.h" #include "srslte/interfaces/ue_nr_interfaces.h"
#include "srslte/mac/mac_nr_pdu.h" #include "srslte/mac/mac_sch_pdu_nr.h"
#include "srsue/hdr/stack/mac/mux.h" #include "srsue/hdr/stack/mac/mux.h"
#include "srsue/hdr/stack/ue_stack_base.h" #include "srsue/hdr/stack/ue_stack_base.h"
@ -94,10 +94,10 @@ private:
mac_metrics_t metrics[SRSLTE_MAX_CARRIERS] = {}; mac_metrics_t metrics[SRSLTE_MAX_CARRIERS] = {};
/// Rx buffer /// Rx buffer
srslte::mac_nr_sch_pdu rx_pdu; srslte::mac_sch_pdu_nr rx_pdu;
/// Tx buffer /// Tx buffer
srslte::mac_nr_sch_pdu tx_pdu; srslte::mac_sch_pdu_nr tx_pdu;
srslte::unique_byte_buffer_t tx_buffer = nullptr; srslte::unique_byte_buffer_t tx_buffer = nullptr;
srslte::unique_byte_buffer_t rlc_buffer = nullptr; srslte::unique_byte_buffer_t rlc_buffer = nullptr;

@ -241,7 +241,7 @@ void mac_nr::handle_pdu(srslte::unique_byte_buffer_t pdu)
rx_pdu.unpack(pdu->msg, pdu->N_bytes); rx_pdu.unpack(pdu->msg, pdu->N_bytes);
for (uint32_t i = 0; i < rx_pdu.get_num_subpdus(); ++i) { for (uint32_t i = 0; i < rx_pdu.get_num_subpdus(); ++i) {
srslte::mac_nr_sch_subpdu subpdu = rx_pdu.get_subpdu(i); srslte::mac_sch_subpdu_nr subpdu = rx_pdu.get_subpdu(i);
log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d", log_h->info("Handling subPDU %d/%d: lcid=%d, sdu_len=%d",
i, i,
rx_pdu.get_num_subpdus(), rx_pdu.get_num_subpdus(),

Loading…
Cancel
Save