properly implement the fifo _reserved stuff.
dev/pktfifo.cc: need to checkpoint _reserved dev/pktfifo.hh: When clearing, clear _reserved size() is used for determining how many bytes are in the fifo ready to be pulled, so we don't want to add _reserved avail() on the other hand is used for determining how much free space is in the fifo for adding packets. adjust the implementation of empty() and full() to reflect this. --HG-- extra : convert_revision : 3281972b4b70ea5833d39ae7ce1e73648b3573b0
This commit is contained in:
parent
c43c3f2af3
commit
5f6328d9c6
2 changed files with 9 additions and 5 deletions
|
@ -36,6 +36,7 @@ PacketFifo::serialize(const string &base, ostream &os)
|
||||||
{
|
{
|
||||||
paramOut(os, base + ".size", _size);
|
paramOut(os, base + ".size", _size);
|
||||||
paramOut(os, base + ".maxsize", _maxsize);
|
paramOut(os, base + ".maxsize", _maxsize);
|
||||||
|
paramOut(os, base + ".reserved", _reserved);
|
||||||
paramOut(os, base + ".packets", fifo.size());
|
paramOut(os, base + ".packets", fifo.size());
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -54,6 +55,7 @@ PacketFifo::unserialize(const string &base, Checkpoint *cp,
|
||||||
{
|
{
|
||||||
paramIn(cp, section, base + ".size", _size);
|
paramIn(cp, section, base + ".size", _size);
|
||||||
paramIn(cp, section, base + ".maxsize", _maxsize);
|
paramIn(cp, section, base + ".maxsize", _maxsize);
|
||||||
|
paramIn(cp, section, base + ".reserved", _reserved);
|
||||||
int fifosize;
|
int fifosize;
|
||||||
paramIn(cp, section, base + ".packets", fifosize);
|
paramIn(cp, section, base + ".packets", fifosize);
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,13 @@ class PacketFifo
|
||||||
explicit PacketFifo(int max) : _maxsize(max), _size(0), _reserved(0) {}
|
explicit PacketFifo(int max) : _maxsize(max), _size(0), _reserved(0) {}
|
||||||
virtual ~PacketFifo() {}
|
virtual ~PacketFifo() {}
|
||||||
|
|
||||||
int maxsize() const { return _maxsize; }
|
|
||||||
int packets() const { return fifo.size(); }
|
int packets() const { return fifo.size(); }
|
||||||
int size() const { return _size + _reserved; }
|
int maxsize() const { return _maxsize; }
|
||||||
int avail() const { return maxsize() - size(); }
|
int size() const { return _size; }
|
||||||
bool empty() const { return size() == 0; }
|
int reserved() const { return _reserved; }
|
||||||
bool full() const { return size() >= maxsize(); }
|
int avail() const { return _maxsize - _size - _reserved; }
|
||||||
|
bool empty() const { return size() <= 0; }
|
||||||
|
bool full() const { return avail() <= 0; }
|
||||||
|
|
||||||
int reserve(int len = 0)
|
int reserve(int len = 0)
|
||||||
{
|
{
|
||||||
|
@ -91,6 +92,7 @@ class PacketFifo
|
||||||
{
|
{
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
_size = 0;
|
_size = 0;
|
||||||
|
_reserved = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue