Compute Graph Framework SDK Reference  5.22
IChannelPacket.hpp
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
31#ifndef DW_FRAMEWORK_ICHANNEL_PACKET_HPP_
32#define DW_FRAMEWORK_ICHANNEL_PACKET_HPP_
33
34#include <typeinfo>
35#include <cstddef>
38#include <nvscibuf.h>
39#include <nvscisync.h>
40#include <dwshared/dwfoundation/dw/core/language/Function.hpp>
41
42namespace dw
43{
44namespace framework
45{
46
56{
57public:
58 // Enable ownership via this interface
59 virtual ~IChannelPacket() = default;
60
65
73 {
74 public:
78 virtual uint8_t* getBuffer() = 0;
83 virtual size_t getBufferSize() = 0;
88 // coverity[autosar_cpp14_a2_10_5_violation]
89 virtual size_t serialize() = 0;
93 virtual void deserialize(size_t) = 0;
94 };
95
100 {
101 public:
106 virtual size_t getBufferSize() = 0;
111 virtual size_t getPoolIndex() = 0;
117 virtual void initializeFromMemory(void* ptr, size_t index) = 0;
121 virtual void pack() = 0;
125 virtual void unpack() = 0;
126 };
127
136 {
137 public:
144 virtual uint32_t getNumBuffers() const = 0;
154 virtual void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList& attrList) const = 0;
161 virtual void initializeFromNvSciBufObjs(dw::core::span<NvSciBufObj> bufs) = 0;
162
166 virtual void pack() = 0;
170 virtual void unpack() = 0;
171 };
172
191};
192
193// TODO(chale): this should be made private to the framework once external entities no longer create
194// Channel packets
196{
197public:
198 explicit ChannelPacketDefaultBase(size_t typeSize);
199
201
202protected:
204 std::unique_ptr<uint8_t[]> m_buffer;
206};
207
208// coverity[autosar_cpp14_a0_1_6_violation]
210{
211public:
212 explicit ChannelPacketDefault(size_t typeSize);
213
214 uint8_t* getBuffer() final;
215
216 size_t getBufferSize() final;
217
218 // coverity[autosar_cpp14_a2_10_5_violation]
219 size_t serialize() final;
220
221 void deserialize(size_t) final;
222};
223
224// coverity[autosar_cpp14_a0_1_6_violation]
226{
227 // coverity[autosar_cpp14_a0_1_1_violation]
228 // coverity[autosar_cpp14_a2_10_5_violation]
229 static constexpr char LOG_TAG[]{"ChannelRemoteShmemPacketDefault"};
230
231public:
233
234 size_t getBufferSize() final;
235
236 size_t getPoolIndex() final;
237
238 void initializeFromMemory(void* ptr, size_t index) final;
239
240 void pack() final;
241
242 void unpack() final;
243
245
246private:
247 size_t m_typeSize;
248 void* m_data;
249 size_t m_poolIndex;
250};
251
252// coverity[autosar_cpp14_a0_1_6_violation]
254{
255 // coverity[autosar_cpp14_a0_1_1_violation]
256 // coverity[autosar_cpp14_a2_10_5_violation]
257 static constexpr char LOG_TAG[]{"ChannelNvSciPacketDefault"};
258
259public:
260 explicit ChannelNvSciPacketDefault(size_t typeSize);
261
262 uint32_t getNumBuffers() const final;
263 void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList& attrList) const final;
264
265 void initializeFromNvSciBufObjs(dw::core::span<NvSciBufObj> bufs);
266
267 void pack() final;
268
269 void unpack() final;
270
272
273private:
274 void fillCpuPacketDataAttributes(NvSciBufAttrList& output) const;
275
276 size_t m_typeSize;
277 void* m_data;
278};
279
284{
285public:
286 virtual ~IChannelPacketFactory() = default;
287
295 // coverity[autosar_cpp14_a2_10_5_violation]
296 virtual std::unique_ptr<IChannelPacket> makePacket(const GenericDataReference& ref, ChannelType channelType) = 0;
297};
298// coverity[autosar_cpp14_a0_1_6_violation]
299using ChannelPacketFactoryPtr = std::shared_ptr<IChannelPacketFactory>;
300
301} // namespace framework
302} // namespace dw
303
304#endif // DW_FRAMEWORK_ICHANNEL_PACKET_HPP_
std::unique_ptr< uint8_t[]> m_buffer
virtual std::unique_ptr< IChannelPacket > makePacket(const GenericDataReference &ref, ChannelType channelType)=0
Make a packet.
virtual ~IChannelPacketFactory()=default
virtual void initializeFromNvSciBufObjs(dw::core::span< NvSciBufObj > bufs)=0
virtual uint32_t getNumBuffers() const =0
virtual void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList &attrList) const =0
virtual void initializeFromMemory(void *ptr, size_t index)=0
SocketCallbacks & getSocketCallbacks()
RemoteShmemCallbacks & getRemoteShmemCallbacks()
virtual GenericData getGenericData()=0
virtual ~IChannelPacket()=default
NvSciCallbacks & getNvSciCallbacks()
std::shared_ptr< IChannelPacketFactory > ChannelPacketFactoryPtr
Definition: Buffer.hpp:41