[ovs-dev,V5,08/18] netdev-offload-dpdk: Implement flow get method
diff mbox series

Message ID 20191218144110.18653-9-elibr@mellanox.com
State Changes Requested
Delegated to: Ilya Maximets
Headers show
Series
  • netdev datapath actions offload
Related show

Commit Message

Eli Britstein Dec. 18, 2019, 2:41 p.m. UTC
Implement the flow get method for DPDK, to get the statistics of the
provided ufid, towards reading statistics of fully offloaded flows.

Signed-off-by: Eli Britstein <elibr@mellanox.com>
Reviewed-by: Oz Shlomo <ozsh@mellanox.com>
---
 lib/netdev-offload-dpdk.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

Comments

0-day Robot Dec. 18, 2019, 3:20 p.m. UTC | #1
Bleep bloop.  Greetings Eli Britstein, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 80 characters long (recommended limit is 79)
#59 FILE: lib/netdev-offload-dpdk.c:990:
                        netdev_get_name(netdev), UUID_ARGS((struct uuid *)ufid),

Lines checked: 85, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot

Patch
diff mbox series

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 905cf7f50..861ceb9fa 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -57,6 +57,7 @@  struct ufid_to_rte_flow_data {
     ovs_u128 ufid;
     struct rte_flow *rte_flow;
     bool actions_offloaded;
+    struct dpif_flow_stats stats;
 };
 
 /* Find rte_flow with @ufid. */
@@ -958,9 +959,55 @@  netdev_offload_dpdk_init_flow_api(struct netdev *netdev)
     return netdev_dpdk_flow_api_supported(netdev) ? 0 : EOPNOTSUPP;
 }
 
+static int
+netdev_offload_dpdk_flow_get(struct netdev *netdev,
+                             struct match *match OVS_UNUSED,
+                             struct nlattr **actions OVS_UNUSED,
+                             const ovs_u128 *ufid,
+                             struct dpif_flow_stats *stats,
+                             struct dpif_flow_attrs *attrs,
+                             struct ofpbuf *buf OVS_UNUSED)
+{
+    struct rte_flow_query_count query = { .reset = 1 };
+    struct ufid_to_rte_flow_data *rte_flow_data;
+    struct rte_flow_error error;
+    int ret = 0;
+
+    rte_flow_data = ufid_to_rte_flow_data_find(ufid);
+    if (!rte_flow_data || !rte_flow_data->rte_flow) {
+        ret = -1;
+        goto out;
+    }
+
+    attrs->offloaded = true;
+    if (rte_flow_data->actions_offloaded) {
+        attrs->dp_layer = "dpdk";
+        ret = netdev_dpdk_rte_flow_query_count(netdev, rte_flow_data->rte_flow,
+                                               &query, &error);
+        if (ret) {
+            VLOG_DBG_RL(&rl,
+                        "%s: Failed to query ufid "UUID_FMT" flow: %p\n",
+                        netdev_get_name(netdev), UUID_ARGS((struct uuid *)ufid),
+                        rte_flow_data->rte_flow);
+            goto out;
+        }
+        rte_flow_data->stats.n_packets += (query.hits_set) ? query.hits : 0;
+        rte_flow_data->stats.n_bytes += (query.bytes_set) ? query.bytes : 0;
+        if (query.hits_set && query.hits) {
+            rte_flow_data->stats.used = time_msec();
+        }
+    } else {
+        attrs->dp_layer = "ovs";
+    }
+    memcpy(stats, &rte_flow_data->stats, sizeof *stats);
+out:
+    return ret;
+}
+
 const struct netdev_flow_api netdev_offload_dpdk = {
     .type = "dpdk_flow_api",
     .flow_put = netdev_offload_dpdk_flow_put,
     .flow_del = netdev_offload_dpdk_flow_del,
     .init_flow_api = netdev_offload_dpdk_init_flow_api,
+    .flow_get = netdev_offload_dpdk_flow_get,
 };