From patchwork Mon Aug 23 16:01:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salem Sol X-Patchwork-Id: 1519810 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 4GtcSc37l7z9sWq for ; Tue, 24 Aug 2021 02:02:08 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 12824403EE; Mon, 23 Aug 2021 16:02:03 +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 VZdwGszJam26; Mon, 23 Aug 2021 16:01:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 8AF04403CC; Mon, 23 Aug 2021 16:01:56 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 458EEC001D; Mon, 23 Aug 2021 16:01:56 +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 A3212C001A for ; Mon, 23 Aug 2021 16:01:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 86A5360768 for ; Mon, 23 Aug 2021 16:01:54 +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 M3LDN9RcjxZ5 for ; Mon, 23 Aug 2021 16:01:49 +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 4FA6960597 for ; Mon, 23 Aug 2021 16:01:48 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from salems@nvidia.com) with SMTP; 23 Aug 2021 19:01:43 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17NG1gmn028973; Mon, 23 Aug 2021 19:01:43 +0300 To: dev@openvswitch.org, Ilya Maximets , Ian Stokes Date: Mon, 23 Aug 2021 19:01:35 +0300 Message-Id: <20210823160140.12788-2-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 1/6] netdev-offload-dpdk: Introduce a get_netdev_by_port helper function 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 Introduce a helper function to get the struct netdev * handle for the target output odp_port, given in the netlink actions, as a pre-step towards using it embedded in a sampled action. Co-authored-by: Salem Sol Signed-off-by: Noa Levy Signed-off-by: Salem Sol --- lib/netdev-offload-dpdk.c | 54 +++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index b87a50b40..ed59d6fcd 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -1356,21 +1356,44 @@ add_count_action(struct flow_actions *actions) add_flow_action(actions, RTE_FLOW_ACTION_TYPE_COUNT, count); } -static int +static void add_port_id_action(struct flow_actions *actions, - struct netdev *outdev) + int outdev_id) { struct rte_flow_action_port_id *port_id; - int outdev_id; - outdev_id = netdev_dpdk_get_port_id(outdev); - if (outdev_id < 0) { - return -1; - } port_id = xzalloc(sizeof *port_id); port_id->id = outdev_id; add_flow_action(actions, RTE_FLOW_ACTION_TYPE_PORT_ID, port_id); - return 0; +} + +static int +get_netdev_by_port(struct netdev *netdev, + const struct nlattr *nla, + int *outdev_id, + struct netdev **outdev) +{ + odp_port_t port; + + port = nl_attr_get_odp_port(nla); + *outdev = netdev_ports_get(port, netdev->dpif_type); + if (!*outdev) { + VLOG_DBG_RL(&rl, "Cannot find netdev for odp port %"PRIu32, port); + return -1; + } + if (!netdev_flow_api_equals(netdev, *outdev)) { + goto err; + } + *outdev_id = netdev_dpdk_get_port_id(*outdev); + if (*outdev_id < 0) { + goto err; + } + return 0; +err: + VLOG_DBG_RL(&rl, "%s: Output to port \'%s\' cannot be offloaded.", + netdev_get_name(netdev), netdev_get_name(*outdev)); + netdev_close(*outdev); + return -1; } static int @@ -1379,21 +1402,14 @@ add_output_action(struct netdev *netdev, const struct nlattr *nla) { struct netdev *outdev; - odp_port_t port; + int outdev_id; int ret = 0; - port = nl_attr_get_odp_port(nla); - outdev = netdev_ports_get(port, netdev->dpif_type); - if (outdev == NULL) { - VLOG_DBG_RL(&rl, "Cannot find netdev for odp port %"PRIu32, port); + if (get_netdev_by_port(netdev, nla, &outdev_id, &outdev)) { return -1; } - if (!netdev_flow_api_equals(netdev, outdev) || - add_port_id_action(actions, outdev)) { - VLOG_DBG_RL(&rl, "%s: Output to port \'%s\' cannot be offloaded.", - netdev_get_name(netdev), netdev_get_name(outdev)); - ret = -1; - } + add_port_id_action(actions, outdev_id); + netdev_close(outdev); return ret; } From patchwork Mon Aug 23 16:01:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salem Sol X-Patchwork-Id: 1519811 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::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4GtcSg2cGcz9s1l for ; Tue, 24 Aug 2021 02:02:11 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id D3127402D1; Mon, 23 Aug 2021 16:02:07 +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 L3sG0Ds2zg6c; Mon, 23 Aug 2021 16:02:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id F1FEE402E5; Mon, 23 Aug 2021 16:01:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C76C5C0028; Mon, 23 Aug 2021 16:01:57 +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 26EB6C000E for ; Mon, 23 Aug 2021 16:01:56 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 08B3160597 for ; Mon, 23 Aug 2021 16:01:56 +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 Zq9OYykFf9q0 for ; Mon, 23 Aug 2021 16:01:49 +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 5410C60600 for ; Mon, 23 Aug 2021 16:01:48 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from salems@nvidia.com) with SMTP; 23 Aug 2021 19:01:43 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17NG1gmo028973; Mon, 23 Aug 2021 19:01:43 +0300 To: dev@openvswitch.org, Ilya Maximets , Ian Stokes Date: Mon, 23 Aug 2021 19:01:36 +0300 Message-Id: <20210823160140.12788-3-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 2/6] netdev-offload-dpdk: Introduce a dump_port_id helper function 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 Introduce a helper function as a pre-step towards supporting offload multiple desinations. Signed-off-by: Noa Levy --- lib/netdev-offload-dpdk.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index ed59d6fcd..9b32816d1 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -454,6 +454,20 @@ dump_vxlan_encap(struct ds *s, const struct rte_flow_item *items) } } +static void +dump_port_id(struct ds *s, const void *conf) +{ + const struct rte_flow_action_port_id *port_id = conf; + + ds_put_cstr(s, "port_id "); + if (port_id) { + ds_put_format(s, "original %d id %d ", port_id->original, + port_id->id); + } + ds_put_cstr(s, "/ "); +} + + static void dump_flow_action(struct ds *s, struct ds *s_extra, struct flow_actions *flow_actions, int act_index) @@ -481,14 +495,7 @@ dump_flow_action(struct ds *s, struct ds *s_extra, } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT) { ds_put_cstr(s, "count / "); } else if (actions->type == RTE_FLOW_ACTION_TYPE_PORT_ID) { - const struct rte_flow_action_port_id *port_id = actions->conf; - - ds_put_cstr(s, "port_id "); - if (port_id) { - ds_put_format(s, "original %d id %d ", - port_id->original, port_id->id); - } - ds_put_cstr(s, "/ "); + dump_port_id(s, actions->conf); } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { ds_put_cstr(s, "drop / "); } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_SRC || From patchwork Mon Aug 23 16:01:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salem Sol X-Patchwork-Id: 1519809 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::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4GtcSb4tDSz9s1l for ; Tue, 24 Aug 2021 02:02:07 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 60DC44032F; Mon, 23 Aug 2021 16:02:04 +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 RM9xOON4rQxC; Mon, 23 Aug 2021 16:02:00 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp2.osuosl.org (Postfix) with ESMTPS id C7DC7402C9; Mon, 23 Aug 2021 16:01:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1EF72C0021; Mon, 23 Aug 2021 16:01:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id AFAACC000E for ; Mon, 23 Aug 2021 16:01:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9EECD403C9 for ; Mon, 23 Aug 2021 16:01:54 +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 XScgSFqiPtcp for ; Mon, 23 Aug 2021 16:01:49 +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 smtp4.osuosl.org (Postfix) with ESMTP id 4724D403A1 for ; Mon, 23 Aug 2021 16:01:49 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from salems@nvidia.com) with SMTP; 23 Aug 2021 19:01:44 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17NG1gmp028973; Mon, 23 Aug 2021 19:01:44 +0300 To: dev@openvswitch.org, Ilya Maximets , Ian Stokes Date: Mon, 23 Aug 2021 19:01:37 +0300 Message-Id: <20210823160140.12788-4-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 3/6] netdev-offload-dpdk: Introduce a dump_raw_encap helper function 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 Introduce a helper function as a pre-step towards supporting offload multiple remote destinations. Co-authored-by: Salem Sol Signed-off-by: Noa Levy Signed-off-by: Salem Sol --- lib/netdev-offload-dpdk.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 9b32816d1..cd63d3ae1 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -454,6 +454,24 @@ dump_vxlan_encap(struct ds *s, const struct rte_flow_item *items) } } +static void +dump_raw_encap(struct ds *s, + struct ds *s_extra, + const struct rte_flow_action_raw_encap *raw_encap) +{ + int i; + + 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 (i = 0; i < raw_encap->size; i++) { + ds_put_format(s_extra, "%02x", raw_encap->data[i]); + } + ds_put_cstr(s_extra, " / end_set; "); + } +} + static void dump_port_id(struct ds *s, const void *conf) { @@ -593,15 +611,7 @@ dump_flow_action(struct ds *s, struct ds *s_extra, } 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;"); - } + dump_raw_encap(s, s_extra, raw_encap); } else if (actions->type == RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP) { const struct rte_flow_action_vxlan_encap *vxlan_encap = actions->conf; const struct rte_flow_item *items = vxlan_encap->definition; 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); From patchwork Mon Aug 23 16:01:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salem Sol X-Patchwork-Id: 1519813 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::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4GtcSn3zfwz9s1l for ; Tue, 24 Aug 2021 02:02:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id F282060793; Mon, 23 Aug 2021 16:02:14 +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 1-lzCKGGkhoQ; Mon, 23 Aug 2021 16:02:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id E7C0860797; Mon, 23 Aug 2021 16:02:09 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 75CBCC0020; Mon, 23 Aug 2021 16:02:08 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9FCB5C000E for ; Mon, 23 Aug 2021 16:02:06 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 9CF724041C for ; Mon, 23 Aug 2021 16:02:06 +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 FZOKipR8vMnv 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 smtp4.osuosl.org (Postfix) with ESMTP id 64878403EF 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:54 +0300 Received: from nvidia.com ([10.228.128.224]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 17NG1gmr028973; Mon, 23 Aug 2021 19:01:54 +0300 To: dev@openvswitch.org, Ilya Maximets , Ian Stokes Date: Mon, 23 Aug 2021 19:01:39 +0300 Message-Id: <20210823160140.12788-6-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 5/6] netdev-offload-dpdk: Extract raw_encap and output netdev by parse_clone_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: , 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 Extract the raw_encap and the output netdev of cloned actions as a pre-step towards using them embedded in a sample action. Co-authored-by: Salem Sol Signed-off-by: Noa Levy Signed-off-by: Salem Sol --- lib/netdev-offload-dpdk.c | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index efd7c844d..251515707 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -1707,9 +1707,12 @@ static int parse_clone_actions(struct netdev *netdev, struct flow_actions *actions, const struct nlattr *clone_actions, - const size_t clone_actions_len) + const size_t clone_actions_len, + int *outdev_id, + struct rte_flow_action_raw_encap *raw_encap) { const struct nlattr *ca; + struct netdev *outdev; unsigned int cleft; NL_ATTR_FOR_EACH_UNSAFE (ca, cleft, clone_actions, clone_actions_len) { @@ -1717,23 +1720,35 @@ parse_clone_actions(struct netdev *netdev, 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; - - if (tnl_push->tnl_type == OVS_VPORT_TYPE_VXLAN && - !add_vxlan_encap_action(actions, tnl_push->header)) { - continue; + struct rte_flow_action_raw_encap *action_raw_encap = NULL; + + if (!raw_encap) { + action_raw_encap = xzalloc(sizeof *action_raw_encap); + raw_encap = action_raw_encap; + if (tnl_push->tnl_type == OVS_VPORT_TYPE_VXLAN && + !add_vxlan_encap_action(actions, tnl_push->header)) { + continue; + } } - 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); + if (action_raw_encap) { + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_RAW_ENCAP, + action_raw_encap); + } } else if (clone_type == OVS_ACTION_ATTR_OUTPUT) { - if (add_output_action(netdev, actions, ca)) { - return -1; + if (actions) { + if (add_output_action(netdev, actions, ca)) { + return -1; + } + } else { + if (get_netdev_by_port(netdev, ca, outdev_id, &outdev)) { + return -1; + } + netdev_close(outdev); } } else { VLOG_DBG_RL(&rl, @@ -1889,7 +1904,7 @@ parse_flow_actions(struct netdev *netdev, size_t clone_actions_len = nl_attr_get_size(nla); if (parse_clone_actions(netdev, actions, clone_actions, - clone_actions_len)) { + clone_actions_len, NULL, NULL)) { return -1; } #ifdef ALLOW_EXPERIMENTAL_API /* Packet restoration API required. */ 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) {