[ovs-dev] [PATCH V2 18/19] netdev-offload-dpdk-flow: Support offload of clone tnl_push/output actions

Eli Britstein elibr at mellanox.com
Mon Dec 2 08:41:52 UTC 2019


Signed-off-by: Eli Britstein <elibr at mellanox.com>
Reviewed-by: Oz Shlomo <ozsh at mellanox.com>
---
 NEWS                           |  4 +--
 lib/netdev-offload-dpdk-flow.c | 61 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 19fe2b72b..2ccc19b90 100644
--- a/NEWS
+++ b/NEWS
@@ -26,8 +26,8 @@ Post-v2.12.0
        releases.
      * OVS validated with DPDK 18.11.5, due to the inclusion of a fix for
        CVE-2019-14818, this DPDK version is strongly recommended to be used.
-     * Add hardware offload support for output, drop and set actions of
-       MAC and IPv4 (experimental).
+     * Add hardware offload support for output, drop, set of MAC, IPv4
+       and tunnel push-output actions (experimental).
 
 v2.12.0 - 03 Sep 2019
 ---------------------
diff --git a/lib/netdev-offload-dpdk-flow.c b/lib/netdev-offload-dpdk-flow.c
index 7b1ea3e08..aa976d62e 100644
--- a/lib/netdev-offload-dpdk-flow.c
+++ b/lib/netdev-offload-dpdk-flow.c
@@ -337,6 +337,20 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions)
         } else {
             ds_put_cstr(s, "  Set-ttl = null\n");
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_RAW_ENCAP) {
+        const struct rte_flow_action_raw_encap *raw_encap = actions->conf;
+
+        ds_put_cstr(s, "rte flow raw-encap action:\n");
+        if (raw_encap) {
+            ds_put_format(s,
+                          "  Raw-encap: size=%ld\n",
+                          raw_encap->size);
+            ds_put_format(s,
+                          "  Raw-encap: encap=\n");
+            ds_put_hex_dump(s, raw_encap->data, raw_encap->size, 0, false);
+        } else {
+            ds_put_cstr(s, "  Raw-encap = null\n");
+        }
     } else {
         ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
     }
@@ -770,6 +784,44 @@ netdev_dpdk_flow_add_set_actions(struct flow_actions *actions,
     return 0;
 }
 
+static int
+netdev_dpdk_flow_add_clone_actions(struct flow_actions *actions,
+                                   const struct nlattr *clone_actions,
+                                   const size_t clone_actions_len,
+                                   struct offload_info *info)
+{
+    const struct nlattr *ca;
+    unsigned int cleft;
+
+    NL_ATTR_FOR_EACH_UNSAFE (ca, cleft, clone_actions, clone_actions_len) {
+        int clone_type = nl_attr_type(ca);
+
+        if (clone_type == OVS_ACTION_ATTR_TUNNEL_PUSH) {
+            const struct ovs_action_push_tnl *tnl_push = nl_attr_get(ca);
+            struct rte_flow_action_raw_encap *raw_encap =
+                xzalloc(sizeof *raw_encap);
+
+            raw_encap->data = (uint8_t *)tnl_push->header;
+            raw_encap->preserve = NULL;
+            raw_encap->size = tnl_push->header_len;
+
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_RAW_ENCAP,
+                            raw_encap);
+        } else if (clone_type == OVS_ACTION_ATTR_OUTPUT) {
+            if (!(cleft <= NLA_ALIGN(ca->nla_len)) ||
+                netdev_dpdk_flow_add_output_action(actions, ca, info)) {
+                return -1;
+            }
+        } else {
+            VLOG_DBG_RL(&error_rl,
+                        "Unsupported clone action. clone_type=%d", clone_type);
+            return -1;
+        }
+    }
+
+    return 0;
+}
+
 int
 netdev_dpdk_flow_actions_add(struct flow_actions *actions,
                              struct nlattr *nl_actions,
@@ -796,6 +848,15 @@ netdev_dpdk_flow_actions_add(struct flow_actions *actions,
                                                  set_actions_len, masked)) {
                 return -1;
             }
+        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_CLONE) {
+            const struct nlattr *clone_actions = nl_attr_get(nla);
+            size_t clone_actions_len = nl_attr_get_size(nla);
+
+            if (!(left <= NLA_ALIGN(nla->nla_len)) ||
+                netdev_dpdk_flow_add_clone_actions(actions, clone_actions,
+                                                   clone_actions_len, info)) {
+                return -1;
+            }
         } else {
             VLOG_DBG_RL(&error_rl,
                         "Unsupported action type %d", nl_attr_type(nla));
-- 
2.14.5



More information about the dev mailing list