gem5 v24.0.0.0
Loading...
Searching...
No Matches
pm4_packet_processor.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Advanced Micro Devices, Inc.
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 met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 */
32
33#ifndef __DEV_AMDGPU_PM4_PACKET_PROCESSOR__
34#define __DEV_AMDGPU_PM4_PACKET_PROCESSOR__
35
36#include <unordered_map>
37
42#include "params/PM4PacketProcessor.hh"
43
44namespace gem5
45{
46
47class AMDGPUDevice;
48
49
50
51
53{
55 /* First graphics queue */
58 /* First compute queue */
61
62 /* All PM4 queues, indexed by VMID */
63 std::unordered_map<uint16_t, PM4Queue *> queues;
64 /* A map of PM4 queues based on doorbell offset */
65 std::unordered_map<uint32_t, PM4Queue *> queuesMap;
66
67 int _ipId;
69
70 public:
71 PM4PacketProcessor(const PM4PacketProcessorParams &p);
72
73 void setGPUDevice(AMDGPUDevice *gpu_device);
74
78 Tick write(PacketPtr pkt) override { return 0; }
79 Tick read(PacketPtr pkt) override { return 0; }
80 AddrRangeList getAddrRanges() const override;
81 void serialize(CheckpointOut &cp) const override;
82 void unserialize(CheckpointIn &cp) override;
83
88
89 uint32_t getKiqDoorbellOffset() { return kiq.doorbell & 0x1ffffffc; }
90 uint32_t getPqDoorbellOffset() { return pq.doorbellOffset; }
91
93
98 PM4Queue* getQueue(Addr offset, bool gfx = false);
104 void mapPq(Addr offset);
110 void mapKiq(Addr offset);
115 void newQueue(QueueDesc *q, Addr offset, PM4MapQueues *pkt = nullptr,
116 int id = -1);
117
122 void process(PM4Queue *q, Addr wptrOffset);
123
130 void updateReadIndex(Addr offset, uint64_t rd_idx);
131
135 void decodeNext(PM4Queue *q);
141
142 /* Methods that implement PM4 packets */
145 void mapQueues(PM4Queue *q, PM4MapQueues *pkt);
147 void doneMQDWrite(Addr mqdAddr, Addr addr);
148 void mapProcess(uint32_t pasid, uint64_t ptBase, uint32_t shMemBases);
152 uint16_t vmid);
154 SDMAQueueDesc *mqd, uint16_t vmid);
155 void releaseMem(PM4Queue *q, PM4ReleaseMem *pkt);
157 void runList(PM4Queue *q, PM4RunList *pkt);
159 void switchBuffer(PM4Queue *q, PM4SwitchBuf *pkt);
161 void waitRegMem(PM4Queue *q, PM4WaitRegMem *pkt);
164
165 /* Methods that implement MMIO regs */
166 void writeMMIO(PacketPtr pkt, Addr mmio_offset);
167
168 void setHqdVmid(uint32_t data);
169 void setHqdActive(uint32_t data);
170 void setHqdPqBase(uint32_t data);
171 void setHqdPqBaseHi(uint32_t data);
172 void setHqdPqDoorbellCtrl(uint32_t data);
173 void setHqdPqPtr(uint32_t data);
174 void setHqdPqWptrLo(uint32_t data);
175 void setHqdPqWptrHi(uint32_t data);
176 void setHqdPqRptrReportAddr(uint32_t data);
177 void setHqdPqRptrReportAddrHi(uint32_t data);
178 void setHqdPqWptrPollAddr(uint32_t data);
179 void setHqdPqWptrPollAddrHi(uint32_t data);
180 void setHqdPqControl(uint32_t data);
181 void setHqdIbCtrl(uint32_t data);
182 void setRbVmid(uint32_t data);
183 void setRbCntl(uint32_t data);
184 void setRbWptrLo(uint32_t data);
185 void setRbWptrHi(uint32_t data);
186 void setRbRptrAddrLo(uint32_t data);
187 void setRbRptrAddrHi(uint32_t data);
188 void setRbWptrPollAddrLo(uint32_t data);
189 void setRbWptrPollAddrHi(uint32_t data);
190 void setRbBaseLo(uint32_t data);
191 void setRbBaseHi(uint32_t data);
192 void setRbDoorbellCntrl(uint32_t data);
193 void setRbDoorbellRangeLo(uint32_t data);
194 void setRbDoorbellRangeHi(uint32_t data);
195
196 int getIpId() const { return _ipId; }
198};
199
200} // namespace gem5
201
202#endif //__DEV_AMDGPU_PM4_PACKET_PROCESSOR__
const char data[]
Device model for an AMD GPU.
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition addr_range.hh:82
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
void setRbWptrPollAddrLo(uint32_t data)
void decodeHeader(PM4Queue *q, PM4Header header)
This method calls other PM4 packet processing methods based on the header of a PM4 packet.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void mapKiq(Addr offset)
The first compute queue, the Kernel Interface Queueu a.k.a.
Addr getGARTAddr(Addr addr) const
void writeDataDone(PM4Queue *q, PM4WriteData *pkt, Addr addr)
void switchBuffer(PM4Queue *q, PM4SwitchBuf *pkt)
void setGPUDevice(AMDGPUDevice *gpu_device)
void serialize(CheckpointOut &cp) const override
Serialize an object.
void setHqdPqWptrLo(uint32_t data)
std::unordered_map< uint32_t, PM4Queue * > queuesMap
void setUconfigReg(PM4Queue *q, PM4SetUconfigReg *pkt)
Tick write(PacketPtr pkt) override
Inherited methods.
void queryStatus(PM4Queue *q, PM4QueryStatus *pkt)
void releaseMem(PM4Queue *q, PM4ReleaseMem *pkt)
void releaseMemDone(PM4Queue *q, PM4ReleaseMem *pkt, Addr addr)
void setHqdPqRptrReportAddr(uint32_t data)
void updateReadIndex(Addr offset, uint64_t rd_idx)
Update read index on doorbell rings.
void mapProcessV1(PM4Queue *q, PM4MapProcess *pkt)
void processSDMAMQD(PM4MapQueues *pkt, PM4Queue *q, Addr addr, SDMAQueueDesc *mqd, uint16_t vmid)
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void process(PM4Queue *q, Addr wptrOffset)
This method start processing a PM4Queue from the current read pointer to the newly communicated write...
void setHqdPqControl(uint32_t data)
void mapProcessV2(PM4Queue *q, PM4MapProcessV2 *pkt)
void setRbRptrAddrHi(uint32_t data)
void setHqdPqWptrPollAddr(uint32_t data)
void newQueue(QueueDesc *q, Addr offset, PM4MapQueues *pkt=nullptr, int id=-1)
This method creates a new PM4Queue based on a queue descriptor and an offset.
void unmapQueues(PM4Queue *q, PM4UnmapQueues *pkt)
void queryStatusDone(PM4Queue *q, PM4QueryStatus *pkt)
void mapProcess(uint32_t pasid, uint64_t ptBase, uint32_t shMemBases)
void setRbDoorbellRangeLo(uint32_t data)
void waitRegMem(PM4Queue *q, PM4WaitRegMem *pkt)
void setHqdPqBaseHi(uint32_t data)
void runList(PM4Queue *q, PM4RunList *pkt)
void decodeNext(PM4Queue *q)
This method decodes the next packet in a PM4Queue.
void mapPq(Addr offset)
The first graphics queue, the Primary Queueu a.k.a.
void writeData(PM4Queue *q, PM4WriteData *pkt, PM4Header header)
void setHqdPqDoorbellCtrl(uint32_t data)
void setRbDoorbellRangeHi(uint32_t data)
void doneMQDWrite(Addr mqdAddr, Addr addr)
std::unordered_map< uint16_t, PM4Queue * > queues
void indirectBuffer(PM4Queue *q, PM4IndirectBuf *pkt)
PM4PacketProcessor(const PM4PacketProcessorParams &p)
void setHqdPqRptrReportAddrHi(uint32_t data)
void mapQueues(PM4Queue *q, PM4MapQueues *pkt)
TranslationGenPtr translate(Addr vaddr, Addr size) override
Method for functional translation.
void processMQD(PM4MapQueues *pkt, PM4Queue *q, Addr addr, QueueDesc *mqd, uint16_t vmid)
void setRbRptrAddrLo(uint32_t data)
void setRbDoorbellCntrl(uint32_t data)
PM4Queue * getQueue(Addr offset, bool gfx=false)
Based on an offset communicated through doorbell write, the PM4PacketProcessor identifies which queue...
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
void setHqdPqWptrPollAddrHi(uint32_t data)
void setHqdPqWptrHi(uint32_t data)
void setRbWptrPollAddrHi(uint32_t data)
Class defining a PM4 queue.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
Bitfield< 27 > q
Definition misc_types.hh:55
Bitfield< 23, 0 > offset
Definition types.hh:144
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
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
Bitfield< 10 > pasid
Definition x86_cpu.cc:129
uint64_t Tick
Tick count type.
Definition types.hh:58
std::unique_ptr< TranslationGen > TranslationGenPtr
output header
Definition nop.cc:36
PM4 packets.
uint32_t doorbellOffset

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