Skip to content

Commit

Permalink
Add switching for writing into tsc deltas
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Abrosimov committed Dec 28, 2023
1 parent 0a31e77 commit a122aa3
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 78 deletions.
4 changes: 3 additions & 1 deletion cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ std::vector<std::tuple<std::string,
{"fw list", "<original|generated|state|all|dispatcher>", [](const auto& args) { call(show::fwlist, args); }},
{},
{"show shm info", "", [](const auto& args) { call(show::shm_info, args); }},
{"show shm tsc info", "", [](const auto& args) { call(show::shm_tsc_info, args); }},
{},
{"tsc show shm info", "", [](const auto& args) { call(show::shm_tsc_info, args); }},
{"tsc set state", "[true|false]", [](const auto& args) { call(show::shm_tsc_set_state, args); }},
{},
{"samples show", "", [](const auto& args) { call(show::samples, args); }},
{"samples dump", "", [](const auto& args) { call(show::samples_dump, args); }},
Expand Down
7 changes: 7 additions & 0 deletions cli/show.h
Original file line number Diff line number Diff line change
Expand Up @@ -869,4 +869,11 @@ void shm_tsc_info()
table.print();
}

void shm_tsc_set_state(std::string state)
{
interface::dataPlane dataplane;
bool new_state = state == "true";
dataplane.set_shm_tsc_state(new_state);
}

}
5 changes: 5 additions & 0 deletions common/idataplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ class dataPlane
return get<common::idp::requestType::get_shm_tsc_info, common::idp::get_shm_tsc_info::response>();
}

auto set_shm_tsc_state(const common::idp::get_shm_tsc_info::request& request) const
{
return get<common::idp::requestType::set_shm_tsc_state, eResult>(request);
}

auto dump_physical_port(const common::idp::dump_physical_port::request& request) const
{
return get<common::idp::requestType::dump_physical_port, eResult>(request);
Expand Down
6 changes: 5 additions & 1 deletion common/idp.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ enum class requestType : uint32_t
get_counter_by_name,
get_shm_info,
get_shm_tsc_info,
set_shm_tsc_state,
dump_physical_port,
balancer_state_clear,
size, // size should always be at the bottom of the list, this enum allows us to find out the size of the enum list
Expand Down Expand Up @@ -861,6 +862,8 @@ using tsc_meta = std::tuple<tCoreId, ///< core id
uint64_t>; /// offset

using response = std::vector<tsc_meta>;
using state = bool;
using request = bool;
}

namespace dump_physical_port
Expand Down Expand Up @@ -927,7 +930,8 @@ using request = std::tuple<requestType,
unrdup_vip_to_balancers::request,
update_vip_vport_proto::request,
get_counter_by_name::request,
dump_physical_port::request>>;
dump_physical_port::request,
get_shm_tsc_info::request>>;

using response = std::variant<std::tuple<>,
updateGlobalBase::response, ///< + others which have eResult as response
Expand Down
4 changes: 4 additions & 0 deletions dataplane/bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ void cBus::clientThread(int clientSocket)
{
response = callWithResponse(&cControlPlane::get_shm_tsc_info, request);
}
else if (type == common::idp::requestType::set_shm_tsc_state)
{
response = callWithResponse(&cControlPlane::set_shm_tsc_state, request);
}
else if (type == common::idp::requestType::dump_physical_port)
{
response = callWithResponse(&cControlPlane::dump_physical_port, request);
Expand Down
7 changes: 7 additions & 0 deletions dataplane/controlplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <rte_lcore.h>
#include <rte_malloc.h>

#include "common/idp.h"
#include "common/version.h"

#include "checksum.h"
Expand Down Expand Up @@ -1239,6 +1240,12 @@ common::idp::get_shm_tsc_info::response cControlPlane::get_shm_tsc_info()
return response;
}

eResult cControlPlane::set_shm_tsc_state(const common::idp::get_shm_tsc_info::request& request)
{
auto response = dataPlane->setShmTscState(request);
return response;
}

eResult cControlPlane::dump_physical_port(const common::idp::dump_physical_port::request& request)
{
const auto& [interface_name, direction, state] = request;
Expand Down
1 change: 1 addition & 0 deletions dataplane/controlplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class cControlPlane ///< @todo: move to cDataPlane
common::idp::nat64stateful_state::response nat64stateful_state(const common::idp::nat64stateful_state::request& request);
common::idp::get_shm_info::response get_shm_info();
common::idp::get_shm_tsc_info::response get_shm_tsc_info();
eResult set_shm_tsc_state(const common::idp::get_shm_tsc_info::request& request);
eResult dump_physical_port(const common::idp::dump_physical_port::request& request);
eResult balancer_state_clear();

Expand Down
8 changes: 8 additions & 0 deletions dataplane/dataplane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <sys/mman.h>

#include "common.h"
#include "common/idp.h"
#include "common/result.h"
#include "dataplane.h"
#include "report.h"
#include "sock_dev.h"
Expand Down Expand Up @@ -1408,6 +1410,12 @@ common::idp::get_shm_tsc_info::response cDataPlane::getShmTscInfo()
return result;
}

eResult cDataPlane::setShmTscState(common::idp::get_shm_tsc_info::state state)
{
tscs_active = state;
return eResult::success;
}

std::map<std::string, common::uint64> cDataPlane::getPortStats(const tPortId& portId) const
{
/// unsafe
Expand Down
5 changes: 4 additions & 1 deletion dataplane/dataplane.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class cDataPlane
std::optional<uint64_t> getCounterValueByName(const std::string& counter_name, uint32_t coreId);
common::idp::get_shm_info::response getShmInfo();
common::idp::get_shm_tsc_info::response getShmTscInfo();
eResult setShmTscState(common::idp::get_shm_tsc_info::state new_state);

template<typename type,
typename... args_t>
Expand Down Expand Up @@ -328,9 +329,11 @@ class cDataPlane
rte_mempool* mempool_log;

common::idp::get_shm_info::response dumps_meta;
common::idp::get_shm_tsc_info::response tscs_meta;
std::map<std::string, uint64_t> tag_to_id;

common::idp::get_shm_tsc_info::response tscs_meta;
common::idp::get_shm_tsc_info::state tscs_active;

/// modules
cReport report;
std::unique_ptr<cControlPlane> controlPlane;
Expand Down
Loading

0 comments on commit a122aa3

Please sign in to comment.