From patchwork Mon Aug 23 16:01:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salem Sol X-Patchwork-Id: 1519814 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::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4GtcSs1NN4z9s1l for ; Tue, 24 Aug 2021 02:02:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 7881E80EEA; Mon, 23 Aug 2021 16:02:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id psH5R0T4T7jH; Mon, 23 Aug 2021 16:02:13 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 92CB780E97; Mon, 23 Aug 2021 16:02:11 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5D60BC0020; Mon, 23 Aug 2021 16:02:11 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 17335C0027 for ; Mon, 23 Aug 2021 16:02:09 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id CE0F5402E3 for ; Mon, 23 Aug 2021 16:02:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ee83O4i6v7gd for ; Mon, 23 Aug 2021 16:02:02 +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 smtp2.osuosl.org (Postfix) with ESMTP id 62EA0402DA 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:53 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17NG1gmq028973; Mon, 23 Aug 2021 19:01:53 +0300 To: dev@openvswitch.org, Ilya Maximets , Ian Stokes Date: Mon, 23 Aug 2021 19:01:38 +0300 Message-Id: <20210823160140.12788-5-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 4/6] netdev-offload-dpdk: Support multiple local 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 local destinations using rte_flow_action_sample with ratio 1. Co-authored-by: Salem Sol Signed-off-by: Noa Levy Signed-off-by: Salem Sol --- NEWS | 1 + lib/netdev-offload-dpdk.c | 77 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1f2adf718..793e1adc5 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ 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. v2.16.0 - 16 Aug 2021 diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index cd63d3ae1..efd7c844d 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -627,6 +627,29 @@ dump_flow_action(struct ds *s, struct ds *s_extra, ds_put_format(s, "group %"PRIu32" ", jump->group); } ds_put_cstr(s, "/ "); + } else if (actions->type == RTE_FLOW_ACTION_TYPE_SAMPLE) { + const struct rte_flow_action_sample *sample = actions->conf; + + if (sample) { + const struct rte_flow_action *rte_actions; + + rte_actions = sample->actions; + ds_put_format(s_extra, "set sample_actions %d ", act_index); + + while (rte_actions && + 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 { + ds_put_format(s, "unknown rte flow action (%d)\n", + rte_actions->type); + } + rte_actions++; + } + ds_put_cstr(s_extra, "end; "); + ds_put_format(s, "sample ratio %d index %d / ", sample->ratio, + act_index); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } @@ -1722,6 +1745,47 @@ parse_clone_actions(struct netdev *netdev, return 0; } +/* Maximum number of actions in multiple local destinations. + * PORT_ID / END + */ +#define SAMPLE_EMBEDDED_ACTIONS_NUM 2 + +static int +add_sample_embedded_output_action(struct netdev *netdev, + struct flow_actions *actions, + const struct nlattr *nla) +{ + struct netdev *outdev; + struct sample_conf { + struct rte_flow_action_sample sample; + struct rte_flow_action_port_id port_id; + 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; + 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; + /* Initialize sample struct */ + sample_conf->sample.ratio = 1; + sample_conf->sample.actions = sample_conf->sample_actions; + sample_conf->port_id.id = port_id; + + sample_itr->conf = &sample_conf->port_id; + sample_itr->type = RTE_FLOW_ACTION_TYPE_PORT_ID; + sample_itr++; + sample_itr->type = RTE_FLOW_ACTION_TYPE_END; + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_SAMPLE, sample_conf); + return 0; +} + static void add_jump_action(struct flow_actions *actions, uint32_t group) { @@ -1787,8 +1851,17 @@ parse_flow_actions(struct netdev *netdev, add_count_action(actions); NL_ATTR_FOR_EACH_UNSAFE (nla, left, nl_actions, nl_actions_len) { if (nl_attr_type(nla) == OVS_ACTION_ATTR_OUTPUT) { - if (add_output_action(netdev, actions, nla)) { - return -1; + /* The last output should use port-id action, while previous + * outputs should embed the port-id action inside a sample action. + */ + if (left <= NLA_ALIGN(nla->nla_len)) { + if (add_output_action(netdev, actions, nla)) { + return -1; + } + } else { + if (add_sample_embedded_output_action(netdev, actions, nla)) { + return -1; + } } } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_DROP) { add_flow_action(actions, RTE_FLOW_ACTION_TYPE_DROP, NULL);