[ovs-dev] [PATCH V2 17/19] netdev-offload-dpdk-flow: Support offload of set IPv4 actions

Eli Britstein elibr at mellanox.com
Mon Dec 2 08:41:51 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 | 50 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index b372e703a..19fe2b72b 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 MAC actions
-       (experimental).
+     * Add hardware offload support for output, drop and set actions of
+       MAC and IPv4 (experimental).
 
 v2.12.0 - 03 Sep 2019
 ---------------------
diff --git a/lib/netdev-offload-dpdk-flow.c b/lib/netdev-offload-dpdk-flow.c
index b9ceb1aaf..7b1ea3e08 100644
--- a/lib/netdev-offload-dpdk-flow.c
+++ b/lib/netdev-offload-dpdk-flow.c
@@ -313,6 +313,30 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions)
         } else {
             ds_put_format(s, "  Set-mac-%s = null\n", dirstr);
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC ||
+               actions->type == RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) {
+        const struct rte_flow_action_set_ipv4 *set_ipv4 = actions->conf;
+        char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_IPV4_DST
+                       ? "dst" : "src";
+
+        ds_put_format(s, "rte flow set-ipv4-%s action:\n", dirstr);
+        if (set_ipv4) {
+            ds_put_format(s,
+                          "  Set-ipv4-%s: "IP_FMT"\n",
+                          dirstr, IP_ARGS(set_ipv4->ipv4_addr));
+        } else {
+            ds_put_format(s, "  Set-ipv4-%s = null\n", dirstr);
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_TTL) {
+        const struct rte_flow_action_set_ttl *set_ttl = actions->conf;
+
+        ds_put_cstr(s, "rte flow set-ttl action:\n");
+        if (set_ttl) {
+            ds_put_format(s,
+                          "  Set-ttl: %d\n", set_ttl->ttl_value);
+        } else {
+            ds_put_cstr(s, "  Set-ttl = null\n");
+        }
     } else {
         ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
     }
@@ -706,6 +730,32 @@ netdev_dpdk_flow_add_set_actions(struct flow_actions *actions,
                         RTE_FLOW_ACTION_TYPE_SET_MAC_DST),
             };
 
+            if (add_set_flow_action(actions, sa_info_arr,
+                                    ARRAY_SIZE(sa_info_arr))) {
+                return -1;
+            }
+        } else if (nl_attr_type(sa) == OVS_KEY_ATTR_IPV4) {
+            const struct ovs_key_ipv4 *key = nl_attr_get(sa);
+            const struct ovs_key_ipv4 *mask = masked ?
+                get_mask(sa, struct ovs_key_ipv4) : NULL;
+            struct rte_flow_action_set_ipv4 *src = xzalloc(sizeof *src);
+            struct rte_flow_action_set_ipv4 *dst = xzalloc(sizeof *dst);
+            struct rte_flow_action_set_ttl *ttl = xzalloc(sizeof *ttl);
+            struct set_action_info sa_info_arr[] = {
+                SA_INFO(ipv4_src, src->ipv4_addr,
+                        RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC),
+                SA_INFO(ipv4_dst, dst->ipv4_addr,
+                        RTE_FLOW_ACTION_TYPE_SET_IPV4_DST),
+                SA_INFO(ipv4_ttl, ttl->ttl_value,
+                        RTE_FLOW_ACTION_TYPE_SET_TTL),
+            };
+
+            if (mask && (mask->ipv4_proto || mask->ipv4_tos ||
+                mask->ipv4_frag)) {
+                VLOG_DBG_RL(&error_rl, "Unsupported IPv4 set action");
+                return -1;
+            }
+
             if (add_set_flow_action(actions, sa_info_arr,
                                     ARRAY_SIZE(sa_info_arr))) {
                 return -1;
-- 
2.14.5



More information about the dev mailing list