blob: 4a78a10c82fb29cf9f644a1800b33af06a8441f5 [file] [log] [blame]
Jason M. Bills3f7c5e42018-10-03 14:00:41 -07001/*
2// Copyright (c) 2017 2018 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16
17#pragma once
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070018#include <phosphor-ipmi-host/sensorhandler.hpp>
19
James Feistfcd2d3a2020-05-28 10:38:15 -070020#include <cstdint>
21
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070022static constexpr uint8_t ipmiSdrVersion = 0x51;
23
Jason M. Billsc04e2e72018-11-28 15:15:56 -080024namespace intel_oem::ipmi::sel
25{
Jason M. Billsc04e2e72018-11-28 15:15:56 -080026static constexpr uint8_t selOperationSupport = 0x02;
27static constexpr uint8_t systemEvent = 0x02;
28static constexpr size_t systemEventSize = 3;
29static constexpr uint8_t oemTsEventFirst = 0xC0;
30static constexpr uint8_t oemTsEventLast = 0xDF;
31static constexpr size_t oemTsEventSize = 9;
32static constexpr uint8_t oemEventFirst = 0xE0;
33static constexpr uint8_t oemEventLast = 0xFF;
34static constexpr size_t oemEventSize = 13;
35static constexpr uint8_t eventMsgRev = 0x04;
36} // namespace intel_oem::ipmi::sel
37
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070038#pragma pack(push, 1)
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070039struct GetSDRReq
40{
41 uint16_t reservationID;
42 uint16_t recordID;
43 uint8_t offset;
44 uint8_t bytesToRead;
45};
46#pragma pack(pop)
47
48enum class SdrRepositoryInfoOps : uint8_t
49{
50 allocCommandSupported = 0x1,
51 reserveSDRRepositoryCommandSupported = 0x2,
52 partialAddSDRSupported = 0x4,
53 deleteSDRSupported = 0x8,
54 reserved = 0x10,
55 modalLSB = 0x20,
56 modalMSB = 0x40,
57 overflow = 0x80
58};
59
Jason M. Billse2d1aee2018-10-03 15:57:18 -070060enum class GetFRUAreaAccessType : uint8_t
61{
62 byte = 0x0,
63 words = 0x1
64};
65
Jason M. Bills3f7c5e42018-10-03 14:00:41 -070066enum class SensorUnits : uint8_t
67{
68 unspecified = 0x0,
69 degreesC = 0x1,
70 volts = 0x4,
71 amps = 0x5,
72 watts = 0x6,
73 rpm = 0x12,
74};
75
Jason M. Billse2d1aee2018-10-03 15:57:18 -070076#pragma pack(push, 1)
77struct FRUHeader
78{
79 uint8_t commonHeaderFormat;
80 uint8_t internalOffset;
81 uint8_t chassisOffset;
82 uint8_t boardOffset;
83 uint8_t productOffset;
84 uint8_t multiRecordOffset;
85 uint8_t pad;
86 uint8_t checksum;
87};
88#pragma pack(pop)
89
James Feist74c50c62019-08-14 14:18:41 -070090#pragma pack(push, 1)
91struct Type12Record
92{
93 get_sdr::SensorDataRecordHeader header;
Matt Simmering80d4d5f2023-02-15 15:18:51 -080094 uint8_t targetAddress;
James Feist74c50c62019-08-14 14:18:41 -070095 uint8_t channelNumber;
96 uint8_t powerStateNotification;
97 uint8_t deviceCapabilities;
Johnathan Manteyf4d5e052021-09-22 12:58:08 -070098 // define reserved bytes explicitly. The uint24_t is silently expanded to
99 // uint32_t, which ruins the byte alignment required by this structure.
100 uint8_t reserved[3];
James Feist74c50c62019-08-14 14:18:41 -0700101 uint8_t entityID;
102 uint8_t entityInstance;
103 uint8_t oem;
104 uint8_t typeLengthCode;
105 char name[16];
Johnathan Manteyf4d5e052021-09-22 12:58:08 -0700106
107 Type12Record(uint16_t recordID, uint8_t address, uint8_t chNumber,
108 uint8_t pwrStateNotification, uint8_t capabilities,
109 uint8_t eid, uint8_t entityInst, uint8_t mfrDefined,
110 const std::string& sensorname) :
Matt Simmering80d4d5f2023-02-15 15:18:51 -0800111 targetAddress(address),
Johnathan Manteyf4d5e052021-09-22 12:58:08 -0700112 channelNumber(chNumber), powerStateNotification(pwrStateNotification),
113 deviceCapabilities(capabilities), reserved{}, entityID(eid),
114 entityInstance(entityInst), oem(mfrDefined)
115 {
116 get_sdr::header::set_record_id(recordID, &header);
117 header.sdr_version = ipmiSdrVersion;
118 header.record_type = 0x12;
119 size_t nameLen = std::min(sensorname.size(), sizeof(name));
120 header.record_length = sizeof(Type12Record) -
121 sizeof(get_sdr::SensorDataRecordHeader) -
122 sizeof(name) + nameLen;
123 typeLengthCode = 0xc0 | nameLen;
124 std::copy(sensorname.begin(), sensorname.begin() + nameLen, name);
125 }
James Feist74c50c62019-08-14 14:18:41 -0700126};
127#pragma pack(pop)
128
Yong Lifee5e4c2020-01-17 19:36:29 +0800129#pragma pack(push, 1)
130struct NMDiscoveryRecord
131{
132 get_sdr::SensorDataRecordHeader header;
133 uint8_t oemID0;
134 uint8_t oemID1;
135 uint8_t oemID2;
136 uint8_t subType;
137 uint8_t version;
Matt Simmering80d4d5f2023-02-15 15:18:51 -0800138 uint8_t targetAddress;
Yong Lifee5e4c2020-01-17 19:36:29 +0800139 uint8_t channelNumber;
140 uint8_t healthEventSensor;
141 uint8_t exceptionEventSensor;
142 uint8_t operationalCapSensor;
143 uint8_t thresholdExceededSensor;
144};
145#pragma pack(pop)
146
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700147namespace ipmi
148{
149namespace storage
150{
James Feist74c50c62019-08-14 14:18:41 -0700151
Yong Lifee5e4c2020-01-17 19:36:29 +0800152constexpr const size_t nmDiscoverySDRCount = 1;
James Feist74c50c62019-08-14 14:18:41 -0700153constexpr const size_t type12Count = 2;
Vernon Mauerydcff1502022-09-28 11:12:46 -0700154ipmi::Cc getFruSdrs(ipmi::Context::ptr& ctx, size_t index,
155 get_sdr::SensorDataFruRecord& resp);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700156
Vernon Mauerydcff1502022-09-28 11:12:46 -0700157ipmi::Cc getFruSdrCount(ipmi::Context::ptr& ctx, size_t& count);
James Feist74c50c62019-08-14 14:18:41 -0700158
159std::vector<uint8_t> getType12SDRs(uint16_t index, uint16_t recordId);
Yong Lifee5e4c2020-01-17 19:36:29 +0800160std::vector<uint8_t> getNMDiscoverySDR(uint16_t index, uint16_t recordId);
Jason M. Bills3f7c5e42018-10-03 14:00:41 -0700161} // namespace storage
162} // namespace ipmi