Skip to content

Commit

Permalink
netdev-offload-dpdk: Implement hw-offload statistics read.
Browse files Browse the repository at this point in the history
In the DPDK offload provider, keep track of inserted rte_flow and report
it when queried.

Signed-off-by: Gaetan Rivet <[email protected]>
Reviewed-by: Eli Britstein <[email protected]>
Reviewed-by: Maxime Coquelin <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
Gaetan Rivet authored and igsilya committed Jan 18, 2022
1 parent adbd430 commit 0e6366c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/netdev-offload-dpdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ struct ufid_to_rte_flow_data {

struct netdev_offload_dpdk_data {
struct cmap ufid_to_rte_flow;
uint64_t rte_flow_counter;
};

static int
Expand Down Expand Up @@ -831,6 +832,12 @@ 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;

data = (struct netdev_offload_dpdk_data *)
ovsrcu_get(void *, &netdev->hw_info.offload_data);
data->rte_flow_counter++;

if (!VLOG_DROP_DBG(&rl)) {
dump_flow(&s, &s_extra, attr, flow_patterns, flow_actions);
extra_str = ds_cstr(&s_extra);
Expand Down Expand Up @@ -2217,6 +2224,12 @@ netdev_offload_dpdk_flow_destroy(struct ufid_to_rte_flow_data *rte_flow_data)
ret = netdev_dpdk_rte_flow_destroy(physdev, rte_flow, &error);

if (ret == 0) {
struct netdev_offload_dpdk_data *data;

data = (struct netdev_offload_dpdk_data *)
ovsrcu_get(void *, &netdev->hw_info.offload_data);
data->rte_flow_counter--;

ufid_to_rte_flow_disassociate(rte_flow_data);
VLOG_DBG_RL(&rl, "%s/%s: rte_flow 0x%"PRIxPTR
" flow destroy %d ufid " UUID_FMT,
Expand Down Expand Up @@ -2570,6 +2583,23 @@ netdev_offload_dpdk_hw_miss_packet_recover(struct netdev *netdev,
return ret;
}

static int
netdev_offload_dpdk_get_n_flows(struct netdev *netdev,
uint64_t *n_flows)
{
struct netdev_offload_dpdk_data *data;

data = (struct netdev_offload_dpdk_data *)
ovsrcu_get(void *, &netdev->hw_info.offload_data);
if (!data) {
return -1;
}

*n_flows = data->rte_flow_counter;

return 0;
}

const struct netdev_flow_api netdev_offload_dpdk = {
.type = "dpdk_flow_api",
.flow_put = netdev_offload_dpdk_flow_put,
Expand All @@ -2579,4 +2609,5 @@ const struct netdev_flow_api netdev_offload_dpdk = {
.flow_get = netdev_offload_dpdk_flow_get,
.flow_flush = netdev_offload_dpdk_flow_flush,
.hw_miss_packet_recover = netdev_offload_dpdk_hw_miss_packet_recover,
.flow_get_n_flows = netdev_offload_dpdk_get_n_flows,
};

0 comments on commit 0e6366c

Please sign in to comment.