summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch
blob: 49a2c01ba9f3ab46d1fd111d6eac03202b7d322c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
From 973865687325c6563fd6b729a3a220661066f635 Mon Sep 17 00:00:00 2001
From: Cheng C Yang <cheng.c.yang@intel.com>
Date: Wed, 3 Apr 2019 15:55:04 +0800
Subject: [PATCH] Move Get SOL config parameter to host-ipmid

Move Get SOL config parameter command from net-ipmid to host-ipmid.

Tested By:
Run command ipmitool sol info
Set in progress                 : set-complete
Enabled                         : true
Force Encryption                : false
Force Authentication            : false
Privilege Level                 : USER
Character Accumulate Level (ms) : 100
Character Send Threshold        : 1
Retry Count                     : 3
Retry Interval (ms)             : 100
Volatile Bit Rate (kbps)        : IPMI-Over-Serial-Setting
Non-Volatile Bit Rate (kbps)    : IPMI-Over-Serial-Setting
Payload Channel                 : 14 (0x0e)
Payload Port                    : 623

Signed-off-by: Cheng C Yang <cheng.c.yang@intel.com>
---
 transporthandler.cpp | 139 ++++++++++++++++++++++++++++++++++++++++++++++++---
 transporthandler.hpp |  26 +++++++++-
 2 files changed, 156 insertions(+), 9 deletions(-)

diff --git a/transporthandler.cpp b/transporthandler.cpp
index 2111acf..b18f522 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -1715,11 +1715,133 @@ void initializeSOLInProgress()
     }
 }
 
