AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 1 | /* |
| 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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 17 | #include "channel_layer.hpp" |
| 18 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 19 | #include <ipmid/api.hpp> |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 20 | #include <phosphor-logging/lg2.hpp> |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 21 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 22 | #include <regex> |
| 23 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 24 | namespace ipmi |
| 25 | { |
| 26 | |
George Liu | 36627e8 | 2025-07-08 13:53:25 +0800 | [diff] [blame] | 27 | constexpr Cc ccPayloadTypeNotSupported = 0x80; |
| 28 | |
| 29 | static inline auto responsePayloadTypeNotSupported() |
| 30 | { |
| 31 | return response(ccPayloadTypeNotSupported); |
| 32 | } |
| 33 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 34 | /** @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 Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 49 | RspType<> 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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 53 | { |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 54 | if (reserved1 || reserved2 || |
| 55 | !isValidPrivLimit(static_cast<uint8_t>(channelPrivLimit))) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 56 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 57 | lg2::debug("Set channel access - Invalid field in request"); |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 58 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 59 | } |
| 60 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 61 | const uint8_t chNum = |
| 62 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
| 63 | if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) || |
| 64 | (!isValidChannel(chNum))) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 65 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 66 | lg2::debug("Set channel access - No support on channel: {CHANNEL}", |
| 67 | "CHANNEL", chNum); |
anil kumar appana | ddb1f44 | 2019-07-04 18:07:27 +0000 | [diff] [blame] | 68 | return response(ccActionNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | ChannelAccess chActData; |
| 72 | ChannelAccess chNVData; |
| 73 | uint8_t setActFlag = 0; |
| 74 | uint8_t setNVFlag = 0; |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 75 | Cc compCode; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 76 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 77 | // 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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 80 | { |
| 81 | case doNotSet: |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 82 | break; |
| 83 | case nvData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 84 | chNVData.accessMode = static_cast<uint8_t>(accessMode); |
| 85 | chNVData.userAuthDisabled = usrAuth; |
| 86 | chNVData.perMsgAuthDisabled = msgAuth; |
| 87 | chNVData.alertingDisabled = alertDisabled; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 88 | setNVFlag |= (setAccessMode | setUserAuthEnabled | |
| 89 | setMsgAuthEnabled | setAlertingEnabled); |
| 90 | break; |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 91 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 92 | case activeData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 93 | chActData.accessMode = static_cast<uint8_t>(accessMode); |
| 94 | chActData.userAuthDisabled = usrAuth; |
| 95 | chActData.perMsgAuthDisabled = msgAuth; |
| 96 | chActData.alertingDisabled = alertDisabled; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 97 | setActFlag |= (setAccessMode | setUserAuthEnabled | |
| 98 | setMsgAuthEnabled | setAlertingEnabled); |
| 99 | break; |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 100 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 101 | case reserved: |
| 102 | default: |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 103 | lg2::debug("Set channel access - Invalid access set mode"); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 104 | return response(ccAccessModeNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 105 | } |
| 106 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 107 | // 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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 110 | { |
| 111 | case doNotSet: |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 112 | break; |
| 113 | case nvData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 114 | chNVData.privLimit = static_cast<uint8_t>(channelPrivLimit); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 115 | setNVFlag |= setPrivLimit; |
| 116 | break; |
| 117 | case activeData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 118 | chActData.privLimit = static_cast<uint8_t>(channelPrivLimit); |
| 119 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 120 | setActFlag |= setPrivLimit; |
| 121 | break; |
| 122 | case reserved: |
| 123 | default: |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 124 | lg2::debug("Set channel access - Invalid access priv mode"); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 125 | return response(ccAccessModeNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | if (setNVFlag != 0) |
| 129 | { |
| 130 | compCode = setChannelAccessPersistData(chNum, chNVData, setNVFlag); |
NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 131 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 132 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 133 | lg2::debug("Set channel access - Failed to set access data"); |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 134 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 135 | } |
| 136 | } |
| 137 | |
| 138 | if (setActFlag != 0) |
| 139 | { |
| 140 | compCode = setChannelAccessData(chNum, chActData, setActFlag); |
NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 141 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 142 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 143 | lg2::debug("Set channel access - Failed to set access data"); |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 144 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 145 | } |
| 146 | } |
| 147 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 148 | return responseSuccess(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 149 | } |
| 150 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 151 | /** @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 | * */ |
| 167 | ipmi ::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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 178 | { |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 179 | if (reserved1 || reserved2) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 180 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 181 | lg2::debug("Get channel access - Invalid field in request"); |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 182 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 183 | } |
| 184 | |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 185 | if ((types::enum_cast<EChannelActionType>(accessSetMode) == doNotSet) || |
| 186 | (types::enum_cast<EChannelActionType>(accessSetMode) == reserved)) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 187 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 188 | lg2::debug("Get channel access - Invalid Access mode"); |
AppaRao Puli | c4f4f7a | 2020-07-13 16:43:59 +0530 | [diff] [blame] | 189 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 190 | } |
| 191 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 192 | const uint8_t chNum = |
| 193 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
| 194 | |
| 195 | if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) || |
| 196 | (!isValidChannel(chNum))) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 197 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 198 | lg2::debug("Get channel access - No support on channel: {CHANNEL}", |
| 199 | "CHANNEL", chNum); |
anil kumar appana | ddb1f44 | 2019-07-04 18:07:27 +0000 | [diff] [blame] | 200 | return response(ccActionNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 201 | } |
| 202 | |
PavanKumarIntel | 3771f5f | 2023-11-02 06:26:42 +0000 | [diff] [blame] | 203 | ChannelAccess chAccess = {}; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 204 | |
William A. Kennington III | 4c52102 | 2023-07-28 13:07:30 -0700 | [diff] [blame] | 205 | Cc compCode = ipmi::ccUnspecifiedError; |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 206 | |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 207 | if (types::enum_cast<EChannelActionType>(accessSetMode) == nvData) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 208 | { |
| 209 | compCode = getChannelAccessPersistData(chNum, chAccess); |
| 210 | } |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 211 | else if (types::enum_cast<EChannelActionType>(accessSetMode) == activeData) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 212 | { |
| 213 | compCode = getChannelAccessData(chNum, chAccess); |
| 214 | } |
| 215 | |
NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 216 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 217 | { |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 218 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 219 | } |
| 220 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 221 | constexpr uint2_t reservedOut1 = 0; |
| 222 | constexpr uint4_t reservedOut2 = 0; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 223 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 224 | return responseSuccess( |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 225 | 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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 229 | } |
| 230 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 231 | /** @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 | * */ |
| 245 | RspType<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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 257 | { |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 258 | if (reserved) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 259 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 260 | lg2::debug("Get channel access - Invalid field in request"); |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 261 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 262 | } |
| 263 | |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 264 | uint8_t chNum = |
| 265 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 266 | if (!isValidChannel(chNum)) |
| 267 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 268 | lg2::debug("Get channel Info - No support on channel: {CHANNEL}", |
| 269 | "CHANNEL", chNum); |
Jayaprakash Mutyala | afd12b4 | 2020-07-07 01:06:57 +0000 | [diff] [blame] | 270 | return responseInvalidFieldRequest(); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 271 | } |
| 272 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 273 | ChannelInfo chInfo; |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 274 | Cc compCode = getChannelInfo(chNum, chInfo); |
| 275 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 276 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 277 | lg2::error("Failed to get channel info, channel: {CHANNEL}, " |
| 278 | "errno: {ERRNO}", |
| 279 | "CHANNEL", chNum, "ERRNO", compCode); |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 280 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 281 | } |
| 282 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 283 | 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 Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 290 | // IPMI Spec: The IPMI Enterprise Number is: 7154 (decimal) |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 291 | constexpr uint24_t vendorId = 7154; |
| 292 | constexpr uint16_t auxChInfo = 0; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 293 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 294 | return responseSuccess(chNum, reserved1, mediumType, reserved2, |
| 295 | protocolType, reserved3, activeSessionCount, |
| 296 | sessionType, vendorId, auxChInfo); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 297 | } |
| 298 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 299 | namespace |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 300 | { |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 301 | constexpr uint16_t standardPayloadBit(PayloadType p) |
| 302 | { |
| 303 | return (1 << static_cast<size_t>(p)); |
| 304 | } |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 305 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 306 | constexpr 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 Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 313 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 314 | /** @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 | **/ |
| 325 | RspType<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 Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 333 | uint8_t chNum = |
| 334 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 335 | |
| 336 | if (!doesDeviceExist(chNum) || !isValidChannel(chNum) || reserved) |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 337 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 338 | lg2::debug("Get channel payload - Invalid field in request"); |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 339 | return responseInvalidFieldRequest(); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | // Session support is available in active LAN channels. |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 343 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 344 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 345 | lg2::debug("Get channel payload - No support on channel"); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 346 | return response(ccActionNotSupportedForChannel); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 347 | } |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 348 | 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 Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 361 | } |
| 362 | |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 363 | /** @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 | |
| 373 | RspType<uint8_t> // formatVersion |
| 374 | ipmiGetChannelPayloadVersion(Context::ptr ctx, uint4_t chNum, |
| 375 | uint4_t reserved, uint8_t payloadTypeNum) |
| 376 | { |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 377 | uint8_t channel = |
| 378 | convertCurrentChannelNum(static_cast<uint8_t>(chNum), ctx->channel); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 379 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 380 | if (reserved || !isValidChannel(channel)) |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 381 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 382 | lg2::debug("Get channel payload version - Invalid field in request"); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 383 | return responseInvalidFieldRequest(); |
| 384 | } |
| 385 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 386 | if (getChannelSessionSupport(channel) == EChannelSessSupported::none) |
| 387 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 388 | lg2::debug("Get channel payload version - No support on channel"); |
George Liu | 36627e8 | 2025-07-08 13:53:25 +0800 | [diff] [blame] | 389 | return responsePayloadTypeNotSupported(); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 390 | } |
| 391 | |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 392 | if (!isValidPayloadType(static_cast<PayloadType>(payloadTypeNum))) |
| 393 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 394 | lg2::error("Get channel payload version - Payload type unavailable"); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 395 | |
George Liu | 36627e8 | 2025-07-08 13:53:25 +0800 | [diff] [blame] | 396 | return responsePayloadTypeNotSupported(); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 397 | } |
| 398 | |
| 399 | // BCD encoded version representation - 1.0 |
| 400 | constexpr uint8_t formatVersion = 0x10; |
| 401 | |
| 402 | return responseSuccess(formatVersion); |
| 403 | } |
| 404 | |
William A. Kennington III | 343d061 | 2018-12-10 15:56:24 -0800 | [diff] [blame] | 405 | void registerChannelFunctions() __attribute__((constructor)); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 406 | void registerChannelFunctions() |
| 407 | { |
| 408 | ipmiChannelInit(); |
| 409 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 410 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdSetChannelAccess, |
| 411 | Privilege::Admin, ipmiSetChannelAccess); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 412 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 413 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelAccess, |
| 414 | Privilege::User, ipmiGetChannelAccess); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 415 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 416 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelInfoCommand, |
| 417 | Privilege::User, ipmiGetChannelInfo); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 418 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 419 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadSupport, |
| 420 | Privilege::User, ipmiGetChannelPayloadSupport); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 421 | |
| 422 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadVersion, |
| 423 | Privilege::User, ipmiGetChannelPayloadVersion); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | } // namespace ipmi |