summaryrefslogtreecommitdiffstats
path: root/user_channel/channel_mgmt.hpp
diff options
context:
space:
mode:
authorAppaRao Puli <apparao.puli@linux.intel.com>2018-09-01 23:46:44 +0530
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2018-11-20 10:09:26 +0530
commit9613ed76ba9c60232ee2064a36c10f5bd7b81b84 (patch)
treee4a7a0305e45ee325ff2f7cdc9de9b1ca499dadc /user_channel/channel_mgmt.hpp
parent071f3f2f298ab4a4799b7fcdba3255dfd999452d (diff)
downloadphosphor-host-ipmid-9613ed76ba9c60232ee2064a36c10f5bd7b81b84.tar.gz
phosphor-host-ipmid-9613ed76ba9c60232ee2064a36c10f5bd7b81b84.zip
Synchronize channel info between network and ipmi
Synchronizing the channel privilege config between network interface(generic) and channel managament(IPMI). 1) During start-up get the network interface privilege and update the IPMI data base(NV). 2) Catch the signal for network interface channel privilege and update the ipmi data base(Volatile and NV data). 3) During ipmi privilege update(NV), send it to network interface over DBUS. Unit Test: Verified the changes by modifying MaxPrivilege in network interfaces and signal catching logic and vise versa as specified in description. Change-Id: Iaa7e9e248f1cac6ab560137c8c136abdd44e190e Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com> Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'user_channel/channel_mgmt.hpp')
-rw-r--r--user_channel/channel_mgmt.hpp94
1 files changed, 75 insertions, 19 deletions
diff --git a/user_channel/channel_mgmt.hpp b/user_channel/channel_mgmt.hpp
index 053fa39..5c35041 100644
--- a/user_channel/channel_mgmt.hpp
+++ b/user_channel/channel_mgmt.hpp
@@ -29,6 +29,11 @@ namespace ipmi
using Json = nlohmann::json;
+using DbusVariant =
+ sdbusplus::message::variant<std::vector<std::string>, std::string, bool>;
+
+using DbusChObjProperties = std::vector<std::pair<std::string, DbusVariant>>;
+
static constexpr const char* ipmiChannelMutex = "ipmi_channel_mutex";
static constexpr const char* ipmiChMutexCleanupLockFile =
"/var/lib/ipmi/ipmi_channel_mutex_cleanup";
@@ -61,7 +66,7 @@ class ChannelConfig
ChannelConfig(ChannelConfig&&) = delete;
ChannelConfig& operator=(ChannelConfig&&) = delete;
- ~ChannelConfig() = default;
+ ~ChannelConfig();
ChannelConfig();
/** @brief determines valid channel
@@ -172,6 +177,36 @@ class ChannelConfig
const uint8_t& priv,
EAuthType& authType);
+ /** @brief conver to channel privilege from system privilege
+ *
+ * @param[in] value - privilege value
+ *
+ * @return Channel privilege
+ */
+ CommandPrivilege convertToPrivLimitIndex(const std::string& value);
+
+ /** @brief function to write persistent channel configuration to config file
+ *
+ * @return 0 for success, -errno for failure.
+ */
+ int writeChannelPersistData();
+
+ /** @brief function to write volatile channel configuration to config file
+ *
+ * @return 0 for success, -errno for failure.
+ */
+ int writeChannelVolatileData();
+
+ /** @brief function to get channel data based on channel number
+ *
+ * @param[in] chNum - channel number
+ *
+ * @return 0 for success, -errno for failure.
+ */
+ ChannelData* getChannelDataPtr(const uint8_t& chNum);
+
+ uint32_t signalFlag = 0;
+
std::unique_ptr<boost::interprocess::named_recursive_mutex> channelMutex{
nullptr};
@@ -182,6 +217,8 @@ class ChannelConfig
std::time_t getUpdatedFileTime(const std::string& fileName);
boost::interprocess::file_lock mutexCleanupLock;
sdbusplus::bus::bus bus;
+ bool signalHndlrObjectState = false;
+ boost::interprocess::file_lock sigHndlrLock;
/** @brief function to initialize persistent channel configuration
*
@@ -209,35 +246,62 @@ class ChannelConfig
*/
int readChannelPersistData();
- /** @brief function to write persistent channel configuration to config file
+ /** @brief function to read volatile channel data
*
* @return 0 for success, -errno for failure.
*/
- int writeChannelPersistData();
+ int readChannelVolatileData();
- /** @brief function to read volatile channel data
+ /** @brief function to check and reload persistent channel data
*
* @return 0 for success, -errno for failure.
*/
- int readChannelVolatileData();
+ int checkAndReloadNVData();
- /** @brief function to write volatile channel configuration to config file
+ /** @brief function to check and reload volatile channel data
*
* @return 0 for success, -errno for failure.
*/
- int writeChannelVolatileData();
+ int checkAndReloadVolatileData();
- /** @brief function to check and reload persistent channel data
+ /** @brief function to sync channel privilege with system network channel
+ * privilege
*
* @return 0 for success, -errno for failure.
*/
- int checkAndReloadNVData();
+ int syncNetworkChannelConfig();
- /** @brief function to check and reload volatile channel data
+ /** @brief function to set D-Bus property value
+ *
+ * @param[in] bus - bus
+ * @param[in] service - service name
+ * @param[in] objPath - object path
+ * @param[in] interface - interface
+ * @param[in] property - property name
+ * @param[in] value - property value
*
* @return 0 for success, -errno for failure.
*/
- int checkAndReloadVolatileData();
+ int setDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+ const std::string& objPath,
+ const std::string& interface,
+ const std::string& property, const DbusVariant& value);
+
+ /** @brief function to get D-Bus property value
+ *
+ * @param[in] bus - bus
+ * @param[in] service - service name
+ * @param[in] objPath - object path
+ * @param[in] interface - interface
+ * @param[in] property - property name
+ * @param[out] value - property value
+ *
+ * @return 0 for success, -errno for failure.
+ */
+ int getDbusProperty(sdbusplus::bus::bus& bus, const std::string& service,
+ const std::string& objPath,
+ const std::string& interface,
+ const std::string& property, DbusVariant& value);
/** @brief function to read json config file
*
@@ -273,14 +337,6 @@ class ChannelConfig
*/
std::string convertToAccessModeString(const uint8_t& value);
- /** @brief conver to channel privilege from system privilege
- *
- * @param[in] value - privilege value
- *
- * @return Channel privilege
- */
- CommandPrivilege convertToPrivLimitIndex(const std::string& value);
-
/** @brief function to convert privilege value to string
*
* @param[in] value - privilege value
OpenPOWER on IntegriCloud