-ipmi_ret_t setConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
-                         ipmi_request_t request, ipmi_response_t response,
-                         ipmi_data_len_t dataLen, ipmi_context_t context)
+//    For getsetSOLConfParams, there are still three tings TODO:
+//    1. session less channel number request has to return error.
+//    2. convert 0xE channel number.
+//    3. have unique object for every session based channel.
+ipmi_ret_t getSOLConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
+                            ipmi_request_t request, ipmi_response_t response,
+                            ipmi_data_len_t dataLen, ipmi_context_t context)
 {
-    auto reqData = reinterpret_cast<const SetConfParamsRequest*>(request);
+    auto reqData = reinterpret_cast<const GetSOLConfParamsRequest*>(request);
+    std::vector<uint8_t> outPayload;
+
+    if (*dataLen < sizeof(GetSOLConfParamsRequest) - 2)
+    {
+        *dataLen = 0;
+        return IPMI_CC_REQ_DATA_LEN_INVALID;
+    }
+
+    *dataLen = 0;
+
+    outPayload.push_back(solParameterRevision);
+    if (reqData->getParamRev)
+    {
+        std::copy(outPayload.begin(), outPayload.end(),
+                  static_cast<uint8_t*>(response));
+        *dataLen = outPayload.size();
+        return IPMI_CC_OK;
+    }
+
+    ipmi::Value value;
+    switch (static_cast<sol::Parameter>(reqData->paramSelector))
+    {
+        case sol::Parameter::progress:
+        {
+            if (getSOLParameter("Progress", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            outPayload.push_back(std::get<uint8_t>(value));
+            break;
+        }
+        case sol::Parameter::enable:
+        {
+            if (getSOLParameter("Enable", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            outPayload.push_back(static_cast<uint8_t>(std::get<bool>(value)));
+            break;
+        }
+        case sol::Parameter::authentication:
+        {
+            uint8_t authentication = 0;
+            if (getSOLParameter("Privilege", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            authentication = (std::get<uint8_t>(value) & 0x0f);
+
+            if (getSOLParameter("ForceAuthentication", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            authentication |=
+                (static_cast<uint8_t>(std::get<bool>(value)) << 6);
+
+            if (getSOLParameter("ForceEncryption", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            authentication |=
+                (static_cast<uint8_t>(std::get<bool>(value)) << 7);
+            outPayload.push_back(authentication);
+            break;
+        }
+        case sol::Parameter::accumulate:
+        {
+            if (getSOLParameter("AccumulateIntervalMS", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            outPayload.push_back(std::get<uint8_t>(value));
+
+            if (getSOLParameter("Threshold", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            outPayload.push_back(std::get<uint8_t>(value));
+            break;
+        }
+        case sol::Parameter::retry:
+        {
+            if (getSOLParameter("RetryCount", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            outPayload.push_back(std::get<uint8_t>(value) & 0x03);
+
+            if (getSOLParameter("RetryIntervalMS", value) < 0)
+            {
+                return IPMI_CC_UNSPECIFIED_ERROR;
+            }
+            outPayload.push_back(std::get<uint8_t>(value));
+            break;
+        }
+        case sol::Parameter::port:
+        {
+            uint16_t port = htole16(ipmiStdPort);
+            auto buffer = reinterpret_cast<const uint8_t*>(&port);
+            std::copy(buffer, buffer + sizeof(port),
+                      std::back_inserter(outPayload));
+            break;
+        }
+        default:
+            return IPMI_CC_PARM_NOT_SUPPORTED;
+    }
+    std::copy(outPayload.begin(), outPayload.end(),
+              static_cast<uint8_t*>(response));
+    *dataLen = outPayload.size();
+
+    return IPMI_CC_OK;
+}
+
+ipmi_ret_t setSOLConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
+                            ipmi_request_t request, ipmi_response_t response,
+                            ipmi_data_len_t dataLen, ipmi_context_t context)
+{
+    auto reqData = reinterpret_cast<const SetSOLConfParamsRequest*>(request);
 
     // Check request length first
     switch (static_cast<sol::Parameter>(reqData->paramSelector))
@@ -1728,7 +1850,7 @@ ipmi_ret_t setConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
         case sol::Parameter::enable:
         case sol::Parameter::authentication:
         {
-            if (*dataLen != sizeof(SetConfParamsRequest) - 1)
+            if (*dataLen != sizeof(SetSOLConfParamsRequest) - 1)
             {
                 *dataLen = 0;
                 return IPMI_CC_REQ_DATA_LEN_INVALID;
@@ -1738,7 +1860,7 @@ ipmi_ret_t setConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
         case sol::Parameter::accumulate:
         case sol::Parameter::retry:
         {
-            if (*dataLen != sizeof(SetConfParamsRequest))
+            if (*dataLen != sizeof(SetSOLConfParamsRequest))
             {
                 *dataLen = 0;
                 return IPMI_CC_REQ_DATA_LEN_INVALID;
@@ -1869,7 +1991,10 @@ void register_netfn_transport_functions()
                            ipmi_transport_get_lan, PRIVILEGE_OPERATOR);
 
     ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_SET_SOL_CONF_PARAMS, NULL,
-                           setConfParams, PRIVILEGE_ADMIN);
+                           setSOLConfParams, PRIVILEGE_ADMIN);
+
+    ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_GET_SOL_CONF_PARAMS, NULL,
+                           getSOLConfParams, PRIVILEGE_ADMIN);
 
     // Initialize dbus property progress to 0 every time sol manager restart.
     initializeSOLInProgress();
diff --git a/transporthandler.hpp b/transporthandler.hpp
index 3b5e9e1..7132cff 100644
--- a/transporthandler.hpp
+++ b/transporthandler.hpp
@@ -257,7 +257,7 @@ struct Retry
     uint8_t interval; //!< SOL retry interval.
 } __attribute__((packed));
 
-struct SetConfParamsRequest
+struct SetSOLConfParamsRequest
 {
 #if BYTE_ORDER == LITTLE_ENDIAN
     uint8_t channelNumber : 4; //!< Channel number.
@@ -279,7 +279,29 @@ struct SetConfParamsRequest
     };
 } __attribute__((packed));
 
-struct SetConfParamsResponse
+struct SetSOLConfParamsResponse
 {
     uint8_t completionCode; //!< Completion code.
 } __attribute__((packed));
+
+struct GetSOLConfParamsRequest
+{
+#if BYTE_ORDER == LITTLE_ENDIAN
+    uint8_t channelNum : 4;  //!< Channel number.
+    uint8_t reserved : 3;    //!< Reserved.
+    uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision
+#endif
+
+#if BYTE_ORDER == BIG_ENDIAN
+    uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision
+    uint8_t reserved : 3;    //!< Reserved.
+    uint8_t channelNum : 4;  //!< Channel number.
+#endif
+
+    uint8_t paramSelector; //!< Parameter selector.
+    uint8_t setSelector;   //!< Set selector.
+    uint8_t blockSelector; //!< Block selector.
+} __attribute__((packed));
+
+static constexpr uint16_t ipmiStdPort = 623;
+static constexpr uint8_t solParameterRevision = 0x11;
-- 
2.16.2