Optimize stream preflight check for performance
Loop only once for all packets of the stream
This commit is contained in:
parent
ba06b88329
commit
ac1356ed53
@ -581,32 +581,46 @@ quint64 StreamBase::neighborMacAddress(int frameIndex) const
|
||||
return getNeighborMacAddress(portId_, int(mStreamId->id()), frameIndex);
|
||||
}
|
||||
|
||||
/*!
|
||||
Checks for any potential errors with the packets generated by this
|
||||
stream. Returns true if no problems are found, false otherwise. Details
|
||||
of the error(s) are available in the INOUT param result
|
||||
|
||||
All errors found are returned. However, each type of error is reported
|
||||
only once, even if multiple packets may have that error.
|
||||
*/
|
||||
bool StreamBase::preflightCheck(QString &result) const
|
||||
{
|
||||
bool pass = true;
|
||||
bool chkTrunc = true;
|
||||
bool chkJumbo = true;
|
||||
int count = isFrameSizeVariable() ? frameCount() : 1;
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (frameLen(i) < (frameProtocolLength(i) + kFcsSize))
|
||||
int pktLen = frameLen(i);
|
||||
|
||||
if (chkTrunc && (pktLen < (frameProtocolLength(i) + kFcsSize)))
|
||||
{
|
||||
result += QString("One or more frames may be truncated - "
|
||||
"frame length should be at least %1.\n")
|
||||
.arg(frameProtocolLength(i) + kFcsSize);
|
||||
chkTrunc = false;
|
||||
pass = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (frameLen(i) > 1522)
|
||||
if (chkJumbo && (pktLen > 1522))
|
||||
{
|
||||
result += QString("Jumbo frames may be truncated or dropped "
|
||||
"if not supported by the hardware\n");
|
||||
"if not supported by the hardware.\n");
|
||||
chkJumbo = false;
|
||||
pass = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Break out of loop if we've seen at least one instance of all
|
||||
// the above errors
|
||||
if (!chkTrunc && !chkJumbo)
|
||||
break;
|
||||
}
|
||||
|
||||
return pass;
|
||||
|
Loading…
Reference in New Issue
Block a user