From 071f3f2f298ab4a4799b7fcdba3255dfd999452d Mon Sep 17 00:00:00 2001 From: AppaRao Puli Date: Thu, 24 May 2018 16:45:30 +0530 Subject: IPMI Channel commands implementation IPMI Channel commands implemenation - squashed commit e9a75d8dd6e89d17381f0310c7930586c6b79996 Author: AppaRao Puli Date: Thu Jul 5 14:47:22 2018 +0530 Channel layer separation De-coupling the channel management from ipmi channel commands implementation. This gives flexibility to load only needed stuff in different modules(host-ipmi or netipmid) Change-Id: Ib334562beb9325f7768ed6a15475cae15af17b19 Signed-off-by: AppaRao Puli Signed-off-by: Richard Marian Thomaiyar commit 726ddf2af678ea6773f4b4b918fbd49be8c83e6a Author: AppaRao Puli Date: Thu May 24 16:45:30 2018 +0530 IPMI Channel commands implementation Following IPMI channel commands are implemented. 1) Set channel access (0x40) 2) Get channel access (0x41) 3) Get channel info (0x42) Also added code supported for LAN configuration parameters 1) Authentication Type Support (selector #1) 2) Authentication Type Enables (selector #2) Change-Id: Ic4156378c7756eca383dc3da52114fd119346ca6 Signed-off-by: AppaRao Puli Signed-off-by: Richard Marian Thomaiyar Change-Id: Ic4156378c7756eca383dc3da52114fd119346ca6 Signed-off-by: AppaRao Puli Signed-off-by: Richard Marian Thomaiyar --- user_channel/channel_layer.cpp | 131 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 user_channel/channel_layer.cpp (limited to 'user_channel/channel_layer.cpp') diff --git a/user_channel/channel_layer.cpp b/user_channel/channel_layer.cpp new file mode 100644 index 0000000..32f4ded --- /dev/null +++ b/user_channel/channel_layer.cpp @@ -0,0 +1,131 @@ +/* +// Copyright (c) 2018 Intel Corporation +// +// 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 "channel_layer.hpp" + +#include "channel_mgmt.hpp" + +#include + +namespace ipmi +{ + +bool doesDeviceExist(const uint8_t& chNum) +{ + // TODO: This is not the reliable way to find the device + // associated with ethernet interface as the channel number to + // eth association is not done. Need to revisit later + struct stat fileStat; + std::string devName("/sys/class/net/eth"); + devName += std::to_string(chNum - 1); + + if (stat(devName.data(), &fileStat) != 0) + { + phosphor::logging::log( + "Ethernet device not found"); + return false; + } + + return true; +} + +bool isValidPrivLimit(const uint8_t& privLimit) +{ + return ((privLimit >= PRIVILEGE_CALLBACK) && (privLimit <= PRIVILEGE_OEM)); +} + +bool isValidAccessMode(const uint8_t& accessMode) +{ + return ( + (accessMode >= static_cast(EChannelAccessMode::disabled)) && + (accessMode <= static_cast(EChannelAccessMode::shared))); +} + +bool isValidChannel(const uint8_t& chNum) +{ + return getChannelConfigObject().isValidChannel(chNum); +} + +bool isValidAuthType(const uint8_t& chNum, const EAuthType& authType) +{ + return getChannelConfigObject().isValidAuthType(chNum, authType); +} + +EChannelSessSupported getChannelSessionSupport(const uint8_t& chNum) +{ + return getChannelConfigObject().getChannelSessionSupport(chNum); +} + +int getChannelActiveSessions(const uint8_t& chNum) +{ + return getChannelConfigObject().getChannelActiveSessions(chNum); +} + +ipmi_ret_t ipmiChannelInit() +{ + getChannelConfigObject(); + return IPMI_CC_OK; +} + +ipmi_ret_t getChannelInfo(const uint8_t& chNum, ChannelInfo& chInfo) +{ + return getChannelConfigObject().getChannelInfo(chNum, chInfo); +} + +ipmi_ret_t getChannelAccessData(const uint8_t& chNum, + ChannelAccess& chAccessData) +{ + return getChannelConfigObject().getChannelAccessData(chNum, chAccessData); +} + +ipmi_ret_t setChannelAccessData(const uint8_t& chNum, + const ChannelAccess& chAccessData, + const uint8_t& setFlag) +{ + return getChannelConfigObject().setChannelAccessData(chNum, chAccessData, + setFlag); +} + +ipmi_ret_t getChannelAccessPersistData(const uint8_t& chNum, + ChannelAccess& chAccessData) +{ + return getChannelConfigObject().getChannelAccessPersistData(chNum, + chAccessData); +} + +ipmi_ret_t setChannelAccessPersistData(const uint8_t& chNum, + const ChannelAccess& chAccessData, + const uint8_t& setFlag) +{ + return getChannelConfigObject().setChannelAccessPersistData( + chNum, chAccessData, setFlag); +} + +ipmi_ret_t getChannelAuthTypeSupported(const uint8_t& chNum, + uint8_t& authTypeSupported) +{ + return getChannelConfigObject().getChannelAuthTypeSupported( + chNum, authTypeSupported); +} + +ipmi_ret_t getChannelEnabledAuthType(const uint8_t& chNum, const uint8_t& priv, + EAuthType& authType) +{ + return getChannelConfigObject().getChannelEnabledAuthType(chNum, priv, + authType); +} + +} // namespace ipmi -- cgit v1.2.1