2 * Copyright (c) 2004 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * Device module for modelling the National Semiconductor
31 * DP83820 ethernet controller. Does not support priority queueing
37 #include "base/inet.hh"
38 #include "cpu/exec_context.hh"
40 #include "dev/etherlink.hh"
41 #include "dev/ns_gige.hh"
42 #include "dev/pciconfigall.hh"
43 #include "mem/bus/bus.hh"
44 #include "mem/bus/dma_interface.hh"
45 #include "mem/bus/pio_interface.hh"
46 #include "mem/bus/pio_interface_impl.hh"
47 #include "mem/functional_mem/memory_control.hh"
48 #include "mem/functional_mem/physical_memory.hh"
49 #include "sim/builder.hh"
50 #include "sim/debug.hh"
51 #include "sim/host.hh"
52 #include "sim/stats.hh"
53 #include "targetarch/vtophys.hh"
55 const char *NsRxStateStrings
[] =
66 const char *NsTxStateStrings
[] =
77 const char *NsDmaState
[] =
89 ///////////////////////////////////////////////////////////////////////
93 NSGigE::NSGigE(Params
*p
)
94 : PciDev(p
), ioEnable(false),
95 txFifo(p
->tx_fifo_size
), rxFifo(p
->rx_fifo_size
),
96 txPacket(0), rxPacket(0), txPacketBufPtr(NULL
), rxPacketBufPtr(NULL
),
97 txXferLen(0), rxXferLen(0), cycleTime(p
->cycle_time
),
98 txState(txIdle
), txEnable(false), CTDD(false),
99 txFragPtr(0), txDescCnt(0), txDmaState(dmaIdle
), rxState(rxIdle
),
100 rxEnable(false), CRDD(false), rxPktBytes(0),
101 rxFragPtr(0), rxDescCnt(0), rxDmaState(dmaIdle
), extstsEnable(false),
102 rxDmaReadEvent(this), rxDmaWriteEvent(this),
103 txDmaReadEvent(this), txDmaWriteEvent(this),
104 dmaDescFree(p
->dma_desc_free
), dmaDataFree(p
->dma_data_free
),
105 txDelay(p
->tx_delay
), rxDelay(p
->rx_delay
),
106 rxKickTick(0), txKickTick(0),
107 txEvent(this), rxFilterEnable(p
->rx_filter
), acceptBroadcast(false),
108 acceptMulticast(false), acceptUnicast(false),
109 acceptPerfect(false), acceptArp(false),
110 physmem(p
->pmem
), intrTick(0), cpuPendingIntr(false),
111 intrEvent(0), interface(0)
114 pioInterface
= newPioInterface(name(), p
->hier
,
116 &NSGigE::cacheAccess
);
118 pioLatency
= p
->pio_latency
* p
->header_bus
->clockRatio
;
121 dmaInterface
= new DMAInterface
<Bus
>(name() + ".dma",
125 dmaInterface
= new DMAInterface
<Bus
>(name() + ".dma",
128 } else if (p
->payload_bus
) {
129 pioInterface
= newPioInterface(name(), p
->hier
,
130 p
->payload_bus
, this,
131 &NSGigE::cacheAccess
);
133 pioLatency
= p
->pio_latency
* p
->payload_bus
->clockRatio
;
135 dmaInterface
= new DMAInterface
<Bus
>(name() + ".dma",
141 intrDelay
= p
->intr_delay
;
142 dmaReadDelay
= p
->dma_read_delay
;
143 dmaWriteDelay
= p
->dma_write_delay
;
144 dmaReadFactor
= p
->dma_read_factor
;
145 dmaWriteFactor
= p
->dma_write_factor
;
148 memcpy(&rom
.perfectMatch
, p
->eaddr
.bytes(), ETH_ADDR_LEN
);
158 .name(name() + ".txBytes")
159 .desc("Bytes Transmitted")
164 .name(name() + ".rxBytes")
165 .desc("Bytes Received")
170 .name(name() + ".txPackets")
171 .desc("Number of Packets Transmitted")
176 .name(name() + ".rxPackets")
177 .desc("Number of Packets Received")
182 .name(name() + ".txIpChecksums")
183 .desc("Number of tx IP Checksums done by device")
189 .name(name() + ".rxIpChecksums")
190 .desc("Number of rx IP Checksums done by device")
196 .name(name() + ".txTcpChecksums")
197 .desc("Number of tx TCP Checksums done by device")
203 .name(name() + ".rxTcpChecksums")
204 .desc("Number of rx TCP Checksums done by device")
210 .name(name() + ".txUdpChecksums")
211 .desc("Number of tx UDP Checksums done by device")
217 .name(name() + ".rxUdpChecksums")
218 .desc("Number of rx UDP Checksums done by device")
224 .name(name() + ".descDMAReads")
225 .desc("Number of descriptors the device read w/ DMA")
230 .name(name() + ".descDMAWrites")
231 .desc("Number of descriptors the device wrote w/ DMA")
236 .name(name() + ".descDmaReadBytes")
237 .desc("number of descriptor bytes read w/ DMA")
242 .name(name() + ".descDmaWriteBytes")
243 .desc("number of descriptor bytes write w/ DMA")
248 .name(name() + ".txBandwidth")
249 .desc("Transmit Bandwidth (bits/s)")
255 .name(name() + ".rxBandwidth")
256 .desc("Receive Bandwidth (bits/s)")
262 .name(name() + ".totBandwidth")
263 .desc("Total Bandwidth (bits/s)")
269 .name(name() + ".totPackets")
270 .desc("Total Packets")
276 .name(name() + ".totBytes")
283 .name(name() + ".totPPS")
284 .desc("Total Tranmission Rate (packets/s)")
290 .name(name() + ".txPPS")
291 .desc("Packet Tranmission Rate (packets/s)")
297 .name(name() + ".rxPPS")
298 .desc("Packet Reception Rate (packets/s)")
304 .name(name() + ".postedSwi")
305 .desc("number of software interrupts posted to CPU")
310 .name(name() + ".totalSwi")
311 .desc("number of total Swi written to ISR")
316 .name(name() + ".coalescedSwi")
317 .desc("average number of Swi's coalesced into each post")
322 .name(name() + ".postedRxIdle")
323 .desc("number of rxIdle interrupts posted to CPU")
328 .name(name() + ".totalRxIdle")
329 .desc("number of total RxIdle written to ISR")
334 .name(name() + ".coalescedRxIdle")
335 .desc("average number of RxIdle's coalesced into each post")
340 .name(name() + ".postedRxOk")
341 .desc("number of RxOk interrupts posted to CPU")
346 .name(name() + ".totalRxOk")
347 .desc("number of total RxOk written to ISR")
352 .name(name() + ".coalescedRxOk")
353 .desc("average number of RxOk's coalesced into each post")
358 .name(name() + ".postedRxDesc")
359 .desc("number of RxDesc interrupts posted to CPU")
364 .name(name() + ".totalRxDesc")
365 .desc("number of total RxDesc written to ISR")
370 .name(name() + ".coalescedRxDesc")
371 .desc("average number of RxDesc's coalesced into each post")
376 .name(name() + ".postedTxOk")
377 .desc("number of TxOk interrupts posted to CPU")
382 .name(name() + ".totalTxOk")
383 .desc("number of total TxOk written to ISR")
388 .name(name() + ".coalescedTxOk")
389 .desc("average number of TxOk's coalesced into each post")
394 .name(name() + ".postedTxIdle")
395 .desc("number of TxIdle interrupts posted to CPU")
400 .name(name() + ".totalTxIdle")
401 .desc("number of total TxIdle written to ISR")
406 .name(name() + ".coalescedTxIdle")
407 .desc("average number of TxIdle's coalesced into each post")
412 .name(name() + ".postedTxDesc")
413 .desc("number of TxDesc interrupts posted to CPU")
418 .name(name() + ".totalTxDesc")
419 .desc("number of total TxDesc written to ISR")
424 .name(name() + ".coalescedTxDesc")
425 .desc("average number of TxDesc's coalesced into each post")
430 .name(name() + ".postedRxOrn")
431 .desc("number of RxOrn posted to CPU")
436 .name(name() + ".totalRxOrn")
437 .desc("number of total RxOrn written to ISR")
442 .name(name() + ".coalescedRxOrn")
443 .desc("average number of RxOrn's coalesced into each post")
448 .name(name() + ".coalescedTotal")
449 .desc("average number of interrupts coalesced into each post")
454 .name(name() + ".postedInterrupts")
455 .desc("number of posts to CPU")
460 .name(name() + ".droppedPackets")
461 .desc("number of packets dropped")
465 coalescedSwi
= totalSwi
/ postedInterrupts
;
466 coalescedRxIdle
= totalRxIdle
/ postedInterrupts
;
467 coalescedRxOk
= totalRxOk
/ postedInterrupts
;
468 coalescedRxDesc
= totalRxDesc
/ postedInterrupts
;
469 coalescedTxOk
= totalTxOk
/ postedInterrupts
;
470 coalescedTxIdle
= totalTxIdle
/ postedInterrupts
;
471 coalescedTxDesc
= totalTxDesc
/ postedInterrupts
;
472 coalescedRxOrn
= totalRxOrn
/ postedInterrupts
;
474 coalescedTotal
= (totalSwi
+ totalRxIdle
+ totalRxOk
+ totalRxDesc
+ totalTxOk
475 + totalTxIdle
+ totalTxDesc
+ totalRxOrn
) / postedInterrupts
;
477 txBandwidth
= txBytes
* Stats::constant(8) / simSeconds
;
478 rxBandwidth
= rxBytes
* Stats::constant(8) / simSeconds
;
479 totBandwidth
= txBandwidth
+ rxBandwidth
;
480 totBytes
= txBytes
+ rxBytes
;
481 totPackets
= txPackets
+ rxPackets
;
483 txPacketRate
= txPackets
/ simSeconds
;
484 rxPacketRate
= rxPackets
/ simSeconds
;
488 * This is to read the PCI general configuration registers
491 NSGigE::ReadConfig(int offset
, int size
, uint8_t *data
)
493 if (offset
< PCI_DEVICE_SPECIFIC
)
494 PciDev::ReadConfig(offset
, size
, data
);
496 panic("Device specific PCI config space not implemented!\n");
500 * This is to write to the PCI general configuration registers
503 NSGigE::WriteConfig(int offset
, int size
, uint32_t data
)
505 if (offset
< PCI_DEVICE_SPECIFIC
)
506 PciDev::WriteConfig(offset
, size
, data
);
508 panic("Device specific PCI config space not implemented!\n");
510 // Need to catch writes to BARs to update the PIO interface
512 // seems to work fine without all these PCI settings, but i
513 // put in the IO to double check, an assertion will fail if we
514 // need to properly implement it
516 if (config
.data
[offset
] & PCI_CMD_IOSE
)
522 if (config
.data
[offset
] & PCI_CMD_BME
) {
529 if (config
.data
[offset
] & PCI_CMD_MSE
) {
538 case PCI0_BASE_ADDR0
:
539 if (BARAddrs
[0] != 0) {
541 pioInterface
->addAddrRange(RangeSize(BARAddrs
[0], BARSize
[0]));
543 BARAddrs
[0] &= EV5::PAddrUncachedMask
;
546 case PCI0_BASE_ADDR1
:
547 if (BARAddrs
[1] != 0) {
549 pioInterface
->addAddrRange(RangeSize(BARAddrs
[1], BARSize
[1]));
551 BARAddrs
[1] &= EV5::PAddrUncachedMask
;
558 * This reads the device registers, which are detailed in the NS83820
562 NSGigE::read(MemReqPtr
&req
, uint8_t *data
)
566 //The mask is to give you only the offset into the device register file
567 Addr daddr
= req
->paddr
& 0xfff;
568 DPRINTF(EthernetPIO
, "read da=%#x pa=%#x va=%#x size=%d\n",
569 daddr
, req
->paddr
, req
->vaddr
, req
->size
);
572 // there are some reserved registers, you can see ns_gige_reg.h and
573 // the spec sheet for details
574 if (daddr
> LAST
&& daddr
<= RESERVED
) {
575 panic("Accessing reserved register");
576 } else if (daddr
> RESERVED
&& daddr
<= 0x3FC) {
577 ReadConfig(daddr
& 0xff, req
->size
, data
);
579 } else if (daddr
>= MIB_START
&& daddr
<= MIB_END
) {
580 // don't implement all the MIB's. hopefully the kernel
581 // doesn't actually DEPEND upon their values
582 // MIB are just hardware stats keepers
583 uint32_t ®
= *(uint32_t *) data
;
586 } else if (daddr
> 0x3FC)
587 panic("Something is messed up!\n");
590 case sizeof(uint32_t):
592 uint32_t ®
= *(uint32_t *)data
;
597 //these are supposed to be cleared on a read
598 reg
&= ~(CR_RXD
| CR_TXD
| CR_TXR
| CR_RXR
);
615 devIntrClear(ISR_ALL
);
670 // see the spec sheet for how RFCR and RFDR work
671 // basically, you write to RFCR to tell the machine
672 // what you want to do next, then you act upon RFDR,
673 // and the device will be prepared b/c of what you
680 switch (regs
.rfcr
& RFCR_RFADDR
) {
682 reg
= rom
.perfectMatch
[1];
684 reg
+= rom
.perfectMatch
[0];
687 reg
= rom
.perfectMatch
[3] << 8;
688 reg
+= rom
.perfectMatch
[2];
691 reg
= rom
.perfectMatch
[5] << 8;
692 reg
+= rom
.perfectMatch
[4];
695 panic("reading RFDR for something other than PMATCH!\n");
696 // didn't implement other RFDR functionality b/c
697 // driver didn't use it
707 reg
&= ~(MIBC_MIBS
| MIBC_ACLR
);
751 reg
= params()->m5reg
;
755 panic("reading unimplemented register: addr=%#x", daddr
);
758 DPRINTF(EthernetPIO
, "read from %#x: data=%d data=%#x\n",
764 panic("accessing register with invalid size: addr=%#x, size=%d",
772 NSGigE::write(MemReqPtr
&req
, const uint8_t *data
)
776 Addr daddr
= req
->paddr
& 0xfff;
777 DPRINTF(EthernetPIO
, "write da=%#x pa=%#x va=%#x size=%d\n",
778 daddr
, req
->paddr
, req
->vaddr
, req
->size
);
780 if (daddr
> LAST
&& daddr
<= RESERVED
) {
781 panic("Accessing reserved register");
782 } else if (daddr
> RESERVED
&& daddr
<= 0x3FC) {
783 WriteConfig(daddr
& 0xff, req
->size
, *(uint32_t *)data
);
785 } else if (daddr
> 0x3FC)
786 panic("Something is messed up!\n");
788 if (req
->size
== sizeof(uint32_t)) {
789 uint32_t reg
= *(uint32_t *)data
;
790 DPRINTF(EthernetPIO
, "write data=%d data=%#x\n", reg
, reg
);
797 } else if (reg
& CR_TXE
) {
800 // the kernel is enabling the transmit machine
801 if (txState
== txIdle
)
807 } else if (reg
& CR_RXE
) {
810 if (rxState
== rxIdle
)
821 devIntrPost(ISR_SWI
);
832 if (reg
& CFG_LNKSTS
||
835 reg
& CFG_RESERVED
||
838 panic("writing to read-only or reserved CFG bits!\n");
840 regs
.config
|= reg
& ~(CFG_LNKSTS
| CFG_SPDSTS
| CFG_DUPSTS
|
841 CFG_RESERVED
| CFG_T64ADDR
| CFG_PCI64_DET
);
843 // all these #if 0's are because i don't THINK the kernel needs to
844 // have these implemented. if there is a problem relating to one of
845 // these, you may need to add functionality in.
847 if (reg
& CFG_TBI_EN
) ;
848 if (reg
& CFG_MODE_1000
) ;
851 if (reg
& CFG_AUTO_1000
)
852 panic("CFG_AUTO_1000 not implemented!\n");
855 if (reg
& CFG_PINT_DUPSTS
||
856 reg
& CFG_PINT_LNKSTS
||
857 reg
& CFG_PINT_SPDSTS
)
860 if (reg
& CFG_TMRTEST
) ;
861 if (reg
& CFG_MRM_DIS
) ;
862 if (reg
& CFG_MWI_DIS
) ;
864 if (reg
& CFG_T64ADDR
)
865 panic("CFG_T64ADDR is read only register!\n");
867 if (reg
& CFG_PCI64_DET
)
868 panic("CFG_PCI64_DET is read only register!\n");
870 if (reg
& CFG_DATA64_EN
) ;
871 if (reg
& CFG_M64ADDR
) ;
872 if (reg
& CFG_PHY_RST
) ;
873 if (reg
& CFG_PHY_DIS
) ;
876 if (reg
& CFG_EXTSTS_EN
)
879 extstsEnable
= false;
882 if (reg
& CFG_REQALG
) ;
886 if (reg
& CFG_PESEL
) ;
887 if (reg
& CFG_BROM_DIS
) ;
888 if (reg
& CFG_EXT_125
) ;
895 // since phy is completely faked, MEAR_MD* don't matter
896 // and since the driver never uses MEAR_EE*, they don't
899 if (reg
& MEAR_EEDI
) ;
900 if (reg
& MEAR_EEDO
) ; // this one is read only
901 if (reg
& MEAR_EECLK
) ;
902 if (reg
& MEAR_EESEL
) ;
903 if (reg
& MEAR_MDIO
) ;
904 if (reg
& MEAR_MDDIR
) ;
905 if (reg
& MEAR_MDC
) ;
910 regs
.ptscr
= reg
& ~(PTSCR_RBIST_RDONLY
);
911 // these control BISTs for various parts of chip - we
912 // don't care or do just fake that the BIST is done
913 if (reg
& PTSCR_RBIST_EN
)
914 regs
.ptscr
|= PTSCR_RBIST_DONE
;
915 if (reg
& PTSCR_EEBIST_EN
)
916 regs
.ptscr
&= ~PTSCR_EEBIST_EN
;
917 if (reg
& PTSCR_EELOAD_EN
)
918 regs
.ptscr
&= ~PTSCR_EELOAD_EN
;
921 case ISR
: /* writing to the ISR has no effect */
922 panic("ISR is a read only register!\n");
935 /* not going to implement real interrupt holdoff */
939 regs
.txdp
= (reg
& 0xFFFFFFFC);
940 assert(txState
== txIdle
);
951 if (reg
& TXCFG_CSI
) ;
952 if (reg
& TXCFG_HBI
) ;
953 if (reg
& TXCFG_MLB
) ;
954 if (reg
& TXCFG_ATP
) ;
955 if (reg
& TXCFG_ECRETRY
) {
957 * this could easily be implemented, but considering
958 * the network is just a fake pipe, wouldn't make
963 if (reg
& TXCFG_BRST_DIS
) ;
967 /* we handle our own DMA, ignore the kernel's exhortations */
968 if (reg
& TXCFG_MXDMA
) ;
971 // also, we currently don't care about fill/drain
972 // thresholds though this may change in the future with
973 // more realistic networks or a driver which changes it
974 // according to feedback
980 /* these just control general purpose i/o pins, don't matter */
995 if (reg
& RXCFG_AEP
) ;
996 if (reg
& RXCFG_ARP
) ;
997 if (reg
& RXCFG_STRIPCRC
) ;
998 if (reg
& RXCFG_RX_RD
) ;
999 if (reg
& RXCFG_ALP
) ;
1000 if (reg
& RXCFG_AIRL
) ;
1002 /* we handle our own DMA, ignore what kernel says about it */
1003 if (reg
& RXCFG_MXDMA
) ;
1005 //also, we currently don't care about fill/drain thresholds
1006 //though this may change in the future with more realistic
1007 //networks or a driver which changes it according to feedback
1008 if (reg
& (RXCFG_DRTH
| RXCFG_DRTH0
)) ;
1013 /* there is no priority queueing used in the linux 2.6 driver */
1018 /* not going to implement wake on LAN */
1023 /* not going to implement pause control */
1030 rxFilterEnable
= (reg
& RFCR_RFEN
) ? true : false;
1031 acceptBroadcast
= (reg
& RFCR_AAB
) ? true : false;
1032 acceptMulticast
= (reg
& RFCR_AAM
) ? true : false;
1033 acceptUnicast
= (reg
& RFCR_AAU
) ? true : false;
1034 acceptPerfect
= (reg
& RFCR_APM
) ? true : false;
1035 acceptArp
= (reg
& RFCR_AARP
) ? true : false;
1038 if (reg
& RFCR_APAT
)
1039 panic("RFCR_APAT not implemented!\n");
1042 if (reg
& RFCR_MHEN
|| reg
& RFCR_UHEN
)
1043 panic("hash filtering not implemented!\n");
1046 panic("RFCR_ULM not implemented!\n");
1051 panic("the driver never writes to RFDR, something is wrong!\n");
1054 panic("the driver never uses BRAR, something is wrong!\n");
1057 panic("the driver never uses BRDR, something is wrong!\n");
1060 panic("SRR is read only register!\n");
1063 panic("the driver never uses MIBC, something is wrong!\n");
1074 panic("the driver never uses VDR, something is wrong!\n");
1078 /* not going to implement clockrun stuff */
1084 if (reg
& TBICR_MR_LOOPBACK
)
1085 panic("TBICR_MR_LOOPBACK never used, something wrong!\n");
1087 if (reg
& TBICR_MR_AN_ENABLE
) {
1088 regs
.tanlpar
= regs
.tanar
;
1089 regs
.tbisr
|= (TBISR_MR_AN_COMPLETE
| TBISR_MR_LINK_STATUS
);
1093 if (reg
& TBICR_MR_RESTART_AN
) ;
1099 panic("TBISR is read only register!\n");
1103 if (reg
& TANAR_PS2
)
1104 panic("this isn't used in driver, something wrong!\n");
1106 if (reg
& TANAR_PS1
)
1107 panic("this isn't used in driver, something wrong!\n");
1111 panic("this should only be written to by the fake phy!\n");
1114 panic("TANER is read only register!\n");
1121 panic("invalid register access daddr=%#x", daddr
);
1124 panic("Invalid Request Size");
1131 NSGigE::devIntrPost(uint32_t interrupts
)
1133 if (interrupts
& ISR_RESERVE
)
1134 panic("Cannot set a reserved interrupt");
1136 if (interrupts
& ISR_NOIMPL
)
1137 warn("interrupt not implemented %#x\n", interrupts
);
1139 interrupts
&= ~ISR_NOIMPL
;
1140 regs
.isr
|= interrupts
;
1142 if (interrupts
& regs
.imr
) {
1143 if (interrupts
& ISR_SWI
) {
1146 if (interrupts
& ISR_RXIDLE
) {
1149 if (interrupts
& ISR_RXOK
) {
1152 if (interrupts
& ISR_RXDESC
) {
1155 if (interrupts
& ISR_TXOK
) {
1158 if (interrupts
& ISR_TXIDLE
) {
1161 if (interrupts
& ISR_TXDESC
) {
1164 if (interrupts
& ISR_RXORN
) {
1169 DPRINTF(EthernetIntr
,
1170 "interrupt written to ISR: intr=%#x isr=%#x imr=%#x\n",
1171 interrupts
, regs
.isr
, regs
.imr
);
1173 if ((regs
.isr
& regs
.imr
)) {
1174 Tick when
= curTick
;
1175 if (!(regs
.isr
& regs
.imr
& ISR_NODELAY
))
1181 /* writing this interrupt counting stats inside this means that this function
1182 is now limited to being used to clear all interrupts upon the kernel
1183 reading isr and servicing. just telling you in case you were thinking
1187 NSGigE::devIntrClear(uint32_t interrupts
)
1189 if (interrupts
& ISR_RESERVE
)
1190 panic("Cannot clear a reserved interrupt");
1192 if (regs
.isr
& regs
.imr
& ISR_SWI
) {
1195 if (regs
.isr
& regs
.imr
& ISR_RXIDLE
) {
1198 if (regs
.isr
& regs
.imr
& ISR_RXOK
) {
1201 if (regs
.isr
& regs
.imr
& ISR_RXDESC
) {
1204 if (regs
.isr
& regs
.imr
& ISR_TXOK
) {
1207 if (regs
.isr
& regs
.imr
& ISR_TXIDLE
) {
1210 if (regs
.isr
& regs
.imr
& ISR_TXDESC
) {
1213 if (regs
.isr
& regs
.imr
& ISR_RXORN
) {
1217 if (regs
.isr
& regs
.imr
& (ISR_SWI
| ISR_RXIDLE
| ISR_RXOK
| ISR_RXDESC
|
1218 ISR_TXOK
| ISR_TXIDLE
| ISR_TXDESC
| ISR_RXORN
) )
1221 interrupts
&= ~ISR_NOIMPL
;
1222 regs
.isr
&= ~interrupts
;
1224 DPRINTF(EthernetIntr
,
1225 "interrupt cleared from ISR: intr=%x isr=%x imr=%x\n",
1226 interrupts
, regs
.isr
, regs
.imr
);
1228 if (!(regs
.isr
& regs
.imr
))
1233 NSGigE::devIntrChangeMask()
1235 DPRINTF(EthernetIntr
, "interrupt mask changed: isr=%x imr=%x masked=%x\n",
1236 regs
.isr
, regs
.imr
, regs
.isr
& regs
.imr
);
1238 if (regs
.isr
& regs
.imr
)
1239 cpuIntrPost(curTick
);
1245 NSGigE::cpuIntrPost(Tick when
)
1247 // If the interrupt you want to post is later than an interrupt
1248 // already scheduled, just let it post in the coming one and don't
1249 // schedule another.
1250 // HOWEVER, must be sure that the scheduled intrTick is in the
1251 // future (this was formerly the source of a bug)
1253 * @todo this warning should be removed and the intrTick code should
1256 assert(when
>= curTick
);
1257 assert(intrTick
>= curTick
|| intrTick
== 0);
1258 if (when
> intrTick
&& intrTick
!= 0) {
1259 DPRINTF(EthernetIntr
, "don't need to schedule event...intrTick=%d\n",
1265 if (intrTick
< curTick
) {
1270 DPRINTF(EthernetIntr
, "going to schedule an interrupt for intrTick=%d\n",
1274 intrEvent
->squash();
1275 intrEvent
= new IntrEvent(this, true);
1276 intrEvent
->schedule(intrTick
);
1280 NSGigE::cpuInterrupt()
1282 assert(intrTick
== curTick
);
1284 // Whether or not there's a pending interrupt, we don't care about
1289 // Don't send an interrupt if there's already one
1290 if (cpuPendingIntr
) {
1291 DPRINTF(EthernetIntr
,
1292 "would send an interrupt now, but there's already pending\n");
1295 cpuPendingIntr
= true;
1297 DPRINTF(EthernetIntr
, "posting interrupt\n");
1303 NSGigE::cpuIntrClear()
1305 if (!cpuPendingIntr
)
1309 intrEvent
->squash();
1315 cpuPendingIntr
= false;
1317 DPRINTF(EthernetIntr
, "clearing interrupt\n");
1322 NSGigE::cpuIntrPending() const
1323 { return cpuPendingIntr
; }
1329 DPRINTF(Ethernet
, "transmit reset\n");
1334 assert(txDescCnt
== 0);
1337 assert(txDmaState
== dmaIdle
);
1343 DPRINTF(Ethernet
, "receive reset\n");
1346 assert(rxPktBytes
== 0);
1349 assert(rxDescCnt
== 0);
1350 assert(rxDmaState
== dmaIdle
);
1358 memset(®s
, 0, sizeof(regs
));
1359 regs
.config
= CFG_LNKSTS
;
1360 regs
.mear
= MEAR_MDDIR
| MEAR_EEDO
;
1361 regs
.txcfg
= 0x120; // set drain threshold to 1024 bytes and
1362 // fill threshold to 32 bytes
1363 regs
.rxcfg
= 0x4; // set drain threshold to 16 bytes
1364 regs
.srr
= 0x0103; // set the silicon revision to rev B or 0x103
1365 regs
.mibc
= MIBC_FRZ
;
1366 regs
.vdr
= 0x81; // set the vlan tag type to 802.1q
1367 regs
.tesr
= 0xc000; // TBI capable of both full and half duplex
1369 extstsEnable
= false;
1370 acceptBroadcast
= false;
1371 acceptMulticast
= false;
1372 acceptUnicast
= false;
1373 acceptPerfect
= false;
1378 NSGigE::rxDmaReadCopy()
1380 assert(rxDmaState
== dmaReading
);
1382 physmem
->dma_read((uint8_t *)rxDmaData
, rxDmaAddr
, rxDmaLen
);
1383 rxDmaState
= dmaIdle
;
1385 DPRINTF(EthernetDMA
, "rx dma read paddr=%#x len=%d\n",
1386 rxDmaAddr
, rxDmaLen
);
1387 DDUMP(EthernetDMA
, rxDmaData
, rxDmaLen
);
1391 NSGigE::doRxDmaRead()
1393 assert(rxDmaState
== dmaIdle
|| rxDmaState
== dmaReadWaiting
);
1394 rxDmaState
= dmaReading
;
1396 if (dmaInterface
&& !rxDmaFree
) {
1397 if (dmaInterface
->busy())
1398 rxDmaState
= dmaReadWaiting
;
1400 dmaInterface
->doDMA(Read
, rxDmaAddr
, rxDmaLen
, curTick
,
1401 &rxDmaReadEvent
, true);
1405 if (dmaReadDelay
== 0 && dmaReadFactor
== 0) {
1410 Tick factor
= ((rxDmaLen
+ ULL(63)) >> ULL(6)) * dmaReadFactor
;
1411 Tick start
= curTick
+ dmaReadDelay
+ factor
;
1412 rxDmaReadEvent
.schedule(start
);
1417 NSGigE::rxDmaReadDone()
1419 assert(rxDmaState
== dmaReading
);
1422 // If the transmit state machine has a pending DMA, let it go first
1423 if (txDmaState
== dmaReadWaiting
|| txDmaState
== dmaWriteWaiting
)
1430 NSGigE::rxDmaWriteCopy()
1432 assert(rxDmaState
== dmaWriting
);
1434 physmem
->dma_write(rxDmaAddr
, (uint8_t *)rxDmaData
, rxDmaLen
);
1435 rxDmaState
= dmaIdle
;
1437 DPRINTF(EthernetDMA
, "rx dma write paddr=%#x len=%d\n",
1438 rxDmaAddr
, rxDmaLen
);
1439 DDUMP(EthernetDMA
, rxDmaData
, rxDmaLen
);
1443 NSGigE::doRxDmaWrite()
1445 assert(rxDmaState
== dmaIdle
|| rxDmaState
== dmaWriteWaiting
);
1446 rxDmaState
= dmaWriting
;
1448 if (dmaInterface
&& !rxDmaFree
) {
1449 if (dmaInterface
->busy())
1450 rxDmaState
= dmaWriteWaiting
;
1452 dmaInterface
->doDMA(WriteInvalidate
, rxDmaAddr
, rxDmaLen
, curTick
,
1453 &rxDmaWriteEvent
, true);
1457 if (dmaWriteDelay
== 0 && dmaWriteFactor
== 0) {
1462 Tick factor
= ((rxDmaLen
+ ULL(63)) >> ULL(6)) * dmaWriteFactor
;
1463 Tick start
= curTick
+ dmaWriteDelay
+ factor
;
1464 rxDmaWriteEvent
.schedule(start
);
1469 NSGigE::rxDmaWriteDone()
1471 assert(rxDmaState
== dmaWriting
);
1474 // If the transmit state machine has a pending DMA, let it go first
1475 if (txDmaState
== dmaReadWaiting
|| txDmaState
== dmaWriteWaiting
)
1484 DPRINTF(EthernetSM
, "receive kick rxState=%s (rxBuf.size=%d)\n",
1485 NsRxStateStrings
[rxState
], rxFifo
.size());
1487 if (rxKickTick
> curTick
) {
1488 DPRINTF(EthernetSM
, "receive kick exiting, can't run till %d\n",
1494 switch(rxDmaState
) {
1495 case dmaReadWaiting
:
1499 case dmaWriteWaiting
:
1507 // see state machine from spec for details
1508 // the way this works is, if you finish work on one state and can
1509 // go directly to another, you do that through jumping to the
1510 // label "next". however, if you have intermediate work, like DMA
1511 // so that you can't go to the next state yet, you go to exit and
1512 // exit the loop. however, when the DMA is done it will trigger
1513 // an event and come back to this loop.
1517 DPRINTF(EthernetSM
, "Receive Disabled! Nothing to do.\n");
1522 rxState
= rxDescRefr
;
1524 rxDmaAddr
= regs
.rxdp
& 0x3fffffff;
1525 rxDmaData
= &rxDescCache
+ offsetof(ns_desc
, link
);
1526 rxDmaLen
= sizeof(rxDescCache
.link
);
1527 rxDmaFree
= dmaDescFree
;
1530 descDmaRdBytes
+= rxDmaLen
;
1535 rxState
= rxDescRead
;
1537 rxDmaAddr
= regs
.rxdp
& 0x3fffffff;
1538 rxDmaData
= &rxDescCache
;
1539 rxDmaLen
= sizeof(ns_desc
);
1540 rxDmaFree
= dmaDescFree
;
1543 descDmaRdBytes
+= rxDmaLen
;
1551 if (rxDmaState
!= dmaIdle
)
1554 rxState
= rxAdvance
;
1558 if (rxDmaState
!= dmaIdle
)
1561 DPRINTF(EthernetDesc
,
1562 "rxDescCache: addr=%08x read descriptor\n",
1563 regs
.rxdp
& 0x3fffffff);
1564 DPRINTF(EthernetDesc
,
1565 "rxDescCache: link=%08x bufptr=%08x cmdsts=%08x extsts=%08x\n",
1566 rxDescCache
.link
, rxDescCache
.bufptr
, rxDescCache
.cmdsts
,
1567 rxDescCache
.extsts
);
1569 if (rxDescCache
.cmdsts
& CMDSTS_OWN
) {
1570 devIntrPost(ISR_RXIDLE
);
1574 rxState
= rxFifoBlock
;
1575 rxFragPtr
= rxDescCache
.bufptr
;
1576 rxDescCnt
= rxDescCache
.cmdsts
& CMDSTS_LEN_MASK
;
1583 * @todo in reality, we should be able to start processing
1584 * the packet as it arrives, and not have to wait for the
1585 * full packet ot be in the receive fifo.
1590 DPRINTF(EthernetSM
, "****processing receive of new packet****\n");
1592 // If we don't have a packet, grab a new one from the fifo.
1593 rxPacket
= rxFifo
.front();
1594 rxPktBytes
= rxPacket
->length
;
1595 rxPacketBufPtr
= rxPacket
->data
;
1598 if (DTRACE(Ethernet
)) {
1601 DPRINTF(Ethernet
, "ID is %d\n", ip
->id());
1605 "Src Port=%d, Dest Port=%d, Seq=%d, Ack=%d\n",
1606 tcp
->sport(), tcp
->dport(), tcp
->seq(),
1613 // sanity check - i think the driver behaves like this
1614 assert(rxDescCnt
>= rxPktBytes
);
1619 // dont' need the && rxDescCnt > 0 if driver sanity check
1621 if (rxPktBytes
> 0) {
1622 rxState
= rxFragWrite
;
1623 // don't need min<>(rxPktBytes,rxDescCnt) if above sanity
1625 rxXferLen
= rxPktBytes
;
1627 rxDmaAddr
= rxFragPtr
& 0x3fffffff;
1628 rxDmaData
= rxPacketBufPtr
;
1629 rxDmaLen
= rxXferLen
;
1630 rxDmaFree
= dmaDataFree
;
1636 rxState
= rxDescWrite
;
1638 //if (rxPktBytes == 0) { /* packet is done */
1639 assert(rxPktBytes
== 0);
1640 DPRINTF(EthernetSM
, "done with receiving packet\n");
1642 rxDescCache
.cmdsts
|= CMDSTS_OWN
;
1643 rxDescCache
.cmdsts
&= ~CMDSTS_MORE
;
1644 rxDescCache
.cmdsts
|= CMDSTS_OK
;
1645 rxDescCache
.cmdsts
&= 0xffff0000;
1646 rxDescCache
.cmdsts
+= rxPacket
->length
; //i.e. set CMDSTS_SIZE
1650 * all the driver uses these are for its own stats keeping
1651 * which we don't care about, aren't necessary for
1652 * functionality and doing this would just slow us down.
1653 * if they end up using this in a later version for
1654 * functional purposes, just undef
1656 if (rxFilterEnable
) {
1657 rxDescCache
.cmdsts
&= ~CMDSTS_DEST_MASK
;
1658 const EthAddr
&dst
= rxFifoFront()->dst();
1660 rxDescCache
.cmdsts
|= CMDSTS_DEST_SELF
;
1661 if (dst
->multicast())
1662 rxDescCache
.cmdsts
|= CMDSTS_DEST_MULTI
;
1663 if (dst
->broadcast())
1664 rxDescCache
.cmdsts
|= CMDSTS_DEST_MASK
;
1669 if (extstsEnable
&& ip
) {
1670 rxDescCache
.extsts
|= EXTSTS_IPPKT
;
1672 if (cksum(ip
) != 0) {
1673 DPRINTF(EthernetCksum
, "Rx IP Checksum Error\n");
1674 rxDescCache
.extsts
|= EXTSTS_IPERR
;
1679 rxDescCache
.extsts
|= EXTSTS_TCPPKT
;
1681 if (cksum(tcp
) != 0) {
1682 DPRINTF(EthernetCksum
, "Rx TCP Checksum Error\n");
1683 rxDescCache
.extsts
|= EXTSTS_TCPERR
;
1687 rxDescCache
.extsts
|= EXTSTS_UDPPKT
;
1689 if (cksum(udp
) != 0) {
1690 DPRINTF(EthernetCksum
, "Rx UDP Checksum Error\n");
1691 rxDescCache
.extsts
|= EXTSTS_UDPERR
;
1698 * the driver seems to always receive into desc buffers
1699 * of size 1514, so you never have a pkt that is split
1700 * into multiple descriptors on the receive side, so
1701 * i don't implement that case, hence the assert above.
1704 DPRINTF(EthernetDesc
,
1705 "rxDescCache: addr=%08x writeback cmdsts extsts\n",
1706 regs
.rxdp
& 0x3fffffff);
1707 DPRINTF(EthernetDesc
,
1708 "rxDescCache: link=%08x bufptr=%08x cmdsts=%08x extsts=%08x\n",
1709 rxDescCache
.link
, rxDescCache
.bufptr
, rxDescCache
.cmdsts
,
1710 rxDescCache
.extsts
);
1712 rxDmaAddr
= (regs
.rxdp
+ offsetof(ns_desc
, cmdsts
)) & 0x3fffffff;
1713 rxDmaData
= &(rxDescCache
.cmdsts
);
1714 rxDmaLen
= sizeof(rxDescCache
.cmdsts
) + sizeof(rxDescCache
.extsts
);
1715 rxDmaFree
= dmaDescFree
;
1718 descDmaWrBytes
+= rxDmaLen
;
1726 if (rxDmaState
!= dmaIdle
)
1729 rxPacketBufPtr
+= rxXferLen
;
1730 rxFragPtr
+= rxXferLen
;
1731 rxPktBytes
-= rxXferLen
;
1733 rxState
= rxFifoBlock
;
1737 if (rxDmaState
!= dmaIdle
)
1740 assert(rxDescCache
.cmdsts
& CMDSTS_OWN
);
1742 assert(rxPacket
== 0);
1743 devIntrPost(ISR_RXOK
);
1745 if (rxDescCache
.cmdsts
& CMDSTS_INTR
)
1746 devIntrPost(ISR_RXDESC
);
1749 DPRINTF(EthernetSM
, "Halting the RX state machine\n");
1753 rxState
= rxAdvance
;
1757 if (rxDescCache
.link
== 0) {
1758 devIntrPost(ISR_RXIDLE
);
1763 rxState
= rxDescRead
;
1764 regs
.rxdp
= rxDescCache
.link
;
1767 rxDmaAddr
= regs
.rxdp
& 0x3fffffff;
1768 rxDmaData
= &rxDescCache
;
1769 rxDmaLen
= sizeof(ns_desc
);
1770 rxDmaFree
= dmaDescFree
;
1778 panic("Invalid rxState!");
1781 DPRINTF(EthernetSM
, "entering next rxState=%s\n",
1782 NsRxStateStrings
[rxState
]);
1788 * @todo do we want to schedule a future kick?
1790 DPRINTF(EthernetSM
, "rx state machine exited rxState=%s\n",
1791 NsRxStateStrings
[rxState
]);
1797 if (txFifo
.empty()) {
1798 DPRINTF(Ethernet
, "nothing to transmit\n");
1802 DPRINTF(Ethernet
, "Attempt Pkt Transmit: txFifo length=%d\n",
1804 if (interface
->sendPacket(txFifo
.front())) {
1806 if (DTRACE(Ethernet
)) {
1807 IpPtr
ip(txFifo
.front());
1809 DPRINTF(Ethernet
, "ID is %d\n", ip
->id());
1813 "Src Port=%d, Dest Port=%d, Seq=%d, Ack=%d\n",
1814 tcp
->sport(), tcp
->dport(), tcp
->seq(), tcp
->ack());
1820 DDUMP(EthernetData
, txFifo
.front()->data
, txFifo
.front()->length
);
1821 txBytes
+= txFifo
.front()->length
;
1824 DPRINTF(Ethernet
, "Successful Xmit! now txFifoAvail is %d\n",
1829 * normally do a writeback of the descriptor here, and ONLY
1830 * after that is done, send this interrupt. but since our
1831 * stuff never actually fails, just do this interrupt here,
1832 * otherwise the code has to stray from this nice format.
1833 * besides, it's functionally the same.
1835 devIntrPost(ISR_TXOK
);
1838 if (!txFifo
.empty() && !txEvent
.scheduled()) {
1839 DPRINTF(Ethernet
, "reschedule transmit\n");
1840 txEvent
.schedule(curTick
+ retryTime
);
1845 NSGigE::txDmaReadCopy()
1847 assert(txDmaState
== dmaReading
);
1849 physmem
->dma_read((uint8_t *)txDmaData
, txDmaAddr
, txDmaLen
);
1850 txDmaState
= dmaIdle
;
1852 DPRINTF(EthernetDMA
, "tx dma read paddr=%#x len=%d\n",
1853 txDmaAddr
, txDmaLen
);
1854 DDUMP(EthernetDMA
, txDmaData
, txDmaLen
);
1858 NSGigE::doTxDmaRead()
1860 assert(txDmaState
== dmaIdle
|| txDmaState
== dmaReadWaiting
);
1861 txDmaState
= dmaReading
;
1863 if (dmaInterface
&& !txDmaFree
) {
1864 if (dmaInterface
->busy())
1865 txDmaState
= dmaReadWaiting
;
1867 dmaInterface
->doDMA(Read
, txDmaAddr
, txDmaLen
, curTick
,
1868 &txDmaReadEvent
, true);
1872 if (dmaReadDelay
== 0 && dmaReadFactor
== 0.0) {
1877 Tick factor
= ((txDmaLen
+ ULL(63)) >> ULL(6)) * dmaReadFactor
;
1878 Tick start
= curTick
+ dmaReadDelay
+ factor
;
1879 txDmaReadEvent
.schedule(start
);
1884 NSGigE::txDmaReadDone()
1886 assert(txDmaState
== dmaReading
);
1889 // If the receive state machine has a pending DMA, let it go first
1890 if (rxDmaState
== dmaReadWaiting
|| rxDmaState
== dmaWriteWaiting
)
1897 NSGigE::txDmaWriteCopy()
1899 assert(txDmaState
== dmaWriting
);
1901 physmem
->dma_write(txDmaAddr
, (uint8_t *)txDmaData
, txDmaLen
);
1902 txDmaState
= dmaIdle
;
1904 DPRINTF(EthernetDMA
, "tx dma write paddr=%#x len=%d\n",
1905 txDmaAddr
, txDmaLen
);
1906 DDUMP(EthernetDMA
, txDmaData
, txDmaLen
);
1910 NSGigE::doTxDmaWrite()
1912 assert(txDmaState
== dmaIdle
|| txDmaState
== dmaWriteWaiting
);
1913 txDmaState
= dmaWriting
;
1915 if (dmaInterface
&& !txDmaFree
) {
1916 if (dmaInterface
->busy())
1917 txDmaState
= dmaWriteWaiting
;
1919 dmaInterface
->doDMA(WriteInvalidate
, txDmaAddr
, txDmaLen
, curTick
,
1920 &txDmaWriteEvent
, true);
1924 if (dmaWriteDelay
== 0 && dmaWriteFactor
== 0.0) {
1929 Tick factor
= ((txDmaLen
+ ULL(63)) >> ULL(6)) * dmaWriteFactor
;
1930 Tick start
= curTick
+ dmaWriteDelay
+ factor
;
1931 txDmaWriteEvent
.schedule(start
);
1936 NSGigE::txDmaWriteDone()
1938 assert(txDmaState
== dmaWriting
);
1941 // If the receive state machine has a pending DMA, let it go first
1942 if (rxDmaState
== dmaReadWaiting
|| rxDmaState
== dmaWriteWaiting
)
1951 DPRINTF(EthernetSM
, "transmit kick txState=%s\n",
1952 NsTxStateStrings
[txState
]);
1954 if (txKickTick
> curTick
) {
1955 DPRINTF(EthernetSM
, "transmit kick exiting, can't run till %d\n",
1962 switch(txDmaState
) {
1963 case dmaReadWaiting
:
1967 case dmaWriteWaiting
:
1978 DPRINTF(EthernetSM
, "Transmit disabled. Nothing to do.\n");
1983 txState
= txDescRefr
;
1985 txDmaAddr
= regs
.txdp
& 0x3fffffff;
1986 txDmaData
= &txDescCache
+ offsetof(ns_desc
, link
);
1987 txDmaLen
= sizeof(txDescCache
.link
);
1988 txDmaFree
= dmaDescFree
;
1991 descDmaRdBytes
+= txDmaLen
;
1997 txState
= txDescRead
;
1999 txDmaAddr
= regs
.txdp
& 0x3fffffff;
2000 txDmaData
= &txDescCache
;
2001 txDmaLen
= sizeof(ns_desc
);
2002 txDmaFree
= dmaDescFree
;
2005 descDmaRdBytes
+= txDmaLen
;
2013 if (txDmaState
!= dmaIdle
)
2016 txState
= txAdvance
;
2020 if (txDmaState
!= dmaIdle
)
2023 DPRINTF(EthernetDesc
,
2024 "txDescCache: link=%08x bufptr=%08x cmdsts=%08x extsts=%08x\n",
2025 txDescCache
.link
, txDescCache
.bufptr
, txDescCache
.cmdsts
,
2026 txDescCache
.extsts
);
2028 if (txDescCache
.cmdsts
& CMDSTS_OWN
) {
2029 txState
= txFifoBlock
;
2030 txFragPtr
= txDescCache
.bufptr
;
2031 txDescCnt
= txDescCache
.cmdsts
& CMDSTS_LEN_MASK
;
2033 devIntrPost(ISR_TXIDLE
);
2041 DPRINTF(EthernetSM
, "****starting the tx of a new packet****\n");
2042 txPacket
= new PacketData(16384);
2043 txPacketBufPtr
= txPacket
->data
;
2046 if (txDescCnt
== 0) {
2047 DPRINTF(EthernetSM
, "the txDescCnt == 0, done with descriptor\n");
2048 if (txDescCache
.cmdsts
& CMDSTS_MORE
) {
2049 DPRINTF(EthernetSM
, "there are more descriptors to come\n");
2050 txState
= txDescWrite
;
2052 txDescCache
.cmdsts
&= ~CMDSTS_OWN
;
2054 txDmaAddr
= regs
.txdp
+ offsetof(ns_desc
, cmdsts
);
2055 txDmaAddr
&= 0x3fffffff;
2056 txDmaData
= &(txDescCache
.cmdsts
);
2057 txDmaLen
= sizeof(txDescCache
.cmdsts
);
2058 txDmaFree
= dmaDescFree
;
2063 } else { /* this packet is totally done */
2064 DPRINTF(EthernetSM
, "This packet is done, let's wrap it up\n");
2065 /* deal with the the packet that just finished */
2066 if ((regs
.vtcr
& VTCR_PPCHK
) && extstsEnable
) {
2068 if (txDescCache
.extsts
& EXTSTS_UDPPKT
) {
2071 udp
->sum(cksum(udp
));
2073 } else if (txDescCache
.extsts
& EXTSTS_TCPPKT
) {
2076 tcp
->sum(cksum(tcp
));
2079 if (txDescCache
.extsts
& EXTSTS_IPPKT
) {
2086 txPacket
->length
= txPacketBufPtr
- txPacket
->data
;
2087 // this is just because the receive can't handle a
2088 // packet bigger want to make sure
2089 assert(txPacket
->length
<= 1514);
2093 txFifo
.push(txPacket
);
2097 * this following section is not tqo spec, but
2098 * functionally shouldn't be any different. normally,
2099 * the chip will wait til the transmit has occurred
2100 * before writing back the descriptor because it has
2101 * to wait to see that it was successfully transmitted
2102 * to decide whether to set CMDSTS_OK or not.
2103 * however, in the simulator since it is always
2104 * successfully transmitted, and writing it exactly to
2105 * spec would complicate the code, we just do it here
2108 txDescCache
.cmdsts
&= ~CMDSTS_OWN
;
2109 txDescCache
.cmdsts
|= CMDSTS_OK
;
2111 DPRINTF(EthernetDesc
,
2112 "txDesc writeback: cmdsts=%08x extsts=%08x\n",
2113 txDescCache
.cmdsts
, txDescCache
.extsts
);
2115 txDmaAddr
= regs
.txdp
+ offsetof(ns_desc
, cmdsts
);
2116 txDmaAddr
&= 0x3fffffff;
2117 txDmaData
= &(txDescCache
.cmdsts
);
2118 txDmaLen
= sizeof(txDescCache
.cmdsts
) +
2119 sizeof(txDescCache
.extsts
);
2120 txDmaFree
= dmaDescFree
;
2123 descDmaWrBytes
+= txDmaLen
;
2129 DPRINTF(EthernetSM
, "halting TX state machine\n");
2133 txState
= txAdvance
;
2139 DPRINTF(EthernetSM
, "this descriptor isn't done yet\n");
2140 if (!txFifo
.full()) {
2141 txState
= txFragRead
;
2144 * The number of bytes transferred is either whatever
2145 * is left in the descriptor (txDescCnt), or if there
2146 * is not enough room in the fifo, just whatever room
2147 * is left in the fifo
2149 txXferLen
= min
<uint32_t>(txDescCnt
, txFifo
.avail());
2151 txDmaAddr
= txFragPtr
& 0x3fffffff;
2152 txDmaData
= txPacketBufPtr
;
2153 txDmaLen
= txXferLen
;
2154 txDmaFree
= dmaDataFree
;
2159 txState
= txFifoBlock
;
2169 if (txDmaState
!= dmaIdle
)
2172 txPacketBufPtr
+= txXferLen
;
2173 txFragPtr
+= txXferLen
;
2174 txDescCnt
-= txXferLen
;
2175 txFifo
.reserve(txXferLen
);
2177 txState
= txFifoBlock
;
2181 if (txDmaState
!= dmaIdle
)
2184 if (txDescCache
.cmdsts
& CMDSTS_INTR
)
2185 devIntrPost(ISR_TXDESC
);
2187 txState
= txAdvance
;
2191 if (txDescCache
.link
== 0) {
2192 devIntrPost(ISR_TXIDLE
);
2196 txState
= txDescRead
;
2197 regs
.txdp
= txDescCache
.link
;
2200 txDmaAddr
= txDescCache
.link
& 0x3fffffff;
2201 txDmaData
= &txDescCache
;
2202 txDmaLen
= sizeof(ns_desc
);
2203 txDmaFree
= dmaDescFree
;
2211 panic("invalid state");
2214 DPRINTF(EthernetSM
, "entering next txState=%s\n",
2215 NsTxStateStrings
[txState
]);
2221 * @todo do we want to schedule a future kick?
2223 DPRINTF(EthernetSM
, "tx state machine exited txState=%s\n",
2224 NsTxStateStrings
[txState
]);
2228 NSGigE::transferDone()
2230 if (txFifo
.empty()) {
2231 DPRINTF(Ethernet
, "transfer complete: txFifo empty...nothing to do\n");
2235 DPRINTF(Ethernet
, "transfer complete: data in txFifo...schedule xmit\n");
2237 if (txEvent
.scheduled())
2238 txEvent
.reschedule(curTick
+ cycles(1));
2240 txEvent
.schedule(curTick
+ cycles(1));
2244 NSGigE::rxFilter(const PacketPtr
&packet
)
2246 EthPtr eth
= packet
;
2250 const EthAddr
&dst
= eth
->dst();
2251 if (dst
.unicast()) {
2252 // If we're accepting all unicast addresses
2256 // If we make a perfect match
2257 if (acceptPerfect
&& dst
== rom
.perfectMatch
)
2260 if (acceptArp
&& eth
->type() == ETH_TYPE_ARP
)
2263 } else if (dst
.broadcast()) {
2264 // if we're accepting broadcasts
2265 if (acceptBroadcast
)
2268 } else if (dst
.multicast()) {
2269 // if we're accepting all multicasts
2270 if (acceptMulticast
)
2276 DPRINTF(Ethernet
, "rxFilter drop\n");
2277 DDUMP(EthernetData
, packet
->data
, packet
->length
);
2284 NSGigE::recvPacket(PacketPtr packet
)
2286 rxBytes
+= packet
->length
;
2289 DPRINTF(Ethernet
, "Receiving packet from wire, rxFifoAvail=%d\n",
2293 DPRINTF(Ethernet
, "receive disabled...packet dropped\n");
2295 interface
->recvDone();
2299 if (rxFilterEnable
&& rxFilter(packet
)) {
2300 DPRINTF(Ethernet
, "packet filtered...dropped\n");
2301 interface
->recvDone();
2305 if (rxFifo
.avail() < packet
->length
) {
2311 "packet won't fit in receive buffer...pkt ID %d dropped\n",
2314 DPRINTF(Ethernet
, "Seq=%d\n", tcp
->seq());
2319 devIntrPost(ISR_RXORN
);
2323 rxFifo
.push(packet
);
2324 interface
->recvDone();
2330 //=====================================================================
2334 NSGigE::serialize(ostream
&os
)
2336 // Serialize the PciDev base class
2337 PciDev::serialize(os
);
2340 * Finalize any DMA events now.
2342 if (rxDmaReadEvent
.scheduled())
2344 if (rxDmaWriteEvent
.scheduled())
2346 if (txDmaReadEvent
.scheduled())
2348 if (txDmaWriteEvent
.scheduled())
2352 * Serialize the device registers
2354 SERIALIZE_SCALAR(regs
.command
);
2355 SERIALIZE_SCALAR(regs
.config
);
2356 SERIALIZE_SCALAR(regs
.mear
);
2357 SERIALIZE_SCALAR(regs
.ptscr
);
2358 SERIALIZE_SCALAR(regs
.isr
);
2359 SERIALIZE_SCALAR(regs
.imr
);
2360 SERIALIZE_SCALAR(regs
.ier
);
2361 SERIALIZE_SCALAR(regs
.ihr
);
2362 SERIALIZE_SCALAR(regs
.txdp
);
2363 SERIALIZE_SCALAR(regs
.txdp_hi
);
2364 SERIALIZE_SCALAR(regs
.txcfg
);
2365 SERIALIZE_SCALAR(regs
.gpior
);
2366 SERIALIZE_SCALAR(regs
.rxdp
);
2367 SERIALIZE_SCALAR(regs
.rxdp_hi
);
2368 SERIALIZE_SCALAR(regs
.rxcfg
);
2369 SERIALIZE_SCALAR(regs
.pqcr
);
2370 SERIALIZE_SCALAR(regs
.wcsr
);
2371 SERIALIZE_SCALAR(regs
.pcr
);
2372 SERIALIZE_SCALAR(regs
.rfcr
);
2373 SERIALIZE_SCALAR(regs
.rfdr
);
2374 SERIALIZE_SCALAR(regs
.srr
);
2375 SERIALIZE_SCALAR(regs
.mibc
);
2376 SERIALIZE_SCALAR(regs
.vrcr
);
2377 SERIALIZE_SCALAR(regs
.vtcr
);
2378 SERIALIZE_SCALAR(regs
.vdr
);
2379 SERIALIZE_SCALAR(regs
.ccsr
);
2380 SERIALIZE_SCALAR(regs
.tbicr
);
2381 SERIALIZE_SCALAR(regs
.tbisr
);
2382 SERIALIZE_SCALAR(regs
.tanar
);
2383 SERIALIZE_SCALAR(regs
.tanlpar
);
2384 SERIALIZE_SCALAR(regs
.taner
);
2385 SERIALIZE_SCALAR(regs
.tesr
);
2387 SERIALIZE_ARRAY(rom
.perfectMatch
, ETH_ADDR_LEN
);
2389 SERIALIZE_SCALAR(ioEnable
);
2392 * Serialize the data Fifos
2394 rxFifo
.serialize("rxFifo", os
);
2395 txFifo
.serialize("txFifo", os
);
2398 * Serialize the various helper variables
2400 bool txPacketExists
= txPacket
;
2401 SERIALIZE_SCALAR(txPacketExists
);
2402 if (txPacketExists
) {
2403 txPacket
->length
= txPacketBufPtr
- txPacket
->data
;
2404 txPacket
->serialize("txPacket", os
);
2405 uint32_t txPktBufPtr
= (uint32_t) (txPacketBufPtr
- txPacket
->data
);
2406 SERIALIZE_SCALAR(txPktBufPtr
);
2409 bool rxPacketExists
= rxPacket
;
2410 SERIALIZE_SCALAR(rxPacketExists
);
2411 if (rxPacketExists
) {
2412 rxPacket
->serialize("rxPacket", os
);
2413 uint32_t rxPktBufPtr
= (uint32_t) (rxPacketBufPtr
- rxPacket
->data
);
2414 SERIALIZE_SCALAR(rxPktBufPtr
);
2417 SERIALIZE_SCALAR(txXferLen
);
2418 SERIALIZE_SCALAR(rxXferLen
);
2421 * Serialize DescCaches
2423 SERIALIZE_SCALAR(txDescCache
.link
);
2424 SERIALIZE_SCALAR(txDescCache
.bufptr
);
2425 SERIALIZE_SCALAR(txDescCache
.cmdsts
);
2426 SERIALIZE_SCALAR(txDescCache
.extsts
);
2427 SERIALIZE_SCALAR(rxDescCache
.link
);
2428 SERIALIZE_SCALAR(rxDescCache
.bufptr
);
2429 SERIALIZE_SCALAR(rxDescCache
.cmdsts
);
2430 SERIALIZE_SCALAR(rxDescCache
.extsts
);
2433 * Serialize tx state machine
2435 int txState
= this->txState
;
2436 SERIALIZE_SCALAR(txState
);
2437 SERIALIZE_SCALAR(txEnable
);
2438 SERIALIZE_SCALAR(CTDD
);
2439 SERIALIZE_SCALAR(txFragPtr
);
2440 SERIALIZE_SCALAR(txDescCnt
);
2441 int txDmaState
= this->txDmaState
;
2442 SERIALIZE_SCALAR(txDmaState
);
2445 * Serialize rx state machine
2447 int rxState
= this->rxState
;
2448 SERIALIZE_SCALAR(rxState
);
2449 SERIALIZE_SCALAR(rxEnable
);
2450 SERIALIZE_SCALAR(CRDD
);
2451 SERIALIZE_SCALAR(rxPktBytes
);
2452 SERIALIZE_SCALAR(rxFragPtr
);
2453 SERIALIZE_SCALAR(rxDescCnt
);
2454 int rxDmaState
= this->rxDmaState
;
2455 SERIALIZE_SCALAR(rxDmaState
);
2457 SERIALIZE_SCALAR(extstsEnable
);
2460 * If there's a pending transmit, store the time so we can
2461 * reschedule it later
2463 Tick transmitTick
= txEvent
.scheduled() ? txEvent
.when() - curTick
: 0;
2464 SERIALIZE_SCALAR(transmitTick
);
2467 * receive address filter settings
2469 SERIALIZE_SCALAR(rxFilterEnable
);
2470 SERIALIZE_SCALAR(acceptBroadcast
);
2471 SERIALIZE_SCALAR(acceptMulticast
);
2472 SERIALIZE_SCALAR(acceptUnicast
);
2473 SERIALIZE_SCALAR(acceptPerfect
);
2474 SERIALIZE_SCALAR(acceptArp
);
2477 * Keep track of pending interrupt status.
2479 SERIALIZE_SCALAR(intrTick
);
2480 SERIALIZE_SCALAR(cpuPendingIntr
);
2481 Tick intrEventTick
= 0;
2483 intrEventTick
= intrEvent
->when();
2484 SERIALIZE_SCALAR(intrEventTick
);
2489 NSGigE::unserialize(Checkpoint
*cp
, const std::string
§ion
)
2491 // Unserialize the PciDev base class
2492 PciDev::unserialize(cp
, section
);
2494 UNSERIALIZE_SCALAR(regs
.command
);
2495 UNSERIALIZE_SCALAR(regs
.config
);
2496 UNSERIALIZE_SCALAR(regs
.mear
);
2497 UNSERIALIZE_SCALAR(regs
.ptscr
);
2498 UNSERIALIZE_SCALAR(regs
.isr
);
2499 UNSERIALIZE_SCALAR(regs
.imr
);
2500 UNSERIALIZE_SCALAR(regs
.ier
);
2501 UNSERIALIZE_SCALAR(regs
.ihr
);
2502 UNSERIALIZE_SCALAR(regs
.txdp
);
2503 UNSERIALIZE_SCALAR(regs
.txdp_hi
);
2504 UNSERIALIZE_SCALAR(regs
.txcfg
);
2505 UNSERIALIZE_SCALAR(regs
.gpior
);
2506 UNSERIALIZE_SCALAR(regs
.rxdp
);
2507 UNSERIALIZE_SCALAR(regs
.rxdp_hi
);
2508 UNSERIALIZE_SCALAR(regs
.rxcfg
);
2509 UNSERIALIZE_SCALAR(regs
.pqcr
);
2510 UNSERIALIZE_SCALAR(regs
.wcsr
);
2511 UNSERIALIZE_SCALAR(regs
.pcr
);
2512 UNSERIALIZE_SCALAR(regs
.rfcr
);
2513 UNSERIALIZE_SCALAR(regs
.rfdr
);
2514 UNSERIALIZE_SCALAR(regs
.srr
);
2515 UNSERIALIZE_SCALAR(regs
.mibc
);
2516 UNSERIALIZE_SCALAR(regs
.vrcr
);
2517 UNSERIALIZE_SCALAR(regs
.vtcr
);
2518 UNSERIALIZE_SCALAR(regs
.vdr
);
2519 UNSERIALIZE_SCALAR(regs
.ccsr
);
2520 UNSERIALIZE_SCALAR(regs
.tbicr
);
2521 UNSERIALIZE_SCALAR(regs
.tbisr
);
2522 UNSERIALIZE_SCALAR(regs
.tanar
);
2523 UNSERIALIZE_SCALAR(regs
.tanlpar
);
2524 UNSERIALIZE_SCALAR(regs
.taner
);
2525 UNSERIALIZE_SCALAR(regs
.tesr
);
2527 UNSERIALIZE_ARRAY(rom
.perfectMatch
, ETH_ADDR_LEN
);
2529 UNSERIALIZE_SCALAR(ioEnable
);
2532 * unserialize the data fifos
2534 rxFifo
.unserialize("rxFifo", cp
, section
);
2535 txFifo
.unserialize("txFifo", cp
, section
);
2538 * unserialize the various helper variables
2540 bool txPacketExists
;
2541 UNSERIALIZE_SCALAR(txPacketExists
);
2542 if (txPacketExists
) {
2543 txPacket
= new PacketData(16384);
2544 txPacket
->unserialize("txPacket", cp
, section
);
2545 uint32_t txPktBufPtr
;
2546 UNSERIALIZE_SCALAR(txPktBufPtr
);
2547 txPacketBufPtr
= (uint8_t *) txPacket
->data
+ txPktBufPtr
;
2551 bool rxPacketExists
;
2552 UNSERIALIZE_SCALAR(rxPacketExists
);
2554 if (rxPacketExists
) {
2555 rxPacket
= new PacketData(16384);
2556 rxPacket
->unserialize("rxPacket", cp
, section
);
2557 uint32_t rxPktBufPtr
;
2558 UNSERIALIZE_SCALAR(rxPktBufPtr
);
2559 rxPacketBufPtr
= (uint8_t *) rxPacket
->data
+ rxPktBufPtr
;
2563 UNSERIALIZE_SCALAR(txXferLen
);
2564 UNSERIALIZE_SCALAR(rxXferLen
);
2567 * Unserialize DescCaches
2569 UNSERIALIZE_SCALAR(txDescCache
.link
);
2570 UNSERIALIZE_SCALAR(txDescCache
.bufptr
);
2571 UNSERIALIZE_SCALAR(txDescCache
.cmdsts
);
2572 UNSERIALIZE_SCALAR(txDescCache
.extsts
);
2573 UNSERIALIZE_SCALAR(rxDescCache
.link
);
2574 UNSERIALIZE_SCALAR(rxDescCache
.bufptr
);
2575 UNSERIALIZE_SCALAR(rxDescCache
.cmdsts
);
2576 UNSERIALIZE_SCALAR(rxDescCache
.extsts
);
2579 * unserialize tx state machine
2582 UNSERIALIZE_SCALAR(txState
);
2583 this->txState
= (TxState
) txState
;
2584 UNSERIALIZE_SCALAR(txEnable
);
2585 UNSERIALIZE_SCALAR(CTDD
);
2586 UNSERIALIZE_SCALAR(txFragPtr
);
2587 UNSERIALIZE_SCALAR(txDescCnt
);
2589 UNSERIALIZE_SCALAR(txDmaState
);
2590 this->txDmaState
= (DmaState
) txDmaState
;
2593 * unserialize rx state machine
2596 UNSERIALIZE_SCALAR(rxState
);
2597 this->rxState
= (RxState
) rxState
;
2598 UNSERIALIZE_SCALAR(rxEnable
);
2599 UNSERIALIZE_SCALAR(CRDD
);
2600 UNSERIALIZE_SCALAR(rxPktBytes
);
2601 UNSERIALIZE_SCALAR(rxFragPtr
);
2602 UNSERIALIZE_SCALAR(rxDescCnt
);
2604 UNSERIALIZE_SCALAR(rxDmaState
);
2605 this->rxDmaState
= (DmaState
) rxDmaState
;
2607 UNSERIALIZE_SCALAR(extstsEnable
);
2610 * If there's a pending transmit, reschedule it now
2613 UNSERIALIZE_SCALAR(transmitTick
);
2615 txEvent
.schedule(curTick
+ transmitTick
);
2618 * unserialize receive address filter settings
2620 UNSERIALIZE_SCALAR(rxFilterEnable
);
2621 UNSERIALIZE_SCALAR(acceptBroadcast
);
2622 UNSERIALIZE_SCALAR(acceptMulticast
);
2623 UNSERIALIZE_SCALAR(acceptUnicast
);
2624 UNSERIALIZE_SCALAR(acceptPerfect
);
2625 UNSERIALIZE_SCALAR(acceptArp
);
2628 * Keep track of pending interrupt status.
2630 UNSERIALIZE_SCALAR(intrTick
);
2631 UNSERIALIZE_SCALAR(cpuPendingIntr
);
2633 UNSERIALIZE_SCALAR(intrEventTick
);
2634 if (intrEventTick
) {
2635 intrEvent
= new IntrEvent(this, true);
2636 intrEvent
->schedule(intrEventTick
);
2640 * re-add addrRanges to bus bridges
2643 pioInterface
->addAddrRange(RangeSize(BARAddrs
[0], BARSize
[0]));
2644 pioInterface
->addAddrRange(RangeSize(BARAddrs
[1], BARSize
[1]));
2649 NSGigE::cacheAccess(MemReqPtr
&req
)
2651 DPRINTF(EthernetPIO
, "timing access to paddr=%#x (daddr=%#x)\n",
2652 req
->paddr
, req
->paddr
- addr
);
2653 return curTick
+ pioLatency
;
2656 BEGIN_DECLARE_SIM_OBJECT_PARAMS(NSGigEInt
)
2658 SimObjectParam
<EtherInt
*> peer
;
2659 SimObjectParam
<NSGigE
*> device
;
2661 END_DECLARE_SIM_OBJECT_PARAMS(NSGigEInt
)
2663 BEGIN_INIT_SIM_OBJECT_PARAMS(NSGigEInt
)
2665 INIT_PARAM_DFLT(peer
, "peer interface", NULL
),
2666 INIT_PARAM(device
, "Ethernet device of this interface")
2668 END_INIT_SIM_OBJECT_PARAMS(NSGigEInt
)
2670 CREATE_SIM_OBJECT(NSGigEInt
)
2672 NSGigEInt
*dev_int
= new NSGigEInt(getInstanceName(), device
);
2674 EtherInt
*p
= (EtherInt
*)peer
;
2676 dev_int
->setPeer(p
);
2677 p
->setPeer(dev_int
);
2683 REGISTER_SIM_OBJECT("NSGigEInt", NSGigEInt
)
2686 BEGIN_DECLARE_SIM_OBJECT_PARAMS(NSGigE
)
2689 Param
<Tick
> cycle_time
;
2690 Param
<Tick
> tx_delay
;
2691 Param
<Tick
> rx_delay
;
2692 Param
<Tick
> intr_delay
;
2693 SimObjectParam
<MemoryController
*> mmu
;
2694 SimObjectParam
<PhysicalMemory
*> physmem
;
2695 Param
<bool> rx_filter
;
2696 Param
<string
> hardware_address
;
2697 SimObjectParam
<Bus
*> io_bus
;
2698 SimObjectParam
<Bus
*> payload_bus
;
2699 SimObjectParam
<HierParams
*> hier
;
2700 Param
<Tick
> pio_latency
;
2701 Param
<bool> dma_desc_free
;
2702 Param
<bool> dma_data_free
;
2703 Param
<Tick
> dma_read_delay
;
2704 Param
<Tick
> dma_write_delay
;
2705 Param
<Tick
> dma_read_factor
;
2706 Param
<Tick
> dma_write_factor
;
2707 SimObjectParam
<PciConfigAll
*> configspace
;
2708 SimObjectParam
<PciConfigData
*> configdata
;
2709 SimObjectParam
<Platform
*> platform
;
2710 Param
<uint32_t> pci_bus
;
2711 Param
<uint32_t> pci_dev
;
2712 Param
<uint32_t> pci_func
;
2713 Param
<uint32_t> tx_fifo_size
;
2714 Param
<uint32_t> rx_fifo_size
;
2715 Param
<uint32_t> m5reg
;
2717 END_DECLARE_SIM_OBJECT_PARAMS(NSGigE
)
2719 BEGIN_INIT_SIM_OBJECT_PARAMS(NSGigE
)
2721 INIT_PARAM(addr
, "Device Address"),
2722 INIT_PARAM(cycle_time
, "State machine processor frequency"),
2723 INIT_PARAM(tx_delay
, "Transmit Delay"),
2724 INIT_PARAM(rx_delay
, "Receive Delay"),
2725 INIT_PARAM(intr_delay
, "Interrupt Delay in microseconds"),
2726 INIT_PARAM(mmu
, "Memory Controller"),
2727 INIT_PARAM(physmem
, "Physical Memory"),
2728 INIT_PARAM_DFLT(rx_filter
, "Enable Receive Filter", true),
2729 INIT_PARAM_DFLT(hardware_address
, "Ethernet Hardware Address",
2730 "00:99:00:00:00:01"),
2731 INIT_PARAM_DFLT(io_bus
, "The IO Bus to attach to for headers", NULL
),
2732 INIT_PARAM_DFLT(payload_bus
, "The IO Bus to attach to for payload", NULL
),
2733 INIT_PARAM_DFLT(hier
, "Hierarchy global variables", &defaultHierParams
),
2734 INIT_PARAM_DFLT(pio_latency
, "Programmed IO latency in bus cycles", 1),
2735 INIT_PARAM_DFLT(dma_desc_free
, "DMA of Descriptors is free", false),
2736 INIT_PARAM_DFLT(dma_data_free
, "DMA of Data is free", false),
2737 INIT_PARAM_DFLT(dma_read_delay
, "fixed delay for dma reads", 0),
2738 INIT_PARAM_DFLT(dma_write_delay
, "fixed delay for dma writes", 0),
2739 INIT_PARAM_DFLT(dma_read_factor
, "multiplier for dma reads", 0),
2740 INIT_PARAM_DFLT(dma_write_factor
, "multiplier for dma writes", 0),
2741 INIT_PARAM(configspace
, "PCI Configspace"),
2742 INIT_PARAM(configdata
, "PCI Config data"),
2743 INIT_PARAM(platform
, "Platform"),
2744 INIT_PARAM(pci_bus
, "PCI bus"),
2745 INIT_PARAM(pci_dev
, "PCI device number"),
2746 INIT_PARAM(pci_func
, "PCI function code"),
2747 INIT_PARAM_DFLT(tx_fifo_size
, "max size in bytes of txFifo", 131072),
2748 INIT_PARAM_DFLT(rx_fifo_size
, "max size in bytes of rxFifo", 131072),
2749 INIT_PARAM(m5reg
, "m5 register")
2751 END_INIT_SIM_OBJECT_PARAMS(NSGigE
)
2754 CREATE_SIM_OBJECT(NSGigE
)
2756 NSGigE::Params
*params
= new NSGigE::Params
;
2758 params
->name
= getInstanceName();
2760 params
->configSpace
= configspace
;
2761 params
->configData
= configdata
;
2762 params
->plat
= platform
;
2763 params
->busNum
= pci_bus
;
2764 params
->deviceNum
= pci_dev
;
2765 params
->functionNum
= pci_func
;
2767 params
->cycle_time
= cycle_time
;
2768 params
->intr_delay
= intr_delay
;
2769 params
->pmem
= physmem
;
2770 params
->tx_delay
= tx_delay
;
2771 params
->rx_delay
= rx_delay
;
2772 params
->hier
= hier
;
2773 params
->header_bus
= io_bus
;
2774 params
->payload_bus
= payload_bus
;
2775 params
->pio_latency
= pio_latency
;
2776 params
->dma_desc_free
= dma_desc_free
;
2777 params
->dma_data_free
= dma_data_free
;
2778 params
->dma_read_delay
= dma_read_delay
;
2779 params
->dma_write_delay
= dma_write_delay
;
2780 params
->dma_read_factor
= dma_read_factor
;
2781 params
->dma_write_factor
= dma_write_factor
;
2782 params
->rx_filter
= rx_filter
;
2783 params
->eaddr
= hardware_address
;
2784 params
->tx_fifo_size
= tx_fifo_size
;
2785 params
->rx_fifo_size
= rx_fifo_size
;
2786 params
->m5reg
= m5reg
;
2787 return new NSGigE(params
);
2790 REGISTER_SIM_OBJECT("NSGigE", NSGigE
)