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 //---------------------------------------------------------------------- 49e39f9393SWilly Tu ipmi_ret_t ipmiTransGetSolConfig(ipmi_netfn_t, ipmi_cmd_t, 501744cb3aSVijay Khemka ipmi_request_t request, 511744cb3aSVijay Khemka ipmi_response_t response, 52e39f9393SWilly Tu ipmi_data_len_t data_len, ipmi_context_t) 531744cb3aSVijay Khemka { 541744cb3aSVijay Khemka uint8_t* req = reinterpret_cast<uint8_t*>(request); 551744cb3aSVijay Khemka uint8_t* res = reinterpret_cast<uint8_t*>(response); 561744cb3aSVijay Khemka uint8_t param = req[0]; 571744cb3aSVijay Khemka uint8_t paramSel = req[1]; 581744cb3aSVijay Khemka 591744cb3aSVijay Khemka *res++ = 0x01; // Parameter revision 601744cb3aSVijay Khemka *data_len = 1; 611744cb3aSVijay Khemka 621744cb3aSVijay Khemka /* If request for revision only then return 631744cb3aSVijay Khemka * with only one byte of data 641744cb3aSVijay Khemka */ 651744cb3aSVijay Khemka if (param & 0x80) 661744cb3aSVijay Khemka return IPMI_CC_OK; 671744cb3aSVijay Khemka 681744cb3aSVijay Khemka switch (paramSel) 691744cb3aSVijay Khemka { 701744cb3aSVijay Khemka case SOL_PARAM_SET_IN_PROG: 711744cb3aSVijay Khemka *res++ = 0x00; // Set this value as (set complete) 721744cb3aSVijay Khemka *data_len += 1; 731744cb3aSVijay Khemka break; 741744cb3aSVijay Khemka case SOL_PARAM_SOL_ENABLE: 751744cb3aSVijay Khemka *res++ = 0x01; // Enable SoL payload 761744cb3aSVijay Khemka *data_len += 1; 771744cb3aSVijay Khemka break; 781744cb3aSVijay Khemka case SOL_PARAM_SOL_AUTH: 791744cb3aSVijay Khemka *res++ = 0x02; // Set as (User Level) 801744cb3aSVijay Khemka *data_len += 1; 811744cb3aSVijay Khemka break; 821744cb3aSVijay Khemka case SOL_PARAM_SOL_THRESHOLD: 831744cb3aSVijay Khemka *res++ = 0x00; 84*519530beSManojkiran Eda /* Byte 2: Char send threshold: setting this value to 1 means 851744cb3aSVijay Khemka * that BMC to send packet as soon as first character arrived. 861744cb3aSVijay Khemka */ 871744cb3aSVijay Khemka *res++ = 0x01; 881744cb3aSVijay Khemka *data_len += 2; 891744cb3aSVijay Khemka break; 901744cb3aSVijay Khemka case SOL_PARAM_SOL_RETRY: 911744cb3aSVijay Khemka *res++ = 0x00; // Retry count: No retry after packet transmission. 921744cb3aSVijay Khemka *res++ = 0x00; // Retry interval 931744cb3aSVijay Khemka *data_len += 2; 941744cb3aSVijay Khemka break; 951744cb3aSVijay Khemka case SOL_PARAM_SOL_BITRATE: 961744cb3aSVijay Khemka case SOL_PARAM_SOL_NV_BITRATE: 971744cb3aSVijay Khemka *res++ = 0x09; // Bit rate: set as 57.6 kbps 981744cb3aSVijay Khemka *data_len += 1; 991744cb3aSVijay Khemka break; 1001744cb3aSVijay Khemka default: 1011744cb3aSVijay Khemka *data_len = 0; 1021744cb3aSVijay Khemka return IPMI_CC_PARAMETER_NOT_SUPPORTED; 1031744cb3aSVijay Khemka break; 1041744cb3aSVijay Khemka } 1051744cb3aSVijay Khemka 1061744cb3aSVijay Khemka return IPMI_CC_OK; 1071744cb3aSVijay Khemka } 1081744cb3aSVijay Khemka 1091744cb3aSVijay Khemka void registerTransportFunctions() 1101744cb3aSVijay Khemka { 1111744cb3aSVijay Khemka ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL, 1121744cb3aSVijay Khemka ipmiTransGetSolConfig, 1131744cb3aSVijay Khemka PRIVILEGE_OPERATOR); // Get Sol Config 1141744cb3aSVijay Khemka 1151744cb3aSVijay Khemka return; 1161744cb3aSVijay Khemka } 1171744cb3aSVijay Khemka } // namespace ipmi 118