blob: fb1114447fb8031348f2cbec0eb707fb924b9856 [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>
20
21#define IPMI_CC_PARAMETER_NOT_SUPPORTED 0x80
22
23namespace ipmi
24{
25
26void registerTransportFunctions() __attribute__((constructor));
27
28// Transport Command Codes (IPMI/Table H-1)
29enum
30{
31 CMD_TRANSPORT_GET_SOL_CONFIG = 0x22,
32};
33
34// SOL Configuration parameters (IPMI/Table 26-5)
35enum
36{
37 SOL_PARAM_SET_IN_PROG,
38 SOL_PARAM_SOL_ENABLE,
39 SOL_PARAM_SOL_AUTH,
40 SOL_PARAM_SOL_THRESHOLD,
41 SOL_PARAM_SOL_RETRY,
42 SOL_PARAM_SOL_BITRATE,
43 SOL_PARAM_SOL_NV_BITRATE,
44};
45
46//----------------------------------------------------------------------
47// Get SoL Config (IPMI/Section 26.3) (CMD_TRANSPORT_GET_SOL_CONFIG)
48//----------------------------------------------------------------------
49ipmi_ret_t ipmiTransGetSolConfig(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
50 ipmi_request_t request,
51 ipmi_response_t response,
52 ipmi_data_len_t data_len,
53 ipmi_context_t context)
54{
Vijay Khemka63c99be2020-05-27 19:14:35 -070055 uint8_t* req = reinterpret_cast<uint8_t*>(request);
56 uint8_t* res = reinterpret_cast<uint8_t*>(response);
Vijay Khemka1744cb32019-04-10 14:54:09 -070057 uint8_t param = req[0];
58 uint8_t paramSel = req[1];
59
60 *res++ = 0x01; // Parameter revision
61 *data_len = 1;
62
63 /* If request for revision only then return
64 * with only one byte of data
65 */
66 if (param & 0x80)
67 return IPMI_CC_OK;
68
69 switch (paramSel)
70 {
71 case SOL_PARAM_SET_IN_PROG:
72 *res++ = 0x00; // Set this value as (set complete)
73 *data_len += 1;
74 break;
75 case SOL_PARAM_SOL_ENABLE:
76 *res++ = 0x01; // Enable SoL payload
77 *data_len += 1;
78 break;
79 case SOL_PARAM_SOL_AUTH:
80 *res++ = 0x02; // Set as (User Level)
81 *data_len += 1;
82 break;
83 case SOL_PARAM_SOL_THRESHOLD:
84 *res++ = 0x00;
85 /* Byte 2: Char send thresold: setting this value to 1 means
86 * that BMC to send packet as soon as first character arrived.
87 */
88 *res++ = 0x01;
89 *data_len += 2;
90 break;
91 case SOL_PARAM_SOL_RETRY:
92 *res++ = 0x00; // Retry count: No retry after packet transmission.
93 *res++ = 0x00; // Retry interval
94 *data_len += 2;
95 break;
96 case SOL_PARAM_SOL_BITRATE:
97 case SOL_PARAM_SOL_NV_BITRATE:
98 *res++ = 0x09; // Bit rate: set as 57.6 kbps
99 *data_len += 1;
100 break;
101 default:
102 *data_len = 0;
103 return IPMI_CC_PARAMETER_NOT_SUPPORTED;
104 break;
105 }
106
107 return IPMI_CC_OK;
108}
109
110void registerTransportFunctions()
111{
112 ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL,
113 ipmiTransGetSolConfig,
114 PRIVILEGE_OPERATOR); // Get Sol Config
115
116 return;
117}
118} // namespace ipmi