gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hmc_controller.cc
Go to the documentation of this file.
1 #include "mem/hmc_controller.hh"
2 
3 #include "base/random.hh"
4 #include "debug/HMCController.hh"
5 
6 HMCController::HMCController(const HMCControllerParams* p) :
8  n_master_ports(p->port_master_connection_count),
9  rr_counter(0)
10 {
11  assert(p->port_slave_connection_count == 1);
12 }
13 
15 HMCControllerParams::create()
16 {
17  return new HMCController(this);
18 }
19 
20 // Since this module is a load distributor, all its master ports have the same
21 // range so we should keep only one of the ranges and ignore the others
23 {
24  if (master_port_id == 0)
25  {
26  gotAllAddrRanges = true;
27  BaseXBar::recvRangeChange(master_port_id);
28  }
29  else
30  gotAddrRanges[master_port_id] = true;
31 }
32 
34 {
35  int current_value = rr_counter;
36  rr_counter++;
38  rr_counter = 0;
39  return current_value;
40 }
41 
43 {
44  // determine the source port based on the id
45  SlavePort *src_port = slavePorts[slave_port_id];
46 
47  // we should never see express snoops on a non-coherent component
48  assert(!pkt->isExpressSnoop());
49 
50  // For now, this is a simple round robin counter, for distribution the
51  // load among the serial links
52  PortID master_port_id = rotate_counter();
53 
54  // test if the layer should be considered occupied for the current
55  // port
56  if (!reqLayers[master_port_id]->tryTiming(src_port)) {
57  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x BUSY\n",
58  src_port->name(), pkt->cmdString(), pkt->getAddr());
59  return false;
60  }
61 
62  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x\n",
63  src_port->name(), pkt->cmdString(), pkt->getAddr());
64 
65  // store size and command as they might be modified when
66  // forwarding the packet
67  unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
68  unsigned int pkt_cmd = pkt->cmdToIndex();
69 
70  // store the old header delay so we can restore it if needed
71  Tick old_header_delay = pkt->headerDelay;
72 
73  // a request sees the frontend and forward latency
74  Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
75 
76  // set the packet header and payload delay
77  calcPacketTiming(pkt, xbar_delay);
78 
79  // determine how long to be layer is busy
80  Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
81 
82  // before forwarding the packet (and possibly altering it),
83  // remember if we are expecting a response
84  const bool expect_response = pkt->needsResponse() &&
85  !pkt->cacheResponding();
86 
87  // since it is a normal request, attempt to send the packet
88  bool success = masterPorts[master_port_id]->sendTimingReq(pkt);
89 
90  if (!success) {
91  DPRINTF(HMCController, "recvTimingReq: src %s %s 0x%x RETRY\n",
92  src_port->name(), pkt->cmdString(), pkt->getAddr());
93 
94  // restore the header delay as it is additive
95  pkt->headerDelay = old_header_delay;
96 
97  // occupy until the header is sent
98  reqLayers[master_port_id]->failedTiming(src_port,
99  clockEdge(Cycles(1)));
100 
101  return false;
102  }
103 
104  // remember where to route the response to
105  if (expect_response) {
106  assert(routeTo.find(pkt->req) == routeTo.end());
107  routeTo[pkt->req] = slave_port_id;
108  }
109 
110  reqLayers[master_port_id]->succeededTiming(packetFinishTime);
111 
112  // stats updates
113  pktCount[slave_port_id][master_port_id]++;
114  pktSize[slave_port_id][master_port_id] += pkt_size;
115  transDist[pkt_cmd]++;
116 
117  return true;
118 }
#define DPRINTF(x,...)
Definition: trace.hh:212
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests and one for responses.
int rotate_counter()
Function for rotating the round robin counter.
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:99
HMCController declaration.
bool isExpressSnoop() const
Definition: packet.hh:601
bool hasData() const
Definition: packet.hh:521
std::unordered_map< RequestPtr, PortID > routeTo
Remember where request packets came from so that we can route responses to the appropriate port...
Definition: xbar.hh:330
A SlavePort is a specialisation of a port.
Definition: port.hh:331
int cmdToIndex() const
Return the index of this command.
Definition: packet.hh:500
std::vector< bool > gotAddrRanges
Remember for each of the master ports of the crossbar if we got an address range from the connected s...
Definition: xbar.hh:424
virtual bool recvTimingReq(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a Timing request packet.
virtual void recvRangeChange(PortID master_port_id)
Function called by the port when the crossbar is recieving a range change.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition: packet.hh:340
HMC Controller, in general, is responsible for translating the host protocol (AXI for example) to ser...
uint64_t Tick
Tick count type.
Definition: types.hh:63
Stats::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
Definition: xbar.hh:451
const RequestPtr req
A pointer to the original request.
Definition: packet.hh:304
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Definition: xbar.cc:109
bool needsResponse() const
Definition: packet.hh:516
bool cacheResponding() const
Definition: packet.hh:558
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition: packet.hh:358
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
const Cycles frontendLatency
Cycles of front-end pipeline including the delay to accept the request and to decode the address...
Definition: xbar.hh:314
HMCController(const HMCControllerParams *p)
bool gotAllAddrRanges
Definition: xbar.hh:425
A non-coherent crossbar connects a number of non-snooping masters and slaves, and routes the request ...
std::vector< MasterPort * > masterPorts
Definition: xbar.hh:429
Tick clockPeriod() const
std::vector< QueuedSlavePort * > slavePorts
The master and slave ports of the crossbar.
Definition: xbar.hh:428
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Definition: packet.hh:497
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
const Cycles forwardLatency
Cycles of forward latency.
Definition: xbar.hh:316
unsigned getSize() const
Definition: packet.hh:649
Bitfield< 0 > p
Stats::Vector2d pktSize
Definition: xbar.hh:453
virtual void recvRangeChange(PortID master_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: xbar.cc:364
Addr getAddr() const
Definition: packet.hh:639
Stats::Vector2d pktCount
Definition: xbar.hh:452

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