From patchwork Sun Dec 8 13:23:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205671 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Vl1QfKz9sP6 for ; Mon, 9 Dec 2019 00:24:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 966FD88134; Sun, 8 Dec 2019 13:24:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KWP2RVzjMMlw; Sun, 8 Dec 2019 13:24:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id C77528764B; Sun, 8 Dec 2019 13:23:41 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A2AE0C1D83; Sun, 8 Dec 2019 13:23:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97F8BC1D83 for ; Sun, 8 Dec 2019 13:23:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 86FF0203FE for ; Sun, 8 Dec 2019 13:23:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fr3xPvtKbxLt for ; Sun, 8 Dec 2019 13:23:35 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by silver.osuosl.org (Postfix) with ESMTP id 230DC20444 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +0200 Received: from dev-r-vrt-215.mtr.labs.mlnx. (dev-r-vrt-215.mtr.labs.mlnx [10.212.215.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xB8DNJhD002052; Sun, 8 Dec 2019 15:23:21 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:23:04 +0000 Message-Id: <20191208132304.15521-20-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 19/19] netdev-offload-dpdk: Support offload of set TCP/UDP ports actions X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- 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;