gem5  v22.1.0.0
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 
29 #ifndef __DEV_NET_SINIC_HH__
30 #define __DEV_NET_SINIC_HH__
31 
32 #include "base/compiler.hh"
33 #include "base/inet.hh"
34 #include "base/statistics.hh"
35 #include "dev/io_device.hh"
36 #include "dev/net/etherdevice.hh"
37 #include "dev/net/etherint.hh"
38 #include "dev/net/etherpkt.hh"
39 #include "dev/net/pktfifo.hh"
40 #include "dev/net/sinicreg.hh"
41 #include "dev/pci/device.hh"
42 #include "params/Sinic.hh"
43 #include "sim/eventq.hh"
44 
45 namespace gem5
46 {
47 
48 GEM5_DEPRECATED_NAMESPACE(Sinic, sinic);
49 namespace sinic
50 {
51 
52 class Interface;
53 class Base : public EtherDevBase
54 {
55  protected:
56  bool rxEnable;
57  bool txEnable;
58 
59  protected:
64  void cpuIntrPost(Tick when);
65  void cpuInterrupt();
66  void cpuIntrClear();
67 
70 
71  bool cpuIntrPending() const;
72  void cpuIntrAck() { cpuIntrClear(); }
73 
77  public:
78  void serialize(CheckpointOut &cp) const override;
79  void unserialize(CheckpointIn &cp) override;
80 
84  public:
85  PARAMS(Sinic);
86  Base(const Params &p);
87 };
88 
89 class Device : public Base
90 {
91  protected:
93  enum RxState
94  {
100  };
101 
103  enum TxState
104  {
109  txCopyDone
110  };
111 
113  struct
114  {
115  uint32_t Config; // 0x00
116  uint32_t Command; // 0x04
117  uint32_t IntrStatus; // 0x08
118  uint32_t IntrMask; // 0x0c
119  uint32_t RxMaxCopy; // 0x10
120  uint32_t TxMaxCopy; // 0x14
121  uint32_t ZeroCopySize; // 0x18
122  uint32_t ZeroCopyMark; // 0x1c
123  uint32_t VirtualCount; // 0x20
124  uint32_t RxMaxIntr; // 0x24
125  uint32_t RxFifoSize; // 0x28
126  uint32_t TxFifoSize; // 0x2c
127  uint32_t RxFifoLow; // 0x30
128  uint32_t TxFifoLow; // 0x34
129  uint32_t RxFifoHigh; // 0x38
130  uint32_t TxFifoHigh; // 0x3c
131  uint64_t RxData; // 0x40
132  uint64_t RxDone; // 0x48
133  uint64_t RxWait; // 0x50
134  uint64_t TxData; // 0x58
135  uint64_t TxDone; // 0x60
136  uint64_t TxWait; // 0x68
137  uint64_t HwAddr; // 0x70
138  uint64_t RxStatus; // 0x78
139  } regs;
140 
141  struct VirtualReg
142  {
143  uint64_t RxData;
144  uint64_t RxDone;
145  uint64_t TxData;
146  uint64_t TxDone;
147 
149  unsigned rxPacketOffset;
150  unsigned rxPacketBytes;
151  uint64_t rxDoneData;
152 
155 
157  : RxData(0), RxDone(0), TxData(0), TxDone(0),
159  { }
160  };
168  int rxActive;
170 
174 
175  uint8_t &regData8(Addr daddr) { return *((uint8_t *)&regs + daddr); }
176  uint32_t &regData32(Addr daddr) { return *(uint32_t *)&regData8(daddr); }
177  uint64_t &regData64(Addr daddr) { return *(uint64_t *)&regData8(daddr); }
178 
179  protected:
183  bool rxEmpty;
184  bool rxLow;
186  uint8_t *rxDmaData;
187  unsigned rxDmaLen;
188 
191  bool txFull;
196  uint8_t *txDmaData;
197  int txDmaLen;
198 
199  protected:
200  void reset();
201 
202  void rxKick();
204 
205  void txKick();
207 
211  void transmit();
213  {
214  transmit();
215  if (txState == txFifoBlock)
216  txKick();
217  }
219 
220  void txDump() const;
221  void rxDump() const;
222 
226  bool rxFilter(const EthPacketPtr &packet);
227 
231  void changeConfig(uint32_t newconfig);
232  void command(uint32_t command);
233 
237  public:
238  bool recvPacket(EthPacketPtr packet);
239  void transferDone();
240  Port &getPort(const std::string &if_name,
241  PortID idx=InvalidPortID) override;
242 
246  protected:
247  void rxDmaDone();
249 
250  void txDmaDone();
252 
257 
261  protected:
262  void devIntrPost(uint32_t interrupts);
263  void devIntrClear(uint32_t interrupts = registers::Intr_All);
264  void devIntrChangeMask(uint32_t newmask);
265 
269  public:
270  Tick read(PacketPtr pkt) override;
271  Tick write(PacketPtr pkt) override;
272  virtual void drainResume() override;
273 
274  void prepareIO(ContextID cpu, int index);
275  void prepareRead(ContextID cpu, int index);
276  void prepareWrite(ContextID cpu, int index);
277  // Fault iprRead(Addr daddr, ContextID cpu, uint64_t &result);
278 
282  private:
284  {
286 
291 
294 
295 
296  public:
297  void resetStats() override;
298 
302  public:
303  void serialize(CheckpointOut &cp) const override;
304  void unserialize(CheckpointIn &cp) override;
305 
306  public:
307  Device(const Params &p);
308  ~Device();
309 };
310 
311 /*
312  * Ethernet Interface for an Ethernet Device
313  */
314 class Interface : public EtherInt
315 {
316  private:
318 
319  public:
320  Interface(const std::string &name, Device *d)
321  : EtherInt(name), dev(d)
322  { }
323 
324  virtual bool recvPacket(EthPacketPtr pkt) { return dev->recvPacket(pkt); }
325  virtual void sendDone() { dev->transferDone(); }
326 };
327 
328 } // namespace sinic
329 } // namespace gem5
330 
331 #endif // __DEV_NET_SINIC_HH__
DmaDeviceParams Params
Definition: dma_device.hh:209
Dummy class to keep the Python class hierarchy in sync with the C++ object hierarchy.
Definition: etherdevice.hh:144
EtherDevBaseParams Params
Definition: etherdevice.hh:146
const std::string & name() const
Return port name (for DPRINTF).
Definition: etherint.hh:62
fifo_list::iterator iterator
Definition: pktfifo.hh:85
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Ports are used to interface objects to each other.
Definition: port.hh:62
void cpuInterrupt()
Definition: sinic.cc:517
Base(const Params &p)
Definition: sinic.cc:78
void cpuIntrPost(Tick when)
Definition: sinic.cc:475
EventFunctionWrapper * intrEvent
Definition: sinic.hh:68
bool cpuIntrEnable
Definition: sinic.hh:62
void cpuIntrAck()
Definition: sinic.hh:72
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition: sinic.cc:1203
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sinic.cc:1224
Tick intrDelay
Definition: sinic.hh:60
void cpuIntrClear()
Definition: sinic.cc:540
Interface * interface
Definition: sinic.hh:69
bool cpuIntrPending() const
Definition: sinic.cc:559
bool cpuPendingIntr
Definition: sinic.hh:63
PARAMS(Sinic)
Construction/Destruction/Parameters.
EventFunctionWrapper txEvent
Definition: sinic.hh:218
uint32_t IntrMask
Definition: sinic.hh:118
void transmit()
Retransmit event.
Definition: sinic.cc:962
bool rxFilter(const EthPacketPtr &packet)
receive address filter
Definition: sinic.cc:1139
TxState txState
Definition: sinic.hh:189
void prepareRead(ContextID cpu, int index)
Definition: sinic.cc:150
uint32_t TxFifoSize
Definition: sinic.hh:126
Tick write(PacketPtr pkt) override
IPR read of device register.
Definition: sinic.cc:291
uint64_t RxStatus
Definition: sinic.hh:138
void transferDone()
Definition: sinic.cc:1126
uint64_t RxData
Definition: sinic.hh:131
PacketFifo::iterator rxFifoPtr
Definition: sinic.hh:182
VirtualList rxBusy
Definition: sinic.hh:167
uint32_t & regData32(Addr daddr)
Definition: sinic.hh:176
struct gem5::sinic::Device::@314 regs
device register file
EthPacketPtr txPacket
Definition: sinic.hh:192
Counter rxUnique
Definition: sinic.hh:163
VirtualList txList
Definition: sinic.hh:169
uint32_t RxFifoSize
Definition: sinic.hh:125
void txDump() const
void changeConfig(uint32_t newconfig)
device configuration
Definition: sinic.cc:563
bool recvPacket(EthPacketPtr packet)
device ethernet interface
Definition: sinic.cc:1150
void devIntrPost(uint32_t interrupts)
Interrupt management.
Definition: sinic.cc:405
void rxDump() const
uint32_t RxFifoLow
Definition: sinic.hh:127
EventFunctionWrapper txDmaEvent
Definition: sinic.hh:251
void devIntrChangeMask(uint32_t newmask)
Definition: sinic.cc:457
uint32_t RxMaxCopy
Definition: sinic.hh:119
void txEventTransmit()
Definition: sinic.hh:212
void prepareWrite(ContextID cpu, int index)
Definition: sinic.cc:191
uint32_t VirtualCount
Definition: sinic.hh:123
unsigned rxDmaLen
Definition: sinic.hh:187
void rxDmaDone()
DMA parameters.
Definition: sinic.cc:675
RxState
Receive State Machine States.
Definition: sinic.hh:94
uint64_t TxData
Definition: sinic.hh:134
uint8_t * txDmaData
Definition: sinic.hh:196
uint64_t RxWait
Definition: sinic.hh:133
PacketFifo rxFifo
Definition: sinic.hh:181
uint8_t * rxDmaData
Definition: sinic.hh:186
uint32_t RxFifoHigh
Definition: sinic.hh:129
Tick read(PacketPtr pkt) override
Memory Interface.
Definition: sinic.cc:200
uint32_t RxMaxIntr
Definition: sinic.hh:124
uint32_t IntrStatus
Definition: sinic.hh:117
uint32_t TxMaxCopy
Definition: sinic.hh:120
uint64_t RxDone
Definition: sinic.hh:132
RxState rxState
Definition: sinic.hh:180
uint32_t Config
Definition: sinic.hh:115
Device(const Params &p)
Definition: sinic.cc:85
uint32_t Command
Definition: sinic.hh:116
void txDmaDone()
Definition: sinic.cc:946
TxState
Transmit State Machine states.
Definition: sinic.hh:104
uint32_t TxFifoHigh
Definition: sinic.hh:130
EventFunctionWrapper rxDmaEvent
Definition: sinic.hh:248
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sinic.cc:1363
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition: sinic.cc:1248
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition: sinic.cc:128
PacketFifo txFifo
Definition: sinic.hh:190
uint32_t ZeroCopySize
Definition: sinic.hh:121
uint64_t TxWait
Definition: sinic.hh:136
void command(uint32_t command)
Definition: sinic.cc:595
Counter txUnique
Definition: sinic.hh:164
void resetStats() override
Callback to reset stats.
Definition: sinic.cc:120
std::list< unsigned > VirtualList
Definition: sinic.hh:162
uint64_t & regData64(Addr daddr)
Definition: sinic.hh:177
virtual void drainResume() override
Resume execution after a successful drain.
Definition: sinic.cc:1188
uint64_t TxDone
Definition: sinic.hh:135
gem5::sinic::Device::DeviceStats sinicDeviceStats
uint32_t TxFifoLow
Definition: sinic.hh:128
std::vector< VirtualReg > VirtualRegs
Definition: sinic.hh:161
void prepareIO(ContextID cpu, int index)
Definition: sinic.cc:137
uint64_t HwAddr
Definition: sinic.hh:137
VirtualList rxList
Definition: sinic.hh:166
uint8_t & regData8(Addr daddr)
Definition: sinic.hh:175
void devIntrClear(uint32_t interrupts=registers::Intr_All)
Definition: sinic.cc:441
VirtualRegs virtualRegs
Definition: sinic.hh:165
uint32_t ZeroCopyMark
Definition: sinic.hh:122
virtual bool recvPacket(EthPacketPtr pkt)
Definition: sinic.hh:324
virtual void sendDone()
Definition: sinic.hh:325
Interface(const std::string &name, Device *d)
Definition: sinic.hh:320
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2540
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
Base Ethernet Device declaration.
Bitfield< 9 > d
Definition: misc_types.hh:64
Bitfield< 30, 0 > index
Bitfield< 54 > p
Definition: pagetable.hh:70
double Counter
All counters are of 64-bit values.
Definition: types.hh:47
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
std::shared_ptr< EthPacketData > EthPacketPtr
Definition: etherpkt.hh:90
Declaration of Statistics objects.
statistics::Scalar totalVnicDistance
Definition: sinic.hh:287
statistics::Scalar maxVnicDistance
Definition: sinic.hh:289
statistics::Scalar numVnicDistance
Definition: sinic.hh:288
DeviceStats(statistics::Group *parent)
Definition: sinic.cc:104
statistics::Formula avgVnicDistance
Definition: sinic.hh:290
PacketFifo::iterator rxIndex
Definition: sinic.hh:148

Generated on Wed Dec 21 2022 10:22:34 for gem5 by doxygen 1.9.1