diff --git a/dataplane/controlplane.cpp b/dataplane/controlplane.cpp index d7a7580c..9d07b5a6 100644 --- a/dataplane/controlplane.cpp +++ b/dataplane/controlplane.cpp @@ -80,7 +80,7 @@ eResult cControlPlane::init(bool use_kernel_interface) return result; } - gc_step = dataPlane->getConfigValue(eConfigType::gc_step); + gc_step = dataPlane->getConfigValues().gc_step; dregress.gc_step = gc_step; icmpOutRemainder = dataPlane->config.SWICMPOutRateLimit / dataPlane->config.rateLimitDivisor; @@ -1415,7 +1415,7 @@ void cControlPlane::waitAllWorkers() eResult cControlPlane::initMempool() { mempool = rte_mempool_create("cp", - CONFIG_YADECAP_MBUFS_COUNT + dataPlane->getConfigValue(eConfigType::fragmentation_size) + dataPlane->getConfigValue(eConfigType::master_mempool_size) + 4 * CONFIG_YADECAP_PORTS_SIZE * CONFIG_YADECAP_MBUFS_BURST_SIZE + 4 * dataPlane->ports.size() * dataPlane->getConfigValue(eConfigType::kernel_interface_queue_size), + CONFIG_YADECAP_MBUFS_COUNT + dataPlane->getConfigValues().fragmentation_size + dataPlane->getConfigValues().master_mempool_size + 4 * CONFIG_YADECAP_PORTS_SIZE * CONFIG_YADECAP_MBUFS_BURST_SIZE + 4 * dataPlane->ports.size() * dataPlane->getConfigValues().kernel_interface_queue_size, CONFIG_YADECAP_MBUF_SIZE, 0, sizeof(struct rte_pktmbuf_pool_private), @@ -1515,7 +1515,7 @@ std::optional cControlPlane::add_kernel_interface(const tPortId port_id snprintf(vdev_args, sizeof(vdev_args), "path=/dev/vhost-net,queues=1,queue_size=%lu,iface=%s,mac=%s", - dataPlane->getConfigValue(eConfigType::kernel_interface_queue_size), + dataPlane->getConfigValues().kernel_interface_queue_size, interface_name.data(), common::mac_address_t(ether_addr.addr_bytes).toString().data()); @@ -1557,7 +1557,7 @@ std::optional cControlPlane::add_kernel_interface(const tPortId port_id int rc = rte_eth_rx_queue_setup(kernel_port_id, 0, - dataPlane->getConfigValue(eConfigType::kernel_interface_queue_size), + dataPlane->getConfigValues().kernel_interface_queue_size, 0, ///< @todo: socket nullptr, mempool); @@ -1570,7 +1570,7 @@ std::optional cControlPlane::add_kernel_interface(const tPortId port_id rc = rte_eth_tx_queue_setup(kernel_port_id, 0, - dataPlane->getConfigValue(eConfigType::kernel_interface_queue_size), + dataPlane->getConfigValues().kernel_interface_queue_size, 0, ///< @todo: socket nullptr); if (rc < 0) @@ -2826,26 +2826,26 @@ bool cControlPlane::handlePacket_fw_state_sync_ingress(rte_mbuf* mbuf) value.packets_forward = 0; value.tcp.unpack(payload->flags); - uint32_t state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_other_protocols_timeout); + uint32_t state_timeout = dataPlane->getConfigValues().stateful_firewall_other_protocols_timeout; if (payload->proto == IPPROTO_UDP) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_udp_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_udp_timeout; } else if (payload->proto == IPPROTO_TCP) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_timeout; uint8_t flags = value.tcp.src_flags | value.tcp.dst_flags; if (flags & (uint8_t)common::fwstate::tcp_flags_e::ACK) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_syn_ack_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_syn_ack_timeout; } else if (flags & (uint8_t)common::fwstate::tcp_flags_e::SYN) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_syn_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_syn_timeout; } if (flags & (uint8_t)common::fwstate::tcp_flags_e::FIN) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_fin_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_fin_timeout; } } value.state_timeout = state_timeout; @@ -2906,26 +2906,26 @@ bool cControlPlane::handlePacket_fw_state_sync_ingress(rte_mbuf* mbuf) value.packets_forward = 0; value.tcp.unpack(payload->flags); - uint32_t state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_other_protocols_timeout); + uint32_t state_timeout = dataPlane->getConfigValues().stateful_firewall_other_protocols_timeout; if (payload->proto == IPPROTO_UDP) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_udp_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_udp_timeout; } else if (payload->proto == IPPROTO_TCP) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_timeout; uint8_t flags = value.tcp.src_flags | value.tcp.dst_flags; if (flags & (uint8_t)common::fwstate::tcp_flags_e::ACK) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_syn_ack_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_syn_ack_timeout; } else if (flags & (uint8_t)common::fwstate::tcp_flags_e::SYN) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_syn_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_syn_timeout; } if (flags & (uint8_t)common::fwstate::tcp_flags_e::FIN) { - state_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_fin_timeout); + state_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_fin_timeout; } } value.state_timeout = state_timeout; diff --git a/dataplane/dataplane.cpp b/dataplane/dataplane.cpp index 61676cf2..a329d57d 100644 --- a/dataplane/dataplane.cpp +++ b/dataplane/dataplane.cpp @@ -47,41 +47,6 @@ cDataPlane::cDataPlane() : controlPlane(new cControlPlane(this)), bus(this) { - configValues = { - {eConfigType::port_rx_queue_size, 4096}, - {eConfigType::port_tx_queue_size, 4096}, - {eConfigType::ring_highPriority_size, 64}, - {eConfigType::ring_normalPriority_size, 256}, - {eConfigType::ring_lowPriority_size, 64}, - {eConfigType::ring_toFreePackets_size, 64}, - {eConfigType::ring_log_size, 1024}, - {eConfigType::fragmentation_size, 1024}, - {eConfigType::fragmentation_timeout_first, 32}, - {eConfigType::fragmentation_timeout_last, 16}, - {eConfigType::fragmentation_packets_per_flow, 64}, - {eConfigType::stateful_firewall_tcp_timeout, 120}, - {eConfigType::stateful_firewall_tcp_syn_timeout, YANET_CONFIG_STATE_TIMEOUT_DEFAULT}, - {eConfigType::stateful_firewall_tcp_syn_ack_timeout, YANET_CONFIG_STATE_TIMEOUT_DEFAULT}, - {eConfigType::stateful_firewall_tcp_fin_timeout, YANET_CONFIG_STATE_TIMEOUT_DEFAULT}, - {eConfigType::stateful_firewall_udp_timeout, 30}, - {eConfigType::stateful_firewall_other_protocols_timeout, 16}, - {eConfigType::gc_step, 8}, - {eConfigType::sample_gc_step, 512}, - {eConfigType::acl_states4_ht_size, YANET_CONFIG_ACL_STATES4_HT_SIZE}, - {eConfigType::acl_states6_ht_size, YANET_CONFIG_ACL_STATES6_HT_SIZE}, - {eConfigType::master_mempool_size, 8192}, - {eConfigType::nat64stateful_states_size, YANET_CONFIG_NAT64STATEFUL_HT_SIZE}, - {eConfigType::kernel_interface_queue_size, YANET_CONFIG_KERNEL_INTERFACE_QUEUE_SIZE}, - {eConfigType::balancer_state_ht_size, YANET_CONFIG_BALANCER_STATE_HT_SIZE}, - {eConfigType::tsc_active_state, YANET_CONFIG_TSC_ACTIVE_STATE}, - {eConfigType::balancer_tcp_timeout, YANET_CONFIG_BALANCER_STATE_TIMEOUT_DEFAULT}, - {eConfigType::balancer_tcp_syn_timeout, YANET_CONFIG_BALANCER_STATE_TIMEOUT_DEFAULT}, - {eConfigType::balancer_tcp_syn_ack_timeout, YANET_CONFIG_BALANCER_STATE_TIMEOUT_DEFAULT}, - {eConfigType::balancer_tcp_fin_timeout, YANET_CONFIG_BALANCER_STATE_TIMEOUT_DEFAULT}, - {eConfigType::balancer_udp_timeout, YANET_CONFIG_BALANCER_STATE_TIMEOUT_DEFAULT}, - {eConfigType::balancer_other_protocols_timeout, YANET_CONFIG_BALANCER_STATE_TIMEOUT_DEFAULT}, - {eConfigType::neighbor_ht_size, 64 * 1024}, - }; } cDataPlane::~cDataPlane() @@ -594,7 +559,7 @@ eResult cDataPlane::initGlobalBases() auto* ipv4_states_ht = memory_manager.create("acl.state.v4.ht", socket_id, - acl::ipv4_states_ht::calculate_sizeof(getConfigValue(eConfigType::acl_states4_ht_size))); + acl::ipv4_states_ht::calculate_sizeof(getConfigValues().acl_states4_ht_size)); if (!ipv4_states_ht) { return eResult::errorAllocatingMemory; @@ -602,7 +567,7 @@ eResult cDataPlane::initGlobalBases() auto* ipv6_states_ht = memory_manager.create("acl.state.v6.ht", socket_id, - acl::ipv6_states_ht::calculate_sizeof(getConfigValue(eConfigType::acl_states6_ht_size))); + acl::ipv6_states_ht::calculate_sizeof(getConfigValues().acl_states6_ht_size)); if (!ipv6_states_ht) { return eResult::errorAllocatingMemory; @@ -610,7 +575,7 @@ eResult cDataPlane::initGlobalBases() auto* nat64stateful_lan_state = memory_manager.create("nat64stateful.state.lan.ht", socket_id, - nat64stateful::lan_ht::calculate_sizeof(getConfigValue(eConfigType::nat64stateful_states_size))); + nat64stateful::lan_ht::calculate_sizeof(getConfigValues().nat64stateful_states_size)); if (!nat64stateful_lan_state) { return eResult::errorAllocatingMemory; @@ -618,7 +583,7 @@ eResult cDataPlane::initGlobalBases() auto* nat64stateful_wan_state = memory_manager.create("nat64stateful.state.wan.ht", socket_id, - nat64stateful::wan_ht::calculate_sizeof(getConfigValue(eConfigType::nat64stateful_states_size))); + nat64stateful::wan_ht::calculate_sizeof(getConfigValues().nat64stateful_states_size)); if (!nat64stateful_wan_state) { return eResult::errorAllocatingMemory; @@ -626,17 +591,17 @@ eResult cDataPlane::initGlobalBases() auto* balancer_state = memory_manager.create("balancer.state.ht", socket_id, - dataplane::globalBase::balancer::state_ht::calculate_sizeof(getConfigValue(eConfigType::balancer_state_ht_size))); + dataplane::globalBase::balancer::state_ht::calculate_sizeof(getConfigValues().balancer_state_ht_size)); if (!balancer_state) { return eResult::errorAllocatingMemory; } - globalbase_atomic->updater.fw4_state.update_pointer(ipv4_states_ht, socket_id, getConfigValue(eConfigType::acl_states4_ht_size)); - globalbase_atomic->updater.fw6_state.update_pointer(ipv6_states_ht, socket_id, getConfigValue(eConfigType::acl_states6_ht_size)); - globalbase_atomic->updater.nat64stateful_lan_state.update_pointer(nat64stateful_lan_state, socket_id, getConfigValue(eConfigType::nat64stateful_states_size)); - globalbase_atomic->updater.nat64stateful_wan_state.update_pointer(nat64stateful_wan_state, socket_id, getConfigValue(eConfigType::nat64stateful_states_size)); - globalbase_atomic->updater.balancer_state.update_pointer(balancer_state, socket_id, getConfigValue(eConfigType::balancer_state_ht_size)); + globalbase_atomic->updater.fw4_state.update_pointer(ipv4_states_ht, socket_id, getConfigValues().acl_states4_ht_size); + globalbase_atomic->updater.fw6_state.update_pointer(ipv6_states_ht, socket_id, getConfigValues().acl_states6_ht_size); + globalbase_atomic->updater.nat64stateful_lan_state.update_pointer(nat64stateful_lan_state, socket_id, getConfigValues().nat64stateful_states_size); + globalbase_atomic->updater.nat64stateful_wan_state.update_pointer(nat64stateful_wan_state, socket_id, getConfigValues().nat64stateful_states_size); + globalbase_atomic->updater.balancer_state.update_pointer(balancer_state, socket_id, getConfigValues().balancer_state_ht_size); globalbase_atomic->fw4_state = ipv4_states_ht; globalbase_atomic->fw6_state = ipv6_states_ht; @@ -1049,7 +1014,7 @@ eResult cDataPlane::initQueues() { int ret = rte_eth_tx_queue_setup(portId, queueId, - getConfigValue(eConfigType::port_tx_queue_size), + getConfigValues().port_tx_queue_size, rte_eth_dev_socket_id(portId), nullptr); ///< @todo if (ret < 0) @@ -1173,17 +1138,6 @@ void cDataPlane::run_on_worker_gc(const tSocketId socket_id, socket_worker_gcs.find(socket_id)->second->run_on_this_thread(callback); } -uint64_t cDataPlane::getConfigValue(const eConfigType& type) const -{ - if (configValues.find(type) == configValues.end()) - { - YADECAP_LOG_ERROR("unknown variable\n"); - return 0; - } - - return configValues.find(type)->second; -} - eResult cDataPlane::allocateSharedMemory() { /// precalculation of shared memory size for each numa @@ -1714,178 +1668,7 @@ eResult cDataPlane::parseJsonPorts(const nlohmann::json& json) eResult cDataPlane::parseConfigValues(const nlohmann::json& json) { - if (exist(json, "port_rx_queue_size")) - { - configValues[eConfigType::port_rx_queue_size] = json["port_rx_queue_size"]; - } - - if (exist(json, "port_tx_queue_size")) - { - configValues[eConfigType::port_tx_queue_size] = json["port_tx_queue_size"]; - } - - if (exist(json, "ring_highPriority_size")) - { - configValues[eConfigType::ring_highPriority_size] = json["ring_highPriority_size"]; - } - - if (exist(json, "ring_normalPriority_size")) - { - configValues[eConfigType::ring_normalPriority_size] = json["ring_normalPriority_size"]; - } - - if (exist(json, "ring_lowPriority_size")) - { - configValues[eConfigType::ring_lowPriority_size] = json["ring_lowPriority_size"]; - } - - if (exist(json, "fragmentation_size")) - { - configValues[eConfigType::fragmentation_size] = json["fragmentation_size"]; - } - - if (exist(json, "fragmentation_timeout_first")) - { - configValues[eConfigType::fragmentation_timeout_first] = json["fragmentation_timeout_first"]; - } - - if (exist(json, "fragmentation_timeout_last")) - { - configValues[eConfigType::fragmentation_timeout_last] = json["fragmentation_timeout_last"]; - } - - if (exist(json, "fragmentation_packets_per_flow")) - { - configValues[eConfigType::fragmentation_packets_per_flow] = json["fragmentation_packets_per_flow"]; - } - /* - The decoding order of four options bellow is important. The first one - is more common and sets a timeout value for any tcp session whereas - three following aloow one to set timeouts more precissely basing on - the last processed tcp session packet flags. So if any of flag-based - options is ommitted the more common option should be applied. - */ - if (exist(json, "stateful_firewall_tcp_timeout")) - { - configValues[eConfigType::stateful_firewall_tcp_timeout] = json["stateful_firewall_tcp_timeout"]; - /* Set the same value as a default for all descendant options. */ - configValues[eConfigType::stateful_firewall_tcp_syn_timeout] = configValues[eConfigType::stateful_firewall_tcp_timeout]; - configValues[eConfigType::stateful_firewall_tcp_syn_ack_timeout] = configValues[eConfigType::stateful_firewall_tcp_timeout]; - configValues[eConfigType::stateful_firewall_tcp_fin_timeout] = configValues[eConfigType::stateful_firewall_tcp_timeout]; - } - /* - Syn Ack is descendant of Syn state so as we do not have `is-set` - flag for option we should preserve the decoding order. - */ - if (exist(json, "stateful_firewall_tcp_syn_timeout")) - { - configValues[eConfigType::stateful_firewall_tcp_syn_timeout] = json["stateful_firewall_tcp_syn_timeout"]; - /* Set the value as default for Syn-Ack timeouts. */ - configValues[eConfigType::stateful_firewall_tcp_syn_ack_timeout] = configValues[eConfigType::stateful_firewall_tcp_syn_timeout]; - } - if (exist(json, "stateful_firewall_tcp_syn_ack_timeout")) - { - configValues[eConfigType::stateful_firewall_tcp_syn_ack_timeout] = json["stateful_firewall_tcp_syn_ack_timeout"]; - } - if (exist(json, "stateful_firewall_tcp_fin_timeout")) - { - configValues[eConfigType::stateful_firewall_tcp_fin_timeout] = json["stateful_firewall_tcp_fin_timeout"]; - } - if (exist(json, "stateful_firewall_udp_timeout")) - { - configValues[eConfigType::stateful_firewall_udp_timeout] = json["stateful_firewall_udp_timeout"]; - } - if (exist(json, "stateful_firewall_other_protocols_timeout")) - { - configValues[eConfigType::stateful_firewall_other_protocols_timeout] = json["stateful_firewall_other_protocols_timeout"]; - } - if (exist(json, "gc_step")) - { - configValues[eConfigType::gc_step] = json["gc_step"]; - } - if (exist(json, "sample_gc_step")) - { - configValues[eConfigType::sample_gc_step] = json["sample_gc_step"]; - } - if (exist(json, "acl_states4_ht_size")) - { - configValues[eConfigType::acl_states4_ht_size] = json["acl_states4_ht_size"]; - } - if (exist(json, "acl_states6_ht_size")) - { - configValues[eConfigType::acl_states6_ht_size] = json["acl_states6_ht_size"]; - } - - if (exist(json, "master_mempool_size")) - { - configValues[eConfigType::master_mempool_size] = json["master_mempool_size"]; - } - - if (exist(json, "nat64stateful_states_size")) - { - configValues[eConfigType::nat64stateful_states_size] = json["nat64stateful_states_size"]; - } - - if (exist(json, "kernel_interface_queue_size")) - { - configValues[eConfigType::kernel_interface_queue_size] = json["kernel_interface_queue_size"]; - } - - if (exist(json, "balancer_state_ht_size")) - { - configValues[eConfigType::balancer_state_ht_size] = json["balancer_state_ht_size"]; - } - - if (exist(json, "tsc_active_state")) - { - configValues[eConfigType::tsc_active_state] = json["tsc_active_state"]; - } - /* - The decoding order of four options bellow is important. The first one - is more common and sets a timeout value for any tcp session whereas - three following aloow one to set timeouts more precissely basing on - the last processed tcp session packet flags. So if any of flag-based - options is ommitted the more common option should be applied. - */ - if (exist(json, "balancer_tcp_timeout")) - { - configValues[eConfigType::balancer_tcp_timeout] = json["balancer_tcp_timeout"]; - /* Set the same value as a default for all descendant options. */ - configValues[eConfigType::balancer_tcp_syn_timeout] = configValues[eConfigType::balancer_tcp_timeout]; - configValues[eConfigType::balancer_tcp_syn_ack_timeout] = configValues[eConfigType::balancer_tcp_timeout]; - configValues[eConfigType::balancer_tcp_fin_timeout] = configValues[eConfigType::balancer_tcp_timeout]; - } - /* - Syn Ack is descendant of Syn state so as we do not have `is-set` - flag for option we should preserve the decoding order. - */ - if (exist(json, "balancer_tcp_syn_timeout")) - { - configValues[eConfigType::balancer_tcp_syn_timeout] = json["balancer_tcp_syn_timeout"]; - /* Set the value as default for Syn-Ack timeouts. */ - configValues[eConfigType::balancer_tcp_syn_ack_timeout] = configValues[eConfigType::balancer_tcp_syn_timeout]; - } - if (exist(json, "balancer_tcp_syn_ack_timeout")) - { - configValues[eConfigType::balancer_tcp_syn_ack_timeout] = json["balancer_tcp_syn_ack_timeout"]; - } - if (exist(json, "balancer_tcp_fin_timeout")) - { - configValues[eConfigType::balancer_tcp_fin_timeout] = json["balancer_tcp_fin_timeout"]; - } - if (exist(json, "balancer_udp_timeout")) - { - configValues[eConfigType::balancer_udp_timeout] = json["balancer_udp_timeout"]; - } - if (exist(json, "balancer_other_protocols_timeout")) - { - configValues[eConfigType::balancer_other_protocols_timeout] = json["balancer_other_protocols_timeout"]; - } - if (exist(json, "neighbor_ht_size")) - { - configValues[eConfigType::neighbor_ht_size] = json["neighbor_ht_size"]; - } - + configValues = json; return eResult::success; } diff --git a/dataplane/dataplane.h b/dataplane/dataplane.h index 9c7fcf8f..24e4e6f9 100644 --- a/dataplane/dataplane.h +++ b/dataplane/dataplane.h @@ -18,6 +18,7 @@ #include "common/result.h" #include "common/type.h" +#include "config_values.h" #include "bus.h" #include "controlplane.h" #include "globalbase.h" @@ -26,43 +27,6 @@ #include "type.h" #include "worker_gc.h" -enum class eConfigType -{ - port_rx_queue_size, - port_tx_queue_size, - ring_highPriority_size, - ring_normalPriority_size, - ring_lowPriority_size, - ring_toFreePackets_size, - ring_log_size, - fragmentation_size, - fragmentation_timeout_first, - fragmentation_timeout_last, - fragmentation_packets_per_flow, - stateful_firewall_udp_timeout, - stateful_firewall_tcp_timeout, - stateful_firewall_tcp_syn_timeout, - stateful_firewall_tcp_syn_ack_timeout, - stateful_firewall_tcp_fin_timeout, - stateful_firewall_other_protocols_timeout, - gc_step, - sample_gc_step, - acl_states4_ht_size, - acl_states6_ht_size, - master_mempool_size, - nat64stateful_states_size, - kernel_interface_queue_size, - balancer_state_ht_size, - tsc_active_state, - balancer_udp_timeout, - balancer_tcp_timeout, - balancer_tcp_syn_timeout, - balancer_tcp_syn_ack_timeout, - balancer_tcp_fin_timeout, - balancer_other_protocols_timeout, - neighbor_ht_size, -}; - struct tDataPlaneConfig { /* @@ -126,7 +90,7 @@ class cDataPlane void start(); void join(); - uint64_t getConfigValue(const eConfigType& type) const; + const ConfigValues& getConfigValues() const { return configValues; } std::map getPortStats(const tPortId& portId) const; std::optional interface_name_to_port_id(const std::string& interface_name); const std::set& get_socket_ids() const; @@ -195,7 +159,7 @@ class cDataPlane std::map> globalBases; uint32_t globalBaseSerial; - std::map configValues; + ConfigValues configValues; std::map dataPlane->getConfigValue(eConfigType::fragmentation_size)) + if (stats.current_count_packets > dataPlane->getConfigValues().fragmentation_size) { stats.total_overflow_packets++; rte_pktmbuf_free(mbuf); @@ -137,7 +137,7 @@ void fragmentation_t::insert(rte_mbuf* mbuf) { auto& value = fragments[key]; - if (std::get<0>(value).size() > dataPlane->getConfigValue(eConfigType::fragmentation_packets_per_flow)) + if (std::get<0>(value).size() > dataPlane->getConfigValues().fragmentation_packets_per_flow) { stats.flow_overflow_packets++; rte_pktmbuf_free(mbuf); @@ -246,12 +246,12 @@ bool fragmentation_t::isTimeout(const fragmentation::value_t& value) { uint16_t currentTime = time(nullptr); - if ((uint16_t)(currentTime - std::get<1>(value)) >= dataPlane->getConfigValue(eConfigType::fragmentation_timeout_first)) + if ((uint16_t)(currentTime - std::get<1>(value)) >= dataPlane->getConfigValues().fragmentation_timeout_first) { return true; } - if ((uint16_t)(currentTime - std::get<2>(value)) >= dataPlane->getConfigValue(eConfigType::fragmentation_timeout_last)) + if ((uint16_t)(currentTime - std::get<2>(value)) >= dataPlane->getConfigValues().fragmentation_timeout_last) { return true; } diff --git a/dataplane/globalbase.cpp b/dataplane/globalbase.cpp index 446ac1c4..84afe5f9 100644 --- a/dataplane/globalbase.cpp +++ b/dataplane/globalbase.cpp @@ -19,16 +19,16 @@ atomic::atomic(cDataPlane* dataPlane, dataPlane(dataPlane), socketId(socketId) { - fw_state_config.tcp_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_timeout); - fw_state_config.udp_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_udp_timeout); - fw_state_config.other_protocols_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_other_protocols_timeout); + fw_state_config.tcp_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_timeout; + fw_state_config.udp_timeout = dataPlane->getConfigValues().stateful_firewall_udp_timeout; + fw_state_config.other_protocols_timeout = dataPlane->getConfigValues().stateful_firewall_other_protocols_timeout; fw_state_config.sync_timeout = 8; memset(physicalPort_flags, 0, sizeof(physicalPort_flags)); memset(counter_shifts, 0, sizeof(counter_shifts)); memset(gc_counter_shifts, 0, sizeof(gc_counter_shifts)); - tsc_active_state = dataPlane->getConfigValue(eConfigType::tsc_active_state); + tsc_active_state = dataPlane->getConfigValues().tsc_active_state; } atomic::~atomic() diff --git a/dataplane/neighbor.cpp b/dataplane/neighbor.cpp index db986ebf..c20743a0 100644 --- a/dataplane/neighbor.cpp +++ b/dataplane/neighbor.cpp @@ -203,7 +203,7 @@ eResult module::init(cDataPlane* dataplane) { this->dataplane = dataplane; - auto ht_size = dataplane->getConfigValue(eConfigType::neighbor_ht_size); + auto ht_size = dataplane->getConfigValues().neighbor_ht_size; generation_hashtable.fill([&](neighbor::generation_hashtable& hashtable) { for (const auto socket_id : dataplane->get_socket_ids()) { diff --git a/dataplane/worker.cpp b/dataplane/worker.cpp index 6be69733..7980f46f 100644 --- a/dataplane/worker.cpp +++ b/dataplane/worker.cpp @@ -95,11 +95,11 @@ eResult cWorker::init(const tCoreId& coreId, this->bases[currentBaseId] = base; this->bases[currentBaseId ^ 1] = base; - unsigned int elements_count = 2 * basePermanently.workerPortsCount * dataPlane->getConfigValue(eConfigType::port_rx_queue_size) + - 2 * basePermanently.workerPortsCount * dataPlane->getConfigValue(eConfigType::port_tx_queue_size) + - 2 * dataPlane->getConfigValue(eConfigType::ring_highPriority_size) + - 2 * dataPlane->getConfigValue(eConfigType::ring_normalPriority_size) + - 2 * dataPlane->getConfigValue(eConfigType::ring_lowPriority_size); + unsigned int elements_count = 2 * basePermanently.workerPortsCount * dataPlane->getConfigValues().port_rx_queue_size + + 2 * basePermanently.workerPortsCount * dataPlane->getConfigValues().port_tx_queue_size + + 2 * dataPlane->getConfigValues().ring_highPriority_size + + 2 * dataPlane->getConfigValues().ring_normalPriority_size + + 2 * dataPlane->getConfigValues().ring_lowPriority_size; YADECAP_LOG_DEBUG("elements_count: %u\n", elements_count); @@ -123,7 +123,7 @@ eResult cWorker::init(const tCoreId& coreId, /// init rings ring_highPriority = rte_ring_create(("r_hp_" + std::to_string(coreId)).c_str(), - dataPlane->getConfigValue(eConfigType::ring_highPriority_size), + dataPlane->getConfigValues().ring_highPriority_size, socketId, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_highPriority) @@ -132,7 +132,7 @@ eResult cWorker::init(const tCoreId& coreId, } ring_normalPriority = rte_ring_create(("r_np_" + std::to_string(coreId)).c_str(), - dataPlane->getConfigValue(eConfigType::ring_normalPriority_size), + dataPlane->getConfigValues().ring_normalPriority_size, socketId, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_normalPriority) @@ -141,7 +141,7 @@ eResult cWorker::init(const tCoreId& coreId, } ring_lowPriority = rte_ring_create(("r_lp_" + std::to_string(coreId)).c_str(), - dataPlane->getConfigValue(eConfigType::ring_lowPriority_size), + dataPlane->getConfigValues().ring_lowPriority_size, socketId, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_lowPriority) @@ -150,7 +150,7 @@ eResult cWorker::init(const tCoreId& coreId, } ring_toFreePackets = rte_ring_create(("r_tfp_" + std::to_string(coreId)).c_str(), - dataPlane->getConfigValue(eConfigType::ring_toFreePackets_size), + dataPlane->getConfigValues().ring_toFreePackets_size, socketId, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_toFreePackets) @@ -159,7 +159,7 @@ eResult cWorker::init(const tCoreId& coreId, } ring_log = rte_ring_create(("r_log_" + std::to_string(coreId)).c_str(), - dataPlane->getConfigValue(eConfigType::ring_log_size), + dataPlane->getConfigValues().ring_log_size, socketId, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_log) @@ -173,19 +173,19 @@ eResult cWorker::init(const tCoreId& coreId, return eResult::invalidCoreId; } - acl_state_config.tcp_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_timeout); - acl_state_config.tcp_syn_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_syn_timeout); - acl_state_config.tcp_syn_ack_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_syn_ack_timeout); - acl_state_config.tcp_fin_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_tcp_fin_timeout); - acl_state_config.udp_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_udp_timeout); - acl_state_config.default_timeout = dataPlane->getConfigValue(eConfigType::stateful_firewall_other_protocols_timeout); + acl_state_config.tcp_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_timeout; + acl_state_config.tcp_syn_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_syn_timeout; + acl_state_config.tcp_syn_ack_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_syn_ack_timeout; + acl_state_config.tcp_fin_timeout = dataPlane->getConfigValues().stateful_firewall_tcp_fin_timeout; + acl_state_config.udp_timeout = dataPlane->getConfigValues().stateful_firewall_udp_timeout; + acl_state_config.default_timeout = dataPlane->getConfigValues().stateful_firewall_other_protocols_timeout; - balancer_state_config.tcp_timeout = dataPlane->getConfigValue(eConfigType::balancer_tcp_timeout); - balancer_state_config.tcp_syn_timeout = dataPlane->getConfigValue(eConfigType::balancer_tcp_syn_timeout); - balancer_state_config.tcp_syn_ack_timeout = dataPlane->getConfigValue(eConfigType::balancer_tcp_syn_ack_timeout); - balancer_state_config.tcp_fin_timeout = dataPlane->getConfigValue(eConfigType::balancer_tcp_fin_timeout); - balancer_state_config.udp_timeout = dataPlane->getConfigValue(eConfigType::balancer_udp_timeout); - balancer_state_config.default_timeout = dataPlane->getConfigValue(eConfigType::balancer_other_protocols_timeout); + balancer_state_config.tcp_timeout = dataPlane->getConfigValues().balancer_tcp_timeout; + balancer_state_config.tcp_syn_timeout = dataPlane->getConfigValues().balancer_tcp_syn_timeout; + balancer_state_config.tcp_syn_ack_timeout = dataPlane->getConfigValues().balancer_tcp_syn_ack_timeout; + balancer_state_config.tcp_fin_timeout = dataPlane->getConfigValues().balancer_tcp_fin_timeout; + balancer_state_config.udp_timeout = dataPlane->getConfigValues().balancer_udp_timeout; + balancer_state_config.default_timeout = dataPlane->getConfigValues().balancer_other_protocols_timeout; return eResult::success; } @@ -199,11 +199,11 @@ void cWorker::start() /// @todo: prepare() - unsigned int mbufs_count_expect = 2 * basePermanently.workerPortsCount * dataPlane->getConfigValue(eConfigType::port_rx_queue_size) + - 2 * basePermanently.workerPortsCount * dataPlane->getConfigValue(eConfigType::port_tx_queue_size) + - 2 * dataPlane->getConfigValue(eConfigType::ring_highPriority_size) + - 2 * dataPlane->getConfigValue(eConfigType::ring_normalPriority_size) + - 2 * dataPlane->getConfigValue(eConfigType::ring_lowPriority_size); + unsigned int mbufs_count_expect = 2 * basePermanently.workerPortsCount * dataPlane->getConfigValues().port_rx_queue_size + + 2 * basePermanently.workerPortsCount * dataPlane->getConfigValues().port_tx_queue_size + + 2 * dataPlane->getConfigValues().ring_highPriority_size + + 2 * dataPlane->getConfigValues().ring_normalPriority_size + + 2 * dataPlane->getConfigValues().ring_lowPriority_size; unsigned int mbufs_count = rte_mempool_avail_count(mempool); if (mbufs_count != mbufs_count_expect) @@ -240,7 +240,7 @@ void cWorker::start() rc = rte_eth_rx_queue_setup(portId, queueId, - dataPlane->getConfigValue(eConfigType::port_rx_queue_size), + dataPlane->getConfigValues().port_rx_queue_size, rte_eth_dev_socket_id(portId), nullptr, ///< @todo mempool); diff --git a/dataplane/worker_gc.cpp b/dataplane/worker_gc.cpp index 81812e45..91e688d5 100644 --- a/dataplane/worker_gc.cpp +++ b/dataplane/worker_gc.cpp @@ -63,8 +63,8 @@ eResult worker_gc_t::init(const tCoreId& core_id, port_id_to_socket_id[port_id] = rte_eth_dev_socket_id(port_id); } - gc_step = dataplane->getConfigValue(eConfigType::gc_step); - sample_gc_step = dataplane->getConfigValue(eConfigType::sample_gc_step); + gc_step = dataplane->getConfigValues().gc_step; + sample_gc_step = dataplane->getConfigValues().sample_gc_step; mempool = rte_mempool_create(("wgc" + std::to_string(core_id)).data(), CONFIG_YADECAP_MBUFS_COUNT + 3 * CONFIG_YADECAP_PORTS_SIZE * CONFIG_YADECAP_MBUFS_BURST_SIZE, @@ -84,7 +84,7 @@ eResult worker_gc_t::init(const tCoreId& core_id, } ring_to_slowworker = rte_ring_create(("r_tsw_" + std::to_string(core_id)).c_str(), - dataplane->getConfigValue(eConfigType::ring_normalPriority_size), + dataplane->getConfigValues().ring_normalPriority_size, socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_to_slowworker) @@ -93,7 +93,7 @@ eResult worker_gc_t::init(const tCoreId& core_id, } ring_to_free_mbuf = rte_ring_create(("r_tfmb_" + std::to_string(core_id)).c_str(), - dataplane->getConfigValue(eConfigType::ring_toFreePackets_size), + dataplane->getConfigValues().ring_toFreePackets_size, socket_id, RING_F_SP_ENQ | RING_F_SC_DEQ); if (!ring_to_free_mbuf)