blob: bf7bdbc5c4abbfe53818a4be1ea953f351d75db6 [file] [log] [blame]
Jim Flynn4e755a52020-03-29 17:48:26 +01001//
2// Copyright © 2020 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
8
9#include <armnn/utility/IgnoreUnused.hpp>
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000010#include "../../../profiling/common/include/TargetEndianess.hpp"
Jim Flynn4e755a52020-03-29 17:48:26 +010011
12#include <cstdint>
13#include <memory>
14#include <vector>
15
Jim Flynnbbfe6032020-07-20 16:57:44 +010016// forward declare to prevent a circular dependency
17namespace arm
18{
19namespace pipe
20{
Jim Flynnbbfe6032020-07-20 16:57:44 +010021
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000022class Packet;
Jim Flynn01d02812020-04-29 21:12:13 +010023
Jim Flynn01d02812020-04-29 21:12:13 +010024// the handlers need to be able to do two
25// things to service the FileOnlyProfilingConnection
26// and any other implementation of IProfilingConnection
27// set the endianness and write a packet back i.e.
28// return a packet and close the connection
29class IInternalProfilingConnection
30{
31public:
32 virtual ~IInternalProfilingConnection() {};
33
34 virtual void SetEndianess(const TargetEndianness& endianness) = 0;
35
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000036 virtual void ReturnPacket(Packet& packet) = 0;
Jim Flynn01d02812020-04-29 21:12:13 +010037
38 virtual void Close() = 0;
39};
Jim Flynn4e755a52020-03-29 17:48:26 +010040
41class ILocalPacketHandler
42{
43public:
44 virtual ~ILocalPacketHandler() {};
45
46 /// @return lists the headers of the packets that this handler accepts
47 /// only these packets will get sent to this handler.
48 /// If this function returns an empty list then ALL packets
49 /// will be sent to the PacketHandler i.e. a universal handler.
50 virtual std::vector<uint32_t> GetHeadersAccepted() = 0;
51
52 /// process the packet
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000053 virtual void HandlePacket(const Packet& packet) = 0;
Jim Flynn4e755a52020-03-29 17:48:26 +010054
55 /// Set a profiling connection on the handler. Only need to implement this
56 /// function if the handler will be writing data back to the profiled application.
Jim Flynn01d02812020-04-29 21:12:13 +010057 virtual void SetConnection(IInternalProfilingConnection* profilingConnection)
58 {armnn::IgnoreUnused(profilingConnection);}
Jim Flynn4e755a52020-03-29 17:48:26 +010059};
60
61using ILocalPacketHandlerPtr = std::unique_ptr<ILocalPacketHandler>;
62using ILocalPacketHandlerSharedPtr = std::shared_ptr<ILocalPacketHandler>;
63
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000064} // namespace pipe
Jim Flynn4e755a52020-03-29 17:48:26 +010065
Cathal Corbett5aa9fd72022-02-25 15:33:28 +000066} // namespace arm