gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
sinic.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  */
30 
31 #ifndef __DEV_NET_SINIC_HH__
32 #define __DEV_NET_SINIC_HH__
33 
34 #include "base/inet.hh"
35 #include "base/statistics.hh"
36 #include "dev/io_device.hh"
37 #include "dev/net/etherdevice.hh"
38 #include "dev/net/etherint.hh"
39 #include "dev/net/etherpkt.hh"
40 #include "dev/net/pktfifo.hh"
41 #include "dev/net/sinicreg.hh"
42 #include "dev/pci/device.hh"
43 #include "params/Sinic.hh"
44 #include "sim/eventq.hh"
45 
46 namespace Sinic {
47 
48 class Interface;
49 class Base : public EtherDevBase
50 {
51  protected:
52  bool rxEnable;
53  bool txEnable;
54 
55  protected:
60  void cpuIntrPost(Tick when);
61  void cpuInterrupt();
62  void cpuIntrClear();
63 
66 
67  bool cpuIntrPending() const;
68  void cpuIntrAck() { cpuIntrClear(); }
69 
73  public:
74  void serialize(CheckpointOut &cp) const override;
75  void unserialize(CheckpointIn &cp) override;
76 
80  public:
81  typedef SinicParams Params;
82  const Params *params() const { return (const Params *)_params; }
83  Base(const Params *p);
84 };
85 
86 class Device : public Base
87 {
88  protected:
90  enum RxState {
95  rxCopyDone
96  };
97 
99  enum TxState {
104  txCopyDone
105  };
106 
108  struct {
109  uint32_t Config; // 0x00
110  uint32_t Command; // 0x04
111  uint32_t IntrStatus; // 0x08
112  uint32_t IntrMask; // 0x0c
113  uint32_t RxMaxCopy; // 0x10
114  uint32_t TxMaxCopy; // 0x14
115  uint32_t ZeroCopySize; // 0x18
116  uint32_t ZeroCopyMark; // 0x1c
117  uint32_t VirtualCount; // 0x20
118  uint32_t RxMaxIntr; // 0x24
119  uint32_t RxFifoSize; // 0x28
120  uint32_t TxFifoSize; // 0x2c
121  uint32_t RxFifoLow; // 0x30
122  uint32_t TxFifoLow; // 0x34
123  uint32_t RxFifoHigh; // 0x38
124  uint32_t TxFifoHigh; // 0x3c
125  uint64_t RxData; // 0x40
126  uint64_t RxDone; // 0x48
127  uint64_t RxWait; // 0x50
128  uint64_t TxData; // 0x58
129  uint64_t TxDone; // 0x60
130  uint64_t TxWait; // 0x68
131  uint64_t HwAddr; // 0x70
132  uint64_t RxStatus; // 0x78
133  } regs;
134 
135  struct VirtualReg {
136  uint64_t RxData;
137  uint64_t RxDone;
138  uint64_t TxData;
139  uint64_t TxDone;
140 
142  unsigned rxPacketOffset;
143  unsigned rxPacketBytes;
144  uint64_t rxDoneData;
145 
148 
150  : RxData(0), RxDone(0), TxData(0), TxDone(0),
151  rxPacketOffset(0), rxPacketBytes(0), rxDoneData(0)
152  { }
153  };
158  VirtualRegs virtualRegs;
159  VirtualList rxList;
160  VirtualList rxBusy;
161  int rxActive;
162  VirtualList txList;
163 
167 
168  uint8_t &regData8(Addr daddr) { return *((uint8_t *)&regs + daddr); }
169  uint32_t &regData32(Addr daddr) { return *(uint32_t *)&regData8(daddr); }
170  uint64_t &regData64(Addr daddr) { return *(uint64_t *)&regData8(daddr); }
171 
172  protected:
176  bool rxEmpty;
177  bool rxLow;
179  uint8_t *rxDmaData;
180  unsigned rxDmaLen;
181 
184  bool txFull;
189  uint8_t *txDmaData;
190  int txDmaLen;
191 
192  protected:
193  void reset();
194 
195  void rxKick();
197 
198  void txKick();
200 
204  void transmit();
206  {
207  transmit();
208  if (txState == txFifoBlock)
209  txKick();
210  }
212 
213  void txDump() const;
214  void rxDump() const;
215 
219  bool rxFilter(const EthPacketPtr &packet);
220 
224  void changeConfig(uint32_t newconfig);
225  void command(uint32_t command);
226 
230  public:
231  bool recvPacket(EthPacketPtr packet);
232  void transferDone();
233  Port &getPort(const std::string &if_name,
234  PortID idx=InvalidPortID) override;
235 
239  protected:
240  void rxDmaDone();
242 
243  void txDmaDone();
245 
250 
254  protected:
255  void devIntrPost(uint32_t interrupts);
256  void devIntrClear(uint32_t interrupts = Regs::Intr_All);
257  void devIntrChangeMask(uint32_t newmask);
258 
262  public:
263  Tick read(PacketPtr pkt) override;
264  Tick write(PacketPtr pkt) override;
265  virtual void drainResume() override;
266 
267  void prepareIO(ContextID cpu, int index);
268  void prepareRead(ContextID cpu, int index);
269  void prepareWrite(ContextID cpu, int index);
270  // Fault iprRead(Addr daddr, ContextID cpu, uint64_t &result);
271 
275  private:
280 
282 
283  public:
284  void regStats() override;
285  void resetStats() override;
286 
290  public:
291  void serialize(CheckpointOut &cp) const override;
292  void unserialize(CheckpointIn &cp) override;
293 
294  public:
295  Device(const Params *p);
296  ~Device();
297 };
298 
299 /*
300  * Ethernet Interface for an Ethernet Device
301  */
302 class Interface : public EtherInt
303 {
304  private:
306 
307  public:
308  Interface(const std::string &name, Device *d)
309  : EtherInt(name), dev(d)
310  { }
311 
312  virtual bool recvPacket(EthPacketPtr pkt) { return dev->recvPacket(pkt); }
313  virtual void sendDone() { dev->transferDone(); }
314 };
315 
316 } // namespace Sinic
317 
318 #endif // __DEV_NET_SINIC_HH__
uint32_t RxFifoHigh
Definition: sinic.hh:123
uint64_t TxDone
Definition: sinic.hh:129
Tick dmaReadFactor
Definition: sinic.hh:247
Ports are used to interface objects to each other.
Definition: port.hh:60
Base(const Params *p)
Definition: sinic.cc:76
int txPacketOffset
Definition: sinic.hh:186
Bitfield< 30, 0 > index
uint32_t VirtualCount
Definition: sinic.hh:117
Counter rxUnique
Definition: sinic.hh:156
virtual void sendDone()
Definition: sinic.hh:313
void transferDone()
Definition: sinic.cc:1129
PacketFifo::iterator rxFifoPtr
Definition: sinic.hh:175
const PortID InvalidPortID
Definition: types.hh:238
uint32_t TxFifoSize
Definition: sinic.hh:120
Dummy class to keep the Python class hierarchy in sync with the C++ object hierarchy.
Definition: etherdevice.hh:126
EventFunctionWrapper txEvent
Definition: sinic.hh:211
TxState
Transmit State Machine states.
Definition: sinic.hh:99
RxState rxState
Definition: sinic.hh:173
uint8_t * txDmaData
Definition: sinic.hh:189
uint8_t * rxDmaData
Definition: sinic.hh:179
SinicParams Params
Construction/Destruction/Parameters.
Definition: sinic.hh:81
Counter txUnique
Definition: sinic.hh:157
virtual Tick read(PacketPtr pkt)=0
Pure virtual function that the device must implement.
int rxDirtyCount
Definition: sinic.hh:166
int rxMappedCount
Definition: sinic.hh:165
uint64_t TxWait
Definition: sinic.hh:130
void cpuIntrPost(Tick when)
Definition: sinic.cc:479
Tick dmaWriteDelay
Definition: sinic.hh:248
uint64_t RxWait
Definition: sinic.hh:127
const Params * params() const
Definition: sinic.hh:82
unsigned rxDmaLen
Definition: sinic.hh:180
void reset()
Definition: statistics.cc:570
std::list< unsigned > VirtualList
Definition: sinic.hh:155
EventFunctionWrapper rxDmaEvent
Definition: sinic.hh:241
PacketFifo txFifo
Definition: sinic.hh:183
Addr rxDmaAddr
Definition: sinic.hh:178
int _maxVnicDistance
Definition: sinic.hh:281
virtual bool recvPacket(EthPacketPtr pkt)
Definition: sinic.hh:312
uint32_t TxMaxCopy
Definition: sinic.hh:114
uint32_t RxMaxIntr
Definition: sinic.hh:118
Definition: cprintf.cc:42
Stats::Scalar maxVnicDistance
Definition: sinic.hh:278
uint32_t IntrStatus
Definition: sinic.hh:111
Declaration of Statistics objects.
uint32_t Command
Definition: sinic.hh:110
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
uint64_t RxData
Definition: sinic.hh:125
bool rxEnable
Definition: sinic.hh:52
bool txFull
Definition: sinic.hh:184
uint32_t ZeroCopyMark
Definition: sinic.hh:116
Tick rxKickTick
Definition: sinic.hh:196
EventFunctionWrapper * intrEvent
Definition: sinic.hh:64
EthPacketPtr txPacket
Definition: sinic.hh:185
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition: sinic.cc:1206
bool txEnable
Definition: sinic.hh:53
VirtualRegs virtualRegs
Definition: sinic.hh:158
uint64_t HwAddr
Definition: sinic.hh:131
uint64_t & regData64(Addr daddr)
Definition: sinic.hh:170
virtual Tick write(PacketPtr pkt)=0
Pure virtual function that the device must implement.
Definition: sinic.cc:51
void regStats()
Callback to set stat parameters.
Definition: etherdevice.cc:37
DmaDeviceParams Params
Definition: dma_device.hh:175
uint64_t Tick
Tick count type.
Definition: types.hh:63
bool cpuPendingIntr
Definition: sinic.hh:59
Stats::Scalar numVnicDistance
Definition: sinic.hh:277
uint32_t TxFifoHigh
Definition: sinic.hh:124
uint64_t RxStatus
Definition: sinic.hh:132
Bitfield< 9 > d
uint32_t Config
Definition: sinic.hh:109
virtual void resetStats()
Callback to reset stats.
Definition: group.cc:84
Addr txDmaAddr
Definition: sinic.hh:188
Stats::Formula avgVnicDistance
Definition: sinic.hh:279
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sinic.cc:1227
Interface(const std::string &name, Device *d)
Definition: sinic.hh:308
std::shared_ptr< EthPacketData > EthPacketPtr
Definition: etherpkt.hh:90
Device * dev
Definition: sinic.hh:305
VirtualList rxList
Definition: sinic.hh:159
PacketFifo rxFifo
Definition: sinic.hh:174
int txDmaLen
Definition: sinic.hh:190
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: dma_device.cc:282
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
virtual const std::string name() const
Definition: sim_object.hh:120
int64_t Counter
Statistics counter type.
Definition: types.hh:58
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
bool recvPacket(EthPacketPtr packet)
device ethernet interface
Definition: sinic.cc:1153
uint8_t & regData8(Addr daddr)
Definition: sinic.hh:168
Interface * interface
Definition: sinic.hh:65
void cpuIntrAck()
Definition: sinic.hh:68
Base Ethernet Device declaration.
bool cpuIntrPending() const
Definition: sinic.cc:563
Stats::Scalar totalVnicDistance
Statistics.
Definition: sinic.hh:276
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
uint32_t ZeroCopySize
Definition: sinic.hh:115
uint32_t & regData32(Addr daddr)
Definition: sinic.hh:169
Tick dmaReadDelay
Definition: sinic.hh:246
bool rxLow
Definition: sinic.hh:177
uint32_t RxMaxCopy
Definition: sinic.hh:113
void txEventTransmit()
Definition: sinic.hh:205
std::ostream CheckpointOut
Definition: serialize.hh:68
uint32_t RxFifoSize
Definition: sinic.hh:119
fifo_list::iterator iterator
Definition: pktfifo.hh:83
Tick intrDelay
Definition: sinic.hh:56
virtual void drainResume()
Resume execution after a successful drain.
Definition: drain.hh:257
uint64_t RxDone
Definition: sinic.hh:126
bool rxEmpty
Definition: sinic.hh:176
int rxBusyCount
Definition: sinic.hh:164
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:110
VirtualList txList
Definition: sinic.hh:162
Tick txKickTick
Definition: sinic.hh:199
PacketFifo::iterator rxIndex
Definition: sinic.hh:141
Tick dmaWriteFactor
Definition: sinic.hh:249
Tick intrTick
Definition: sinic.hh:57
int txPacketBytes
Definition: sinic.hh:187
EventFunctionWrapper txDmaEvent
Definition: sinic.hh:244
RxState
Receive State Machine States.
Definition: sinic.hh:90
void cpuInterrupt()
Definition: sinic.cc:521
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
std::vector< VirtualReg > VirtualRegs
Definition: sinic.hh:154
void cpuIntrClear()
Definition: sinic.cc:544
uint64_t TxData
Definition: sinic.hh:128
VirtualList rxBusy
Definition: sinic.hh:160
TxState txState
Definition: sinic.hh:182
uint32_t IntrMask
Definition: sinic.hh:112
Bitfield< 0 > p
uint32_t TxFifoLow
Definition: sinic.hh:122
int ContextID
Globally unique thread context ID.
Definition: types.hh:231
bool cpuIntrEnable
Definition: sinic.hh:58
int rxActive
Definition: sinic.hh:161
uint32_t RxFifoLow
Definition: sinic.hh:121

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