1*1744cb3aSVijay Khemka /* 2*1744cb3aSVijay Khemka * Copyright (c) 2018-present Facebook. 3*1744cb3aSVijay Khemka * 4*1744cb3aSVijay Khemka * Licensed under the Apache License, Version 2.0 (the "License"); 5*1744cb3aSVijay Khemka * you may not use this file except in compliance with the License. 6*1744cb3aSVijay Khemka * You may obtain a copy of the License at 7*1744cb3aSVijay Khemka * 8*1744cb3aSVijay Khemka * http://www.apache.org/licenses/LICENSE-2.0 9*1744cb3aSVijay Khemka * 10*1744cb3aSVijay Khemka * Unless required by applicable law or agreed to in writing, software 11*1744cb3aSVijay Khemka * distributed under the License is distributed on an "AS IS" BASIS, 12*1744cb3aSVijay Khemka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*1744cb3aSVijay Khemka * See the License for the specific language governing permissions and 14*1744cb3aSVijay Khemka * limitations under the License. 15*1744cb3aSVijay Khemka */ 16*1744cb3aSVijay Khemka 17*1744cb3aSVijay Khemka #include <ipmid/api.h> 18*1744cb3aSVijay Khemka #include <commandutils.hpp> 19*1744cb3aSVijay Khemka 20*1744cb3aSVijay Khemka #define IPMI_CC_PARAMETER_NOT_SUPPORTED 0x80 21*1744cb3aSVijay Khemka 22*1744cb3aSVijay Khemka namespace ipmi 23*1744cb3aSVijay Khemka { 24*1744cb3aSVijay Khemka 25*1744cb3aSVijay Khemka void registerTransportFunctions() __attribute__((constructor)); 26*1744cb3aSVijay Khemka 27*1744cb3aSVijay Khemka // Transport Command Codes (IPMI/Table H-1) 28*1744cb3aSVijay Khemka enum 29*1744cb3aSVijay Khemka { 30*1744cb3aSVijay Khemka CMD_TRANSPORT_GET_SOL_CONFIG = 0x22, 31*1744cb3aSVijay Khemka }; 32*1744cb3aSVijay Khemka 33*1744cb3aSVijay Khemka // SOL Configuration parameters (IPMI/Table 26-5) 34*1744cb3aSVijay Khemka enum 35*1744cb3aSVijay Khemka { 36*1744cb3aSVijay Khemka SOL_PARAM_SET_IN_PROG, 37*1744cb3aSVijay Khemka SOL_PARAM_SOL_ENABLE, 38*1744cb3aSVijay Khemka SOL_PARAM_SOL_AUTH, 39*1744cb3aSVijay Khemka SOL_PARAM_SOL_THRESHOLD, 40*1744cb3aSVijay Khemka SOL_PARAM_SOL_RETRY, 41*1744cb3aSVijay Khemka SOL_PARAM_SOL_BITRATE, 42*1744cb3aSVijay Khemka SOL_PARAM_SOL_NV_BITRATE, 43*1744cb3aSVijay Khemka }; 44*1744cb3aSVijay Khemka 45*1744cb3aSVijay Khemka //---------------------------------------------------------------------- 46*1744cb3aSVijay Khemka // Get SoL Config (IPMI/Section 26.3) (CMD_TRANSPORT_GET_SOL_CONFIG) 47*1744cb3aSVijay Khemka //---------------------------------------------------------------------- 48*1744cb3aSVijay Khemka ipmi_ret_t ipmiTransGetSolConfig(ipmi_netfn_t netfn, ipmi_cmd_t cmd, 49*1744cb3aSVijay Khemka ipmi_request_t request, 50*1744cb3aSVijay Khemka ipmi_response_t response, 51*1744cb3aSVijay Khemka ipmi_data_len_t data_len, 52*1744cb3aSVijay Khemka ipmi_context_t context) 53*1744cb3aSVijay Khemka { 54*1744cb3aSVijay Khemka uint8_t *req = reinterpret_cast<uint8_t *>(request); 55*1744cb3aSVijay Khemka uint8_t *res = reinterpret_cast<uint8_t *>(response); 56*1744cb3aSVijay Khemka uint8_t param = req[0]; 57*1744cb3aSVijay Khemka uint8_t paramSel = req[1]; 58*1744cb3aSVijay Khemka 59*1744cb3aSVijay Khemka *res++ = 0x01; // Parameter revision 60*1744cb3aSVijay Khemka *data_len = 1; 61*1744cb3aSVijay Khemka 62*1744cb3aSVijay Khemka /* If request for revision only then return 63*1744cb3aSVijay Khemka * with only one byte of data 64*1744cb3aSVijay Khemka */ 65*1744cb3aSVijay Khemka if (param & 0x80) 66*1744cb3aSVijay Khemka return IPMI_CC_OK; 67*1744cb3aSVijay Khemka 68*1744cb3aSVijay Khemka switch (paramSel) 69*1744cb3aSVijay Khemka { 70*1744cb3aSVijay Khemka case SOL_PARAM_SET_IN_PROG: 71*1744cb3aSVijay Khemka *res++ = 0x00; // Set this value as (set complete) 72*1744cb3aSVijay Khemka *data_len += 1; 73*1744cb3aSVijay Khemka break; 74*1744cb3aSVijay Khemka case SOL_PARAM_SOL_ENABLE: 75*1744cb3aSVijay Khemka *res++ = 0x01; // Enable SoL payload 76*1744cb3aSVijay Khemka *data_len += 1; 77*1744cb3aSVijay Khemka break; 78*1744cb3aSVijay Khemka case SOL_PARAM_SOL_AUTH: 79*1744cb3aSVijay Khemka *res++ = 0x02; // Set as (User Level) 80*1744cb3aSVijay Khemka *data_len += 1; 81*1744cb3aSVijay Khemka break; 82*1744cb3aSVijay Khemka case SOL_PARAM_SOL_THRESHOLD: 83*1744cb3aSVijay Khemka *res++ = 0x00; 84*1744cb3aSVijay Khemka /* Byte 2: Char send thresold: setting this value to 1 means 85*1744cb3aSVijay Khemka * that BMC to send packet as soon as first character arrived. 86*1744cb3aSVijay Khemka */ 87*1744cb3aSVijay Khemka *res++ = 0x01; 88*1744cb3aSVijay Khemka *data_len += 2; 89*1744cb3aSVijay Khemka break; 90*1744cb3aSVijay Khemka case SOL_PARAM_SOL_RETRY: 91*1744cb3aSVijay Khemka *res++ = 0x00; // Retry count: No retry after packet transmission. 92*1744cb3aSVijay Khemka *res++ = 0x00; // Retry interval 93*1744cb3aSVijay Khemka *data_len += 2; 94*1744cb3aSVijay Khemka break; 95*1744cb3aSVijay Khemka case SOL_PARAM_SOL_BITRATE: 96*1744cb3aSVijay Khemka case SOL_PARAM_SOL_NV_BITRATE: 97*1744cb3aSVijay Khemka *res++ = 0x09; // Bit rate: set as 57.6 kbps 98*1744cb3aSVijay Khemka *data_len += 1; 99*1744cb3aSVijay Khemka break; 100*1744cb3aSVijay Khemka default: 101*1744cb3aSVijay Khemka *data_len = 0; 102*1744cb3aSVijay Khemka return IPMI_CC_PARAMETER_NOT_SUPPORTED; 103*1744cb3aSVijay Khemka break; 104*1744cb3aSVijay Khemka } 105*1744cb3aSVijay Khemka 106*1744cb3aSVijay Khemka return IPMI_CC_OK; 107*1744cb3aSVijay Khemka } 108*1744cb3aSVijay Khemka 109*1744cb3aSVijay Khemka void registerTransportFunctions() 110*1744cb3aSVijay Khemka { 111*1744cb3aSVijay Khemka ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL, 112*1744cb3aSVijay Khemka ipmiTransGetSolConfig, 113*1744cb3aSVijay Khemka PRIVILEGE_OPERATOR); // Get Sol Config 114*1744cb3aSVijay Khemka 115*1744cb3aSVijay Khemka return; 116*1744cb3aSVijay Khemka } 117*1744cb3aSVijay Khemka } // namespace ipmi 118