summaryrefslogtreecommitdiffstats
path: root/user_channel
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2019-05-02 16:31:07 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2019-05-23 17:29:44 +0000
commit6f1e978814b8f9be012f7f0c1944d652243a20f8 (patch)
tree496fa1c3ba1bbc3aa532b412d1f5b56043baef34 /user_channel
parentbc5e9bab25e356caa9c7b7b04b68969f2ab62eb9 (diff)
downloadphosphor-host-ipmid-6f1e978814b8f9be012f7f0c1944d652243a20f8.tar.gz
phosphor-host-ipmid-6f1e978814b8f9be012f7f0c1944d652243a20f8.zip
Updates get channel info command to use the new provider API
Update the get channel info command to use the new IPMI provider API. Because of the change, this command can support the use of the special channel number 0x0e. Tested-by: (remote via RMCP+ interface) ipmitool -I lanplus -H ... -U ... channel info Channel 0x1 info: Channel Medium Type : 802.3 LAN Channel Protocol Type : IPMB-1.0 Session Support : multi-session Active Session Count : 0 Protocol Vendor ID : 7154 Volatile(active) Settings Alerting : disabled Per-message Auth : enabled User Level Auth : enabled Access Mode : always available Non-Volatile Settings Alerting : disabled Per-message Auth : enabled User Level Auth : enabled Access Mode : always available (on host via kcs interface) ipmitool channel info Channel 0xf info: Channel Medium Type : System Interface Channel Protocol Type : KCS Session Support : session-less Active Session Count : 0 Protocol Vendor ID : 7154 Change-Id: Ica4262593acaefe12ccf70724ad4db40da344da4 Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Diffstat (limited to 'user_channel')
-rw-r--r--user_channel/channelcommands.cpp152
1 files changed, 51 insertions, 101 deletions
diff --git a/user_channel/channelcommands.cpp b/user_channel/channelcommands.cpp
index 08b58a9..9c633ec 100644
--- a/user_channel/channelcommands.cpp
+++ b/user_channel/channelcommands.cpp
@@ -28,52 +28,6 @@ using namespace phosphor::logging;
namespace ipmi
{
-/** @struct GetChannelInfoReq
- *
- * Structure for get channel info request command (refer spec sec 22.24)
- */
-struct GetChannelInfoReq
-{
-#if BYTE_ORDER == LITTLE_ENDIAN
- uint8_t chNum : 4;
- uint8_t reserved_1 : 4;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- uint8_t reserved_1 : 4;
- uint8_t chNum : 4;
-#endif
-} __attribute__((packed));
-
-/** @struct GetChannelInfoResp
- *
- * Structure for get channel info response command (refer spec sec 22.24)
- */
-struct GetChannelInfoResp
-{
-#if BYTE_ORDER == LITTLE_ENDIAN
- uint8_t chNum : 4;
- uint8_t reserved_1 : 4;
- uint8_t mediumType : 7;
- uint8_t reserved_2 : 1;
- uint8_t msgProtType : 5;
- uint8_t reserved_3 : 3;
- uint8_t actSessCount : 6;
- uint8_t sessType : 2;
-#endif
-#if BYTE_ORDER == BIG_ENDIAN
- uint8_t reserved_1 : 4;
- uint8_t chNum : 4;
- uint8_t reserved_2 : 1;
- uint8_t mediumType : 7;
- uint8_t reserved_3 : 3;
- uint8_t msgProtType : 5;
- uint8_t sessType : 2;
- uint8_t actSessCount : 6;
-#endif
- uint8_t vendorId[3];
- uint8_t auxChInfo[2];
-} __attribute__((packed));
-
/** @struct GetChannelPayloadSupportReq
*
* Structure for get channel payload support command request (refer spec
@@ -296,69 +250,65 @@ ipmi ::RspType<uint3_t, // access mode,
static_cast<uint4_t>(chAccess.privLimit), reservedOut2);
}
-ipmi_ret_t ipmiGetChannelInfo(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)
+/** @brief implements the get channel info command
+ * @ param ctx - context pointer
+ * @ param channel - channel number
+ * @ param reserved - skip 4 bits
+ *
+ * @returns ipmi completion code plus response data
+ * - chNum - the channel number for this request
+ * - mediumType - see Table 6-3, Channel Medium Type Numbers
+ * - protocolType - Table 6-2, Channel Protocol Type Numbers
+ * - activeSessionCount - number of active sessions
+ * - sessionType - channel support for sessions
+ * - vendorId - vendor for this channel protocol (IPMI - 7154)
+ * - auxChInfo - auxiliary info for channel
+ * */
+RspType<uint4_t, // chNum
+ uint4_t, // reserved
+ uint7_t, // mediumType
+ bool, // reserved
+ uint5_t, // protocolType
+ uint3_t, // reserved
+ uint6_t, // activeSessionCount
+ uint2_t, // sessionType
+ uint24_t, // Vendor IANA
+ uint16_t // aux info
+ >
+ ipmiGetChannelInfo(Context::ptr ctx, uint4_t channel, uint4_t reserved)
{
- const GetChannelInfoReq* req = static_cast<GetChannelInfoReq*>(request);
- size_t reqLength = *data_len;
-
- *data_len = 0;
-
- if (reqLength != sizeof(*req))
- {
- log<level::DEBUG>("Get channel info - Invalid Length");
- return IPMI_CC_REQ_DATA_LEN_INVALID;
- }
-
- uint8_t chNum = convertCurrentChannelNum(req->chNum);
- if (!isValidChannel(chNum) || req->reserved_1 != 0)
- {
- log<level::DEBUG>("Get channel info - Invalid field in request");
- return IPMI_CC_INVALID_FIELD_REQUEST;
- }
-
- // Check the existance of device for session-less channels.
- if ((EChannelSessSupported::none != getChannelSessionSupport(chNum)) &&
- (!(doesDeviceExist(chNum))))
+ uint8_t chNum =
+ convertCurrentChannelNum(static_cast<uint8_t>(channel), ctx->channel);
+ if (!isValidChannel(chNum) || reserved)
{
- log<level::DEBUG>("Get channel info - Device not exist");
- return IPMI_CC_PARM_OUT_OF_RANGE;
+ log<level::DEBUG>("Get channel access - Invalid field in request");
+ return responseInvalidFieldRequest();
}
- GetChannelInfoResp* resp = static_cast<GetChannelInfoResp*>(response);
-
- std::fill(reinterpret_cast<uint8_t*>(resp),
- reinterpret_cast<uint8_t*>(resp) + sizeof(*resp), 0);
-
ChannelInfo chInfo;
- ipmi_ret_t compCode = getChannelInfo(chNum, chInfo);
- if (compCode != IPMI_CC_OK)
+ Cc compCode = getChannelInfo(chNum, chInfo);
+ if (compCode != ccSuccess)
{
- return compCode;
+ log<level::ERR>("Failed to get channel info",
+ entry("CHANNEL=%x", chNum),
+ entry("ERRNO=%x", compCode));
+ return response(compCode);
}
- resp->chNum = chNum;
- resp->mediumType = chInfo.mediumType;
- resp->msgProtType = chInfo.protocolType;
- resp->actSessCount = getChannelActiveSessions(chNum);
- resp->sessType = chInfo.sessionSupported;
-
+ constexpr uint4_t reserved1 = 0;
+ constexpr bool reserved2 = false;
+ constexpr uint3_t reserved3 = 0;
+ uint8_t mediumType = chInfo.mediumType;
+ uint8_t protocolType = chInfo.protocolType;
+ uint2_t sessionType = chInfo.sessionSupported;
+ uint6_t activeSessionCount = getChannelActiveSessions(chNum);
// IPMI Spec: The IPMI Enterprise Number is: 7154 (decimal)
- resp->vendorId[0] = 0xF2;
- resp->vendorId[1] = 0x1B;
- resp->vendorId[2] = 0x00;
-
- // Auxiliary Channel info - byte 1:2
- // TODO: For System Interface(0xF) and OEM channel types, this needs
- // to be changed acoordingly.
- // All other channel types, its reverved
- resp->auxChInfo[0] = 0x00;
- resp->auxChInfo[1] = 0x00;
+ constexpr uint24_t vendorId = 7154;
+ constexpr uint16_t auxChInfo = 0;
- *data_len = sizeof(*resp);
-
- return IPMI_CC_OK;
+ return responseSuccess(chNum, reserved1, mediumType, reserved2,
+ protocolType, reserved3, activeSessionCount,
+ sessionType, vendorId, auxChInfo);
}
ipmi_ret_t ipmiGetChannelPayloadSupport(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
@@ -447,8 +397,8 @@ void registerChannelFunctions()
registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelAccess,
Privilege::User, ipmiGetChannelAccess);
- ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHANNEL_INFO, NULL,
- ipmiGetChannelInfo, PRIVILEGE_USER);
+ registerHandler(prioOpenBmcBase, netFnApp, app::cmdGetChannelInfoCommand,
+ Privilege::User, ipmiGetChannelInfo);
ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHANNEL_PAYLOAD_SUPPORT,
NULL, ipmiGetChannelPayloadSupport, PRIVILEGE_USER);
OpenPOWER on IntegriCloud