Change StreamTiming::TxRxKey format
The format now matches the ttag list format input in recordTxTime() making that API a little more optimized.
This commit is contained in:
parent
5ec7010c51
commit
ee45aaf0eb
@ -119,7 +119,7 @@ int StreamTiming::processRecords()
|
|||||||
struct timespec diff;
|
struct timespec diff;
|
||||||
timespecsub(&rxTime, &txTime, &diff);
|
timespecsub(&rxTime, &txTime, &diff);
|
||||||
|
|
||||||
uint guid = i.key() >> 8;
|
uint guid = guidFromKey(i.key());
|
||||||
uint portId = i.value().portId;
|
uint portId = i.value().portId;
|
||||||
|
|
||||||
if (!timing_.contains(portId))
|
if (!timing_.contains(portId))
|
||||||
@ -132,7 +132,7 @@ int StreamTiming::processRecords()
|
|||||||
count++;
|
count++;
|
||||||
|
|
||||||
timingDebug("[%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)",
|
timingDebug("[%u/%u/%u] diff %ld.%09ld (%ld.%09ld - %ld.%09ld)",
|
||||||
i.value().portId, guid, i.key() & 0xFF,
|
i.value().portId, guid, ttagIdFromKey(i.key()),
|
||||||
diff.tv_sec, diff.tv_nsec,
|
diff.tv_sec, diff.tv_nsec,
|
||||||
rxTime.tv_sec, rxTime.tv_nsec,
|
rxTime.tv_sec, rxTime.tv_nsec,
|
||||||
txTime.tv_sec, txTime.tv_nsec);
|
txTime.tv_sec, txTime.tv_nsec);
|
||||||
|
@ -62,10 +62,6 @@ private:
|
|||||||
int processRecords();
|
int processRecords();
|
||||||
int deleteStaleRecords();
|
int deleteStaleRecords();
|
||||||
|
|
||||||
quint32 makeKey(uint guid, uint ttagId) {
|
|
||||||
return guid << 8 | (ttagId & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX: use only time intervals, not absolute time
|
// XXX: use only time intervals, not absolute time
|
||||||
quint64 timespecToNsecs(const struct timespec &interval) {
|
quint64 timespecToNsecs(const struct timespec &interval) {
|
||||||
return interval.tv_nsec + interval.tv_sec*1e9;
|
return interval.tv_nsec + interval.tv_sec*1e9;
|
||||||
@ -83,16 +79,26 @@ private:
|
|||||||
|
|
||||||
QSet<uint> activePortSet_;
|
QSet<uint> activePortSet_;
|
||||||
|
|
||||||
// XXX: TxRxKey = guid (24 bit MSB) + ttagid (8 bit LSB)
|
// XXX: TxRxKey = ttagid (8 bit MSB) + guid (24 bit LSB)
|
||||||
// TODO: encode tx port in in packet and use as part of key
|
// TODO: encode tx port in packet and use as part of key
|
||||||
typedef quint32 TxRxKey;
|
typedef quint32 TxRxKey;
|
||||||
|
TxRxKey makeKey(uint guid, uint ttagId) {
|
||||||
|
return (ttagId << 24 ) | (guid & 0x00FFFFFF);
|
||||||
|
}
|
||||||
|
uint guidFromKey(TxRxKey key) {
|
||||||
|
return uint(key) & 0x00FFFFFF;
|
||||||
|
}
|
||||||
|
uint ttagIdFromKey(TxRxKey key) {
|
||||||
|
return uint(key) >> 24;
|
||||||
|
}
|
||||||
|
|
||||||
QHash<TxRxKey, TtagData> txHash_;
|
QHash<TxRxKey, TtagData> txHash_;
|
||||||
QHash<TxRxKey, TtagData> rxHash_;
|
QHash<TxRxKey, TtagData> rxHash_;
|
||||||
QMutex txHashLock_;
|
QMutex txHashLock_;
|
||||||
QMutex rxHashLock_;
|
QMutex rxHashLock_;
|
||||||
|
|
||||||
typedef uint PortIdKey;
|
typedef uint PortIdKey;
|
||||||
typedef uint GuidKey;
|
typedef uint GuidKey; // guid only, no ttagid
|
||||||
typedef QHash<GuidKey, Timing> PortTiming;
|
typedef QHash<GuidKey, Timing> PortTiming;
|
||||||
QHash<PortIdKey, PortTiming*> timing_;
|
QHash<PortIdKey, PortTiming*> timing_;
|
||||||
QMutex timingLock_;
|
QMutex timingLock_;
|
||||||
@ -163,14 +169,12 @@ bool StreamTiming::recordTxTime(uint portId, uint *ttagList, int count,
|
|||||||
TtagData value = { .timeStamp = timestamp, .portId = portId};
|
TtagData value = { .timeStamp = timestamp, .portId = portId};
|
||||||
QMutexLocker locker(&txHashLock_);
|
QMutexLocker locker(&txHashLock_);
|
||||||
|
|
||||||
// FIXME: Change TxRxKey to match the format passed to this function
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
uint guid = ttagList[i] & 0x00FFFFFF;
|
TxRxKey key = TxRxKey(ttagList[i]);
|
||||||
uint ttagId = ttagList[i] >> 24;
|
|
||||||
TxRxKey key = makeKey(guid, ttagId);
|
|
||||||
|
|
||||||
timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId,
|
timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId,
|
||||||
timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid);
|
timestamp.tv_sec, long(timestamp.tv_nsec),
|
||||||
|
ttagIdFromKey(key), guidFromKey(key));
|
||||||
|
|
||||||
txHash_.insert(key, value);
|
txHash_.insert(key, value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user