DataHoarder
704df5b09d
Implemented extra missing fields, added VPD hash match Add extra configuration required for external port tagging, maybe do it via config
118 lines
3.2 KiB
C++
118 lines
3.2 KiB
C++
#pragma once
|
|
|
|
|
|
#include <memory>
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <functional>
|
|
|
|
struct _fm_eventPort;
|
|
struct _fm_switchInfo;
|
|
|
|
|
|
namespace FM10K {
|
|
|
|
class IES {
|
|
public:
|
|
static IES& getInstance();
|
|
~IES();
|
|
|
|
bool isInitialized() const{
|
|
return m_initialized;
|
|
}
|
|
|
|
enum class TlvType{
|
|
Text,
|
|
Integer,
|
|
UnsignedInteger,
|
|
UnsignedInteger64,
|
|
Boolean,
|
|
Null
|
|
};
|
|
|
|
bool addConfigEntry(const std::string& key, const std::string& value);
|
|
bool addConfigEntry(const std::string& key, int32_t value);
|
|
bool addConfigEntry(const std::string& key, uint32_t value);
|
|
bool addConfigEntry(const std::string& key, uint64_t value);
|
|
bool addConfigEntry(const std::string& key, bool value);
|
|
|
|
bool addConfigEntry(const std::string& key, TlvType type, const std::string& value);
|
|
|
|
bool replaceConfigEntry(const std::string& key, TlvType type, const std::string& value);
|
|
|
|
bool loadKnownConfiguration(const std::string& key);
|
|
|
|
std::string getPlatformConfiguration() const;
|
|
|
|
bool writePlatformConfiguration();
|
|
|
|
const std::string& getTempPath();
|
|
|
|
std::string getPlatformConfigurationPath();
|
|
bool init();
|
|
void teardown();
|
|
|
|
struct _fm_switchInfo fmGetSwitchInfo() const;
|
|
|
|
void iteratePorts(const std::function<void(int logicalPort, int physicalPort, int cpi, bool isInternalPort, bool isPCIePort, bool isSpecialPort, bool isEplPort, bool isCpuPort)>& callback) const;
|
|
|
|
bool fmIsPciePort(int port) const;
|
|
bool fmIsSpecialPort(int port) const;
|
|
bool fmIsEplPort(int port) const;
|
|
|
|
void fmSetPortState(int port, int mode, int submode) const;
|
|
|
|
void fmCreateVlan(uint16_t vlan) const;
|
|
void fmAddVlanPort(uint16_t vlan, int port, bool tagVlan) const;
|
|
void fmSetVlanPortState(uint16_t vlan, int port, int state) const;
|
|
|
|
template<typename T>
|
|
void fmSetVlanAttribute(uint16_t vlan, int attribute, T value) const;
|
|
|
|
template<typename T>
|
|
T fmGetVlanAttribute(uint16_t vlan, int attribute) const;
|
|
|
|
template<typename T>
|
|
void fmSetPortAttribute(int port, int attribute, T value) const;
|
|
|
|
template<typename T>
|
|
T fmGetPortAttribute(int port, int attribute) const;
|
|
|
|
template<typename T>
|
|
void fmSetSwitchAttribute(int attribute, T value) const;
|
|
|
|
template<typename T>
|
|
T fmGetSwitchAttribute(int attribute) const;
|
|
|
|
int fmGetSwitch() const;
|
|
|
|
private:
|
|
IES();
|
|
|
|
std::vector<std::pair<std::string, std::pair<TlvType, std::string>>> m_configuration{};
|
|
bool m_initialized = false;
|
|
std::string m_tempPath{};
|
|
|
|
|
|
static std::unique_ptr<IES> instance;
|
|
|
|
void handleSwitchInsertedEvent(int sw);
|
|
void handlePortEvent(int sw, struct _fm_eventPort&);
|
|
|
|
static void eventHandler(int event, int sw, void *ptr);
|
|
};
|
|
}
|
|
|
|
|
|
class IESException : public std::exception{
|
|
public:
|
|
explicit IESException(int status);
|
|
|
|
const char* what() const noexcept override
|
|
{
|
|
return m_msg.c_str();
|
|
}
|
|
|
|
const std::string m_msg;
|
|
}; |