Skip to content

Commit d1ae0b8

Browse files
committed
[roc] Sequence ID field in CardDescriptor
1 parent a130bc4 commit d1ae0b8

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

include/ReadoutCard/CardDescriptor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct CardDescriptor {
3535
PciId pciId;
3636
PciAddress pciAddress;
3737
int32_t numaNode;
38+
int sequenceId;
3839
};
3940

4041
} // namespace roc

src/Dummy/DummyDmaChannel.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace
2727
{
2828
CardDescriptor makeDummyDescriptor()
2929
{
30-
return { CardType::Dummy, ChannelFactory::getDummySerialId(), PciId{ "dummy", "dummy" }, PciAddress{ 0, 0, 0 }, -1 };
30+
return { CardType::Dummy, ChannelFactory::getDummySerialId(), PciId{ "dummy", "dummy" }, PciAddress{ 0, 0, 0 }, -1, -1 };
3131
}
3232

3333
constexpr size_t TRANSFER_QUEUE_CAPACITY = 16;

src/Pda/Util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void freePdaDmaBuffersWrapped(const CardDescriptor cardDescriptor, const int cha
101101

102102
void freePdaDmaBuffers()
103103
{
104-
const CardDescriptor cardDescriptor = { CardType::Cru, SerialId{ SERIAL_DUMMY, ENDPOINT_DUMMY }, PciId{ "-1", "-1" }, PciAddress{ 0, 0, 0 }, -1 }; // a dummy card descriptor - call is anyway forced
104+
const CardDescriptor cardDescriptor = { CardType::Cru, SerialId{ SERIAL_DUMMY, ENDPOINT_DUMMY }, PciId{ "-1", "-1" }, PciAddress{ 0, 0, 0 }, -1, -1 }; // a dummy card descriptor - call is anyway forced
105105
freePdaDmaBuffersWrapped(cardDescriptor, -1, true);
106106
}
107107

src/RocPciDevice.cxx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PciAddress addressFromDevice(PciDevice* pciDevice)
6767

6868
CardDescriptor defaultDescriptor()
6969
{
70-
return { CardType::Unknown, SerialId(-1, 0), { "unknown", "unknown" }, PciAddress(0, 0, 0), -1 };
70+
return { CardType::Unknown, SerialId(-1, 0), { "unknown", "unknown" }, PciAddress(0, 0, 0), -1, -1 };
7171
}
7272
} // Anonymous namespace
7373

@@ -91,6 +91,7 @@ RocPciDevice::~RocPciDevice()
9191

9292
void RocPciDevice::initWithSerialId(const SerialId& serialId)
9393
{
94+
int sequenceCounter = 0;
9495
try {
9596
for (const auto& typedPciDevice : Pda::PdaDevice::getPciDevices()) {
9697
PciDevice* pciDevice = typedPciDevice.pciDevice;
@@ -112,9 +113,10 @@ void RocPciDevice::initWithSerialId(const SerialId& serialId)
112113

113114
if (serial == serialId.getSerial() && endpoint == serialId.getEndpoint()) {
114115
mPciDevice = pciDevice;
115-
mDescriptor = CardDescriptor{ type.cardType, serialId, type.pciId, addressFromDevice(pciDevice), PciDevice_getNumaNode(pciDevice) };
116+
mDescriptor = CardDescriptor{ type.cardType, serialId, type.pciId, addressFromDevice(pciDevice), PciDevice_getNumaNode(pciDevice), sequenceCounter };
116117
return;
117118
}
119+
sequenceCounter++;
118120
}
119121
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not find card"));
120122
} catch (boost::exception& e) {
@@ -126,6 +128,7 @@ void RocPciDevice::initWithSerialId(const SerialId& serialId)
126128

127129
void RocPciDevice::initWithAddress(const PciAddress& address)
128130
{
131+
int sequenceCounter = 0;
129132
try {
130133
for (const auto& typedPciDevice : Pda::PdaDevice::getPciDevices()) {
131134
PciDevice* pciDevice = typedPciDevice.pciDevice;
@@ -146,9 +149,10 @@ void RocPciDevice::initWithAddress(const PciAddress& address)
146149
endpoint = type.getEndpoint(mPdaBar0);
147150

148151
mPciDevice = pciDevice;
149-
mDescriptor = CardDescriptor{ type.cardType, SerialId{ serial, endpoint }, type.pciId, address, PciDevice_getNumaNode(pciDevice) };
152+
mDescriptor = CardDescriptor{ type.cardType, SerialId{ serial, endpoint }, type.pciId, address, PciDevice_getNumaNode(pciDevice), sequenceCounter };
150153
return;
151154
}
155+
sequenceCounter++;
152156
}
153157
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not find card"));
154158
} catch (boost::exception& e) {
@@ -181,7 +185,7 @@ void RocPciDevice::initWithSequenceNumber(const PciSequenceNumber& sequenceNumbe
181185
endpoint = type.getEndpoint(mPdaBar0);
182186

183187
mPciDevice = pciDevice;
184-
mDescriptor = CardDescriptor{ type.cardType, SerialId{ serial, endpoint }, type.pciId, addressFromDevice(pciDevice), PciDevice_getNumaNode(pciDevice) };
188+
mDescriptor = CardDescriptor{ type.cardType, SerialId{ serial, endpoint }, type.pciId, addressFromDevice(pciDevice), PciDevice_getNumaNode(pciDevice), sequenceCounter };
185189
return;
186190
}
187191
sequenceCounter++;
@@ -196,6 +200,7 @@ void RocPciDevice::initWithSequenceNumber(const PciSequenceNumber& sequenceNumbe
196200

197201
std::vector<CardDescriptor> RocPciDevice::findSystemDevices()
198202
{
203+
int sequenceCounter = 0;
199204
std::vector<CardDescriptor> cards;
200205
for (const auto& typedPciDevice : Pda::PdaDevice::getPciDevices()) {
201206
PciDevice* pciDevice = typedPciDevice.pciDevice;
@@ -218,10 +223,11 @@ std::vector<CardDescriptor> RocPciDevice::findSystemDevices()
218223
endpoint = type.getEndpoint(pdaBar0);
219224

220225
try {
221-
cards.push_back(CardDescriptor{ type.cardType, SerialId{ serial, endpoint }, type.pciId, addressFromDevice(pciDevice), PciDevice_getNumaNode(pciDevice) });
226+
cards.push_back(CardDescriptor{ type.cardType, SerialId{ serial, endpoint }, type.pciId, addressFromDevice(pciDevice), PciDevice_getNumaNode(pciDevice), sequenceCounter });
222227
} catch (boost::exception& e) {
223228
std::cout << boost::diagnostic_information(e);
224229
}
230+
sequenceCounter++;
225231
}
226232
return cards;
227233
}

src/RocPciDevice.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class RocPciDevice
7171
return mDescriptor.serialId;
7272
}
7373

74+
int getSequenceId() const
75+
{
76+
return mDescriptor.sequenceId;
77+
}
78+
7479
std::shared_ptr<Pda::PdaBar> getBar(int barIndex)
7580
{
7681
if (barIndex == 0) {

0 commit comments

Comments
 (0)