[ovs-dev] [PATCH V3 19/19] netdev-offload-dpdk: Support offload of set TCP/UDP ports actions

Eli Britstein elibr at mellanox.com
Sun Dec 8 13:23:04 UTC 2019


Signed-off-by: Eli Britstein <elibr at mellanox.com>
Reviewed-by: Oz Shlomo <ozsh at mellanox.com>
---
 Documentation/howto/dpdk.rst |  1 +
 NEWS                         |  4 ++--
 lib/netdev-dpdk.c            | 14 ++++++++++++++
 lib/netdev-offload-dpdk.c    | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
index b9aaf26bf..df863e4f1 100644
--- a/Documentation/howto/dpdk.rst
+++ b/Documentation/howto/dpdk.rst
@@ -396,6 +396,7 @@ Supported actions for hardware offload are:
 - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
 - Clone with tnl_push and output (a single clone, as the last action,
   with a single output, as the last nested clone action).
+- Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
 
 Further Reading
 ---------------
diff --git a/NEWS b/NEWS
index 25125801b..d01b8983b 100644
--- a/NEWS
+++ b/NEWS
@@ -26,8 +26,8 @@ Post-v2.12.0
      * DPDK ring ports (dpdkr) are deprecated and will be removed in next
        releases.
      * Add support for DPDK 19.11.
-     * Add hardware offload support for output, drop, set of MAC, IPv4
-       and tunnel push-output actions (experimental).
+     * Add hardware offload support for output, drop, set of MAC, IPv4,
+       TCP/UDP ports and tunnel push-output actions (experimental).
 
 v2.12.0 - 03 Sep 2019
 ---------------------
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 14f5d6f3b..377e8ae07 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -4776,6 +4776,20 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions)
         } else {
             ds_put_cstr(s, "  Raw-encap = null\n");
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_SRC ||
+               actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST) {
+        const struct rte_flow_action_set_tp *set_tp = actions->conf;
+        char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST
+                       ? "dst" : "src";
+
+        ds_put_format(s, "rte flow set-tcp/udp-port-%s action:\n", dirstr);
+        if (set_tp) {
+            ds_put_format(s,
+                          "  Set-%s-tcp/udp-port: %"PRIu16"\n",
+                          dirstr, ntohs(set_tp->port));
+        } else {
+            ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
+        }
     } else {
         ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
     }
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index b0403a085..6a5d00276 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -620,6 +620,40 @@ parse_set_actions(struct flow_actions *actions,
                 return -1;
             }
 
+            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_TCP) {
+            const struct ovs_key_tcp *key = nl_attr_get(sa);
+            const struct ovs_key_tcp *mask = masked ?
+                get_mask(sa, struct ovs_key_tcp) : NULL;
+            struct rte_flow_action_set_tp *src = xzalloc(sizeof *src);
+            struct rte_flow_action_set_tp *dst = xzalloc(sizeof *dst);
+            struct set_action_info sa_info_arr[] = {
+                SA_INFO(tcp_src, src->port,
+                        RTE_FLOW_ACTION_TYPE_SET_TP_SRC),
+                SA_INFO(tcp_dst, dst->port,
+                        RTE_FLOW_ACTION_TYPE_SET_TP_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_UDP) {
+            const struct ovs_key_udp *key = nl_attr_get(sa);
+            const struct ovs_key_udp *mask = masked ?
+                get_mask(sa, struct ovs_key_udp) : NULL;
+            struct rte_flow_action_set_tp *src = xzalloc(sizeof *src);
+            struct rte_flow_action_set_tp *dst = xzalloc(sizeof *dst);
+            struct set_action_info sa_info_arr[] = {
+                SA_INFO(udp_src, src->port,
+                        RTE_FLOW_ACTION_TYPE_SET_TP_SRC),
+                SA_INFO(udp_dst, dst->port,
+                        RTE_FLOW_ACTION_TYPE_SET_TP_DST),
+            };
+
             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