diff --git a/src/gpu/OcpMctpVdm.cpp b/src/gpu/OcpMctpVdm.cpp
new file mode 100644
index 0000000..c6ede8f
--- /dev/null
+++ b/src/gpu/OcpMctpVdm.cpp
@@ -0,0 +1,90 @@
+/*
+ * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION &
+ * AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "OcpMctpVdm.hpp"
+
+#include <endian.h>
+
+#include <cstdint>
+#include <cstring>
+
+namespace ocp
+{
+namespace accelerator_management
+{
+
+CompletionCode packHeader(uint16_t pciVendorId, const BindingPciVidInfo& hdr,
+                          BindingPciVid& msg)
+{
+    if (hdr.ocp_accelerator_management_msg_type !=
+            static_cast<uint8_t>(MessageType::RESPONSE) &&
+        hdr.ocp_accelerator_management_msg_type !=
+            static_cast<uint8_t>(MessageType::REQUEST))
+    {
+        return CompletionCode::ERR_INVALID_DATA;
+    }
+
+    if (hdr.instance_id > instanceMax)
+    {
+        return CompletionCode::ERR_INVALID_DATA;
+    }
+
+    msg.datagram = 0;
+
+    msg.request = 0;
+    if (hdr.ocp_accelerator_management_msg_type ==
+        static_cast<uint8_t>(MessageType::REQUEST))
+    {
+        msg.request = 1;
+    }
+
+    msg.pci_vendor_id = htobe16(pciVendorId);
+    msg.reserved = 0;
+    msg.instance_id = hdr.instance_id;
+    msg.ocp_type = type;
+    msg.ocp_version = version;
+    msg.ocp_accelerator_management_msg_type = hdr.msg_type;
+
+    return CompletionCode::SUCCESS;
+}
+
+CompletionCode encodeReasonCode(uint8_t cc, uint16_t reasonCode,
+                                uint8_t commandCode, Message& msg)
+{
+    CommonNonSuccessResponse response{};
+    response.command = commandCode;
+    response.completion_code = cc;
+    reasonCode = htole16(reasonCode);
+    response.reason_code = reasonCode;
+
+    std::memcpy(&msg.data, &response, sizeof(response));
+
+    return CompletionCode::SUCCESS;
+}
+
+CompletionCode decodeReasonCodeAndCC(const Message& msg, size_t msgLen,
+                                     uint8_t& cc, uint16_t& reasonCode)
+{
+    CommonNonSuccessResponse response{};
+    std::memcpy(&response, &msg.data, sizeof(response));
+
+    cc = response.completion_code;
+    if (cc == static_cast<uint8_t>(CompletionCode::SUCCESS))
+    {
+        return CompletionCode::SUCCESS;
+    }
+
+    if (msgLen != (sizeof(BindingPciVid) + sizeof(CommonNonSuccessResponse)))
+    {
+        return CompletionCode::ERR_INVALID_DATA_LENGTH;
+    }
+
+    // reason code is expected to be present if CC != SUCCESS
+    reasonCode = le16toh(response.reason_code);
+
+    return CompletionCode::SUCCESS;
+}
+} // namespace accelerator_management
+} // namespace ocp
