2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

netdev-offload-dpdk: Use per-thread HW offload stats.

The implementation of hardware offload counters in currently meant to be
managed by a single thread. Use the offload thread pool API to manage
one counter per thread.

Signed-off-by: Gaetan Rivet <grive@u256.net>
Reviewed-by: Eli Britstein <elibr@nvidia.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Gaetan Rivet
2021-09-08 11:47:44 +02:00
committed by Ilya Maximets
parent 5b0aa55776
commit 7851e602c0

View File

@@ -69,7 +69,7 @@ struct ufid_to_rte_flow_data {
struct netdev_offload_dpdk_data {
struct cmap ufid_to_rte_flow;
uint64_t rte_flow_counter;
uint64_t *rte_flow_counters;
};
static int
@@ -79,6 +79,8 @@ offload_data_init(struct netdev *netdev)
data = xzalloc(sizeof *data);
cmap_init(&data->ufid_to_rte_flow);
data->rte_flow_counters = xcalloc(netdev_offload_thread_nb(),
sizeof *data->rte_flow_counters);
ovsrcu_set(&netdev->hw_info.offload_data, (void *) data);
@@ -88,6 +90,7 @@ offload_data_init(struct netdev *netdev)
static void
offload_data_destroy__(struct netdev_offload_dpdk_data *data)
{
free(data->rte_flow_counters);
free(data);
}
@@ -833,10 +836,11 @@ netdev_offload_dpdk_flow_create(struct netdev *netdev,
flow = netdev_dpdk_rte_flow_create(netdev, attr, items, actions, error);
if (flow) {
struct netdev_offload_dpdk_data *data;
unsigned int tid = netdev_offload_thread_id();
data = (struct netdev_offload_dpdk_data *)
ovsrcu_get(void *, &netdev->hw_info.offload_data);
data->rte_flow_counter++;
data->rte_flow_counters[tid]++;
if (!VLOG_DROP_DBG(&rl)) {
dump_flow(&s, &s_extra, attr, flow_patterns, flow_actions);
@@ -2225,10 +2229,11 @@ netdev_offload_dpdk_flow_destroy(struct ufid_to_rte_flow_data *rte_flow_data)
if (ret == 0) {
struct netdev_offload_dpdk_data *data;
unsigned int tid = netdev_offload_thread_id();
data = (struct netdev_offload_dpdk_data *)
ovsrcu_get(void *, &netdev->hw_info.offload_data);
data->rte_flow_counter--;
data->rte_flow_counters[tid]--;
ufid_to_rte_flow_disassociate(rte_flow_data);
VLOG_DBG_RL(&rl, "%s/%s: rte_flow 0x%"PRIxPTR
@@ -2588,6 +2593,7 @@ netdev_offload_dpdk_get_n_flows(struct netdev *netdev,
uint64_t *n_flows)
{
struct netdev_offload_dpdk_data *data;
unsigned int tid;
data = (struct netdev_offload_dpdk_data *)
ovsrcu_get(void *, &netdev->hw_info.offload_data);
@@ -2595,7 +2601,9 @@ netdev_offload_dpdk_get_n_flows(struct netdev *netdev,
return -1;
}
*n_flows = data->rte_flow_counter;
for (tid = 0; tid < netdev_offload_thread_nb(); tid++) {
n_flows[tid] = data->rte_flow_counters[tid];
}
return 0;
}