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( 50 ipmi_netfn_t, ipmi_cmd_t, ipmi_request_t request, ipmi_response_t response, 51 ipmi_data_len_t data_len, ipmi_context_t) 52 { 53 uint8_t* req = reinterpret_cast<uint8_t*>(request); 54 uint8_t* res = reinterpret_cast<uint8_t*>(response); 55 uint8_t param = req[0]; 56 uint8_t paramSel = req[1]; 57 58 *res++ = 0x01; // Parameter revision 59 *data_len = 1; 60 61 /* If request for revision only then return 62 * with only one byte of data 63 */ 64 if (param & 0x80) 65 return IPMI_CC_OK; 66 67 switch (paramSel) 68 { 69 case SOL_PARAM_SET_IN_PROG: 70 *res++ = 0x00; // Set this value as (set complete) 71 *data_len += 1; 72 break; 73 case SOL_PARAM_SOL_ENABLE: 74 *res++ = 0x01; // Enable SoL payload 75 *data_len += 1; 76 break; 77 case SOL_PARAM_SOL_AUTH: 78 *res++ = 0x02; // Set as (User Level) 79 *data_len += 1; 80 break; 81 case SOL_PARAM_SOL_THRESHOLD: 82 *res++ = 0x00; 83 /* Byte 2: Char send threshold: setting this value to 1 means 84 * that BMC to send packet as soon as first character arrived. 85 */ 86 *res++ = 0x01; 87 *data_len += 2; 88 break; 89 case SOL_PARAM_SOL_RETRY: 90 *res++ = 0x00; // Retry count: No retry after packet transmission. 91 *res++ = 0x00; // Retry interval 92 *data_len += 2; 93 break; 94 case SOL_PARAM_SOL_BITRATE: 95 case SOL_PARAM_SOL_NV_BITRATE: 96 *res++ = 0x09; // Bit rate: set as 57.6 kbps 97 *data_len += 1; 98 break; 99 default: 100 *data_len = 0; 101 return IPMI_CC_PARAMETER_NOT_SUPPORTED; 102 break; 103 } 104 105 return IPMI_CC_OK; 106 } 107 108 void registerTransportFunctions() 109 { 110 ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL, 111 ipmiTransGetSolConfig, 112 PRIVILEGE_OPERATOR); // Get Sol Config 113 114 return; 115 } 116 } // namespace ipmi 117