summaryrefslogtreecommitdiff
path: root/dev
diff options
context:
space:
mode:
Diffstat (limited to 'dev')
-rw-r--r--dev/pktfifo.cc2
-rw-r--r--dev/pktfifo.hh12
2 files changed, 9 insertions, 5 deletions
diff --git a/dev/pktfifo.cc b/dev/pktfifo.cc
index cf09ae910..00c12ce68 100644
--- a/dev/pktfifo.cc
+++ b/dev/pktfifo.cc
@@ -36,6 +36,7 @@ PacketFifo::serialize(const string &base, ostream &os)
{
paramOut(os, base + ".size", _size);
paramOut(os, base + ".maxsize", _maxsize);
+ paramOut(os, base + ".reserved", _reserved);
paramOut(os, base + ".packets", fifo.size());
int i = 0;
@@ -54,6 +55,7 @@ PacketFifo::unserialize(const string &base, Checkpoint *cp,
{
paramIn(cp, section, base + ".size", _size);
paramIn(cp, section, base + ".maxsize", _maxsize);
+ paramIn(cp, section, base + ".reserved", _reserved);
int fifosize;
paramIn(cp, section, base + ".packets", fifosize);
diff --git a/dev/pktfifo.hh b/dev/pktfifo.hh
index 56e72947a..0c237949c 100644
--- a/dev/pktfifo.hh
+++ b/dev/pktfifo.hh
@@ -49,12 +49,13 @@ class PacketFifo
explicit PacketFifo(int max) : _maxsize(max), _size(0), _reserved(0) {}
virtual ~PacketFifo() {}
- int maxsize() const { return _maxsize; }
int packets() const { return fifo.size(); }
- int size() const { return _size + _reserved; }
- int avail() const { return maxsize() - size(); }
- bool empty() const { return size() == 0; }
- bool full() const { return size() >= maxsize(); }
+ int maxsize() const { return _maxsize; }
+ int size() const { return _size; }
+ int reserved() const { return _reserved; }
+ int avail() const { return _maxsize - _size - _reserved; }
+ bool empty() const { return size() <= 0; }
+ bool full() const { return avail() <= 0; }
int reserve(int len = 0)
{
@@ -91,6 +92,7 @@ class PacketFifo
{
fifo.clear();
_size = 0;
+ _reserved = 0;
}
/**