gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
65  friend void IntrEvent::process();
68 
69  bool cpuIntrPending() const;
70  void cpuIntrAck() { cpuIntrClear(); }
71 
75  public:
76  void serialize(CheckpointOut &cp) const override;
77  void unserialize(CheckpointIn &cp) override;
78 
82  public:
83  typedef SinicParams Params;
84  const Params *params() const { return (const Params *)_params; }
85  Base(const Params *p);
86 };
87 
88 class Device : public Base
89 {
90  protected:
92  enum RxState {
98  };
99 
101  enum TxState {
107  };
108 
110  struct {
111  uint32_t Config; // 0x00
112  uint32_t Command; // 0x04
113  uint32_t IntrStatus; // 0x08
114  uint32_t IntrMask; // 0x0c
115  uint32_t RxMaxCopy; // 0x10
116  uint32_t TxMaxCopy; // 0x14
117  uint32_t ZeroCopySize; // 0x18
118  uint32_t ZeroCopyMark; // 0x1c
119  uint32_t VirtualCount; // 0x20
120  uint32_t RxMaxIntr; // 0x24
121  uint32_t RxFifoSize; // 0x28
122  uint32_t TxFifoSize; // 0x2c
123  uint32_t RxFifoLow; // 0x30
124  uint32_t TxFifoLow; // 0x34
125  uint32_t RxFifoHigh; // 0x38
126  uint32_t TxFifoHigh; // 0x3c
127  uint64_t RxData; // 0x40
128  uint64_t RxDone; // 0x48
129  uint64_t RxWait; // 0x50
130  uint64_t TxData; // 0x58
131  uint64_t TxDone; // 0x60
132  uint64_t TxWait; // 0x68
133  uint64_t HwAddr; // 0x70
134  uint64_t RxStatus; // 0x78
135  } regs;
136 
137  struct VirtualReg {
138  uint64_t RxData;
139  uint64_t RxDone;
140  uint64_t TxData;
141  uint64_t TxDone;
142 
144  unsigned rxPacketOffset;
145  unsigned rxPacketBytes;
146  uint64_t rxDoneData;
147 
150 
152  : RxData(0), RxDone(0), TxData(0), TxDone(0),
154  { }
155  };
163  int rxActive;
165 
169 
170  uint8_t &regData8(Addr daddr) { return *((uint8_t *)&regs + daddr); }
171  uint32_t &regData32(Addr daddr) { return *(uint32_t *)&regData8(daddr); }
172  uint64_t &regData64(Addr daddr) { return *(uint64_t *)&regData8(daddr); }
173 
174  protected:
178  bool rxEmpty;
179  bool rxLow;
181  uint8_t *rxDmaData;
182  unsigned rxDmaLen;
183 
186  bool txFull;
191  uint8_t *txDmaData;
192  int txDmaLen;
193 
194  protected:
195  void reset();
196 
197  void rxKick();
200  friend void RxKickEvent::process();
201 
202  void txKick();
205  friend void TxKickEvent::process();
206 
210  void transmit();
212  {
213  transmit();
214  if (txState == txFifoBlock)
215  txKick();
216  }
218  friend void TxEvent::process();
220 
221  void txDump() const;
222  void rxDump() const;
223 
227  bool rxFilter(const EthPacketPtr &packet);
228 
232  void changeConfig(uint32_t newconfig);
233  void command(uint32_t command);
234 
238  public:
239  bool recvPacket(EthPacketPtr packet);
240  void transferDone();
241  EtherInt *getEthPort(const std::string &if_name, int idx) override;
242 
246  protected:
247  void rxDmaDone();
250 
251  void txDmaDone();
254 
259 
263  protected:
264  void devIntrPost(uint32_t interrupts);
265  void devIntrClear(uint32_t interrupts = Regs::Intr_All);
266  void devIntrChangeMask(uint32_t newmask);
267 
271  public:
272  Tick read(PacketPtr pkt) override;
273  Tick write(PacketPtr pkt) override;
274  virtual void drainResume() override;
275 
276  void prepareIO(ContextID cpu, int index);
277  void prepareRead(ContextID cpu, int index);
278  void prepareWrite(ContextID cpu, int index);
279  // Fault iprRead(Addr daddr, ContextID cpu, uint64_t &result);
280 
284  private:
289 
291 
292  public:
293  void regStats() override;
294  void resetStats() override;
295 
299  public:
300  void serialize(CheckpointOut &cp) const override;
301  void unserialize(CheckpointIn &cp) override;
302 
303  public:
304  Device(const Params *p);
305  ~Device();
306 };
307 
308 /*
309  * Ethernet Interface for an Ethernet Device
310  */
311 class Interface : public EtherInt
312 {
313  private:
315 
316  public:
317  Interface(const std::string &name, Device *d)
318  : EtherInt(name), dev(d)
319  { }
320 
321  virtual bool recvPacket(EthPacketPtr pkt) { return dev->recvPacket(pkt); }
322  virtual void sendDone() { dev->transferDone(); }
323 };
324 
325 } // namespace Sinic
326 
327 #endif // __DEV_NET_SINIC_HH__
void reset()
Definition: sinic.cc:631
void process()
Definition: eventq.hh:812
uint32_t RxFifoHigh
Definition: sinic.hh:125
uint64_t TxDone
Definition: sinic.hh:131
Tick dmaReadFactor
Definition: sinic.hh:256
Base(const Params *p)
Definition: sinic.cc:82
EventWrapper< Device,&Device::rxDmaDone > rxDmaEvent
Definition: sinic.hh:249
int txPacketOffset
Definition: sinic.hh:188
Bitfield< 30, 0 > index
uint32_t VirtualCount
Definition: sinic.hh:119
Counter rxUnique
Definition: sinic.hh:158
virtual void sendDone()
Definition: sinic.hh:322
void transferDone()
Definition: sinic.cc:1151
PacketFifo::iterator rxFifoPtr
Definition: sinic.hh:177
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sinic.cc:1421
uint32_t TxFifoSize
Definition: sinic.hh:122
Dummy class to keep the Python class hierarchy in sync with the C++ object hierarchy.
Definition: etherdevice.hh:134
void devIntrPost(uint32_t interrupts)
Interrupt management.
Definition: sinic.cc:433
void txDmaDone()
Definition: sinic.cc:971
TxState
Transmit State Machine states.
Definition: sinic.hh:101
RxState rxState
Definition: sinic.hh:175
void prepareRead(ContextID cpu, int index)
Definition: sinic.cc:170
uint8_t * txDmaData
Definition: sinic.hh:191
uint8_t * rxDmaData
Definition: sinic.hh:181
void transmit()
Retransmit event.
Definition: sinic.cc:987
SinicParams Params
Construction/Destruction/Parameters.
Definition: sinic.hh:83
struct Sinic::Device::@70 regs
device register file
Counter txUnique
Definition: sinic.hh:159
int rxDirtyCount
Definition: sinic.hh:168
int rxMappedCount
Definition: sinic.hh:167
uint64_t TxWait
Definition: sinic.hh:132
void cpuIntrPost(Tick when)
Definition: sinic.cc:503
Tick dmaWriteDelay
Definition: sinic.hh:257
uint64_t RxWait
Definition: sinic.hh:129
void regStats() override
Register statistics for this object.
Definition: sinic.cc:107
unsigned rxDmaLen
Definition: sinic.hh:182
std::list< unsigned > VirtualList
Definition: sinic.hh:157
PacketFifo txFifo
Definition: sinic.hh:185
Addr rxDmaAddr
Definition: sinic.hh:180
int _maxVnicDistance
Definition: sinic.hh:290
virtual bool recvPacket(EthPacketPtr pkt)
Definition: sinic.hh:321
uint32_t TxMaxCopy
Definition: sinic.hh:116
uint32_t RxMaxIntr
Definition: sinic.hh:120
EventWrapper< Device,&Device::rxKick > RxKickEvent
Definition: sinic.hh:199
void command(uint32_t command)
Definition: sinic.cc:621
void txDump() const
Stats::Scalar maxVnicDistance
Definition: sinic.hh:287
uint32_t IntrStatus
Definition: sinic.hh:113
Declaration of Statistics objects.
uint32_t Command
Definition: sinic.hh:112
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
uint64_t RxData
Definition: sinic.hh:127
bool rxEnable
Definition: sinic.hh:52
bool txFull
Definition: sinic.hh:186
uint32_t ZeroCopyMark
Definition: sinic.hh:118
Tick rxKickTick
Definition: sinic.hh:198
EthPacketPtr txPacket
Definition: sinic.hh:187
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition: sinic.cc:1262
bool txEnable
Definition: sinic.hh:53
VirtualRegs virtualRegs
Definition: sinic.hh:160
uint64_t HwAddr
Definition: sinic.hh:133
bool rxFilter(const EthPacketPtr &packet)
receive address filter
Definition: sinic.cc:1164
uint64_t & regData64(Addr daddr)
Definition: sinic.hh:172
void rxKick()
Definition: sinic.cc:717
EtherInt * getEthPort(const std::string &if_name, int idx) override
Additional function to return the Port of a memory object.
Definition: sinic.cc:144
DmaDeviceParams Params
Definition: dma_device.hh:160
uint64_t Tick
Tick count type.
Definition: types.hh:63
bool cpuPendingIntr
Definition: sinic.hh:59
void prepareIO(ContextID cpu, int index)
Definition: sinic.cc:157
Stats::Scalar numVnicDistance
Definition: sinic.hh:286
TxEvent txEvent
Definition: sinic.hh:219
uint32_t TxFifoHigh
Definition: sinic.hh:126
uint64_t RxStatus
Definition: sinic.hh:134
Bitfield< 9 > d
Definition: miscregs.hh:1375
uint32_t Config
Definition: sinic.hh:111
Tick read(PacketPtr pkt) override
Memory Interface.
Definition: sinic.cc:220
Addr txDmaAddr
Definition: sinic.hh:190
Stats::Formula avgVnicDistance
Definition: sinic.hh:288
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: sinic.cc:1283
void resetStats() override
Reset statistics associated with this object.
Definition: sinic.cc:136
Interface(const std::string &name, Device *d)
Definition: sinic.hh:317
std::shared_ptr< EthPacketData > EthPacketPtr
Definition: etherpkt.hh:90
Device * dev
Definition: sinic.hh:314
VirtualList rxList
Definition: sinic.hh:161
void rxDmaDone()
DMA parameters.
Definition: sinic.cc:701
PacketFifo rxFifo
Definition: sinic.hh:176
void devIntrClear(uint32_t interrupts=Regs::Intr_All)
Definition: sinic.cc:469
void rxDump() const
int txDmaLen
Definition: sinic.hh:192
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
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:245
bool recvPacket(EthPacketPtr packet)
device ethernet interface
Definition: sinic.cc:1209
uint8_t & regData8(Addr daddr)
Definition: sinic.hh:170
Interface * interface
Definition: sinic.hh:67
void cpuIntrAck()
Definition: sinic.hh:70
Base Ethernet Device declaration.
Stats::Scalar totalVnicDistance
Statistics.
Definition: sinic.hh:285
A formula for statistics that is calculated when printed.
Definition: statistics.hh:2895
uint32_t ZeroCopySize
Definition: sinic.hh:117
uint32_t & regData32(Addr daddr)
Definition: sinic.hh:171
Tick write(PacketPtr pkt) override
IPR read of device register.
Definition: sinic.cc:305
void txKick()
Definition: sinic.cc:1033
bool cpuIntrPending() const
Definition: sinic.cc:585
Tick dmaReadDelay
Definition: sinic.hh:255
bool rxLow
Definition: sinic.hh:179
IntrEvent * intrEvent
Definition: sinic.hh:66
uint32_t RxMaxCopy
Definition: sinic.hh:115
void txEventTransmit()
Definition: sinic.hh:211
std::ostream CheckpointOut
Definition: serialize.hh:67
EventWrapper< Device,&Device::txKick > TxKickEvent
Definition: sinic.hh:204
uint32_t RxFifoSize
Definition: sinic.hh:121
fifo_list::iterator iterator
Definition: pktfifo.hh:83
void prepareWrite(ContextID cpu, int index)
Definition: sinic.cc:211
void changeConfig(uint32_t newconfig)
device configuration
Definition: sinic.cc:589
Tick intrDelay
Definition: sinic.hh:56
EventWrapper< Device,&Device::txEventTransmit > TxEvent
Definition: sinic.hh:217
uint64_t RxDone
Definition: sinic.hh:128
bool rxEmpty
Definition: sinic.hh:178
int rxBusyCount
Definition: sinic.hh:166
const SimObjectParams * _params
Cached copy of the object parameters.
Definition: sim_object.hh:107
VirtualList txList
Definition: sinic.hh:164
Tick txKickTick
Definition: sinic.hh:203
PacketFifo::iterator rxIndex
Definition: sinic.hh:143
void devIntrChangeMask(uint32_t newmask)
Definition: sinic.cc:485
Tick dmaWriteFactor
Definition: sinic.hh:258
const std::string & name() const
Return port name (for DPRINTF).
Definition: etherint.hh:60
Tick intrTick
Definition: sinic.hh:57
int txPacketBytes
Definition: sinic.hh:189
RxState
Receive State Machine States.
Definition: sinic.hh:92
void cpuInterrupt()
Definition: sinic.cc:543
virtual void drainResume() override
Resume execution after a successful drain.
Definition: sinic.cc:1247
std::vector< VirtualReg > VirtualRegs
Definition: sinic.hh:156
void cpuIntrClear()
Definition: sinic.cc:566
Device(const Params *p)
Definition: sinic.cc:89
uint64_t TxData
Definition: sinic.hh:130
VirtualList rxBusy
Definition: sinic.hh:162
TxState txState
Definition: sinic.hh:184
uint32_t IntrMask
Definition: sinic.hh:114
Bitfield< 0 > p
uint32_t TxFifoLow
Definition: sinic.hh:124
const Params * params() const
Definition: sinic.hh:84
int ContextID
Globally unique thread context ID.
Definition: types.hh:175
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Definition: sinic.cc:1306
EventWrapper< Base,&Base::cpuInterrupt > IntrEvent
Definition: sinic.hh:64
bool cpuIntrEnable
Definition: sinic.hh:58
EventWrapper< Device,&Device::txDmaDone > txDmaEvent
Definition: sinic.hh:253
int rxActive
Definition: sinic.hh:163
uint32_t RxFifoLow
Definition: sinic.hh:123

Generated on Fri Jun 9 2017 13:03:46 for gem5 by doxygen 1.8.6