From patchwork Mon Aug 23 16:01:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salem Sol X-Patchwork-Id: 1519812 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=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GtcSk63BPz9s1l for ; Tue, 24 Aug 2021 02:02:14 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7E2EE4043F; Mon, 23 Aug 2021 16:02:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bs0FSlxMHH9U; Mon, 23 Aug 2021 16:02:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id AF8FB403FA; Mon, 23 Aug 2021 16:02:07 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 843A8C001D; Mon, 23 Aug 2021 16:02:07 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5ADBEC000E for ; Mon, 23 Aug 2021 16:02:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 352CD6058B for ; Mon, 23 Aug 2021 16:02:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iUMW2HCel21L for ; Mon, 23 Aug 2021 16:02:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp3.osuosl.org (Postfix) with ESMTP id 7593360783 for ; Mon, 23 Aug 2021 16:01:59 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from salems@nvidia.com) with SMTP; 23 Aug 2021 19:01:55 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17NG1gms028973; Mon, 23 Aug 2021 19:01:55 +0300 To: dev@openvswitch.org, Ilya Maximets , Ian Stokes Date: Mon, 23 Aug 2021 19:01:40 +0300 Message-Id: <20210823160140.12788-7-salems@nvidia.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20210823160140.12788-1-salems@nvidia.com> References: <20210823160140.12788-1-salems@nvidia.com> MIME-Version: 1.0 Cc: Eli Britstein , Noa Levy Subject: [ovs-dev] [PATCH v2 6/6] netdev-offload-dpdk: Support multiple remote destinations 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: , X-Patchwork-Original-From: Salem Sol via dev From: Salem Sol Reply-To: Salem Sol Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Noa Levy Add support for offloading multiple remote destinations by parsing the actions and adding remote destinations actions. Update dump_flow_action in order to support tunnel actions. Co-authored-by: Salem Sol Signed-off-by: Noa Levy Signed-off-by: Salem Sol --- NEWS | 3 +- lib/netdev-offload-dpdk.c | 69 ++++++++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 793e1adc5..6c45f0f2b 100644 --- a/NEWS +++ b/NEWS @@ -8,7 +8,8 @@ Post-v2.16.0 by default. 'other_config:dpdk-socket-limit' can be set equal to the 'other_config:dpdk-socket-mem' to preserve the legacy memory limiting behavior. - * Add support for offloading multiple local destinations actions. + * Add support for offloading multiple local and remote destinations + actions. v2.16.0 - 16 Aug 2021 diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 251515707..9bbf91bd7 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -640,6 +640,13 @@ dump_flow_action(struct ds *s, struct ds *s_extra, rte_actions->type != RTE_FLOW_ACTION_TYPE_END) { if (rte_actions->type == RTE_FLOW_ACTION_TYPE_PORT_ID) { dump_port_id(s_extra, rte_actions->conf); + } else if (rte_actions->type == + RTE_FLOW_ACTION_TYPE_RAW_ENCAP) { + const struct rte_flow_action_raw_encap *raw_encap = + rte_actions->conf; + + dump_raw_encap(s, s_extra, raw_encap); + ds_put_format(s_extra, "raw_encap index 0 / "); } else { ds_put_format(s, "unknown rte flow action (%d)\n", rte_actions->type); @@ -1761,37 +1768,53 @@ parse_clone_actions(struct netdev *netdev, } /* Maximum number of actions in multiple local destinations. - * PORT_ID / END + * RAW_ENCAP / PORT_ID / END */ -#define SAMPLE_EMBEDDED_ACTIONS_NUM 2 +#define SAMPLE_EMBEDDED_ACTIONS_NUM 3 static int add_sample_embedded_output_action(struct netdev *netdev, struct flow_actions *actions, - const struct nlattr *nla) + const struct nlattr *nla, + const size_t clone_actions_len) { struct netdev *outdev; struct sample_conf { struct rte_flow_action_sample sample; struct rte_flow_action_port_id port_id; + struct rte_flow_action_raw_encap raw_encap; struct rte_flow_action sample_actions[SAMPLE_EMBEDDED_ACTIONS_NUM]; } *sample_conf; BUILD_ASSERT_DECL(offsetof(struct sample_conf, sample) == 0); struct rte_flow_action *sample_itr; + bool is_raw; int port_id; - if (get_netdev_by_port(netdev, nla, &port_id, &outdev)) { - return -1; - } - netdev_close(outdev); - sample_conf = xzalloc(sizeof *sample_conf); sample_itr = sample_conf->sample_actions; + is_raw = false; + if (!clone_actions_len) { + if (get_netdev_by_port(netdev, nla, &port_id, &outdev)) { + goto err; + } + netdev_close(outdev); + } else { + if (parse_clone_actions(netdev, NULL, nla, + clone_actions_len, &port_id, + &sample_conf->raw_encap)) { + goto err; + } + is_raw = sample_conf->raw_encap.size > 0; + } /* Initialize sample struct */ sample_conf->sample.ratio = 1; sample_conf->sample.actions = sample_conf->sample_actions; sample_conf->port_id.id = port_id; - + if (is_raw) { + sample_itr->conf = &sample_conf->raw_encap; + sample_itr->type = RTE_FLOW_ACTION_TYPE_RAW_ENCAP; + sample_itr++; + } sample_itr->conf = &sample_conf->port_id; sample_itr->type = RTE_FLOW_ACTION_TYPE_PORT_ID; sample_itr++; @@ -1799,6 +1822,9 @@ add_sample_embedded_output_action(struct netdev *netdev, add_flow_action(actions, RTE_FLOW_ACTION_TYPE_SAMPLE, sample_conf); return 0; +err: + free(sample_conf); + return -1; } static void @@ -1874,7 +1900,8 @@ parse_flow_actions(struct netdev *netdev, return -1; } } else { - if (add_sample_embedded_output_action(netdev, actions, nla)) { + if (add_sample_embedded_output_action(netdev, actions, nla, + 0)) { return -1; } } @@ -1898,14 +1925,24 @@ 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)) { + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_CLONE) { 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, NULL, NULL)) { - return -1; + /* The last cloned action is parsed and actions are applied + * natively, while previous ones are parsed and the actions are + * applied embedded in a sample action. + */ + if (left <= NLA_ALIGN(nla->nla_len)) { + if (parse_clone_actions(netdev, actions, clone_actions, + clone_actions_len, NULL, NULL)) { + return -1; + } + } else { + if (add_sample_embedded_output_action(netdev, actions, + clone_actions, + clone_actions_len)) { + return -1; + } } #ifdef ALLOW_EXPERIMENTAL_API /* Packet restoration API required. */ } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_TUNNEL_POP) {