blob: 237b2b5cc17130a637da107efb3f77ce04247750 [file] [log] [blame]
Steve Foreman4f0d1de2021-09-20 14:06:32 -07001// Copyright 2022 Google LLC
Willy Tua2056e92021-10-10 13:36:16 -07002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070014
15#include "ipmi.hpp"
16
Brandon Kim93a4c0a2024-08-17 00:36:55 +000017#include "bios_setting.hpp"
Brandon Kim559cb012024-05-03 09:12:07 +000018#include "bm_instance.hpp"
Nikhil Namjoshi5e70dc82022-09-16 00:36:07 +000019#include "bmc_mode.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070020#include "cable.hpp"
Patrick Venture0e9aae52020-08-13 13:07:09 -070021#include "commands.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070022#include "cpld.hpp"
23#include "entity_name.hpp"
24#include "eth.hpp"
Willy Tu3b1b4272021-03-02 17:58:10 -080025#include "flash_size.hpp"
Steve Foreman4f0d1de2021-09-20 14:06:32 -070026#include "google_accel_oob.hpp"
Patrick Venture6d507442020-08-13 13:41:55 -070027#include "handler.hpp"
linyuny8cfa4c42021-06-16 13:53:08 -070028#include "host_power_off.hpp"
John Wediga92d0e62023-06-29 10:43:47 -070029#include "linux_boot_done.hpp"
William A. Kennington III29f35bc2020-11-03 23:30:31 -080030#include "machine_name.hpp"
Willy Tu6c71b0f2021-10-10 13:34:41 -070031#include "pcie_bifurcation.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070032#include "pcie_i2c.hpp"
33#include "psu.hpp"
34
35#include <ipmid/api.h>
36
Willy Tuff3cd8e2021-09-14 22:49:55 -070037#include <ipmid/api-types.hpp>
38#include <ipmid/message.hpp>
Michael Shen8d618532023-10-25 09:14:07 +000039#include <stdplus/print.hpp>
Patrick Williams444b5ea2023-05-19 13:56:42 -050040
41#include <cstdint>
42#include <cstdio>
Willy Tuff3cd8e2021-09-14 22:49:55 -070043#include <optional>
Willy Tub4e37042021-10-12 17:12:30 -070044#include <span>
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070045
46namespace google
47{
48namespace ipmi
49{
50
Gaurav Gandhid455bfd2024-01-29 22:32:27 -080051Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr ctx,
Willy Tub4e37042021-10-12 17:12:30 -070052 uint8_t cmd, std::span<const uint8_t> data)
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070053{
Willy Tuff3cd8e2021-09-14 22:49:55 -070054 switch (cmd)
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070055 {
Nikhil Namjoshi5e70dc82022-09-16 00:36:07 +000056 case SysGetBmcMode:
57 return getBmcMode(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070058 case SysCableCheck:
Willy Tuff3cd8e2021-09-14 22:49:55 -070059 return cableCheck(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070060 case SysCpldVersion:
Willy Tuff3cd8e2021-09-14 22:49:55 -070061 return cpldVersion(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070062 case SysGetEthDevice:
Willy Tuff3cd8e2021-09-14 22:49:55 -070063 return getEthDevice(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070064 case SysPsuHardReset:
Willy Tuff3cd8e2021-09-14 22:49:55 -070065 return psuHardReset(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070066 case SysPcieSlotCount:
Willy Tuff3cd8e2021-09-14 22:49:55 -070067 return pcieSlotCount(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070068 case SysPcieSlotI2cBusMapping:
Willy Tuff3cd8e2021-09-14 22:49:55 -070069 return pcieSlotI2cBusMapping(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070070 case SysEntityName:
Willy Tuff3cd8e2021-09-14 22:49:55 -070071 return getEntityName(data, handler);
William A. Kennington III29f35bc2020-11-03 23:30:31 -080072 case SysMachineName:
Willy Tuff3cd8e2021-09-14 22:49:55 -070073 return getMachineName(data, handler);
Shounak Mitraac4a16f2021-02-02 11:11:44 -080074 case SysPsuHardResetOnShutdown:
Willy Tuff3cd8e2021-09-14 22:49:55 -070075 return psuHardResetOnShutdown(data, handler);
Willy Tu3b1b4272021-03-02 17:58:10 -080076 case SysGetFlashSize:
Willy Tuff3cd8e2021-09-14 22:49:55 -070077 return getFlashSize(data, handler);
linyuny8cfa4c42021-06-16 13:53:08 -070078 case SysHostPowerOff:
Willy Tuff3cd8e2021-09-14 22:49:55 -070079 return hostPowerOff(data, handler);
Steve Foreman4f0d1de2021-09-20 14:06:32 -070080 case SysAccelOobDeviceCount:
81 return accelOobDeviceCount(data, handler);
82 case SysAccelOobDeviceName:
83 return accelOobDeviceName(data, handler);
84 case SysAccelOobRead:
85 return accelOobRead(data, handler);
86 case SysAccelOobWrite:
87 return accelOobWrite(data, handler);
Willy Tu6c71b0f2021-10-10 13:34:41 -070088 case SysPCIeSlotBifurcation:
89 return pcieBifurcation(data, handler);
John Wediga92d0e62023-06-29 10:43:47 -070090 case SysLinuxBootDone:
91 return linuxBootDone(data, handler);
Gaurav Gandhid455bfd2024-01-29 22:32:27 -080092 case SysGetAccelVrSettings:
93 return accelGetVrSettings(ctx, data, handler);
94 case SysSetAccelVrSettings:
95 return accelSetVrSettings(ctx, data, handler);
Brandon Kim559cb012024-05-03 09:12:07 +000096 case SysGetBMInstanceProperty:
97 return getBMInstanceProperty(data, handler);
Brandon Kim93a4c0a2024-08-17 00:36:55 +000098 case SysReadBiosSetting:
99 return readBiosSetting(data, handler);
Brandon Kime8929692024-08-19 22:00:36 +0000100 case SysWriteBiosSetting:
101 return writeBiosSetting(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -0700102 default:
Michael Shen8d618532023-10-25 09:14:07 +0000103 stdplus::print(stderr, "Invalid subcommand: {:#x}\n", cmd);
Willy Tuff3cd8e2021-09-14 22:49:55 -0700104 return ::ipmi::responseInvalidCommand();
Patrick Ventureeff1f2e2020-08-05 08:27:36 -0700105 }
106}
107
108} // namespace ipmi
109} // namespace google