gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ns_gige.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  *
28  * Authors: Nathan Binkert
29  * Lisa Hsu
30  */
31 
37 #ifndef __DEV_NET_NS_GIGE_HH__
38 #define __DEV_NET_NS_GIGE_HH__
39 
40 #include "base/inet.hh"
41 #include "dev/io_device.hh"
42 #include "dev/net/etherdevice.hh"
43 #include "dev/net/etherint.hh"
44 #include "dev/net/etherpkt.hh"
45 #include "dev/net/ns_gige_reg.h"
46 #include "dev/net/pktfifo.hh"
47 #include "params/NSGigE.hh"
48 #include "sim/eventq.hh"
49 
50 // Hash filtering constants
51 const uint16_t FHASH_ADDR = 0x100;
52 const uint16_t FHASH_SIZE = 0x100;
53 
54 // EEPROM constants
55 const uint8_t EEPROM_READ = 0x2;
56 const uint8_t EEPROM_SIZE = 64; // Size in words of NSC93C46 EEPROM
57 const uint8_t EEPROM_PMATCH2_ADDR = 0xA; // EEPROM Address of PMATCH word 2
58 const uint8_t EEPROM_PMATCH1_ADDR = 0xB; // EEPROM Address of PMATCH word 1
59 const uint8_t EEPROM_PMATCH0_ADDR = 0xC; // EEPROM Address of PMATCH word 0
60 
64 struct dp_regs {
65  uint32_t command;
66  uint32_t config;
67  uint32_t mear;
68  uint32_t ptscr;
69  uint32_t isr;
70  uint32_t imr;
71  uint32_t ier;
72  uint32_t ihr;
73  uint32_t txdp;
74  uint32_t txdp_hi;
75  uint32_t txcfg;
76  uint32_t gpior;
77  uint32_t rxdp;
78  uint32_t rxdp_hi;
79  uint32_t rxcfg;
80  uint32_t pqcr;
81  uint32_t wcsr;
82  uint32_t pcr;
83  uint32_t rfcr;
84  uint32_t rfdr;
85  uint32_t brar;
86  uint32_t brdr;
87  uint32_t srr;
88  uint32_t mibc;
89  uint32_t vrcr;
90  uint32_t vtcr;
91  uint32_t vdr;
92  uint32_t ccsr;
93  uint32_t tbicr;
94  uint32_t tbisr;
95  uint32_t tanar;
96  uint32_t tanlpar;
97  uint32_t taner;
98  uint32_t tesr;
99 };
100 
101 struct dp_rom {
106  uint8_t perfectMatch[ETH_ADDR_LEN];
107 
112  uint8_t filterHash[FHASH_SIZE];
113 };
114 
115 class NSGigEInt;
116 class Packet;
117 
121 class NSGigE : public EtherDevBase
122 {
123  public:
125  enum TxState
126  {
133  txAdvance
134  };
135 
137  enum RxState
138  {
145  rxAdvance
146  };
147 
148  enum DmaState
149  {
154  dmaWriteWaiting
155  };
156 
159  {
163  eepromRead
164  };
165 
166  protected:
170 
172  bool ioEnable;
173 
174  /*** BASIC STRUCTURES FOR TX/RX ***/
175  /* Data FIFOs */
178 
182  uint8_t *txPacketBufPtr;
183  uint8_t *rxPacketBufPtr;
184  uint32_t txXferLen;
185  uint32_t rxXferLen;
186  bool rxDmaFree;
187  bool txDmaFree;
188 
194 
195  /* tx State Machine */
197  bool txEnable;
198 
200  bool CTDD;
202  bool txHalt;
206  uint32_t txDescCnt;
208 
211  bool rxEnable;
212 
214  bool CRDD;
216  uint32_t rxPktBytes;
218  bool rxHalt;
222  uint32_t rxDescCnt;
224 
226 
229  bool eepromClk;
230  uint8_t eepromBitsToRx;
231  uint8_t eepromOpcode;
232  uint8_t eepromAddress;
233  uint16_t eepromData;
234 
235  protected:
238 
241 
242  void *rxDmaData;
244  int rxDmaLen;
245  bool doRxDmaRead();
246  bool doRxDmaWrite();
247 
248  void *txDmaData;
250  int txDmaLen;
251  bool doTxDmaRead();
252  bool doTxDmaWrite();
253 
254  void rxDmaReadDone();
256 
257  void rxDmaWriteDone();
259 
260  void txDmaReadDone();
262 
263  void txDmaWriteDone();
265 
268 
269  protected:
272 
273  void txReset();
274  void rxReset();
275  void regsReset();
276 
277  void rxKick();
280 
281  void txKick();
284 
285  void eepromKick();
286 
290  void transmit();
292  {
293  transmit();
294  if (txState == txFifoBlock)
295  txKick();
296  }
298 
299  void txDump() const;
300  void rxDump() const;
301 
306  bool rxFilter(const EthPacketPtr &packet);
311  bool acceptArp;
313 
317  void devIntrPost(uint32_t interrupts);
318  void devIntrClear(uint32_t interrupts);
319  void devIntrChangeMask();
320 
324  void cpuIntrPost(Tick when);
325  void cpuInterrupt();
326  void cpuIntrClear();
327 
330 
331  public:
332  typedef NSGigEParams Params;
333  const Params *params() const {
334  return dynamic_cast<const Params *>(_params);
335  }
336 
337  NSGigE(Params *params);
338  ~NSGigE();
339 
340  Port &getPort(const std::string &if_name,
341  PortID idx=InvalidPortID) override;
342 
343  Tick writeConfig(PacketPtr pkt) override;
344 
345  Tick read(PacketPtr pkt) override;
346  Tick write(PacketPtr pkt) override;
347 
348  bool cpuIntrPending() const;
349  void cpuIntrAck() { cpuIntrClear(); }
350 
351  bool recvPacket(EthPacketPtr packet);
352  void transferDone();
353 
354  void serialize(CheckpointOut &cp) const override;
355  void unserialize(CheckpointIn &cp) override;
356 
357  void drainResume() override;
358 };
359 
360 /*
361  * Ethernet Interface for an Ethernet Device
362  */
363 class NSGigEInt : public EtherInt
364 {
365  private:
367 
368  public:
369  NSGigEInt(const std::string &name, NSGigE *d)
370  : EtherInt(name), dev(d)
371  { }
372 
373  virtual bool recvPacket(EthPacketPtr pkt) { return dev->recvPacket(pkt); }
374  virtual void sendDone() { dev->transferDone(); }
375 };
376 
377 #endif // __DEV_NET_NS_GIGE_HH__
Ports are used to interface objects to each other.
Definition: port.hh:60
Tick txDelay
Definition: ns_gige.hh:270
bool cpuPendingIntr
Definition: ns_gige.hh:323
EventFunctionWrapper txDmaReadEvent
Definition: ns_gige.hh:261
Addr rxDmaAddr
Definition: ns_gige.hh:243
const uint8_t EEPROM_READ
Definition: ns_gige.hh:55
const std::string & name()
Definition: trace.cc:54
bool rxEnable
Definition: ns_gige.hh:211
Addr rxFragPtr
ptr to the next byte in current fragment
Definition: ns_gige.hh:220
const PortID InvalidPortID
Definition: types.hh:238
uint32_t mibc
Definition: ns_gige.hh:88
bool eepromClk
Definition: ns_gige.hh:229
Dummy class to keep the Python class hierarchy in sync with the C++ object hierarchy.
Definition: etherdevice.hh:126
uint8_t * txPacketBufPtr
Definition: ns_gige.hh:182
Tick intrDelay
Definition: ns_gige.hh:321
DmaState txDmaState
Definition: ns_gige.hh:207
dp_regs regs
device register file
Definition: ns_gige.hh:168
uint32_t tbisr
Definition: ns_gige.hh:94
EEPROMState
EEPROM State Machine States.
Definition: ns_gige.hh:158
EventFunctionWrapper rxDmaWriteEvent
Definition: ns_gige.hh:258
TxState txState
Definition: ns_gige.hh:196
const uint8_t EEPROM_PMATCH2_ADDR
Definition: ns_gige.hh:57
bool acceptBroadcast
Definition: ns_gige.hh:307
const Params * params() const
Definition: ns_gige.hh:333
uint32_t tesr
Definition: ns_gige.hh:98
EventFunctionWrapper txDmaWriteEvent
Definition: ns_gige.hh:264
uint32_t command
Definition: ns_gige.hh:65
TxState
Transmit State Machine states.
Definition: ns_gige.hh:125
PacketFifo txFifo
Definition: ns_gige.hh:176
bool acceptPerfect
Definition: ns_gige.hh:310
EEPROMState eepromState
EEPROM State Machine.
Definition: ns_gige.hh:228
NSGigEInt * interface
Definition: ns_gige.hh:329
uint32_t ptscr
Definition: ns_gige.hh:68
Definition: cprintf.cc:42
ns_desc64 rxDesc64
Definition: ns_gige.hh:193
const uint16_t FHASH_SIZE
Definition: ns_gige.hh:52
ns_desc64 txDesc64
Definition: ns_gige.hh:192
bool txHalt
halt the tx state machine after next packet
Definition: ns_gige.hh:202
uint32_t rxDescCnt
count of bytes remaining in the current descriptor
Definition: ns_gige.hh:222
EventFunctionWrapper rxDmaReadEvent
Definition: ns_gige.hh:255
uint32_t rxdp
Definition: ns_gige.hh:77
NSGigEInt(const std::string &name, NSGigE *d)
Definition: ns_gige.hh:369
Tick dmaReadFactor
Definition: ns_gige.hh:239
DmaState rxDmaState
Definition: ns_gige.hh:223
bool extstsEnable
Definition: ns_gige.hh:225
bool rxDmaFree
Definition: ns_gige.hh:186
uint8_t eepromAddress
Definition: ns_gige.hh:232
Tick intrTick
Definition: ns_gige.hh:322
uint32_t wcsr
Definition: ns_gige.hh:81
bool dmaDescFree
Definition: ns_gige.hh:266
void transferDone()
Definition: ns_gige.cc:1896
uint8_t eepromBitsToRx
Definition: ns_gige.hh:230
dp_rom rom
Definition: ns_gige.hh:169
Addr txFragPtr
ptr to the next byte in the current fragment
Definition: ns_gige.hh:204
uint32_t ccsr
Definition: ns_gige.hh:92
uint32_t brdr
Definition: ns_gige.hh:86
int txDmaLen
Definition: ns_gige.hh:250
ns_desc32 txDesc32
DescCaches.
Definition: ns_gige.hh:190
uint32_t txdp
Definition: ns_gige.hh:73
EthPacketPtr rxPacket
Definition: ns_gige.hh:181
Tick rxDelay
Definition: ns_gige.hh:271
const uint8_t EEPROM_PMATCH0_ADDR
Definition: ns_gige.hh:59
DmaState
Definition: ns_gige.hh:148
bool acceptUnicast
Definition: ns_gige.hh:309
PacketFifo rxFifo
Definition: ns_gige.hh:177
uint32_t ihr
Definition: ns_gige.hh:72
uint32_t txcfg
Definition: ns_gige.hh:75
uint64_t Tick
Tick count type.
Definition: types.hh:63
void * rxDmaData
Definition: ns_gige.hh:242
const uint8_t EEPROM_SIZE
Definition: ns_gige.hh:56
uint32_t rxdp_hi
Definition: ns_gige.hh:78
const uint8_t EEPROM_PMATCH1_ADDR
Definition: ns_gige.hh:58
uint32_t gpior
Definition: ns_gige.hh:76
Bitfield< 9 > d
Tick rxKickTick
Definition: ns_gige.hh:278
uint32_t rfdr
Definition: ns_gige.hh:84
uint32_t tanlpar
Definition: ns_gige.hh:96
Addr txDmaAddr
Definition: ns_gige.hh:249
uint32_t rfcr
Definition: ns_gige.hh:83
bool dmaDataFree
Definition: ns_gige.hh:267
void serialize(const ThreadContext &tc, CheckpointOut &cp)
Thread context serialization helpers.
bool CTDD
Current Transmit Descriptor Done.
Definition: ns_gige.hh:200
bool acceptMulticast
Definition: ns_gige.hh:308
NSGigE * dev
Definition: ns_gige.hh:366
bool acceptArp
Definition: ns_gige.hh:311
NSGigEParams Params
Definition: ns_gige.hh:332
std::shared_ptr< EthPacketData > EthPacketPtr
Definition: etherpkt.hh:90
uint32_t config
Definition: ns_gige.hh:66
bool multicastHashEnable
Definition: ns_gige.hh:312
uint32_t pqcr
Definition: ns_gige.hh:80
uint32_t srr
Definition: ns_gige.hh:87
void * txDmaData
Definition: ns_gige.hh:248
Ethernet device registers.
Definition: ns_gige.hh:64
bool ioEnable
pci settings
Definition: ns_gige.hh:172
int rxDmaLen
Definition: ns_gige.hh:244
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
const uint16_t FHASH_ADDR
Definition: ns_gige.hh:51
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
Base Ethernet Device declaration.
RxState
Receive State Machine States.
Definition: ns_gige.hh:137
Ethernet device register definitions for the National Semiconductor DP83820 Ethernet controller...
EventFunctionWrapper * intrEvent
Definition: ns_gige.hh:328
bool rxHalt
halt the rx state machine after current packet
Definition: ns_gige.hh:218
EventFunctionWrapper rxKickEvent
Definition: ns_gige.hh:279
uint32_t vrcr
Definition: ns_gige.hh:89
EthPacketPtr txPacket
various helper vars
Definition: ns_gige.hh:180
ns_desc32 rxDesc32
Definition: ns_gige.hh:191
uint32_t vdr
Definition: ns_gige.hh:91
EventFunctionWrapper txKickEvent
Definition: ns_gige.hh:283
uint32_t rxcfg
Definition: ns_gige.hh:79
uint32_t vtcr
Definition: ns_gige.hh:90
std::ostream CheckpointOut
Definition: serialize.hh:68
uint32_t brar
Definition: ns_gige.hh:85
uint16_t eepromData
Definition: ns_gige.hh:233
uint32_t tbicr
Definition: ns_gige.hh:93
EventFunctionWrapper txEvent
Definition: ns_gige.hh:297
bool txEnable
Definition: ns_gige.hh:197
uint32_t txXferLen
Definition: ns_gige.hh:184
void cpuIntrAck()
Definition: ns_gige.hh:349
uint32_t txDescCnt
count of bytes remaining in the current descriptor
Definition: ns_gige.hh:206
Tick dmaWriteDelay
Definition: ns_gige.hh:237
uint8_t eepromOpcode
Definition: ns_gige.hh:231
uint32_t tanar
Definition: ns_gige.hh:95
uint32_t isr
Definition: ns_gige.hh:69
void unserialize(ThreadContext &tc, CheckpointIn &cp)
uint32_t pcr
Definition: ns_gige.hh:82
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
bool rxFilterEnable
receive address filter
Definition: ns_gige.hh:305
RxState rxState
rx State Machine
Definition: ns_gige.hh:210
NS DP83820 Ethernet device model.
Definition: ns_gige.hh:121
uint32_t imr
Definition: ns_gige.hh:70
Tick dmaReadDelay
Definition: ns_gige.hh:236
bool CRDD
Current Receive Descriptor Done.
Definition: ns_gige.hh:214
bool txDmaFree
Definition: ns_gige.hh:187
uint8_t * rxPacketBufPtr
Definition: ns_gige.hh:183
void txEventTransmit()
Definition: ns_gige.hh:291
uint32_t taner
Definition: ns_gige.hh:97
uint32_t txdp_hi
Definition: ns_gige.hh:74
virtual bool recvPacket(EthPacketPtr pkt)
Definition: ns_gige.hh:373
uint32_t mear
Definition: ns_gige.hh:67
uint32_t ier
Definition: ns_gige.hh:71
uint32_t rxPktBytes
num of bytes in the current packet being drained from rxDataFifo
Definition: ns_gige.hh:216
uint32_t rxXferLen
Definition: ns_gige.hh:185
virtual void sendDone()
Definition: ns_gige.hh:374
Tick txKickTick
Definition: ns_gige.hh:282
Tick dmaWriteFactor
Definition: ns_gige.hh:240
bool recvPacket(EthPacketPtr packet)
Definition: ns_gige.cc:1952

Generated on Fri Feb 28 2020 16:27:01 for gem5 by doxygen 1.8.13