Prithvi Pai | bffaa11 | 2025-07-19 13:57:19 +0530 | [diff] [blame] | 1 | /* |
| 2 | * SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & |
| 3 | * AFFILIATES. All rights reserved. |
| 4 | * SPDX-License-Identifier: Apache-2.0 |
| 5 | */ |
| 6 | |
| 7 | #include "oemcommands.hpp" |
| 8 | |
| 9 | #include <ipmid/api.hpp> |
| 10 | #include <ipmid/types.hpp> |
| 11 | |
| 12 | #include <cstdint> |
| 13 | |
| 14 | void registerBootstrapCredentialsOemCommands() __attribute__((constructor)); |
| 15 | |
| 16 | namespace ipmi |
| 17 | { |
| 18 | ipmi::RspType<uint8_t, uint8_t> ipmiGetUsbVendorIdProductId(uint8_t type) |
| 19 | { |
| 20 | constexpr uint8_t descriptorVendorId = 1; |
| 21 | constexpr uint8_t descriptorProductId = 2; |
| 22 | |
| 23 | // IPMI OEM USB Linux Gadget info |
| 24 | constexpr uint16_t usbVendorId = 0x0525; |
| 25 | constexpr uint16_t usbProductId = 0xA4A2; |
| 26 | |
| 27 | if (type == descriptorVendorId) |
| 28 | { |
| 29 | return ipmi::responseSuccess(static_cast<uint8_t>(usbVendorId >> 8), |
| 30 | static_cast<uint8_t>(usbVendorId & 0xFF)); |
| 31 | } |
| 32 | else if (type == descriptorProductId) |
| 33 | { |
| 34 | return ipmi::responseSuccess(static_cast<uint8_t>(usbProductId >> 8), |
| 35 | static_cast<uint8_t>(usbProductId & 0xFF)); |
| 36 | } |
| 37 | return ipmi::responseInvalidFieldRequest(); |
| 38 | } |
| 39 | |
Prithvi Pai | 6bf35ee | 2025-07-24 12:05:10 +0530 | [diff] [blame^] | 40 | ipmi::RspType<ipmi::message::Payload> ipmiGetUsbSerialNumber() |
| 41 | { |
| 42 | static constexpr uint8_t usbSerialNumber = 0x00; |
| 43 | ipmi::message::Payload usbSerialNumberPayload; |
| 44 | usbSerialNumberPayload.pack(usbSerialNumber); |
| 45 | return ipmi::responseSuccess(usbSerialNumberPayload); |
| 46 | } |
| 47 | |
Prithvi Pai | bffaa11 | 2025-07-19 13:57:19 +0530 | [diff] [blame] | 48 | } // namespace ipmi |
| 49 | |
| 50 | void registerBootstrapCredentialsOemCommands() |
| 51 | { |
| 52 | ipmi::registerHandler( |
| 53 | ipmi::prioOemBase, ipmi::groupNvidia, |
| 54 | ipmi::bootstrap_credentials_oem::cmdGetUsbVendorIdProductId, |
| 55 | ipmi::Privilege::Admin, ipmi::ipmiGetUsbVendorIdProductId); |
Prithvi Pai | 6bf35ee | 2025-07-24 12:05:10 +0530 | [diff] [blame^] | 56 | |
| 57 | ipmi::registerHandler( |
| 58 | ipmi::prioOemBase, ipmi::groupNvidia, |
| 59 | ipmi::bootstrap_credentials_oem::cmdGetUsbSerialNumber, |
| 60 | ipmi::Privilege::Admin, ipmi::ipmiGetUsbSerialNumber); |
Prithvi Pai | bffaa11 | 2025-07-19 13:57:19 +0530 | [diff] [blame] | 61 | } |