1 // SPDX-License-Identifier: Apache-2.0 2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors 3 #pragma once 4 #include <nlohmann/json.hpp> 5 6 namespace port 7 { 8 // clang-format off 9 10 enum class PortType{ 11 Invalid, 12 UpstreamPort, 13 DownstreamPort, 14 InterswitchPort, 15 ManagementPort, 16 BidirectionalPort, 17 UnconfiguredPort, 18 }; 19 20 enum class PortMedium{ 21 Invalid, 22 Electrical, 23 Optical, 24 }; 25 26 enum class LinkState{ 27 Invalid, 28 Enabled, 29 Disabled, 30 }; 31 32 enum class LinkStatus{ 33 Invalid, 34 LinkUp, 35 Starting, 36 Training, 37 LinkDown, 38 NoLink, 39 }; 40 41 enum class LinkNetworkTechnology{ 42 Invalid, 43 Ethernet, 44 InfiniBand, 45 FibreChannel, 46 GenZ, 47 PCIe, 48 }; 49 50 enum class PortConnectionType{ 51 Invalid, 52 NotConnected, 53 NPort, 54 PointToPoint, 55 PrivateLoop, 56 PublicLoop, 57 Generic, 58 ExtenderFabric, 59 FPort, 60 EPort, 61 TEPort, 62 NPPort, 63 GPort, 64 NLPort, 65 FLPort, 66 EXPort, 67 UPort, 68 DPort, 69 }; 70 71 enum class SupportedEthernetCapabilities{ 72 Invalid, 73 WakeOnLAN, 74 EEE, 75 }; 76 77 enum class FlowControl{ 78 Invalid, 79 None, 80 TX, 81 RX, 82 TX_RX, 83 }; 84 85 enum class IEEE802IdSubtype{ 86 Invalid, 87 ChassisComp, 88 IfAlias, 89 PortComp, 90 MacAddr, 91 NetworkAddr, 92 IfName, 93 AgentId, 94 LocalAssign, 95 NotTransmitted, 96 }; 97 98 enum class SFPType{ 99 Invalid, 100 SFP, 101 SFPPlus, 102 SFP28, 103 cSFP, 104 SFPDD, 105 QSFP, 106 QSFPPlus, 107 QSFP14, 108 QSFP28, 109 QSFP56, 110 MiniSASHD, 111 QSFPDD, 112 OSFP, 113 }; 114 115 enum class MediumType{ 116 Invalid, 117 Copper, 118 FiberOptic, 119 }; 120 121 enum class FiberConnectionType{ 122 Invalid, 123 SingleMode, 124 MultiMode, 125 }; 126 127 enum class LLDPSystemCapabilities{ 128 Invalid, 129 None, 130 Bridge, 131 DOCSISCableDevice, 132 Other, 133 Repeater, 134 Router, 135 Station, 136 Telephone, 137 WLANAccessPoint, 138 }; 139 140 enum class CurrentPortConfigurationState{ 141 Invalid, 142 Disabled, 143 BindInProgress, 144 UnbindInProgress, 145 DSP, 146 USP, 147 Reserved, 148 FabricLink, 149 }; 150 151 enum class ConnectedDeviceMode{ 152 Invalid, 153 Disconnected, 154 RCD, 155 CXL68BFlitAndVH, 156 Standard256BFlit, 157 CXLLatencyOptimized256BFlit, 158 PBR, 159 }; 160 161 enum class ConnectedDeviceType{ 162 Invalid, 163 None, 164 PCIeDevice, 165 Type1, 166 Type2, 167 Type3SLD, 168 Type3MLD, 169 }; 170 171 enum class HostDeviceType{ 172 Invalid, 173 None, 174 System, 175 Manager, 176 }; 177 178 NLOHMANN_JSON_SERIALIZE_ENUM(PortType, { 179 {PortType::Invalid, "Invalid"}, 180 {PortType::UpstreamPort, "UpstreamPort"}, 181 {PortType::DownstreamPort, "DownstreamPort"}, 182 {PortType::InterswitchPort, "InterswitchPort"}, 183 {PortType::ManagementPort, "ManagementPort"}, 184 {PortType::BidirectionalPort, "BidirectionalPort"}, 185 {PortType::UnconfiguredPort, "UnconfiguredPort"}, 186 }); 187 188 NLOHMANN_JSON_SERIALIZE_ENUM(PortMedium, { 189 {PortMedium::Invalid, "Invalid"}, 190 {PortMedium::Electrical, "Electrical"}, 191 {PortMedium::Optical, "Optical"}, 192 }); 193 194 NLOHMANN_JSON_SERIALIZE_ENUM(LinkState, { 195 {LinkState::Invalid, "Invalid"}, 196 {LinkState::Enabled, "Enabled"}, 197 {LinkState::Disabled, "Disabled"}, 198 }); 199 200 NLOHMANN_JSON_SERIALIZE_ENUM(LinkStatus, { 201 {LinkStatus::Invalid, "Invalid"}, 202 {LinkStatus::LinkUp, "LinkUp"}, 203 {LinkStatus::Starting, "Starting"}, 204 {LinkStatus::Training, "Training"}, 205 {LinkStatus::LinkDown, "LinkDown"}, 206 {LinkStatus::NoLink, "NoLink"}, 207 }); 208 209 NLOHMANN_JSON_SERIALIZE_ENUM(LinkNetworkTechnology, { 210 {LinkNetworkTechnology::Invalid, "Invalid"}, 211 {LinkNetworkTechnology::Ethernet, "Ethernet"}, 212 {LinkNetworkTechnology::InfiniBand, "InfiniBand"}, 213 {LinkNetworkTechnology::FibreChannel, "FibreChannel"}, 214 {LinkNetworkTechnology::GenZ, "GenZ"}, 215 {LinkNetworkTechnology::PCIe, "PCIe"}, 216 }); 217 218 NLOHMANN_JSON_SERIALIZE_ENUM(PortConnectionType, { 219 {PortConnectionType::Invalid, "Invalid"}, 220 {PortConnectionType::NotConnected, "NotConnected"}, 221 {PortConnectionType::NPort, "NPort"}, 222 {PortConnectionType::PointToPoint, "PointToPoint"}, 223 {PortConnectionType::PrivateLoop, "PrivateLoop"}, 224 {PortConnectionType::PublicLoop, "PublicLoop"}, 225 {PortConnectionType::Generic, "Generic"}, 226 {PortConnectionType::ExtenderFabric, "ExtenderFabric"}, 227 {PortConnectionType::FPort, "FPort"}, 228 {PortConnectionType::EPort, "EPort"}, 229 {PortConnectionType::TEPort, "TEPort"}, 230 {PortConnectionType::NPPort, "NPPort"}, 231 {PortConnectionType::GPort, "GPort"}, 232 {PortConnectionType::NLPort, "NLPort"}, 233 {PortConnectionType::FLPort, "FLPort"}, 234 {PortConnectionType::EXPort, "EXPort"}, 235 {PortConnectionType::UPort, "UPort"}, 236 {PortConnectionType::DPort, "DPort"}, 237 }); 238 239 NLOHMANN_JSON_SERIALIZE_ENUM(SupportedEthernetCapabilities, { 240 {SupportedEthernetCapabilities::Invalid, "Invalid"}, 241 {SupportedEthernetCapabilities::WakeOnLAN, "WakeOnLAN"}, 242 {SupportedEthernetCapabilities::EEE, "EEE"}, 243 }); 244 245 NLOHMANN_JSON_SERIALIZE_ENUM(FlowControl, { 246 {FlowControl::Invalid, "Invalid"}, 247 {FlowControl::None, "None"}, 248 {FlowControl::TX, "TX"}, 249 {FlowControl::RX, "RX"}, 250 {FlowControl::TX_RX, "TX_RX"}, 251 }); 252 253 NLOHMANN_JSON_SERIALIZE_ENUM(IEEE802IdSubtype, { 254 {IEEE802IdSubtype::Invalid, "Invalid"}, 255 {IEEE802IdSubtype::ChassisComp, "ChassisComp"}, 256 {IEEE802IdSubtype::IfAlias, "IfAlias"}, 257 {IEEE802IdSubtype::PortComp, "PortComp"}, 258 {IEEE802IdSubtype::MacAddr, "MacAddr"}, 259 {IEEE802IdSubtype::NetworkAddr, "NetworkAddr"}, 260 {IEEE802IdSubtype::IfName, "IfName"}, 261 {IEEE802IdSubtype::AgentId, "AgentId"}, 262 {IEEE802IdSubtype::LocalAssign, "LocalAssign"}, 263 {IEEE802IdSubtype::NotTransmitted, "NotTransmitted"}, 264 }); 265 266 NLOHMANN_JSON_SERIALIZE_ENUM(SFPType, { 267 {SFPType::Invalid, "Invalid"}, 268 {SFPType::SFP, "SFP"}, 269 {SFPType::SFPPlus, "SFPPlus"}, 270 {SFPType::SFP28, "SFP28"}, 271 {SFPType::cSFP, "cSFP"}, 272 {SFPType::SFPDD, "SFPDD"}, 273 {SFPType::QSFP, "QSFP"}, 274 {SFPType::QSFPPlus, "QSFPPlus"}, 275 {SFPType::QSFP14, "QSFP14"}, 276 {SFPType::QSFP28, "QSFP28"}, 277 {SFPType::QSFP56, "QSFP56"}, 278 {SFPType::MiniSASHD, "MiniSASHD"}, 279 {SFPType::QSFPDD, "QSFPDD"}, 280 {SFPType::OSFP, "OSFP"}, 281 }); 282 283 NLOHMANN_JSON_SERIALIZE_ENUM(MediumType, { 284 {MediumType::Invalid, "Invalid"}, 285 {MediumType::Copper, "Copper"}, 286 {MediumType::FiberOptic, "FiberOptic"}, 287 }); 288 289 NLOHMANN_JSON_SERIALIZE_ENUM(FiberConnectionType, { 290 {FiberConnectionType::Invalid, "Invalid"}, 291 {FiberConnectionType::SingleMode, "SingleMode"}, 292 {FiberConnectionType::MultiMode, "MultiMode"}, 293 }); 294 295 NLOHMANN_JSON_SERIALIZE_ENUM(LLDPSystemCapabilities, { 296 {LLDPSystemCapabilities::Invalid, "Invalid"}, 297 {LLDPSystemCapabilities::None, "None"}, 298 {LLDPSystemCapabilities::Bridge, "Bridge"}, 299 {LLDPSystemCapabilities::DOCSISCableDevice, "DOCSISCableDevice"}, 300 {LLDPSystemCapabilities::Other, "Other"}, 301 {LLDPSystemCapabilities::Repeater, "Repeater"}, 302 {LLDPSystemCapabilities::Router, "Router"}, 303 {LLDPSystemCapabilities::Station, "Station"}, 304 {LLDPSystemCapabilities::Telephone, "Telephone"}, 305 {LLDPSystemCapabilities::WLANAccessPoint, "WLANAccessPoint"}, 306 }); 307 308 NLOHMANN_JSON_SERIALIZE_ENUM(CurrentPortConfigurationState, { 309 {CurrentPortConfigurationState::Invalid, "Invalid"}, 310 {CurrentPortConfigurationState::Disabled, "Disabled"}, 311 {CurrentPortConfigurationState::BindInProgress, "BindInProgress"}, 312 {CurrentPortConfigurationState::UnbindInProgress, "UnbindInProgress"}, 313 {CurrentPortConfigurationState::DSP, "DSP"}, 314 {CurrentPortConfigurationState::USP, "USP"}, 315 {CurrentPortConfigurationState::Reserved, "Reserved"}, 316 {CurrentPortConfigurationState::FabricLink, "FabricLink"}, 317 }); 318 319 NLOHMANN_JSON_SERIALIZE_ENUM(ConnectedDeviceMode, { 320 {ConnectedDeviceMode::Invalid, "Invalid"}, 321 {ConnectedDeviceMode::Disconnected, "Disconnected"}, 322 {ConnectedDeviceMode::RCD, "RCD"}, 323 {ConnectedDeviceMode::CXL68BFlitAndVH, "CXL68BFlitAndVH"}, 324 {ConnectedDeviceMode::Standard256BFlit, "Standard256BFlit"}, 325 {ConnectedDeviceMode::CXLLatencyOptimized256BFlit, "CXLLatencyOptimized256BFlit"}, 326 {ConnectedDeviceMode::PBR, "PBR"}, 327 }); 328 329 NLOHMANN_JSON_SERIALIZE_ENUM(ConnectedDeviceType, { 330 {ConnectedDeviceType::Invalid, "Invalid"}, 331 {ConnectedDeviceType::None, "None"}, 332 {ConnectedDeviceType::PCIeDevice, "PCIeDevice"}, 333 {ConnectedDeviceType::Type1, "Type1"}, 334 {ConnectedDeviceType::Type2, "Type2"}, 335 {ConnectedDeviceType::Type3SLD, "Type3SLD"}, 336 {ConnectedDeviceType::Type3MLD, "Type3MLD"}, 337 }); 338 339 NLOHMANN_JSON_SERIALIZE_ENUM(HostDeviceType, { 340 {HostDeviceType::Invalid, "Invalid"}, 341 {HostDeviceType::None, "None"}, 342 {HostDeviceType::System, "System"}, 343 {HostDeviceType::Manager, "Manager"}, 344 }); 345 346 } 347 // clang-format on 348