11744cb3aSVijay Khemka /*
21744cb3aSVijay Khemka * Copyright (c) 2018-present Facebook.
31744cb3aSVijay Khemka *
41744cb3aSVijay Khemka * Licensed under the Apache License, Version 2.0 (the "License");
51744cb3aSVijay Khemka * you may not use this file except in compliance with the License.
61744cb3aSVijay Khemka * You may obtain a copy of the License at
71744cb3aSVijay Khemka *
81744cb3aSVijay Khemka * http://www.apache.org/licenses/LICENSE-2.0
91744cb3aSVijay Khemka *
101744cb3aSVijay Khemka * Unless required by applicable law or agreed to in writing, software
111744cb3aSVijay Khemka * distributed under the License is distributed on an "AS IS" BASIS,
121744cb3aSVijay Khemka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131744cb3aSVijay Khemka * See the License for the specific language governing permissions and
141744cb3aSVijay Khemka * limitations under the License.
151744cb3aSVijay Khemka */
161744cb3aSVijay Khemka
171744cb3aSVijay Khemka #include <ipmid/api.h>
1863c99be4SVijay Khemka
191744cb3aSVijay Khemka #include <commandutils.hpp>
201744cb3aSVijay Khemka
211744cb3aSVijay Khemka #define IPMI_CC_PARAMETER_NOT_SUPPORTED 0x80
221744cb3aSVijay Khemka
231744cb3aSVijay Khemka namespace ipmi
241744cb3aSVijay Khemka {
251744cb3aSVijay Khemka
261744cb3aSVijay Khemka void registerTransportFunctions() __attribute__((constructor));
271744cb3aSVijay Khemka
281744cb3aSVijay Khemka // Transport Command Codes (IPMI/Table H-1)
291744cb3aSVijay Khemka enum
301744cb3aSVijay Khemka {
311744cb3aSVijay Khemka CMD_TRANSPORT_GET_SOL_CONFIG = 0x22,
321744cb3aSVijay Khemka };
331744cb3aSVijay Khemka
341744cb3aSVijay Khemka // SOL Configuration parameters (IPMI/Table 26-5)
351744cb3aSVijay Khemka enum
361744cb3aSVijay Khemka {
371744cb3aSVijay Khemka SOL_PARAM_SET_IN_PROG,
381744cb3aSVijay Khemka SOL_PARAM_SOL_ENABLE,
391744cb3aSVijay Khemka SOL_PARAM_SOL_AUTH,
401744cb3aSVijay Khemka SOL_PARAM_SOL_THRESHOLD,
411744cb3aSVijay Khemka SOL_PARAM_SOL_RETRY,
421744cb3aSVijay Khemka SOL_PARAM_SOL_BITRATE,
431744cb3aSVijay Khemka SOL_PARAM_SOL_NV_BITRATE,
441744cb3aSVijay Khemka };
451744cb3aSVijay Khemka
461744cb3aSVijay Khemka //----------------------------------------------------------------------
471744cb3aSVijay Khemka // Get SoL Config (IPMI/Section 26.3) (CMD_TRANSPORT_GET_SOL_CONFIG)
481744cb3aSVijay Khemka //----------------------------------------------------------------------
ipmiTransGetSolConfig(ipmi_netfn_t,ipmi_cmd_t,ipmi_request_t request,ipmi_response_t response,ipmi_data_len_t data_len,ipmi_context_t)49*010dee04SPatrick Williams ipmi_ret_t ipmiTransGetSolConfig(
50*010dee04SPatrick Williams ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, ipmi_response_t response,
51e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t)
521744cb3aSVijay Khemka {
531744cb3aSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request);
541744cb3aSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response);
551744cb3aSVijay Khemka uint8_t param = req[0];
561744cb3aSVijay Khemka uint8_t paramSel = req[1];
571744cb3aSVijay Khemka
581744cb3aSVijay Khemka *res++ = 0x01; // Parameter revision
591744cb3aSVijay Khemka *data_len = 1;
601744cb3aSVijay Khemka
611744cb3aSVijay Khemka /* If request for revision only then return
621744cb3aSVijay Khemka * with only one byte of data
631744cb3aSVijay Khemka */
641744cb3aSVijay Khemka if (param & 0x80)
651744cb3aSVijay Khemka return IPMI_CC_OK;
661744cb3aSVijay Khemka
671744cb3aSVijay Khemka switch (paramSel)
681744cb3aSVijay Khemka {
691744cb3aSVijay Khemka case SOL_PARAM_SET_IN_PROG:
701744cb3aSVijay Khemka *res++ = 0x00; // Set this value as (set complete)
711744cb3aSVijay Khemka *data_len += 1;
721744cb3aSVijay Khemka break;
731744cb3aSVijay Khemka case SOL_PARAM_SOL_ENABLE:
741744cb3aSVijay Khemka *res++ = 0x01; // Enable SoL payload
751744cb3aSVijay Khemka *data_len += 1;
761744cb3aSVijay Khemka break;
771744cb3aSVijay Khemka case SOL_PARAM_SOL_AUTH:
781744cb3aSVijay Khemka *res++ = 0x02; // Set as (User Level)
791744cb3aSVijay Khemka *data_len += 1;
801744cb3aSVijay Khemka break;
811744cb3aSVijay Khemka case SOL_PARAM_SOL_THRESHOLD:
821744cb3aSVijay Khemka *res++ = 0x00;
83519530beSManojkiran Eda /* Byte 2: Char send threshold: setting this value to 1 means
841744cb3aSVijay Khemka * that BMC to send packet as soon as first character arrived.
851744cb3aSVijay Khemka */
861744cb3aSVijay Khemka *res++ = 0x01;
871744cb3aSVijay Khemka *data_len += 2;
881744cb3aSVijay Khemka break;
891744cb3aSVijay Khemka case SOL_PARAM_SOL_RETRY:
901744cb3aSVijay Khemka *res++ = 0x00; // Retry count: No retry after packet transmission.
911744cb3aSVijay Khemka *res++ = 0x00; // Retry interval
921744cb3aSVijay Khemka *data_len += 2;
931744cb3aSVijay Khemka break;
941744cb3aSVijay Khemka case SOL_PARAM_SOL_BITRATE:
951744cb3aSVijay Khemka case SOL_PARAM_SOL_NV_BITRATE:
961744cb3aSVijay Khemka *res++ = 0x09; // Bit rate: set as 57.6 kbps
971744cb3aSVijay Khemka *data_len += 1;
981744cb3aSVijay Khemka break;
991744cb3aSVijay Khemka default:
1001744cb3aSVijay Khemka *data_len = 0;
1011744cb3aSVijay Khemka return IPMI_CC_PARAMETER_NOT_SUPPORTED;
1021744cb3aSVijay Khemka break;
1031744cb3aSVijay Khemka }
1041744cb3aSVijay Khemka
1051744cb3aSVijay Khemka return IPMI_CC_OK;
1061744cb3aSVijay Khemka }
1071744cb3aSVijay Khemka
registerTransportFunctions()1081744cb3aSVijay Khemka void registerTransportFunctions()
1091744cb3aSVijay Khemka {
1101744cb3aSVijay Khemka ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL,
1111744cb3aSVijay Khemka ipmiTransGetSolConfig,
1121744cb3aSVijay Khemka PRIVILEGE_OPERATOR); // Get Sol Config
1131744cb3aSVijay Khemka
1141744cb3aSVijay Khemka return;
1151744cb3aSVijay Khemka }
1161744cb3aSVijay Khemka } // namespace ipmi
117