blob: b4caf0cef0674ae621a51bc5eff403b7e89d4ad0 [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 "channel_layer.hpp"
18
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000019#include <ipmid/api.hpp>
George Liu82844ef2024-07-17 17:03:56 +080020#include <phosphor-logging/lg2.hpp>
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -050021
AppaRao Puli071f3f22018-05-24 16:45:30 +053022#include <regex>
23
AppaRao Puli071f3f22018-05-24 16:45:30 +053024namespace ipmi
25{
26
George Liu36627e82025-07-08 13:53:25 +080027constexpr Cc ccPayloadTypeNotSupported = 0x80;
28
29static inline auto responsePayloadTypeNotSupported()
30{
31 return response(ccPayloadTypeNotSupported);
32}
33
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000034/** @brief implements the set channel access command
35 * @ param ctx - context pointer
36 * @ param channel - channel number
37 * @ param reserved - skip 4 bits
38 * @ param accessMode - access mode for IPMI messaging
39 * @ param usrAuth - user level authentication (enable/disable)
40 * @ param msgAuth - per message authentication (enable/disable)
41 * @ param alertDisabled - PEF alerting (enable/disable)
42 * @ param chanAccess - channel access
43 * @ param channelPrivLimit - channel privilege limit
44 * @ param reserved - skip 3 bits
45 * @ param channelPrivMode - channel priviledge mode
46 *
47 * @ returns IPMI completion code
48 **/
Patrick Williams1318a5e2024-08-16 15:19:54 -040049RspType<> ipmiSetChannelAccess(
50 Context::ptr ctx, uint4_t channel, uint4_t reserved1, uint3_t accessMode,
51 bool usrAuth, bool msgAuth, bool alertDisabled, uint2_t chanAccess,
52 uint4_t channelPrivLimit, uint2_t reserved2, uint2_t channelPrivMode)
AppaRao Puli071f3f22018-05-24 16:45:30 +053053{
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +000054 if (reserved1 || reserved2 ||
55 !isValidPrivLimit(static_cast<uint8_t>(channelPrivLimit)))
AppaRao Puli071f3f22018-05-24 16:45:30 +053056 {
George Liu82844ef2024-07-17 17:03:56 +080057 lg2::debug("Set channel access - Invalid field in request");
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000058 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +053059 }
60
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +000061 const uint8_t chNum =
62 convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
63 if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) ||
64 (!isValidChannel(chNum)))
AppaRao Puli071f3f22018-05-24 16:45:30 +053065 {
George Liu82844ef2024-07-17 17:03:56 +080066 lg2::debug("Set channel access - No support on channel: {CHANNEL}",
67 "CHANNEL", chNum);
anil kumar appanaddb1f442019-07-04 18:07:27 +000068 return response(ccActionNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +053069 }
70
71 ChannelAccess chActData;
72 ChannelAccess chNVData;
73 uint8_t setActFlag = 0;
74 uint8_t setNVFlag = 0;
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000075 Cc compCode;
AppaRao Puli071f3f22018-05-24 16:45:30 +053076
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000077 // cannot static cast directly from uint2_t to enum; must go via int
78 uint8_t channelAccessAction = static_cast<uint8_t>(chanAccess);
79 switch (static_cast<EChannelActionType>(channelAccessAction))
AppaRao Puli071f3f22018-05-24 16:45:30 +053080 {
81 case doNotSet:
AppaRao Puli071f3f22018-05-24 16:45:30 +053082 break;
83 case nvData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000084 chNVData.accessMode = static_cast<uint8_t>(accessMode);
85 chNVData.userAuthDisabled = usrAuth;
86 chNVData.perMsgAuthDisabled = msgAuth;
87 chNVData.alertingDisabled = alertDisabled;
AppaRao Puli071f3f22018-05-24 16:45:30 +053088 setNVFlag |= (setAccessMode | setUserAuthEnabled |
89 setMsgAuthEnabled | setAlertingEnabled);
90 break;
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000091
AppaRao Puli071f3f22018-05-24 16:45:30 +053092 case activeData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +000093 chActData.accessMode = static_cast<uint8_t>(accessMode);
94 chActData.userAuthDisabled = usrAuth;
95 chActData.perMsgAuthDisabled = msgAuth;
96 chActData.alertingDisabled = alertDisabled;
AppaRao Puli071f3f22018-05-24 16:45:30 +053097 setActFlag |= (setAccessMode | setUserAuthEnabled |
98 setMsgAuthEnabled | setAlertingEnabled);
99 break;
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000100
AppaRao Puli071f3f22018-05-24 16:45:30 +0530101 case reserved:
102 default:
George Liu82844ef2024-07-17 17:03:56 +0800103 lg2::debug("Set channel access - Invalid access set mode");
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000104 return response(ccAccessModeNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530105 }
106
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000107 // cannot static cast directly from uint2_t to enum; must go via int
108 uint8_t channelPrivAction = static_cast<uint8_t>(channelPrivMode);
109 switch (static_cast<EChannelActionType>(channelPrivAction))
AppaRao Puli071f3f22018-05-24 16:45:30 +0530110 {
111 case doNotSet:
AppaRao Puli071f3f22018-05-24 16:45:30 +0530112 break;
113 case nvData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000114 chNVData.privLimit = static_cast<uint8_t>(channelPrivLimit);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530115 setNVFlag |= setPrivLimit;
116 break;
117 case activeData:
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000118 chActData.privLimit = static_cast<uint8_t>(channelPrivLimit);
119
AppaRao Puli071f3f22018-05-24 16:45:30 +0530120 setActFlag |= setPrivLimit;
121 break;
122 case reserved:
123 default:
George Liu82844ef2024-07-17 17:03:56 +0800124 lg2::debug("Set channel access - Invalid access priv mode");
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000125 return response(ccAccessModeNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530126 }
127
128 if (setNVFlag != 0)
129 {
130 compCode = setChannelAccessPersistData(chNum, chNVData, setNVFlag);
NITIN SHARMAb541a5a2019-07-18 12:46:59 +0000131 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530132 {
George Liu82844ef2024-07-17 17:03:56 +0800133 lg2::debug("Set channel access - Failed to set access data");
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000134 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530135 }
136 }
137
138 if (setActFlag != 0)
139 {
140 compCode = setChannelAccessData(chNum, chActData, setActFlag);
NITIN SHARMAb541a5a2019-07-18 12:46:59 +0000141 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530142 {
George Liu82844ef2024-07-17 17:03:56 +0800143 lg2::debug("Set channel access - Failed to set access data");
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000144 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530145 }
146 }
147
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000148 return responseSuccess();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530149}
150
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530151/** @brief implements the get channel access command
152 * @ param ctx - context pointer
153 * @ param channel - channel number
154 * @ param reserved1 - skip 4 bits
155 * @ param reserved2 - skip 6 bits
156 * @ param accessMode - get access mode
157 *
158 * @returns ipmi completion code plus response data
159 * - accessMode - get access mode
160 * - usrAuthDisabled - user level authentication status
161 * - msgAuthDisabled - message level authentication status
162 * - alertDisabled - alerting status
163 * - reserved - skip 2 bits
164 * - privLimit - channel privilege limit
165 * - reserved - skip 4 bits
166 * */
167ipmi ::RspType<uint3_t, // access mode,
168 bool, // user authentication status,
169 bool, // message authentication status,
170 bool, // alerting status,
171 uint2_t, // reserved,
172
173 uint4_t, // channel privilege,
174 uint4_t // reserved
175 >
176 ipmiGetChannelAccess(Context::ptr ctx, uint4_t channel, uint4_t reserved1,
177 uint6_t reserved2, uint2_t accessSetMode)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530178{
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000179 if (reserved1 || reserved2)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530180 {
George Liu82844ef2024-07-17 17:03:56 +0800181 lg2::debug("Get channel access - Invalid field in request");
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530182 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530183 }
184
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700185 if ((types::enum_cast<EChannelActionType>(accessSetMode) == doNotSet) ||
186 (types::enum_cast<EChannelActionType>(accessSetMode) == reserved))
AppaRao Puli071f3f22018-05-24 16:45:30 +0530187 {
George Liu82844ef2024-07-17 17:03:56 +0800188 lg2::debug("Get channel access - Invalid Access mode");
AppaRao Pulic4f4f7a2020-07-13 16:43:59 +0530189 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530190 }
191
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000192 const uint8_t chNum =
193 convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
194
195 if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) ||
196 (!isValidChannel(chNum)))
AppaRao Puli071f3f22018-05-24 16:45:30 +0530197 {
George Liu82844ef2024-07-17 17:03:56 +0800198 lg2::debug("Get channel access - No support on channel: {CHANNEL}",
199 "CHANNEL", chNum);
anil kumar appanaddb1f442019-07-04 18:07:27 +0000200 return response(ccActionNotSupportedForChannel);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530201 }
202
PavanKumarIntel3771f5f2023-11-02 06:26:42 +0000203 ChannelAccess chAccess = {};
AppaRao Puli071f3f22018-05-24 16:45:30 +0530204
William A. Kennington III4c521022023-07-28 13:07:30 -0700205 Cc compCode = ipmi::ccUnspecifiedError;
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530206
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700207 if (types::enum_cast<EChannelActionType>(accessSetMode) == nvData)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530208 {
209 compCode = getChannelAccessPersistData(chNum, chAccess);
210 }
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700211 else if (types::enum_cast<EChannelActionType>(accessSetMode) == activeData)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530212 {
213 compCode = getChannelAccessData(chNum, chAccess);
214 }
215
NITIN SHARMAb541a5a2019-07-18 12:46:59 +0000216 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530217 {
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530218 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530219 }
220
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530221 constexpr uint2_t reservedOut1 = 0;
222 constexpr uint4_t reservedOut2 = 0;
AppaRao Puli071f3f22018-05-24 16:45:30 +0530223
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530224 return responseSuccess(
William A. Kennington III7a0e5df2021-05-19 13:31:29 -0700225 types::enum_cast<uint3_t>(chAccess.accessMode),
226 chAccess.userAuthDisabled, chAccess.perMsgAuthDisabled,
227 chAccess.alertingDisabled, reservedOut1,
228 types::enum_cast<uint4_t>(chAccess.privLimit), reservedOut2);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530229}
230
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700231/** @brief implements the get channel info command
232 * @ param ctx - context pointer
233 * @ param channel - channel number
234 * @ param reserved - skip 4 bits
235 *
236 * @returns ipmi completion code plus response data
237 * - chNum - the channel number for this request
238 * - mediumType - see Table 6-3, Channel Medium Type Numbers
239 * - protocolType - Table 6-2, Channel Protocol Type Numbers
240 * - activeSessionCount - number of active sessions
241 * - sessionType - channel support for sessions
242 * - vendorId - vendor for this channel protocol (IPMI - 7154)
243 * - auxChInfo - auxiliary info for channel
244 * */
245RspType<uint4_t, // chNum
246 uint4_t, // reserved
247 uint7_t, // mediumType
248 bool, // reserved
249 uint5_t, // protocolType
250 uint3_t, // reserved
251 uint6_t, // activeSessionCount
252 uint2_t, // sessionType
253 uint24_t, // Vendor IANA
254 uint16_t // aux info
255 >
256 ipmiGetChannelInfo(Context::ptr ctx, uint4_t channel, uint4_t reserved)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530257{
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000258 if (reserved)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530259 {
George Liu82844ef2024-07-17 17:03:56 +0800260 lg2::debug("Get channel access - Invalid field in request");
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700261 return responseInvalidFieldRequest();
AppaRao Puli071f3f22018-05-24 16:45:30 +0530262 }
263
Patrick Williams1318a5e2024-08-16 15:19:54 -0400264 uint8_t chNum =
265 convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000266 if (!isValidChannel(chNum))
267 {
George Liu82844ef2024-07-17 17:03:56 +0800268 lg2::debug("Get channel Info - No support on channel: {CHANNEL}",
269 "CHANNEL", chNum);
Jayaprakash Mutyalaafd12b42020-07-07 01:06:57 +0000270 return responseInvalidFieldRequest();
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000271 }
272
AppaRao Puli071f3f22018-05-24 16:45:30 +0530273 ChannelInfo chInfo;
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700274 Cc compCode = getChannelInfo(chNum, chInfo);
275 if (compCode != ccSuccess)
AppaRao Puli071f3f22018-05-24 16:45:30 +0530276 {
George Liu82844ef2024-07-17 17:03:56 +0800277 lg2::error("Failed to get channel info, channel: {CHANNEL}, "
278 "errno: {ERRNO}",
279 "CHANNEL", chNum, "ERRNO", compCode);
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700280 return response(compCode);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530281 }
282
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700283 constexpr uint4_t reserved1 = 0;
284 constexpr bool reserved2 = false;
285 constexpr uint3_t reserved3 = 0;
286 uint8_t mediumType = chInfo.mediumType;
287 uint8_t protocolType = chInfo.protocolType;
288 uint2_t sessionType = chInfo.sessionSupported;
289 uint6_t activeSessionCount = getChannelActiveSessions(chNum);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530290 // IPMI Spec: The IPMI Enterprise Number is: 7154 (decimal)
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700291 constexpr uint24_t vendorId = 7154;
292 constexpr uint16_t auxChInfo = 0;
AppaRao Puli071f3f22018-05-24 16:45:30 +0530293
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700294 return responseSuccess(chNum, reserved1, mediumType, reserved2,
295 protocolType, reserved3, activeSessionCount,
296 sessionType, vendorId, auxChInfo);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530297}
298
Vernon Maueryf6092892019-05-02 16:35:10 -0700299namespace
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530300{
Vernon Maueryf6092892019-05-02 16:35:10 -0700301constexpr uint16_t standardPayloadBit(PayloadType p)
302{
303 return (1 << static_cast<size_t>(p));
304}
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530305
Vernon Maueryf6092892019-05-02 16:35:10 -0700306constexpr uint16_t sessionPayloadBit(PayloadType p)
307{
308 constexpr size_t sessionShift =
309 static_cast<size_t>(PayloadType::OPEN_SESSION_REQUEST);
310 return ((1 << static_cast<size_t>(p)) >> sessionShift);
311}
312} // namespace
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530313
Vernon Maueryf6092892019-05-02 16:35:10 -0700314/** @brief implements get channel payload support command
315 * @ param ctx - ipmi context pointer
316 * @ param chNum - channel number
317 * @ param reserved - skip 4 bits
318 *
319 * @ returns IPMI completion code plus response data
320 * - stdPayloadType - bitmask of supported standard payload types
321 * - sessSetupPayloadType - bitmask of supported session setup payload types
322 * - OEMPayloadType - bitmask of supported OEM payload types
323 * - reserved - 2 bytes of 0
324 **/
325RspType<uint16_t, // stdPayloadType
326 uint16_t, // sessSetupPayloadType
327 uint16_t, // OEMPayloadType
328 uint16_t // reserved
329 >
330 ipmiGetChannelPayloadSupport(Context::ptr ctx, uint4_t channel,
331 uint4_t reserved)
332{
Patrick Williams1318a5e2024-08-16 15:19:54 -0400333 uint8_t chNum =
334 convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000335
336 if (!doesDeviceExist(chNum) || !isValidChannel(chNum) || reserved)
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530337 {
George Liu82844ef2024-07-17 17:03:56 +0800338 lg2::debug("Get channel payload - Invalid field in request");
Vernon Maueryf6092892019-05-02 16:35:10 -0700339 return responseInvalidFieldRequest();
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530340 }
341
342 // Session support is available in active LAN channels.
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000343 if (getChannelSessionSupport(chNum) == EChannelSessSupported::none)
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530344 {
George Liu82844ef2024-07-17 17:03:56 +0800345 lg2::debug("Get channel payload - No support on channel");
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000346 return response(ccActionNotSupportedForChannel);
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530347 }
Vernon Maueryf6092892019-05-02 16:35:10 -0700348 constexpr uint16_t stdPayloadType = standardPayloadBit(PayloadType::IPMI) |
349 standardPayloadBit(PayloadType::SOL);
350 constexpr uint16_t sessSetupPayloadType =
351 sessionPayloadBit(PayloadType::OPEN_SESSION_REQUEST) |
352 sessionPayloadBit(PayloadType::OPEN_SESSION_RESPONSE) |
353 sessionPayloadBit(PayloadType::RAKP1) |
354 sessionPayloadBit(PayloadType::RAKP2) |
355 sessionPayloadBit(PayloadType::RAKP3) |
356 sessionPayloadBit(PayloadType::RAKP4);
357 constexpr uint16_t OEMPayloadType = 0;
358 constexpr uint16_t rspRsvd = 0;
359 return responseSuccess(stdPayloadType, sessSetupPayloadType, OEMPayloadType,
360 rspRsvd);
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530361}
362
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000363/** @brief implements the get channel payload version command
364 * @param ctx - IPMI context pointer (for channel)
365 * @param chNum - channel number to get info about
366 * @param reserved - skip 4 bits
367 * @param payloadTypeNum - to get payload type info
368
369 * @returns IPMI completion code plus response data
370 * - formatVersion - BCD encoded format version info
371 */
372
373RspType<uint8_t> // formatVersion
374 ipmiGetChannelPayloadVersion(Context::ptr ctx, uint4_t chNum,
375 uint4_t reserved, uint8_t payloadTypeNum)
376{
Patrick Williams1318a5e2024-08-16 15:19:54 -0400377 uint8_t channel =
378 convertCurrentChannelNum(static_cast<uint8_t>(chNum), ctx->channel);
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000379
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000380 if (reserved || !isValidChannel(channel))
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000381 {
George Liu82844ef2024-07-17 17:03:56 +0800382 lg2::debug("Get channel payload version - Invalid field in request");
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000383 return responseInvalidFieldRequest();
384 }
385
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000386 if (getChannelSessionSupport(channel) == EChannelSessSupported::none)
387 {
George Liu82844ef2024-07-17 17:03:56 +0800388 lg2::debug("Get channel payload version - No support on channel");
George Liu36627e82025-07-08 13:53:25 +0800389 return responsePayloadTypeNotSupported();
jayaprakash Mutyala0e2dbee2019-12-26 13:03:04 +0000390 }
391
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000392 if (!isValidPayloadType(static_cast<PayloadType>(payloadTypeNum)))
393 {
George Liu82844ef2024-07-17 17:03:56 +0800394 lg2::error("Get channel payload version - Payload type unavailable");
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000395
George Liu36627e82025-07-08 13:53:25 +0800396 return responsePayloadTypeNotSupported();
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000397 }
398
399 // BCD encoded version representation - 1.0
400 constexpr uint8_t formatVersion = 0x10;
401
402 return responseSuccess(formatVersion);
403}
404
William A. Kennington III343d0612018-12-10 15:56:24 -0800405void registerChannelFunctions() __attribute__((constructor));
AppaRao Puli071f3f22018-05-24 16:45:30 +0530406void registerChannelFunctions()
407{
408 ipmiChannelInit();
409
NITIN SHARMA89e4bf22019-05-02 13:03:58 +0000410 registerHandler(prioOpenBmcBase, netFnApp, app::cmdSetChannelAccess,
411 Privilege::Admin, ipmiSetChannelAccess);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530412
Richard Marian Thomaiyarbc5e9ba2019-05-07 13:32:48 +0530413 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelAccess,
414 Privilege::User, ipmiGetChannelAccess);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530415
Vernon Mauery6f1e9782019-05-02 16:31:07 -0700416 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelInfoCommand,
417 Privilege::User, ipmiGetChannelInfo);
Saravanan Palanisamyb5a0f162019-03-04 18:34:44 +0530418
Vernon Maueryf6092892019-05-02 16:35:10 -0700419 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadSupport,
420 Privilege::User, ipmiGetChannelPayloadSupport);
Ayushi Smriti6fd812d2019-04-12 18:51:31 +0000421
422 registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadVersion,
423 Privilege::User, ipmiGetChannelPayloadVersion);
AppaRao Puli071f3f22018-05-24 16:45:30 +0530424}
425
426} // namespace ipmi