blob: 2264a80c2e5f000ce8a8a1779d4767e5db0eac35 [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>
18#include <commandutils.hpp>
19
20#define IPMI_CC_PARAMETER_NOT_SUPPORTED 0x80
21
22namespace ipmi
23{
24
25void registerTransportFunctions() __attribute__((constructor));
26
27// Transport Command Codes (IPMI/Table H-1)
28enum
29{
30 CMD_TRANSPORT_GET_SOL_CONFIG = 0x22,
31};
32
33// SOL Configuration parameters (IPMI/Table 26-5)
34enum
35{
36 SOL_PARAM_SET_IN_PROG,
37 SOL_PARAM_SOL_ENABLE,
38 SOL_PARAM_SOL_AUTH,
39 SOL_PARAM_SOL_THRESHOLD,
40 SOL_PARAM_SOL_RETRY,
41 SOL_PARAM_SOL_BITRATE,
42 SOL_PARAM_SOL_NV_BITRATE,
43};
44
45//----------------------------------------------------------------------
46// Get SoL Config (IPMI/Section 26.3) (CMD_TRANSPORT_GET_SOL_CONFIG)
47//----------------------------------------------------------------------
48ipmi_ret_t ipmiTransGetSolConfig(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
49 ipmi_request_t request,
50 ipmi_response_t response,
51 ipmi_data_len_t data_len,
52 ipmi_context_t context)
53{
54 uint8_t *req = reinterpret_cast<uint8_t *>(request);
55 uint8_t *res = reinterpret_cast<uint8_t *>(response);
56 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)
66 return IPMI_CC_OK;
67
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;
84 /* Byte 2: Char send thresold: setting this value to 1 means
85 * 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;
102 return IPMI_CC_PARAMETER_NOT_SUPPORTED;
103 break;
104 }
105
106 return IPMI_CC_OK;
107}
108
109void registerTransportFunctions()
110{
111 ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL,
112 ipmiTransGetSolConfig,
113 PRIVILEGE_OPERATOR); // Get Sol Config
114
115 return;
116}
117} // namespace ipmi