Files
rocm-systems/tests/kfdtest/src/SDMAPacket.hpp
T

145 lines
5.1 KiB
C++
Raw Normal View History

2018-07-23 14:45:44 -04:00
/*
* Copyright (C) 2014-2018 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
#ifndef __KFD_SDMA_PACKET__H__
#define __KFD_SDMA_PACKET__H__
#include "BasePacket.hpp"
#include "sdma_pkt_struct.h"
2018-08-14 09:52:31 -04:00
// @class SDMAPacket: Marks a group of all SDMA packets
2018-07-23 14:45:44 -04:00
class SDMAPacket : public BasePacket {
public:
SDMAPacket(void) {}
virtual ~SDMAPacket(void) {}
virtual PACKETTYPE PacketType() const { return PACKETTYPE_SDMA; }
};
class SDMAWriteDataPacket : public SDMAPacket {
public:
2018-08-14 09:52:31 -04:00
// Empty constructor, before using the packet call the init func
2018-07-23 14:45:44 -04:00
SDMAWriteDataPacket(void);
2018-08-14 09:52:31 -04:00
// This contructor will also init the packet, no need for additional calls
2018-07-23 14:45:44 -04:00
SDMAWriteDataPacket(void* destAddr, unsigned int data);
SDMAWriteDataPacket(void* destAddr, unsigned int ndw, void *data);
virtual ~SDMAWriteDataPacket(void);
2018-08-14 09:52:31 -04:00
// @returns Pointer to the packet
2018-07-23 14:45:44 -04:00
virtual const void *GetPacket() const { return packetData; }
2018-08-14 09:52:31 -04:00
// @breif Initialise the packet
2018-07-23 14:45:44 -04:00
void InitPacket(void* destAddr, unsigned int data);
void InitPacket(void* destAddr, unsigned int ndw, void *data);
2018-08-14 09:52:31 -04:00
// @returns Packet size in bytes
2018-07-23 14:45:44 -04:00
virtual unsigned int SizeInBytes() const { return packetSize; }
protected:
2018-08-14 09:52:31 -04:00
// SDMA_PKT_WRITE_UNTILED struct contains all the packet's data
2018-07-23 14:45:44 -04:00
SDMA_PKT_WRITE_UNTILED *packetData;
unsigned int packetSize;
};
class SDMACopyDataPacket : public SDMAPacket {
public:
2018-08-14 09:52:31 -04:00
// This contructor will also init the packet, no need for additional calls
2018-07-23 14:45:44 -04:00
SDMACopyDataPacket(void *dest, void *src, unsigned int size);
2018-08-02 17:13:26 +08:00
SDMACopyDataPacket(void *const dst[], void *src, int n, unsigned int surfsize);
2018-07-23 14:45:44 -04:00
virtual ~SDMACopyDataPacket(void);
2018-08-14 09:52:31 -04:00
// @returns Pointer to the packet
2018-07-23 14:45:44 -04:00
virtual const void *GetPacket() const { return packetData; }
2018-08-14 09:52:31 -04:00
// @returns Packet size in bytes
2018-07-23 14:45:44 -04:00
virtual unsigned int SizeInBytes() const { return packetSize; }
protected:
2018-08-14 09:52:31 -04:00
// SDMA_PKT_COPY_LINEAR struct contains all the packet's data
2018-07-23 14:45:44 -04:00
SDMA_PKT_COPY_LINEAR *packetData;
unsigned int packetSize;
};
class SDMAFillDataPacket : public SDMAPacket {
public:
2018-08-14 09:52:31 -04:00
// This contructor will also init the packet, no need for additional calls
2018-07-23 14:45:44 -04:00
SDMAFillDataPacket(void *dest, unsigned int data, unsigned int size);
virtual ~SDMAFillDataPacket(void);
2018-08-14 09:52:31 -04:00
// @returns Pointer to the packet
2018-07-23 14:45:44 -04:00
virtual const void *GetPacket() const { return m_PacketData; }
2018-08-14 09:52:31 -04:00
// @returns Packet size in bytes
2018-07-23 14:45:44 -04:00
virtual unsigned int SizeInBytes() const { return m_PacketSize; }
protected:
2018-08-14 09:52:31 -04:00
// SDMA_PKT_CONSTANT_FILL struct contains all the packet's data
2018-07-23 14:45:44 -04:00
SDMA_PKT_CONSTANT_FILL *m_PacketData;
unsigned int m_PacketSize;
};
class SDMAFencePacket : public SDMAPacket {
public:
2018-08-14 09:52:31 -04:00
// Empty constructor, before using the packet call the init func
2018-07-23 14:45:44 -04:00
SDMAFencePacket(void);
2018-08-14 09:52:31 -04:00
// This contructor will also init the packet, no need for additional calls
2018-07-23 14:45:44 -04:00
SDMAFencePacket(void* destAddr, unsigned int data);
virtual ~SDMAFencePacket(void);
2018-08-14 09:52:31 -04:00
// @returns Pointer to the packet
2018-07-23 14:45:44 -04:00
virtual const void *GetPacket() const { return &packetData; }
2018-08-14 09:52:31 -04:00
// @brief Initialise the packet
2018-07-23 14:45:44 -04:00
void InitPacket(void* destAddr, unsigned int data);
2018-08-14 09:52:31 -04:00
// @returns Packet size in bytes
2018-07-23 14:45:44 -04:00
virtual unsigned int SizeInBytes() const { return sizeof(SDMA_PKT_FENCE ); }
protected:
2018-08-14 09:52:31 -04:00
// SDMA_PKT_FENCE struct contains all the packet's data
2018-07-23 14:45:44 -04:00
SDMA_PKT_FENCE packetData;
};
class SDMATrapPacket : public SDMAPacket {
public:
2018-08-14 09:52:31 -04:00
// Empty constructor, before using the packet call the init func
2018-08-13 09:03:31 -04:00
explicit SDMATrapPacket(unsigned int eventID = 0);
2018-07-23 14:45:44 -04:00
virtual ~SDMATrapPacket(void);
2018-08-14 09:52:31 -04:00
// @returns Pointer to the packet
2018-07-23 14:45:44 -04:00
virtual const void *GetPacket() const { return &packetData; }
2018-08-14 09:52:31 -04:00
// @brief Initialise the packet
2018-07-23 14:45:44 -04:00
void InitPacket(unsigned int eventID);
2018-08-14 09:52:31 -04:00
// @returns Packet size in bytes
2018-07-23 14:45:44 -04:00
virtual unsigned int SizeInBytes() const { return sizeof(SDMA_PKT_TRAP); }
protected:
2018-08-14 09:52:31 -04:00
// SDMA_PKT_TRAP struct contains all the packet's data
2018-07-23 14:45:44 -04:00
SDMA_PKT_TRAP packetData;
};
#endif // __KFD_SDMA_PACKET__H__