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