blob: 151aca1226556f6ba65f51638518e321ce89d65d [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);
30} // namespace impl
31
32/**
33 * @brief main IPMI handler registration function
34 *
35 * This function should be used to register all new-style IPMI handler
36 * functions. This function just passes the callback to makeHandler, which
37 * creates a new wrapper object that will automatically extract the appropriate
38 * parameters for the callback function as well as pack up the response.
39 *
40 * @param prio - priority at which to register; see api.hpp
41 * @param netFn - the IPMI net function number to register
42 * @param cmd - the IPMI command number to register
43 * @param priv - the IPMI user privilige required for this command
44 * @param handler - the callback function that will handle this request
45 *
46 * @return bool - success of registering the handler
47 */
48template <typename Handler>
49bool registerHandler(int prio, NetFn netFn, Cmd cmd, Privilege priv,
50 Handler&& handler)
51{
52 auto h = ipmi::makeHandler(std::forward<Handler>(handler));
53 return impl::registerHandler(prio, netFn, cmd, priv, h);
54}
55
56} // namespace ipmi
57
58#ifdef ALLOW_DEPRECATED_API
59/**
60 * @brief legacy IPMI handler registration function
61 *
62 * This function should be used to register all legacy IPMI handler
63 * functions. This function just behaves just as the legacy registration
64 * mechanism did, silently replacing any existing handler with a new one.
65 *
66 * @param netFn - the IPMI net function number to register
67 * @param cmd - the IPMI command number to register
68 * @param context - ignored
69 * @param handler - the callback function that will handle this request
70 * @param priv - the IPMI user privilige required for this command
71 */
72// [[deprecated("Use ipmi::registerHandler() instead")]]
73void ipmi_register_callback(ipmi_netfn_t netFn, ipmi_cmd_t cmd,
74 ipmi_context_t context, ipmid_callback_t handler,
75 ipmi_cmd_privilege_t priv);
76
77#endif /* ALLOW_DEPRECATED_API */
78
79// IPMI 2.0 and DCMI 1.5 standard commands, namespaced by NetFn
80// OEM and non-standard commands should be defined where they are used
81namespace ipmi
82{
83namespace app
84{
85// 0x00 reserved
86constexpr Cmd cmdGetDeviceId = 0x01;
87constexpr Cmd cmdColdReset = 0x02;
88constexpr Cmd cmdWarmReset = 0x03;
89constexpr Cmd cmdGetSelfTestResults = 0x04;
90constexpr Cmd cmdManufacturingTestOn = 0x05;
91constexpr Cmd cmdSetAcpiPowerState = 0x06;
92constexpr Cmd cmdGetAcpiPowerState = 0x07;
93constexpr Cmd cmdGetDeviceGuid = 0x08;
94constexpr Cmd cmdGetNetFnSupport = 0x09;
95constexpr Cmd cmdGetCmdSupport = 0x0A;
96constexpr Cmd cmdGetCmdSubFnSupport = 0x0B;
97constexpr Cmd cmdGetConfigurableCmds = 0x0C;
98constexpr Cmd cmdGetConfigurableCmdSubFns = 0x0D;
99// 0x0E-0x21 unassigned
100constexpr Cmd cmdResetWatchdogTimer = 0x22;
101// 0x23 unassigned
102constexpr Cmd cmdSetWatchdogTimer = 0x24;
103constexpr Cmd cmdGetWatchdogTimer = 0x25;
104// 0x26-0x2D unassigned
105constexpr Cmd cmdSetBmcGlobalEnables = 0x2E;
106constexpr Cmd cmdGetBmcGlobalEnables = 0x2F;
107constexpr Cmd cmdClearMessageFlags = 0x30;
108constexpr Cmd cmdGetMessageFlags = 0x31;
109constexpr Cmd cmdEnableMessageChannelRcv = 0x32;
110constexpr Cmd cmdGetMessage = 0x33;
111constexpr Cmd cmdSendMessage = 0x34;
112constexpr Cmd cmdReadEventMessageBuffer = 0x35;
113constexpr Cmd cmdGetBtIfaceCapabilities = 0x36;
114constexpr Cmd cmdGetSystemGuid = 0x37;
115constexpr Cmd cmdGetChannelAuthCapabilities = 0x38;
116constexpr Cmd cmdGetSessionChallenge = 0x39;
117constexpr Cmd cmdActivateSession = 0x3A;
118constexpr Cmd cmdSetSessionPrivilegeLevel = 0x3B;
119constexpr Cmd cmdCloseSession = 0x3C;
120constexpr Cmd cmdGetSessionInfo = 0x3D;
121// 0x3E unassigned
122constexpr Cmd cmdGetAuthCode = 0x3F;
123constexpr Cmd cmdSetChannelAccess = 0x40;
124constexpr Cmd cmdGetChannelAccess = 0x41;
125constexpr Cmd cmdGetChannelInfoCommand = 0x42;
126constexpr Cmd cmdSetUserAccessCommand = 0x43;
127constexpr Cmd cmdGetUserAccessCommand = 0x44;
128constexpr Cmd cmdSetUserName = 0x45;
129constexpr Cmd cmdGetUserNameCommand = 0x46;
130constexpr Cmd cmdSetUserPasswordCommand = 0x47;
131constexpr Cmd cmdActivatePayload = 0x48;
132constexpr Cmd cmdDeactivatePayload = 0x49;
133constexpr Cmd cmdGetPayloadActivationStatus = 0x4A;
134constexpr Cmd cmdGetPayloadInstanceInfo = 0x4B;
135constexpr Cmd cmdSetUserPayloadAccess = 0x4C;
136constexpr Cmd cmdGetUserPayloadAccess = 0x4D;
137constexpr Cmd cmdGetChannelPayloadSupport = 0x4E;
138constexpr Cmd cmdGetChannelPayloadVersion = 0x4F;
139constexpr Cmd cmdGetChannelOemPayloadInfo = 0x50;
140// 0x51 unassigned
141constexpr Cmd cmdMasterWriteRead = 0x52;
142// 0x53 unassigned
143constexpr Cmd cmdGetChannelCipherSuites = 0x54;
144constexpr Cmd cmdSuspendResumePayloadEnc = 0x55;
145constexpr Cmd cmdSetChannelSecurityKeys = 0x56;
146constexpr Cmd cmdGetSystemIfCapabilities = 0x57;
147constexpr Cmd cmdSetSystemInfoParameters = 0x58;
148constexpr Cmd cmdGetSystemInfoParameters = 0x59;
149// 0x5A-0x5F unassigned
150constexpr Cmd cmdSetCommandEnables = 0x60;
151constexpr Cmd cmdGetCommandEnables = 0x61;
152constexpr Cmd cmdSetCommandSubFnEnables = 0x62;
153constexpr Cmd cmdGetCommandSubFnEnables = 0x63;
154constexpr Cmd cmdGetOemNetFnIanaSupport = 0x64;
155// 0x65-0xff unassigned
156} // namespace app
157
158namespace chassis
159{
160constexpr Cmd cmdGetChassisCapabilities = 0x00;
161constexpr Cmd cmdGetChassisStatus = 0x01;
162constexpr Cmd cmdChassisControl = 0x02;
163constexpr Cmd cmdChassisReset = 0x03;
164constexpr Cmd cmdChassisIdentify = 0x04;
165constexpr Cmd cmdSetChassisCapabilities = 0x05;
166constexpr Cmd cmdSetPowerRestorePolicy = 0x06;
167constexpr Cmd cmdGetSystemRestartCause = 0x07;
168constexpr Cmd cmdSetSystemBootOptions = 0x08;
169constexpr Cmd cmdGetSystemBootOptions = 0x09;
170constexpr Cmd cmdSetFrontPanelButtonEnables = 0x0A;
171constexpr Cmd cmdSetPowerCycleInterval = 0x0B;
172// 0x0C-0x0E unassigned
173constexpr Cmd cmdGetPohCounter = 0x0F;
174// 0x10-0xFF unassigned
175} // namespace chassis
176
177namespace sensor_event
178{
179constexpr Cmd cmdSetEventReceiver = 0x00;
180constexpr Cmd cmdGetEventReceiver = 0x01;
181constexpr Cmd cmdPlatformEvent = 0x02;
182// 0x03-0x0F unassigned
183constexpr Cmd cmdGetPefCapabilities = 0x10;
184constexpr Cmd cmdArmPefPostponeTimer = 0x11;
185constexpr Cmd cmdSetPefConfigurationParams = 0x12;
186constexpr Cmd cmdGetPefConfigurationParams = 0x13;
187constexpr Cmd cmdSetLastProcessedEventId = 0x14;
188constexpr Cmd cmdGetLastProcessedEventId = 0x15;
189constexpr Cmd cmdAlertImmediate = 0x16;
190constexpr Cmd cmdPetAcknowledge = 0x17;
191constexpr Cmd cmdGetDeviceSdrInfo = 0x20;
192constexpr Cmd cmdGetDeviceSdr = 0x21;
193constexpr Cmd cmdReserveDeviceSdrRepository = 0x22;
194constexpr Cmd cmdGetSensorReadingFactors = 0x23;
195constexpr Cmd cmdSetSensorHysteresis = 0x24;
196constexpr Cmd cmdGetSensorHysteresis = 0x25;
197constexpr Cmd cmdSetSensorThreshold = 0x26;
198constexpr Cmd cmdGetSensorThreshold = 0x27;
199constexpr Cmd cmdSetSensorEventEnable = 0x28;
200constexpr Cmd cmdGetSensorEventEnable = 0x29;
201constexpr Cmd cmdRearmSensorEvents = 0x2A;
202constexpr Cmd cmdGetSensorEventStatus = 0x2B;
203constexpr Cmd cmdGetSensorReading = 0x2D;
204constexpr Cmd cmdSetSensorType = 0x2E;
205constexpr Cmd cmdGetSensorType = 0x2F;
206constexpr Cmd cmdSetSensorReadingAndEvtSts = 0x30;
207// 0x31-0xFF unassigned
208} // namespace sensor_event
209
210namespace storage
211{
212// 0x00-0x0F unassigned
213constexpr Cmd cmdGetFruInventoryAreaInfo = 0x10;
214constexpr Cmd cmdReadFruData = 0x11;
215constexpr Cmd cmdWriteFruData = 0x12;
216// 0x13-0x1F unassigned
217constexpr Cmd cmdGetSdrRepositoryInfo = 0x20;
218constexpr Cmd cmdGetSdrRepositoryAllocInfo = 0x21;
219constexpr Cmd cmdReserveSdrRepository = 0x22;
220constexpr Cmd cmdGetSdr = 0x23;
221constexpr Cmd cmdAddSdr = 0x24;
222constexpr Cmd cmdPartialAddSdr = 0x25;
223constexpr Cmd cmdDeleteSdr = 0x26;
224constexpr Cmd cmdClearSdrRepository = 0x27;
225constexpr Cmd cmdGetSdrRepositoryTime = 0x28;
226constexpr Cmd cmdSetSdrRepositoryTime = 0x29;
227constexpr Cmd cmdEnterSdrRepoUpdateMode = 0x2A;
228constexpr Cmd cmdExitSdrReposUpdateMode = 0x2B;
229constexpr Cmd cmdRunInitializationAgent = 0x2C;
230// 0x2D-0x3F unassigned
231constexpr Cmd cmdGetSelInfo = 0x40;
232constexpr Cmd cmdGetSelAllocationInfo = 0x41;
233constexpr Cmd cmdReserveSel = 0x42;
234constexpr Cmd cmdGetSelEntry = 0x43;
235constexpr Cmd cmdAddSelEntry = 0x44;
236constexpr Cmd cmdPartialAddSelEntry = 0x45;
237constexpr Cmd cmdDeleteSelEntry = 0x46;
238constexpr Cmd cmdClearSel = 0x47;
239constexpr Cmd cmdGetSelTime = 0x48;
240constexpr Cmd cmdSetSelTime = 0x49;
241constexpr Cmd cmdGetAuxiliaryLogStatus = 0x5A;
242constexpr Cmd cmdSetAuxiliaryLogStatus = 0x5B;
243constexpr Cmd cmdGetSelTimeUtcOffset = 0x5C;
244constexpr Cmd cmdSetSelTimeUtcOffset = 0x5D;
245// 0x5E-0xFF unassigned
246} // namespace storage
247
248namespace transport
249{
250constexpr Cmd cmdSetLanConfigParameters = 0x01;
251constexpr Cmd cmdGetLanConfigParameters = 0x02;
252constexpr Cmd cmdSuspendBmcArps = 0x03;
253constexpr Cmd cmdGetIpUdpRmcpStatistics = 0x04;
254constexpr Cmd cmdSetSerialModemConfig = 0x10;
255constexpr Cmd cmdGetSerialModemConfig = 0x11;
256constexpr Cmd cmdSetSerialModemMux = 0x12;
257constexpr Cmd cmdGetTapResponseCodes = 0x13;
258constexpr Cmd cmdSetPppUdpProxyTransmitData = 0x14;
259constexpr Cmd cmdGetPppUdpProxyTransmitData = 0x15;
260constexpr Cmd cmdSendPppUdpProxyPacket = 0x16;
261constexpr Cmd cmdGetPppUdpProxyReceiveData = 0x17;
262constexpr Cmd cmdSerialModemConnActive = 0x18;
263constexpr Cmd cmdCallback = 0x19;
264constexpr Cmd cmdSetUserCallbackOptions = 0x1A;
265constexpr Cmd cmdGetUserCallbackOptions = 0x1B;
266constexpr Cmd cmdSetSerialRoutingMux = 0x1C;
267constexpr Cmd cmdSolActivating = 0x20;
268constexpr Cmd cmdSetSolConfigParameters = 0x21;
269constexpr Cmd cmdGetSolConfigParameters = 0x22;
270constexpr Cmd cmdForwardedCommand = 0x30;
271constexpr Cmd cmdSetForwardedCommands = 0x31;
272constexpr Cmd cmdGetForwardedCommands = 0x32;
273constexpr Cmd cmdEnableForwardedCommands = 0x33;
274} // namespace transport
275
276namespace bridge
277{
278constexpr Cmd cmdGetBridgeState = 0x00;
279constexpr Cmd cmdSetBridgeState = 0x01;
280constexpr Cmd cmdGetIcmbAddress = 0x02;
281constexpr Cmd cmdSetIcmbAddress = 0x03;
282constexpr Cmd cmdSetBridgeProxyAddress = 0x04;
283constexpr Cmd cmdGetBridgeStatistics = 0x05;
284constexpr Cmd cmdGetIcmbCapabilities = 0x06;
285constexpr Cmd cmdClearBridgeStatistics = 0x08;
286constexpr Cmd cmdGetBridgeProxyAddress = 0x09;
287constexpr Cmd cmdGetIcmbConnectorInfo = 0x0A;
288constexpr Cmd cmdGetIcmbConnectionId = 0x0B;
289constexpr Cmd cmdSendIcmbConnectionId = 0x0C;
290constexpr Cmd cmdPrepareForDiscovery = 0x10;
291constexpr Cmd cmdGetAddresses = 0x11;
292constexpr Cmd cmdSetDiscovered = 0x12;
293constexpr Cmd cmdGetChassisDeviceId = 0x13;
294constexpr Cmd cmdSetChassisDeviceId = 0x14;
295constexpr Cmd cmdBridgeRequest = 0x20;
296constexpr Cmd cmdBridgeMessage = 0x21;
297// 0x22-0x2F unassigned
298constexpr Cmd cmdGetEventCount = 0x30;
299constexpr Cmd cmdSetEventDestination = 0x31;
300constexpr Cmd cmdSetEventReceptionState = 0x32;
301constexpr Cmd cmdSendIcmbEventMessage = 0x33;
302constexpr Cmd cmdGetEventDestination = 0x34;
303constexpr Cmd cmdGetEventReceptionState = 0x35;
304// 0xC0-0xFE OEM Commands
305constexpr Cmd cmdErrorReport = 0xFF;
306} // namespace bridge
307
308namespace dcmi
309{
310constexpr Cmd cmdGetDcmiCapabilitiesInfo = 0x01;
311constexpr Cmd cmdGetPowerReading = 0x02;
312constexpr Cmd cmdGetPowerLimit = 0x03;
313constexpr Cmd cmdSetPowerLimit = 0x04;
314constexpr Cmd cmdActDeactivatePwrLimit = 0x05;
315constexpr Cmd cmdGetAssetTag = 0x06;
316constexpr Cmd cmdGetDcmiSensorInfo = 0x07;
317constexpr Cmd cmdSetAssetTag = 0x08;
318constexpr Cmd cmdGetMgmtCntlrIdString = 0x09;
319constexpr Cmd cmdSetMgmtCntlrIdString = 0x0A;
320constexpr Cmd cmdSetThermalLimit = 0x0B;
321constexpr Cmd cmdGetThermalLimit = 0x0C;
322constexpr Cmd cmdGetTemperatureReadings = 0x10;
323constexpr Cmd cmdSetDcmiConfigParameters = 0x12;
324constexpr Cmd cmdGetDcmiConfigParameters = 0x13;
325} // namespace dcmi
326
327} // namespace ipmi