From patchwork Sun Dec 8 13:23:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205672 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 47W6Vs0k8Qz9sP6 for ; Mon, 9 Dec 2019 00:24:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 86AAC880A0; Sun, 8 Dec 2019 13:24:35 +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 EpzpFiTp587z; Sun, 8 Dec 2019 13:24:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id C8DE6876C2; Sun, 8 Dec 2019 13:23:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B19C6C1D83; Sun, 8 Dec 2019 13:23:42 +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 C2461C1D90 for ; Sun, 8 Dec 2019 13:23:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A29172045C for ; Sun, 8 Dec 2019 13:23:38 +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 XmyDym42x54k for ; Sun, 8 Dec 2019 13:23:33 +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 0E64620424 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 xB8DNJhB002052; 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:02 +0000 Message-Id: <20191208132304.15521-18-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 17/19] netdev-offload-dpdk: Support offload of set IPv4 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 | 24 ++++++++++++++++++++++++ lib/netdev-offload-dpdk.c | 26 ++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index d228493e9..b9be83002 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -393,6 +393,7 @@ Supported actions for hardware offload are: - Output (a single output, as the last action). - Drop. - Modification of Ethernet (mod_dl_src/mod_dl_dst). +- Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl). Further Reading --------------- diff --git a/NEWS b/NEWS index 3ade86d49..297ca6fff 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 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-dpdk.c b/lib/netdev-dpdk.c index e67a3dd76..c4606363d 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4738,6 +4738,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); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 07f5d4687..3fccac956 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -594,6 +594,32 @@ parse_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;