From b9254f7b59bc3e7166c4d555cd40fb8e0b32bafc Mon Sep 17 00:00:00 2001 From: Eli Britstein Date: Thu, 9 Jan 2020 07:46:55 +0000 Subject: [PATCH] netdev-offload-dpdk: Support offload of set TCP/UDP ports actions. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo Signed-off-by: Ilya Maximets --- Documentation/howto/dpdk.rst | 1 + NEWS | 4 ++-- lib/netdev-offload-dpdk.c | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index c440bf28e..be950d7ce 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -394,6 +394,7 @@ Supported actions for hardware offload are: - Drop. - Modification of Ethernet (mod_dl_src/mod_dl_dst). - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl). +- Modification of TCP/UDP (mod_tp_src/mod_tp_dst). Further Reading --------------- diff --git a/NEWS b/NEWS index 00aa10cae..e8d662a0c 100644 --- a/NEWS +++ b/NEWS @@ -34,8 +34,8 @@ Post-v2.12.0 interval is increased to 60 seconds for the connection to the replication server. This value is configurable with the unixctl command - ovsdb-server/set-active-ovsdb-server-probe-interval. - * 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 + TCP/UDP ports actions (experimental). - 'ovs-appctl dpctl/dump-flows' can now show offloaded=partial for partially offloaded flows, dp:dpdk for fully offloaded by dpdk, and type filter supports new filters: "dpdk" and "partially-offloaded". diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 81d67442c..1ae8230fa 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -407,6 +407,19 @@ dump_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_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); } @@ -876,6 +889,14 @@ BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ipv4) == MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_dst)); BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_ttl) == MEMBER_SIZEOF(struct ovs_key_ipv4, ipv4_ttl)); +BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) == + MEMBER_SIZEOF(struct ovs_key_tcp, tcp_src)); +BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) == + MEMBER_SIZEOF(struct ovs_key_tcp, tcp_dst)); +BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) == + MEMBER_SIZEOF(struct ovs_key_udp, udp_src)); +BUILD_ASSERT_DECL(sizeof(struct rte_flow_action_set_tp) == + MEMBER_SIZEOF(struct ovs_key_udp, udp_dst)); static int parse_set_actions(struct flow_actions *actions, @@ -917,6 +938,28 @@ parse_set_actions(struct flow_actions *actions, VLOG_DBG_RL(&rl, "Unsupported IPv4 set action"); 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 ? key + 1 : NULL; + + add_set_flow_action(tcp_src, RTE_FLOW_ACTION_TYPE_SET_TP_SRC); + add_set_flow_action(tcp_dst, RTE_FLOW_ACTION_TYPE_SET_TP_DST); + + if (mask && !is_all_zeros(mask, sizeof *mask)) { + VLOG_DBG_RL(&rl, "Unsupported TCP set action"); + 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 ? key + 1 : NULL; + + add_set_flow_action(udp_src, RTE_FLOW_ACTION_TYPE_SET_TP_SRC); + add_set_flow_action(udp_dst, RTE_FLOW_ACTION_TYPE_SET_TP_DST); + + if (mask && !is_all_zeros(mask, sizeof *mask)) { + VLOG_DBG_RL(&rl, "Unsupported UDP set action"); + return -1; + } } else { VLOG_DBG_RL(&rl, "Unsupported set action type %d", nl_attr_type(sa));