blob: 321526f3eb1362d79fbc32fac72a9afd065d437e [file] [log] [blame]
AppaRao Puli071f3f22018-05-24 16:45:30 +05301/*
2// Copyright (c) 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
AppaRao Puli071f3f22018-05-24 16:45:30 +053017#include "apphandler.hpp"
18#include "channel_layer.hpp"
19
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000020#include <ipmid/api.hpp>
George Liu82844ef2024-07-17 17:03:56 +080021#include <phosphor-logging/lg2.hpp>
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050022
AppaRao Puli071f3f22018-05-24 16:45:30 +053023#include <regex>
24
AppaRao Puli071f3f22018-05-24 16:45:30 +053025namespace ipmi
26{
27
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000028/** @brief implements the set channel access command
29 * @ param ctx - context pointer
30 * @ param channel - channel number
31 * @ param reserved - skip 4 bits
32 * @ param accessMode - access mode for IPMI messaging
33 * @ param usrAuth - user level authentication (enable/disable)
34 * @ param msgAuth - per message authentication (enable/disable)
35 * @ param alertDisabled - PEF alerting (enable/disable)
36 * @ param chanAccess - channel access
37 * @ param channelPrivLimit - channel privilege limit
38 * @ param reserved - skip 3 bits
39 * @ param channelPrivMode - channel priviledge mode
40 *
41 * @ returns IPMI completion code
42 **/
43RspType<> ipmiSetChannelAccess(Context::ptr ctx, uint4_t channel,
44 uint4_t reserved1, uint3_t accessMode,
45 bool usrAuth, bool msgAuth, bool alertDisabled,
46 uint2_t chanAccess, uint4_t channelPrivLimit,
47 uint2_t reserved2, uint2_t channelPrivMode)
AppaRao Puli071f3f22018-05-24 16:45:30 +053048{
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +000049 if (reserved1 || reserved2 ||
50 !isValidPrivLimit(static_cast<uint8_t>(channelPrivLimit)))
AppaRao Puli071f3f22018-05-24 16:45:30 +053051 {
George Liu82844ef2024-07-17 17:03:56 +080052 lg2::debug("Set channel access - Invalid field in request");
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000053 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +053054 }
55
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +000056 const uint8_t chNum =
57 convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
58 if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) ||
59 (!isValidChannel(chNum)))
AppaRao Puli071f3f22018-05-24 16:45:30 +053060 {
George Liu82844ef2024-07-17 17:03:56 +080061 lg2::debug("Set channel access - No support on channel: {CHANNEL}",
62 "CHANNEL", chNum);
anil kumar appanaddb1f442019-07-04 18:07:27 +000063 return response(ccActionNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +053064 }
65
66 ChannelAccess chActData;
67 ChannelAccess chNVData;
68 uint8_t setActFlag = 0;
69 uint8_t setNVFlag = 0;
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000070 Cc compCode;
AppaRao Puli071f3f22018-05-24 16:45:30 +053071
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000072 // cannot static cast directly from uint2_t to enum; must go via int
73 uint8_t channelAccessAction = static_cast<uint8_t>(chanAccess);
74 switch (static_cast<EChannelActionType>(channelAccessAction))
AppaRao Puli071f3f22018-05-24 16:45:30 +053075 {
76 case doNotSet:
AppaRao Puli071f3f22018-05-24 16:45:30 +053077 break;
78 case nvData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000079 chNVData.accessMode = static_cast<uint8_t>(accessMode);
80 chNVData.userAuthDisabled = usrAuth;
81 chNVData.perMsgAuthDisabled = msgAuth;
82 chNVData.alertingDisabled = alertDisabled;
AppaRao Puli071f3f22018-05-24 16:45:30 +053083 setNVFlag |= (setAccessMode | setUserAuthEnabled |
84 setMsgAuthEnabled | setAlertingEnabled);
85 break;
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000086
AppaRao Puli071f3f22018-05-24 16:45:30 +053087 case activeData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000088 chActData.accessMode = static_cast<uint8_t>(accessMode);
89 chActData.userAuthDisabled = usrAuth;
90 chActData.perMsgAuthDisabled = msgAuth;
91 chActData.alertingDisabled = alertDisabled;
AppaRao Puli071f3f22018-05-24 16:45:30 +053092 setActFlag |= (setAccessMode | setUserAuthEnabled |
93 setMsgAuthEnabled | setAlertingEnabled);
94 break;
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000095
AppaRao Puli071f3f22018-05-24 16:45:30 +053096 case reserved:
97 default:
George Liu82844ef2024-07-17 17:03:56 +080098 lg2::debug("Set channel access - Invalid access set mode");
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +000099 return response(ccAccessModeNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530100 }
101
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000102 // cannot static cast directly from uint2_t to enum; must go via int
103 uint8_t channelPrivAction = static_cast<uint8_t>(channelPrivMode);
104 switch (static_cast<EChannelActionType>(channelPrivAction))
AppaRao Puli071f3f22018-05-24 16:45:30 +0530105 {
106 case doNotSet:
AppaRao Puli071f3f22018-05-24 16:45:30 +0530107 break;
108 case nvData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000109 chNVData.privLimit = static_cast<uint8_t>(channelPrivLimit);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530110 setNVFlag |= setPrivLimit;
111 break;
112 case activeData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000113 chActData.privLimit = static_cast<uint8_t>(channelPrivLimit);
114
AppaRao Puli071f3f22018-05-24 16:45:30 +0530115 setActFlag |= setPrivLimit;
116 break;
117 case reserved:
118 default:
George Liu82844ef2024-07-17 17:03:56 +0800119 lg2::debug("Set channel access - Invalid access priv mode");
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000120 return response(ccAccessModeNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530121 }
122
123 if (setNVFlag != 0)
124 {
125 compCode = setChannelAccessPersistData(chNum, chNVData, setNVFlag);
NITIN SHARMAb541a5a2019-07-18 12:46:59 +0000126 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530127 {
George Liu82844ef2024-07-17 17:03:56 +0800128 lg2::debug("Set channel access - Failed to set access data");
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000129 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530130 }
131 }
132
133 if (setActFlag != 0)
134 {
135 compCode = setChannelAccessData(chNum, chActData, setActFlag);
NITIN SHARMAb541a5a2019-07-18 12:46:59 +0000136 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530137 {
George Liu82844ef2024-07-17 17:03:56 +0800138 lg2::debug("Set channel access - Failed to set access data");
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000139 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530140 }
141 }
142
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000143 return responseSuccess();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530144}
145
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530146/** @brief implements the get channel access command
147 * @ param ctx - context pointer
148 * @ param channel - channel number
149 * @ param reserved1 - skip 4 bits
150 * @ param reserved2 - skip 6 bits
151 * @ param accessMode - get access mode
152 *
153 * @returns ipmi completion code plus response data
154 * - accessMode - get access mode
155 * - usrAuthDisabled - user level authentication status
156 * - msgAuthDisabled - message level authentication status
157 * - alertDisabled - alerting status
158 * - reserved - skip 2 bits
159 * - privLimit - channel privilege limit
160 * - reserved - skip 4 bits
161 * */
162ipmi ::RspType<uint3_t, // access mode,
163 bool, // user authentication status,
164 bool, // message authentication status,
165 bool, // alerting status,
166 uint2_t, // reserved,
167
168 uint4_t, // channel privilege,
169 uint4_t // reserved
170 >
171 ipmiGetChannelAccess(Context::ptr ctx, uint4_t channel, uint4_t reserved1,
172 uint6_t reserved2, uint2_t accessSetMode)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530173{
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000174 if (reserved1 || reserved2)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530175 {
George Liu82844ef2024-07-17 17:03:56 +0800176 lg2::debug("Get channel access - Invalid field in request");
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530177 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530178 }
179
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700180 if ((types::enum_cast<EChannelActionType>(accessSetMode) == doNotSet) ||
181 (types::enum_cast<EChannelActionType>(accessSetMode) == reserved))
AppaRao Puli071f3f22018-05-24 16:45:30 +0530182 {
George Liu82844ef2024-07-17 17:03:56 +0800183 lg2::debug("Get channel access - Invalid Access mode");
AppaRao Pulic4f4f7a2020-07-13 16:43:59 +0530184 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530185 }
186
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000187 const uint8_t chNum =
188 convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
189
190 if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) ||
191 (!isValidChannel(chNum)))
AppaRao Puli071f3f22018-05-24 16:45:30 +0530192 {
George Liu82844ef2024-07-17 17:03:56 +0800193 lg2::debug("Get channel access - No support on channel: {CHANNEL}",
194 "CHANNEL", chNum);
anil kumar appanaddb1f442019-07-04 18:07:27 +0000195 return response(ccActionNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530196 }
197
PavanKumarIntel3771f5f2023-11-02 06:26:42 +0000198 ChannelAccess chAccess = {};
AppaRao Puli071f3f22018-05-24 16:45:30 +0530199
William A. Kennington III4c521022023-07-28 13:07:30 -0700200 Cc compCode = ipmi::ccUnspecifiedError;
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530201
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700202 if (types::enum_cast<EChannelActionType>(accessSetMode) == nvData)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530203 {
204 compCode = getChannelAccessPersistData(chNum, chAccess);
205 }
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700206 else if (types::enum_cast<EChannelActionType>(accessSetMode) == activeData)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530207 {
208 compCode = getChannelAccessData(chNum, chAccess);
209 }
210
NITIN SHARMAb541a5a2019-07-18 12:46:59 +0000211 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530212 {
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530213 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530214 }
215
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530216 constexpr uint2_t reservedOut1 = 0;
217 constexpr uint4_t reservedOut2 = 0;
AppaRao Puli071f3f22018-05-24 16:45:30 +0530218
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530219 return responseSuccess(
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700220 types::enum_cast<uint3_t>(chAccess.accessMode),
221 chAccess.userAuthDisabled, chAccess.perMsgAuthDisabled,
222 chAccess.alertingDisabled, reservedOut1,
223 types::enum_cast<uint4_t>(chAccess.privLimit), reservedOut2);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530224}
225
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700226/** @brief implements the get channel info command
227 * @ param ctx - context pointer
228 * @ param channel - channel number
229 * @ param reserved - skip 4 bits
230 *
231 * @returns ipmi completion code plus response data
232 * - chNum - the channel number for this request
233 * - mediumType - see Table 6-3, Channel Medium Type Numbers
234 * - protocolType - Table 6-2, Channel Protocol Type Numbers
235 * - activeSessionCount - number of active sessions
236 * - sessionType - channel support for sessions
237 * - vendorId - vendor for this channel protocol (IPMI - 7154)
238 * - auxChInfo - auxiliary info for channel
239 * */
240RspType<uint4_t, // chNum
241 uint4_t, // reserved
242 uint7_t, // mediumType
243 bool, // reserved
244 uint5_t, // protocolType
245 uint3_t, // reserved
246 uint6_t, // activeSessionCount
247 uint2_t, // sessionType
248 uint24_t, // Vendor IANA
249 uint16_t // aux info
250 >
251 ipmiGetChannelInfo(Context::ptr ctx, uint4_t channel, uint4_t reserved)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530252{
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000253 if (reserved)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530254 {
George Liu82844ef2024-07-17 17:03:56 +0800255 lg2::debug("Get channel access - Invalid field in request");
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700256 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530257 }
258
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -0500259 uint8_t chNum = convertCurrentChannelNum(static_cast<uint8_t>(channel),
260 ctx->channel);
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000261 if (!isValidChannel(chNum))
262 {
George Liu82844ef2024-07-17 17:03:56 +0800263 lg2::debug("Get channel Info - No support on channel: {CHANNEL}",
264 "CHANNEL", chNum);
Jayaprakash Mutyalaafd12b42020-07-07 01:06:57 +0000265 return responseInvalidFieldRequest();
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000266 }
267
AppaRao Puli071f3f22018-05-24 16:45:30 +0530268 ChannelInfo chInfo;
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700269 Cc compCode = getChannelInfo(chNum, chInfo);
270 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530271 {
George Liu82844ef2024-07-17 17:03:56 +0800272 lg2::error("Failed to get channel info, channel: {CHANNEL}, "
273 "errno: {ERRNO}",
274 "CHANNEL", chNum, "ERRNO", compCode);
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700275 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530276 }
277
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700278 constexpr uint4_t reserved1 = 0;
279 constexpr bool reserved2 = false;
280 constexpr uint3_t reserved3 = 0;
281 uint8_t mediumType = chInfo.mediumType;
282 uint8_t protocolType = chInfo.protocolType;
283 uint2_t sessionType = chInfo.sessionSupported;
284 uint6_t activeSessionCount = getChannelActiveSessions(chNum);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530285 // IPMI Spec: The IPMI Enterprise Number is: 7154 (decimal)
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700286 constexpr uint24_t vendorId = 7154;
287 constexpr uint16_t auxChInfo = 0;
AppaRao Puli071f3f22018-05-24 16:45:30 +0530288
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700289 return responseSuccess(chNum, reserved1, mediumType, reserved2,
290 protocolType, reserved3, activeSessionCount,
291 sessionType, vendorId, auxChInfo);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530292}
293
Vernon Maueryf6092892019-05-02 16:35:10 -0700294namespace
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530295{
Vernon Maueryf6092892019-05-02 16:35:10 -0700296constexpr uint16_t standardPayloadBit(PayloadType p)
297{
298 return (1 << static_cast<size_t>(p));
299}
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530300
Vernon Maueryf6092892019-05-02 16:35:10 -0700301constexpr uint16_t sessionPayloadBit(PayloadType p)
302{
303 constexpr size_t sessionShift =
304 static_cast<size_t>(PayloadType::OPEN_SESSION_REQUEST);
305 return ((1 << static_cast<size_t>(p)) >> sessionShift);
306}
307} // namespace
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530308
Vernon Maueryf6092892019-05-02 16:35:10 -0700309/** @brief implements get channel payload support command
310 * @ param ctx - ipmi context pointer
311 * @ param chNum - channel number
312 * @ param reserved - skip 4 bits
313 *
314 * @ returns IPMI completion code plus response data
315 * - stdPayloadType - bitmask of supported standard payload types
316 * - sessSetupPayloadType - bitmask of supported session setup payload types
317 * - OEMPayloadType - bitmask of supported OEM payload types
318 * - reserved - 2 bytes of 0
319 **/
320RspType<uint16_t, // stdPayloadType
321 uint16_t, // sessSetupPayloadType
322 uint16_t, // OEMPayloadType
323 uint16_t // reserved
324 >
325 ipmiGetChannelPayloadSupport(Context::ptr ctx, uint4_t channel,
326 uint4_t reserved)
327{
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -0500328 uint8_t chNum = convertCurrentChannelNum(static_cast<uint8_t>(channel),
329 ctx->channel);
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000330
331 if (!doesDeviceExist(chNum) || !isValidChannel(chNum) || reserved)
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530332 {
George Liu82844ef2024-07-17 17:03:56 +0800333 lg2::debug("Get channel payload - Invalid field in request");
Vernon Maueryf6092892019-05-02 16:35:10 -0700334 return responseInvalidFieldRequest();
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530335 }
336
337 // Session support is available in active LAN channels.
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000338 if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530339 {
George Liu82844ef2024-07-17 17:03:56 +0800340 lg2::debug("Get channel payload - No support on channel");
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000341 return response(ccActionNotSupportedForChannel);
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530342 }
Vernon Maueryf6092892019-05-02 16:35:10 -0700343 constexpr uint16_t stdPayloadType = standardPayloadBit(PayloadType::IPMI) |
344 standardPayloadBit(PayloadType::SOL);
345 constexpr uint16_t sessSetupPayloadType =
346 sessionPayloadBit(PayloadType::OPEN_SESSION_REQUEST) |
347 sessionPayloadBit(PayloadType::OPEN_SESSION_RESPONSE) |
348 sessionPayloadBit(PayloadType::RAKP1) |
349 sessionPayloadBit(PayloadType::RAKP2) |
350 sessionPayloadBit(PayloadType::RAKP3) |
351 sessionPayloadBit(PayloadType::RAKP4);
352 constexpr uint16_t OEMPayloadType = 0;
353 constexpr uint16_t rspRsvd = 0;
354 return responseSuccess(stdPayloadType, sessSetupPayloadType, OEMPayloadType,
355 rspRsvd);
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530356}
357
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000358/** @brief implements the get channel payload version command
359 * @param ctx - IPMI context pointer (for channel)
360 * @param chNum - channel number to get info about
361 * @param reserved - skip 4 bits
362 * @param payloadTypeNum - to get payload type info
363
364 * @returns IPMI completion code plus response data
365 * - formatVersion - BCD encoded format version info
366 */
367
368RspType<uint8_t> // formatVersion
369 ipmiGetChannelPayloadVersion(Context::ptr ctx, uint4_t chNum,
370 uint4_t reserved, uint8_t payloadTypeNum)
371{
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -0500372 uint8_t channel = convertCurrentChannelNum(static_cast<uint8_t>(chNum),
373 ctx->channel);
Manoj Ashok271d9c22021-07-22 23:21:31 +0530374 constexpr uint8_t payloadTypeNotSupported = 0x80;
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000375
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000376 if (reserved || !isValidChannel(channel))
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000377 {
George Liu82844ef2024-07-17 17:03:56 +0800378 lg2::debug("Get channel payload version - Invalid field in request");
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000379 return responseInvalidFieldRequest();
380 }
381
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000382 if (getChannelSessionSupport(channel) == EChannelSessSupported::none)
383 {
George Liu82844ef2024-07-17 17:03:56 +0800384 lg2::debug("Get channel payload version - No support on channel");
Manoj Ashok271d9c22021-07-22 23:21:31 +0530385 return response(payloadTypeNotSupported);
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000386 }
387
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000388 if (!isValidPayloadType(static_cast<PayloadType>(payloadTypeNum)))
389 {
George Liu82844ef2024-07-17 17:03:56 +0800390 lg2::error("Get channel payload version - Payload type unavailable");
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000391
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000392 return response(payloadTypeNotSupported);
393 }
394
395 // BCD encoded version representation - 1.0
396 constexpr uint8_t formatVersion = 0x10;
397
398 return responseSuccess(formatVersion);
399}
400
William A. Kennington III343d0612018-12-10 15:56:24 -0800401void registerChannelFunctions() __attribute__((constructor));
AppaRao Puli071f3f22018-05-24 16:45:30 +0530402void registerChannelFunctions()
403{
404 ipmiChannelInit();
405
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000406 registerHandler(prioOpenBmcBase, netFnApp, app::cmdSetChannelAccess,
407 Privilege::Admin, ipmiSetChannelAccess);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530408
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530409 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelAccess,
410 Privilege::User, ipmiGetChannelAccess);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530411
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700412 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelInfoCommand,
413 Privilege::User, ipmiGetChannelInfo);
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530414
Vernon Maueryf6092892019-05-02 16:35:10 -0700415 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadSupport,
416 Privilege::User, ipmiGetChannelPayloadSupport);
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000417
418 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadVersion,
419 Privilege::User, ipmiGetChannelPayloadVersion);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530420}
421
422} // namespace ipmi