Skip to content

Commit e866500

Browse files
maxpoliakdcrowell77
authored andcommitted
ipmidcmi: Get DCMI capabilities info to check PM support
According to section 6.6 Power management of DCMI spec, the DCMI Get Power Limit command isn`t supported if Get DCMI Capabilities Info command indicates no Power Management support. Commit adds code to get DCMI capabilities information from BMC to check this Tested on the Vesnin P8 server Change-Id: I3c4216e2ee4f5fa98ffbcfa95c4af6771f81b43c RTC: 123256 Resolves #176 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/80681 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Martha Broyles <mbroyles@us.ibm.com> Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
1 parent f18f9f2 commit e866500

File tree

3 files changed

+139
-4
lines changed

3 files changed

+139
-4
lines changed

src/include/usr/ipmi/ipmi_reasoncodes.H

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* Contributors Listed Below - COPYRIGHT 2014,2017 */
8+
/* Contributors Listed Below - COPYRIGHT 2014,2019 */
99
/* [+] Google Inc. */
1010
/* [+] International Business Machines Corp. */
11+
/* [+] Maxim Polyakov */
1112
/* */
1213
/* */
1314
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -64,6 +65,7 @@ namespace IPMI
6465
RC_INVALID_VPD_DATA = IPMI_COMP_ID | 0x0e,
6566
RC_INVALID_SENSOR_NUMBER = IPMI_COMP_ID | 0x0f,
6667
RC_INVALID_SENSOR_SETTING = IPMI_COMP_ID | 0x10,
68+
RC_GET_DCMI_CAP_CMD_FAILED = IPMI_COMP_ID | 0x11,
6769
};
6870
};
6971

src/include/usr/ipmi/ipmiif.H

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* Contributors Listed Below - COPYRIGHT 2012,2018 */
8+
/* Contributors Listed Below - COPYRIGHT 2012,2019 */
99
/* [+] Google Inc. */
1010
/* [+] International Business Machines Corp. */
11+
/* [+] Maxim Polyakov */
1112
/* */
1213
/* */
1314
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -304,7 +305,10 @@ namespace IPMI
304305
inline const command_t hiomap_event(void)
305306
{ return std::make_pair(NETFUN_IBM, 0x0f); }
306307

307-
// $TODO RTC:123256 - need to add code to get dcmi capabilities
308+
// Used to get dcmi capabilities
309+
inline const command_t get_dcmi_capability_info(void)
310+
{ return std::make_pair(NETFUN_GRPEXT, 0x01); }
311+
308312
// This is a dcmi message used to request the
309313
// user defined power limit from the BMC.
310314
inline const command_t get_power_limit(void)

src/usr/ipmiext/ipmidcmi.C

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* Contributors Listed Below - COPYRIGHT 2015,2018 */
8+
/* Contributors Listed Below - COPYRIGHT 2015,2019 */
99
/* [+] International Business Machines Corp. */
10+
/* [+] Maxim Polyakov */
1011
/* */
1112
/* */
1213
/* Licensed under the Apache License, Version 2.0 (the "License"); */
@@ -34,6 +35,8 @@
3435
#include <ipmi/ipmi_reasoncodes.H>
3536
extern trace_desc_t * g_trac_ipmi;
3637

38+
#define DCMI_CAP_RESPONSE_DATA_LENGTH 7
39+
3740
namespace SENSOR
3841
{
3942
enum dcmi_cc
@@ -42,6 +45,107 @@ namespace SENSOR
4245
POWER_LIMIT_NOT_ACTIVE = 0x80,
4346
};
4447

48+
static errlHndl_t getPowerManagementSupportStatus(bool &support)
49+
{
50+
errlHndl_t err = NULL;
51+
IPMI::completion_code cc = IPMI::CC_UNKBAD;
52+
53+
support = false;
54+
55+
size_t len = 2;
56+
uint8_t* data = new uint8_t[len];
57+
data[0] = 0xDC; // Group Extension Identification
58+
data[1] = 0x01; // Selector - Supported DCMI Capabilities
59+
60+
err = IPMI::sendrecv(IPMI::get_dcmi_capability_info(), cc, len, data);
61+
do
62+
{
63+
if (err)
64+
{
65+
TRACFCOMP(g_trac_ipmi,
66+
"Failed to send DCMI Capabilities Command to BMC");
67+
break;
68+
}
69+
70+
if (cc != IPMI::CC_OK)
71+
{
72+
TRACFCOMP(g_trac_ipmi,
73+
"Get DCMI Capabilities Command: "
74+
"bad completion code from BMC=0x%x",
75+
cc);
76+
77+
/*@
78+
* @errortype ERRL_SEV_INFORMATIONAL
79+
* @moduleid IPMI::MOD_IPMIDCMI
80+
* @reasoncode IPMI::RC_GET_DCMI_CAP_CMD_FAILED
81+
* @userdata1 BMC IPMI Completion code.
82+
* @devdesc Request to get DCMI Capabilities information
83+
* failed
84+
* @custdesc The DCMI Capabilities Info Command retrieve
85+
* data from the BMC has failed.
86+
*
87+
*/
88+
89+
err = new ERRORLOG::ErrlEntry(
90+
ERRORLOG::ERRL_SEV_INFORMATIONAL,
91+
IPMI::MOD_IPMIDCMI,
92+
IPMI::RC_GET_DCMI_CAP_CMD_FAILED,
93+
static_cast<uint64_t>(cc),
94+
0,
95+
true);
96+
break;
97+
}
98+
99+
if (len != DCMI_CAP_RESPONSE_DATA_LENGTH)
100+
{
101+
TRACFCOMP(g_trac_ipmi,
102+
"Get DCMI Capabilities Command: "
103+
"invalid data length=%d",
104+
len);
105+
106+
/*@
107+
* @errortype ERRL_SEV_INFORMATIONAL
108+
* @moduleid IPMI::MOD_IPMIDCMI
109+
* @reasoncode IPMI::RC_INVALID_QRESPONSE
110+
* @userdata1 Response data length.
111+
* @devdesc Request to get DCMI Capabilities information
112+
* failed
113+
* @custdesc The DCMI Capabilities Info Command retrieve
114+
* data with invalid length.
115+
*
116+
*/
117+
118+
err = new ERRORLOG::ErrlEntry(
119+
ERRORLOG::ERRL_SEV_INFORMATIONAL,
120+
IPMI::MOD_IPMIDCMI,
121+
IPMI::RC_INVALID_QRESPONSE,
122+
static_cast<uint64_t>(len),
123+
0,
124+
true);
125+
break;
126+
}
127+
128+
// from the DCMI spec v1.5, Revision 1.0, August 23, 2011
129+
// DCMI Capabilities Response Command Format:
130+
// cc: byte 1 completion code
131+
// data:
132+
// data[0]: byte 1 0xDC
133+
// data[1]: byte 2 Major Version (01h)
134+
// data[2]: byte 3 Minor Version (05h)
135+
// data[3]: byte 4 Parameter Revision (02h)
136+
// data[4]: byte 5 Reserved
137+
// data[5]: byte 6 Platform capabilities
138+
// [7:1] Reserved
139+
// [0] Power management
140+
// data[6]: byte 7 Manageability Access Capabilities
141+
support = !!(data[5] & 0x1);
142+
143+
} while(false);
144+
145+
delete[] data;
146+
return err;
147+
}
148+
45149
// fetch the user defined power limit stored on the BMC
46150
// using the DCMI Get Power Limit command
47151
errlHndl_t getUserPowerLimit( uint16_t &o_powerLimit, bool &o_limitActive )
@@ -53,6 +157,31 @@ namespace SENSOR
53157

54158
errlHndl_t l_err = NULL;
55159

160+
// Power Management support check
161+
bool support;
162+
l_err = getPowerManagementSupportStatus(support);
163+
if (l_err != NULL)
164+
{
165+
// Since the Power Management support information isn`t received,
166+
// commit this error and still try to read the power limit. If the
167+
// Power Management is really unsupported, the DCMI Get Power Limit
168+
// command will return error code in l_cc
169+
l_err->collectTrace(IPMI_COMP_NAME);
170+
errlCommit(l_err, IPMI_COMP_ID);
171+
172+
TRACFCOMP(g_trac_ipmi,
173+
"Failed to determine if the BMC supports Power Management");
174+
175+
support = true;
176+
}
177+
178+
if (!support)
179+
{
180+
TRACFCOMP(g_trac_ipmi,
181+
"Power Management is not supported by BMC");
182+
return NULL;
183+
}
184+
56185
// per DCMI spec data size is 3 bytes
57186
size_t len = 3;
58187

0 commit comments

Comments
 (0)