summaryrefslogtreecommitdiffstats
path: root/user_channel
diff options
context:
space:
mode:
Diffstat (limited to 'user_channel')
-rw-r--r--user_channel/channel_layer.hpp1
-rw-r--r--user_channel/channel_mgmt.cpp38
2 files changed, 39 insertions, 0 deletions
diff --git a/user_channel/channel_layer.hpp b/user_channel/channel_layer.hpp
index 4c931df..fa15378 100644
--- a/user_channel/channel_layer.hpp
+++ b/user_channel/channel_layer.hpp
@@ -22,6 +22,7 @@ namespace ipmi
{
static constexpr uint8_t maxIpmiChannels = 16;
+static constexpr uint8_t selfChNum = 0xE;
// IPMI return codes specific to channel
enum ipmi_channel_return_codes
diff --git a/user_channel/channel_mgmt.cpp b/user_channel/channel_mgmt.cpp
index 4cae923..fc2ca1b 100644
--- a/user_channel/channel_mgmt.cpp
+++ b/user_channel/channel_mgmt.cpp
@@ -106,6 +106,11 @@ static std::unordered_map<std::string, EChannelMediumType> mediumTypeMap = {
{"oem", EChannelMediumType::oem},
{"unknown", EChannelMediumType::unknown}};
+static std::unordered_map<EInterfaceIndex, std::string> interfaceMap = {
+ {interfaceKCS, "KCS"},
+ {interfaceLAN1, "LAN1"},
+ {interfaceUnknown, "unknown"}};
+
static std::unordered_map<std::string, EChannelProtocolType> protocolTypeMap = {
{"na", EChannelProtocolType::na},
{"ipmb-1.0", EChannelProtocolType::ipmbV10},
@@ -791,6 +796,39 @@ EChannelProtocolType
return static_cast<EChannelProtocolType>(it->second);
}
+uint8_t ChannelConfig::convertToChannelIndexNumber(const uint8_t& chNum)
+{
+
+ // TODO: There is limitation in current design. we cannot detect exact
+ // LAN interface(eth0 or eth1) so Implementation may be updated
+ // when there is any design update to figure out all the interfaces
+ // independently based on the message.
+
+ static uint8_t curChannel = 0xFF;
+
+ if (curChannel == 0xFF)
+ {
+ auto it = interfaceMap.find(getInterfaceIndex());
+ if (it == interfaceMap.end())
+ {
+ log<level::ERR>("Invalid Interface type ",
+ entry("InterfaceIndex: %d", getInterfaceIndex()));
+ throw std::invalid_argument("Invalid interface type.");
+ }
+
+ for (auto& channel : channelData)
+ {
+ std::string& interfaceName = it->second;
+ if (channel.chName == interfaceName)
+ {
+ curChannel = channel.chID;
+ break;
+ }
+ }
+ }
+ return ((chNum == selfChNum) ? curChannel : chNum);
+}
+
std::string ChannelConfig::convertToNetInterface(const std::string& value)
{
auto it = channelToInterfaceMap.find(value);
OpenPOWER on IntegriCloud