Add Transport commands
Added Get config SoL transport commands for FB tiogapass.
Change-Id: I1e1f0bf13bc8787dcb4e48f13f996365280ebc9a
Signed-off-by: Vijay Khemka <vijaykhemka@fb.com>
diff --git a/src/transportcommands.cpp b/src/transportcommands.cpp
new file mode 100644
index 0000000..2264a80
--- /dev/null
+++ b/src/transportcommands.cpp
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2018-present Facebook.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <ipmid/api.h>
+#include <commandutils.hpp>
+
+#define IPMI_CC_PARAMETER_NOT_SUPPORTED 0x80
+
+namespace ipmi
+{
+
+void registerTransportFunctions() __attribute__((constructor));
+
+// Transport Command Codes (IPMI/Table H-1)
+enum
+{
+ CMD_TRANSPORT_GET_SOL_CONFIG = 0x22,
+};
+
+// SOL Configuration parameters (IPMI/Table 26-5)
+enum
+{
+ SOL_PARAM_SET_IN_PROG,
+ SOL_PARAM_SOL_ENABLE,
+ SOL_PARAM_SOL_AUTH,
+ SOL_PARAM_SOL_THRESHOLD,
+ SOL_PARAM_SOL_RETRY,
+ SOL_PARAM_SOL_BITRATE,
+ SOL_PARAM_SOL_NV_BITRATE,
+};
+
+//----------------------------------------------------------------------
+// Get SoL Config (IPMI/Section 26.3) (CMD_TRANSPORT_GET_SOL_CONFIG)
+//----------------------------------------------------------------------
+ipmi_ret_t ipmiTransGetSolConfig(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
+ ipmi_request_t request,
+ ipmi_response_t response,
+ ipmi_data_len_t data_len,
+ ipmi_context_t context)
+{
+ uint8_t *req = reinterpret_cast<uint8_t *>(request);
+ uint8_t *res = reinterpret_cast<uint8_t *>(response);
+ uint8_t param = req[0];
+ uint8_t paramSel = req[1];
+
+ *res++ = 0x01; // Parameter revision
+ *data_len = 1;
+
+ /* If request for revision only then return
+ * with only one byte of data
+ */
+ if (param & 0x80)
+ return IPMI_CC_OK;
+
+ switch (paramSel)
+ {
+ case SOL_PARAM_SET_IN_PROG:
+ *res++ = 0x00; // Set this value as (set complete)
+ *data_len += 1;
+ break;
+ case SOL_PARAM_SOL_ENABLE:
+ *res++ = 0x01; // Enable SoL payload
+ *data_len += 1;
+ break;
+ case SOL_PARAM_SOL_AUTH:
+ *res++ = 0x02; // Set as (User Level)
+ *data_len += 1;
+ break;
+ case SOL_PARAM_SOL_THRESHOLD:
+ *res++ = 0x00;
+ /* Byte 2: Char send thresold: setting this value to 1 means
+ * that BMC to send packet as soon as first character arrived.
+ */
+ *res++ = 0x01;
+ *data_len += 2;
+ break;
+ case SOL_PARAM_SOL_RETRY:
+ *res++ = 0x00; // Retry count: No retry after packet transmission.
+ *res++ = 0x00; // Retry interval
+ *data_len += 2;
+ break;
+ case SOL_PARAM_SOL_BITRATE:
+ case SOL_PARAM_SOL_NV_BITRATE:
+ *res++ = 0x09; // Bit rate: set as 57.6 kbps
+ *data_len += 1;
+ break;
+ default:
+ *data_len = 0;
+ return IPMI_CC_PARAMETER_NOT_SUPPORTED;
+ break;
+ }
+
+ return IPMI_CC_OK;
+}
+
+void registerTransportFunctions()
+{
+ ipmiPrintAndRegister(NETFUN_TRANSPORT, CMD_TRANSPORT_GET_SOL_CONFIG, NULL,
+ ipmiTransGetSolConfig,
+ PRIVILEGE_OPERATOR); // Get Sol Config
+
+ return;
+}
+} // namespace ipmi