xref: /openbmc/phosphor-net-ipmid/command/sol_cmds.hpp (revision 41ff9b51e4bf4bb501c669527d45293acf0645fc)
1 #pragma once
2 
3 #include "message_handler.hpp"
4 
5 #include <vector>
6 
7 namespace sol
8 {
9 
10 namespace command
11 {
12 
13 /** @brief SOL Payload Handler
14  *
15  *  This command is used for activating and deactivating a payload type under a
16  *  given IPMI session. The UDP Port number for SOL is the same as the port that
17  *  was used to establish the IPMI session.
18  *
19  *  @param[in] inPayload - Request data for the command.
20  *  @param[in] handler - Reference to the message handler.
21  *
22  *  @return Response data for the command.
23  */
24 std::vector<uint8_t> payloadHandler(const std::vector<uint8_t>& inPayload,
25                                     std::shared_ptr<message::Handler>& handler);
26 
27 constexpr uint8_t netfnTransport = 0x0C;
28 constexpr uint8_t solActivatingCmd = 0x20;
29 
30 /** @struct ActivatingRequest
31  *
32  *  IPMI payload for SOL Activating command.
33  */
34 struct ActivatingRequest
35 {
36 #if BYTE_ORDER == LITTLE_ENDIAN
37     uint8_t sessionState : 4; //!< SOL session state.
38     uint8_t reserved : 4;     //!< Reserved.
39 #endif
40 
41 #if BYTE_ORDER == BIG_ENDIAN
42     uint8_t reserved : 4;     //!< Reserved.
43     uint8_t sessionState : 4; //!< SOL session state.
44 #endif
45 
46     uint8_t payloadInstance; //!< Payload instance.
47     uint8_t majorVersion;    //!< SOL format major version
48     uint8_t minorVersion;    //!< SOL format minor version
49 } __attribute__((packed));
50 
51 /** @brief SOL Activating Command.
52  *
53  *  This command provides a mechanism for the BMC to notify a remote application
54  *  that a SOL payload is activating on another channel.The request message is a
55  *  message that is asynchronously generated by the BMC. The BMC will not wait
56  *  for a response from the remote console before dropping the serial connection
57  *  to proceed with SOL, therefore the remote console does not need to respond
58  *  to this command.
59  *
60  *  @param[in] payloadInstance - SOL payload instance.
61  *  @param[in] sessionID - IPMI session ID.
62  */
63 void activating(uint8_t payloadInstance, uint32_t sessionID);
64 
65 /** @enum Parameter
66  *
67  *  SOL parameters are volatile, they are initialized by the SOL manager.
68  *  They can be read using Get SOL configuration parameters command and updated
69  *  using Set SOL configuration parameters command.
70  */
71 enum class Parameter
72 {
73     PROGRESS,       //!< Set In Progress.
74     ENABLE,         //!< SOL Enable.
75     AUTHENTICATION, //!< SOL Authentication.
76     ACCUMULATE,     //!< Character Accumulate Interval & Send Threshold.
77     RETRY,          //!< SOL Retry.
78     NVBITRATE,      //!< SOL non-volatile bit rate.
79     VBITRATE,       //!< SOL volatile bit rate.
80     CHANNEL,        //!< SOL payload channel.
81     PORT,           //!< SOL payload port.
82 };
83 
84 constexpr uint8_t progressMask = 0x03;
85 constexpr uint8_t enableMask = 0x01;
86 
87 /** @struct Auth
88  *
89  *  SOL authentication parameter.
90  */
91 struct Auth
92 {
93 #if BYTE_ORDER == LITTLE_ENDIAN
94     uint8_t privilege : 4; //!< SOL privilege level.
95     uint8_t reserved : 2;  //!< Reserved.
96     uint8_t auth : 1;      //!< Force SOL payload Authentication.
97     uint8_t encrypt : 1;   //!< Force SOL payload encryption.
98 #endif
99 
100 #if BYTE_ORDER == BIG_ENDIAN
101     uint8_t encrypt : 1;   //!< Force SOL payload encryption.
102     uint8_t auth : 1;      //!< Force SOL payload Authentication.
103     uint8_t reserved : 2;  //!< Reserved.
104     uint8_t privilege : 4; //!< SOL privilege level.
105 #endif
106 } __attribute__((packed));
107 
108 /** @struct Accumulate
109  *
110  *  Character accumulate interval & Character send threshold.
111  */
112 struct Accumulate
113 {
114     uint8_t interval;  //!< Character accumulate interval.
115     uint8_t threshold; //!< Character send threshold.
116 } __attribute__((packed));
117 
118 constexpr uint8_t retryCountMask = 0x07;
119 
120 /** @struct Retry
121  *
122  *  SOL retry count and interval.
123  */
124 struct Retry
125 {
126 #if BYTE_ORDER == LITTLE_ENDIAN
127     uint8_t count : 3;    //!< SOL retry count.
128     uint8_t reserved : 5; //!< Reserved.
129 #endif
130 
131 #if BYTE_ORDER == BIG_ENDIAN
132     uint8_t reserved : 5; //!< Reserved.
133     uint8_t count : 3;    //!< SOL retry count.
134 #endif
135 
136     uint8_t interval; //!< SOL retry interval.
137 } __attribute__((packed));
138 
139 constexpr uint8_t ipmiCCParamNotSupported = 0x80;
140 constexpr uint8_t ipmiCCInvalidSetInProgress = 0x81;
141 constexpr uint8_t ipmiCCWriteReadParameter = 0x82;
142 constexpr uint8_t ipmiCCReadWriteParameter = 0x83;
143 constexpr uint8_t parameterRevision = 0x11;
144 
145 /** @struct SetConfParamsRequest
146  *
147  *  IPMI payload for Set SOL configuration parameters command request.
148  */
149 struct SetConfParamsRequest
150 {
151 #if BYTE_ORDER == LITTLE_ENDIAN
152     uint8_t channelNumber : 4; //!< Channel number.
153     uint8_t reserved : 4;      //!< Reserved.
154 #endif
155 
156 #if BYTE_ORDER == BIG_ENDIAN
157     uint8_t reserved : 4;      //!< Reserved.
158     uint8_t channelNumber : 4; //!< Channel number.
159 #endif
160 
161     uint8_t paramSelector; //!< Parameter selector.
162     union
163     {
164         uint8_t value;         //!< Represents one byte SOL parameters.
165         struct Accumulate acc; //!< Character accumulate values.
166         struct Retry retry;    //!< Retry values.
167         struct Auth auth;      //!< Authentication parameters.
168     };
169 } __attribute__((packed));
170 
171 /** @struct SetConfParamsResponse
172  *
173  *  IPMI payload for Set SOL configuration parameters command response.
174  */
175 struct SetConfParamsResponse
176 {
177     uint8_t completionCode; //!< Completion code.
178 } __attribute__((packed));
179 
180 /** @brief Set SOL configuration parameters command.
181  *
182  *  @param[in] inPayload - Request data for the command.
183  *  @param[in] handler - Reference to the message handler.
184  *
185  *  @return Response data for the command.
186  */
187 std::vector<uint8_t> setConfParams(const std::vector<uint8_t>& inPayload,
188                                    std::shared_ptr<message::Handler>& handler);
189 
190 /** @struct GetConfParamsRequest
191  *
192  *  IPMI payload for Get SOL configuration parameters command request.
193  */
194 struct GetConfParamsRequest
195 {
196 #if BYTE_ORDER == LITTLE_ENDIAN
197     uint8_t channelNum : 4;  //!< Channel number.
198     uint8_t reserved : 3;    //!< Reserved.
199     uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision
200 #endif
201 
202 #if BYTE_ORDER == BIG_ENDIAN
203     uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision
204     uint8_t reserved : 3;    //!< Reserved.
205     uint8_t channelNum : 4;  //!< Channel number.
206 #endif
207 
208     uint8_t paramSelector; //!< Parameter selector.
209     uint8_t setSelector;   //!< Set selector.
210     uint8_t blockSelector; //!< Block selector.
211 } __attribute__((packed));
212 
213 /** @struct GetConfParamsResponse
214  *
215  *  IPMI payload for Get SOL configuration parameters command response.
216  */
217 struct GetConfParamsResponse
218 {
219     uint8_t completionCode; //!< Completion code.
220     uint8_t paramRev;       //!< Parameter revision.
221 } __attribute__((packed));
222 
223 /** @brief Get SOL configuration parameters command.
224  *
225  *  @param[in] inPayload - Request data for the command.
226  *  @param[in] handler - Reference to the message handler.
227  *
228  *  @return Response data for the command.
229  */
230 std::vector<uint8_t> getConfParams(const std::vector<uint8_t>& inPayload,
231                                    std::shared_ptr<message::Handler>& handler);
232 
233 } // namespace command
234 
235 } // namespace sol
236