blob: 6f1b80ca73763ba5f827549e14ed930e2cf2fed6 [file] [log] [blame]
Mike Baiocchi73573d82015-04-22 17:45:40 -05001From 1674da76fadc52f8c6aff6d8435536dd33b7417f Mon Sep 17 00:00:00 2001
Bill Hoffaffe83702015-03-30 21:37:20 -05002From: Bill Hoffa <wghoffa@us.ibm.com>
3Date: Mon, 30 Mar 2015 15:11:28 -0500
Mike Baiocchi73573d82015-04-22 17:45:40 -05004Subject: [PATCH] Add PNOR Version Information to IPMI Fru Inventory
Bill Hoffaffe83702015-03-30 21:37:20 -05005
6Change-Id: Ib49fe67e9c6631b2b7ea0005e692c9aea6d84057
7RTC:123353
Bill Hoffaffe83702015-03-30 21:37:20 -05008---
9 src/usr/ipmi/ipmifruinv.C | 207 +++++++++++++++++++++
10 src/usr/ipmi/ipmifruinvprvt.H | 47 +++++
11 .../targeting/common/xmltohb/attribute_types.xml | 8 +
12 src/usr/targeting/common/xmltohb/target_types.xml | 1 +
13 4 files changed, 263 insertions(+)
14
15diff --git a/src/usr/ipmi/ipmifruinv.C b/src/usr/ipmi/ipmifruinv.C
Mike Baiocchi73573d82015-04-22 17:45:40 -050016index 4f0d7d7..aaf62d1 100644
Bill Hoffaffe83702015-03-30 21:37:20 -050017--- a/src/usr/ipmi/ipmifruinv.C
18+++ b/src/usr/ipmi/ipmifruinv.C
Mike Baiocchi73573d82015-04-22 17:45:40 -050019@@ -37,6 +37,7 @@
Bill Hoffaffe83702015-03-30 21:37:20 -050020 #include "ipmifruinvprvt.H"
21 #include <stdio.h>
Mike Baiocchi73573d82015-04-22 17:45:40 -050022 #include <assert.h>
Bill Hoffaffe83702015-03-30 21:37:20 -050023+#include <pnor/pnorif.H>
24
25 extern trace_desc_t * g_trac_ipmi;
26
Mike Baiocchi73573d82015-04-22 17:45:40 -050027@@ -84,6 +85,10 @@ IpmiFruInv *IpmiFruInv::Factory(TARGETING::TargetHandleList i_targets,
Bill Hoffaffe83702015-03-30 21:37:20 -050028 // @todo-RTC:117702
29 l_fru = new backplaneIpmiFruInv(l_target, i_targets, i_updateData);
30 break;
31+ case TARGETING::TYPE_SYS:
32+ // Use sys target for setting System Firmware Info
33+ l_fru = new systemFwIpmiFruInv(l_target);
34+ break;
35 default:
36 assert(false,
37 "IpmiFruInv::Factory: No support for target type given: [%08x]",
Mike Baiocchi73573d82015-04-22 17:45:40 -050038@@ -927,6 +932,199 @@ errlHndl_t backplaneIpmiFruInv::addVpdData(std::vector<uint8_t> &io_data,
Bill Hoffaffe83702015-03-30 21:37:20 -050039 return l_errl;
40 }
41
42+//##############################################################################
43+systemFwIpmiFruInv::systemFwIpmiFruInv( TARGETING::TargetHandle_t i_target )
44+ :IpmiFruInv(i_target)
45+{
46+
47+};
48+
49+errlHndl_t systemFwIpmiFruInv::buildInternalUseArea(std::vector<uint8_t>
50+ &io_data)
51+{
52+ //This section not needed for proc type
53+ return IpmiFruInv::buildEmptyArea(io_data);
54+}
55+
56+errlHndl_t systemFwIpmiFruInv::buildChassisInfoArea(std::vector<uint8_t>
57+ &io_data)
58+{
59+ //This section not needed for system firmware type
60+ return IpmiFruInv::buildEmptyArea(io_data);
61+}
62+
63+errlHndl_t systemFwIpmiFruInv::buildBoardInfoArea(std::vector<uint8_t> &io_data)
64+{
65+ //This section not needed for system firmware type
66+ return IpmiFruInv::buildEmptyArea(io_data);
67+}
68+
69+errlHndl_t systemFwIpmiFruInv::buildProductInfoArea(std::vector<uint8_t>
70+ &io_data)
71+{
72+ errlHndl_t l_errl = NULL;
73+
74+ do {
75+ //Set formatting data that goes at the beginning of the record
76+ preFormatProcessing(io_data, true);
77+
Mike Baiocchi73573d82015-04-22 17:45:40 -050078+ uint8_t l_data[] = {IPMIFRUINV::TYPELENGTH_BYTE_NULL,
Bill Hoffaffe83702015-03-30 21:37:20 -050079+ IPMIFRUINV::TYPELENGTH_BYTE_ASCII + 18, 'O','p','e',
80+ 'n','P','O','W','E','R',' ','F','i','r','m','w','a',
81+ 'r','e', IPMIFRUINV::TYPELENGTH_BYTE_NULL};
82+
83+ io_data.insert( io_data.end(),
84+ &l_data[0],
85+ &l_data[0] + (uint8_t(sizeof(l_data) / sizeof(uint8_t))));
86+
87+ //Get PNOR Version Here
88+ PNOR::SectionInfo_t l_pnorInfo;
89+ l_errl = getSectionInfo( PNOR::VERSION , l_pnorInfo);
90+ if (l_errl) { break; }
91+
92+ uint8_t* l_versionData = reinterpret_cast<uint8_t*>( l_pnorInfo.vaddr );
93+ //Total Bytes in PNOR Version String
94+ uint8_t l_numBytes = 0;
95+ uint8_t l_curOffset = 0;
96+
97+ //Total Number of fields needed to print PNOR Version String
98+ uint8_t l_numFields = 0;
99+ bool l_clearStandardFields = true;
100+
101+ //First determine number of bytes in PNOR Version string
102+ // with the caveat there is a max record size allowed, so
103+ // the string will be cut off if too long
Mike Baiocchi73573d82015-04-22 17:45:40 -0500104+ //Also, remove newline chars
Bill Hoffaffe83702015-03-30 21:37:20 -0500105+ while ((l_numBytes < IPMIFRUINV::MAX_RECORD_SIZE -
106+ (uint8_t(sizeof(l_data) / sizeof(uint8_t))) -
107+ IPMIFRUINV::COMMON_HEADER_FORMAT_SIZE - 8)
108+ && (((char)(l_versionData[l_numBytes])) != '\0'))
109+ {
110+
111+ if (((char)(l_versionData[l_numBytes])) == '\n')
112+ {
113+
114+ if (l_numBytes > l_curOffset)
115+ {
116+ //Add on size of this field to the data buffer
117+ io_data.push_back(
118+ IPMIFRUINV::TYPELENGTH_BYTE_ASCII
119+ + (l_numBytes-l_curOffset));
120+
121+ io_data.insert(io_data.end(),
122+ &l_versionData[0]+(l_curOffset),
123+ &l_versionData[0]+(l_numBytes));
124+ }
125+
126+ //Null data for standard fields needs to be indicated once after
127+ // the first segment of data is displayed to match the
128+ // ipmi fru spec
129+ if (l_clearStandardFields)
130+ {
131+ //Add Empty Asset Tag
132+ io_data.push_back(uint8_t(0));
133+ //FRU File ID - Empty
134+ io_data.push_back(IPMIFRUINV::TYPELENGTH_BYTE_NULL);
135+ io_data.push_back(uint8_t(0)); // Empty FRU File ID bytes
136+ l_clearStandardFields = false;
137+ }
138+
139+ //Increment past the newline char
140+ l_curOffset = l_numBytes + 1;
141+ }
142+ l_numBytes++;
143+ }
144+
145+ if (l_curOffset == 0)
146+ {
147+ //Calculate the number of fields required to display this data
148+ // given only MAX_ASCII_FIELD_SIZE bytes can be in any one given
149+ // IPMI fru inventory field
150+ l_numFields = l_numBytes / IPMIFRUINV::MAX_ASCII_FIELD_SIZE;
151+ if (l_numBytes % IPMIFRUINV::MAX_ASCII_FIELD_SIZE)
152+ {
153+ l_numFields += 1;
154+ }
155+
156+ //Count by number of fields, adding the data to the buffer as
157+ // we go.
158+ for (uint8_t i=0; i < l_numFields; i++)
159+ {
160+ //Determine the data size for this particular field
161+ uint8_t l_dataSize=IPMIFRUINV::MAX_ASCII_FIELD_SIZE;
162+ if (i == l_numFields - 1)
163+ {
164+ l_dataSize = l_numBytes -
165+ (i * IPMIFRUINV::MAX_ASCII_FIELD_SIZE);
166+ }
167+
168+ //Add on size of this field to the data buffer
169+ io_data.push_back(IPMIFRUINV::TYPELENGTH_BYTE_ASCII
170+ + l_dataSize);
171+
172+ //Insert this segment of version string data
173+ io_data.insert(io_data.end(),
174+ &l_versionData[0]+(i * IPMIFRUINV::MAX_ASCII_FIELD_SIZE),
175+ &l_versionData[0]+(i * IPMIFRUINV::MAX_ASCII_FIELD_SIZE)
176+ +l_dataSize);
177+
178+ //Null data for standard fields needs to be indicated once after
179+ // the first segment of data is displayed to match the
180+ // ipmi fru spec
181+ if (l_clearStandardFields)
182+ {
183+ //Add Empty Asset Tag
184+ io_data.push_back(uint8_t(0));
185+ //FRU File ID - Empty
186+ io_data.push_back(IPMIFRUINV::TYPELENGTH_BYTE_NULL);
187+ //io_data.push_back(uint8_t(0)); // Empty FRU File ID bytes
188+ l_clearStandardFields = false;
189+ }
190+
191+ }
192+ }
193+ else
194+ {
195+ if (l_numBytes > l_curOffset)
196+ {
197+ io_data.push_back( IPMIFRUINV::TYPELENGTH_BYTE_ASCII
198+ + (l_numBytes-l_curOffset));
199+
200+ io_data.insert(io_data.end(),
201+ &l_versionData[0]+(l_curOffset),
202+ &l_versionData[0]+(l_numBytes));
203+ }
204+
205+ }
206+
207+ if (l_clearStandardFields)
208+ {
209+ //Add Asset Tag
210+ io_data.push_back(uint8_t(0)); //No Asset Tag needed - O bytes
211+ //FRU File ID - Empty
212+ io_data.push_back(IPMIFRUINV::TYPELENGTH_BYTE_NULL);
213+ //io_data.push_back(uint8_t(0)); // Empty FRU File ID bytes
214+ }
215+
216+ io_data.push_back(IPMIFRUINV::END_OF_CUSTOM_FIELDS);
217+
218+ //Finalize section formatting
219+ postFormatProcessing(io_data);
220+
221+ } while(0);
222+
223+ return l_errl;
224+}
225+
226+errlHndl_t systemFwIpmiFruInv::buildMultiRecordInfoArea(std::vector<uint8_t>
227+ &io_data)
228+{
229+ //This section not needed for system firmware type
230+ return IpmiFruInv::buildEmptyArea(io_data);
231+}
232+
233+
234+
235 void IpmiFruInv::addEcidData(const TARGETING::TargetHandle_t& i_target,
236 const TARGETING::ATTR_ECID_type& i_ecidInfo,
237 std::vector<uint8_t> &io_data)
Mike Baiocchi73573d82015-04-22 17:45:40 -0500238@@ -997,6 +1195,15 @@ void IPMIFRUINV::setData(bool i_updateData)
Bill Hoffaffe83702015-03-30 21:37:20 -0500239 IPMIFRUINV::gatherClearData(pSys, frusToClear);
240 }
241
242+ //Get System FW FRU_ID if available
243+ uint32_t l_systemFwFruId;
244+ bool hasSystemFwFruId =
Mike Baiocchi73573d82015-04-22 17:45:40 -0500245+ pSys->tryGetAttr<TARGETING::ATTR_BMC_FRU_ID>(l_systemFwFruId);
Bill Hoffaffe83702015-03-30 21:37:20 -0500246+ if (hasSystemFwFruId)
247+ {
248+ l_potentialFrus.push_back(std::make_pair(pSys, l_systemFwFruId));
249+ }
250+
251 // Find list of all target types that may need a fru inv. record set
252 IPMIFRUINV::gatherSetData(pSys, frusToClear,
253 l_potentialFrus, i_updateData);
254diff --git a/src/usr/ipmi/ipmifruinvprvt.H b/src/usr/ipmi/ipmifruinvprvt.H
255index 2573a84..468a47f 100644
256--- a/src/usr/ipmi/ipmifruinvprvt.H
257+++ b/src/usr/ipmi/ipmifruinvprvt.H
258@@ -42,6 +42,8 @@ namespace IPMIFRUINV
259 COMMON_HEADER_FORMAT_SIZE = 8, //size in bytes
260 DEFAULT_CHASSIS_TYPE = 0x05,
261 DEFAULT_FRU_OFFSET = 0,
262+ MAX_ASCII_FIELD_SIZE = 0x3F, //size in bytes
263+ MAX_RECORD_SIZE = 0xFF, //size in bytes
264 };
265 };
266
267@@ -460,4 +462,49 @@ class backplaneIpmiFruInv : public IpmiFruInv
268
269 };
270
271+//Child class for building up System Firwmare Fru Inventory Record Data
272+class systemFwIpmiFruInv : public IpmiFruInv
273+{
274+
275+ public:
276+ /**
277+ * @brief Constructor
278+ *
279+ * @param[in] TargetHandle_t, Handle to target for which
280+ * to get relevant IPMI FRU Data from
281+ */
282+ systemFwIpmiFruInv( TARGETING::TargetHandle_t i_target);
283+
284+ /**
285+ * @brief Builds the Internal Use Area Data Section
286+ * @param[in/out] data, The container to put internal use area data in
287+ */
288+ errlHndl_t buildInternalUseArea(std::vector<uint8_t> &io_data);
289+
290+ /**
291+ * @brief Builds the Chassis Info Area Data Section
292+ * @param[in/out] data, The container to put chassis info area data in
293+ */
294+ errlHndl_t buildChassisInfoArea(std::vector<uint8_t> &io_data);
295+
296+ /**
297+ * @brief Builds the Board Info Area Data Section
298+ * @param[in/out] data, The container to put board info area data in
299+ */
300+ errlHndl_t buildBoardInfoArea(std::vector<uint8_t> &io_data);
301+
302+ /**
303+ * @brief Builds the Product Info Area Data Section
304+ * @param[in/out] data, The container to put product info area data in
305+ */
306+ errlHndl_t buildProductInfoArea(std::vector<uint8_t> &io_data);
307+
308+ /**
309+ * @brief Builds the MultiRecord Info Area Data Section
310+ * @param[in/out] data, The container to put multirecord info area data in
311+ */
312+ errlHndl_t buildMultiRecordInfoArea(std::vector<uint8_t> &io_data);
313+
314+};
315+
316 #endif
317diff --git a/src/usr/targeting/common/xmltohb/attribute_types.xml b/src/usr/targeting/common/xmltohb/attribute_types.xml
Mike Baiocchi73573d82015-04-22 17:45:40 -0500318index ec256de..17729cd 100644
Bill Hoffaffe83702015-03-30 21:37:20 -0500319--- a/src/usr/targeting/common/xmltohb/attribute_types.xml
320+++ b/src/usr/targeting/common/xmltohb/attribute_types.xml
Mike Baiocchi73573d82015-04-22 17:45:40 -0500321@@ -11659,6 +11659,14 @@ firmware notes: Platforms should initialize this attribute to AUTO (0)</descript
Bill Hoffaffe83702015-03-30 21:37:20 -0500322 </attribute>
323
324 <attribute>
325+ <id>BMC_FRU_ID</id>
326+ <description>BMC FRU ID attribute for node class</description>
327+ <simpleType><uint32_t><default>0</default></uint32_t></simpleType>
328+ <persistency>non-volatile</persistency>
329+ <readable/>
330+</attribute>
331+
332+<attribute>
333 <id>PLCK_IPL_ATTR_OVERRIDES_EXIST</id>
334 <description>
335 Set to 1 by HWSV to indicate that attribute overrides exist in a PLCK IPL
336diff --git a/src/usr/targeting/common/xmltohb/target_types.xml b/src/usr/targeting/common/xmltohb/target_types.xml
Mike Baiocchi73573d82015-04-22 17:45:40 -0500337index 15d7921..82ec014 100644
Bill Hoffaffe83702015-03-30 21:37:20 -0500338--- a/src/usr/targeting/common/xmltohb/target_types.xml
339+++ b/src/usr/targeting/common/xmltohb/target_types.xml
Mike Baiocchi73573d82015-04-22 17:45:40 -0500340@@ -300,6 +300,7 @@
Bill Hoffaffe83702015-03-30 21:37:20 -0500341 <attribute><id>MNFG_TH_CEN_L4_CACHE_CES</id></attribute>
342 <attribute><id>OPT_MEMMAP_GROUP_POLICY</id></attribute>
343 <attribute><id>FRU_ID</id></attribute>
344+ <attribute><id>BMC_FRU_ID</id></attribute>
345 </targetType>
346
347 <targetType>
348--
3491.8.2.2
350