Files

98 lines
3.4 KiB
C++

/**
* @file include/ActivMiddleware/ActivFramework/KernelBypass/DpdkSettings.h
*
* @brief Header file for DpdkSettings class.
*/
#if (!defined ACTIV_FRAMEWORK_KERNEL_BYPASS_DPDK_SETTINGS_H)
#define ACTIV_FRAMEWORK_KERNEL_BYPASS_DPDK_SETTINGS_H
#include "ActivMiddleware/ActivFramework/External.h"
#if (!defined ACTIV_ENABLE_DPDK)
#error DPDK is not supported on this processor/platform/compiler.
#endif
#include "ActivMiddleware/ActivBase/IniFileParser.h"
#include "ActivMiddleware/ActivBase/ProcessorAffinity.h"
//! Activ namespace.
namespace Activ
{
//! KernelBypass namespace.
namespace KernelBypass
{
/**
* @brief Process wide settings for DPDK.
*
* To use DPDK in multiple threads these settings must be fully populated.
*
* To use DPDK in a single thread these settings do not need to be specified. Devices will be initialized as needed.
*/
class DpdkSettings
{
public:
// Settings for a device.
class Device
{
public:
// Default constructor.
ACTIV_FRAMEWORK_API Device();
/**
* @brief Read settings from an ini file section.
*
* @param sectionIterator iterator to an ini file section.
* @param isDefault whether the default section is being read.
*
* @throw Exception
*/
void Read(const IniFileParser::ConstSectionIterator &sectionIterator, const bool isDefault = false);
String m_deviceName; ///< Name of the device, e.g. eth1.
uint16_t m_rxDescriptorCount; ///< Number of rx descriptors.
uint32_t m_rxBufferCount; ///< Number of rx buffers for queuing.
uint32_t m_rxBufferCacheSize; ///< Size of the per core rx buffer cache.
uint32_t m_rxBufferSize; ///< Size of the rx buffers, zero for DPDK default.
uint16_t m_txDescriptorCount; ///< Number of tx descriptors.
uint32_t m_txBufferCount; ///< Number of tx buffers for queuing.
uint32_t m_txBufferCacheSize; ///< Size of the per core tx buffer cache.
uint32_t m_txBufferSize; ///< Size of the tx buffers, zero for DPDK default.
std::set<String> m_managedEndPointSet; ///< Set of ManagedEndPoint names that will use the device.
};
//! Type to map from device name to device settings.
using DeviceMap = std::map<String, Device>;
//! Default constructor.
ACTIV_FRAMEWORK_API DpdkSettings();
/**
* @brief Read settings from an ini file section.
*
* @param sectionIterator iterator to an ini file section.
*
* @throw Exception
*/
ACTIV_FRAMEWORK_API void Read(const IniFileParser::ConstSectionIterator &sectionIterator);
bool m_isEnabled; ///< Whether DPDK is configured to enable at initialization time.
String m_driverPath; ///< The path to the PMD drivers.
ProcessorAffinity m_controlThreadAffinity; ///< Affinity to apply to any DPDK control threads.
std::vector<String> m_optionList; ///< Additional options to pass to DPDK.
bool m_enableRxInterrupts; ///< Whether to enable RX interrupts.
bool m_enableStatsLog; ///< Whether to enable the per-process stats log.
uint32_t m_statsLogInterval; ///< Interval in ms between stats log entries.
uint32_t m_statsLogNumberOfBackups; ///< Number of stats log backups to keep.
Device m_defaultDeviceSettings; ///< Default settings for devices.
DeviceMap m_deviceMap; ///< Map of devices to configure at initialization time.
};
} // namespace KernelBypass
} // namespace Activ
#endif // (!defined ACTIV_FRAMEWORK_KERNEL_BYPASS_DPDK_SETTINGS_H)