Commit b99b6b54 authored by aligungr's avatar aligungr

Performance improvements

parent 455d044f
...@@ -228,7 +228,7 @@ void UeCmdHandler::handleCmdImpl(NmUeCliCommand &msg) ...@@ -228,7 +228,7 @@ void UeCmdHandler::handleCmdImpl(NmUeCliCommand &msg)
case app::UeCliCommand::COVERAGE: { case app::UeCliCommand::COVERAGE: {
Json json = Json::Obj({}); Json json = Json::Obj({});
const auto &cells = m_base->rrcTask->m_cellDesc; const auto &cells = m_base->rrcTask->layer->m_cellDesc;
for (auto &item : cells) for (auto &item : cells)
{ {
auto &cell = item.second; auto &cell = item.second;
......
...@@ -132,18 +132,6 @@ struct NmUeRrcToRls : NtsMessage ...@@ -132,18 +132,6 @@ struct NmUeRrcToRls : NtsMessage
} }
}; };
struct NmUeRrcToRrc : NtsMessage
{
enum PR
{
TRIGGER_CYCLE,
} present;
explicit NmUeRrcToRrc(PR present) : NtsMessage(NtsMessageType::UE_RRC_TO_RRC), present(present)
{
}
};
struct NmUeRlsToRrc : NtsMessage struct NmUeRlsToRrc : NtsMessage
{ {
enum PR enum PR
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::performUac(std::shared_ptr<LightSync<UacInput, UacOutput>> &uacCtl) void UeRrcLayer::performUac(std::shared_ptr<LightSync<UacInput, UacOutput>> &uacCtl)
{ {
auto &input = uacCtl->input(); auto &input = uacCtl->input();
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::handleCellSignalChange(int cellId, int dbm) void UeRrcLayer::handleCellSignalChange(int cellId, int dbm)
{ {
bool considerLost = dbm < -120; bool considerLost = dbm < -120;
...@@ -32,7 +32,7 @@ void UeRrcTask::handleCellSignalChange(int cellId, int dbm) ...@@ -32,7 +32,7 @@ void UeRrcTask::handleCellSignalChange(int cellId, int dbm)
} }
} }
void UeRrcTask::notifyCellDetected(int cellId, int dbm) void UeRrcLayer::notifyCellDetected(int cellId, int dbm)
{ {
m_cellDesc[cellId] = {}; m_cellDesc[cellId] = {};
m_cellDesc[cellId].dbm = dbm; m_cellDesc[cellId].dbm = dbm;
...@@ -43,7 +43,7 @@ void UeRrcTask::notifyCellDetected(int cellId, int dbm) ...@@ -43,7 +43,7 @@ void UeRrcTask::notifyCellDetected(int cellId, int dbm)
updateAvailablePlmns(); updateAvailablePlmns();
} }
void UeRrcTask::notifyCellLost(int cellId) void UeRrcLayer::notifyCellLost(int cellId)
{ {
if (!m_cellDesc.count(cellId)) if (!m_cellDesc.count(cellId))
return; return;
...@@ -79,17 +79,17 @@ void UeRrcTask::notifyCellLost(int cellId) ...@@ -79,17 +79,17 @@ void UeRrcTask::notifyCellLost(int cellId)
updateAvailablePlmns(); updateAvailablePlmns();
} }
bool UeRrcTask::hasSignalToCell(int cellId) bool UeRrcLayer::hasSignalToCell(int cellId)
{ {
return m_cellDesc.count(cellId); return m_cellDesc.count(cellId);
} }
bool UeRrcTask::isActiveCell(int cellId) bool UeRrcLayer::isActiveCell(int cellId)
{ {
return m_base->shCtx.currentCell.get<int>([](auto &value) { return value.cellId; }) == cellId; return m_base->shCtx.currentCell.get<int>([](auto &value) { return value.cellId; }) == cellId;
} }
void UeRrcTask::updateAvailablePlmns() void UeRrcLayer::updateAvailablePlmns()
{ {
m_base->shCtx.availablePlmns.mutate([this](std::unordered_set<Plmn> &value) { m_base->shCtx.availablePlmns.mutate([this](std::unordered_set<Plmn> &value) {
value.clear(); value.clear();
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const OctetString &rrcPdu) void UeRrcLayer::handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const OctetString &rrcPdu)
{ {
if (!hasSignalToCell(cellId)) if (!hasSignalToCell(cellId))
return; return;
...@@ -84,7 +84,7 @@ void UeRrcTask::handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const Oct ...@@ -84,7 +84,7 @@ void UeRrcTask::handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const Oct
} }
} }
void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg) void UeRrcLayer::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_CCCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_CCCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -100,7 +100,7 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg) ...@@ -100,7 +100,7 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg)
m_base->rlsTask->push(std::move(m)); m_base->rlsTask->push(std::move(m));
} }
void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg) void UeRrcLayer::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_CCCH1_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_CCCH1_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -116,7 +116,7 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg) ...@@ -116,7 +116,7 @@ void UeRrcTask::sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg)
m_base->rlsTask->push(std::move(m)); m_base->rlsTask->push(std::move(m));
} }
void UeRrcTask::sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg) void UeRrcLayer::sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg)
{ {
OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_DCCH_Message, msg); OctetString pdu = rrc::encode::EncodeS(asn_DEF_ASN_RRC_UL_DCCH_Message, msg);
if (pdu.length() == 0) if (pdu.length() == 0)
...@@ -132,13 +132,13 @@ void UeRrcTask::sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg) ...@@ -132,13 +132,13 @@ void UeRrcTask::sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg)
m_base->rlsTask->push(std::move(m)); m_base->rlsTask->push(std::move(m));
} }
void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_BCCH_BCH_Message *msg) void UeRrcLayer::receiveRrcMessage(int cellId, ASN_RRC_BCCH_BCH_Message *msg)
{ {
if (msg->message.present == ASN_RRC_BCCH_BCH_MessageType_PR_mib) if (msg->message.present == ASN_RRC_BCCH_BCH_MessageType_PR_mib)
receiveMib(cellId, *msg->message.choice.mib); receiveMib(cellId, *msg->message.choice.mib);
} }
void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg) void UeRrcLayer::receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg)
{ {
if (msg->message.present != ASN_RRC_BCCH_DL_SCH_MessageType_PR_c1) if (msg->message.present != ASN_RRC_BCCH_DL_SCH_MessageType_PR_c1)
return; return;
...@@ -154,7 +154,7 @@ void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg) ...@@ -154,7 +154,7 @@ void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg)
} }
} }
void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg) void UeRrcLayer::receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg)
{ {
if (msg->message.present != ASN_RRC_DL_CCCH_MessageType_PR_c1) if (msg->message.present != ASN_RRC_DL_CCCH_MessageType_PR_c1)
return; return;
...@@ -173,7 +173,7 @@ void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg) ...@@ -173,7 +173,7 @@ void UeRrcTask::receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg)
} }
} }
void UeRrcTask::receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg) void UeRrcLayer::receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg)
{ {
if (msg->message.present != ASN_RRC_DL_DCCH_MessageType_PR_c1) if (msg->message.present != ASN_RRC_DL_DCCH_MessageType_PR_c1)
return; return;
...@@ -192,7 +192,7 @@ void UeRrcTask::receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg) ...@@ -192,7 +192,7 @@ void UeRrcTask::receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg)
} }
} }
void UeRrcTask::receiveRrcMessage(ASN_RRC_PCCH_Message *msg) void UeRrcLayer::receiveRrcMessage(ASN_RRC_PCCH_Message *msg)
{ {
if (msg->message.present != ASN_RRC_PCCH_MessageType_PR_c1) if (msg->message.present != ASN_RRC_PCCH_MessageType_PR_c1)
return; return;
......
...@@ -39,7 +39,7 @@ static ASN_RRC_UL_CCCH_Message *ConstructSetupRequest(ASN_RRC_InitialUE_Identity ...@@ -39,7 +39,7 @@ static ASN_RRC_UL_CCCH_Message *ConstructSetupRequest(ASN_RRC_InitialUE_Identity
return pdu; return pdu;
} }
void UeRrcTask::startConnectionEstablishment(OctetString &&nasPdu) void UeRrcLayer::startConnectionEstablishment(OctetString &&nasPdu)
{ {
/* Check the protocol state */ /* Check the protocol state */
if (m_state != ERrcState::RRC_IDLE) if (m_state != ERrcState::RRC_IDLE)
...@@ -88,7 +88,7 @@ void UeRrcTask::startConnectionEstablishment(OctetString &&nasPdu) ...@@ -88,7 +88,7 @@ void UeRrcTask::startConnectionEstablishment(OctetString &&nasPdu)
asn::Free(asn_DEF_ASN_RRC_UL_CCCH_Message, rrcSetupRequest); asn::Free(asn_DEF_ASN_RRC_UL_CCCH_Message, rrcSetupRequest);
} }
void UeRrcTask::receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg) void UeRrcLayer::receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg)
{ {
if (!isActiveCell(cellId)) if (!isActiveCell(cellId))
return; return;
...@@ -133,7 +133,7 @@ void UeRrcTask::receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg) ...@@ -133,7 +133,7 @@ void UeRrcTask::receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg)
m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RRC_CONNECTION_SETUP)); m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RRC_CONNECTION_SETUP));
} }
void UeRrcTask::receiveRrcReject(int cellId, const ASN_RRC_RRCReject &msg) void UeRrcLayer::receiveRrcReject(int cellId, const ASN_RRC_RRCReject &msg)
{ {
if (!isActiveCell(cellId)) if (!isActiveCell(cellId))
return; return;
...@@ -143,14 +143,14 @@ void UeRrcTask::receiveRrcReject(int cellId, const ASN_RRC_RRCReject &msg) ...@@ -143,14 +143,14 @@ void UeRrcTask::receiveRrcReject(int cellId, const ASN_RRC_RRCReject &msg)
handleEstablishmentFailure(); handleEstablishmentFailure();
} }
void UeRrcTask::receiveRrcRelease(const ASN_RRC_RRCRelease &msg) void UeRrcLayer::receiveRrcRelease(const ASN_RRC_RRCRelease &msg)
{ {
m_logger->debug("RRC Release received"); m_logger->debug("RRC Release received");
m_state = ERrcState::RRC_IDLE; m_state = ERrcState::RRC_IDLE;
m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RRC_CONNECTION_RELEASE)); m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RRC_CONNECTION_RELEASE));
} }
void UeRrcTask::handleEstablishmentFailure() void UeRrcLayer::handleEstablishmentFailure()
{ {
m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RRC_ESTABLISHMENT_FAILURE)); m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RRC_ESTABLISHMENT_FAILURE));
} }
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::declareRadioLinkFailure(rls::ERlfCause cause) void UeRrcLayer::declareRadioLinkFailure(rls::ERlfCause cause)
{ {
handleRadioLinkFailure(cause); handleRadioLinkFailure(cause);
} }
void UeRrcTask::handleRadioLinkFailure(rls::ERlfCause cause) void UeRrcLayer::handleRadioLinkFailure(rls::ERlfCause cause)
{ {
m_state = ERrcState::RRC_IDLE; m_state = ERrcState::RRC_IDLE;
m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RADIO_LINK_FAILURE)); m_base->nasTask->push(std::make_unique<NmUeRrcToNas>(NmUeRrcToNas::RADIO_LINK_FAILURE));
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::receivePaging(const ASN_RRC_Paging &msg) void UeRrcLayer::receivePaging(const ASN_RRC_Paging &msg)
{ {
std::vector<GutiMobileIdentity> tmsiIds{}; std::vector<GutiMobileIdentity> tmsiIds{};
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::performCellSelection() void UeRrcLayer::performCellSelection()
{ {
if (m_state == ERrcState::RRC_CONNECTED) if (m_state == ERrcState::RRC_CONNECTED)
return; return;
...@@ -110,7 +110,7 @@ void UeRrcTask::performCellSelection() ...@@ -110,7 +110,7 @@ void UeRrcTask::performCellSelection()
} }
} }
bool UeRrcTask::lookForSuitableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report) bool UeRrcLayer::lookForSuitableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report)
{ {
Plmn selectedPlmn = m_base->shCtx.selectedPlmn.get(); Plmn selectedPlmn = m_base->shCtx.selectedPlmn.get();
if (!selectedPlmn.hasValue()) if (!selectedPlmn.hasValue())
...@@ -196,7 +196,7 @@ bool UeRrcTask::lookForSuitableCell(ActiveCellInfo &cellInfo, CellSelectionRepor ...@@ -196,7 +196,7 @@ bool UeRrcTask::lookForSuitableCell(ActiveCellInfo &cellInfo, CellSelectionRepor
return true; return true;
} }
bool UeRrcTask::lookForAcceptableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report) bool UeRrcLayer::lookForAcceptableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report)
{ {
std::vector<int> candidates; std::vector<int> candidates;
......
#include "layer.hpp"
#include <asn/rrc/ASN_RRC_RRCSetupRequest-IEs.h>
#include <asn/rrc/ASN_RRC_RRCSetupRequest.h>
#include <asn/rrc/ASN_RRC_ULInformationTransfer-IEs.h>
#include <asn/rrc/ASN_RRC_ULInformationTransfer.h>
#include <lib/rrc/encode.hpp>
#include <ue/app/task.hpp>
#include <ue/nas/task.hpp>
#include <ue/rls/task.hpp>
#include <utils/common.hpp>
namespace nr::ue
{
UeRrcLayer::UeRrcLayer(TaskBase *base) : m_base{base}, m_timers{}
{
m_logger = base->logBase->makeUniqueLogger(base->config->getLoggerPrefix() + "rrc");
m_startedTime = utils::CurrentTimeMillis();
m_state = ERrcState::RRC_IDLE;
m_establishmentCause = ASN_RRC_EstablishmentCause_mt_Access;
}
void UeRrcLayer::onStart()
{
triggerCycle();
}
void UeRrcLayer::onQuit()
{
// TODO
}
} // namespace nr::ue
\ No newline at end of file
#pragma once
#include <unordered_map>
#include <ue/nts.hpp>
#include <ue/types.hpp>
#include <utils/logger.hpp>
#include <utils/nts.hpp>
#include <asn/rrc/ASN_RRC_InitialUE-Identity.h>
extern "C"
{
struct ASN_RRC_BCCH_BCH_Message;
struct ASN_RRC_BCCH_DL_SCH_Message;
struct ASN_RRC_DL_CCCH_Message;
struct ASN_RRC_DL_DCCH_Message;
struct ASN_RRC_PCCH_Message;
struct ASN_RRC_UL_CCCH_Message;
struct ASN_RRC_UL_CCCH1_Message;
struct ASN_RRC_UL_DCCH_Message;
struct ASN_RRC_RRCSetupRequest;
struct ASN_RRC_DLInformationTransfer;
struct ASN_RRC_ULInformationTransfer;
struct ASN_RRC_RRCSetup;
struct ASN_RRC_RRCReject;
struct ASN_RRC_RRCRelease;
struct ASN_RRC_Paging;
struct ASN_RRC_MIB;
struct ASN_RRC_SIB1;
}
namespace nr::ue
{
class UeRrcLayer
{
private:
TaskBase *m_base;
std::unique_ptr<Logger> m_logger;
int64_t m_startedTime;
ERrcState m_state;
RrcTimers m_timers;
/* Cell and PLMN related */
std::unordered_map<int, UeCellDesc> m_cellDesc{};
int64_t m_lastTimePlmnSearchFailureLogged{};
/* Procedure related */
ERrcLastSetupRequest m_lastSetupReq{};
/* Establishment procedure related */
int m_establishmentCause{};
ASN_RRC_InitialUE_Identity_t m_initialId{};
OctetString m_initialNasPdu{};
friend class UeCmdHandler;
friend class UeRrcTask;
public:
explicit UeRrcLayer(TaskBase *base);
~UeRrcLayer() = default;
public:
void onStart();
void onQuit();
private:
/* Handlers */
void receivePaging(const ASN_RRC_Paging &msg);
/* RRC Message Transmission and Receive */
void handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const OctetString &pdu);
void sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg);
void sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg);
void sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_BCCH_BCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg);
void receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg);
void receiveRrcMessage(ASN_RRC_PCCH_Message *msg);
/* Service Access Point */
void handleRlsSapMessage(NmUeRlsToRrc &msg);
void handleNasSapMessage(NmUeNasToRrc &msg);
/* State Management */
void triggerCycle();
void performCycle();
void switchState(ERrcState state);
void onSwitchState(ERrcState oldState, ERrcState newState);
/* Idle Mode Operations */
void performCellSelection();
bool lookForSuitableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report);
bool lookForAcceptableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report);
/* Cell Management */
void handleCellSignalChange(int cellId, int dbm);
void notifyCellDetected(int cellId, int dbm);
void notifyCellLost(int cellId);
bool hasSignalToCell(int cellId);
bool isActiveCell(int cellId);
void updateAvailablePlmns();
/* System Information and Broadcast */
void receiveMib(int cellId, const ASN_RRC_MIB &msg);
void receiveSib1(int cellId, const ASN_RRC_SIB1 &msg);
/* NAS Transport */
void deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu);
void receiveDownlinkInformationTransfer(const ASN_RRC_DLInformationTransfer &msg);
/* Connection Control */
void startConnectionEstablishment(OctetString &&nasPdu);
void handleEstablishmentFailure();
void receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg);
void receiveRrcReject(int cellId, const ASN_RRC_RRCReject &msg);
void receiveRrcRelease(const ASN_RRC_RRCRelease &msg);
/* Failures */
void declareRadioLinkFailure(rls::ERlfCause cause);
void handleRadioLinkFailure(rls::ERlfCause cause);
/* Access Control */
void performUac(std::shared_ptr<LightSync<UacInput, UacOutput>> &uacCtl);
};
}
\ No newline at end of file
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu) void UeRrcLayer::deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu)
{ {
if (!m_base->shCtx.currentCell.get<bool>([](auto &value) { return value.hasValue(); })) if (!m_base->shCtx.currentCell.get<bool>([](auto &value) { return value.hasValue(); }))
{ {
...@@ -60,7 +60,7 @@ void UeRrcTask::deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu) ...@@ -60,7 +60,7 @@ void UeRrcTask::deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu)
asn::Free(asn_DEF_ASN_RRC_UL_DCCH_Message, pdu); asn::Free(asn_DEF_ASN_RRC_UL_DCCH_Message, pdu);
} }
void UeRrcTask::receiveDownlinkInformationTransfer(const ASN_RRC_DLInformationTransfer &msg) void UeRrcLayer::receiveDownlinkInformationTransfer(const ASN_RRC_DLInformationTransfer &msg)
{ {
OctetString nasPdu = OctetString nasPdu =
asn::GetOctetString(*msg.criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message); asn::GetOctetString(*msg.criticalExtensions.choice.dlInformationTransfer->dedicatedNAS_Message);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::handleRlsSapMessage(NmUeRlsToRrc &msg) void UeRrcLayer::handleRlsSapMessage(NmUeRlsToRrc &msg)
{ {
switch (msg.present) switch (msg.present)
{ {
...@@ -35,7 +35,7 @@ void UeRrcTask::handleRlsSapMessage(NmUeRlsToRrc &msg) ...@@ -35,7 +35,7 @@ void UeRrcTask::handleRlsSapMessage(NmUeRlsToRrc &msg)
} }
} }
void UeRrcTask::handleNasSapMessage(NmUeNasToRrc &msg) void UeRrcLayer::handleNasSapMessage(NmUeNasToRrc &msg)
{ {
switch (msg.present) switch (msg.present)
{ {
......
...@@ -16,12 +16,12 @@ ...@@ -16,12 +16,12 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::triggerCycle() void UeRrcLayer::triggerCycle()
{ {
push(std::make_unique<NmUeRrcToRrc>(NmUeRrcToRrc::TRIGGER_CYCLE)); m_base->rrcTask->push(std::make_unique<NmCycleRequired>());
} }
void UeRrcTask::performCycle() void UeRrcLayer::performCycle()
{ {
if (m_state == ERrcState::RRC_CONNECTED) if (m_state == ERrcState::RRC_CONNECTED)
{ {
...@@ -36,7 +36,7 @@ void UeRrcTask::performCycle() ...@@ -36,7 +36,7 @@ void UeRrcTask::performCycle()
} }
} }
void UeRrcTask::switchState(ERrcState state) void UeRrcLayer::switchState(ERrcState state)
{ {
ERrcState oldState = m_state; ERrcState oldState = m_state;
m_state = state; m_state = state;
...@@ -52,7 +52,7 @@ void UeRrcTask::switchState(ERrcState state) ...@@ -52,7 +52,7 @@ void UeRrcTask::switchState(ERrcState state)
onSwitchState(oldState, state); onSwitchState(oldState, state);
} }
void UeRrcTask::onSwitchState(ERrcState oldState, ERrcState newState) void UeRrcLayer::onSwitchState(ERrcState oldState, ERrcState newState)
{ {
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
namespace nr::ue namespace nr::ue
{ {
void UeRrcTask::receiveMib(int cellId, const ASN_RRC_MIB &msg) void UeRrcLayer::receiveMib(int cellId, const ASN_RRC_MIB &msg)
{ {
auto &desc = m_cellDesc[cellId]; auto &desc = m_cellDesc[cellId];
...@@ -34,7 +34,7 @@ void UeRrcTask::receiveMib(int cellId, const ASN_RRC_MIB &msg) ...@@ -34,7 +34,7 @@ void UeRrcTask::receiveMib(int cellId, const ASN_RRC_MIB &msg)
updateAvailablePlmns(); updateAvailablePlmns();
} }
void UeRrcTask::receiveSib1(int cellId, const ASN_RRC_SIB1 &msg) void UeRrcLayer::receiveSib1(int cellId, const ASN_RRC_SIB1 &msg)
{ {
auto &desc = m_cellDesc[cellId]; auto &desc = m_cellDesc[cellId];
......
...@@ -23,25 +23,21 @@ static constexpr const int TIMER_PERIOD_MACHINE_CYCLE = 2500; ...@@ -23,25 +23,21 @@ static constexpr const int TIMER_PERIOD_MACHINE_CYCLE = 2500;
namespace nr::ue namespace nr::ue
{ {
UeRrcTask::UeRrcTask(TaskBase *base) : m_base{base}, m_timers{} UeRrcTask::UeRrcTask(TaskBase *base)
{ {
m_logger = base->logBase->makeUniqueLogger(base->config->getLoggerPrefix() + "rrc"); layer = std::make_unique<UeRrcLayer>(base);
m_startedTime = utils::CurrentTimeMillis();
m_state = ERrcState::RRC_IDLE;
m_establishmentCause = ASN_RRC_EstablishmentCause_mt_Access;
} }
void UeRrcTask::onStart() void UeRrcTask::onStart()
{ {
triggerCycle(); layer->onStart();
setTimer(TIMER_ID_MACHINE_CYCLE, TIMER_PERIOD_MACHINE_CYCLE); setTimer(TIMER_ID_MACHINE_CYCLE, TIMER_PERIOD_MACHINE_CYCLE);
} }
void UeRrcTask::onQuit() void UeRrcTask::onQuit()
{ {
// TODO layer->onQuit();
} }
void UeRrcTask::onLoop() void UeRrcTask::onLoop()
...@@ -50,38 +46,26 @@ void UeRrcTask::onLoop() ...@@ -50,38 +46,26 @@ void UeRrcTask::onLoop()
if (!msg) if (!msg)
return; return;
switch (msg->msgType) if (msg->msgType == NtsMessageType::UE_CYCLE_REQUIRED)
{ {
case NtsMessageType::UE_NAS_TO_RRC: { layer->performCycle();
handleNasSapMessage(dynamic_cast<NmUeNasToRrc &>(*msg));
break;
}
case NtsMessageType::UE_RLS_TO_RRC: {
handleRlsSapMessage(dynamic_cast<NmUeRlsToRrc &>(*msg));
break;
} }
case NtsMessageType::UE_RRC_TO_RRC: { else if (msg->msgType == NtsMessageType::TIMER_EXPIRED)
auto &w = dynamic_cast<NmUeRrcToRrc &>(*msg);
switch (w.present)
{ {
case NmUeRrcToRrc::TRIGGER_CYCLE:
performCycle();
break;
}
break;
}
case NtsMessageType::TIMER_EXPIRED: {
auto &w = dynamic_cast<NmTimerExpired &>(*msg); auto &w = dynamic_cast<NmTimerExpired &>(*msg);
if (w.timerId == TIMER_ID_MACHINE_CYCLE) if (w.timerId == TIMER_ID_MACHINE_CYCLE)
{ {
setTimer(TIMER_ID_MACHINE_CYCLE, TIMER_PERIOD_MACHINE_CYCLE); setTimer(TIMER_ID_MACHINE_CYCLE, TIMER_PERIOD_MACHINE_CYCLE);
performCycle(); layer->performCycle();
} }
break;
} }
default: else if (msg->msgType == NtsMessageType::UE_NAS_TO_RRC)
m_logger->unhandledNts(*msg); {
break; layer->handleNasSapMessage(dynamic_cast<NmUeNasToRrc &>(*msg));
}
else if (msg->msgType == NtsMessageType::UE_RLS_TO_RRC)
{
layer->handleRlsSapMessage(dynamic_cast<NmUeRlsToRrc &>(*msg));
} }
} }
......
...@@ -8,39 +8,7 @@ ...@@ -8,39 +8,7 @@
#pragma once #pragma once
#include <memory> #include "layer.hpp"
#include <thread>
#include <unordered_map>
#include <vector>
#include <ue/nts.hpp>
#include <ue/types.hpp>
#include <utils/logger.hpp>
#include <utils/nts.hpp>
#include <asn/rrc/ASN_RRC_InitialUE-Identity.h>
extern "C"
{
struct ASN_RRC_BCCH_BCH_Message;
struct ASN_RRC_BCCH_DL_SCH_Message;
struct ASN_RRC_DL_CCCH_Message;
struct ASN_RRC_DL_DCCH_Message;
struct ASN_RRC_PCCH_Message;
struct ASN_RRC_UL_CCCH_Message;
struct ASN_RRC_UL_CCCH1_Message;
struct ASN_RRC_UL_DCCH_Message;
struct ASN_RRC_RRCSetupRequest;
struct ASN_RRC_DLInformationTransfer;
struct ASN_RRC_ULInformationTransfer;
struct ASN_RRC_RRCSetup;
struct ASN_RRC_RRCReject;
struct ASN_RRC_RRCRelease;
struct ASN_RRC_Paging;
struct ASN_RRC_MIB;
struct ASN_RRC_SIB1;
}
namespace nr::ue namespace nr::ue
{ {
...@@ -48,24 +16,7 @@ namespace nr::ue ...@@ -48,24 +16,7 @@ namespace nr::ue
class UeRrcTask : public NtsTask class UeRrcTask : public NtsTask
{ {
private: private:
TaskBase *m_base; std::unique_ptr<UeRrcLayer> layer;
std::unique_ptr<Logger> m_logger;
int64_t m_startedTime;
ERrcState m_state;
RrcTimers m_timers;
/* Cell and PLMN related */
std::unordered_map<int, UeCellDesc> m_cellDesc{};
int64_t m_lastTimePlmnSearchFailureLogged{};
/* Procedure related */
ERrcLastSetupRequest m_lastSetupReq{};
/* Establishment procedure related */
int m_establishmentCause{};
ASN_RRC_InitialUE_Identity_t m_initialId{};
OctetString m_initialNasPdu{};
friend class UeCmdHandler; friend class UeCmdHandler;
...@@ -77,66 +28,6 @@ class UeRrcTask : public NtsTask ...@@ -77,66 +28,6 @@ class UeRrcTask : public NtsTask
void onStart() override; void onStart() override;
void onLoop() override; void onLoop() override;
void onQuit() override; void onQuit() override;
private:
/* Handlers */
void receivePaging(const ASN_RRC_Paging &msg);
/* RRC Message Transmission and Receive */
void handleDownlinkRrc(int cellId, rrc::RrcChannel channel, const OctetString &pdu);
void sendRrcMessage(int cellId, ASN_RRC_UL_CCCH_Message *msg);
void sendRrcMessage(int cellId, ASN_RRC_UL_CCCH1_Message *msg);
void sendRrcMessage(ASN_RRC_UL_DCCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_BCCH_BCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_BCCH_DL_SCH_Message *msg);
void receiveRrcMessage(int cellId, ASN_RRC_DL_CCCH_Message *msg);
void receiveRrcMessage(ASN_RRC_DL_DCCH_Message *msg);
void receiveRrcMessage(ASN_RRC_PCCH_Message *msg);
/* Service Access Point */
void handleRlsSapMessage(NmUeRlsToRrc &msg);
void handleNasSapMessage(NmUeNasToRrc &msg);
/* State Management */
void triggerCycle();
void performCycle();
void switchState(ERrcState state);
void onSwitchState(ERrcState oldState, ERrcState newState);
/* Idle Mode Operations */
void performCellSelection();
bool lookForSuitableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report);
bool lookForAcceptableCell(ActiveCellInfo &cellInfo, CellSelectionReport &report);
/* Cell Management */
void handleCellSignalChange(int cellId, int dbm);
void notifyCellDetected(int cellId, int dbm);
void notifyCellLost(int cellId);
bool hasSignalToCell(int cellId);
bool isActiveCell(int cellId);
void updateAvailablePlmns();
/* System Information and Broadcast */
void receiveMib(int cellId, const ASN_RRC_MIB &msg);
void receiveSib1(int cellId, const ASN_RRC_SIB1 &msg);
/* NAS Transport */
void deliverUplinkNas(uint32_t pduId, OctetString &&nasPdu);
void receiveDownlinkInformationTransfer(const ASN_RRC_DLInformationTransfer &msg);
/* Connection Control */
void startConnectionEstablishment(OctetString &&nasPdu);
void handleEstablishmentFailure();
void receiveRrcSetup(int cellId, const ASN_RRC_RRCSetup &msg);
void receiveRrcReject(int cellId, const ASN_RRC_RRCReject &msg);
void receiveRrcRelease(const ASN_RRC_RRCRelease &msg);
/* Failures */
void declareRadioLinkFailure(rls::ERlfCause cause);
void handleRadioLinkFailure(rls::ERlfCause cause);
/* Access Control */
void performUac(std::shared_ptr<LightSync<UacInput, UacOutput>> &uacCtl);
}; };
} // namespace nr::ue } // namespace nr::ue
...@@ -47,12 +47,10 @@ enum class NtsMessageType ...@@ -47,12 +47,10 @@ enum class NtsMessageType
GNB_SCTP, GNB_SCTP,
UE_APP_TO_TUN, UE_APP_TO_TUN,
UE_APP_TO_NAS,
UE_TUN_TO_APP, UE_TUN_TO_APP,
UE_RRC_TO_NAS, UE_RRC_TO_NAS,
UE_NAS_TO_RRC, UE_NAS_TO_RRC,
UE_RRC_TO_RLS, UE_RRC_TO_RLS,
UE_RRC_TO_RRC,
UE_RLS_TO_RRC, UE_RLS_TO_RRC,
UE_RLS_TO_NAS, UE_RLS_TO_NAS,
UE_RLS_TO_RLS, UE_RLS_TO_RLS,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment