2004-03-12 17:04:58 +01:00
|
|
|
/*
|
2005-06-05 11:16:00 +02:00
|
|
|
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
2004-03-12 17:04:58 +01:00
|
|
|
* 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.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
2006-06-17 23:49:38 +02:00
|
|
|
* Authors: Nathan Binkert
|
|
|
|
* Lisa Hsu
|
2004-03-12 17:04:58 +01:00
|
|
|
*/
|
|
|
|
|
2005-06-05 07:22:21 +02:00
|
|
|
/** @file
|
2004-03-12 17:04:58 +01:00
|
|
|
* Device module for modelling the National Semiconductor
|
|
|
|
* DP83820 ethernet controller. Does not support priority queueing
|
|
|
|
*/
|
|
|
|
#include <deque>
|
|
|
|
#include <string>
|
|
|
|
|
2009-02-23 20:48:40 +01:00
|
|
|
#include "base/debug.hh"
|
2004-03-12 17:04:58 +01:00
|
|
|
#include "base/inet.hh"
|
2009-05-17 23:34:52 +02:00
|
|
|
#include "base/types.hh"
|
2009-09-23 17:34:21 +02:00
|
|
|
#include "config/the_isa.hh"
|
2006-06-06 23:32:21 +02:00
|
|
|
#include "cpu/thread_context.hh"
|
2004-03-12 17:04:58 +01:00
|
|
|
#include "dev/etherlink.hh"
|
2004-07-27 05:10:20 +02:00
|
|
|
#include "dev/ns_gige.hh"
|
|
|
|
#include "dev/pciconfigall.hh"
|
2006-04-25 01:31:50 +02:00
|
|
|
#include "mem/packet.hh"
|
2006-10-20 08:38:45 +02:00
|
|
|
#include "mem/packet_access.hh"
|
2007-07-24 06:51:38 +02:00
|
|
|
#include "params/NSGigE.hh"
|
2006-04-25 01:31:50 +02:00
|
|
|
#include "sim/system.hh"
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
const char *NsRxStateStrings[] =
|
|
|
|
{
|
|
|
|
"rxIdle",
|
|
|
|
"rxDescRefr",
|
|
|
|
"rxDescRead",
|
|
|
|
"rxFifoBlock",
|
|
|
|
"rxFragWrite",
|
|
|
|
"rxDescWrite",
|
|
|
|
"rxAdvance"
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *NsTxStateStrings[] =
|
|
|
|
{
|
|
|
|
"txIdle",
|
|
|
|
"txDescRefr",
|
|
|
|
"txDescRead",
|
|
|
|
"txFifoBlock",
|
|
|
|
"txFragRead",
|
|
|
|
"txDescWrite",
|
|
|
|
"txAdvance"
|
|
|
|
};
|
|
|
|
|
|
|
|
const char *NsDmaState[] =
|
|
|
|
{
|
|
|
|
"dmaIdle",
|
|
|
|
"dmaReading",
|
|
|
|
"dmaWriting",
|
|
|
|
"dmaReadWaiting",
|
|
|
|
"dmaWriteWaiting"
|
|
|
|
};
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
using namespace std;
|
2004-10-23 22:18:44 +02:00
|
|
|
using namespace Net;
|
Changes to untemplate StaticInst and StaticInstPtr, change the isa to a namespace instead of a class, an improvement to the architecture specific header file selection system, and fixed up a few include paths.
arch/alpha/alpha_linux_process.cc:
Added using directive for AlphaISA namespace
arch/alpha/alpha_memory.hh:
arch/alpha/isa/branch.isa:
cpu/pc_event.hh:
Added typedefs for Addr
arch/alpha/alpha_tru64_process.cc:
arch/alpha/arguments.cc:
Added using directive for AlphaISA
arch/alpha/ev5.hh:
Added an include of arch/alpha/isa_traits.hh, and a using directive for the AlphaISA namespace.
arch/alpha/faults.hh:
Added a typedef for the Addr type, and changed the formatting of the faults slightly.
arch/alpha/isa/main.isa:
Untemplatized StaticInst, added a using for namespace AlphaISA to show up in decoder.cc and the exec.ccs, relocated makeNop to decoder.hh
arch/alpha/isa/mem.isa:
Untemplatized StaticInst and StaticInstPtr
arch/alpha/isa/pal.isa:
cpu/base_dyn_inst.cc:
Untemplatized StaticInstPtr
arch/alpha/isa_traits.hh:
Changed variables to be externs instead of static since they are part of a namespace and not a class.
arch/alpha/stacktrace.cc:
Untemplatized StaticInstPtr, and added a using directive for AlphaISA.
arch/alpha/stacktrace.hh:
Added some typedefs for Addr and MachInst, and untemplatized StaticInstPtr
arch/alpha/vtophys.cc:
Added a using directive for AlphaISA
arch/alpha/vtophys.hh:
Added the AlphaISA namespace specifier where needed
arch/isa_parser.py:
Changed the placement of the definition of the decodeInst function to be outside the namespaceInst namespace.
base/loader/object_file.hh:
cpu/o3/bpred_unit.hh:
Added a typedef for Addr
base/loader/symtab.hh:
Added a typedef for Addr, and added a TheISA to Addr in another typedef
base/remote_gdb.cc:
Added a using namespace TheISA, and untemplatized StaticInstPtr
base/remote_gdb.hh:
Added typedefs for Addr and MachInst
cpu/base.cc:
Added TheISA specifier to some variables exported from the isa.
cpu/base.hh:
Added a typedef for Addr, and TheISA to some variables from the ISA
cpu/base_dyn_inst.hh:
Untemplatized StaticInstPtr, and added TheISA specifier to some variables from the ISA.
cpu/exec_context.hh:
Added some typedefs for types from the isa, and added TheISA specifier to some variables from the isa
cpu/exetrace.hh:
Added typedefs for some types from the ISA, and untemplatized StaticInstPtr
cpu/memtest/memtest.cc:
cpu/o3/btb.cc:
dev/baddev.cc:
dev/ide_ctrl.cc:
dev/ide_disk.cc:
dev/isa_fake.cc:
dev/ns_gige.cc:
dev/pciconfigall.cc:
dev/platform.cc:
dev/sinic.cc:
dev/uart8250.cc:
kern/freebsd/freebsd_system.cc:
kern/linux/linux_system.cc:
kern/system_events.cc:
kern/tru64/dump_mbuf.cc:
kern/tru64/tru64_events.cc:
sim/process.cc:
sim/pseudo_inst.cc:
sim/system.cc:
Added using namespace TheISA
cpu/memtest/memtest.hh:
cpu/trace/opt_cpu.hh:
cpu/trace/reader/itx_reader.hh:
dev/ide_disk.hh:
dev/pcidev.hh:
dev/platform.hh:
dev/tsunami.hh:
sim/system.hh:
sim/vptr.hh:
Added typedef for Addr
cpu/o3/2bit_local_pred.hh:
Changed the include to use arch/isa_traits.hh instead of arch/alpha/isa_traits.hh. Added typedef for Addr
cpu/o3/alpha_cpu.hh:
Added typedefs for Addr and IntReg
cpu/o3/alpha_cpu_impl.hh:
Added this-> to setNextPC to fix a problem since it didn't depend on template parameters any more. Removed "typename" where it was no longer needed.
cpu/o3/alpha_dyn_inst.hh:
Cleaned up some typedefs, and untemplatized StaticInst
cpu/o3/alpha_dyn_inst_impl.hh:
untemplatized StaticInstPtr
cpu/o3/alpha_impl.hh:
Fixed up a typedef of MachInst
cpu/o3/bpred_unit_impl.hh:
Added a using TheISA::MachInst to a function
cpu/o3/btb.hh:
Changed an include from arch/alpha/isa_traits.hh to arch/isa_traits.hh, and added a typedef for Addr
cpu/o3/commit.hh:
Removed a typedef of Impl::ISA as ISA, since TheISA takes care of this now.
cpu/o3/cpu.cc:
Cleaned up namespace issues
cpu/o3/cpu.hh:
Cleaned up namespace usage
cpu/o3/decode.hh:
Removed typedef of ISA, and changed it to TheISA
cpu/o3/fetch.hh:
Fized up typedefs, and changed ISA to TheISA
cpu/o3/free_list.hh:
Changed include of arch/alpha/isa_traits.hh to arch/isa_traits.hh
cpu/o3/iew.hh:
Removed typedef of ISA
cpu/o3/iew_impl.hh:
Added TheISA namespace specifier to MachInst
cpu/o3/ras.hh:
Changed include from arch/alpha/isa_traits.hh to arch/isa_traits.hh, and added a typedef for Addr.
cpu/o3/regfile.hh:
Changed ISA to TheISA, and added some typedefs for Addr, IntReg, FloatReg, and MiscRegFile
cpu/o3/rename.hh:
Changed ISA to TheISA, and added a typedef for RegIndex
cpu/o3/rename_map.hh:
Added an include for arch/isa_traits.hh, and a typedef for RegIndex
cpu/o3/rob.hh:
Added a typedef for RegIndex
cpu/o3/store_set.hh:
cpu/o3/tournament_pred.hh:
Changed an include of arch/alpha/isa_traits.hh to arch/isa_traits.hh, and added a typedef of Addr
cpu/ozone/cpu.hh:
Changed ISA into TheISA, and untemplatized StaticInst
cpu/pc_event.cc:
Added namespace specifier TheISA to Addr types
cpu/profile.hh:
kern/kernel_stats.hh:
Added typedef for Addr, and untemplatized StaticInstPtr
cpu/simple/cpu.cc:
Changed using directive from LittleEndianGuest to AlphaISA, which will contain both namespaces. Added TheISA where needed, and untemplatized StaticInst
cpu/simple/cpu.hh:
Added a typedef for MachInst, and untemplatized StaticInst
cpu/static_inst.cc:
Untemplatized StaticInst
cpu/static_inst.hh:
Untemplatized StaticInst by using the TheISA namespace
dev/alpha_console.cc:
Added using namespace AlphaISA
dev/simple_disk.hh:
Added typedef for Addr and fixed up some formatting
dev/sinicreg.hh:
Added TheISA namespace specifier where needed
dev/tsunami.cc:
dev/tsunami_io.cc:
dev/tsunami_pchip.cc:
Added using namespace TheISA. It might be better for it to be AlphaISA
dev/tsunami_cchip.cc:
Added typedef for TheISA. It might be better for it to be AlphaISA
kern/linux/aligned.hh:
sim/pseudo_inst.hh:
Added TheISA namespace specifier to Addr
kern/linux/linux_threadinfo.hh:
Added typedef for Addr, and TheISA namespace specifier to StackPointerReg
kern/tru64/mbuf.hh:
Added TheISA to Addr type in structs
sim/process.hh:
Added typedefs of Addr, RegFile, and MachInst
sim/syscall_emul.cc:
Added using namespace TheISA, and a cast of VMPageSize to the int type
sim/syscall_emul.hh:
Added typecast for Addr, and TheISA namespace specifier for where needed
--HG--
extra : convert_revision : 91d4f6ca33a73b21c1f1771d74bfdea3b80eff45
2006-02-19 08:34:37 +01:00
|
|
|
using namespace TheISA;
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2004-05-25 21:59:54 +02:00
|
|
|
// NSGigE PCI Device
|
2004-03-12 17:04:58 +01:00
|
|
|
//
|
2004-11-13 21:45:22 +01:00
|
|
|
NSGigE::NSGigE(Params *p)
|
2007-08-16 22:49:02 +02:00
|
|
|
: EtherDevice(p), ioEnable(false),
|
2004-11-13 21:45:22 +01:00
|
|
|
txFifo(p->tx_fifo_size), rxFifo(p->rx_fifo_size),
|
2004-06-11 21:26:21 +02:00
|
|
|
txPacket(0), rxPacket(0), txPacketBufPtr(NULL), rxPacketBufPtr(NULL),
|
2007-02-22 05:45:05 +01:00
|
|
|
txXferLen(0), rxXferLen(0), rxDmaFree(false), txDmaFree(false),
|
|
|
|
clock(p->clock),
|
|
|
|
txState(txIdle), txEnable(false), CTDD(false), txHalt(false),
|
2004-04-22 00:23:41 +02:00
|
|
|
txFragPtr(0), txDescCnt(0), txDmaState(dmaIdle), rxState(rxIdle),
|
2007-02-22 05:45:05 +01:00
|
|
|
rxEnable(false), CRDD(false), rxPktBytes(0), rxHalt(false),
|
2004-04-22 00:23:41 +02:00
|
|
|
rxFragPtr(0), rxDescCnt(0), rxDmaState(dmaIdle), extstsEnable(false),
|
2007-02-22 05:45:05 +01:00
|
|
|
eepromState(eepromStart), eepromClk(false), eepromBitsToRx(0),
|
|
|
|
eepromOpcode(0), eepromAddress(0), eepromData(0),
|
|
|
|
dmaReadDelay(p->dma_read_delay), dmaWriteDelay(p->dma_write_delay),
|
|
|
|
dmaReadFactor(p->dma_read_factor), dmaWriteFactor(p->dma_write_factor),
|
|
|
|
rxDmaData(NULL), rxDmaAddr(0), rxDmaLen(0),
|
|
|
|
txDmaData(NULL), txDmaAddr(0), txDmaLen(0),
|
|
|
|
rxDmaReadEvent(this), rxDmaWriteEvent(this),
|
2004-04-22 00:23:41 +02:00
|
|
|
txDmaReadEvent(this), txDmaWriteEvent(this),
|
2004-11-13 21:45:22 +01:00
|
|
|
dmaDescFree(p->dma_desc_free), dmaDataFree(p->dma_data_free),
|
|
|
|
txDelay(p->tx_delay), rxDelay(p->rx_delay),
|
2005-06-27 23:02:40 +02:00
|
|
|
rxKickTick(0), rxKickEvent(this), txKickTick(0), txKickEvent(this),
|
2007-02-22 05:45:05 +01:00
|
|
|
txEvent(this), rxFilterEnable(p->rx_filter),
|
|
|
|
acceptBroadcast(false), acceptMulticast(false), acceptUnicast(false),
|
2005-08-13 00:30:35 +02:00
|
|
|
acceptPerfect(false), acceptArp(false), multicastHashEnable(false),
|
2007-02-22 05:45:05 +01:00
|
|
|
intrDelay(p->intr_delay), intrTick(0), cpuPendingIntr(false),
|
2004-07-13 04:58:22 +02:00
|
|
|
intrEvent(0), interface(0)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
|
2007-08-16 22:49:02 +02:00
|
|
|
interface = new NSGigEInt(name() + ".int0", this);
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
regsReset();
|
2007-07-24 06:51:38 +02:00
|
|
|
memcpy(&rom.perfectMatch, p->hardware_address.bytes(), ETH_ADDR_LEN);
|
2005-10-12 19:39:40 +02:00
|
|
|
|
|
|
|
memset(&rxDesc32, 0, sizeof(rxDesc32));
|
|
|
|
memset(&txDesc32, 0, sizeof(txDesc32));
|
|
|
|
memset(&rxDesc64, 0, sizeof(rxDesc64));
|
|
|
|
memset(&txDesc64, 0, sizeof(txDesc64));
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::~NSGigE()
|
2004-03-12 17:04:58 +01:00
|
|
|
{}
|
|
|
|
|
2004-04-22 00:43:39 +02:00
|
|
|
/**
|
|
|
|
* This is to write to the PCI general configuration registers
|
|
|
|
*/
|
2006-07-06 20:41:01 +02:00
|
|
|
Tick
|
2006-10-20 09:10:12 +02:00
|
|
|
NSGigE::writeConfig(PacketPtr pkt)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2006-07-06 20:41:01 +02:00
|
|
|
int offset = pkt->getAddr() & PCI_CONFIG_SIZE;
|
2004-03-12 17:04:58 +01:00
|
|
|
if (offset < PCI_DEVICE_SPECIFIC)
|
2006-07-06 20:41:01 +02:00
|
|
|
PciDev::writeConfig(pkt);
|
2004-03-12 17:04:58 +01:00
|
|
|
else
|
2004-06-04 21:12:27 +02:00
|
|
|
panic("Device specific PCI config space not implemented!\n");
|
|
|
|
|
|
|
|
switch (offset) {
|
2004-07-27 05:10:20 +02:00
|
|
|
// seems to work fine without all these PCI settings, but i
|
|
|
|
// put in the IO to double check, an assertion will fail if we
|
|
|
|
// need to properly implement it
|
2004-06-12 20:24:20 +02:00
|
|
|
case PCI_COMMAND:
|
|
|
|
if (config.data[offset] & PCI_CMD_IOSE)
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
ioEnable = true;
|
2004-06-12 20:24:20 +02:00
|
|
|
else
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
ioEnable = false;
|
2004-06-04 21:12:27 +02:00
|
|
|
break;
|
|
|
|
}
|
2007-07-01 02:56:30 +02:00
|
|
|
|
2006-07-06 20:41:01 +02:00
|
|
|
return configDelay;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2007-08-16 22:49:02 +02:00
|
|
|
EtherInt*
|
|
|
|
NSGigE::getEthPort(const std::string &if_name, int idx)
|
|
|
|
{
|
|
|
|
if (if_name == "interface") {
|
|
|
|
if (interface->getPeer())
|
|
|
|
panic("interface already connected to\n");
|
|
|
|
return interface;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-04-22 00:43:39 +02:00
|
|
|
/**
|
|
|
|
* This reads the device registers, which are detailed in the NS83820
|
|
|
|
* spec sheet
|
|
|
|
*/
|
2006-04-25 01:31:50 +02:00
|
|
|
Tick
|
2006-10-20 09:10:12 +02:00
|
|
|
NSGigE::read(PacketPtr pkt)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
assert(ioEnable);
|
2004-06-12 20:24:20 +02:00
|
|
|
|
2006-05-19 04:32:21 +02:00
|
|
|
pkt->allocate();
|
2006-04-25 01:31:50 +02:00
|
|
|
|
2004-04-22 00:43:39 +02:00
|
|
|
//The mask is to give you only the offset into the device register file
|
2006-05-26 20:17:33 +02:00
|
|
|
Addr daddr = pkt->getAddr() & 0xfff;
|
2006-04-25 01:31:50 +02:00
|
|
|
DPRINTF(EthernetPIO, "read da=%#x pa=%#x size=%d\n",
|
2006-05-26 20:17:33 +02:00
|
|
|
daddr, pkt->getAddr(), pkt->getSize());
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:43:39 +02:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
// there are some reserved registers, you can see ns_gige_reg.h and
|
|
|
|
// the spec sheet for details
|
2004-04-22 00:23:41 +02:00
|
|
|
if (daddr > LAST && daddr <= RESERVED) {
|
2004-03-12 17:04:58 +01:00
|
|
|
panic("Accessing reserved register");
|
2004-04-22 00:23:41 +02:00
|
|
|
} else if (daddr > RESERVED && daddr <= 0x3FC) {
|
2006-07-06 20:41:01 +02:00
|
|
|
return readConfig(pkt);
|
2004-04-22 00:23:41 +02:00
|
|
|
} else if (daddr >= MIB_START && daddr <= MIB_END) {
|
|
|
|
// don't implement all the MIB's. hopefully the kernel
|
|
|
|
// doesn't actually DEPEND upon their values
|
2004-04-22 00:43:39 +02:00
|
|
|
// MIB are just hardware stats keepers
|
2006-05-19 04:32:21 +02:00
|
|
|
pkt->set<uint32_t>(0);
|
2007-06-30 19:16:18 +02:00
|
|
|
pkt->makeAtomicResponse();
|
2006-04-25 01:31:50 +02:00
|
|
|
return pioDelay;
|
2004-04-22 00:23:41 +02:00
|
|
|
} else if (daddr > 0x3FC)
|
|
|
|
panic("Something is messed up!\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-05-26 20:17:33 +02:00
|
|
|
assert(pkt->getSize() == sizeof(uint32_t));
|
2006-05-19 04:32:21 +02:00
|
|
|
uint32_t ® = *pkt->getPtr<uint32_t>();
|
2006-04-25 01:31:50 +02:00
|
|
|
uint16_t rfaddr;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
switch (daddr) {
|
|
|
|
case CR:
|
|
|
|
reg = regs.command;
|
|
|
|
//these are supposed to be cleared on a read
|
|
|
|
reg &= ~(CR_RXD | CR_TXD | CR_TXR | CR_RXR);
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case CFGR:
|
|
|
|
reg = regs.config;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case MEAR:
|
|
|
|
reg = regs.mear;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case PTSCR:
|
|
|
|
reg = regs.ptscr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case ISR:
|
|
|
|
reg = regs.isr;
|
|
|
|
devIntrClear(ISR_ALL);
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case IMR:
|
|
|
|
reg = regs.imr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case IER:
|
|
|
|
reg = regs.ier;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case IHR:
|
|
|
|
reg = regs.ihr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TXDP:
|
|
|
|
reg = regs.txdp;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TXDP_HI:
|
|
|
|
reg = regs.txdp_hi;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TX_CFG:
|
|
|
|
reg = regs.txcfg;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case GPIOR:
|
|
|
|
reg = regs.gpior;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case RXDP:
|
|
|
|
reg = regs.rxdp;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case RXDP_HI:
|
|
|
|
reg = regs.rxdp_hi;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case RX_CFG:
|
|
|
|
reg = regs.rxcfg;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case PQCR:
|
|
|
|
reg = regs.pqcr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case WCSR:
|
|
|
|
reg = regs.wcsr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCR:
|
|
|
|
reg = regs.pcr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// see the spec sheet for how RFCR and RFDR work
|
|
|
|
// basically, you write to RFCR to tell the machine
|
|
|
|
// what you want to do next, then you act upon RFDR,
|
|
|
|
// and the device will be prepared b/c of what you
|
|
|
|
// wrote to RFCR
|
|
|
|
case RFCR:
|
|
|
|
reg = regs.rfcr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case RFDR:
|
|
|
|
rfaddr = (uint16_t)(regs.rfcr & RFCR_RFADDR);
|
|
|
|
switch (rfaddr) {
|
|
|
|
// Read from perfect match ROM octets
|
|
|
|
case 0x000:
|
|
|
|
reg = rom.perfectMatch[1];
|
|
|
|
reg = reg << 8;
|
|
|
|
reg += rom.perfectMatch[0];
|
|
|
|
break;
|
|
|
|
case 0x002:
|
|
|
|
reg = rom.perfectMatch[3] << 8;
|
|
|
|
reg += rom.perfectMatch[2];
|
2004-03-12 17:04:58 +01:00
|
|
|
break;
|
2006-04-25 01:31:50 +02:00
|
|
|
case 0x004:
|
|
|
|
reg = rom.perfectMatch[5] << 8;
|
|
|
|
reg += rom.perfectMatch[4];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Read filter hash table
|
|
|
|
if (rfaddr >= FHASH_ADDR &&
|
|
|
|
rfaddr < FHASH_ADDR + FHASH_SIZE) {
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
// Only word-aligned reads supported
|
|
|
|
if (rfaddr % 2)
|
|
|
|
panic("unaligned read from filter hash table!");
|
2005-08-13 00:30:35 +02:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
reg = rom.filterHash[rfaddr - FHASH_ADDR + 1] << 8;
|
|
|
|
reg += rom.filterHash[rfaddr - FHASH_ADDR];
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
panic("reading RFDR for something other than pattern"
|
|
|
|
" matching or hashing! %#x\n", rfaddr);
|
|
|
|
}
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case SRR:
|
|
|
|
reg = regs.srr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case MIBC:
|
|
|
|
reg = regs.mibc;
|
|
|
|
reg &= ~(MIBC_MIBS | MIBC_ACLR);
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case VRCR:
|
|
|
|
reg = regs.vrcr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case VTCR:
|
|
|
|
reg = regs.vtcr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case VDR:
|
|
|
|
reg = regs.vdr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case CCSR:
|
|
|
|
reg = regs.ccsr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TBICR:
|
|
|
|
reg = regs.tbicr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TBISR:
|
|
|
|
reg = regs.tbisr;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TANAR:
|
|
|
|
reg = regs.tanar;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TANLPAR:
|
|
|
|
reg = regs.tanlpar;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TANER:
|
|
|
|
reg = regs.taner;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case TESR:
|
|
|
|
reg = regs.tesr;
|
|
|
|
break;
|
2005-04-25 03:32:32 +02:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
case M5REG:
|
|
|
|
reg = 0;
|
|
|
|
if (params()->rx_thread)
|
|
|
|
reg |= M5REG_RX_THREAD;
|
|
|
|
if (params()->tx_thread)
|
|
|
|
reg |= M5REG_TX_THREAD;
|
|
|
|
if (params()->rss)
|
|
|
|
reg |= M5REG_RSS;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
default:
|
|
|
|
panic("reading unimplemented register: addr=%#x", daddr);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
DPRINTF(EthernetPIO, "read from %#x: data=%d data=%#x\n",
|
|
|
|
daddr, reg, reg);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2007-06-30 19:16:18 +02:00
|
|
|
pkt->makeAtomicResponse();
|
2006-04-25 01:31:50 +02:00
|
|
|
return pioDelay;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2006-04-25 01:31:50 +02:00
|
|
|
Tick
|
2006-10-20 09:10:12 +02:00
|
|
|
NSGigE::write(PacketPtr pkt)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
assert(ioEnable);
|
2004-06-12 20:24:20 +02:00
|
|
|
|
2006-05-26 20:17:33 +02:00
|
|
|
Addr daddr = pkt->getAddr() & 0xfff;
|
2006-04-25 01:31:50 +02:00
|
|
|
DPRINTF(EthernetPIO, "write da=%#x pa=%#x size=%d\n",
|
2006-05-26 20:17:33 +02:00
|
|
|
daddr, pkt->getAddr(), pkt->getSize());
|
2006-04-25 01:31:50 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (daddr > LAST && daddr <= RESERVED) {
|
2004-03-12 17:04:58 +01:00
|
|
|
panic("Accessing reserved register");
|
2004-04-22 00:23:41 +02:00
|
|
|
} else if (daddr > RESERVED && daddr <= 0x3FC) {
|
2006-07-06 20:41:01 +02:00
|
|
|
return writeConfig(pkt);
|
2004-04-22 00:23:41 +02:00
|
|
|
} else if (daddr > 0x3FC)
|
|
|
|
panic("Something is messed up!\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2006-05-26 20:17:33 +02:00
|
|
|
if (pkt->getSize() == sizeof(uint32_t)) {
|
2006-05-19 04:32:21 +02:00
|
|
|
uint32_t reg = pkt->get<uint32_t>();
|
2005-08-18 19:29:40 +02:00
|
|
|
uint16_t rfaddr;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
DPRINTF(EthernetPIO, "write data=%d data=%#x\n", reg, reg);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
switch (daddr) {
|
|
|
|
case CR:
|
|
|
|
regs.command = reg;
|
2004-07-30 17:29:45 +02:00
|
|
|
if (reg & CR_TXD) {
|
|
|
|
txEnable = false;
|
2004-03-12 17:04:58 +01:00
|
|
|
} else if (reg & CR_TXE) {
|
2006-02-21 05:41:50 +01:00
|
|
|
txEnable = true;
|
2004-07-30 17:29:45 +02:00
|
|
|
|
2006-02-21 05:41:50 +01:00
|
|
|
// the kernel is enabling the transmit machine
|
|
|
|
if (txState == txIdle)
|
|
|
|
txKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-07-30 17:29:45 +02:00
|
|
|
if (reg & CR_RXD) {
|
|
|
|
rxEnable = false;
|
2004-03-12 17:04:58 +01:00
|
|
|
} else if (reg & CR_RXE) {
|
2006-02-21 05:41:50 +01:00
|
|
|
rxEnable = true;
|
2004-07-30 17:29:45 +02:00
|
|
|
|
2006-02-21 05:41:50 +01:00
|
|
|
if (rxState == rxIdle)
|
|
|
|
rxKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (reg & CR_TXR)
|
|
|
|
txReset();
|
|
|
|
|
|
|
|
if (reg & CR_RXR)
|
|
|
|
rxReset();
|
|
|
|
|
|
|
|
if (reg & CR_SWI)
|
|
|
|
devIntrPost(ISR_SWI);
|
|
|
|
|
|
|
|
if (reg & CR_RST) {
|
|
|
|
txReset();
|
|
|
|
rxReset();
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
regsReset();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
case CFGR:
|
|
|
|
if (reg & CFGR_LNKSTS ||
|
|
|
|
reg & CFGR_SPDSTS ||
|
|
|
|
reg & CFGR_DUPSTS ||
|
|
|
|
reg & CFGR_RESERVED ||
|
|
|
|
reg & CFGR_T64ADDR ||
|
|
|
|
reg & CFGR_PCI64_DET)
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-08-13 00:30:35 +02:00
|
|
|
// First clear all writable bits
|
|
|
|
regs.config &= CFGR_LNKSTS | CFGR_SPDSTS | CFGR_DUPSTS |
|
|
|
|
CFGR_RESERVED | CFGR_T64ADDR |
|
|
|
|
CFGR_PCI64_DET;
|
|
|
|
// Now set the appropriate writable bits
|
2005-05-29 03:54:32 +02:00
|
|
|
regs.config |= reg & ~(CFGR_LNKSTS | CFGR_SPDSTS | CFGR_DUPSTS |
|
2005-06-27 23:02:40 +02:00
|
|
|
CFGR_RESERVED | CFGR_T64ADDR |
|
|
|
|
CFGR_PCI64_DET);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
// all these #if 0's are because i don't THINK the kernel needs to
|
|
|
|
// have these implemented. if there is a problem relating to one of
|
|
|
|
// these, you may need to add functionality in.
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_TBI_EN) ;
|
|
|
|
if (reg & CFGR_MODE_1000) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_AUTO_1000)
|
|
|
|
panic("CFGR_AUTO_1000 not implemented!\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_PINT_DUPSTS ||
|
|
|
|
reg & CFGR_PINT_LNKSTS ||
|
|
|
|
reg & CFGR_PINT_SPDSTS)
|
2004-07-27 05:10:20 +02:00
|
|
|
;
|
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_TMRTEST) ;
|
|
|
|
if (reg & CFGR_MRM_DIS) ;
|
|
|
|
if (reg & CFGR_MWI_DIS) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
if (reg & CFGR_T64ADDR) ;
|
|
|
|
// panic("CFGR_T64ADDR is read only register!\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_PCI64_DET)
|
|
|
|
panic("CFGR_PCI64_DET is read only register!\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_DATA64_EN) ;
|
|
|
|
if (reg & CFGR_M64ADDR) ;
|
|
|
|
if (reg & CFGR_PHY_RST) ;
|
|
|
|
if (reg & CFGR_PHY_DIS) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & CFGR_EXTSTS_EN)
|
2004-03-12 17:04:58 +01:00
|
|
|
extstsEnable = true;
|
|
|
|
else
|
|
|
|
extstsEnable = false;
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
if (reg & CFGR_REQALG) ;
|
|
|
|
if (reg & CFGR_SB) ;
|
|
|
|
if (reg & CFGR_POW) ;
|
|
|
|
if (reg & CFGR_EXD) ;
|
|
|
|
if (reg & CFGR_PESEL) ;
|
|
|
|
if (reg & CFGR_BROM_DIS) ;
|
|
|
|
if (reg & CFGR_EXT_125) ;
|
|
|
|
if (reg & CFGR_BEM) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MEAR:
|
2005-08-13 00:30:35 +02:00
|
|
|
// Clear writable bits
|
|
|
|
regs.mear &= MEAR_EEDO;
|
|
|
|
// Set appropriate writable bits
|
|
|
|
regs.mear |= reg & ~MEAR_EEDO;
|
|
|
|
|
|
|
|
// FreeBSD uses the EEPROM to read PMATCH (for the MAC address)
|
|
|
|
// even though it could get it through RFDR
|
|
|
|
if (reg & MEAR_EESEL) {
|
|
|
|
// Rising edge of clock
|
|
|
|
if (reg & MEAR_EECLK && !eepromClk)
|
|
|
|
eepromKick();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
eepromState = eepromStart;
|
|
|
|
regs.mear &= ~MEAR_EEDI;
|
|
|
|
}
|
|
|
|
|
|
|
|
eepromClk = reg & MEAR_EECLK;
|
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
// since phy is completely faked, MEAR_MD* don't matter
|
2004-03-12 17:04:58 +01:00
|
|
|
if (reg & MEAR_MDIO) ;
|
|
|
|
if (reg & MEAR_MDDIR) ;
|
|
|
|
if (reg & MEAR_MDC) ;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PTSCR:
|
2004-04-22 00:23:41 +02:00
|
|
|
regs.ptscr = reg & ~(PTSCR_RBIST_RDONLY);
|
2004-07-27 05:10:20 +02:00
|
|
|
// these control BISTs for various parts of chip - we
|
|
|
|
// don't care or do just fake that the BIST is done
|
2004-04-22 00:23:41 +02:00
|
|
|
if (reg & PTSCR_RBIST_EN)
|
|
|
|
regs.ptscr |= PTSCR_RBIST_DONE;
|
|
|
|
if (reg & PTSCR_EEBIST_EN)
|
|
|
|
regs.ptscr &= ~PTSCR_EEBIST_EN;
|
|
|
|
if (reg & PTSCR_EELOAD_EN)
|
|
|
|
regs.ptscr &= ~PTSCR_EELOAD_EN;
|
2004-03-12 17:04:58 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ISR: /* writing to the ISR has no effect */
|
|
|
|
panic("ISR is a read only register!\n");
|
|
|
|
|
|
|
|
case IMR:
|
|
|
|
regs.imr = reg;
|
|
|
|
devIntrChangeMask();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IER:
|
|
|
|
regs.ier = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IHR:
|
|
|
|
regs.ihr = reg;
|
|
|
|
/* not going to implement real interrupt holdoff */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TXDP:
|
|
|
|
regs.txdp = (reg & 0xFFFFFFFC);
|
|
|
|
assert(txState == txIdle);
|
|
|
|
CTDD = false;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TXDP_HI:
|
|
|
|
regs.txdp_hi = reg;
|
|
|
|
break;
|
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
case TX_CFG:
|
2004-03-12 17:04:58 +01:00
|
|
|
regs.txcfg = reg;
|
|
|
|
#if 0
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & TX_CFG_CSI) ;
|
|
|
|
if (reg & TX_CFG_HBI) ;
|
|
|
|
if (reg & TX_CFG_MLB) ;
|
|
|
|
if (reg & TX_CFG_ATP) ;
|
|
|
|
if (reg & TX_CFG_ECRETRY) {
|
2004-07-27 05:10:20 +02:00
|
|
|
/*
|
|
|
|
* this could easily be implemented, but considering
|
|
|
|
* the network is just a fake pipe, wouldn't make
|
|
|
|
* sense to do this
|
|
|
|
*/
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & TX_CFG_BRST_DIS) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
#endif
|
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
#if 0
|
2004-04-22 00:23:41 +02:00
|
|
|
/* we handle our own DMA, ignore the kernel's exhortations */
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & TX_CFG_MXDMA) ;
|
2004-07-27 05:10:20 +02:00
|
|
|
#endif
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
// also, we currently don't care about fill/drain
|
|
|
|
// thresholds though this may change in the future with
|
|
|
|
// more realistic networks or a driver which changes it
|
|
|
|
// according to feedback
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPIOR:
|
2005-08-13 00:30:35 +02:00
|
|
|
// Only write writable bits
|
|
|
|
regs.gpior &= GPIOR_UNUSED | GPIOR_GP5_IN | GPIOR_GP4_IN
|
|
|
|
| GPIOR_GP3_IN | GPIOR_GP2_IN | GPIOR_GP1_IN;
|
|
|
|
regs.gpior |= reg & ~(GPIOR_UNUSED | GPIOR_GP5_IN | GPIOR_GP4_IN
|
|
|
|
| GPIOR_GP3_IN | GPIOR_GP2_IN | GPIOR_GP1_IN);
|
2004-03-12 17:04:58 +01:00
|
|
|
/* these just control general purpose i/o pins, don't matter */
|
|
|
|
break;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
case RXDP:
|
|
|
|
regs.rxdp = reg;
|
2004-07-30 17:29:45 +02:00
|
|
|
CRDD = false;
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RXDP_HI:
|
|
|
|
regs.rxdp_hi = reg;
|
|
|
|
break;
|
|
|
|
|
2005-05-29 03:54:32 +02:00
|
|
|
case RX_CFG:
|
2004-03-12 17:04:58 +01:00
|
|
|
regs.rxcfg = reg;
|
|
|
|
#if 0
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & RX_CFG_AEP) ;
|
|
|
|
if (reg & RX_CFG_ARP) ;
|
|
|
|
if (reg & RX_CFG_STRIPCRC) ;
|
|
|
|
if (reg & RX_CFG_RX_RD) ;
|
|
|
|
if (reg & RX_CFG_ALP) ;
|
|
|
|
if (reg & RX_CFG_AIRL) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/* we handle our own DMA, ignore what kernel says about it */
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & RX_CFG_MXDMA) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
//also, we currently don't care about fill/drain thresholds
|
|
|
|
//though this may change in the future with more realistic
|
|
|
|
//networks or a driver which changes it according to feedback
|
2005-05-29 03:54:32 +02:00
|
|
|
if (reg & (RX_CFG_DRTH | RX_CFG_DRTH0)) ;
|
2004-03-12 17:04:58 +01:00
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PQCR:
|
|
|
|
/* there is no priority queueing used in the linux 2.6 driver */
|
|
|
|
regs.pqcr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WCSR:
|
|
|
|
/* not going to implement wake on LAN */
|
|
|
|
regs.wcsr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCR:
|
|
|
|
/* not going to implement pause control */
|
|
|
|
regs.pcr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RFCR:
|
|
|
|
regs.rfcr = reg;
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
rxFilterEnable = (reg & RFCR_RFEN) ? true : false;
|
|
|
|
acceptBroadcast = (reg & RFCR_AAB) ? true : false;
|
|
|
|
acceptMulticast = (reg & RFCR_AAM) ? true : false;
|
|
|
|
acceptUnicast = (reg & RFCR_AAU) ? true : false;
|
|
|
|
acceptPerfect = (reg & RFCR_APM) ? true : false;
|
|
|
|
acceptArp = (reg & RFCR_AARP) ? true : false;
|
2005-08-13 00:30:35 +02:00
|
|
|
multicastHashEnable = (reg & RFCR_MHEN) ? true : false;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
#if 0
|
|
|
|
if (reg & RFCR_APAT)
|
|
|
|
panic("RFCR_APAT not implemented!\n");
|
|
|
|
#endif
|
2005-08-13 00:30:35 +02:00
|
|
|
if (reg & RFCR_UHEN)
|
|
|
|
panic("Unicast hash filtering not used by drivers!\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
if (reg & RFCR_ULM)
|
|
|
|
panic("RFCR_ULM not implemented!\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RFDR:
|
2005-08-18 19:29:40 +02:00
|
|
|
rfaddr = (uint16_t)(regs.rfcr & RFCR_RFADDR);
|
2005-08-13 00:30:35 +02:00
|
|
|
switch (rfaddr) {
|
|
|
|
case 0x000:
|
|
|
|
rom.perfectMatch[0] = (uint8_t)reg;
|
|
|
|
rom.perfectMatch[1] = (uint8_t)(reg >> 8);
|
|
|
|
break;
|
|
|
|
case 0x002:
|
|
|
|
rom.perfectMatch[2] = (uint8_t)reg;
|
|
|
|
rom.perfectMatch[3] = (uint8_t)(reg >> 8);
|
|
|
|
break;
|
|
|
|
case 0x004:
|
|
|
|
rom.perfectMatch[4] = (uint8_t)reg;
|
|
|
|
rom.perfectMatch[5] = (uint8_t)(reg >> 8);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
|
|
|
if (rfaddr >= FHASH_ADDR &&
|
|
|
|
rfaddr < FHASH_ADDR + FHASH_SIZE) {
|
|
|
|
|
|
|
|
// Only word-aligned writes supported
|
|
|
|
if (rfaddr % 2)
|
|
|
|
panic("unaligned write to filter hash table!");
|
|
|
|
|
|
|
|
rom.filterHash[rfaddr - FHASH_ADDR] = (uint8_t)reg;
|
|
|
|
rom.filterHash[rfaddr - FHASH_ADDR + 1]
|
|
|
|
= (uint8_t)(reg >> 8);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
panic("writing RFDR for something other than pattern matching\
|
|
|
|
or hashing! %#x\n", rfaddr);
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
case BRAR:
|
2005-08-13 00:30:35 +02:00
|
|
|
regs.brar = reg;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
case BRDR:
|
|
|
|
panic("the driver never uses BRDR, something is wrong!\n");
|
|
|
|
|
|
|
|
case SRR:
|
|
|
|
panic("SRR is read only register!\n");
|
|
|
|
|
|
|
|
case MIBC:
|
|
|
|
panic("the driver never uses MIBC, something is wrong!\n");
|
|
|
|
|
|
|
|
case VRCR:
|
|
|
|
regs.vrcr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VTCR:
|
|
|
|
regs.vtcr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VDR:
|
|
|
|
panic("the driver never uses VDR, something is wrong!\n");
|
|
|
|
|
|
|
|
case CCSR:
|
|
|
|
/* not going to implement clockrun stuff */
|
|
|
|
regs.ccsr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TBICR:
|
|
|
|
regs.tbicr = reg;
|
|
|
|
if (reg & TBICR_MR_LOOPBACK)
|
|
|
|
panic("TBICR_MR_LOOPBACK never used, something wrong!\n");
|
|
|
|
|
|
|
|
if (reg & TBICR_MR_AN_ENABLE) {
|
|
|
|
regs.tanlpar = regs.tanar;
|
|
|
|
regs.tbisr |= (TBISR_MR_AN_COMPLETE | TBISR_MR_LINK_STATUS);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (reg & TBICR_MR_RESTART_AN) ;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TBISR:
|
|
|
|
panic("TBISR is read only register!\n");
|
|
|
|
|
|
|
|
case TANAR:
|
2005-08-13 00:30:35 +02:00
|
|
|
// Only write the writable bits
|
|
|
|
regs.tanar &= TANAR_RF1 | TANAR_RF2 | TANAR_UNUSED;
|
|
|
|
regs.tanar |= reg & ~(TANAR_RF1 | TANAR_RF2 | TANAR_UNUSED);
|
|
|
|
|
|
|
|
// Pause capability unimplemented
|
|
|
|
#if 0
|
|
|
|
if (reg & TANAR_PS2) ;
|
|
|
|
if (reg & TANAR_PS1) ;
|
|
|
|
#endif
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TANLPAR:
|
|
|
|
panic("this should only be written to by the fake phy!\n");
|
|
|
|
|
|
|
|
case TANER:
|
|
|
|
panic("TANER is read only register!\n");
|
|
|
|
|
|
|
|
case TESR:
|
|
|
|
regs.tesr = reg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-07-27 05:10:20 +02:00
|
|
|
panic("invalid register access daddr=%#x", daddr);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-07-27 05:10:20 +02:00
|
|
|
} else {
|
2004-03-12 17:04:58 +01:00
|
|
|
panic("Invalid Request Size");
|
2004-07-27 05:10:20 +02:00
|
|
|
}
|
2007-06-30 19:16:18 +02:00
|
|
|
pkt->makeAtomicResponse();
|
2006-04-25 01:31:50 +02:00
|
|
|
return pioDelay;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::devIntrPost(uint32_t interrupts)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
if (interrupts & ISR_RESERVE)
|
|
|
|
panic("Cannot set a reserved interrupt");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-08-11 16:14:26 +02:00
|
|
|
if (interrupts & ISR_NOIMPL)
|
|
|
|
warn("interrupt not implemented %#x\n", interrupts);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-09-19 03:22:57 +02:00
|
|
|
interrupts &= ISR_IMPL;
|
2004-08-11 16:14:26 +02:00
|
|
|
regs.isr |= interrupts;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-11-18 21:46:01 +01:00
|
|
|
if (interrupts & regs.imr) {
|
|
|
|
if (interrupts & ISR_SWI) {
|
|
|
|
totalSwi++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_RXIDLE) {
|
|
|
|
totalRxIdle++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_RXOK) {
|
|
|
|
totalRxOk++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_RXDESC) {
|
|
|
|
totalRxDesc++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_TXOK) {
|
|
|
|
totalTxOk++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_TXIDLE) {
|
|
|
|
totalTxIdle++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_TXDESC) {
|
|
|
|
totalTxDesc++;
|
|
|
|
}
|
|
|
|
if (interrupts & ISR_RXORN) {
|
|
|
|
totalRxOrn++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-11 16:14:26 +02:00
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"interrupt written to ISR: intr=%#x isr=%#x imr=%#x\n",
|
|
|
|
interrupts, regs.isr, regs.imr);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if ((regs.isr & regs.imr)) {
|
|
|
|
Tick when = curTick;
|
2005-09-19 03:22:57 +02:00
|
|
|
if ((regs.isr & regs.imr & ISR_NODELAY) == 0)
|
2004-04-22 00:23:41 +02:00
|
|
|
when += intrDelay;
|
2008-06-18 07:22:44 +02:00
|
|
|
postedInterrupts++;
|
2004-04-22 00:23:41 +02:00
|
|
|
cpuIntrPost(when);
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-11-18 21:46:01 +01:00
|
|
|
/* writing this interrupt counting stats inside this means that this function
|
|
|
|
is now limited to being used to clear all interrupts upon the kernel
|
|
|
|
reading isr and servicing. just telling you in case you were thinking
|
|
|
|
of expanding use.
|
|
|
|
*/
|
2004-03-12 17:04:58 +01:00
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::devIntrClear(uint32_t interrupts)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
|
|
|
if (interrupts & ISR_RESERVE)
|
|
|
|
panic("Cannot clear a reserved interrupt");
|
|
|
|
|
2004-11-18 21:46:01 +01:00
|
|
|
if (regs.isr & regs.imr & ISR_SWI) {
|
|
|
|
postedSwi++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_RXIDLE) {
|
|
|
|
postedRxIdle++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_RXOK) {
|
|
|
|
postedRxOk++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_RXDESC) {
|
|
|
|
postedRxDesc++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_TXOK) {
|
|
|
|
postedTxOk++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_TXIDLE) {
|
|
|
|
postedTxIdle++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_TXDESC) {
|
|
|
|
postedTxDesc++;
|
|
|
|
}
|
|
|
|
if (regs.isr & regs.imr & ISR_RXORN) {
|
|
|
|
postedRxOrn++;
|
|
|
|
}
|
|
|
|
|
2004-08-11 16:14:26 +02:00
|
|
|
interrupts &= ~ISR_NOIMPL;
|
|
|
|
regs.isr &= ~interrupts;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"interrupt cleared from ISR: intr=%x isr=%x imr=%x\n",
|
2004-05-26 19:06:32 +02:00
|
|
|
interrupts, regs.isr, regs.imr);
|
2004-07-30 17:33:45 +02:00
|
|
|
|
|
|
|
if (!(regs.isr & regs.imr))
|
|
|
|
cpuIntrClear();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::devIntrChangeMask()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetIntr, "interrupt mask changed: isr=%x imr=%x masked=%x\n",
|
|
|
|
regs.isr, regs.imr, regs.isr & regs.imr);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
|
|
|
if (regs.isr & regs.imr)
|
2004-04-22 00:23:41 +02:00
|
|
|
cpuIntrPost(curTick);
|
2004-03-12 17:04:58 +01:00
|
|
|
else
|
|
|
|
cpuIntrClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::cpuIntrPost(Tick when)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-07-27 05:10:20 +02:00
|
|
|
// If the interrupt you want to post is later than an interrupt
|
|
|
|
// already scheduled, just let it post in the coming one and don't
|
|
|
|
// schedule another.
|
|
|
|
// HOWEVER, must be sure that the scheduled intrTick is in the
|
|
|
|
// future (this was formerly the source of a bug)
|
2004-07-30 17:29:45 +02:00
|
|
|
/**
|
|
|
|
* @todo this warning should be removed and the intrTick code should
|
|
|
|
* be fixed.
|
|
|
|
*/
|
2004-08-20 17:40:57 +02:00
|
|
|
assert(when >= curTick);
|
|
|
|
assert(intrTick >= curTick || intrTick == 0);
|
|
|
|
if (when > intrTick && intrTick != 0) {
|
|
|
|
DPRINTF(EthernetIntr, "don't need to schedule event...intrTick=%d\n",
|
|
|
|
intrTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
return;
|
2004-08-20 17:40:57 +02:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
intrTick = when;
|
2004-08-20 17:40:57 +02:00
|
|
|
if (intrTick < curTick) {
|
|
|
|
debug_break();
|
|
|
|
intrTick = curTick;
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
|
2004-08-20 17:40:57 +02:00
|
|
|
DPRINTF(EthernetIntr, "going to schedule an interrupt for intrTick=%d\n",
|
|
|
|
intrTick);
|
|
|
|
|
|
|
|
if (intrEvent)
|
|
|
|
intrEvent->squash();
|
2008-10-09 13:58:24 +02:00
|
|
|
intrEvent = new IntrEvent(this, true);
|
|
|
|
schedule(intrEvent, intrTick);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::cpuInterrupt()
|
2004-04-22 00:23:41 +02:00
|
|
|
{
|
2004-08-20 17:40:57 +02:00
|
|
|
assert(intrTick == curTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
// Whether or not there's a pending interrupt, we don't care about
|
|
|
|
// it anymore
|
|
|
|
intrEvent = 0;
|
|
|
|
intrTick = 0;
|
|
|
|
|
2004-08-20 17:40:57 +02:00
|
|
|
// Don't send an interrupt if there's already one
|
|
|
|
if (cpuPendingIntr) {
|
|
|
|
DPRINTF(EthernetIntr,
|
|
|
|
"would send an interrupt now, but there's already pending\n");
|
|
|
|
} else {
|
|
|
|
// Send interrupt
|
|
|
|
cpuPendingIntr = true;
|
2004-08-11 16:14:26 +02:00
|
|
|
|
2004-11-13 21:45:22 +01:00
|
|
|
DPRINTF(EthernetIntr, "posting interrupt\n");
|
|
|
|
intrPost();
|
2004-08-20 17:40:57 +02:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::cpuIntrClear()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-07-27 05:10:20 +02:00
|
|
|
if (!cpuPendingIntr)
|
|
|
|
return;
|
|
|
|
|
2004-08-20 17:40:57 +02:00
|
|
|
if (intrEvent) {
|
|
|
|
intrEvent->squash();
|
|
|
|
intrEvent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
intrTick = 0;
|
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
cpuPendingIntr = false;
|
2004-08-11 16:14:26 +02:00
|
|
|
|
2004-11-13 21:45:22 +01:00
|
|
|
DPRINTF(EthernetIntr, "clearing interrupt\n");
|
|
|
|
intrClear();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::cpuIntrPending() const
|
2004-03-12 17:04:58 +01:00
|
|
|
{ return cpuPendingIntr; }
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::txReset()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
DPRINTF(Ethernet, "transmit reset\n");
|
|
|
|
|
|
|
|
CTDD = false;
|
2004-07-30 17:29:45 +02:00
|
|
|
txEnable = false;;
|
2004-04-22 00:23:41 +02:00
|
|
|
txFragPtr = 0;
|
|
|
|
assert(txDescCnt == 0);
|
2004-03-12 17:04:58 +01:00
|
|
|
txFifo.clear();
|
|
|
|
txState = txIdle;
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(txDmaState == dmaIdle);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::rxReset()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
|
|
|
DPRINTF(Ethernet, "receive reset\n");
|
|
|
|
|
|
|
|
CRDD = false;
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(rxPktBytes == 0);
|
2004-07-30 17:29:45 +02:00
|
|
|
rxEnable = false;
|
2004-04-22 00:23:41 +02:00
|
|
|
rxFragPtr = 0;
|
|
|
|
assert(rxDescCnt == 0);
|
|
|
|
assert(rxDmaState == dmaIdle);
|
2004-03-12 17:04:58 +01:00
|
|
|
rxFifo.clear();
|
|
|
|
rxState = rxIdle;
|
|
|
|
}
|
|
|
|
|
2004-07-30 17:33:45 +02:00
|
|
|
void
|
|
|
|
NSGigE::regsReset()
|
2004-06-11 21:26:21 +02:00
|
|
|
{
|
|
|
|
memset(®s, 0, sizeof(regs));
|
2005-06-28 00:08:42 +02:00
|
|
|
regs.config = (CFGR_LNKSTS | CFGR_TBI_EN | CFGR_MODE_1000);
|
2005-08-13 00:30:35 +02:00
|
|
|
regs.mear = 0x12;
|
2004-08-11 16:14:26 +02:00
|
|
|
regs.txcfg = 0x120; // set drain threshold to 1024 bytes and
|
|
|
|
// fill threshold to 32 bytes
|
|
|
|
regs.rxcfg = 0x4; // set drain threshold to 16 bytes
|
|
|
|
regs.srr = 0x0103; // set the silicon revision to rev B or 0x103
|
|
|
|
regs.mibc = MIBC_FRZ;
|
|
|
|
regs.vdr = 0x81; // set the vlan tag type to 802.1q
|
|
|
|
regs.tesr = 0xc000; // TBI capable of both full and half duplex
|
2005-08-13 00:30:35 +02:00
|
|
|
regs.brar = 0xffffffff;
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
|
|
|
extstsEnable = false;
|
|
|
|
acceptBroadcast = false;
|
|
|
|
acceptMulticast = false;
|
|
|
|
acceptUnicast = false;
|
|
|
|
acceptPerfect = false;
|
|
|
|
acceptArp = false;
|
2004-06-11 21:26:21 +02:00
|
|
|
}
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
bool
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::doRxDmaRead()
|
2004-04-22 00:23:41 +02:00
|
|
|
{
|
|
|
|
assert(rxDmaState == dmaIdle || rxDmaState == dmaReadWaiting);
|
|
|
|
rxDmaState = dmaReading;
|
|
|
|
|
2006-07-13 02:22:07 +02:00
|
|
|
if (dmaPending() || getState() != Running)
|
2006-04-25 01:31:50 +02:00
|
|
|
rxDmaState = dmaReadWaiting;
|
|
|
|
else
|
|
|
|
dmaRead(rxDmaAddr, rxDmaLen, &rxDmaReadEvent, (uint8_t*)rxDmaData);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
return true;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::rxDmaReadDone()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(rxDmaState == dmaReading);
|
2006-04-25 01:31:50 +02:00
|
|
|
rxDmaState = dmaIdle;
|
|
|
|
|
|
|
|
DPRINTF(EthernetDMA, "rx dma read paddr=%#x len=%d\n",
|
|
|
|
rxDmaAddr, rxDmaLen);
|
|
|
|
DDUMP(EthernetDMA, rxDmaData, rxDmaLen);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
// If the transmit state machine has a pending DMA, let it go first
|
|
|
|
if (txDmaState == dmaReadWaiting || txDmaState == dmaWriteWaiting)
|
|
|
|
txKick();
|
|
|
|
|
|
|
|
rxKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
bool
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::doRxDmaWrite()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(rxDmaState == dmaIdle || rxDmaState == dmaWriteWaiting);
|
|
|
|
rxDmaState = dmaWriting;
|
|
|
|
|
2006-07-13 02:22:07 +02:00
|
|
|
if (dmaPending() || getState() != Running)
|
2006-04-25 01:31:50 +02:00
|
|
|
rxDmaState = dmaWriteWaiting;
|
|
|
|
else
|
|
|
|
dmaWrite(rxDmaAddr, rxDmaLen, &rxDmaWriteEvent, (uint8_t*)rxDmaData);
|
2004-04-22 00:23:41 +02:00
|
|
|
return true;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::rxDmaWriteDone()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(rxDmaState == dmaWriting);
|
2006-04-25 01:31:50 +02:00
|
|
|
rxDmaState = dmaIdle;
|
|
|
|
|
|
|
|
DPRINTF(EthernetDMA, "rx dma write paddr=%#x len=%d\n",
|
|
|
|
rxDmaAddr, rxDmaLen);
|
|
|
|
DDUMP(EthernetDMA, rxDmaData, rxDmaLen);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
// If the transmit state machine has a pending DMA, let it go first
|
|
|
|
if (txDmaState == dmaReadWaiting || txDmaState == dmaWriteWaiting)
|
|
|
|
txKick();
|
|
|
|
|
|
|
|
rxKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::rxKick()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2005-10-12 19:39:40 +02:00
|
|
|
bool is64bit = (bool)(regs.config & CFGR_M64ADDR);
|
|
|
|
|
|
|
|
DPRINTF(EthernetSM,
|
|
|
|
"receive kick rxState=%s (rxBuf.size=%d) %d-bit\n",
|
|
|
|
NsRxStateStrings[rxState], rxFifo.size(), is64bit ? 64 : 32);
|
|
|
|
|
|
|
|
Addr link, bufptr;
|
|
|
|
uint32_t &cmdsts = is64bit ? rxDesc64.cmdsts : rxDesc32.cmdsts;
|
|
|
|
uint32_t &extsts = is64bit ? rxDesc64.extsts : rxDesc32.extsts;
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2005-06-27 23:02:40 +02:00
|
|
|
next:
|
|
|
|
if (clock) {
|
|
|
|
if (rxKickTick > curTick) {
|
|
|
|
DPRINTF(EthernetSM, "receive kick exiting, can't run till %d\n",
|
|
|
|
rxKickTick);
|
|
|
|
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go to the next state machine clock tick.
|
2007-09-28 19:21:52 +02:00
|
|
|
rxKickTick = curTick + ticks(1);
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(rxDmaState) {
|
|
|
|
case dmaReadWaiting:
|
|
|
|
if (doRxDmaRead())
|
|
|
|
goto exit;
|
|
|
|
break;
|
|
|
|
case dmaWriteWaiting:
|
|
|
|
if (doRxDmaWrite())
|
|
|
|
goto exit;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
link = is64bit ? (Addr)rxDesc64.link : (Addr)rxDesc32.link;
|
|
|
|
bufptr = is64bit ? (Addr)rxDesc64.bufptr : (Addr)rxDesc32.bufptr;
|
|
|
|
|
2004-04-22 00:43:39 +02:00
|
|
|
// see state machine from spec for details
|
2004-07-27 05:10:20 +02:00
|
|
|
// the way this works is, if you finish work on one state and can
|
|
|
|
// go directly to another, you do that through jumping to the
|
|
|
|
// label "next". however, if you have intermediate work, like DMA
|
|
|
|
// so that you can't go to the next state yet, you go to exit and
|
|
|
|
// exit the loop. however, when the DMA is done it will trigger
|
|
|
|
// an event and come back to this loop.
|
2004-04-22 00:23:41 +02:00
|
|
|
switch (rxState) {
|
|
|
|
case rxIdle:
|
2004-07-30 17:29:45 +02:00
|
|
|
if (!rxEnable) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "Receive Disabled! Nothing to do.\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CRDD) {
|
|
|
|
rxState = rxDescRefr;
|
|
|
|
|
|
|
|
rxDmaAddr = regs.rxdp & 0x3fffffff;
|
2005-10-12 19:39:40 +02:00
|
|
|
rxDmaData =
|
|
|
|
is64bit ? (void *)&rxDesc64.link : (void *)&rxDesc32.link;
|
|
|
|
rxDmaLen = is64bit ? sizeof(rxDesc64.link) : sizeof(rxDesc32.link);
|
2004-04-22 00:23:41 +02:00
|
|
|
rxDmaFree = dmaDescFree;
|
|
|
|
|
2004-07-04 22:47:07 +02:00
|
|
|
descDmaReads++;
|
|
|
|
descDmaRdBytes += rxDmaLen;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (doRxDmaRead())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
} else {
|
|
|
|
rxState = rxDescRead;
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
rxDmaAddr = regs.rxdp & 0x3fffffff;
|
2005-10-12 19:39:40 +02:00
|
|
|
rxDmaData = is64bit ? (void *)&rxDesc64 : (void *)&rxDesc32;
|
|
|
|
rxDmaLen = is64bit ? sizeof(rxDesc64) : sizeof(rxDesc32);
|
2004-04-22 00:23:41 +02:00
|
|
|
rxDmaFree = dmaDescFree;
|
|
|
|
|
2004-07-04 22:47:07 +02:00
|
|
|
descDmaReads++;
|
|
|
|
descDmaRdBytes += rxDmaLen;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (doRxDmaRead())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case rxDescRefr:
|
|
|
|
if (rxDmaState != dmaIdle)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
rxState = rxAdvance;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rxDescRead:
|
|
|
|
if (rxDmaState != dmaIdle)
|
|
|
|
goto exit;
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
DPRINTF(EthernetDesc, "rxDesc: addr=%08x read descriptor\n",
|
2004-07-30 17:33:45 +02:00
|
|
|
regs.rxdp & 0x3fffffff);
|
|
|
|
DPRINTF(EthernetDesc,
|
2005-10-12 19:39:40 +02:00
|
|
|
"rxDesc: link=%#x bufptr=%#x cmdsts=%08x extsts=%08x\n",
|
|
|
|
link, bufptr, cmdsts, extsts);
|
2004-05-26 19:06:32 +02:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
if (cmdsts & CMDSTS_OWN) {
|
2004-07-30 17:29:45 +02:00
|
|
|
devIntrPost(ISR_RXIDLE);
|
2004-03-12 17:04:58 +01:00
|
|
|
rxState = rxIdle;
|
2004-07-30 17:29:45 +02:00
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
} else {
|
|
|
|
rxState = rxFifoBlock;
|
2005-10-12 19:39:40 +02:00
|
|
|
rxFragPtr = bufptr;
|
|
|
|
rxDescCnt = cmdsts & CMDSTS_LEN_MASK;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
case rxFifoBlock:
|
|
|
|
if (!rxPacket) {
|
|
|
|
/**
|
|
|
|
* @todo in reality, we should be able to start processing
|
|
|
|
* the packet as it arrives, and not have to wait for the
|
|
|
|
* full packet ot be in the receive fifo.
|
|
|
|
*/
|
|
|
|
if (rxFifo.empty())
|
|
|
|
goto exit;
|
|
|
|
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetSM, "****processing receive of new packet****\n");
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
// If we don't have a packet, grab a new one from the fifo.
|
|
|
|
rxPacket = rxFifo.front();
|
|
|
|
rxPktBytes = rxPacket->length;
|
|
|
|
rxPacketBufPtr = rxPacket->data;
|
|
|
|
|
2004-07-21 21:44:57 +02:00
|
|
|
#if TRACING_ON
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
if (DTRACE(Ethernet)) {
|
2004-10-23 22:18:44 +02:00
|
|
|
IpPtr ip(rxPacket);
|
2004-09-20 16:43:53 +02:00
|
|
|
if (ip) {
|
|
|
|
DPRINTF(Ethernet, "ID is %d\n", ip->id());
|
2004-10-23 22:18:44 +02:00
|
|
|
TcpPtr tcp(ip);
|
2004-09-20 16:43:53 +02:00
|
|
|
if (tcp) {
|
2005-03-16 19:55:58 +01:00
|
|
|
DPRINTF(Ethernet,
|
|
|
|
"Src Port=%d, Dest Port=%d, Seq=%d, Ack=%d\n",
|
|
|
|
tcp->sport(), tcp->dport(), tcp->seq(),
|
|
|
|
tcp->ack());
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-21 21:44:57 +02:00
|
|
|
#endif
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
// sanity check - i think the driver behaves like this
|
|
|
|
assert(rxDescCnt >= rxPktBytes);
|
2004-11-13 22:52:08 +01:00
|
|
|
rxFifo.pop();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
// dont' need the && rxDescCnt > 0 if driver sanity check
|
|
|
|
// above holds
|
2004-04-22 00:23:41 +02:00
|
|
|
if (rxPktBytes > 0) {
|
|
|
|
rxState = rxFragWrite;
|
2004-07-27 05:10:20 +02:00
|
|
|
// don't need min<>(rxPktBytes,rxDescCnt) if above sanity
|
|
|
|
// check holds
|
2004-04-22 00:23:41 +02:00
|
|
|
rxXferLen = rxPktBytes;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
rxDmaAddr = rxFragPtr & 0x3fffffff;
|
|
|
|
rxDmaData = rxPacketBufPtr;
|
|
|
|
rxDmaLen = rxXferLen;
|
|
|
|
rxDmaFree = dmaDataFree;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (doRxDmaWrite())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
} else {
|
|
|
|
rxState = rxDescWrite;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
//if (rxPktBytes == 0) { /* packet is done */
|
|
|
|
assert(rxPktBytes == 0);
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "done with receiving packet\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts |= CMDSTS_OWN;
|
|
|
|
cmdsts &= ~CMDSTS_MORE;
|
|
|
|
cmdsts |= CMDSTS_OK;
|
|
|
|
cmdsts &= 0xffff0000;
|
|
|
|
cmdsts += rxPacket->length; //i.e. set CMDSTS_SIZE
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
#if 0
|
2004-07-27 05:10:20 +02:00
|
|
|
/*
|
|
|
|
* all the driver uses these are for its own stats keeping
|
|
|
|
* which we don't care about, aren't necessary for
|
|
|
|
* functionality and doing this would just slow us down.
|
|
|
|
* if they end up using this in a later version for
|
|
|
|
* functional purposes, just undef
|
|
|
|
*/
|
2004-03-12 17:04:58 +01:00
|
|
|
if (rxFilterEnable) {
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts &= ~CMDSTS_DEST_MASK;
|
2004-10-23 22:18:44 +02:00
|
|
|
const EthAddr &dst = rxFifoFront()->dst();
|
|
|
|
if (dst->unicast())
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts |= CMDSTS_DEST_SELF;
|
2004-10-23 22:18:44 +02:00
|
|
|
if (dst->multicast())
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts |= CMDSTS_DEST_MULTI;
|
2004-10-23 22:18:44 +02:00
|
|
|
if (dst->broadcast())
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts |= CMDSTS_DEST_MASK;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
#endif
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-10-23 22:18:44 +02:00
|
|
|
IpPtr ip(rxPacket);
|
|
|
|
if (extstsEnable && ip) {
|
2005-10-12 19:39:40 +02:00
|
|
|
extsts |= EXTSTS_IPPKT;
|
2004-09-20 16:43:53 +02:00
|
|
|
rxIpChecksums++;
|
2004-10-23 22:18:44 +02:00
|
|
|
if (cksum(ip) != 0) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetCksum, "Rx IP Checksum Error\n");
|
2005-10-12 19:39:40 +02:00
|
|
|
extsts |= EXTSTS_IPERR;
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
}
|
2004-10-23 22:18:44 +02:00
|
|
|
TcpPtr tcp(ip);
|
|
|
|
UdpPtr udp(ip);
|
|
|
|
if (tcp) {
|
2005-10-12 19:39:40 +02:00
|
|
|
extsts |= EXTSTS_TCPPKT;
|
2004-09-20 16:43:53 +02:00
|
|
|
rxTcpChecksums++;
|
2004-10-23 22:18:44 +02:00
|
|
|
if (cksum(tcp) != 0) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetCksum, "Rx TCP Checksum Error\n");
|
2005-10-12 19:39:40 +02:00
|
|
|
extsts |= EXTSTS_TCPERR;
|
2004-07-04 22:47:07 +02:00
|
|
|
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
}
|
2004-10-23 22:18:44 +02:00
|
|
|
} else if (udp) {
|
2005-10-12 19:39:40 +02:00
|
|
|
extsts |= EXTSTS_UDPPKT;
|
2004-09-20 16:43:53 +02:00
|
|
|
rxUdpChecksums++;
|
2004-10-23 22:18:44 +02:00
|
|
|
if (cksum(udp) != 0) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetCksum, "Rx UDP Checksum Error\n");
|
2005-10-12 19:39:40 +02:00
|
|
|
extsts |= EXTSTS_UDPERR;
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
}
|
2004-05-26 19:06:32 +02:00
|
|
|
rxPacket = 0;
|
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
/*
|
|
|
|
* the driver seems to always receive into desc buffers
|
|
|
|
* of size 1514, so you never have a pkt that is split
|
|
|
|
* into multiple descriptors on the receive side, so
|
|
|
|
* i don't implement that case, hence the assert above.
|
|
|
|
*/
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
DPRINTF(EthernetDesc,
|
2005-10-12 19:39:40 +02:00
|
|
|
"rxDesc: addr=%08x writeback cmdsts extsts\n",
|
2004-07-30 17:33:45 +02:00
|
|
|
regs.rxdp & 0x3fffffff);
|
|
|
|
DPRINTF(EthernetDesc,
|
2005-10-12 19:39:40 +02:00
|
|
|
"rxDesc: link=%#x bufptr=%#x cmdsts=%08x extsts=%08x\n",
|
|
|
|
link, bufptr, cmdsts, extsts);
|
2004-05-26 19:06:32 +02:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
rxDmaAddr = regs.rxdp & 0x3fffffff;
|
|
|
|
rxDmaData = &cmdsts;
|
|
|
|
if (is64bit) {
|
|
|
|
rxDmaAddr += offsetof(ns_desc64, cmdsts);
|
|
|
|
rxDmaLen = sizeof(rxDesc64.cmdsts) + sizeof(rxDesc64.extsts);
|
|
|
|
} else {
|
|
|
|
rxDmaAddr += offsetof(ns_desc32, cmdsts);
|
|
|
|
rxDmaLen = sizeof(rxDesc32.cmdsts) + sizeof(rxDesc32.extsts);
|
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
rxDmaFree = dmaDescFree;
|
|
|
|
|
2004-07-04 22:47:07 +02:00
|
|
|
descDmaWrites++;
|
|
|
|
descDmaWrBytes += rxDmaLen;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (doRxDmaWrite())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
case rxFragWrite:
|
|
|
|
if (rxDmaState != dmaIdle)
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
rxPacketBufPtr += rxXferLen;
|
|
|
|
rxFragPtr += rxXferLen;
|
|
|
|
rxPktBytes -= rxXferLen;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
rxState = rxFifoBlock;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
case rxDescWrite:
|
|
|
|
if (rxDmaState != dmaIdle)
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
assert(cmdsts & CMDSTS_OWN);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(rxPacket == 0);
|
|
|
|
devIntrPost(ISR_RXOK);
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
if (cmdsts & CMDSTS_INTR)
|
2004-04-22 00:23:41 +02:00
|
|
|
devIntrPost(ISR_RXDESC);
|
|
|
|
|
2004-07-30 17:29:45 +02:00
|
|
|
if (!rxEnable) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "Halting the RX state machine\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
rxState = rxIdle;
|
2004-07-30 17:29:45 +02:00
|
|
|
goto exit;
|
2004-04-22 00:23:41 +02:00
|
|
|
} else
|
|
|
|
rxState = rxAdvance;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case rxAdvance:
|
2005-10-12 19:39:40 +02:00
|
|
|
if (link == 0) {
|
2004-07-30 17:29:45 +02:00
|
|
|
devIntrPost(ISR_RXIDLE);
|
2004-04-22 00:23:41 +02:00
|
|
|
rxState = rxIdle;
|
2004-07-30 17:29:45 +02:00
|
|
|
CRDD = true;
|
|
|
|
goto exit;
|
2004-04-22 00:23:41 +02:00
|
|
|
} else {
|
2005-09-29 23:09:53 +02:00
|
|
|
if (rxDmaState != dmaIdle)
|
|
|
|
goto exit;
|
2004-04-22 00:23:41 +02:00
|
|
|
rxState = rxDescRead;
|
2005-10-12 19:39:40 +02:00
|
|
|
regs.rxdp = link;
|
2004-04-22 00:23:41 +02:00
|
|
|
CRDD = false;
|
|
|
|
|
|
|
|
rxDmaAddr = regs.rxdp & 0x3fffffff;
|
2005-10-12 19:39:40 +02:00
|
|
|
rxDmaData = is64bit ? (void *)&rxDesc64 : (void *)&rxDesc32;
|
|
|
|
rxDmaLen = is64bit ? sizeof(rxDesc64) : sizeof(rxDesc32);
|
2004-04-22 00:23:41 +02:00
|
|
|
rxDmaFree = dmaDescFree;
|
|
|
|
|
|
|
|
if (doRxDmaRead())
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("Invalid rxState!");
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetSM, "entering next rxState=%s\n",
|
2004-04-22 00:23:41 +02:00
|
|
|
NsRxStateStrings[rxState]);
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
/**
|
|
|
|
* @todo do we want to schedule a future kick?
|
|
|
|
*/
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetSM, "rx state machine exited rxState=%s\n",
|
2004-04-22 00:23:41 +02:00
|
|
|
NsRxStateStrings[rxState]);
|
2005-06-27 23:02:40 +02:00
|
|
|
|
|
|
|
if (clock && !rxKickEvent.scheduled())
|
2008-10-09 13:58:24 +02:00
|
|
|
schedule(rxKickEvent, rxKickTick);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::transmit()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
|
|
|
if (txFifo.empty()) {
|
|
|
|
DPRINTF(Ethernet, "nothing to transmit\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(Ethernet, "Attempt Pkt Transmit: txFifo length=%d\n",
|
2004-11-13 22:52:08 +01:00
|
|
|
txFifo.size());
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
if (interface->sendPacket(txFifo.front())) {
|
2004-07-21 21:44:57 +02:00
|
|
|
#if TRACING_ON
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
if (DTRACE(Ethernet)) {
|
2004-10-23 22:18:44 +02:00
|
|
|
IpPtr ip(txFifo.front());
|
2004-09-20 16:43:53 +02:00
|
|
|
if (ip) {
|
|
|
|
DPRINTF(Ethernet, "ID is %d\n", ip->id());
|
2004-10-23 22:18:44 +02:00
|
|
|
TcpPtr tcp(ip);
|
2004-09-20 16:43:53 +02:00
|
|
|
if (tcp) {
|
2005-03-16 19:55:58 +01:00
|
|
|
DPRINTF(Ethernet,
|
|
|
|
"Src Port=%d, Dest Port=%d, Seq=%d, Ack=%d\n",
|
2005-10-12 19:39:40 +02:00
|
|
|
tcp->sport(), tcp->dport(), tcp->seq(),
|
|
|
|
tcp->ack());
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-07-21 21:44:57 +02:00
|
|
|
#endif
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2005-03-16 19:55:58 +01:00
|
|
|
DDUMP(EthernetData, txFifo.front()->data, txFifo.front()->length);
|
2004-03-12 17:04:58 +01:00
|
|
|
txBytes += txFifo.front()->length;
|
|
|
|
txPackets++;
|
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
DPRINTF(Ethernet, "Successful Xmit! now txFifoAvail is %d\n",
|
2004-11-13 22:52:08 +01:00
|
|
|
txFifo.avail());
|
|
|
|
txFifo.pop();
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
/*
|
|
|
|
* normally do a writeback of the descriptor here, and ONLY
|
|
|
|
* after that is done, send this interrupt. but since our
|
|
|
|
* stuff never actually fails, just do this interrupt here,
|
|
|
|
* otherwise the code has to stray from this nice format.
|
|
|
|
* besides, it's functionally the same.
|
|
|
|
*/
|
2004-04-22 00:23:41 +02:00
|
|
|
devIntrPost(ISR_TXOK);
|
2004-07-27 05:10:20 +02:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
if (!txFifo.empty() && !txEvent.scheduled()) {
|
|
|
|
DPRINTF(Ethernet, "reschedule transmit\n");
|
2008-10-09 13:58:24 +02:00
|
|
|
schedule(txEvent, curTick + retryTime);
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
bool
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::doTxDmaRead()
|
2004-04-22 00:23:41 +02:00
|
|
|
{
|
|
|
|
assert(txDmaState == dmaIdle || txDmaState == dmaReadWaiting);
|
|
|
|
txDmaState = dmaReading;
|
|
|
|
|
2006-07-13 02:22:07 +02:00
|
|
|
if (dmaPending() || getState() != Running)
|
2006-04-25 01:31:50 +02:00
|
|
|
txDmaState = dmaReadWaiting;
|
|
|
|
else
|
|
|
|
dmaRead(txDmaAddr, txDmaLen, &txDmaReadEvent, (uint8_t*)txDmaData);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
return true;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::txDmaReadDone()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(txDmaState == dmaReading);
|
2006-04-25 01:31:50 +02:00
|
|
|
txDmaState = dmaIdle;
|
|
|
|
|
|
|
|
DPRINTF(EthernetDMA, "tx dma read paddr=%#x len=%d\n",
|
|
|
|
txDmaAddr, txDmaLen);
|
|
|
|
DDUMP(EthernetDMA, txDmaData, txDmaLen);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
// If the receive state machine has a pending DMA, let it go first
|
|
|
|
if (rxDmaState == dmaReadWaiting || rxDmaState == dmaWriteWaiting)
|
|
|
|
rxKick();
|
|
|
|
|
|
|
|
txKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
bool
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::doTxDmaWrite()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(txDmaState == dmaIdle || txDmaState == dmaWriteWaiting);
|
|
|
|
txDmaState = dmaWriting;
|
|
|
|
|
2006-07-13 02:22:07 +02:00
|
|
|
if (dmaPending() || getState() != Running)
|
2006-04-25 01:31:50 +02:00
|
|
|
txDmaState = dmaWriteWaiting;
|
|
|
|
else
|
|
|
|
dmaWrite(txDmaAddr, txDmaLen, &txDmaWriteEvent, (uint8_t*)txDmaData);
|
2004-04-22 00:23:41 +02:00
|
|
|
return true;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::txDmaWriteDone()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-04-22 00:23:41 +02:00
|
|
|
assert(txDmaState == dmaWriting);
|
2006-04-25 01:31:50 +02:00
|
|
|
txDmaState = dmaIdle;
|
|
|
|
|
|
|
|
DPRINTF(EthernetDMA, "tx dma write paddr=%#x len=%d\n",
|
|
|
|
txDmaAddr, txDmaLen);
|
|
|
|
DDUMP(EthernetDMA, txDmaData, txDmaLen);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
// If the receive state machine has a pending DMA, let it go first
|
|
|
|
if (rxDmaState == dmaReadWaiting || rxDmaState == dmaWriteWaiting)
|
|
|
|
rxKick();
|
|
|
|
|
|
|
|
txKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::txKick()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2005-10-12 19:39:40 +02:00
|
|
|
bool is64bit = (bool)(regs.config & CFGR_M64ADDR);
|
|
|
|
|
|
|
|
DPRINTF(EthernetSM, "transmit kick txState=%s %d-bit\n",
|
|
|
|
NsTxStateStrings[txState], is64bit ? 64 : 32);
|
|
|
|
|
|
|
|
Addr link, bufptr;
|
|
|
|
uint32_t &cmdsts = is64bit ? txDesc64.cmdsts : txDesc32.cmdsts;
|
|
|
|
uint32_t &extsts = is64bit ? txDesc64.extsts : txDesc32.extsts;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2005-06-27 23:02:40 +02:00
|
|
|
next:
|
|
|
|
if (clock) {
|
|
|
|
if (txKickTick > curTick) {
|
|
|
|
DPRINTF(EthernetSM, "transmit kick exiting, can't run till %d\n",
|
|
|
|
txKickTick);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go to the next state machine clock tick.
|
2007-09-28 19:21:52 +02:00
|
|
|
txKickTick = curTick + ticks(1);
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(txDmaState) {
|
|
|
|
case dmaReadWaiting:
|
|
|
|
if (doTxDmaRead())
|
|
|
|
goto exit;
|
|
|
|
break;
|
|
|
|
case dmaWriteWaiting:
|
|
|
|
if (doTxDmaWrite())
|
|
|
|
goto exit;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
link = is64bit ? (Addr)txDesc64.link : (Addr)txDesc32.link;
|
|
|
|
bufptr = is64bit ? (Addr)txDesc64.bufptr : (Addr)txDesc32.bufptr;
|
2004-04-22 00:23:41 +02:00
|
|
|
switch (txState) {
|
|
|
|
case txIdle:
|
2004-07-30 17:29:45 +02:00
|
|
|
if (!txEnable) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "Transmit disabled. Nothing to do.\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (CTDD) {
|
|
|
|
txState = txDescRefr;
|
|
|
|
|
2004-05-26 19:06:32 +02:00
|
|
|
txDmaAddr = regs.txdp & 0x3fffffff;
|
2005-10-12 19:39:40 +02:00
|
|
|
txDmaData =
|
|
|
|
is64bit ? (void *)&txDesc64.link : (void *)&txDesc32.link;
|
|
|
|
txDmaLen = is64bit ? sizeof(txDesc64.link) : sizeof(txDesc32.link);
|
2004-04-22 00:23:41 +02:00
|
|
|
txDmaFree = dmaDescFree;
|
|
|
|
|
2004-07-04 22:47:07 +02:00
|
|
|
descDmaReads++;
|
|
|
|
descDmaRdBytes += txDmaLen;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (doTxDmaRead())
|
|
|
|
goto exit;
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
} else {
|
|
|
|
txState = txDescRead;
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
txDmaAddr = regs.txdp & 0x3fffffff;
|
2005-10-12 19:39:40 +02:00
|
|
|
txDmaData = is64bit ? (void *)&txDesc64 : (void *)&txDesc32;
|
|
|
|
txDmaLen = is64bit ? sizeof(txDesc64) : sizeof(txDesc32);
|
2004-04-22 00:23:41 +02:00
|
|
|
txDmaFree = dmaDescFree;
|
|
|
|
|
2004-07-04 22:47:07 +02:00
|
|
|
descDmaReads++;
|
|
|
|
descDmaRdBytes += txDmaLen;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (doTxDmaRead())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case txDescRefr:
|
|
|
|
if (txDmaState != dmaIdle)
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
txState = txAdvance;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case txDescRead:
|
|
|
|
if (txDmaState != dmaIdle)
|
|
|
|
goto exit;
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
DPRINTF(EthernetDesc, "txDesc: addr=%08x read descriptor\n",
|
2005-06-27 23:02:40 +02:00
|
|
|
regs.txdp & 0x3fffffff);
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetDesc,
|
2005-10-12 19:39:40 +02:00
|
|
|
"txDesc: link=%#x bufptr=%#x cmdsts=%#08x extsts=%#08x\n",
|
|
|
|
link, bufptr, cmdsts, extsts);
|
2004-05-26 19:06:32 +02:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
if (cmdsts & CMDSTS_OWN) {
|
2004-03-12 17:04:58 +01:00
|
|
|
txState = txFifoBlock;
|
2005-10-12 19:39:40 +02:00
|
|
|
txFragPtr = bufptr;
|
|
|
|
txDescCnt = cmdsts & CMDSTS_LEN_MASK;
|
2004-04-22 00:23:41 +02:00
|
|
|
} else {
|
2004-07-30 17:29:45 +02:00
|
|
|
devIntrPost(ISR_TXIDLE);
|
2004-04-22 00:23:41 +02:00
|
|
|
txState = txIdle;
|
2004-07-30 17:29:45 +02:00
|
|
|
goto exit;
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case txFifoBlock:
|
|
|
|
if (!txPacket) {
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetSM, "****starting the tx of a new packet****\n");
|
2006-04-25 01:31:50 +02:00
|
|
|
txPacket = new EthPacketData(16384);
|
2004-04-22 00:23:41 +02:00
|
|
|
txPacketBufPtr = txPacket->data;
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
if (txDescCnt == 0) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "the txDescCnt == 0, done with descriptor\n");
|
2005-10-12 19:39:40 +02:00
|
|
|
if (cmdsts & CMDSTS_MORE) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "there are more descriptors to come\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
txState = txDescWrite;
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts &= ~CMDSTS_OWN;
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
txDmaAddr = regs.txdp & 0x3fffffff;
|
|
|
|
txDmaData = &cmdsts;
|
|
|
|
if (is64bit) {
|
|
|
|
txDmaAddr += offsetof(ns_desc64, cmdsts);
|
|
|
|
txDmaLen = sizeof(txDesc64.cmdsts);
|
|
|
|
} else {
|
|
|
|
txDmaAddr += offsetof(ns_desc32, cmdsts);
|
|
|
|
txDmaLen = sizeof(txDesc32.cmdsts);
|
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
txDmaFree = dmaDescFree;
|
|
|
|
|
|
|
|
if (doTxDmaWrite())
|
|
|
|
goto exit;
|
|
|
|
|
|
|
|
} else { /* this packet is totally done */
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "This packet is done, let's wrap it up\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
/* deal with the the packet that just finished */
|
|
|
|
if ((regs.vtcr & VTCR_PPCHK) && extstsEnable) {
|
2004-10-23 22:18:44 +02:00
|
|
|
IpPtr ip(txPacket);
|
2005-10-12 19:39:40 +02:00
|
|
|
if (extsts & EXTSTS_UDPPKT) {
|
2004-10-23 22:18:44 +02:00
|
|
|
UdpPtr udp(ip);
|
2008-06-18 07:14:12 +02:00
|
|
|
if (udp) {
|
|
|
|
udp->sum(0);
|
|
|
|
udp->sum(cksum(udp));
|
|
|
|
txUdpChecksums++;
|
|
|
|
} else {
|
|
|
|
debug_break();
|
|
|
|
warn_once("UDPPKT set, but not UDP!\n");
|
|
|
|
}
|
2005-10-12 19:39:40 +02:00
|
|
|
} else if (extsts & EXTSTS_TCPPKT) {
|
2004-10-23 22:18:44 +02:00
|
|
|
TcpPtr tcp(ip);
|
2008-06-18 07:14:12 +02:00
|
|
|
if (tcp) {
|
|
|
|
tcp->sum(0);
|
|
|
|
tcp->sum(cksum(tcp));
|
|
|
|
txTcpChecksums++;
|
|
|
|
} else {
|
|
|
|
debug_break();
|
|
|
|
warn_once("TCPPKT set, but not UDP!\n");
|
|
|
|
}
|
2004-06-30 06:50:56 +02:00
|
|
|
}
|
2005-10-12 19:39:40 +02:00
|
|
|
if (extsts & EXTSTS_IPPKT) {
|
2008-06-18 07:14:12 +02:00
|
|
|
if (ip) {
|
|
|
|
ip->sum(0);
|
|
|
|
ip->sum(cksum(ip));
|
|
|
|
txIpChecksums++;
|
|
|
|
} else {
|
|
|
|
debug_break();
|
|
|
|
warn_once("IPPKT set, but not UDP!\n");
|
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
txPacket->length = txPacketBufPtr - txPacket->data;
|
2004-07-27 05:10:20 +02:00
|
|
|
// this is just because the receive can't handle a
|
|
|
|
// packet bigger want to make sure
|
2005-10-12 19:39:40 +02:00
|
|
|
if (txPacket->length > 1514)
|
|
|
|
panic("transmit packet too large, %s > 1514\n",
|
|
|
|
txPacket->length);
|
|
|
|
|
2004-11-17 05:59:51 +01:00
|
|
|
#ifndef NDEBUG
|
|
|
|
bool success =
|
|
|
|
#endif
|
|
|
|
txFifo.push(txPacket);
|
|
|
|
assert(success);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
/*
|
|
|
|
* this following section is not tqo spec, but
|
|
|
|
* functionally shouldn't be any different. normally,
|
|
|
|
* the chip will wait til the transmit has occurred
|
|
|
|
* before writing back the descriptor because it has
|
|
|
|
* to wait to see that it was successfully transmitted
|
|
|
|
* to decide whether to set CMDSTS_OK or not.
|
|
|
|
* however, in the simulator since it is always
|
|
|
|
* successfully transmitted, and writing it exactly to
|
|
|
|
* spec would complicate the code, we just do it here
|
|
|
|
*/
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts &= ~CMDSTS_OWN;
|
|
|
|
cmdsts |= CMDSTS_OK;
|
2004-04-22 00:23:41 +02:00
|
|
|
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetDesc,
|
2004-07-30 17:33:45 +02:00
|
|
|
"txDesc writeback: cmdsts=%08x extsts=%08x\n",
|
2005-10-12 19:39:40 +02:00
|
|
|
cmdsts, extsts);
|
2004-05-26 19:06:32 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
txDmaFree = dmaDescFree;
|
2005-10-12 19:39:40 +02:00
|
|
|
txDmaAddr = regs.txdp & 0x3fffffff;
|
|
|
|
txDmaData = &cmdsts;
|
|
|
|
if (is64bit) {
|
|
|
|
txDmaAddr += offsetof(ns_desc64, cmdsts);
|
|
|
|
txDmaLen =
|
|
|
|
sizeof(txDesc64.cmdsts) + sizeof(txDesc64.extsts);
|
|
|
|
} else {
|
|
|
|
txDmaAddr += offsetof(ns_desc32, cmdsts);
|
|
|
|
txDmaLen =
|
|
|
|
sizeof(txDesc32.cmdsts) + sizeof(txDesc32.extsts);
|
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-07-04 22:47:07 +02:00
|
|
|
descDmaWrites++;
|
|
|
|
descDmaWrBytes += txDmaLen;
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
transmit();
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
txPacket = 0;
|
|
|
|
|
2004-07-30 17:29:45 +02:00
|
|
|
if (!txEnable) {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "halting TX state machine\n");
|
2004-04-22 00:23:41 +02:00
|
|
|
txState = txIdle;
|
2004-07-30 17:29:45 +02:00
|
|
|
goto exit;
|
2004-04-22 00:23:41 +02:00
|
|
|
} else
|
|
|
|
txState = txAdvance;
|
2004-07-09 17:50:27 +02:00
|
|
|
|
|
|
|
if (doTxDmaWrite())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
} else {
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
DPRINTF(EthernetSM, "this descriptor isn't done yet\n");
|
2004-11-13 22:52:08 +01:00
|
|
|
if (!txFifo.full()) {
|
2004-07-12 22:09:52 +02:00
|
|
|
txState = txFragRead;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-07-27 05:10:20 +02:00
|
|
|
/*
|
|
|
|
* The number of bytes transferred is either whatever
|
|
|
|
* is left in the descriptor (txDescCnt), or if there
|
|
|
|
* is not enough room in the fifo, just whatever room
|
|
|
|
* is left in the fifo
|
|
|
|
*/
|
2004-11-13 22:52:08 +01:00
|
|
|
txXferLen = min<uint32_t>(txDescCnt, txFifo.avail());
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-07-12 22:09:52 +02:00
|
|
|
txDmaAddr = txFragPtr & 0x3fffffff;
|
|
|
|
txDmaData = txPacketBufPtr;
|
|
|
|
txDmaLen = txXferLen;
|
|
|
|
txDmaFree = dmaDataFree;
|
|
|
|
|
|
|
|
if (doTxDmaRead())
|
|
|
|
goto exit;
|
|
|
|
} else {
|
|
|
|
txState = txFifoBlock;
|
|
|
|
transmit();
|
|
|
|
|
2004-07-14 15:02:15 +02:00
|
|
|
goto exit;
|
2004-07-12 22:09:52 +02:00
|
|
|
}
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
case txFragRead:
|
|
|
|
if (txDmaState != dmaIdle)
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
txPacketBufPtr += txXferLen;
|
|
|
|
txFragPtr += txXferLen;
|
|
|
|
txDescCnt -= txXferLen;
|
2004-11-17 05:59:51 +01:00
|
|
|
txFifo.reserve(txXferLen);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
txState = txFifoBlock;
|
|
|
|
break;
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
case txDescWrite:
|
|
|
|
if (txDmaState != dmaIdle)
|
|
|
|
goto exit;
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
if (cmdsts & CMDSTS_INTR)
|
2004-04-22 00:23:41 +02:00
|
|
|
devIntrPost(ISR_TXDESC);
|
|
|
|
|
2005-06-27 23:02:40 +02:00
|
|
|
if (!txEnable) {
|
|
|
|
DPRINTF(EthernetSM, "halting TX state machine\n");
|
|
|
|
txState = txIdle;
|
|
|
|
goto exit;
|
|
|
|
} else
|
|
|
|
txState = txAdvance;
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case txAdvance:
|
2005-10-12 19:39:40 +02:00
|
|
|
if (link == 0) {
|
2004-07-30 17:29:45 +02:00
|
|
|
devIntrPost(ISR_TXIDLE);
|
2004-04-22 00:23:41 +02:00
|
|
|
txState = txIdle;
|
2004-07-30 17:29:45 +02:00
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
} else {
|
2005-09-29 23:09:53 +02:00
|
|
|
if (txDmaState != dmaIdle)
|
|
|
|
goto exit;
|
2004-04-22 00:23:41 +02:00
|
|
|
txState = txDescRead;
|
2005-10-12 19:39:40 +02:00
|
|
|
regs.txdp = link;
|
2004-04-22 00:23:41 +02:00
|
|
|
CTDD = false;
|
|
|
|
|
2005-10-12 19:39:40 +02:00
|
|
|
txDmaAddr = link & 0x3fffffff;
|
|
|
|
txDmaData = is64bit ? (void *)&txDesc64 : (void *)&txDesc32;
|
|
|
|
txDmaLen = is64bit ? sizeof(txDesc64) : sizeof(txDesc32);
|
2004-04-22 00:23:41 +02:00
|
|
|
txDmaFree = dmaDescFree;
|
|
|
|
|
|
|
|
if (doTxDmaRead())
|
|
|
|
goto exit;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
2004-04-22 00:23:41 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("invalid state");
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetSM, "entering next txState=%s\n",
|
2004-04-22 00:23:41 +02:00
|
|
|
NsTxStateStrings[txState]);
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
exit:
|
|
|
|
/**
|
|
|
|
* @todo do we want to schedule a future kick?
|
|
|
|
*/
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(EthernetSM, "tx state machine exited txState=%s\n",
|
2004-04-22 00:23:41 +02:00
|
|
|
NsTxStateStrings[txState]);
|
2005-06-27 23:02:40 +02:00
|
|
|
|
|
|
|
if (clock && !txKickEvent.scheduled())
|
2008-10-09 13:58:24 +02:00
|
|
|
schedule(txKickEvent, txKickTick);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
2005-08-13 00:30:35 +02:00
|
|
|
/**
|
|
|
|
* Advance the EEPROM state machine
|
|
|
|
* Called on rising edge of EEPROM clock bit in MEAR
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
NSGigE::eepromKick()
|
|
|
|
{
|
|
|
|
switch (eepromState) {
|
|
|
|
|
|
|
|
case eepromStart:
|
|
|
|
|
|
|
|
// Wait for start bit
|
|
|
|
if (regs.mear & MEAR_EEDI) {
|
|
|
|
// Set up to get 2 opcode bits
|
|
|
|
eepromState = eepromGetOpcode;
|
|
|
|
eepromBitsToRx = 2;
|
|
|
|
eepromOpcode = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eepromGetOpcode:
|
|
|
|
eepromOpcode <<= 1;
|
|
|
|
eepromOpcode += (regs.mear & MEAR_EEDI) ? 1 : 0;
|
|
|
|
--eepromBitsToRx;
|
|
|
|
|
|
|
|
// Done getting opcode
|
|
|
|
if (eepromBitsToRx == 0) {
|
|
|
|
if (eepromOpcode != EEPROM_READ)
|
|
|
|
panic("only EEPROM reads are implemented!");
|
|
|
|
|
|
|
|
// Set up to get address
|
|
|
|
eepromState = eepromGetAddress;
|
|
|
|
eepromBitsToRx = 6;
|
|
|
|
eepromAddress = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eepromGetAddress:
|
|
|
|
eepromAddress <<= 1;
|
|
|
|
eepromAddress += (regs.mear & MEAR_EEDI) ? 1 : 0;
|
|
|
|
--eepromBitsToRx;
|
|
|
|
|
|
|
|
// Done getting address
|
|
|
|
if (eepromBitsToRx == 0) {
|
|
|
|
|
|
|
|
if (eepromAddress >= EEPROM_SIZE)
|
|
|
|
panic("EEPROM read access out of range!");
|
|
|
|
|
|
|
|
switch (eepromAddress) {
|
|
|
|
|
|
|
|
case EEPROM_PMATCH2_ADDR:
|
|
|
|
eepromData = rom.perfectMatch[5];
|
|
|
|
eepromData <<= 8;
|
|
|
|
eepromData += rom.perfectMatch[4];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EEPROM_PMATCH1_ADDR:
|
|
|
|
eepromData = rom.perfectMatch[3];
|
|
|
|
eepromData <<= 8;
|
|
|
|
eepromData += rom.perfectMatch[2];
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EEPROM_PMATCH0_ADDR:
|
|
|
|
eepromData = rom.perfectMatch[1];
|
|
|
|
eepromData <<= 8;
|
|
|
|
eepromData += rom.perfectMatch[0];
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("FreeBSD driver only uses EEPROM to read PMATCH!");
|
|
|
|
}
|
|
|
|
// Set up to read data
|
|
|
|
eepromState = eepromRead;
|
|
|
|
eepromBitsToRx = 16;
|
|
|
|
|
|
|
|
// Clear data in bit
|
|
|
|
regs.mear &= ~MEAR_EEDI;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case eepromRead:
|
|
|
|
// Clear Data Out bit
|
|
|
|
regs.mear &= ~MEAR_EEDO;
|
|
|
|
// Set bit to value of current EEPROM bit
|
|
|
|
regs.mear |= (eepromData & 0x8000) ? MEAR_EEDO : 0x0;
|
|
|
|
|
|
|
|
eepromData <<= 1;
|
|
|
|
--eepromBitsToRx;
|
|
|
|
|
|
|
|
// All done
|
|
|
|
if (eepromBitsToRx == 0) {
|
|
|
|
eepromState = eepromStart;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
panic("invalid EEPROM state");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::transferDone()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-07-30 17:33:45 +02:00
|
|
|
if (txFifo.empty()) {
|
|
|
|
DPRINTF(Ethernet, "transfer complete: txFifo empty...nothing to do\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
return;
|
2004-07-30 17:33:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(Ethernet, "transfer complete: data in txFifo...schedule xmit\n");
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2008-10-09 13:58:24 +02:00
|
|
|
reschedule(txEvent, curTick + ticks(1), true);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2006-04-25 01:31:50 +02:00
|
|
|
NSGigE::rxFilter(const EthPacketPtr &packet)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-10-23 22:18:44 +02:00
|
|
|
EthPtr eth = packet;
|
2004-03-12 17:04:58 +01:00
|
|
|
bool drop = true;
|
|
|
|
string type;
|
|
|
|
|
2004-10-23 22:18:44 +02:00
|
|
|
const EthAddr &dst = eth->dst();
|
|
|
|
if (dst.unicast()) {
|
2004-03-12 17:04:58 +01:00
|
|
|
// If we're accepting all unicast addresses
|
|
|
|
if (acceptUnicast)
|
|
|
|
drop = false;
|
|
|
|
|
|
|
|
// If we make a perfect match
|
2004-10-23 22:18:44 +02:00
|
|
|
if (acceptPerfect && dst == rom.perfectMatch)
|
2004-03-12 17:04:58 +01:00
|
|
|
drop = false;
|
|
|
|
|
2004-09-20 16:43:53 +02:00
|
|
|
if (acceptArp && eth->type() == ETH_TYPE_ARP)
|
2004-03-12 17:04:58 +01:00
|
|
|
drop = false;
|
|
|
|
|
2004-10-23 22:18:44 +02:00
|
|
|
} else if (dst.broadcast()) {
|
2004-03-12 17:04:58 +01:00
|
|
|
// if we're accepting broadcasts
|
|
|
|
if (acceptBroadcast)
|
|
|
|
drop = false;
|
|
|
|
|
2004-10-23 22:18:44 +02:00
|
|
|
} else if (dst.multicast()) {
|
2004-03-12 17:04:58 +01:00
|
|
|
// if we're accepting all multicasts
|
|
|
|
if (acceptMulticast)
|
|
|
|
drop = false;
|
|
|
|
|
2005-08-13 00:30:35 +02:00
|
|
|
// Multicast hashing faked - all packets accepted
|
|
|
|
if (multicastHashEnable)
|
|
|
|
drop = false;
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (drop) {
|
|
|
|
DPRINTF(Ethernet, "rxFilter drop\n");
|
|
|
|
DDUMP(EthernetData, packet->data, packet->length);
|
|
|
|
}
|
|
|
|
|
|
|
|
return drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2006-04-25 01:31:50 +02:00
|
|
|
NSGigE::recvPacket(EthPacketPtr packet)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
|
|
|
rxBytes += packet->length;
|
|
|
|
rxPackets++;
|
|
|
|
|
2004-07-30 17:33:45 +02:00
|
|
|
DPRINTF(Ethernet, "Receiving packet from wire, rxFifoAvail=%d\n",
|
2004-11-13 22:52:08 +01:00
|
|
|
rxFifo.avail());
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2004-07-30 17:29:45 +02:00
|
|
|
if (!rxEnable) {
|
2004-03-12 17:04:58 +01:00
|
|
|
DPRINTF(Ethernet, "receive disabled...packet dropped\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-08-13 00:30:35 +02:00
|
|
|
if (!rxFilterEnable) {
|
|
|
|
DPRINTF(Ethernet,
|
|
|
|
"receive packet filtering disabled . . . packet dropped\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rxFilter(packet)) {
|
2004-03-12 17:04:58 +01:00
|
|
|
DPRINTF(Ethernet, "packet filtered...dropped\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-11-13 22:52:08 +01:00
|
|
|
if (rxFifo.avail() < packet->length) {
|
2005-03-16 19:55:58 +01:00
|
|
|
#if TRACING_ON
|
|
|
|
IpPtr ip(packet);
|
|
|
|
TcpPtr tcp(ip);
|
|
|
|
if (ip) {
|
|
|
|
DPRINTF(Ethernet,
|
|
|
|
"packet won't fit in receive buffer...pkt ID %d dropped\n",
|
|
|
|
ip->id());
|
|
|
|
if (tcp) {
|
|
|
|
DPRINTF(Ethernet, "Seq=%d\n", tcp->seq());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2004-11-18 21:46:01 +01:00
|
|
|
droppedPackets++;
|
2004-03-12 17:04:58 +01:00
|
|
|
devIntrPost(ISR_RXORN);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-11-13 22:52:08 +01:00
|
|
|
rxFifo.push(packet);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
rxKick();
|
2004-03-12 17:04:58 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-07-13 02:22:07 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
NSGigE::resume()
|
|
|
|
{
|
|
|
|
SimObject::resume();
|
|
|
|
|
|
|
|
// During drain we could have left the state machines in a waiting state and
|
|
|
|
// they wouldn't get out until some other event occured to kick them.
|
|
|
|
// This way they'll get out immediately
|
|
|
|
txKick();
|
|
|
|
rxKick();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
//=====================================================================
|
|
|
|
//
|
|
|
|
//
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::serialize(ostream &os)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-06-04 21:12:27 +02:00
|
|
|
// Serialize the PciDev base class
|
|
|
|
PciDev::serialize(os);
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
|
|
|
* Finalize any DMA events now.
|
|
|
|
*/
|
2006-04-25 01:31:50 +02:00
|
|
|
// @todo will mem system save pending dma?
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Serialize the device registers
|
|
|
|
*/
|
|
|
|
SERIALIZE_SCALAR(regs.command);
|
|
|
|
SERIALIZE_SCALAR(regs.config);
|
|
|
|
SERIALIZE_SCALAR(regs.mear);
|
|
|
|
SERIALIZE_SCALAR(regs.ptscr);
|
|
|
|
SERIALIZE_SCALAR(regs.isr);
|
|
|
|
SERIALIZE_SCALAR(regs.imr);
|
|
|
|
SERIALIZE_SCALAR(regs.ier);
|
|
|
|
SERIALIZE_SCALAR(regs.ihr);
|
|
|
|
SERIALIZE_SCALAR(regs.txdp);
|
|
|
|
SERIALIZE_SCALAR(regs.txdp_hi);
|
|
|
|
SERIALIZE_SCALAR(regs.txcfg);
|
|
|
|
SERIALIZE_SCALAR(regs.gpior);
|
|
|
|
SERIALIZE_SCALAR(regs.rxdp);
|
|
|
|
SERIALIZE_SCALAR(regs.rxdp_hi);
|
|
|
|
SERIALIZE_SCALAR(regs.rxcfg);
|
|
|
|
SERIALIZE_SCALAR(regs.pqcr);
|
|
|
|
SERIALIZE_SCALAR(regs.wcsr);
|
|
|
|
SERIALIZE_SCALAR(regs.pcr);
|
|
|
|
SERIALIZE_SCALAR(regs.rfcr);
|
|
|
|
SERIALIZE_SCALAR(regs.rfdr);
|
2005-08-13 00:30:35 +02:00
|
|
|
SERIALIZE_SCALAR(regs.brar);
|
|
|
|
SERIALIZE_SCALAR(regs.brdr);
|
2004-04-22 00:23:41 +02:00
|
|
|
SERIALIZE_SCALAR(regs.srr);
|
|
|
|
SERIALIZE_SCALAR(regs.mibc);
|
|
|
|
SERIALIZE_SCALAR(regs.vrcr);
|
|
|
|
SERIALIZE_SCALAR(regs.vtcr);
|
|
|
|
SERIALIZE_SCALAR(regs.vdr);
|
|
|
|
SERIALIZE_SCALAR(regs.ccsr);
|
|
|
|
SERIALIZE_SCALAR(regs.tbicr);
|
|
|
|
SERIALIZE_SCALAR(regs.tbisr);
|
|
|
|
SERIALIZE_SCALAR(regs.tanar);
|
|
|
|
SERIALIZE_SCALAR(regs.tanlpar);
|
|
|
|
SERIALIZE_SCALAR(regs.taner);
|
|
|
|
SERIALIZE_SCALAR(regs.tesr);
|
|
|
|
|
2004-10-23 22:18:44 +02:00
|
|
|
SERIALIZE_ARRAY(rom.perfectMatch, ETH_ADDR_LEN);
|
2005-08-13 00:30:35 +02:00
|
|
|
SERIALIZE_ARRAY(rom.filterHash, FHASH_SIZE);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
SERIALIZE_SCALAR(ioEnable);
|
2004-06-12 20:24:20 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
2004-06-11 21:26:21 +02:00
|
|
|
* Serialize the data Fifos
|
2004-04-22 00:23:41 +02:00
|
|
|
*/
|
2004-11-13 22:52:08 +01:00
|
|
|
rxFifo.serialize("rxFifo", os);
|
|
|
|
txFifo.serialize("txFifo", os);
|
2004-06-11 21:26:21 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Serialize the various helper variables
|
|
|
|
*/
|
2004-04-22 00:23:41 +02:00
|
|
|
bool txPacketExists = txPacket;
|
2004-03-12 17:04:58 +01:00
|
|
|
SERIALIZE_SCALAR(txPacketExists);
|
2004-06-11 21:26:21 +02:00
|
|
|
if (txPacketExists) {
|
2005-01-19 22:26:19 +01:00
|
|
|
txPacket->length = txPacketBufPtr - txPacket->data;
|
2004-11-13 22:46:56 +01:00
|
|
|
txPacket->serialize("txPacket", os);
|
2004-06-11 21:26:21 +02:00
|
|
|
uint32_t txPktBufPtr = (uint32_t) (txPacketBufPtr - txPacket->data);
|
|
|
|
SERIALIZE_SCALAR(txPktBufPtr);
|
|
|
|
}
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
bool rxPacketExists = rxPacket;
|
2004-03-12 17:04:58 +01:00
|
|
|
SERIALIZE_SCALAR(rxPacketExists);
|
2004-06-11 21:26:21 +02:00
|
|
|
if (rxPacketExists) {
|
2004-11-13 22:46:56 +01:00
|
|
|
rxPacket->serialize("rxPacket", os);
|
2004-06-11 21:26:21 +02:00
|
|
|
uint32_t rxPktBufPtr = (uint32_t) (rxPacketBufPtr - rxPacket->data);
|
|
|
|
SERIALIZE_SCALAR(rxPktBufPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
SERIALIZE_SCALAR(txXferLen);
|
|
|
|
SERIALIZE_SCALAR(rxXferLen);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
2005-10-12 19:39:40 +02:00
|
|
|
* Serialize Cached Descriptors
|
2004-04-22 00:23:41 +02:00
|
|
|
*/
|
2005-10-12 19:39:40 +02:00
|
|
|
SERIALIZE_SCALAR(rxDesc64.link);
|
|
|
|
SERIALIZE_SCALAR(rxDesc64.bufptr);
|
|
|
|
SERIALIZE_SCALAR(rxDesc64.cmdsts);
|
|
|
|
SERIALIZE_SCALAR(rxDesc64.extsts);
|
|
|
|
SERIALIZE_SCALAR(txDesc64.link);
|
|
|
|
SERIALIZE_SCALAR(txDesc64.bufptr);
|
|
|
|
SERIALIZE_SCALAR(txDesc64.cmdsts);
|
|
|
|
SERIALIZE_SCALAR(txDesc64.extsts);
|
|
|
|
SERIALIZE_SCALAR(rxDesc32.link);
|
|
|
|
SERIALIZE_SCALAR(rxDesc32.bufptr);
|
|
|
|
SERIALIZE_SCALAR(rxDesc32.cmdsts);
|
|
|
|
SERIALIZE_SCALAR(rxDesc32.extsts);
|
|
|
|
SERIALIZE_SCALAR(txDesc32.link);
|
|
|
|
SERIALIZE_SCALAR(txDesc32.bufptr);
|
|
|
|
SERIALIZE_SCALAR(txDesc32.cmdsts);
|
|
|
|
SERIALIZE_SCALAR(txDesc32.extsts);
|
2005-06-27 23:02:40 +02:00
|
|
|
SERIALIZE_SCALAR(extstsEnable);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Serialize tx state machine
|
|
|
|
*/
|
|
|
|
int txState = this->txState;
|
|
|
|
SERIALIZE_SCALAR(txState);
|
2004-07-30 17:29:45 +02:00
|
|
|
SERIALIZE_SCALAR(txEnable);
|
2004-04-22 00:23:41 +02:00
|
|
|
SERIALIZE_SCALAR(CTDD);
|
|
|
|
SERIALIZE_SCALAR(txFragPtr);
|
|
|
|
SERIALIZE_SCALAR(txDescCnt);
|
|
|
|
int txDmaState = this->txDmaState;
|
|
|
|
SERIALIZE_SCALAR(txDmaState);
|
2005-06-27 23:02:40 +02:00
|
|
|
SERIALIZE_SCALAR(txKickTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Serialize rx state machine
|
|
|
|
*/
|
|
|
|
int rxState = this->rxState;
|
|
|
|
SERIALIZE_SCALAR(rxState);
|
2004-07-30 17:29:45 +02:00
|
|
|
SERIALIZE_SCALAR(rxEnable);
|
2004-04-22 00:23:41 +02:00
|
|
|
SERIALIZE_SCALAR(CRDD);
|
|
|
|
SERIALIZE_SCALAR(rxPktBytes);
|
2004-11-18 03:03:51 +01:00
|
|
|
SERIALIZE_SCALAR(rxFragPtr);
|
2004-04-22 00:23:41 +02:00
|
|
|
SERIALIZE_SCALAR(rxDescCnt);
|
|
|
|
int rxDmaState = this->rxDmaState;
|
|
|
|
SERIALIZE_SCALAR(rxDmaState);
|
2005-06-27 23:02:40 +02:00
|
|
|
SERIALIZE_SCALAR(rxKickTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2005-08-13 00:30:35 +02:00
|
|
|
/*
|
|
|
|
* Serialize EEPROM state machine
|
|
|
|
*/
|
|
|
|
int eepromState = this->eepromState;
|
|
|
|
SERIALIZE_SCALAR(eepromState);
|
|
|
|
SERIALIZE_SCALAR(eepromClk);
|
|
|
|
SERIALIZE_SCALAR(eepromBitsToRx);
|
|
|
|
SERIALIZE_SCALAR(eepromOpcode);
|
|
|
|
SERIALIZE_SCALAR(eepromAddress);
|
|
|
|
SERIALIZE_SCALAR(eepromData);
|
|
|
|
|
2004-06-11 21:26:21 +02:00
|
|
|
/*
|
2004-04-22 00:23:41 +02:00
|
|
|
* If there's a pending transmit, store the time so we can
|
|
|
|
* reschedule it later
|
|
|
|
*/
|
|
|
|
Tick transmitTick = txEvent.scheduled() ? txEvent.when() - curTick : 0;
|
|
|
|
SERIALIZE_SCALAR(transmitTick);
|
|
|
|
|
2004-06-11 21:26:21 +02:00
|
|
|
/*
|
|
|
|
* receive address filter settings
|
|
|
|
*/
|
|
|
|
SERIALIZE_SCALAR(rxFilterEnable);
|
|
|
|
SERIALIZE_SCALAR(acceptBroadcast);
|
|
|
|
SERIALIZE_SCALAR(acceptMulticast);
|
|
|
|
SERIALIZE_SCALAR(acceptUnicast);
|
|
|
|
SERIALIZE_SCALAR(acceptPerfect);
|
|
|
|
SERIALIZE_SCALAR(acceptArp);
|
2005-08-13 00:30:35 +02:00
|
|
|
SERIALIZE_SCALAR(multicastHashEnable);
|
2004-06-11 21:26:21 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
|
|
|
* Keep track of pending interrupt status.
|
|
|
|
*/
|
|
|
|
SERIALIZE_SCALAR(intrTick);
|
|
|
|
SERIALIZE_SCALAR(cpuPendingIntr);
|
|
|
|
Tick intrEventTick = 0;
|
|
|
|
if (intrEvent)
|
|
|
|
intrEventTick = intrEvent->when();
|
|
|
|
SERIALIZE_SCALAR(intrEventTick);
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-05-25 21:59:54 +02:00
|
|
|
NSGigE::unserialize(Checkpoint *cp, const std::string §ion)
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2004-06-04 21:12:27 +02:00
|
|
|
// Unserialize the PciDev base class
|
|
|
|
PciDev::unserialize(cp, section);
|
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
UNSERIALIZE_SCALAR(regs.command);
|
|
|
|
UNSERIALIZE_SCALAR(regs.config);
|
|
|
|
UNSERIALIZE_SCALAR(regs.mear);
|
|
|
|
UNSERIALIZE_SCALAR(regs.ptscr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.isr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.imr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.ier);
|
|
|
|
UNSERIALIZE_SCALAR(regs.ihr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.txdp);
|
|
|
|
UNSERIALIZE_SCALAR(regs.txdp_hi);
|
|
|
|
UNSERIALIZE_SCALAR(regs.txcfg);
|
|
|
|
UNSERIALIZE_SCALAR(regs.gpior);
|
|
|
|
UNSERIALIZE_SCALAR(regs.rxdp);
|
|
|
|
UNSERIALIZE_SCALAR(regs.rxdp_hi);
|
|
|
|
UNSERIALIZE_SCALAR(regs.rxcfg);
|
|
|
|
UNSERIALIZE_SCALAR(regs.pqcr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.wcsr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.pcr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.rfcr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.rfdr);
|
2005-08-13 00:30:35 +02:00
|
|
|
UNSERIALIZE_SCALAR(regs.brar);
|
|
|
|
UNSERIALIZE_SCALAR(regs.brdr);
|
2004-04-22 00:23:41 +02:00
|
|
|
UNSERIALIZE_SCALAR(regs.srr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.mibc);
|
|
|
|
UNSERIALIZE_SCALAR(regs.vrcr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.vtcr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.vdr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.ccsr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.tbicr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.tbisr);
|
|
|
|
UNSERIALIZE_SCALAR(regs.tanar);
|
|
|
|
UNSERIALIZE_SCALAR(regs.tanlpar);
|
|
|
|
UNSERIALIZE_SCALAR(regs.taner);
|
|
|
|
UNSERIALIZE_SCALAR(regs.tesr);
|
|
|
|
|
2004-10-23 22:18:44 +02:00
|
|
|
UNSERIALIZE_ARRAY(rom.perfectMatch, ETH_ADDR_LEN);
|
2005-08-13 00:30:35 +02:00
|
|
|
UNSERIALIZE_ARRAY(rom.filterHash, FHASH_SIZE);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
UNSERIALIZE_SCALAR(ioEnable);
|
2004-06-12 20:24:20 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
2004-06-11 21:26:21 +02:00
|
|
|
* unserialize the data fifos
|
2004-04-22 00:23:41 +02:00
|
|
|
*/
|
2004-11-13 22:52:08 +01:00
|
|
|
rxFifo.unserialize("rxFifo", cp, section);
|
|
|
|
txFifo.unserialize("txFifo", cp, section);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-06-11 21:26:21 +02:00
|
|
|
/*
|
|
|
|
* unserialize the various helper variables
|
|
|
|
*/
|
2004-03-12 17:04:58 +01:00
|
|
|
bool txPacketExists;
|
|
|
|
UNSERIALIZE_SCALAR(txPacketExists);
|
2004-06-11 21:26:21 +02:00
|
|
|
if (txPacketExists) {
|
2006-04-25 01:31:50 +02:00
|
|
|
txPacket = new EthPacketData(16384);
|
2004-11-13 22:46:56 +01:00
|
|
|
txPacket->unserialize("txPacket", cp, section);
|
2004-06-11 21:26:21 +02:00
|
|
|
uint32_t txPktBufPtr;
|
|
|
|
UNSERIALIZE_SCALAR(txPktBufPtr);
|
|
|
|
txPacketBufPtr = (uint8_t *) txPacket->data + txPktBufPtr;
|
|
|
|
} else
|
|
|
|
txPacket = 0;
|
|
|
|
|
2004-03-12 17:04:58 +01:00
|
|
|
bool rxPacketExists;
|
|
|
|
UNSERIALIZE_SCALAR(rxPacketExists);
|
2004-06-11 21:26:21 +02:00
|
|
|
rxPacket = 0;
|
|
|
|
if (rxPacketExists) {
|
2006-04-25 01:31:50 +02:00
|
|
|
rxPacket = new EthPacketData(16384);
|
2004-11-13 22:46:56 +01:00
|
|
|
rxPacket->unserialize("rxPacket", cp, section);
|
2004-06-11 21:26:21 +02:00
|
|
|
uint32_t rxPktBufPtr;
|
|
|
|
UNSERIALIZE_SCALAR(rxPktBufPtr);
|
|
|
|
rxPacketBufPtr = (uint8_t *) rxPacket->data + rxPktBufPtr;
|
|
|
|
} else
|
|
|
|
rxPacket = 0;
|
|
|
|
|
|
|
|
UNSERIALIZE_SCALAR(txXferLen);
|
|
|
|
UNSERIALIZE_SCALAR(rxXferLen);
|
2004-03-12 17:04:58 +01:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
2005-10-12 19:39:40 +02:00
|
|
|
* Unserialize Cached Descriptors
|
2004-04-22 00:23:41 +02:00
|
|
|
*/
|
2005-10-12 19:39:40 +02:00
|
|
|
UNSERIALIZE_SCALAR(rxDesc64.link);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc64.bufptr);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc64.cmdsts);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc64.extsts);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc64.link);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc64.bufptr);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc64.cmdsts);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc64.extsts);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc32.link);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc32.bufptr);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc32.cmdsts);
|
|
|
|
UNSERIALIZE_SCALAR(rxDesc32.extsts);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc32.link);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc32.bufptr);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc32.cmdsts);
|
|
|
|
UNSERIALIZE_SCALAR(txDesc32.extsts);
|
2005-06-27 23:02:40 +02:00
|
|
|
UNSERIALIZE_SCALAR(extstsEnable);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* unserialize tx state machine
|
|
|
|
*/
|
|
|
|
int txState;
|
|
|
|
UNSERIALIZE_SCALAR(txState);
|
|
|
|
this->txState = (TxState) txState;
|
2004-07-30 17:29:45 +02:00
|
|
|
UNSERIALIZE_SCALAR(txEnable);
|
2004-04-22 00:23:41 +02:00
|
|
|
UNSERIALIZE_SCALAR(CTDD);
|
|
|
|
UNSERIALIZE_SCALAR(txFragPtr);
|
|
|
|
UNSERIALIZE_SCALAR(txDescCnt);
|
|
|
|
int txDmaState;
|
|
|
|
UNSERIALIZE_SCALAR(txDmaState);
|
|
|
|
this->txDmaState = (DmaState) txDmaState;
|
2005-06-27 23:02:40 +02:00
|
|
|
UNSERIALIZE_SCALAR(txKickTick);
|
|
|
|
if (txKickTick)
|
2008-10-09 13:58:24 +02:00
|
|
|
schedule(txKickEvent, txKickTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* unserialize rx state machine
|
|
|
|
*/
|
|
|
|
int rxState;
|
|
|
|
UNSERIALIZE_SCALAR(rxState);
|
|
|
|
this->rxState = (RxState) rxState;
|
2004-07-30 17:29:45 +02:00
|
|
|
UNSERIALIZE_SCALAR(rxEnable);
|
2004-04-22 00:23:41 +02:00
|
|
|
UNSERIALIZE_SCALAR(CRDD);
|
|
|
|
UNSERIALIZE_SCALAR(rxPktBytes);
|
2004-11-18 03:03:51 +01:00
|
|
|
UNSERIALIZE_SCALAR(rxFragPtr);
|
2004-04-22 00:23:41 +02:00
|
|
|
UNSERIALIZE_SCALAR(rxDescCnt);
|
|
|
|
int rxDmaState;
|
|
|
|
UNSERIALIZE_SCALAR(rxDmaState);
|
|
|
|
this->rxDmaState = (DmaState) rxDmaState;
|
2005-06-27 23:02:40 +02:00
|
|
|
UNSERIALIZE_SCALAR(rxKickTick);
|
|
|
|
if (rxKickTick)
|
2008-10-09 13:58:24 +02:00
|
|
|
schedule(rxKickEvent, rxKickTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2005-08-13 00:30:35 +02:00
|
|
|
/*
|
|
|
|
* Unserialize EEPROM state machine
|
|
|
|
*/
|
|
|
|
int eepromState;
|
|
|
|
UNSERIALIZE_SCALAR(eepromState);
|
|
|
|
this->eepromState = (EEPROMState) eepromState;
|
|
|
|
UNSERIALIZE_SCALAR(eepromClk);
|
|
|
|
UNSERIALIZE_SCALAR(eepromBitsToRx);
|
|
|
|
UNSERIALIZE_SCALAR(eepromOpcode);
|
|
|
|
UNSERIALIZE_SCALAR(eepromAddress);
|
|
|
|
UNSERIALIZE_SCALAR(eepromData);
|
|
|
|
|
|
|
|
/*
|
2004-06-11 21:26:21 +02:00
|
|
|
* If there's a pending transmit, reschedule it now
|
2004-04-22 00:23:41 +02:00
|
|
|
*/
|
|
|
|
Tick transmitTick;
|
|
|
|
UNSERIALIZE_SCALAR(transmitTick);
|
|
|
|
if (transmitTick)
|
2008-10-09 13:58:24 +02:00
|
|
|
schedule(txEvent, curTick + transmitTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
|
2004-06-11 21:26:21 +02:00
|
|
|
/*
|
|
|
|
* unserialize receive address filter settings
|
|
|
|
*/
|
|
|
|
UNSERIALIZE_SCALAR(rxFilterEnable);
|
|
|
|
UNSERIALIZE_SCALAR(acceptBroadcast);
|
|
|
|
UNSERIALIZE_SCALAR(acceptMulticast);
|
|
|
|
UNSERIALIZE_SCALAR(acceptUnicast);
|
|
|
|
UNSERIALIZE_SCALAR(acceptPerfect);
|
|
|
|
UNSERIALIZE_SCALAR(acceptArp);
|
2005-08-13 00:30:35 +02:00
|
|
|
UNSERIALIZE_SCALAR(multicastHashEnable);
|
2004-06-11 21:26:21 +02:00
|
|
|
|
2004-04-22 00:23:41 +02:00
|
|
|
/*
|
|
|
|
* Keep track of pending interrupt status.
|
|
|
|
*/
|
|
|
|
UNSERIALIZE_SCALAR(intrTick);
|
|
|
|
UNSERIALIZE_SCALAR(cpuPendingIntr);
|
|
|
|
Tick intrEventTick;
|
|
|
|
UNSERIALIZE_SCALAR(intrEventTick);
|
|
|
|
if (intrEventTick) {
|
2008-10-09 13:58:24 +02:00
|
|
|
intrEvent = new IntrEvent(this, true);
|
|
|
|
schedule(intrEvent, intrEventTick);
|
2004-04-22 00:23:41 +02:00
|
|
|
}
|
|
|
|
}
|
l
base/traceflags.py:
added some more traceflags for ethernet to break it up better
dev/etherpkt.hh:
since we are not network host order, must reverse bytes for these typechecks.
also, overload isTcp/UdpPkt to take an argument so you don't have to reget the ip header if you've already got one.
dev/ns_gige.cc:
1) add some functions that reverse Endianness so we can generate adn evaluate checksum adn dprintf data accurately/more understandably
2) forget about the implementation of fifo fill/drain thresholds, it's not used by the driver much, nor does it matter with use sending/receiving in whole packets anyway.
get rid of teh associated variables.
3) get rid of txFifoCnt the variable, it's redundant and unnecessary, just use txFifoAvail.
4) change io_enable to ioEnable, just to be picky.
5) modify some DPRINTF's to be clearer, also added a lot, and spread them into better traceflag categories
6) fix the device bug! it's the intrTick = 0 at teh beginning of cpuInterrupt().
7) clear some bools in regsReset() so they don't holdover wrong state
8) fix pseudo header generation for Tcp checksumming to account for network order
dev/ns_gige.hh:
change io_enable to ioEnable, get rid of fill/drain thresh related variables and txFifoCnt, which is redundant
--HG--
extra : convert_revision : c538b75731f3c9e04354f57e6df9a40aeca5096d
2004-06-21 23:25:18 +02:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
NSGigE *
|
|
|
|
NSGigEParams::create()
|
2004-03-12 17:04:58 +01:00
|
|
|
{
|
2007-07-24 06:51:38 +02:00
|
|
|
return new NSGigE(this);
|
2004-03-12 17:04:58 +01:00
|
|
|
}
|