Compute Graph Framework SDK Reference  5.16
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-2023 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] RFD Pending: TID-2053
89 virtual size_t serialize() = 0;
93 virtual void deserialize(size_t) = 0;
94 };
95
104 {
105 public:
112 virtual uint32_t getNumBuffers() const = 0;
122 virtual void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList& attrList) const = 0;
129 virtual void initializeFromNvSciBufObjs(dw::core::span<NvSciBufObj> bufs) = 0;
130
134 virtual void pack() = 0;
138 virtual void unpack() = 0;
139 };
140
153};
154
155// TODO(chale): this should be made private to the framework once external entities no longer create
156// Channel packets
158{
159public:
160 explicit ChannelPacketDefaultBase(size_t typeSize);
161
163
164protected:
166 std::unique_ptr<uint8_t[]> m_buffer;
168};
169
170// coverity[autosar_cpp14_a0_1_6_violation]
172{
173public:
174 explicit ChannelPacketDefault(size_t typeSize);
175
176 uint8_t* getBuffer() final;
177
178 size_t getBufferSize() final;
179
180 // coverity[autosar_cpp14_a2_10_5_violation] RFD Pending: TID-2053
181 size_t serialize() final;
182
183 void deserialize(size_t) final;
184};
185
186// coverity[autosar_cpp14_a0_1_6_violation]
188{
189 // coverity[autosar_cpp14_a0_1_1_violation]
190 // coverity[autosar_cpp14_a2_10_5_violation] RFD Pending: TID-2053
191 static constexpr char LOG_TAG[]{"ChannelNvSciPacketDefault"};
192
193public:
194 explicit ChannelNvSciPacketDefault(size_t typeSize);
195
196 uint32_t getNumBuffers() const final;
197 void fillNvSciBufAttributes(uint32_t bufferIndex, NvSciBufAttrList& attrList) const final;
198
199 void initializeFromNvSciBufObjs(dw::core::span<NvSciBufObj> bufs);
200
201 void pack() final;
202
203 void unpack() final;
204
206
207private:
208 void fillCpuPacketDataAttributes(NvSciBufAttrList& output) const;
209
210 size_t m_typeSize;
211 void* m_data;
212};
213
218{
219public:
220 virtual ~IChannelPacketFactory() = default;
221
229 // coverity[autosar_cpp14_a2_10_5_violation] RFD Pending: TID-2053
230 virtual std::unique_ptr<IChannelPacket> makePacket(const GenericDataReference& ref, ChannelType channelType) = 0;
231};
232// coverity[autosar_cpp14_a0_1_6_violation]
233using ChannelPacketFactoryPtr = std::shared_ptr<IChannelPacketFactory>;
234
235} // namespace framework
236} // namespace dw
237
238#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
SocketCallbacks & getSocketCallbacks()
virtual GenericData getGenericData()=0
virtual ~IChannelPacket()=default
NvSciCallbacks & getNvSciCallbacks()
std::shared_ptr< IChannelPacketFactory > ChannelPacketFactoryPtr
Definition: Buffer.hpp:40