[ovs-dev,ovs,V4,17/24] netdev-tc-offloads: Implement flow get using tc interface

Submitted by Roi Dayan on March 13, 2017, 1:37 p.m.

Details

Message ID 1489412234-30916-18-git-send-email-roid@mellanox.com
State Superseded
Headers show

Commit Message

Roi Dayan March 13, 2017, 1:37 p.m.
From: Paul Blakey <paulb@mellanox.com>

Search the requested ufid for a offloaded flow, and if found,
dump and parse it back to required format.

Signed-off-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
---
 lib/netdev-tc-offloads.c |   49 ++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 43 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 7b21b73..b822777 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -761,13 +761,50 @@  netdev_tc_flow_put(struct netdev *netdev,
 
 int
 netdev_tc_flow_get(struct netdev *netdev OVS_UNUSED,
-                   struct match *match OVS_UNUSED,
-                   struct nlattr **actions OVS_UNUSED,
-                   struct dpif_flow_stats *stats OVS_UNUSED,
-                   const ovs_u128 *ufid OVS_UNUSED,
-                   struct ofpbuf *buf OVS_UNUSED)
+                   struct match *match,
+                   struct nlattr **actions,
+                   struct dpif_flow_stats *stats,
+                   const ovs_u128 *ufid,
+                   struct ofpbuf *buf)
 {
-    return EOPNOTSUPP;
+    static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20);
+    struct netdev *dev;
+    struct tc_flower flower;
+    odp_port_t in_port;
+    int prio = 0;
+    int ifindex;
+    int handle;
+    int err;
+
+    handle = get_ufid_tc_mapping(ufid, &prio, &dev);
+    if (!handle) {
+        return ENOENT;
+    }
+
+    ifindex = netdev_get_ifindex(dev);
+    if (ifindex < 0) {
+        VLOG_ERR_RL(&rl_err, "failed to get ifindex for %s: %s",
+                    netdev_get_name(dev), ovs_strerror(-ifindex));
+        return -ifindex;
+    }
+
+    VLOG_DBG_RL(&rl, "flow get (dev %s prio %d handle %d)",
+                netdev_get_name(dev), prio, handle);
+    err = tc_get_flower(ifindex, prio, handle, &flower);
+    netdev_close(dev);
+    if (err) {
+        VLOG_ERR_RL(&rl_err, "flow get failed (dev %s prio %d handle %d): %s",
+                    netdev_get_name(dev), prio, handle, ovs_strerror(err));
+        return err;
+    }
+
+    in_port = netdev_hmap_port_get_byifidx(ifindex);
+    parse_tc_flower_to_match(&flower, match, actions, stats, buf);
+
+    match->wc.masks.in_port.odp_port = u32_to_odp(UINT32_MAX);
+    match->flow.in_port.odp_port = in_port;
+
+    return 0;
 }
 
 int