blob: af89bc886ab5989c6762eb995828ca104332572a [file] [log] [blame]
Vernon Mauerye7329c72018-10-08 12:05:16 -07001/**
2 * Copyright © 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#pragma once
17
18#include <ipmid/api.hpp>
19#include <ipmid/handler.hpp>
20
21namespace ipmi
22{
23
24namespace impl
25{
26
27// IPMI command handler registration implementation
28bool registerHandler(int prio, NetFn netFn, Cmd cmd, Privilege priv,
29 ::ipmi::HandlerBase::ptr handler);
Vernon Maueryf984a012018-10-08 12:05:18 -070030bool registerGroupHandler(int prio, Group group, Cmd cmd, Privilege priv,
31 ::ipmi::HandlerBase::ptr handler);
32bool registerOemHandler(int prio, Iana iana, Cmd cmd, Privilege priv,
33 ::ipmi::HandlerBase::ptr handler);
34
Vernon Mauerye7329c72018-10-08 12:05:16 -070035} // namespace impl
36
37/**
38 * @brief main IPMI handler registration function
39 *
40 * This function should be used to register all new-style IPMI handler
41 * functions. This function just passes the callback to makeHandler, which
42 * creates a new wrapper object that will automatically extract the appropriate
43 * parameters for the callback function as well as pack up the response.
44 *
45 * @param prio - priority at which to register; see api.hpp
46 * @param netFn - the IPMI net function number to register
47 * @param cmd - the IPMI command number to register
48 * @param priv - the IPMI user privilige required for this command
49 * @param handler - the callback function that will handle this request
50 *
51 * @return bool - success of registering the handler
52 */
53template <typename Handler>
54bool registerHandler(int prio, NetFn netFn, Cmd cmd, Privilege priv,
55 Handler&& handler)
56{
57 auto h = ipmi::makeHandler(std::forward<Handler>(handler));
58 return impl::registerHandler(prio, netFn, cmd, priv, h);
59}
60
Vernon Maueryf984a012018-10-08 12:05:18 -070061/**
62 * @brief register a IPMI OEM group handler
63 *
64 * From IPMI 2.0 spec Network Function Codes Table (Row 2Ch):
65 * The first data byte position in requests and responses under this network
66 * function identifies the defining body that specifies command functionality.
67 * Software assumes that the command and completion code field positions will
68 * hold command and completion code values.
69 *
70 * The following values are used to identify the defining body:
71 * 00h PICMG - PCI Industrial Computer Manufacturer’s Group. (www.picmg.com)
72 * 01h DMTF Pre-OS Working Group ASF Specification (www.dmtf.org)
73 * 02h Server System Infrastructure (SSI) Forum (www.ssiforum.org)
74 * 03h VITA Standards Organization (VSO) (www.vita.com)
75 * DCh DCMI Specifications (www.intel.com/go/dcmi)
76 * all other Reserved
77 *
78 * When this network function is used, the ID for the defining body occupies
79 * the first data byte in a request, and the second data byte (following the
80 * completion code) in a response.
81 *
82 * @tparam Handler - implicitly specified callback function type
83 * @param prio - priority at which to register; see api.hpp
84 * @param netFn - the IPMI net function number to register
85 * @param cmd - the IPMI command number to register
86 * @param priv - the IPMI user privilige required for this command
87 * @param handler - the callback function that will handle this request
88 *
89 * @return bool - success of registering the handler
90 *
91 */
92template <typename Handler>
93void registerGroupHandler(int prio, Group group, Cmd cmd, Privilege priv,
94 Handler&& handler)
95{
96 auto h = ipmi::makeHandler(handler);
97 impl::registerGroupHandler(prio, group, cmd, priv, h);
98}
99
100/**
101 * @brief register a IPMI OEM IANA handler
102 *
103 * From IPMI spec Network Function Codes Table (Row 2Eh):
104 * The first three data bytes of requests and responses under this network
105 * function explicitly identify the OEM or non-IPMI group that specifies the
106 * command functionality. While the OEM or non-IPMI group defines the
107 * functional semantics for the cmd and remaining data fields, the cmd field
108 * is required to hold the same value in requests and responses for a given
109 * operation in order to be supported under the IPMI message handling and
110 * transport mechanisms.
111 *
112 * When this network function is used, the IANA Enterprise Number for the
113 * defining body occupies the first three data bytes in a request, and the
114 * first three data bytes following the completion code position in a
115 * response.
116 *
117 * @tparam Handler - implicitly specified callback function type
118 * @param prio - priority at which to register; see api.hpp
119 * @param netFn - the IPMI net function number to register
120 * @param cmd - the IPMI command number to register
121 * @param priv - the IPMI user privilige required for this command
122 * @param handler - the callback function that will handle this request
123 *
124 * @return bool - success of registering the handler
125 *
126 */
127template <typename Handler>
128void registerOemHandler(int prio, Iana iana, Cmd cmd, Privilege priv,
129 Handler&& handler)
130{
131 auto h = ipmi::makeHandler(handler);
132 impl::registerOemHandler(prio, iana, cmd, priv, h);
133}
134
Vernon Mauerye7329c72018-10-08 12:05:16 -0700135} // namespace ipmi
136
137#ifdef ALLOW_DEPRECATED_API
138/**
139 * @brief legacy IPMI handler registration function
140 *
141 * This function should be used to register all legacy IPMI handler
142 * functions. This function just behaves just as the legacy registration
143 * mechanism did, silently replacing any existing handler with a new one.
144 *
145 * @param netFn - the IPMI net function number to register
146 * @param cmd - the IPMI command number to register
147 * @param context - ignored
148 * @param handler - the callback function that will handle this request
149 * @param priv - the IPMI user privilige required for this command
150 */
151// [[deprecated("Use ipmi::registerHandler() instead")]]
152void ipmi_register_callback(ipmi_netfn_t netFn, ipmi_cmd_t cmd,
153 ipmi_context_t context, ipmid_callback_t handler,
154 ipmi_cmd_privilege_t priv);
155
156#endif /* ALLOW_DEPRECATED_API */
157
158// IPMI 2.0 and DCMI 1.5 standard commands, namespaced by NetFn
159// OEM and non-standard commands should be defined where they are used
160namespace ipmi
161{
162namespace app
163{
164// 0x00 reserved
165constexpr Cmd cmdGetDeviceId = 0x01;
166constexpr Cmd cmdColdReset = 0x02;
167constexpr Cmd cmdWarmReset = 0x03;
168constexpr Cmd cmdGetSelfTestResults = 0x04;
169constexpr Cmd cmdManufacturingTestOn = 0x05;
170constexpr Cmd cmdSetAcpiPowerState = 0x06;
171constexpr Cmd cmdGetAcpiPowerState = 0x07;
172constexpr Cmd cmdGetDeviceGuid = 0x08;
173constexpr Cmd cmdGetNetFnSupport = 0x09;
174constexpr Cmd cmdGetCmdSupport = 0x0A;
175constexpr Cmd cmdGetCmdSubFnSupport = 0x0B;
176constexpr Cmd cmdGetConfigurableCmds = 0x0C;
177constexpr Cmd cmdGetConfigurableCmdSubFns = 0x0D;
178// 0x0E-0x21 unassigned
179constexpr Cmd cmdResetWatchdogTimer = 0x22;
180// 0x23 unassigned
181constexpr Cmd cmdSetWatchdogTimer = 0x24;
182constexpr Cmd cmdGetWatchdogTimer = 0x25;
183// 0x26-0x2D unassigned
184constexpr Cmd cmdSetBmcGlobalEnables = 0x2E;
185constexpr Cmd cmdGetBmcGlobalEnables = 0x2F;
186constexpr Cmd cmdClearMessageFlags = 0x30;
187constexpr Cmd cmdGetMessageFlags = 0x31;
188constexpr Cmd cmdEnableMessageChannelRcv = 0x32;
189constexpr Cmd cmdGetMessage = 0x33;
190constexpr Cmd cmdSendMessage = 0x34;
191constexpr Cmd cmdReadEventMessageBuffer = 0x35;
192constexpr Cmd cmdGetBtIfaceCapabilities = 0x36;
193constexpr Cmd cmdGetSystemGuid = 0x37;
194constexpr Cmd cmdGetChannelAuthCapabilities = 0x38;
195constexpr Cmd cmdGetSessionChallenge = 0x39;
196constexpr Cmd cmdActivateSession = 0x3A;
197constexpr Cmd cmdSetSessionPrivilegeLevel = 0x3B;
198constexpr Cmd cmdCloseSession = 0x3C;
199constexpr Cmd cmdGetSessionInfo = 0x3D;
200// 0x3E unassigned
201constexpr Cmd cmdGetAuthCode = 0x3F;
202constexpr Cmd cmdSetChannelAccess = 0x40;
203constexpr Cmd cmdGetChannelAccess = 0x41;
204constexpr Cmd cmdGetChannelInfoCommand = 0x42;
205constexpr Cmd cmdSetUserAccessCommand = 0x43;
206constexpr Cmd cmdGetUserAccessCommand = 0x44;
207constexpr Cmd cmdSetUserName = 0x45;
208constexpr Cmd cmdGetUserNameCommand = 0x46;
209constexpr Cmd cmdSetUserPasswordCommand = 0x47;
210constexpr Cmd cmdActivatePayload = 0x48;
211constexpr Cmd cmdDeactivatePayload = 0x49;
212constexpr Cmd cmdGetPayloadActivationStatus = 0x4A;
213constexpr Cmd cmdGetPayloadInstanceInfo = 0x4B;
214constexpr Cmd cmdSetUserPayloadAccess = 0x4C;
215constexpr Cmd cmdGetUserPayloadAccess = 0x4D;
216constexpr Cmd cmdGetChannelPayloadSupport = 0x4E;
217constexpr Cmd cmdGetChannelPayloadVersion = 0x4F;
218constexpr Cmd cmdGetChannelOemPayloadInfo = 0x50;
219// 0x51 unassigned
220constexpr Cmd cmdMasterWriteRead = 0x52;
221// 0x53 unassigned
222constexpr Cmd cmdGetChannelCipherSuites = 0x54;
223constexpr Cmd cmdSuspendResumePayloadEnc = 0x55;
224constexpr Cmd cmdSetChannelSecurityKeys = 0x56;
225constexpr Cmd cmdGetSystemIfCapabilities = 0x57;
226constexpr Cmd cmdSetSystemInfoParameters = 0x58;
227constexpr Cmd cmdGetSystemInfoParameters = 0x59;
228// 0x5A-0x5F unassigned
229constexpr Cmd cmdSetCommandEnables = 0x60;
230constexpr Cmd cmdGetCommandEnables = 0x61;
231constexpr Cmd cmdSetCommandSubFnEnables = 0x62;
232constexpr Cmd cmdGetCommandSubFnEnables = 0x63;
233constexpr Cmd cmdGetOemNetFnIanaSupport = 0x64;
234// 0x65-0xff unassigned
235} // namespace app
236
237namespace chassis
238{
239constexpr Cmd cmdGetChassisCapabilities = 0x00;
240constexpr Cmd cmdGetChassisStatus = 0x01;
241constexpr Cmd cmdChassisControl = 0x02;
242constexpr Cmd cmdChassisReset = 0x03;
243constexpr Cmd cmdChassisIdentify = 0x04;
244constexpr Cmd cmdSetChassisCapabilities = 0x05;
245constexpr Cmd cmdSetPowerRestorePolicy = 0x06;
246constexpr Cmd cmdGetSystemRestartCause = 0x07;
247constexpr Cmd cmdSetSystemBootOptions = 0x08;
248constexpr Cmd cmdGetSystemBootOptions = 0x09;
249constexpr Cmd cmdSetFrontPanelButtonEnables = 0x0A;
250constexpr Cmd cmdSetPowerCycleInterval = 0x0B;
251// 0x0C-0x0E unassigned
252constexpr Cmd cmdGetPohCounter = 0x0F;
253// 0x10-0xFF unassigned
254} // namespace chassis
255
256namespace sensor_event
257{
258constexpr Cmd cmdSetEventReceiver = 0x00;
259constexpr Cmd cmdGetEventReceiver = 0x01;
260constexpr Cmd cmdPlatformEvent = 0x02;
261// 0x03-0x0F unassigned
262constexpr Cmd cmdGetPefCapabilities = 0x10;
263constexpr Cmd cmdArmPefPostponeTimer = 0x11;
264constexpr Cmd cmdSetPefConfigurationParams = 0x12;
265constexpr Cmd cmdGetPefConfigurationParams = 0x13;
266constexpr Cmd cmdSetLastProcessedEventId = 0x14;
267constexpr Cmd cmdGetLastProcessedEventId = 0x15;
268constexpr Cmd cmdAlertImmediate = 0x16;
269constexpr Cmd cmdPetAcknowledge = 0x17;
270constexpr Cmd cmdGetDeviceSdrInfo = 0x20;
271constexpr Cmd cmdGetDeviceSdr = 0x21;
272constexpr Cmd cmdReserveDeviceSdrRepository = 0x22;
273constexpr Cmd cmdGetSensorReadingFactors = 0x23;
274constexpr Cmd cmdSetSensorHysteresis = 0x24;
275constexpr Cmd cmdGetSensorHysteresis = 0x25;
276constexpr Cmd cmdSetSensorThreshold = 0x26;
277constexpr Cmd cmdGetSensorThreshold = 0x27;
278constexpr Cmd cmdSetSensorEventEnable = 0x28;
279constexpr Cmd cmdGetSensorEventEnable = 0x29;
280constexpr Cmd cmdRearmSensorEvents = 0x2A;
281constexpr Cmd cmdGetSensorEventStatus = 0x2B;
282constexpr Cmd cmdGetSensorReading = 0x2D;
283constexpr Cmd cmdSetSensorType = 0x2E;
284constexpr Cmd cmdGetSensorType = 0x2F;
285constexpr Cmd cmdSetSensorReadingAndEvtSts = 0x30;
286// 0x31-0xFF unassigned
287} // namespace sensor_event
288
289namespace storage
290{
291// 0x00-0x0F unassigned
292constexpr Cmd cmdGetFruInventoryAreaInfo = 0x10;
293constexpr Cmd cmdReadFruData = 0x11;
294constexpr Cmd cmdWriteFruData = 0x12;
295// 0x13-0x1F unassigned
296constexpr Cmd cmdGetSdrRepositoryInfo = 0x20;
297constexpr Cmd cmdGetSdrRepositoryAllocInfo = 0x21;
298constexpr Cmd cmdReserveSdrRepository = 0x22;
299constexpr Cmd cmdGetSdr = 0x23;
300constexpr Cmd cmdAddSdr = 0x24;
301constexpr Cmd cmdPartialAddSdr = 0x25;
302constexpr Cmd cmdDeleteSdr = 0x26;
303constexpr Cmd cmdClearSdrRepository = 0x27;
304constexpr Cmd cmdGetSdrRepositoryTime = 0x28;
305constexpr Cmd cmdSetSdrRepositoryTime = 0x29;
306constexpr Cmd cmdEnterSdrRepoUpdateMode = 0x2A;
307constexpr Cmd cmdExitSdrReposUpdateMode = 0x2B;
308constexpr Cmd cmdRunInitializationAgent = 0x2C;
309// 0x2D-0x3F unassigned
310constexpr Cmd cmdGetSelInfo = 0x40;
311constexpr Cmd cmdGetSelAllocationInfo = 0x41;
312constexpr Cmd cmdReserveSel = 0x42;
313constexpr Cmd cmdGetSelEntry = 0x43;
314constexpr Cmd cmdAddSelEntry = 0x44;
315constexpr Cmd cmdPartialAddSelEntry = 0x45;
316constexpr Cmd cmdDeleteSelEntry = 0x46;
317constexpr Cmd cmdClearSel = 0x47;
318constexpr Cmd cmdGetSelTime = 0x48;
319constexpr Cmd cmdSetSelTime = 0x49;
320constexpr Cmd cmdGetAuxiliaryLogStatus = 0x5A;
321constexpr Cmd cmdSetAuxiliaryLogStatus = 0x5B;
322constexpr Cmd cmdGetSelTimeUtcOffset = 0x5C;
323constexpr Cmd cmdSetSelTimeUtcOffset = 0x5D;
324// 0x5E-0xFF unassigned
325} // namespace storage
326
327namespace transport
328{
329constexpr Cmd cmdSetLanConfigParameters = 0x01;
330constexpr Cmd cmdGetLanConfigParameters = 0x02;
331constexpr Cmd cmdSuspendBmcArps = 0x03;
332constexpr Cmd cmdGetIpUdpRmcpStatistics = 0x04;
333constexpr Cmd cmdSetSerialModemConfig = 0x10;
334constexpr Cmd cmdGetSerialModemConfig = 0x11;
335constexpr Cmd cmdSetSerialModemMux = 0x12;
336constexpr Cmd cmdGetTapResponseCodes = 0x13;
337constexpr Cmd cmdSetPppUdpProxyTransmitData = 0x14;
338constexpr Cmd cmdGetPppUdpProxyTransmitData = 0x15;
339constexpr Cmd cmdSendPppUdpProxyPacket = 0x16;
340constexpr Cmd cmdGetPppUdpProxyReceiveData = 0x17;
341constexpr Cmd cmdSerialModemConnActive = 0x18;
342constexpr Cmd cmdCallback = 0x19;
343constexpr Cmd cmdSetUserCallbackOptions = 0x1A;
344constexpr Cmd cmdGetUserCallbackOptions = 0x1B;
345constexpr Cmd cmdSetSerialRoutingMux = 0x1C;
346constexpr Cmd cmdSolActivating = 0x20;
347constexpr Cmd cmdSetSolConfigParameters = 0x21;
348constexpr Cmd cmdGetSolConfigParameters = 0x22;
349constexpr Cmd cmdForwardedCommand = 0x30;
350constexpr Cmd cmdSetForwardedCommands = 0x31;
351constexpr Cmd cmdGetForwardedCommands = 0x32;
352constexpr Cmd cmdEnableForwardedCommands = 0x33;
353} // namespace transport
354
355namespace bridge
356{
357constexpr Cmd cmdGetBridgeState = 0x00;
358constexpr Cmd cmdSetBridgeState = 0x01;
359constexpr Cmd cmdGetIcmbAddress = 0x02;
360constexpr Cmd cmdSetIcmbAddress = 0x03;
361constexpr Cmd cmdSetBridgeProxyAddress = 0x04;
362constexpr Cmd cmdGetBridgeStatistics = 0x05;
363constexpr Cmd cmdGetIcmbCapabilities = 0x06;
364constexpr Cmd cmdClearBridgeStatistics = 0x08;
365constexpr Cmd cmdGetBridgeProxyAddress = 0x09;
366constexpr Cmd cmdGetIcmbConnectorInfo = 0x0A;
367constexpr Cmd cmdGetIcmbConnectionId = 0x0B;
368constexpr Cmd cmdSendIcmbConnectionId = 0x0C;
369constexpr Cmd cmdPrepareForDiscovery = 0x10;
370constexpr Cmd cmdGetAddresses = 0x11;
371constexpr Cmd cmdSetDiscovered = 0x12;
372constexpr Cmd cmdGetChassisDeviceId = 0x13;
373constexpr Cmd cmdSetChassisDeviceId = 0x14;
374constexpr Cmd cmdBridgeRequest = 0x20;
375constexpr Cmd cmdBridgeMessage = 0x21;
376// 0x22-0x2F unassigned
377constexpr Cmd cmdGetEventCount = 0x30;
378constexpr Cmd cmdSetEventDestination = 0x31;
379constexpr Cmd cmdSetEventReceptionState = 0x32;
380constexpr Cmd cmdSendIcmbEventMessage = 0x33;
381constexpr Cmd cmdGetEventDestination = 0x34;
382constexpr Cmd cmdGetEventReceptionState = 0x35;
383// 0xC0-0xFE OEM Commands
384constexpr Cmd cmdErrorReport = 0xFF;
385} // namespace bridge
386
387namespace dcmi
388{
389constexpr Cmd cmdGetDcmiCapabilitiesInfo = 0x01;
390constexpr Cmd cmdGetPowerReading = 0x02;
391constexpr Cmd cmdGetPowerLimit = 0x03;
392constexpr Cmd cmdSetPowerLimit = 0x04;
393constexpr Cmd cmdActDeactivatePwrLimit = 0x05;
394constexpr Cmd cmdGetAssetTag = 0x06;
395constexpr Cmd cmdGetDcmiSensorInfo = 0x07;
396constexpr Cmd cmdSetAssetTag = 0x08;
397constexpr Cmd cmdGetMgmtCntlrIdString = 0x09;
398constexpr Cmd cmdSetMgmtCntlrIdString = 0x0A;
399constexpr Cmd cmdSetThermalLimit = 0x0B;
400constexpr Cmd cmdGetThermalLimit = 0x0C;
401constexpr Cmd cmdGetTemperatureReadings = 0x10;
402constexpr Cmd cmdSetDcmiConfigParameters = 0x12;
403constexpr Cmd cmdGetDcmiConfigParameters = 0x13;
404} // namespace dcmi
405
406} // namespace ipmi