Skip to content

Commit 6d5d020

Browse files
committed
ctrlInfoToMacCid(),etc: change arg type from inet::Ptr to plain pointer
Passing smart pointers incurs overhead (inc/dec ref count), dont use where not warranted (ie. for "borrowed" pointers)
1 parent 819e96d commit 6d5d020

10 files changed

Lines changed: 34 additions & 28 deletions

File tree

src/simu5g/common/LteCommon.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,15 @@ bool isMulticastConnection(LteControlInfo *lteInfo)
322322
/*
323323
* Obtain the CID from the Control Info
324324
*/
325-
MacCid ctrlInfoToMacCid(inet::Ptr<FlowControlInfo> info)
325+
MacCid ctrlInfoToMacCid(const FlowControlInfo *info)
326326
{
327327
return MacCid(ctrlInfoToUeId(info), info->getLcid());
328328
}
329329

330330
/*
331331
* Obtain the MacNodeId of a UE from packet control info
332332
*/
333-
MacNodeId ctrlInfoToUeId(inet::Ptr<FlowControlInfo> info)
333+
MacNodeId ctrlInfoToUeId(const FlowControlInfo *info)
334334
{
335335
/*
336336
* direction | src dest

src/simu5g/common/LteCommon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ const std::string rlcTypeToA(LteRlcType type);
449449
char *cStringToLower(char *str);
450450
LteRlcType aToRlcType(std::string s);
451451
const std::string planeToA(Plane p);
452-
MacNodeId ctrlInfoToUeId(inet::Ptr<FlowControlInfo> info);
453-
MacCid ctrlInfoToMacCid(inet::Ptr<FlowControlInfo> info); // get the CID from the packet control info
452+
MacNodeId ctrlInfoToUeId(const FlowControlInfo *info);
453+
MacCid ctrlInfoToMacCid(const FlowControlInfo *info); // get the CID from the packet control info
454454
FeedbackGeneratorType getFeedbackGeneratorType(std::string s);
455455
const std::string fbGeneratorTypeToA(FeedbackGeneratorType type);
456456
const std::string DeploymentScenarioToA(DeploymentScenario type);

src/simu5g/stack/mac/LteMacBase.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ bool LteMacBase::bufferizePacket(cPacket *cpkt)
242242
auto lteInfo = pkt->getTagForUpdate<FlowControlInfo>();
243243

244244
// obtain the CID from the packet information
245-
MacCid cid = ctrlInfoToMacCid(lteInfo);
245+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
246246

247247
// check if queues exist, create them if they don't
248248
if (connDescOut_.find(cid) == connDescOut_.end())

src/simu5g/stack/mac/LteMacEnb.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ bool LteMacEnb::bufferizePacket(cPacket *cpkt)
661661
auto lteInfo = pkt->getTagForUpdate<FlowControlInfo>();
662662

663663
// obtain the cid from the packet information
664-
MacCid cid = ctrlInfoToMacCid(lteInfo);
664+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
665665

666666
// check if queues exist, create them if they don't
667667
if (connDescOut_.find(cid) == connDescOut_.end())

src/simu5g/stack/mac/LteMacUe.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ bool LteMacUe::bufferizePacket(cPacket *cpkt)
252252
auto lteInfo = pkt->getTagForUpdate<FlowControlInfo>();
253253

254254
// obtain the cid from the packet information
255-
MacCid cid = ctrlInfoToMacCid(lteInfo);
255+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
256256

257257
// check if queues exist, create them if they don't
258258
if (connDescOut_.find(cid) == connDescOut_.end())

src/simu5g/stack/rlc/am/LteRlcAm.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void LteRlcAm::sendDefragmented(cPacket *pktAux)
7777
void LteRlcAm::bufferControlPdu(cPacket *pktAux) {
7878
auto pkt = check_and_cast<inet::Packet *>(pktAux);
7979
auto lteInfo = pkt->getTagForUpdate<FlowControlInfo>();
80-
MacCid cid = ctrlInfoToMacCid(lteInfo);
80+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
8181

8282
// Find TXBuffer for this CID
8383
AmTxQueue *txbuf = lookupTxBuffer(cid);
@@ -104,7 +104,7 @@ void LteRlcAm::handleUpperMessage(cPacket *pktAux)
104104
{
105105
auto pkt = check_and_cast<Packet *>(pktAux);
106106
auto lteInfo = pkt->getTagForUpdate<FlowControlInfo>();
107-
MacCid cid = ctrlInfoToMacCid(lteInfo);
107+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
108108

109109
// Find TXBuffer for this CID
110110
AmTxQueue *txbuf = lookupTxBuffer(cid);
@@ -128,7 +128,7 @@ void LteRlcAm::routeControlMessage(cPacket *pktAux)
128128

129129
auto pkt = check_and_cast<Packet *>(pktAux);
130130
auto lteInfo = pkt->getTagForUpdate<FlowControlInfo>();
131-
MacCid cid = ctrlInfoToMacCid(lteInfo);
131+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
132132

133133
// Find TXBuffer for this CID
134134
AmTxQueue *txbuf = lookupTxBuffer(cid);
@@ -149,7 +149,7 @@ void LteRlcAm::handleLowerMessage(cPacket *pktAux)
149149
// process SDU request received from MAC
150150

151151
// get the corresponding Tx buffer
152-
MacCid cid = ctrlInfoToMacCid(lteInfo);
152+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
153153

154154
// Find TXBuffer for this CID
155155
AmTxQueue *txbuf = lookupTxBuffer(cid);
@@ -177,7 +177,7 @@ void LteRlcAm::handleLowerMessage(cPacket *pktAux)
177177
}
178178

179179
// Extract information from fragment
180-
MacCid cid = ctrlInfoToMacCid(lteInfo);
180+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
181181
// Find RXBuffer for this CID
182182
AmRxQueue *rxbuf = lookupRxBuffer(cid);
183183
if (rxbuf == nullptr)

src/simu5g/stack/rlc/um/LteRlcUm.cc

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ UmTxEntity *LteRlcUm::lookupTxBuffer(MacCid cid)
3333
return (it != txEntities_.end()) ? it->second : nullptr;
3434
}
3535

36-
UmTxEntity *LteRlcUm::createTxBuffer(MacCid cid, inet::Ptr<FlowControlInfo> lteInfo)
36+
UmTxEntity *LteRlcUm::createTxBuffer(MacCid cid, FlowControlInfo *lteInfo)
3737
{
38+
if (txEntities_.find(cid) != txEntities_.end())
39+
throw cRuntimeError("RLC-UM connection TX entity for %s already exists", cid.str().c_str());
40+
3841
std::stringstream buf;
3942
buf << "UmTxEntity Lcid: " << cid.getLcid() << " cid: " << cid.asPackedInt();
4043
UmTxEntity *txEnt = check_and_cast<UmTxEntity *>(txEntityModuleType_->createScheduleInit(buf.str().c_str(), getParentModule()));
4144
txEntities_[cid] = txEnt;
4245

43-
txEnt->setFlowControlInfo(lteInfo.get());
46+
txEnt->setFlowControlInfo(lteInfo);
4447

4548
EV << "LteRlcUm::createTxBuffer - Added new UmTxEntity: " << txEnt->getId() << " for CID " << cid << "\n";
4649

@@ -54,15 +57,18 @@ UmRxEntity *LteRlcUm::lookupRxBuffer(MacCid cid)
5457
return (it != rxEntities_.end()) ? it->second : nullptr;
5558
}
5659

57-
UmRxEntity *LteRlcUm::createRxBuffer(MacCid cid, inet::Ptr<FlowControlInfo> lteInfo)
60+
UmRxEntity *LteRlcUm::createRxBuffer(MacCid cid, FlowControlInfo *lteInfo)
5861
{
62+
if (rxEntities_.find(cid) != rxEntities_.end())
63+
throw cRuntimeError("RLC-UM connection RX entity for %s already exists", cid.str().c_str());
64+
5965
std::stringstream buf;
6066
buf << "UmRxEntity Lcid: " << cid.getLcid() << " cid: " << cid.asPackedInt();
6167
UmRxEntity *rxEnt = check_and_cast<UmRxEntity *>(rxEntityModuleType_->createScheduleInit(buf.str().c_str(), getParentModule()));
6268
rxEntities_[cid] = rxEnt;
6369

6470
// configure entity
65-
rxEnt->setFlowControlInfo(lteInfo.get());
71+
rxEnt->setFlowControlInfo(lteInfo);
6672

6773
EV << "LteRlcUm::createRxBuffer - Added new UmRxEntity: " << rxEnt->getId() << " for CID " << cid << "\n";
6874

@@ -102,10 +108,10 @@ void LteRlcUm::handleUpperMessage(cPacket *pktAux)
102108
auto chunk = pkt->peekAtFront<inet::Chunk>();
103109
EV << "LteRlcUm::handleUpperMessage - Received packet " << chunk->getClassName() << " from upper layer, size " << pktAux->getByteLength() << "\n";
104110

105-
MacCid cid = ctrlInfoToMacCid(lteInfo);
111+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
106112
UmTxEntity *txbuf = lookupTxBuffer(cid);
107113
if (txbuf == nullptr)
108-
txbuf = createTxBuffer(cid, lteInfo);
114+
txbuf = createTxBuffer(cid, lteInfo.get());
109115

110116
// Create a new RLC packet
111117
auto rlcPkt = inet::makeShared<LteRlcSdu>();
@@ -150,10 +156,10 @@ void LteRlcUm::handleLowerMessage(cPacket *pktAux)
150156

151157
if (inet::dynamicPtrCast<const LteMacSduRequest>(chunk) != nullptr) {
152158
// get the corresponding Tx buffer
153-
MacCid cid = ctrlInfoToMacCid(lteInfo);
159+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
154160
UmTxEntity *txbuf = lookupTxBuffer(cid);
155161
if (txbuf == nullptr)
156-
txbuf = createTxBuffer(cid, lteInfo);
162+
txbuf = createTxBuffer(cid, lteInfo.get());
157163

158164
auto macSduRequest = pkt->peekAtFront<LteMacSduRequest>();
159165
unsigned int size = macSduRequest->getSduSize();
@@ -173,7 +179,7 @@ void LteRlcUm::handleLowerMessage(cPacket *pktAux)
173179
MacCid cid = MacCid(nodeId, lteInfo->getLcid());
174180
UmRxEntity *rxbuf = lookupRxBuffer(cid);
175181
if (rxbuf == nullptr)
176-
rxbuf = createRxBuffer(cid, lteInfo);
182+
rxbuf = createRxBuffer(cid, lteInfo.get());
177183
drop(pkt);
178184

179185
// Bufferize PDU

src/simu5g/stack/rlc/um/LteRlcUm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class LteRlcUm : public cSimpleModule
175175
* @param lteInfo flow-related info
176176
* @return pointer to the newly created TXBuffer
177177
*/
178-
virtual UmTxEntity *createTxBuffer(MacCid cid, inet::Ptr<FlowControlInfo> lteInfo);
178+
virtual UmTxEntity *createTxBuffer(MacCid cid, FlowControlInfo *lteInfo);
179179

180180

181181
/**
@@ -193,8 +193,8 @@ class LteRlcUm : public cSimpleModule
193193
* @param lteInfo flow-related info
194194
* @return pointer to the newly created RXBuffer
195195
*/
196-
virtual UmRxEntity *createRxBuffer(MacCid cid, inet::Ptr<FlowControlInfo> lteInfo);
197196

197+
virtual UmRxEntity *createRxBuffer(MacCid cid, FlowControlInfo *lteInfo);
198198

199199
/**
200200
* handler for traffic coming

src/simu5g/stack/rlc/um/LteRlcUmD2D.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace simu5g {
1717
Define_Module(LteRlcUmD2D);
1818
using namespace omnetpp;
1919

20-
UmTxEntity *LteRlcUmD2D::createTxBuffer(MacCid cid, inet::Ptr<FlowControlInfo> lteInfo)
20+
UmTxEntity *LteRlcUmD2D::createTxBuffer(MacCid cid, FlowControlInfo *lteInfo)
2121
{
2222
UmTxEntity *txEnt = LteRlcUm::createTxBuffer(cid, lteInfo);
2323

@@ -50,10 +50,10 @@ void LteRlcUmD2D::handleLowerMessage(cPacket *pktAux)
5050

5151
if (switchPkt->getTxSide()) {
5252
// get the corresponding Rx buffer & call handler
53-
MacCid cid = ctrlInfoToMacCid(lteInfo);
53+
MacCid cid = ctrlInfoToMacCid(lteInfo.get());
5454
UmTxEntity *txbuf = lookupTxBuffer(cid);
5555
if (txbuf == nullptr)
56-
txbuf = createTxBuffer(cid, lteInfo);
56+
txbuf = createTxBuffer(cid, lteInfo.get());
5757
txbuf->rlcHandleD2DModeSwitch(switchPkt->getOldConnection(), switchPkt->getClearRlcBuffer());
5858

5959
// forward packet to PDCP
@@ -66,7 +66,7 @@ void LteRlcUmD2D::handleLowerMessage(cPacket *pktAux)
6666
MacCid cid = MacCid(nodeId, lteInfo->getLcid());
6767
UmRxEntity *rxbuf = lookupRxBuffer(cid);
6868
if (rxbuf == nullptr)
69-
rxbuf = createRxBuffer(cid, lteInfo);
69+
rxbuf = createRxBuffer(cid, lteInfo.get());
7070
rxbuf->rlcHandleD2DModeSwitch(switchPkt->getOldConnection(), switchPkt->getOldMode(), switchPkt->getClearRlcBuffer());
7171

7272
delete pkt;

src/simu5g/stack/rlc/um/LteRlcUmD2D.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class LteRlcUmD2D : public LteRlcUm
4747
* @param lteInfo flow-related info
4848
* @return pointer to the newly created TXBuffer
4949
*/
50-
UmTxEntity *createTxBuffer(MacCid cid, inet::Ptr<FlowControlInfo> lteInfo) override;
50+
UmTxEntity *createTxBuffer(MacCid cid, FlowControlInfo *lteInfo) override;
5151

5252
/**
5353
* UM Mode

0 commit comments

Comments
 (0)