blob: 5c0b916e4543de3d4beac85ba41fe3622628a96f [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 Kim559cb012024-05-03 09:12:07 +000017#include "bm_instance.hpp"
Nikhil Namjoshi5e70dc82022-09-16 00:36:07 +000018#include "bmc_mode.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070019#include "cable.hpp"
Patrick Venture0e9aae52020-08-13 13:07:09 -070020#include "commands.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070021#include "cpld.hpp"
22#include "entity_name.hpp"
23#include "eth.hpp"
Willy Tu3b1b4272021-03-02 17:58:10 -080024#include "flash_size.hpp"
Steve Foreman4f0d1de2021-09-20 14:06:32 -070025#include "google_accel_oob.hpp"
Patrick Venture6d507442020-08-13 13:41:55 -070026#include "handler.hpp"
linyuny8cfa4c42021-06-16 13:53:08 -070027#include "host_power_off.hpp"
John Wediga92d0e62023-06-29 10:43:47 -070028#include "linux_boot_done.hpp"
William A. Kennington III29f35bc2020-11-03 23:30:31 -080029#include "machine_name.hpp"
Willy Tu6c71b0f2021-10-10 13:34:41 -070030#include "pcie_bifurcation.hpp"
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070031#include "pcie_i2c.hpp"
32#include "psu.hpp"
33
34#include <ipmid/api.h>
35
Willy Tuff3cd8e2021-09-14 22:49:55 -070036#include <ipmid/api-types.hpp>
37#include <ipmid/message.hpp>
Michael Shen8d618532023-10-25 09:14:07 +000038#include <stdplus/print.hpp>
Patrick Williams444b5ea2023-05-19 13:56:42 -050039
40#include <cstdint>
41#include <cstdio>
Willy Tuff3cd8e2021-09-14 22:49:55 -070042#include <optional>
Willy Tub4e37042021-10-12 17:12:30 -070043#include <span>
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070044
45namespace google
46{
47namespace ipmi
48{
49
Gaurav Gandhid455bfd2024-01-29 22:32:27 -080050Resp handleSysCommand(HandlerInterface* handler, ::ipmi::Context::ptr ctx,
Willy Tub4e37042021-10-12 17:12:30 -070051 uint8_t cmd, std::span<const uint8_t> data)
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070052{
Willy Tuff3cd8e2021-09-14 22:49:55 -070053 switch (cmd)
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070054 {
Nikhil Namjoshi5e70dc82022-09-16 00:36:07 +000055 case SysGetBmcMode:
56 return getBmcMode(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070057 case SysCableCheck:
Willy Tuff3cd8e2021-09-14 22:49:55 -070058 return cableCheck(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070059 case SysCpldVersion:
Willy Tuff3cd8e2021-09-14 22:49:55 -070060 return cpldVersion(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070061 case SysGetEthDevice:
Willy Tuff3cd8e2021-09-14 22:49:55 -070062 return getEthDevice(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070063 case SysPsuHardReset:
Willy Tuff3cd8e2021-09-14 22:49:55 -070064 return psuHardReset(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070065 case SysPcieSlotCount:
Willy Tuff3cd8e2021-09-14 22:49:55 -070066 return pcieSlotCount(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070067 case SysPcieSlotI2cBusMapping:
Willy Tuff3cd8e2021-09-14 22:49:55 -070068 return pcieSlotI2cBusMapping(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070069 case SysEntityName:
Willy Tuff3cd8e2021-09-14 22:49:55 -070070 return getEntityName(data, handler);
William A. Kennington III29f35bc2020-11-03 23:30:31 -080071 case SysMachineName:
Willy Tuff3cd8e2021-09-14 22:49:55 -070072 return getMachineName(data, handler);
Shounak Mitraac4a16f2021-02-02 11:11:44 -080073 case SysPsuHardResetOnShutdown:
Willy Tuff3cd8e2021-09-14 22:49:55 -070074 return psuHardResetOnShutdown(data, handler);
Willy Tu3b1b4272021-03-02 17:58:10 -080075 case SysGetFlashSize:
Willy Tuff3cd8e2021-09-14 22:49:55 -070076 return getFlashSize(data, handler);
linyuny8cfa4c42021-06-16 13:53:08 -070077 case SysHostPowerOff:
Willy Tuff3cd8e2021-09-14 22:49:55 -070078 return hostPowerOff(data, handler);
Steve Foreman4f0d1de2021-09-20 14:06:32 -070079 case SysAccelOobDeviceCount:
80 return accelOobDeviceCount(data, handler);
81 case SysAccelOobDeviceName:
82 return accelOobDeviceName(data, handler);
83 case SysAccelOobRead:
84 return accelOobRead(data, handler);
85 case SysAccelOobWrite:
86 return accelOobWrite(data, handler);
Willy Tu6c71b0f2021-10-10 13:34:41 -070087 case SysPCIeSlotBifurcation:
88 return pcieBifurcation(data, handler);
John Wediga92d0e62023-06-29 10:43:47 -070089 case SysLinuxBootDone:
90 return linuxBootDone(data, handler);
Gaurav Gandhid455bfd2024-01-29 22:32:27 -080091 case SysGetAccelVrSettings:
92 return accelGetVrSettings(ctx, data, handler);
93 case SysSetAccelVrSettings:
94 return accelSetVrSettings(ctx, data, handler);
Brandon Kim559cb012024-05-03 09:12:07 +000095 case SysGetBMInstanceProperty:
96 return getBMInstanceProperty(data, handler);
Patrick Ventureeff1f2e2020-08-05 08:27:36 -070097 default:
Michael Shen8d618532023-10-25 09:14:07 +000098 stdplus::print(stderr, "Invalid subcommand: {:#x}\n", cmd);
Willy Tuff3cd8e2021-09-14 22:49:55 -070099 return ::ipmi::responseInvalidCommand();
Patrick Ventureeff1f2e2020-08-05 08:27:36 -0700100 }
101}
102
103} // namespace ipmi
104} // namespace google