blob: 77c55f6036b57abf3b978207e9e857a8474ee2d9 [file] [log] [blame]
Vijay Khemka1744cb32019-04-10 14:54:09 -07001/*
2 * Copyright (c) 2018-present Facebook.
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
17#include <ipmid/api.h>
Vijay Khemka63c99be2020-05-27 19:14:35 -070018
Vijay Khemka1744cb32019-04-10 14:54:09 -070019#include <commandutils.hpp>
George Liu2f454992025-07-02 16:43:57 +080020#include <ipmid/api-types.hpp>
Vijay Khemka1744cb32019-04-10 14:54:09 -070021
George Liu2f454992025-07-02 16:43:57 +080022constexpr ipmi::Cc ccParameterNotSupported = 0x80;
Vijay Khemka1744cb32019-04-10 14:54:09 -070023
24namespace ipmi
25{
26
27void registerTransportFunctions() __attribute__((constructor));
28
29// Transport Command Codes (IPMI/Table H-1)
30enum
31{
32 CMD_TRANSPORT_GET_SOL_CONFIG = 0x22,
33};
34
35// SOL Configuration parameters (IPMI/Table 26-5)
36enum
37{
38 SOL_PARAM_SET_IN_PROG,
39 SOL_PARAM_SOL_ENABLE,
40 SOL_PARAM_SOL_AUTH,
41 SOL_PARAM_SOL_THRESHOLD,
42 SOL_PARAM_SOL_RETRY,
43 SOL_PARAM_SOL_BITRATE,
44 SOL_PARAM_SOL_NV_BITRATE,
45};
46
47//----------------------------------------------------------------------
48// Get SoL Config (IPMI/Section 26.3) (CMD_TRANSPORT_GET_SOL_CONFIG)
49//----------------------------------------------------------------------
Patrick Williams010dee02024-08-16 15:19:44 -040050ipmi_ret_t ipmiTransGetSolConfig(
51 ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, ipmi_response_t response,
52 ipmi_data_len_t data_len, ipmi_context_t)
Vijay Khemka1744cb32019-04-10 14:54:09 -070053{
Vijay Khemka63c99be2020-05-27 19:14:35 -070054 uint8_t* req = reinterpret_cast<uint8_t*>(request);
55 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1744cb32019-04-10 14:54:09 -070056 uint8_t param = req[0];
57 uint8_t paramSel = req[1];
58
59 *res++ = 0x01; // Parameter revision
60 *data_len = 1;
61
62 /* If request for revision only then return
63 * with only one byte of data
64 */
65 if (param & 0x80)
George Liu2f454992025-07-02 16:43:57 +080066 return ipmi::ccSuccess;
Vijay Khemka1744cb32019-04-10 14:54:09 -070067
68 switch (paramSel)
69 {
70 case SOL_PARAM_SET_IN_PROG:
71 *res++ = 0x00; // Set this value as (set complete)
72 *data_len += 1;
73 break;
74 case SOL_PARAM_SOL_ENABLE:
75 *res++ = 0x01; // Enable SoL payload
76 *data_len += 1;
77 break;
78 case SOL_PARAM_SOL_AUTH:
79 *res++ = 0x02; // Set as (User Level)
80 *data_len += 1;
81 break;
82 case SOL_PARAM_SOL_THRESHOLD:
83 *res++ = 0x00;
Manojkiran Eda519530b2024-06-17 11:46:15 +053084 /* Byte 2: Char send threshold: setting this value to 1 means
Vijay Khemka1744cb32019-04-10 14:54:09 -070085 * that BMC to send packet as soon as first character arrived.
86 */
87 *res++ = 0x01;
88 *data_len += 2;
89 break;
90 case SOL_PARAM_SOL_RETRY:
91 *res++ = 0x00; // Retry count: No retry after packet transmission.
92 *res++ = 0x00; // Retry interval
93 *data_len += 2;
94 break;
95 case SOL_PARAM_SOL_BITRATE:
96 case SOL_PARAM_SOL_NV_BITRATE:
97 *res++ = 0x09; // Bit rate: set as 57.6 kbps
98 *data_len += 1;
99 break;
100 default:
101 *data_len = 0;
George Liu2f454992025-07-02 16:43:57 +0800102 return ccParameterNotSupported;
Vijay Khemka1744cb32019-04-10 14:54:09 -0700103 break;
104 }
105
George Liu2f454992025-07-02 16:43:57 +0800106 return ipmi::ccSuccess;
Vijay Khemka1744cb32019-04-10 14:54:09 -0700107}
108
109void registerTransportFunctions()
110{
George Liu0821a2e2025-04-03 10:12:10 +0800111 ipmiPrintAndRegister(ipmi::netFnTransport, CMD_TRANSPORT_GET_SOL_CONFIG,
112 NULL, ipmiTransGetSolConfig,
Vijay Khemka1744cb32019-04-10 14:54:09 -0700113 PRIVILEGE_OPERATOR); // Get Sol Config
114
115 return;
116}
117} // namespace ipmi