From patchwork Wed Jul 8 06:38:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1325016 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 4B1qRs3Mwqz9sRK for ; Wed, 8 Jul 2020 16:40:09 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EFF1B88B72; Wed, 8 Jul 2020 06:39:39 +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 LeZe+89lCbrr; Wed, 8 Jul 2020 06:39:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id D581588B93; Wed, 8 Jul 2020 06:38:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BC763C1797; Wed, 8 Jul 2020 06:38:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id D5E99C077B for ; Wed, 8 Jul 2020 06:38:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C412988C3C for ; Wed, 8 Jul 2020 06:38:53 +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 PF7WnAV3a34C for ; Wed, 8 Jul 2020 06:38:49 +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 whitealder.osuosl.org (Postfix) with ESMTP id 2B35F88B38 for ; Wed, 8 Jul 2020 06:38:47 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with SMTP; 8 Jul 2020 09:38:42 +0300 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 0686ce8o022461; Wed, 8 Jul 2020 09:38:41 +0300 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets Date: Wed, 8 Jul 2020 06:38:30 +0000 Message-Id: <20200708063831.16413-12-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20200708063831.16413-1-elibr@mellanox.com> References: <20200708063831.16413-1-elibr@mellanox.com> Cc: Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V6 11/12] netdev-offload-dpdk: Support offload of clone tnl_push/output 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" Tunnel encapsulation is done by tnl_push and output actions nested in a clone action. Support offloading of such flows with RTE_FLOW_ACTION_TYPE_RAW_ENCAP attribute. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo Acked-by: Sriharsha Basavapatna --- Documentation/howto/dpdk.rst | 1 + NEWS | 2 +- lib/netdev-offload-dpdk.c | 89 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 77 insertions(+), 15 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index fb9bd2d10..f0d45e47b 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -397,6 +397,7 @@ Supported actions for hardware offload are: - Modification of TCP/UDP (mod_tp_src/mod_tp_dst). - VLAN Push/Pop (push_vlan/pop_vlan). - Modification of IPv6 (set_field:->ipv6_src/ipv6_dst/mod_nw_ttl). +- Clone/output (tnl_push and output) for encapsulating over a tunnel. Further Reading --------------- diff --git a/NEWS b/NEWS index def8d6f61..d6ec4c598 100644 --- a/NEWS +++ b/NEWS @@ -12,7 +12,7 @@ Post-v2.13.0 * Add hardware offload support for VLAN Push/Pop actions (experimental). * Add hardware offload support for matching IPv6 protocol (experimental). * Add hardware offload support for set of IPv6 TCP/UDP ports - actions (experimental). + and tunnel push-output actions (experimental). - Linux datapath: * Support for kernel versions up to 5.5.x. - AF_XDP: diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 834e97107..a8fc14b73 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -337,7 +337,8 @@ dump_flow_pattern(struct ds *s, const struct rte_flow_item *item) } static void -dump_flow_action(struct ds *s, const struct rte_flow_action *actions) +dump_flow_action(struct ds *s, struct ds *s_extra, + const struct rte_flow_action *actions) { if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { const struct rte_flow_action_mark *mark = actions->conf; @@ -451,13 +452,25 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions) ds_put_cstr(s, " "); } ds_put_cstr(s, "/ "); + } else if (actions->type == RTE_FLOW_ACTION_TYPE_RAW_ENCAP) { + const struct rte_flow_action_raw_encap *raw_encap = actions->conf; + + ds_put_cstr(s, "raw_encap index 0 / "); + if (raw_encap) { + ds_put_format(s_extra, "Raw-encap size=%ld set raw_encap 0 raw " + "pattern is ", raw_encap->size); + for (int i = 0; i < raw_encap->size; i++) { + ds_put_format(s_extra, "%02x", raw_encap->data[i]); + } + ds_put_cstr(s_extra, " / end_set;"); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } } static struct ds * -dump_flow(struct ds *s, +dump_flow(struct ds *s, struct ds *s_extra, const struct rte_flow_attr *attr, const struct rte_flow_item *items, const struct rte_flow_action *actions) @@ -471,7 +484,7 @@ dump_flow(struct ds *s, } ds_put_cstr(s, "end actions "); while (actions && actions->type != RTE_FLOW_ACTION_TYPE_END) { - dump_flow_action(s, actions++); + dump_flow_action(s, s_extra, actions++); } ds_put_cstr(s, "end"); return s; @@ -484,18 +497,19 @@ netdev_offload_dpdk_flow_create(struct netdev *netdev, const struct rte_flow_action *actions, struct rte_flow_error *error) { + struct ds s_extra = DS_EMPTY_INITIALIZER; + struct ds s = DS_EMPTY_INITIALIZER; struct rte_flow *flow; - struct ds s; + char *extra_str; flow = netdev_dpdk_rte_flow_create(netdev, attr, items, actions, error); if (flow) { if (!VLOG_DROP_DBG(&rl)) { - ds_init(&s); - dump_flow(&s, attr, items, actions); - VLOG_DBG_RL(&rl, "%s: rte_flow 0x%"PRIxPTR" flow create %d %s", - netdev_get_name(netdev), (intptr_t) flow, + dump_flow(&s, &s_extra, attr, items, actions); + extra_str = ds_cstr(&s_extra); + VLOG_DBG_RL(&rl, "%s: rte_flow 0x%"PRIxPTR" %s flow create %d %s", + netdev_get_name(netdev), (intptr_t) flow, extra_str, netdev_dpdk_get_port_id(netdev), ds_cstr(&s)); - ds_destroy(&s); } } else { enum vlog_level level = VLL_WARN; @@ -506,14 +520,15 @@ netdev_offload_dpdk_flow_create(struct netdev *netdev, VLOG_RL(&rl, level, "%s: rte_flow creation failed: %d (%s).", netdev_get_name(netdev), error->type, error->message); if (!vlog_should_drop(&this_module, level, &rl)) { - ds_init(&s); - dump_flow(&s, attr, items, actions); - VLOG_RL(&rl, level, "Failed flow: %s: flow create %d %s", - netdev_get_name(netdev), + dump_flow(&s, &s_extra, attr, items, actions); + extra_str = ds_cstr(&s_extra); + VLOG_RL(&rl, level, "%s: Failed flow: %s flow create %d %s", + netdev_get_name(netdev), extra_str, netdev_dpdk_get_port_id(netdev), ds_cstr(&s)); - ds_destroy(&s); } } + ds_destroy(&s); + ds_destroy(&s_extra); return flow; } @@ -1120,6 +1135,43 @@ parse_vlan_push_action(struct flow_actions *actions, return 0; } +static int +parse_clone_actions(struct netdev *netdev, + struct flow_actions *actions, + const struct nlattr *clone_actions, + const size_t clone_actions_len) +{ + const struct nlattr *ca; + unsigned int cleft; + + NL_ATTR_FOR_EACH_UNSAFE (ca, cleft, clone_actions, clone_actions_len) { + int clone_type = nl_attr_type(ca); + + if (clone_type == OVS_ACTION_ATTR_TUNNEL_PUSH) { + const struct ovs_action_push_tnl *tnl_push = nl_attr_get(ca); + struct rte_flow_action_raw_encap *raw_encap = + xzalloc(sizeof *raw_encap); + + raw_encap->data = (uint8_t *)tnl_push->header; + raw_encap->preserve = NULL; + raw_encap->size = tnl_push->header_len; + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_RAW_ENCAP, + raw_encap); + } else if (clone_type == OVS_ACTION_ATTR_OUTPUT) { + if (add_output_action(netdev, actions, ca)) { + return -1; + } + } else { + VLOG_DBG_RL(&rl, + "Unsupported nested action inside clone(), " + "action type: %d", clone_type); + return -1; + } + } + return 0; +} + static int parse_flow_actions(struct netdev *netdev, struct flow_actions *actions, @@ -1155,6 +1207,15 @@ parse_flow_actions(struct netdev *netdev, } } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) { add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL); + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_CLONE && + left <= NLA_ALIGN(nla->nla_len)) { + const struct nlattr *clone_actions = nl_attr_get(nla); + size_t clone_actions_len = nl_attr_get_size(nla); + + if (parse_clone_actions(netdev, actions, clone_actions, + clone_actions_len)) { + return -1; + } } else { VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla)); return -1;