[ovs-dev] [PATCH ovs V5 17/24] netdev-tc-offloads: Implement flow get using tc interface
Roi Dayan
roid at mellanox.com
Wed Mar 22 11:10:50 UTC 2017
From: Paul Blakey <paulb at 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 at mellanox.com>
Reviewed-by: Roi Dayan <roid at mellanox.com>
---
lib/netdev-tc-offloads.c | 49 ++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 43 insertions(+), 6 deletions(-)
diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c
index 59af267..0164efd 100644
--- a/lib/netdev-tc-offloads.c
+++ b/lib/netdev-tc-offloads.c
@@ -797,13 +797,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
--
2.7.4
More information about the dev
mailing list