2006-09-19 02:12:45 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006 The Regents of The University of Michigan
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Authors: Ali Saidi
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* @file
|
|
|
|
* Device model for Intel's 8254x line of gigabit ethernet controllers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DEV_I8254XGBE_HH__
|
|
|
|
#define __DEV_I8254XGBE_HH__
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
#include <deque>
|
|
|
|
#include <string>
|
|
|
|
|
2009-02-27 01:29:17 +01:00
|
|
|
#include "base/cp_annotate.hh"
|
2006-09-19 02:12:45 +02:00
|
|
|
#include "base/inet.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/EthernetDesc.hh"
|
|
|
|
#include "debug/EthernetIntr.hh"
|
2007-08-16 22:49:02 +02:00
|
|
|
#include "dev/etherdevice.hh"
|
2006-09-19 02:12:45 +02:00
|
|
|
#include "dev/etherint.hh"
|
|
|
|
#include "dev/etherpkt.hh"
|
2006-10-20 19:00:05 +02:00
|
|
|
#include "dev/i8254xGBe_defs.hh"
|
2006-09-19 02:12:45 +02:00
|
|
|
#include "dev/pcidev.hh"
|
|
|
|
#include "dev/pktfifo.hh"
|
2007-07-24 06:51:38 +02:00
|
|
|
#include "params/IGbE.hh"
|
2006-09-19 02:12:45 +02:00
|
|
|
#include "sim/eventq.hh"
|
|
|
|
|
|
|
|
class IGbEInt;
|
|
|
|
|
2007-08-16 22:49:02 +02:00
|
|
|
class IGbE : public EtherDevice
|
2006-09-19 02:12:45 +02:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
IGbEInt *etherInt;
|
2009-02-27 01:29:17 +01:00
|
|
|
CPA *cpa;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
// device registers
|
2006-10-20 19:00:05 +02:00
|
|
|
iGbReg::Regs regs;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
// eeprom data, status and control bits
|
2006-10-20 19:00:05 +02:00
|
|
|
int eeOpBits, eeAddrBits, eeDataBits;
|
|
|
|
uint8_t eeOpcode, eeAddr;
|
2007-03-22 23:39:41 +01:00
|
|
|
uint16_t flash[iGbReg::EEPROM_SIZE];
|
2006-10-20 19:00:05 +02:00
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
// The drain event if we have one
|
2012-11-02 17:32:01 +01:00
|
|
|
DrainManager *drainManager;
|
2007-03-30 04:00:01 +02:00
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
// cached parameters from params struct
|
2007-03-15 20:16:23 +01:00
|
|
|
bool useFlowControl;
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
// packet fifos
|
|
|
|
PacketFifo rxFifo;
|
|
|
|
PacketFifo txFifo;
|
|
|
|
|
|
|
|
// Packet that we are currently putting into the txFifo
|
|
|
|
EthPacketPtr txPacket;
|
|
|
|
|
|
|
|
// Should to Rx/Tx State machine tick?
|
|
|
|
bool rxTick;
|
|
|
|
bool txTick;
|
2007-03-28 02:44:21 +02:00
|
|
|
bool txFifoTick;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2007-05-14 22:37:00 +02:00
|
|
|
bool rxDmaPacket;
|
|
|
|
|
2009-01-06 16:36:57 +01:00
|
|
|
// Number of bytes copied from current RX packet
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned pktOffset;
|
2009-01-06 16:36:57 +01:00
|
|
|
|
2008-08-13 23:41:58 +02:00
|
|
|
// Delays in managaging descriptors
|
|
|
|
Tick fetchDelay, wbDelay;
|
|
|
|
Tick fetchCompDelay, wbCompDelay;
|
|
|
|
Tick rxWriteDelay, txReadDelay;
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
// Event and function to deal with RDTR timer expiring
|
2007-03-28 02:44:21 +02:00
|
|
|
void rdtrProcess() {
|
|
|
|
rxDescCache.writeback(0);
|
2009-04-22 07:58:53 +02:00
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"Posting RXT interrupt because RDTR timer expired\n");
|
2008-08-13 22:30:30 +02:00
|
|
|
postInterrupt(iGbReg::IT_RXT);
|
2007-03-28 02:44:21 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
//friend class EventWrapper<IGbE, &IGbE::rdtrProcess>;
|
|
|
|
EventWrapper<IGbE, &IGbE::rdtrProcess> rdtrEvent;
|
|
|
|
|
|
|
|
// Event and function to deal with RADV timer expiring
|
2007-03-28 02:44:21 +02:00
|
|
|
void radvProcess() {
|
|
|
|
rxDescCache.writeback(0);
|
2009-04-22 07:58:53 +02:00
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"Posting RXT interrupt because RADV timer expired\n");
|
2008-08-13 22:30:30 +02:00
|
|
|
postInterrupt(iGbReg::IT_RXT);
|
2007-03-28 02:44:21 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
//friend class EventWrapper<IGbE, &IGbE::radvProcess>;
|
|
|
|
EventWrapper<IGbE, &IGbE::radvProcess> radvEvent;
|
|
|
|
|
|
|
|
// Event and function to deal with TADV timer expiring
|
2007-03-28 02:44:21 +02:00
|
|
|
void tadvProcess() {
|
|
|
|
txDescCache.writeback(0);
|
2009-04-22 07:58:53 +02:00
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"Posting TXDW interrupt because TADV timer expired\n");
|
2008-08-13 22:30:30 +02:00
|
|
|
postInterrupt(iGbReg::IT_TXDW);
|
2007-03-28 02:44:21 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
//friend class EventWrapper<IGbE, &IGbE::tadvProcess>;
|
|
|
|
EventWrapper<IGbE, &IGbE::tadvProcess> tadvEvent;
|
|
|
|
|
|
|
|
// Event and function to deal with TIDV timer expiring
|
2007-03-28 02:44:21 +02:00
|
|
|
void tidvProcess() {
|
|
|
|
txDescCache.writeback(0);
|
2009-04-22 07:58:53 +02:00
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"Posting TXDW interrupt because TIDV timer expired\n");
|
2008-08-13 22:30:30 +02:00
|
|
|
postInterrupt(iGbReg::IT_TXDW);
|
2007-03-28 02:44:21 +02:00
|
|
|
}
|
2007-03-22 23:39:41 +01:00
|
|
|
//friend class EventWrapper<IGbE, &IGbE::tidvProcess>;
|
|
|
|
EventWrapper<IGbE, &IGbE::tidvProcess> tidvEvent;
|
|
|
|
|
|
|
|
// Main event to tick the device
|
|
|
|
void tick();
|
|
|
|
//friend class EventWrapper<IGbE, &IGbE::tick>;
|
|
|
|
EventWrapper<IGbE, &IGbE::tick> tickEvent;
|
|
|
|
|
|
|
|
|
2008-08-24 21:27:49 +02:00
|
|
|
uint64_t macAddr;
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
void rxStateMachine();
|
|
|
|
void txStateMachine();
|
|
|
|
void txWire();
|
|
|
|
|
|
|
|
/** Write an interrupt into the interrupt pending register and check mask
|
|
|
|
* and interrupt limit timer before sending interrupt to CPU
|
|
|
|
* @param t the type of interrupt we are posting
|
|
|
|
* @param now should we ignore the interrupt limiting timer
|
|
|
|
*/
|
|
|
|
void postInterrupt(iGbReg::IntTypes t, bool now = false);
|
|
|
|
|
|
|
|
/** Check and see if changes to the mask register have caused an interrupt
|
|
|
|
* to need to be sent or perhaps removed an interrupt cause.
|
|
|
|
*/
|
|
|
|
void chkInterrupt();
|
|
|
|
|
|
|
|
/** Send an interrupt to the cpu
|
|
|
|
*/
|
2007-08-27 06:45:40 +02:00
|
|
|
void delayIntEvent();
|
2007-03-22 23:39:41 +01:00
|
|
|
void cpuPostInt();
|
|
|
|
// Event to moderate interrupts
|
2007-08-27 06:45:40 +02:00
|
|
|
EventWrapper<IGbE, &IGbE::delayIntEvent> interEvent;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
/** Clear the interupt line to the cpu
|
|
|
|
*/
|
|
|
|
void cpuClearInt();
|
|
|
|
|
2010-04-16 01:24:12 +02:00
|
|
|
Tick intClock() { return SimClock::Int::ns * 1024; }
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
/** This function is used to restart the clock so it can handle things like
|
|
|
|
* draining and resume in one place. */
|
2007-03-27 00:40:18 +02:00
|
|
|
void restartClock();
|
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
/** Check if all the draining things that need to occur have occured and
|
|
|
|
* handle the drain event if so.
|
|
|
|
*/
|
|
|
|
void checkDrain();
|
|
|
|
|
2009-02-27 01:29:17 +01:00
|
|
|
void anBegin(std::string sm, std::string st, int flags = CPA::FL_NONE) {
|
|
|
|
cpa->hwBegin((CPA::flags)flags, sys, macAddr, sm, st);
|
|
|
|
}
|
|
|
|
|
|
|
|
void anQ(std::string sm, std::string q) {
|
|
|
|
cpa->hwQ(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void anDq(std::string sm, std::string q) {
|
|
|
|
cpa->hwDq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void anPq(std::string sm, std::string q, int num = 1) {
|
|
|
|
cpa->hwPq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr, NULL, num);
|
|
|
|
}
|
|
|
|
|
|
|
|
void anRq(std::string sm, std::string q, int num = 1) {
|
2009-03-26 01:06:54 +01:00
|
|
|
cpa->hwRq(CPA::FL_NONE, sys, macAddr, sm, q, macAddr, NULL, num);
|
2009-02-27 01:29:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void anWe(std::string sm, std::string q) {
|
|
|
|
cpa->hwWe(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void anWf(std::string sm, std::string q) {
|
|
|
|
cpa->hwWf(CPA::FL_NONE, sys, macAddr, sm, q, macAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
template<class T>
|
|
|
|
class DescCache
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual Addr descBase() const = 0;
|
|
|
|
virtual long descHead() const = 0;
|
|
|
|
virtual long descTail() const = 0;
|
|
|
|
virtual long descLen() const = 0;
|
|
|
|
virtual void updateHead(long h) = 0;
|
|
|
|
virtual void enableSm() = 0;
|
2008-12-05 19:58:22 +01:00
|
|
|
virtual void actionAfterWb() {}
|
2007-08-27 06:45:40 +02:00
|
|
|
virtual void fetchAfterWb() = 0;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2009-06-05 08:21:12 +02:00
|
|
|
typedef std::deque<T *> CacheType;
|
|
|
|
CacheType usedCache;
|
|
|
|
CacheType unusedCache;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
T *fetchBuf;
|
|
|
|
T *wbBuf;
|
|
|
|
|
|
|
|
// Pointer to the device we cache for
|
|
|
|
IGbE *igbe;
|
|
|
|
|
|
|
|
// Name of this descriptor cache
|
|
|
|
std::string _name;
|
|
|
|
|
|
|
|
// How far we've cached
|
|
|
|
int cachePnt;
|
|
|
|
|
|
|
|
// The size of the descriptor cache
|
|
|
|
int size;
|
|
|
|
|
|
|
|
// How many descriptors we are currently fetching
|
|
|
|
int curFetching;
|
|
|
|
|
|
|
|
// How many descriptors we are currently writing back
|
|
|
|
int wbOut;
|
|
|
|
|
|
|
|
// if the we wrote back to the end of the descriptor ring and are going
|
|
|
|
// to have to wrap and write more
|
|
|
|
bool moreToWb;
|
|
|
|
|
|
|
|
// What the alignment is of the next descriptor writeback
|
|
|
|
Addr wbAlignment;
|
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
/** The packet that is currently being dmad to memory if any */
|
2007-03-22 23:39:41 +01:00
|
|
|
EthPacketPtr pktPtr;
|
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
/** Shortcut for DMA address translation */
|
|
|
|
Addr pciToDma(Addr a) { return igbe->platform->pciToDma(a); }
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
public:
|
2009-02-27 01:29:17 +01:00
|
|
|
/** Annotate sm*/
|
|
|
|
std::string annSmFetch, annSmWb, annUnusedDescQ, annUsedCacheQ,
|
|
|
|
annUsedDescQ, annUnusedCacheQ, annDescQ;
|
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
DescCache(IGbE *i, const std::string n, int s);
|
|
|
|
virtual ~DescCache();
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
std::string name() { return _name; }
|
|
|
|
|
|
|
|
/** If the address/len/head change when we've got descriptors that are
|
|
|
|
* dirty that is very bad. This function checks that we don't and if we
|
|
|
|
* do panics.
|
|
|
|
*/
|
2009-04-22 07:58:53 +02:00
|
|
|
void areaChanged();
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
void writeback(Addr aMask);
|
|
|
|
void writeback1();
|
2008-08-13 23:41:58 +02:00
|
|
|
EventWrapper<DescCache, &DescCache::writeback1> wbDelayEvent;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
/** Fetch a chunk of descriptors into the descriptor cache.
|
|
|
|
* Calls fetchComplete when the memory system returns the data
|
|
|
|
*/
|
2009-04-22 07:58:53 +02:00
|
|
|
void fetchDescriptors();
|
|
|
|
void fetchDescriptors1();
|
2008-08-13 23:41:58 +02:00
|
|
|
EventWrapper<DescCache, &DescCache::fetchDescriptors1> fetchDelayEvent;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
/** Called by event when dma to read descriptors is completed
|
|
|
|
*/
|
2009-04-22 07:58:53 +02:00
|
|
|
void fetchComplete();
|
2007-03-22 23:39:41 +01:00
|
|
|
EventWrapper<DescCache, &DescCache::fetchComplete> fetchEvent;
|
|
|
|
|
|
|
|
/** Called by event when dma to writeback descriptors is completed
|
|
|
|
*/
|
2009-04-22 07:58:53 +02:00
|
|
|
void wbComplete();
|
2007-03-22 23:39:41 +01:00
|
|
|
EventWrapper<DescCache, &DescCache::wbComplete> wbEvent;
|
|
|
|
|
|
|
|
/* Return the number of descriptors left in the ring, so the device has
|
|
|
|
* a way to figure out if it needs to interrupt.
|
|
|
|
*/
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned
|
|
|
|
descLeft() const
|
2007-03-22 23:39:41 +01:00
|
|
|
{
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned left = unusedCache.size();
|
2009-05-21 06:52:32 +02:00
|
|
|
if (cachePnt > descTail())
|
2008-12-05 19:58:21 +01:00
|
|
|
left += (descLen() - cachePnt + descTail());
|
2007-03-22 23:39:41 +01:00
|
|
|
else
|
2007-03-27 00:40:18 +02:00
|
|
|
left += (descTail() - cachePnt);
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
return left;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the number of descriptors used and not written back.
|
|
|
|
*/
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned descUsed() const { return usedCache.size(); }
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
/* Return the number of cache unused descriptors we have. */
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned descUnused() const { return unusedCache.size(); }
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
/* Get into a state where the descriptor address/head/etc colud be
|
|
|
|
* changed */
|
2009-04-22 07:58:53 +02:00
|
|
|
void reset();
|
2008-08-13 23:41:58 +02:00
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
virtual void serialize(std::ostream &os);
|
|
|
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
2008-08-13 23:41:58 +02:00
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
virtual bool hasOutstandingEvents() {
|
|
|
|
return wbEvent.scheduled() || fetchEvent.scheduled();
|
|
|
|
}
|
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
};
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
|
|
|
|
class RxDescCache : public DescCache<iGbReg::RxDesc>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual Addr descBase() const { return igbe->regs.rdba(); }
|
|
|
|
virtual long descHead() const { return igbe->regs.rdh(); }
|
|
|
|
virtual long descLen() const { return igbe->regs.rdlen() >> 4; }
|
|
|
|
virtual long descTail() const { return igbe->regs.rdt(); }
|
|
|
|
virtual void updateHead(long h) { igbe->regs.rdh(h); }
|
|
|
|
virtual void enableSm();
|
2007-08-27 06:45:40 +02:00
|
|
|
virtual void fetchAfterWb() {
|
2012-11-02 17:32:01 +01:00
|
|
|
if (!igbe->rxTick && igbe->getDrainState() == Drainable::Running)
|
2007-08-27 06:45:40 +02:00
|
|
|
fetchDescriptors();
|
|
|
|
}
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
bool pktDone;
|
|
|
|
|
2009-01-06 16:36:57 +01:00
|
|
|
/** Variable to head with header/data completion events */
|
|
|
|
int splitCount;
|
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
/** Bytes of packet that have been copied, so we know when to
|
|
|
|
set EOP */
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned bytesCopied;
|
2009-01-06 16:36:57 +01:00
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
public:
|
|
|
|
RxDescCache(IGbE *i, std::string n, int s);
|
|
|
|
|
|
|
|
/** Write the given packet into the buffer(s) pointed to by the
|
|
|
|
* descriptor and update the book keeping. Should only be called when
|
|
|
|
* there are no dma's pending.
|
|
|
|
* @param packet ethernet packet to write
|
2009-01-06 16:36:57 +01:00
|
|
|
* @param pkt_offset bytes already copied from the packet to memory
|
|
|
|
* @return pkt_offset + number of bytes copied during this call
|
2007-03-22 23:39:41 +01:00
|
|
|
*/
|
2009-01-06 16:36:57 +01:00
|
|
|
int writePacket(EthPacketPtr packet, int pkt_offset);
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
/** Called by event when dma to write packet is completed
|
|
|
|
*/
|
|
|
|
void pktComplete();
|
|
|
|
|
2009-01-06 16:36:57 +01:00
|
|
|
/** Check if the dma on the packet has completed and RX state machine
|
|
|
|
* can continue
|
2007-03-22 23:39:41 +01:00
|
|
|
*/
|
|
|
|
bool packetDone();
|
|
|
|
|
|
|
|
EventWrapper<RxDescCache, &RxDescCache::pktComplete> pktEvent;
|
|
|
|
|
2009-01-06 16:36:57 +01:00
|
|
|
// Event to handle issuing header and data write at the same time
|
|
|
|
// and only callking pktComplete() when both are completed
|
|
|
|
void pktSplitDone();
|
|
|
|
EventWrapper<RxDescCache, &RxDescCache::pktSplitDone> pktHdrEvent;
|
|
|
|
EventWrapper<RxDescCache, &RxDescCache::pktSplitDone> pktDataEvent;
|
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
virtual bool hasOutstandingEvents();
|
|
|
|
|
|
|
|
virtual void serialize(std::ostream &os);
|
|
|
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
2007-03-22 23:39:41 +01:00
|
|
|
};
|
|
|
|
friend class RxDescCache;
|
|
|
|
|
|
|
|
RxDescCache rxDescCache;
|
|
|
|
|
|
|
|
class TxDescCache : public DescCache<iGbReg::TxDesc>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual Addr descBase() const { return igbe->regs.tdba(); }
|
|
|
|
virtual long descHead() const { return igbe->regs.tdh(); }
|
|
|
|
virtual long descTail() const { return igbe->regs.tdt(); }
|
|
|
|
virtual long descLen() const { return igbe->regs.tdlen() >> 4; }
|
|
|
|
virtual void updateHead(long h) { igbe->regs.tdh(h); }
|
|
|
|
virtual void enableSm();
|
2008-12-05 19:58:22 +01:00
|
|
|
virtual void actionAfterWb();
|
2007-08-27 06:45:40 +02:00
|
|
|
virtual void fetchAfterWb() {
|
2012-11-02 17:32:01 +01:00
|
|
|
if (!igbe->txTick && igbe->getDrainState() == Drainable::Running)
|
2007-08-27 06:45:40 +02:00
|
|
|
fetchDescriptors();
|
|
|
|
}
|
2008-12-05 19:58:22 +01:00
|
|
|
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
|
|
|
|
bool pktDone;
|
|
|
|
bool isTcp;
|
|
|
|
bool pktWaiting;
|
2008-05-20 22:06:56 +02:00
|
|
|
bool pktMultiDesc;
|
2008-12-05 19:58:22 +01:00
|
|
|
Addr completionAddress;
|
|
|
|
bool completionEnabled;
|
|
|
|
uint32_t descEnd;
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2008-12-05 19:58:21 +01:00
|
|
|
// tso variables
|
|
|
|
bool useTso;
|
|
|
|
Addr tsoHeaderLen;
|
|
|
|
Addr tsoMss;
|
|
|
|
Addr tsoTotalLen;
|
|
|
|
Addr tsoUsedLen;
|
2012-03-19 11:36:09 +01:00
|
|
|
Addr tsoPrevSeq;
|
2008-12-05 19:58:21 +01:00
|
|
|
Addr tsoPktPayloadBytes;
|
|
|
|
bool tsoLoadedHeader;
|
|
|
|
bool tsoPktHasHeader;
|
|
|
|
uint8_t tsoHeader[256];
|
|
|
|
Addr tsoDescBytesUsed;
|
|
|
|
Addr tsoCopyBytes;
|
|
|
|
int tsoPkts;
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
public:
|
|
|
|
TxDescCache(IGbE *i, std::string n, int s);
|
|
|
|
|
|
|
|
/** Tell the cache to DMA a packet from main memory into its buffer and
|
|
|
|
* return the size the of the packet to reserve space in tx fifo.
|
|
|
|
* @return size of the packet
|
|
|
|
*/
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned getPacketSize(EthPacketPtr p);
|
2007-03-22 23:39:41 +01:00
|
|
|
void getPacketData(EthPacketPtr p);
|
2008-12-05 19:58:21 +01:00
|
|
|
void processContextDesc();
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2008-12-05 19:58:22 +01:00
|
|
|
/** Return the number of dsecriptors in a cache block for threshold
|
|
|
|
* operations.
|
|
|
|
*/
|
2009-06-05 08:21:12 +02:00
|
|
|
unsigned
|
|
|
|
descInBlock(unsigned num_desc)
|
|
|
|
{
|
|
|
|
return num_desc / igbe->cacheBlockSize() / sizeof(iGbReg::TxDesc);
|
|
|
|
}
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
/** Ask if the packet has been transfered so the state machine can give
|
|
|
|
* it to the fifo.
|
|
|
|
* @return packet available in descriptor cache
|
|
|
|
*/
|
|
|
|
bool packetAvailable();
|
|
|
|
|
|
|
|
/** Ask if we are still waiting for the packet to be transfered.
|
|
|
|
* @return packet still in transit.
|
|
|
|
*/
|
|
|
|
bool packetWaiting() { return pktWaiting; }
|
|
|
|
|
2008-05-20 22:06:56 +02:00
|
|
|
/** Ask if this packet is composed of multiple descriptors
|
|
|
|
* so even if we've got data, we need to wait for more before
|
|
|
|
* we can send it out.
|
|
|
|
* @return packet can't be sent out because it's a multi-descriptor
|
|
|
|
* packet
|
|
|
|
*/
|
|
|
|
bool packetMultiDesc() { return pktMultiDesc;}
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
/** Called by event when dma to write packet is completed
|
|
|
|
*/
|
|
|
|
void pktComplete();
|
|
|
|
EventWrapper<TxDescCache, &TxDescCache::pktComplete> pktEvent;
|
|
|
|
|
2008-12-05 19:58:21 +01:00
|
|
|
void headerComplete();
|
|
|
|
EventWrapper<TxDescCache, &TxDescCache::headerComplete> headerEvent;
|
|
|
|
|
2008-12-05 19:58:22 +01:00
|
|
|
|
|
|
|
void completionWriteback(Addr a, bool enabled) {
|
2009-04-22 07:58:53 +02:00
|
|
|
DPRINTF(EthernetDesc,
|
|
|
|
"Completion writeback Addr: %#x enabled: %d\n",
|
2008-12-05 19:58:22 +01:00
|
|
|
a, enabled);
|
|
|
|
completionAddress = a;
|
|
|
|
completionEnabled = enabled;
|
|
|
|
}
|
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
virtual bool hasOutstandingEvents();
|
|
|
|
|
2009-04-22 07:58:53 +02:00
|
|
|
void nullCallback() {
|
|
|
|
DPRINTF(EthernetDesc, "Completion writeback complete\n");
|
|
|
|
}
|
2008-12-05 19:58:22 +01:00
|
|
|
EventWrapper<TxDescCache, &TxDescCache::nullCallback> nullEvent;
|
|
|
|
|
2007-03-30 04:00:01 +02:00
|
|
|
virtual void serialize(std::ostream &os);
|
|
|
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
|
|
|
|
2007-03-22 23:39:41 +01:00
|
|
|
};
|
|
|
|
friend class TxDescCache;
|
|
|
|
|
|
|
|
TxDescCache txDescCache;
|
2006-09-19 02:12:45 +02:00
|
|
|
|
|
|
|
public:
|
2007-07-24 06:51:38 +02:00
|
|
|
typedef IGbEParams Params;
|
|
|
|
const Params *
|
2009-04-22 07:58:53 +02:00
|
|
|
params() const {
|
2007-07-24 06:51:38 +02:00
|
|
|
return dynamic_cast<const Params *>(_params);
|
|
|
|
}
|
2009-04-22 07:58:53 +02:00
|
|
|
|
2007-08-16 22:49:02 +02:00
|
|
|
IGbE(const Params *params);
|
2012-07-09 18:35:30 +02:00
|
|
|
~IGbE();
|
2009-02-27 01:29:17 +01:00
|
|
|
virtual void init();
|
2006-09-19 02:12:45 +02:00
|
|
|
|
2007-08-16 22:49:02 +02:00
|
|
|
virtual EtherInt *getEthPort(const std::string &if_name, int idx);
|
|
|
|
|
2008-07-01 16:30:08 +02:00
|
|
|
Tick lastInterrupt;
|
2007-03-22 23:39:41 +01:00
|
|
|
|
2006-10-20 09:10:12 +02:00
|
|
|
virtual Tick read(PacketPtr pkt);
|
|
|
|
virtual Tick write(PacketPtr pkt);
|
2006-09-19 02:12:45 +02:00
|
|
|
|
2006-10-20 09:10:12 +02:00
|
|
|
virtual Tick writeConfig(PacketPtr pkt);
|
2006-09-19 02:12:45 +02:00
|
|
|
|
|
|
|
bool ethRxPkt(EthPacketPtr packet);
|
|
|
|
void ethTxDone();
|
|
|
|
|
|
|
|
virtual void serialize(std::ostream &os);
|
|
|
|
virtual void unserialize(Checkpoint *cp, const std::string §ion);
|
2012-11-02 17:32:01 +01:00
|
|
|
|
|
|
|
unsigned int drain(DrainManager *dm);
|
|
|
|
void drainResume();
|
2006-09-19 02:12:45 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class IGbEInt : public EtherInt
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
IGbE *dev;
|
|
|
|
|
|
|
|
public:
|
|
|
|
IGbEInt(const std::string &name, IGbE *d)
|
|
|
|
: EtherInt(name), dev(d)
|
2007-08-16 22:49:02 +02:00
|
|
|
{ }
|
2006-09-19 02:12:45 +02:00
|
|
|
|
|
|
|
virtual bool recvPacket(EthPacketPtr pkt) { return dev->ethRxPkt(pkt); }
|
|
|
|
virtual void sendDone() { dev->ethTxDone(); }
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__DEV_I8254XGBE_HH__
|