mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
3.2 KiB
C
108 lines
3.2 KiB
C
4 years ago
|
/**
|
||
|
*
|
||
|
* \section COPYRIGHT
|
||
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
4 years ago
|
*
|
||
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
|
*
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef SRSRAN_MAC_RAR_PDU_NR_H
|
||
|
#define SRSRAN_MAC_RAR_PDU_NR_H
|
||
4 years ago
|
|
||
4 years ago
|
#include "srsran/common/common.h"
|
||
|
#include "srsran/config.h"
|
||
|
#include "srsran/phy/common/phy_common_nr.h"
|
||
|
#include "srsran/srslog/srslog.h"
|
||
4 years ago
|
#include <memory>
|
||
|
#include <stdint.h>
|
||
|
#include <vector>
|
||
|
|
||
4 years ago
|
namespace srsran {
|
||
4 years ago
|
|
||
|
class mac_rar_pdu_nr;
|
||
|
|
||
|
// 3GPP 38.321 v15.3.0 Sec 6.1.5
|
||
|
class mac_rar_subpdu_nr
|
||
|
{
|
||
|
public:
|
||
|
// Possible types of RAR subpdus (same like EUTRA)
|
||
|
typedef enum { BACKOFF = 0, RAPID } rar_subh_type_t;
|
||
|
|
||
|
mac_rar_subpdu_nr(mac_rar_pdu_nr* parent_);
|
||
|
|
||
|
// RAR content length in bits (38.321 Sec 6.2.3)
|
||
4 years ago
|
static const uint32_t UL_GRANT_NBITS = SRSRAN_RAR_UL_GRANT_NBITS;
|
||
4 years ago
|
static const uint32_t TA_COMMAND_NBITS = 12;
|
||
|
|
||
|
// getter
|
||
|
bool read_subpdu(const uint8_t* ptr);
|
||
|
bool has_more_subpdus();
|
||
|
uint32_t get_total_length();
|
||
4 years ago
|
bool has_rapid() const;
|
||
|
uint8_t get_rapid() const;
|
||
|
uint16_t get_temp_crnti() const;
|
||
|
uint32_t get_ta() const;
|
||
|
std::array<uint8_t, UL_GRANT_NBITS> get_ul_grant() const;
|
||
|
bool has_backoff() const;
|
||
|
uint8_t get_backoff() const;
|
||
4 years ago
|
|
||
|
// setter
|
||
|
uint32_t write_subpdu(const uint8_t* start_);
|
||
|
void set_backoff(const uint8_t backoff_indicator_);
|
||
|
|
||
|
std::string to_string();
|
||
|
|
||
|
private:
|
||
|
int header_length = 1; // RAR PDU subheader is always 1 B
|
||
|
int payload_length = 0; // only used if MAC RAR is included
|
||
|
|
||
|
std::array<uint8_t, UL_GRANT_NBITS> ul_grant = {};
|
||
|
uint16_t ta = 0; // 12bit TA
|
||
|
uint16_t temp_crnti = 0;
|
||
|
uint16_t rapid = 0;
|
||
|
uint8_t backoff_indicator = 0;
|
||
|
rar_subh_type_t type = BACKOFF;
|
||
|
bool E_bit = 0;
|
||
|
|
||
|
srslog::basic_logger& logger;
|
||
|
|
||
|
mac_rar_pdu_nr* parent = nullptr;
|
||
|
};
|
||
|
|
||
|
class mac_rar_pdu_nr
|
||
|
{
|
||
|
public:
|
||
|
mac_rar_pdu_nr();
|
||
|
~mac_rar_pdu_nr() = default;
|
||
|
|
||
|
bool pack();
|
||
|
bool unpack(const uint8_t* payload, const uint32_t& len);
|
||
|
uint32_t get_num_subpdus();
|
||
4 years ago
|
// Returns reference to a single subPDU
|
||
4 years ago
|
const mac_rar_subpdu_nr& get_subpdu(const uint32_t& index);
|
||
4 years ago
|
// Returns reference to all subPDUs
|
||
|
const std::vector<mac_rar_subpdu_nr>& get_subpdus();
|
||
4 years ago
|
|
||
|
uint32_t get_remaining_len();
|
||
|
|
||
|
void set_si_rapid(uint16_t si_rapid_); // configured through SIB1 for on-demand SI request (See 38.331 Sec 5.2.1)
|
||
|
bool has_si_rapid();
|
||
|
|
||
|
std::string to_string();
|
||
|
|
||
|
private:
|
||
|
std::vector<mac_rar_subpdu_nr> subpdus;
|
||
|
uint32_t remaining_len = 0;
|
||
|
uint16_t si_rapid = 0;
|
||
|
bool si_rapid_set = false;
|
||
|
srslog::basic_logger& logger;
|
||
|
};
|
||
|
|
||
4 years ago
|
} // namespace srsran
|
||
4 years ago
|
|
||
4 years ago
|
#endif // SRSRAN_MAC_RAR_PDU_NR_H
|