summaryrefslogtreecommitdiffstats
path: root/user_channel/channel_mgmt.cpp
diff options
context:
space:
mode:
authorssekar <suryakanth.sekar@intel.com>2018-07-25 18:49:08 +0530
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2018-11-20 10:09:55 +0530
commitf4b2b090a4c67e132d4c22fdc13ecbb261c6147a (patch)
tree39f81e40a78f9f700414cad53ed89b927802bcaa /user_channel/channel_mgmt.cpp
parent9613ed76ba9c60232ee2064a36c10f5bd7b81b84 (diff)
downloadphosphor-host-ipmid-f4b2b090a4c67e132d4c22fdc13ecbb261c6147a.tar.gz
phosphor-host-ipmid-f4b2b090a4c67e132d4c22fdc13ecbb261c6147a.zip
Added suppport to convert self channel number.
Define API for getting self channel number. Change-Id: I4027f580f30bd2ba84b11260f11f86eb8e9af1ff Signed-off-by: ssekar <suryakanth.sekar@intel.com> Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'user_channel/channel_mgmt.cpp')
-rw-r--r--user_channel/channel_mgmt.cpp38
1 files changed, 38 insertions, 0 deletions
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