1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors 3 #pragma once 4 #include <nlohmann/json.hpp> 5 6 namespace resource 7 { 8 // clang-format off 9 10 enum class State{ 11 Invalid, 12 Enabled, 13 Disabled, 14 StandbyOffline, 15 StandbySpare, 16 InTest, 17 Starting, 18 Absent, 19 UnavailableOffline, 20 Deferring, 21 Quiesced, 22 Updating, 23 Qualified, 24 Degraded, 25 }; 26 27 enum class Health{ 28 Invalid, 29 OK, 30 Warning, 31 Critical, 32 }; 33 34 enum class ResetType{ 35 Invalid, 36 On, 37 ForceOff, 38 GracefulShutdown, 39 GracefulRestart, 40 ForceRestart, 41 Nmi, 42 ForceOn, 43 PushPowerButton, 44 PowerCycle, 45 Suspend, 46 Pause, 47 Resume, 48 FullPowerCycle, 49 }; 50 51 enum class IndicatorLED{ 52 Invalid, 53 Lit, 54 Blinking, 55 Off, 56 }; 57 58 enum class PowerState{ 59 Invalid, 60 On, 61 Off, 62 PoweringOn, 63 PoweringOff, 64 Paused, 65 }; 66 67 enum class DurableNameFormat{ 68 Invalid, 69 NAA, 70 iQN, 71 FC_WWN, 72 UUID, 73 EUI, 74 NQN, 75 NSID, 76 NGUID, 77 MACAddress, 78 GCXLID, 79 }; 80 81 enum class RackUnits{ 82 Invalid, 83 OpenU, 84 EIA_310, 85 }; 86 87 enum class LocationType{ 88 Invalid, 89 Slot, 90 Bay, 91 Connector, 92 Socket, 93 Backplane, 94 Embedded, 95 }; 96 97 enum class Reference{ 98 Invalid, 99 Top, 100 Bottom, 101 Front, 102 Rear, 103 Left, 104 Right, 105 Middle, 106 }; 107 108 enum class Orientation{ 109 Invalid, 110 FrontToBack, 111 BackToFront, 112 TopToBottom, 113 BottomToTop, 114 LeftToRight, 115 RightToLeft, 116 }; 117 118 NLOHMANN_JSON_SERIALIZE_ENUM(State, { 119 {State::Invalid, "Invalid"}, 120 {State::Enabled, "Enabled"}, 121 {State::Disabled, "Disabled"}, 122 {State::StandbyOffline, "StandbyOffline"}, 123 {State::StandbySpare, "StandbySpare"}, 124 {State::InTest, "InTest"}, 125 {State::Starting, "Starting"}, 126 {State::Absent, "Absent"}, 127 {State::UnavailableOffline, "UnavailableOffline"}, 128 {State::Deferring, "Deferring"}, 129 {State::Quiesced, "Quiesced"}, 130 {State::Updating, "Updating"}, 131 {State::Qualified, "Qualified"}, 132 {State::Degraded, "Degraded"}, 133 }); 134 135 NLOHMANN_JSON_SERIALIZE_ENUM(Health, { 136 {Health::Invalid, "Invalid"}, 137 {Health::OK, "OK"}, 138 {Health::Warning, "Warning"}, 139 {Health::Critical, "Critical"}, 140 }); 141 142 NLOHMANN_JSON_SERIALIZE_ENUM(ResetType, { 143 {ResetType::Invalid, "Invalid"}, 144 {ResetType::On, "On"}, 145 {ResetType::ForceOff, "ForceOff"}, 146 {ResetType::GracefulShutdown, "GracefulShutdown"}, 147 {ResetType::GracefulRestart, "GracefulRestart"}, 148 {ResetType::ForceRestart, "ForceRestart"}, 149 {ResetType::Nmi, "Nmi"}, 150 {ResetType::ForceOn, "ForceOn"}, 151 {ResetType::PushPowerButton, "PushPowerButton"}, 152 {ResetType::PowerCycle, "PowerCycle"}, 153 {ResetType::Suspend, "Suspend"}, 154 {ResetType::Pause, "Pause"}, 155 {ResetType::Resume, "Resume"}, 156 {ResetType::FullPowerCycle, "FullPowerCycle"}, 157 }); 158 159 NLOHMANN_JSON_SERIALIZE_ENUM(IndicatorLED, { 160 {IndicatorLED::Invalid, "Invalid"}, 161 {IndicatorLED::Lit, "Lit"}, 162 {IndicatorLED::Blinking, "Blinking"}, 163 {IndicatorLED::Off, "Off"}, 164 }); 165 166 NLOHMANN_JSON_SERIALIZE_ENUM(PowerState, { 167 {PowerState::Invalid, "Invalid"}, 168 {PowerState::On, "On"}, 169 {PowerState::Off, "Off"}, 170 {PowerState::PoweringOn, "PoweringOn"}, 171 {PowerState::PoweringOff, "PoweringOff"}, 172 {PowerState::Paused, "Paused"}, 173 }); 174 175 NLOHMANN_JSON_SERIALIZE_ENUM(DurableNameFormat, { 176 {DurableNameFormat::Invalid, "Invalid"}, 177 {DurableNameFormat::NAA, "NAA"}, 178 {DurableNameFormat::iQN, "iQN"}, 179 {DurableNameFormat::FC_WWN, "FC_WWN"}, 180 {DurableNameFormat::UUID, "UUID"}, 181 {DurableNameFormat::EUI, "EUI"}, 182 {DurableNameFormat::NQN, "NQN"}, 183 {DurableNameFormat::NSID, "NSID"}, 184 {DurableNameFormat::NGUID, "NGUID"}, 185 {DurableNameFormat::MACAddress, "MACAddress"}, 186 {DurableNameFormat::GCXLID, "GCXLID"}, 187 }); 188 189 NLOHMANN_JSON_SERIALIZE_ENUM(RackUnits, { 190 {RackUnits::Invalid, "Invalid"}, 191 {RackUnits::OpenU, "OpenU"}, 192 {RackUnits::EIA_310, "EIA_310"}, 193 }); 194 195 NLOHMANN_JSON_SERIALIZE_ENUM(LocationType, { 196 {LocationType::Invalid, "Invalid"}, 197 {LocationType::Slot, "Slot"}, 198 {LocationType::Bay, "Bay"}, 199 {LocationType::Connector, "Connector"}, 200 {LocationType::Socket, "Socket"}, 201 {LocationType::Backplane, "Backplane"}, 202 {LocationType::Embedded, "Embedded"}, 203 }); 204 205 NLOHMANN_JSON_SERIALIZE_ENUM(Reference, { 206 {Reference::Invalid, "Invalid"}, 207 {Reference::Top, "Top"}, 208 {Reference::Bottom, "Bottom"}, 209 {Reference::Front, "Front"}, 210 {Reference::Rear, "Rear"}, 211 {Reference::Left, "Left"}, 212 {Reference::Right, "Right"}, 213 {Reference::Middle, "Middle"}, 214 }); 215 216 NLOHMANN_JSON_SERIALIZE_ENUM(Orientation, { 217 {Orientation::Invalid, "Invalid"}, 218 {Orientation::FrontToBack, "FrontToBack"}, 219 {Orientation::BackToFront, "BackToFront"}, 220 {Orientation::TopToBottom, "TopToBottom"}, 221 {Orientation::BottomToTop, "BottomToTop"}, 222 {Orientation::LeftToRight, "LeftToRight"}, 223 {Orientation::RightToLeft, "RightToLeft"}, 224 }); 225 226 } 227 // clang-format on 228