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 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 27 | /** @brief implements the set channel access command |
| 28 | * @ param ctx - context pointer |
| 29 | * @ param channel - channel number |
| 30 | * @ param reserved - skip 4 bits |
| 31 | * @ param accessMode - access mode for IPMI messaging |
| 32 | * @ param usrAuth - user level authentication (enable/disable) |
| 33 | * @ param msgAuth - per message authentication (enable/disable) |
| 34 | * @ param alertDisabled - PEF alerting (enable/disable) |
| 35 | * @ param chanAccess - channel access |
| 36 | * @ param channelPrivLimit - channel privilege limit |
| 37 | * @ param reserved - skip 3 bits |
| 38 | * @ param channelPrivMode - channel priviledge mode |
| 39 | * |
| 40 | * @ returns IPMI completion code |
| 41 | **/ |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 42 | RspType<> ipmiSetChannelAccess( |
| 43 | Context::ptr ctx, uint4_t channel, uint4_t reserved1, uint3_t accessMode, |
| 44 | bool usrAuth, bool msgAuth, bool alertDisabled, uint2_t chanAccess, |
| 45 | uint4_t channelPrivLimit, uint2_t reserved2, uint2_t channelPrivMode) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 46 | { |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 47 | if (reserved1 || reserved2 || |
| 48 | !isValidPrivLimit(static_cast<uint8_t>(channelPrivLimit))) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 49 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 50 | lg2::debug("Set channel access - Invalid field in request"); |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 51 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 52 | } |
| 53 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 54 | const uint8_t chNum = |
| 55 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
| 56 | if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) || |
| 57 | (!isValidChannel(chNum))) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 58 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 59 | lg2::debug("Set channel access - No support on channel: {CHANNEL}", |
| 60 | "CHANNEL", chNum); |
anil kumar appana | ddb1f44 | 2019-07-04 18:07:27 +0000 | [diff] [blame] | 61 | return response(ccActionNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | ChannelAccess chActData; |
| 65 | ChannelAccess chNVData; |
| 66 | uint8_t setActFlag = 0; |
| 67 | uint8_t setNVFlag = 0; |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 68 | Cc compCode; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 69 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 70 | // cannot static cast directly from uint2_t to enum; must go via int |
| 71 | uint8_t channelAccessAction = static_cast<uint8_t>(chanAccess); |
| 72 | switch (static_cast<EChannelActionType>(channelAccessAction)) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 73 | { |
| 74 | case doNotSet: |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 75 | break; |
| 76 | case nvData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 77 | chNVData.accessMode = static_cast<uint8_t>(accessMode); |
| 78 | chNVData.userAuthDisabled = usrAuth; |
| 79 | chNVData.perMsgAuthDisabled = msgAuth; |
| 80 | chNVData.alertingDisabled = alertDisabled; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 81 | setNVFlag |= (setAccessMode | setUserAuthEnabled | |
| 82 | setMsgAuthEnabled | setAlertingEnabled); |
| 83 | break; |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 84 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 85 | case activeData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 86 | chActData.accessMode = static_cast<uint8_t>(accessMode); |
| 87 | chActData.userAuthDisabled = usrAuth; |
| 88 | chActData.perMsgAuthDisabled = msgAuth; |
| 89 | chActData.alertingDisabled = alertDisabled; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 90 | setActFlag |= (setAccessMode | setUserAuthEnabled | |
| 91 | setMsgAuthEnabled | setAlertingEnabled); |
| 92 | break; |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 93 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 94 | case reserved: |
| 95 | default: |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 96 | lg2::debug("Set channel access - Invalid access set mode"); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 97 | return response(ccAccessModeNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 98 | } |
| 99 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 100 | // cannot static cast directly from uint2_t to enum; must go via int |
| 101 | uint8_t channelPrivAction = static_cast<uint8_t>(channelPrivMode); |
| 102 | switch (static_cast<EChannelActionType>(channelPrivAction)) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 103 | { |
| 104 | case doNotSet: |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 105 | break; |
| 106 | case nvData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 107 | chNVData.privLimit = static_cast<uint8_t>(channelPrivLimit); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 108 | setNVFlag |= setPrivLimit; |
| 109 | break; |
| 110 | case activeData: |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 111 | chActData.privLimit = static_cast<uint8_t>(channelPrivLimit); |
| 112 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 113 | setActFlag |= setPrivLimit; |
| 114 | break; |
| 115 | case reserved: |
| 116 | default: |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 117 | lg2::debug("Set channel access - Invalid access priv mode"); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 118 | return response(ccAccessModeNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | if (setNVFlag != 0) |
| 122 | { |
| 123 | compCode = setChannelAccessPersistData(chNum, chNVData, setNVFlag); |
NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 124 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 125 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 126 | lg2::debug("Set channel access - Failed to set access data"); |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 127 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
| 131 | if (setActFlag != 0) |
| 132 | { |
| 133 | compCode = setChannelAccessData(chNum, chActData, setActFlag); |
NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 134 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 135 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 136 | lg2::debug("Set channel access - Failed to set access data"); |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 137 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 141 | return responseSuccess(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 142 | } |
| 143 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 144 | /** @brief implements the get channel access command |
| 145 | * @ param ctx - context pointer |
| 146 | * @ param channel - channel number |
| 147 | * @ param reserved1 - skip 4 bits |
| 148 | * @ param reserved2 - skip 6 bits |
| 149 | * @ param accessMode - get access mode |
| 150 | * |
| 151 | * @returns ipmi completion code plus response data |
| 152 | * - accessMode - get access mode |
| 153 | * - usrAuthDisabled - user level authentication status |
| 154 | * - msgAuthDisabled - message level authentication status |
| 155 | * - alertDisabled - alerting status |
| 156 | * - reserved - skip 2 bits |
| 157 | * - privLimit - channel privilege limit |
| 158 | * - reserved - skip 4 bits |
| 159 | * */ |
| 160 | ipmi ::RspType<uint3_t, // access mode, |
| 161 | bool, // user authentication status, |
| 162 | bool, // message authentication status, |
| 163 | bool, // alerting status, |
| 164 | uint2_t, // reserved, |
| 165 | |
| 166 | uint4_t, // channel privilege, |
| 167 | uint4_t // reserved |
| 168 | > |
| 169 | ipmiGetChannelAccess(Context::ptr ctx, uint4_t channel, uint4_t reserved1, |
| 170 | uint6_t reserved2, uint2_t accessSetMode) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 171 | { |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 172 | if (reserved1 || reserved2) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 173 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 174 | lg2::debug("Get channel access - Invalid field in request"); |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 175 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 176 | } |
| 177 | |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 178 | if ((types::enum_cast<EChannelActionType>(accessSetMode) == doNotSet) || |
| 179 | (types::enum_cast<EChannelActionType>(accessSetMode) == reserved)) |
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 Access mode"); |
AppaRao Puli | c4f4f7a | 2020-07-13 16:43:59 +0530 | [diff] [blame] | 182 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 183 | } |
| 184 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 185 | const uint8_t chNum = |
| 186 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
| 187 | |
| 188 | if ((getChannelSessionSupport(chNum) == EChannelSessSupported::none) || |
| 189 | (!isValidChannel(chNum))) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 190 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 191 | lg2::debug("Get channel access - No support on channel: {CHANNEL}", |
| 192 | "CHANNEL", chNum); |
anil kumar appana | ddb1f44 | 2019-07-04 18:07:27 +0000 | [diff] [blame] | 193 | return response(ccActionNotSupportedForChannel); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 194 | } |
| 195 | |
PavanKumarIntel | 3771f5f | 2023-11-02 06:26:42 +0000 | [diff] [blame] | 196 | ChannelAccess chAccess = {}; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 197 | |
William A. Kennington III | 4c52102 | 2023-07-28 13:07:30 -0700 | [diff] [blame] | 198 | Cc compCode = ipmi::ccUnspecifiedError; |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 199 | |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 200 | if (types::enum_cast<EChannelActionType>(accessSetMode) == nvData) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 201 | { |
| 202 | compCode = getChannelAccessPersistData(chNum, chAccess); |
| 203 | } |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 204 | else if (types::enum_cast<EChannelActionType>(accessSetMode) == activeData) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 205 | { |
| 206 | compCode = getChannelAccessData(chNum, chAccess); |
| 207 | } |
| 208 | |
NITIN SHARMA | b541a5a | 2019-07-18 12:46:59 +0000 | [diff] [blame] | 209 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 210 | { |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 211 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 212 | } |
| 213 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 214 | constexpr uint2_t reservedOut1 = 0; |
| 215 | constexpr uint4_t reservedOut2 = 0; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 216 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 217 | return responseSuccess( |
William A. Kennington III | 7a0e5df | 2021-05-19 13:31:29 -0700 | [diff] [blame] | 218 | types::enum_cast<uint3_t>(chAccess.accessMode), |
| 219 | chAccess.userAuthDisabled, chAccess.perMsgAuthDisabled, |
| 220 | chAccess.alertingDisabled, reservedOut1, |
| 221 | types::enum_cast<uint4_t>(chAccess.privLimit), reservedOut2); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 222 | } |
| 223 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 224 | /** @brief implements the get channel info command |
| 225 | * @ param ctx - context pointer |
| 226 | * @ param channel - channel number |
| 227 | * @ param reserved - skip 4 bits |
| 228 | * |
| 229 | * @returns ipmi completion code plus response data |
| 230 | * - chNum - the channel number for this request |
| 231 | * - mediumType - see Table 6-3, Channel Medium Type Numbers |
| 232 | * - protocolType - Table 6-2, Channel Protocol Type Numbers |
| 233 | * - activeSessionCount - number of active sessions |
| 234 | * - sessionType - channel support for sessions |
| 235 | * - vendorId - vendor for this channel protocol (IPMI - 7154) |
| 236 | * - auxChInfo - auxiliary info for channel |
| 237 | * */ |
| 238 | RspType<uint4_t, // chNum |
| 239 | uint4_t, // reserved |
| 240 | uint7_t, // mediumType |
| 241 | bool, // reserved |
| 242 | uint5_t, // protocolType |
| 243 | uint3_t, // reserved |
| 244 | uint6_t, // activeSessionCount |
| 245 | uint2_t, // sessionType |
| 246 | uint24_t, // Vendor IANA |
| 247 | uint16_t // aux info |
| 248 | > |
| 249 | ipmiGetChannelInfo(Context::ptr ctx, uint4_t channel, uint4_t reserved) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 250 | { |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 251 | if (reserved) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 252 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 253 | lg2::debug("Get channel access - Invalid field in request"); |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 254 | return responseInvalidFieldRequest(); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 255 | } |
| 256 | |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 257 | uint8_t chNum = |
| 258 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 259 | if (!isValidChannel(chNum)) |
| 260 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 261 | lg2::debug("Get channel Info - No support on channel: {CHANNEL}", |
| 262 | "CHANNEL", chNum); |
Jayaprakash Mutyala | afd12b4 | 2020-07-07 01:06:57 +0000 | [diff] [blame] | 263 | return responseInvalidFieldRequest(); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 264 | } |
| 265 | |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 266 | ChannelInfo chInfo; |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 267 | Cc compCode = getChannelInfo(chNum, chInfo); |
| 268 | if (compCode != ccSuccess) |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 269 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 270 | lg2::error("Failed to get channel info, channel: {CHANNEL}, " |
| 271 | "errno: {ERRNO}", |
| 272 | "CHANNEL", chNum, "ERRNO", compCode); |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 273 | return response(compCode); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 274 | } |
| 275 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 276 | constexpr uint4_t reserved1 = 0; |
| 277 | constexpr bool reserved2 = false; |
| 278 | constexpr uint3_t reserved3 = 0; |
| 279 | uint8_t mediumType = chInfo.mediumType; |
| 280 | uint8_t protocolType = chInfo.protocolType; |
| 281 | uint2_t sessionType = chInfo.sessionSupported; |
| 282 | uint6_t activeSessionCount = getChannelActiveSessions(chNum); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 283 | // IPMI Spec: The IPMI Enterprise Number is: 7154 (decimal) |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 284 | constexpr uint24_t vendorId = 7154; |
| 285 | constexpr uint16_t auxChInfo = 0; |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 286 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 287 | return responseSuccess(chNum, reserved1, mediumType, reserved2, |
| 288 | protocolType, reserved3, activeSessionCount, |
| 289 | sessionType, vendorId, auxChInfo); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 290 | } |
| 291 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 292 | namespace |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 293 | { |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 294 | constexpr uint16_t standardPayloadBit(PayloadType p) |
| 295 | { |
| 296 | return (1 << static_cast<size_t>(p)); |
| 297 | } |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 298 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 299 | constexpr uint16_t sessionPayloadBit(PayloadType p) |
| 300 | { |
| 301 | constexpr size_t sessionShift = |
| 302 | static_cast<size_t>(PayloadType::OPEN_SESSION_REQUEST); |
| 303 | return ((1 << static_cast<size_t>(p)) >> sessionShift); |
| 304 | } |
| 305 | } // namespace |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 306 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 307 | /** @brief implements get channel payload support command |
| 308 | * @ param ctx - ipmi context pointer |
| 309 | * @ param chNum - channel number |
| 310 | * @ param reserved - skip 4 bits |
| 311 | * |
| 312 | * @ returns IPMI completion code plus response data |
| 313 | * - stdPayloadType - bitmask of supported standard payload types |
| 314 | * - sessSetupPayloadType - bitmask of supported session setup payload types |
| 315 | * - OEMPayloadType - bitmask of supported OEM payload types |
| 316 | * - reserved - 2 bytes of 0 |
| 317 | **/ |
| 318 | RspType<uint16_t, // stdPayloadType |
| 319 | uint16_t, // sessSetupPayloadType |
| 320 | uint16_t, // OEMPayloadType |
| 321 | uint16_t // reserved |
| 322 | > |
| 323 | ipmiGetChannelPayloadSupport(Context::ptr ctx, uint4_t channel, |
| 324 | uint4_t reserved) |
| 325 | { |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 326 | uint8_t chNum = |
| 327 | convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 328 | |
| 329 | if (!doesDeviceExist(chNum) || !isValidChannel(chNum) || reserved) |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 330 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 331 | lg2::debug("Get channel payload - Invalid field in request"); |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 332 | return responseInvalidFieldRequest(); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | // Session support is available in active LAN channels. |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 336 | if (getChannelSessionSupport(chNum) == EChannelSessSupported::none) |
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 - No support on channel"); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 339 | return response(ccActionNotSupportedForChannel); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 340 | } |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 341 | constexpr uint16_t stdPayloadType = standardPayloadBit(PayloadType::IPMI) | |
| 342 | standardPayloadBit(PayloadType::SOL); |
| 343 | constexpr uint16_t sessSetupPayloadType = |
| 344 | sessionPayloadBit(PayloadType::OPEN_SESSION_REQUEST) | |
| 345 | sessionPayloadBit(PayloadType::OPEN_SESSION_RESPONSE) | |
| 346 | sessionPayloadBit(PayloadType::RAKP1) | |
| 347 | sessionPayloadBit(PayloadType::RAKP2) | |
| 348 | sessionPayloadBit(PayloadType::RAKP3) | |
| 349 | sessionPayloadBit(PayloadType::RAKP4); |
| 350 | constexpr uint16_t OEMPayloadType = 0; |
| 351 | constexpr uint16_t rspRsvd = 0; |
| 352 | return responseSuccess(stdPayloadType, sessSetupPayloadType, OEMPayloadType, |
| 353 | rspRsvd); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 354 | } |
| 355 | |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 356 | /** @brief implements the get channel payload version command |
| 357 | * @param ctx - IPMI context pointer (for channel) |
| 358 | * @param chNum - channel number to get info about |
| 359 | * @param reserved - skip 4 bits |
| 360 | * @param payloadTypeNum - to get payload type info |
| 361 | |
| 362 | * @returns IPMI completion code plus response data |
| 363 | * - formatVersion - BCD encoded format version info |
| 364 | */ |
| 365 | |
| 366 | RspType<uint8_t> // formatVersion |
| 367 | ipmiGetChannelPayloadVersion(Context::ptr ctx, uint4_t chNum, |
| 368 | uint4_t reserved, uint8_t payloadTypeNum) |
| 369 | { |
Patrick Williams | 1318a5e | 2024-08-16 15:19:54 -0400 | [diff] [blame] | 370 | uint8_t channel = |
| 371 | convertCurrentChannelNum(static_cast<uint8_t>(chNum), ctx->channel); |
Manoj Ashok | 271d9c2 | 2021-07-22 23:21:31 +0530 | [diff] [blame] | 372 | constexpr uint8_t payloadTypeNotSupported = 0x80; |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 373 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 374 | if (reserved || !isValidChannel(channel)) |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 375 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 376 | lg2::debug("Get channel payload version - Invalid field in request"); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 377 | return responseInvalidFieldRequest(); |
| 378 | } |
| 379 | |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 380 | if (getChannelSessionSupport(channel) == EChannelSessSupported::none) |
| 381 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 382 | lg2::debug("Get channel payload version - No support on channel"); |
Manoj Ashok | 271d9c2 | 2021-07-22 23:21:31 +0530 | [diff] [blame] | 383 | return response(payloadTypeNotSupported); |
jayaprakash Mutyala | 0e2dbee | 2019-12-26 13:03:04 +0000 | [diff] [blame] | 384 | } |
| 385 | |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 386 | if (!isValidPayloadType(static_cast<PayloadType>(payloadTypeNum))) |
| 387 | { |
George Liu | 82844ef | 2024-07-17 17:03:56 +0800 | [diff] [blame] | 388 | lg2::error("Get channel payload version - Payload type unavailable"); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 389 | |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 390 | return response(payloadTypeNotSupported); |
| 391 | } |
| 392 | |
| 393 | // BCD encoded version representation - 1.0 |
| 394 | constexpr uint8_t formatVersion = 0x10; |
| 395 | |
| 396 | return responseSuccess(formatVersion); |
| 397 | } |
| 398 | |
William A. Kennington III | 343d061 | 2018-12-10 15:56:24 -0800 | [diff] [blame] | 399 | void registerChannelFunctions() __attribute__((constructor)); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 400 | void registerChannelFunctions() |
| 401 | { |
| 402 | ipmiChannelInit(); |
| 403 | |
NITIN SHARMA | 89e4bf2 | 2019-05-02 13:03:58 +0000 | [diff] [blame] | 404 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdSetChannelAccess, |
| 405 | Privilege::Admin, ipmiSetChannelAccess); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 406 | |
Richard Marian Thomaiyar | bc5e9ba | 2019-05-07 13:32:48 +0530 | [diff] [blame] | 407 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelAccess, |
| 408 | Privilege::User, ipmiGetChannelAccess); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 409 | |
Vernon Mauery | 6f1e978 | 2019-05-02 16:31:07 -0700 | [diff] [blame] | 410 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelInfoCommand, |
| 411 | Privilege::User, ipmiGetChannelInfo); |
Saravanan Palanisamy | b5a0f16 | 2019-03-04 18:34:44 +0530 | [diff] [blame] | 412 | |
Vernon Mauery | f609289 | 2019-05-02 16:35:10 -0700 | [diff] [blame] | 413 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadSupport, |
| 414 | Privilege::User, ipmiGetChannelPayloadSupport); |
Ayushi Smriti | 6fd812d | 2019-04-12 18:51:31 +0000 | [diff] [blame] | 415 | |
| 416 | registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelPayloadVersion, |
| 417 | Privilege::User, ipmiGetChannelPayloadVersion); |
AppaRao Puli | 071f3f2 | 2018-05-24 16:45:30 +0530 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | } // namespace ipmi |