gem5 v24.0.0.0
Loading...
Searching...
No Matches
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"
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
45namespace gem5
46{
47
48namespace sinic
49{
50
51class Interface;
52class Base : public EtherDevBase
53{
54 protected:
57
58 protected:
63 void cpuIntrPost(Tick when);
64 void cpuInterrupt();
65 void cpuIntrClear();
66
69
70 bool cpuIntrPending() const;
72
76 public:
77 void serialize(CheckpointOut &cp) const override;
78 void unserialize(CheckpointIn &cp) override;
79
83 public:
84 PARAMS(Sinic);
85 Base(const Params &p);
86};
87
88class Device : public Base
89{
90 protected:
100
110
112 struct
113 {
114 uint32_t Config; // 0x00
115 uint32_t Command; // 0x04
116 uint32_t IntrStatus; // 0x08
117 uint32_t IntrMask; // 0x0c
118 uint32_t RxMaxCopy; // 0x10
119 uint32_t TxMaxCopy; // 0x14
120 uint32_t ZeroCopySize; // 0x18
121 uint32_t ZeroCopyMark; // 0x1c
122 uint32_t VirtualCount; // 0x20
123 uint32_t RxMaxIntr; // 0x24
124 uint32_t RxFifoSize; // 0x28
125 uint32_t TxFifoSize; // 0x2c
126 uint32_t RxFifoLow; // 0x30
127 uint32_t TxFifoLow; // 0x34
128 uint32_t RxFifoHigh; // 0x38
129 uint32_t TxFifoHigh; // 0x3c
130 uint64_t RxData; // 0x40
131 uint64_t RxDone; // 0x48
132 uint64_t RxWait; // 0x50
133 uint64_t TxData; // 0x58
134 uint64_t TxDone; // 0x60
135 uint64_t TxWait; // 0x68
136 uint64_t HwAddr; // 0x70
137 uint64_t RxStatus; // 0x78
139
141 {
142 uint64_t RxData;
143 uint64_t RxDone;
144 uint64_t TxData;
145 uint64_t TxDone;
146
150 uint64_t rxDoneData;
151
154
156 : RxData(0), RxDone(0), TxData(0), TxDone(0),
158 { }
159 };
169
173
174 uint8_t &regData8(Addr daddr) { return *((uint8_t *)&regs + daddr); }
175 uint32_t &regData32(Addr daddr) { return *(uint32_t *)&regData8(daddr); }
176 uint64_t &regData64(Addr daddr) { return *(uint64_t *)&regData8(daddr); }
177
178 protected:
183 bool rxLow;
185 uint8_t *rxDmaData;
186 unsigned rxDmaLen;
187
190 bool txFull;
195 uint8_t *txDmaData;
197
198 protected:
199 void reset();
200
201 void rxKick();
203
204 void txKick();
206
210 void transmit();
212 {
213 transmit();
214 if (txState == txFifoBlock)
215 txKick();
216 }
218
219 void txDump() const;
220 void rxDump() const;
221
225 bool rxFilter(const EthPacketPtr &packet);
226
230 void changeConfig(uint32_t newconfig);
231 void command(uint32_t command);
232
236 public:
237 bool recvPacket(EthPacketPtr packet);
238 void transferDone();
239 Port &getPort(const std::string &if_name,
240 PortID idx=InvalidPortID) override;
241
245 protected:
246 void rxDmaDone();
248
249 void txDmaDone();
251
256
260 protected:
261 void devIntrPost(uint32_t interrupts);
262 void devIntrClear(uint32_t interrupts = registers::Intr_All);
263 void devIntrChangeMask(uint32_t newmask);
264
268 public:
269 Tick read(PacketPtr pkt) override;
270 Tick write(PacketPtr pkt) override;
271 virtual void drainResume() override;
272
273 void prepareIO(ContextID cpu, int index);
274 void prepareRead(ContextID cpu, int index);
275 void prepareWrite(ContextID cpu, int index);
276 // Fault iprRead(Addr daddr, ContextID cpu, uint64_t &result);
277
281 private:
293
294
295 public:
296 void resetStats() override;
297
301 public:
302 void serialize(CheckpointOut &cp) const override;
303 void unserialize(CheckpointIn &cp) override;
304
305 public:
306 Device(const Params &p);
307 ~Device();
308};
309
310/*
311 * Ethernet Interface for an Ethernet Device
312 */
313class Interface : public EtherInt
314{
315 private:
317
318 public:
319 Interface(const std::string &name, Device *d)
320 : EtherInt(name), dev(d)
321 { }
322
323 virtual bool recvPacket(EthPacketPtr pkt) { return dev->recvPacket(pkt); }
324 virtual void sendDone() { dev->transferDone(); }
325};
326
327} // namespace sinic
328} // namespace gem5
329
330#endif // __DEV_NET_SINIC_HH__
Dummy class to keep the Python class hierarchy in sync with the C++ object hierarchy.
EtherDevBaseParams Params
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:295
Ports are used to interface objects to each other.
Definition port.hh:62
Base(const Params &p)
Definition sinic.cc:77
void cpuIntrPost(Tick when)
Definition sinic.cc:474
EventFunctionWrapper * intrEvent
Definition sinic.hh:67
bool cpuIntrEnable
Definition sinic.hh:61
void cpuIntrAck()
Definition sinic.hh:71
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition sinic.cc:1202
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition sinic.cc:1223
void cpuIntrClear()
Definition sinic.cc:539
Interface * interface
Definition sinic.hh:68
bool cpuIntrPending() const
Definition sinic.cc:558
bool cpuPendingIntr
Definition sinic.hh:62
void cpuInterrupt()
Definition sinic.cc:516
PARAMS(Sinic)
Construction/Destruction/Parameters.
EventFunctionWrapper txEvent
Definition sinic.hh:217
uint32_t IntrMask
Definition sinic.hh:117
void transmit()
Retransmit event.
Definition sinic.cc:961
bool rxFilter(const EthPacketPtr &packet)
receive address filter
Definition sinic.cc:1138
void prepareRead(ContextID cpu, int index)
Definition sinic.cc:149
uint32_t TxFifoSize
Definition sinic.hh:125
Tick write(PacketPtr pkt) override
IPR read of device register.
Definition sinic.cc:290
uint64_t RxStatus
Definition sinic.hh:137
uint64_t RxData
Definition sinic.hh:130
PacketFifo::iterator rxFifoPtr
Definition sinic.hh:181
VirtualList rxBusy
Definition sinic.hh:166
EthPacketPtr txPacket
Definition sinic.hh:191
uint64_t & regData64(Addr daddr)
Definition sinic.hh:176
VirtualList txList
Definition sinic.hh:168
uint32_t RxFifoSize
Definition sinic.hh:124
void txDump() const
void changeConfig(uint32_t newconfig)
device configuration
Definition sinic.cc:562
struct gem5::sinic::Device::@349 regs
device register file
bool recvPacket(EthPacketPtr packet)
device ethernet interface
Definition sinic.cc:1149
void devIntrPost(uint32_t interrupts)
Interrupt management.
Definition sinic.cc:404
void rxDump() const
uint32_t RxFifoLow
Definition sinic.hh:126
EventFunctionWrapper txDmaEvent
Definition sinic.hh:250
void devIntrChangeMask(uint32_t newmask)
Definition sinic.cc:456
uint32_t RxMaxCopy
Definition sinic.hh:118
void txEventTransmit()
Definition sinic.hh:211
void prepareWrite(ContextID cpu, int index)
Definition sinic.cc:190
uint32_t VirtualCount
Definition sinic.hh:122
unsigned rxDmaLen
Definition sinic.hh:186
void rxDmaDone()
DMA parameters.
Definition sinic.cc:674
RxState
Receive State Machine States.
Definition sinic.hh:93
uint64_t TxData
Definition sinic.hh:133
uint8_t * txDmaData
Definition sinic.hh:195
uint64_t RxWait
Definition sinic.hh:132
PacketFifo rxFifo
Definition sinic.hh:180
uint8_t * rxDmaData
Definition sinic.hh:185
uint32_t RxFifoHigh
Definition sinic.hh:128
Tick read(PacketPtr pkt) override
Memory Interface.
Definition sinic.cc:199
uint32_t RxMaxIntr
Definition sinic.hh:123
uint8_t & regData8(Addr daddr)
Definition sinic.hh:174
uint32_t IntrStatus
Definition sinic.hh:116
uint32_t TxMaxCopy
Definition sinic.hh:119
uint64_t RxDone
Definition sinic.hh:131
uint32_t Config
Definition sinic.hh:114
Device(const Params &p)
Definition sinic.cc:84
uint32_t Command
Definition sinic.hh:115
TxState
Transmit State Machine states.
Definition sinic.hh:103
uint32_t TxFifoHigh
Definition sinic.hh:129
EventFunctionWrapper rxDmaEvent
Definition sinic.hh:247
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition sinic.cc:1362
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition sinic.cc:1247
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Definition sinic.cc:127
PacketFifo txFifo
Definition sinic.hh:189
uint32_t ZeroCopySize
Definition sinic.hh:120
uint64_t TxWait
Definition sinic.hh:135
void command(uint32_t command)
Definition sinic.cc:594
void resetStats() override
Callback to reset stats.
Definition sinic.cc:119
std::list< unsigned > VirtualList
Definition sinic.hh:161
virtual void drainResume() override
Resume execution after a successful drain.
Definition sinic.cc:1187
uint64_t TxDone
Definition sinic.hh:134
gem5::sinic::Device::DeviceStats sinicDeviceStats
uint32_t TxFifoLow
Definition sinic.hh:127
uint32_t & regData32(Addr daddr)
Definition sinic.hh:175
std::vector< VirtualReg > VirtualRegs
Definition sinic.hh:160
void prepareIO(ContextID cpu, int index)
Definition sinic.cc:136
uint64_t HwAddr
Definition sinic.hh:136
VirtualList rxList
Definition sinic.hh:165
void devIntrClear(uint32_t interrupts=registers::Intr_All)
Definition sinic.cc:440
VirtualRegs virtualRegs
Definition sinic.hh:164
uint32_t ZeroCopyMark
Definition sinic.hh:121
virtual bool recvPacket(EthPacketPtr pkt)
Definition sinic.hh:323
virtual void sendDone()
Definition sinic.hh:324
Interface(const std::string &name, Device *d)
Definition sinic.hh:319
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
Base Ethernet Device declaration.
Bitfield< 9 > d
Definition misc_types.hh:64
Bitfield< 30, 0 > index
Bitfield< 0 > p
double Counter
All counters are of 64-bit values.
Definition types.hh:46
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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
std::shared_ptr< EthPacketData > EthPacketPtr
Definition etherpkt.hh:90
Declaration of Statistics objects.
statistics::Scalar totalVnicDistance
Definition sinic.hh:286
statistics::Scalar maxVnicDistance
Definition sinic.hh:288
statistics::Scalar numVnicDistance
Definition sinic.hh:287
DeviceStats(statistics::Group *parent)
Definition sinic.cc:103
statistics::Formula avgVnicDistance
Definition sinic.hh:289
PacketFifo::iterator rxIndex
Definition sinic.hh:147

Generated on Tue Jun 18 2024 16:24:03 for gem5 by doxygen 1.11.0