diff options
author | Michael LeBeane <michael.lebeane@amd.com> | 2016-11-29 13:04:45 -0500 |
---|---|---|
committer | Michael LeBeane <michael.lebeane@amd.com> | 2016-11-29 13:04:45 -0500 |
commit | cd4b26b6ae984a75e16f4d71152d99b6c063d366 (patch) | |
tree | 33248f61326415ea11ff30dce527ed8fa5121231 /src/dev/net/etherpkt.cc | |
parent | 4b7bc5b1e1915915a746af16d36de1d006db8700 (diff) | |
download | gem5-cd4b26b6ae984a75e16f4d71152d99b6c063d366.tar.xz |
dev: Fix buffer length when unserializing an eth pkt
Changeset 11701 only serialized the useful portion of of an ethernet packets'
payload. However, the device models expect each ethernet packet to contain
a 16KB buffer, even if there is no data in it. This patch adds a 'bufLength'
field to EthPacketData so the original size of the packet buffer can always
be unserialized.
Reported-by: Gabor Dozsa <Gabor.Dozsa@arm.com>
Diffstat (limited to 'src/dev/net/etherpkt.cc')
-rw-r--r-- | src/dev/net/etherpkt.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/dev/net/etherpkt.cc b/src/dev/net/etherpkt.cc index 446e44e46..22c0156d0 100644 --- a/src/dev/net/etherpkt.cc +++ b/src/dev/net/etherpkt.cc @@ -42,6 +42,7 @@ void EthPacketData::serialize(const string &base, CheckpointOut &cp) const { paramOut(cp, base + ".simLength", simLength); + paramOut(cp, base + ".bufLength", bufLength); paramOut(cp, base + ".length", length); arrayParamOut(cp, base + ".data", data, length); } @@ -50,11 +51,23 @@ void EthPacketData::unserialize(const string &base, CheckpointIn &cp) { paramIn(cp, base + ".length", length); - if (length) { - assert(data == nullptr); - data = new uint8_t[length]; - arrayParamIn(cp, base + ".data", data, length); + unsigned chkpt_buf_length; + if (optParamIn(cp, base + ".bufLength", chkpt_buf_length)) { + // If bufLength is in the checkpoint, make sure that the current buffer + // is unallocated or that the checkpoint requested size is smaller than + // the current buffer. + assert(!data || chkpt_buf_length <= bufLength); + bufLength = chkpt_buf_length; + } else { + // If bufLength is not in the checkpoint, try to use the existing + // buffer or use length to size the buffer + if (!data) + bufLength = length; } + assert(length <= bufLength); + if (!data) + data = new uint8_t[bufLength]; + arrayParamIn(cp, base + ".data", data, length); if (!optParamIn(cp, base + ".simLength", simLength)) simLength = length; } |