From patchwork Mon Jun 29 09:50:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 1318807 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=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=Ea55B/wD; dkim-atps=neutral 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 49wN5q35ZSz9sQx for ; Mon, 29 Jun 2020 19:50:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id EE54788822; Mon, 29 Jun 2020 09:50:37 +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 vJwk2y8ZTnWm; Mon, 29 Jun 2020 09:50:36 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id C175988831; Mon, 29 Jun 2020 09:50:36 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A72F2C07FF; Mon, 29 Jun 2020 09:50:36 +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 82444C016E for ; Mon, 29 Jun 2020 09:50:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7CDB925DA8 for ; Mon, 29 Jun 2020 09:50:35 +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 6AauJsdfXKvL for ; Mon, 29 Jun 2020 09:50:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by silver.osuosl.org (Postfix) with ESMTPS id 4782120477 for ; Mon, 29 Jun 2020 09:50:34 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id l63so8041009pge.12 for ; Mon, 29 Jun 2020 02:50:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GhGJps1+4f/oN2TO1fSyLo71zkJigauZ4HT+v9cdaco=; b=Ea55B/wDQqbuz39fp/oY3cTrSgf2/zHvgd1nMBqb1txUmtjcgujRtzLOrD9z3/rFQN Wqak46ss5PBb1xXC7JYhrcMl0sePBx9EWZZKXuk1qneSGDxyGghCjzzMVnj1qlGvtnMU 6QBDbyObqZodhhtxT+G/sBnAoMozBareEyUk0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GhGJps1+4f/oN2TO1fSyLo71zkJigauZ4HT+v9cdaco=; b=VG+LTy0TdO0uO5EP8aqI58qj9behkkHpu5WxqRsrVlLQBVzC7ubp/oqxxCg+YnYr8M 6W+u3qW9n0xGYX7Q5R5+EvBrqIVl3UkksVtBXlcKmcyNqWz0qK+oVQXvjtWKBzmrI74M LxdbQzmJlQ8necHsesgxzhOSmUlZZo0d2VkP7DZwPOb28d7h3B1yzEuYn2G2+oKhmZ3Y FQzmQJIGsiP5h8Xb1NvKu/xORFis6xAN62Tkq9dDi+5WwbQ5vC2035u7t+CvEbLCrxr1 BWTnzNuEBbYatnLqmmw9dnTFfopJqO+pggC4R1SXqd9ToewZw3imViRqPT6GQdjaoykr GYrA== X-Gm-Message-State: AOAM530qx4e/slitQW1ge/FfBhiSAPMe5haZDr8t23Nll4EY+GFb0rEa EIOI6kfuIY2WmoKN/13kjoSnegGam2UMxbWeKFTay++TsH+edEFHBDHON97jwoMO/9zXOLaTbOv 2O2ek2OFkuurF6wa2iowB902H00JVbmaHu1p77XOLs8YHtana5hwA+94HKxUgbXjRMU6CBiDCr6 Orm723 X-Google-Smtp-Source: ABdhPJwm1GkDckv2yfZYbDv1GQral9EfzwKjLRv2xha1BuMEv0llB432LkRPMTSmMemFZVx/OBcolA== X-Received: by 2002:a63:c150:: with SMTP id p16mr9730929pgi.141.1593424233180; Mon, 29 Jun 2020 02:50:33 -0700 (PDT) Received: from dhcp-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id mr8sm1227888pjb.5.2020.06.29.02.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 02:50:32 -0700 (PDT) To: dev@openvswitch.org Date: Mon, 29 Jun 2020 05:50:16 -0400 Message-Id: <20200629095020.8491-2-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.25.0.rc2 In-Reply-To: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> References: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 1/5] dpif-netdev: Refactor dp_netdev_flow_offload_put() 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: Sriharsha Basavapatna via dev From: Sriharsha Basavapatna Reply-To: Sriharsha Basavapatna Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch refactors dp_netdev_flow_offload_put() to prepare for changes to support partial action offload, in subsequent patches. - Move mark allocation code into a separate wrapper function, outside of dp_netdev_flow_offload_put() to improve readability and to facilitate more changes in this function to support partial action offload. - We need to get the in-port's netdev-type (e.g, vhost) to determine if the flow should be offloaded on the egress device instead. To facilitate such changes, netdev_ports_get() is moved ahead of mark allocation. Signed-off-by: Sriharsha Basavapatna --- lib/dpif-netdev.c | 72 +++++++++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 285c1c52f..7adea8c40 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2482,6 +2482,43 @@ dp_netdev_flow_offload_del(struct dp_flow_offload_item *offload) return mark_to_flow_disassociate(offload->pmd, offload->flow); } +static int +dp_netdev_alloc_flow_mark(struct dp_netdev_flow *flow, bool modification, + uint32_t *markp) +{ + uint32_t mark; + + if (modification) { + mark = flow->mark; + ovs_assert(mark != INVALID_FLOW_MARK); + *markp = mark; + return 0; + } + + /* + * If a mega flow has already been offloaded (from other PMD + * instances), do not offload it again. + */ + mark = megaflow_to_mark_find(&flow->mega_ufid); + if (mark != INVALID_FLOW_MARK) { + VLOG_DBG("Flow has already been offloaded with mark %u\n", mark); + if (flow->mark != INVALID_FLOW_MARK) { + ovs_assert(flow->mark == mark); + } else { + mark_to_flow_associate(mark, flow); + } + return 1; + } + + mark = flow_mark_alloc(); + if (mark == INVALID_FLOW_MARK) { + VLOG_ERR("Failed to allocate flow mark!\n"); + } + + *markp = mark; + return 0; +} + /* * There are two flow offload operations here: addition and modification. * @@ -2510,37 +2547,18 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) return -1; } - if (modification) { - mark = flow->mark; - ovs_assert(mark != INVALID_FLOW_MARK); - } else { - /* - * If a mega flow has already been offloaded (from other PMD - * instances), do not offload it again. - */ - mark = megaflow_to_mark_find(&flow->mega_ufid); - if (mark != INVALID_FLOW_MARK) { - VLOG_DBG("Flow has already been offloaded with mark %u\n", mark); - if (flow->mark != INVALID_FLOW_MARK) { - ovs_assert(flow->mark == mark); - } else { - mark_to_flow_associate(mark, flow); - } - return 0; - } + port = netdev_ports_get(in_port, dpif_type_str); + if (!port) { + return -1; + } - mark = flow_mark_alloc(); - if (mark == INVALID_FLOW_MARK) { - VLOG_ERR("Failed to allocate flow mark!\n"); - } + if (dp_netdev_alloc_flow_mark(flow, modification, &mark)) { + /* flow already offloaded */ + netdev_close(port); + return 0; } info.flow_mark = mark; - port = netdev_ports_get(in_port, dpif_type_str); - if (!port || netdev_vport_is_vport_class(port->netdev_class)) { - netdev_close(port); - goto err_free; - } /* Taking a global 'port_mutex' to fulfill thread safety restrictions for * the netdev-offload-dpdk module. */ ovs_mutex_lock(&pmd->dp->port_mutex); From patchwork Mon Jun 29 09:50:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 1318808 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=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=QLr6g6Fi; dkim-atps=neutral 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 49wN5t15TJz9sQx for ; Mon, 29 Jun 2020 19:50:42 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A32848888A; Mon, 29 Jun 2020 09:50:40 +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 mD5tbDCdqa6j; Mon, 29 Jun 2020 09:50:38 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id A8A468883F; Mon, 29 Jun 2020 09:50:38 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9B6D7C07FF; Mon, 29 Jun 2020 09:50:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 48693C0895 for ; Mon, 29 Jun 2020 09:50:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 335B98934C for ; Mon, 29 Jun 2020 09:50:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lU5ilJjHMACy for ; Mon, 29 Jun 2020 09:50:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by hemlock.osuosl.org (Postfix) with ESMTPS id A0B12891A7 for ; Mon, 29 Jun 2020 09:50:36 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id u5so7682527pfn.7 for ; Mon, 29 Jun 2020 02:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8OTSDkFlrqHDWvj+TPxrBhwvGndDA9Vp+V2Esmr3j/A=; b=QLr6g6Fi8HV9fICingOSXmsHZ75qHGQaOowhB9dGW4plGFGRnTBxDmXp4z1U2JHe7k +3Ueags0YxBGVP2vWMZ3MXHEfqy+SdM+4TySRXxssAQkEob0GChJ6gOawWDTX5OyS1hX +LfhbOwEbUrddmbCZhwKFFvp/w6un7JHymbtc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8OTSDkFlrqHDWvj+TPxrBhwvGndDA9Vp+V2Esmr3j/A=; b=Ez5SQbMYPESQHZa2DuKGDE/VWF+TKdfXPK17umb0i5xSzrxFAmI+7T74nyIj+vy8gM YGFrYBkMaofrKkqBpHdFXwDGk0dZv6ec4EhWr/NG+Z6SUbRys1ez/EbFnwA82eJThmZv o2rl77Fz0H7ZYDVEID6+k5WS5XfvqI+03KFBRzCQIlggDmhClGIqKOGsfkKBepwd2F4P 87086ADzrTo07ioO6GcPpv25/utaxh7fAH7YyIf7rQUKDpR+Z/c05+mLI9ceSlv+e6q2 NEBPPq3coLOMAvhpw0WvSsIGfbBOIwz9oyKEZ8BAZzbtXAOaWHhXC9f04xI+ETL88Rlq 7qrA== X-Gm-Message-State: AOAM533VdS1sn1IlAJo0cBZOr8qftsmbcyr7LKpwCsxXhRHIe+lv8NVY aCAS4MgjTq2u4lBwkJhKQDmfo0nk7NvHhn8DnqrAbEURzSqQPO9HoUHlbjYpf9ywLMrbZMkYEXt GC6bI6JZePOxAHEQEcBIg9Di1NCX1EL6aMXKzgG34hymSmoSEh6yj3YUtFMktxlQn82CfjLB6EN ZftTBJ X-Google-Smtp-Source: ABdhPJxO24MG5tzMjX6fdiXHVezRdCVYvbpBd3VtaYj5Eqj0g7zy7roxSohuPC6RaOQxI1UbANA+ng== X-Received: by 2002:a65:6645:: with SMTP id z5mr7447947pgv.123.1593424235517; Mon, 29 Jun 2020 02:50:35 -0700 (PDT) Received: from dhcp-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id mr8sm1227888pjb.5.2020.06.29.02.50.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 02:50:34 -0700 (PDT) To: dev@openvswitch.org Date: Mon, 29 Jun 2020 05:50:17 -0400 Message-Id: <20200629095020.8491-3-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.25.0.rc2 In-Reply-To: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> References: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 2/5] netdev-dpdk: provide a function to identify dpdk-vhost netdevs 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: Sriharsha Basavapatna via dev From: Sriharsha Basavapatna Reply-To: Sriharsha Basavapatna Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" This patch adds a function to determine if a given netdev belongs to the dpdk-vhost class, using the netdev_class specific data. Signed-off-by: Sriharsha Basavapatna --- lib/netdev-dpdk.c | 5 +++++ lib/netdev-dpdk.h | 1 + 2 files changed, 6 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 44ebf96da..a2a9bb8e7 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -558,6 +558,11 @@ is_dpdk_class(const struct netdev_class *class) || class->destruct == netdev_dpdk_vhost_destruct; } +bool is_dpdk_vhost_netdev(struct netdev *netdev) +{ + return netdev->netdev_class->destruct == netdev_dpdk_vhost_destruct; +} + /* DPDK NIC drivers allocate RX buffers at a particular granularity, typically * aligned at 1k or less. If a declared mbuf size is not a multiple of this * value, insufficient buffers are allocated to accomodate the packet in its diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h index 848346cb4..ab3c3102e 100644 --- a/lib/netdev-dpdk.h +++ b/lib/netdev-dpdk.h @@ -37,6 +37,7 @@ void netdev_dpdk_register(void); void free_dpdk_buf(struct dp_packet *); bool netdev_dpdk_flow_api_supported(struct netdev *); +bool is_dpdk_vhost_netdev(struct netdev *); int netdev_dpdk_rte_flow_destroy(struct netdev *netdev, From patchwork Mon Jun 29 09:50:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 1318817 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=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=ToWYEbh7; dkim-atps=neutral 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 49wNGJ4QzHz9sRk for ; Mon, 29 Jun 2020 19:58:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 20CD888886; Mon, 29 Jun 2020 09:57:59 +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 s2ggnxdFxYvi; Mon, 29 Jun 2020 09:57:57 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 74FC188863; Mon, 29 Jun 2020 09:57:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 33CB3C07FF; Mon, 29 Jun 2020 09:57:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id B30A1C016E for ; Mon, 29 Jun 2020 09:57:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A27F589367 for ; Mon, 29 Jun 2020 09:57:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JNniuBJCtbcW for ; Mon, 29 Jun 2020 09:57:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) by hemlock.osuosl.org (Postfix) with ESMTPS id 7C1698936E for ; Mon, 29 Jun 2020 09:57:54 +0000 (UTC) Received: by mail-qv1-f66.google.com with SMTP id el4so3255717qvb.13 for ; Mon, 29 Jun 2020 02:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZcbmkrzRshF3+0jCwMKjHjZGauSSj+nquXQ298225R8=; b=ToWYEbh7EAUmKnKAUsQrnYxc2JfJAh29oxPqpBZ4dZT8KfgrqGZoyRL/5N9xBIei7p DL8clZwJDYRYGggqCKWPE0IuRdsy86YnWxK036pahY+EtKqHWkELH1s8M+U+D0a3wi5h I6cFnknk5MariaJ6pbVjGQ16lka5gQzsmUO7o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZcbmkrzRshF3+0jCwMKjHjZGauSSj+nquXQ298225R8=; b=Wzc/Ul4E0S7+KGyEtPEJ7ZwYkL+smRROrSk2W8PSGhXk/FSFn64O6GcYTIOBjM+U89 99JYJtWVY/1t+KJAp2yv/sovj2iRur/bWp1z6gTuEerGPjoOf8xiU0h4cGuqAg4tTHf2 YouORa/3nqpMgEkhM/BmKTxP45e5OX1fe3CgJTPiM/wgVlLue71mO/ygeJ4kKx8yUSBx IG/frNU52kUpvdZ+NUKxcYB2qsHE//QuFb6S+xuwaFmCBa/8RZ2IFwrwZ1CZZAL26Zn2 /UmZKKg+hvm4JpbDAfrs97CcDXfNTiX4pvdJo5Bgz53+f3lDP6PjuYsNzuMUZ96muJuP m/KA== X-Gm-Message-State: AOAM533UFOU0UH48JbaIHTWcDKav+0X6cTG1DGIzCUAF5xshoJeqoM2m o77r/QqVLRcjMa91H/uarIBWjfPTJrOBBJgr+p7Asp5FSAIF2ksxMrBlSfwiyLg4F5OZ3GdUzWw EoSy3nq9psbdKij2OugkOV7NV9JvlDzcECyPk8Dt2kZVHXFjMIxWV6tkgP5YiWaWubljbpaSKV8 WL1MeJKvI= X-Google-Smtp-Source: ABdhPJzNC7FGnRM/wge3h6nnrUkaGsoWy5UcXqQV+A5X0c7zCXWxJ87PURXEV8cBd5vVfn+aP5J5Lw== X-Received: by 2002:a17:902:ed02:: with SMTP id b2mr1728382pld.121.1593424237931; Mon, 29 Jun 2020 02:50:37 -0700 (PDT) Received: from dhcp-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id mr8sm1227888pjb.5.2020.06.29.02.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 02:50:36 -0700 (PDT) To: dev@openvswitch.org Date: Mon, 29 Jun 2020 05:50:18 -0400 Message-Id: <20200629095020.8491-4-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.25.0.rc2 In-Reply-To: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> References: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 3/5] dpif-netdev: Skip encap action during datapath execution 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: Sriharsha Basavapatna via dev From: Sriharsha Basavapatna Reply-To: Sriharsha Basavapatna Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In this patch we check if action processing (apart from OUTPUT action), should be skipped for a given dp_netdev_flow. Specifically, we check if the action is TNL_PUSH and if it has been offloaded to HW, then we do not push the tunnel header in SW. The datapath only executes the OUTPUT action. The packet will be encapsulated in HW during transmit. Signed-off-by: Sriharsha Basavapatna --- lib/dpif-netdev.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 7adea8c40..b96a75d1f 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -114,6 +114,7 @@ COVERAGE_DEFINE(datapath_drop_invalid_port); COVERAGE_DEFINE(datapath_drop_invalid_bond); COVERAGE_DEFINE(datapath_drop_invalid_tnl_port); COVERAGE_DEFINE(datapath_drop_rx_invalid_packet); +COVERAGE_DEFINE(datapath_skip_tunnel_push); /* Protects against changes to 'dp_netdevs'. */ static struct ovs_mutex dp_netdev_mutex = OVS_MUTEX_INITIALIZER; @@ -545,6 +546,16 @@ struct dp_netdev_flow { bool dead; uint32_t mark; /* Unique flow mark assigned to a flow */ + /* The next two members are used to support partial offloading of + * actions. The boolean flag tells if this flow has its actions partially + * offloaded. The egress port# tells if the action should be offloaded + * on the egress (output) port instead of the in-port for the flow. Note + * that we support flows with a single egress port action. + * (see MAX_ACTION_ATTRS for related comments). + */ + bool partial_actions_offloaded; + odp_port_t egress_offload_port; + /* Statistics. */ struct dp_netdev_flow_stats stats; @@ -817,7 +828,8 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd, bool should_steal, const struct flow *flow, const struct nlattr *actions, - size_t actions_len); + size_t actions_len, + const struct dp_netdev_flow *dp_flow); static void dp_netdev_input(struct dp_netdev_pmd_thread *, struct dp_packet_batch *, odp_port_t port_no); static void dp_netdev_recirculate(struct dp_netdev_pmd_thread *, @@ -3954,7 +3966,7 @@ dpif_netdev_execute(struct dpif *dpif, struct dpif_execute *execute) dp_packet_batch_init_packet(&pp, execute->packet); pp.do_not_steal = true; dp_netdev_execute_actions(pmd, &pp, false, execute->flow, - execute->actions, execute->actions_len); + execute->actions, execute->actions_len, NULL); dp_netdev_pmd_flush_output_packets(pmd, true); if (pmd->core_id == NON_PMD_CORE_ID) { @@ -6672,7 +6684,7 @@ packet_batch_per_flow_execute(struct packet_batch_per_flow *batch, actions = dp_netdev_flow_get_actions(flow); dp_netdev_execute_actions(pmd, &batch->array, true, &flow->flow, - actions->actions, actions->size); + actions->actions, actions->size, flow); } static inline void @@ -6967,7 +6979,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, * we'll send the packet up twice. */ dp_packet_batch_init_packet(&b, packet); dp_netdev_execute_actions(pmd, &b, true, &match.flow, - actions->data, actions->size); + actions->data, actions->size, NULL); add_actions = put_actions->size ? put_actions : actions; if (OVS_LIKELY(error != ENOSPC)) { @@ -7202,6 +7214,7 @@ dp_netdev_recirculate(struct dp_netdev_pmd_thread *pmd, struct dp_netdev_execute_aux { struct dp_netdev_pmd_thread *pmd; const struct flow *flow; + const struct dp_netdev_flow *dp_flow; /* for partial action offload */ }; static void @@ -7346,7 +7359,7 @@ dp_execute_userspace_action(struct dp_netdev_pmd_thread *pmd, if (!error || error == ENOSPC) { dp_packet_batch_init_packet(&b, packet); dp_netdev_execute_actions(pmd, &b, should_steal, flow, - actions->data, actions->size); + actions->data, actions->size, NULL); } else if (should_steal) { dp_packet_delete(packet); COVERAGE_INC(datapath_drop_userspace_action_error); @@ -7455,6 +7468,7 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, int type = nl_attr_type(a); struct tx_port *p; uint32_t packet_count, packets_dropped; + struct dp_netdev_flow *dp_flow = aux->dp_flow; switch ((enum ovs_action_attr)type) { case OVS_ACTION_ATTR_OUTPUT: @@ -7477,9 +7491,20 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_, } dp_packet_batch_apply_cutlen(packets_); packet_count = dp_packet_batch_size(packets_); - if (push_tnl_action(pmd, a, packets_)) { - COVERAGE_ADD(datapath_drop_tunnel_push_error, - packet_count); + /* Execute tnl_push action in SW, if it is not offloaded as a partial + * action in HW. Otherwise, HW pushes the tunnel header during output + * processing. There's a small window here in which the offload thread + * offloads the flow, but the partial_actions_offloaded flag is still + * not set. In this case, as the packet is already encapsulated, it + * wouldn't match the offloaded flow and the action won't be executed + * in HW. + */ + if (!dp_flow || !dp_flow->partial_actions_offloaded) { + if (push_tnl_action(pmd, a, packets_)) { + COVERAGE_ADD(datapath_drop_tunnel_push_error, packet_count); + } + } else { + COVERAGE_ADD(datapath_skip_tunnel_push, packet_count); } return; @@ -7771,9 +7796,10 @@ static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd, struct dp_packet_batch *packets, bool should_steal, const struct flow *flow, - const struct nlattr *actions, size_t actions_len) + const struct nlattr *actions, size_t actions_len, + const struct dp_netdev_flow *dp_flow) { - struct dp_netdev_execute_aux aux = { pmd, flow }; + struct dp_netdev_execute_aux aux = { pmd, flow, dp_flow }; odp_execute_actions(&aux, packets, should_steal, actions, actions_len, dp_execute_cb); From patchwork Mon Jun 29 09:50:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 1318818 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=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=EiKEz+lj; dkim-atps=neutral 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 49wNGg6prRz9sQx for ; Mon, 29 Jun 2020 19:58:19 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 740CC888AB; Mon, 29 Jun 2020 09:58:18 +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 lOdl7eUMzMdW; Mon, 29 Jun 2020 09:58:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 63B6C88882; Mon, 29 Jun 2020 09:58:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 49727C0895; Mon, 29 Jun 2020 09:58:17 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id CE9FBC016E for ; Mon, 29 Jun 2020 09:58:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CB7AE87692 for ; Mon, 29 Jun 2020 09:58:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WiAjeCphbqYU for ; Mon, 29 Jun 2020 09:58:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 648AA8767F for ; Mon, 29 Jun 2020 09:58:15 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id e18so8066111pgn.7 for ; Mon, 29 Jun 2020 02:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3X62S+YrxExYIUuxfeICF2bKT731iLZD4cjA7Q/ljHQ=; b=EiKEz+ljXofXa502M+W4Xg9kZ4YM5hSH4EB9AFIsJC09aCF8bZ81auKTNT6G2A7p4a +QOKro5YCoPYrsoMprgazcBPeIA2LjzW8dmk/9C4qfgtqcn/UIfqkHbUSo/y5hYmRXLG cDQCo+qgUZYInD975U1hSxW30/YIZkk0g4Dag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3X62S+YrxExYIUuxfeICF2bKT731iLZD4cjA7Q/ljHQ=; b=AaaTQc1zzz6wmPAt7+quh+bl5LLEYlOLWwaV7C86D8G0entGspWeYIKvkhzU5hyA/Q Le2DEYQOe9hMzCOmSMm4q6CsvuNCddMMNzpgO0HxacWt7MtkzILWd1SUuUPGOrIc8Htx 3WzUhc+ZHTH53f9sVGFs1nGeG/O4b4GqEIp3SiU/8B1D4PehdTKk60j/ZRjyaYmQxHWX EPKeI1nYyqxaOgfQIYXmOlyyMsBK4GtvGkySXB8uoTLsv95rOBQKAd+wcCjwWGK3YDSI bA4C8fHGq6X2WPKYL2BK47BTEuqL+MfXiLiINBx6DDO64LhsEelN68EXsPV5jvS2+/YG mQtA== X-Gm-Message-State: AOAM5329WWQD9QVux3bwYMV/EaFuNAOWLWuUr8O4DRGpjPxDnjUUgke6 g3CbQS0XfUSXkBZKCKEQvucOlXshPSH/7OaVshgYtnOEHHOYle1ni8wj53rDVMQsPu/nKUbUaxq Kl89i0RCgR0Uv1djunwGMzcbtzAOtCejoABkXSFN2d8G+k4+qSmDPEx42YssjOgt6H3cXaOwSFY K1S2CL X-Google-Smtp-Source: ABdhPJwU6DNlfRyZSfnPbC2h+QN6M/9Px4GTUCtGyBbB6W/tqHpByLPfTCnwnl29Q+rZBTceYLQkMw== X-Received: by 2002:a17:902:6b8c:: with SMTP id p12mr13001900plk.256.1593424240077; Mon, 29 Jun 2020 02:50:40 -0700 (PDT) Received: from dhcp-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id mr8sm1227888pjb.5.2020.06.29.02.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 02:50:39 -0700 (PDT) To: dev@openvswitch.org Date: Mon, 29 Jun 2020 05:50:19 -0400 Message-Id: <20200629095020.8491-5-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.25.0.rc2 In-Reply-To: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> References: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 4/5] dpif-netdev: Support flow_get() with partial-action-offload 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: Sriharsha Basavapatna via dev From: Sriharsha Basavapatna Reply-To: Sriharsha Basavapatna Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" For flows that offload partial actions in egress direction, provide the right netdev to fetch statistics. Signed-off-by: Sriharsha Basavapatna --- lib/dpif-netdev.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index b96a75d1f..e489e2d90 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -3180,8 +3180,14 @@ dpif_netdev_get_flow_offload_status(const struct dp_netdev *dp, return false; } - netdev = netdev_ports_get(netdev_flow->flow.in_port.odp_port, - dpif_normalize_type(dp->class->type)); + if (netdev_flow->partial_actions_offloaded && + netdev_flow->egress_offload_port != ODPP_NONE) { + netdev = netdev_ports_get(netdev_flow->egress_offload_port, + dpif_normalize_type(dp->class->type)); + } else { + netdev = netdev_ports_get(netdev_flow->flow.in_port.odp_port, + dpif_normalize_type(dp->class->type)); + } if (!netdev) { return false; } From patchwork Mon Jun 29 09:50:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriharsha Basavapatna X-Patchwork-Id: 1318809 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.133; helo=hemlock.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=openvswitch.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=IMXMmm56; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49wN6B4c7mz9sQx for ; Mon, 29 Jun 2020 19:50:58 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 32E3A89347; Mon, 29 Jun 2020 09:50:57 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KZhpd73kkZ0o; Mon, 29 Jun 2020 09:50:55 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id DCC3C88D8F; Mon, 29 Jun 2020 09:50:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BFE98C0895; Mon, 29 Jun 2020 09:50:55 +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 C563DC016E for ; Mon, 29 Jun 2020 09:50:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B242825E15 for ; Mon, 29 Jun 2020 09:50:54 +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 MUCh5d7VA6KD for ; Mon, 29 Jun 2020 09:50:44 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by silver.osuosl.org (Postfix) with ESMTPS id E898725E18 for ; Mon, 29 Jun 2020 09:50:43 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id p3so8065427pgh.3 for ; Mon, 29 Jun 2020 02:50:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n8sJJywnB4DyiqJXvv44QDQk7EX3FBBdmnowsrx5tCs=; b=IMXMmm56owALrhl4xZLi0Me7YOoePL95k6WXUtSettYTbjyrj7obwTpNrsKz0Vc9tQ kYJexBZ49+x395WGyE41giEC+c9zK/sj8hen1u6Ir462iuXrOIDu3zA3IbVYAutqltgg sNkCWnyGSS4p7D4QsSHU20mV0WaElJHk9w354= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n8sJJywnB4DyiqJXvv44QDQk7EX3FBBdmnowsrx5tCs=; b=OIyXrMH2ZeKbJqHIcO8mqMEEoMSvOAEAVqnsDWGU+DODWbDADoMwLpEBBDUz3fvJCd qqpCm4Csi6jxsPo4k5GKqdq9bV1JW9QpVbQ9LQujDgq0DyeGFZkWsg5qcRegxwGfisc8 sRJ4Cb6mqe6xvboX6eHCZK3OyZkcXkbkFf2+KxIbc7mEIvrEBu7qAnUQthSzK0SQo8oY B7CMaUv53/ZfFL9VJ7RdApmrbzg1OMMuPKZlFegniGoXABn60w3anJCtMcLvtYUmfFjC dISaKtC/mmmE+Vyyoi96Rw84kX6R0wSVQu7dGKcno9EO3RnyR2UyfOU4CW8N3IM/tdPe jrHw== X-Gm-Message-State: AOAM533A/KLqByefPxB+O510iflqMjCplgJikwt8ZcRCwRtWvCLy0AtJ LjLQVDnldvkQCnYAO34M3EntRXbEvmW87ElVxS06185TEV6dGpxT75I50l1VVGdeKs78sq+Z3DN srXEamXy7dJ+AeN7yO+/oCzSvoXdt6Np+Z9sgNCFBAo8QP5HHsZ4IjCgqin0++5vaL4/L0HGKZP TAcUhy X-Google-Smtp-Source: ABdhPJytsAREOghHyV1tB0sgSaQOoWaQ/IzAPj2mqE09Cbi+1CztOi+hvCQEXkNHZfcifZaoezaTNA== X-Received: by 2002:a62:f24b:: with SMTP id y11mr13366470pfl.85.1593424242443; Mon, 29 Jun 2020 02:50:42 -0700 (PDT) Received: from dhcp-10-123-153-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id mr8sm1227888pjb.5.2020.06.29.02.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2020 02:50:41 -0700 (PDT) To: dev@openvswitch.org Date: Mon, 29 Jun 2020 05:50:20 -0400 Message-Id: <20200629095020.8491-6-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.25.0.rc2 In-Reply-To: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> References: <20200629095020.8491-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Subject: [ovs-dev] [PATCH v4 5/5] dpif-netdev: Support partial-action-offload of VXLAN encap flow 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: Sriharsha Basavapatna via dev From: Sriharsha Basavapatna Reply-To: Sriharsha Basavapatna Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" In this patch, we support offloading of VXLAN_ENCAP action for a vhost-user port (aka "partial-action-offload"). At the time of offloading the flow, we determine if the flow can be offloaded to an egress device, if the input port is not offload capable such as a vhost-user port. We then offload the flow with a VXLAN_ENCAP RTE action, to the egress device. We do not add the OUTPUT RTE action, which indicates to the PMD that is is a partial action offload request. Note that since the action is being offloaded in egress direction, classification is expected to be done by OVS SW datapath and hence there's no need to offload a MARK action. If offload succeeds, we save the information in 'dp_netdev_flow' so that we skip execution of the corresponding action (previous patch) during SW datapath processing. Signed-off-by: Sriharsha Basavapatna --- lib/dpif-netdev.c | 212 ++++++++++++++++++++++++++++++++++++-- lib/netdev-offload-dpdk.c | 78 ++++++++++---- lib/netdev-offload.h | 2 + 3 files changed, 262 insertions(+), 30 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index e489e2d90..d289d265d 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2488,10 +2488,174 @@ dp_netdev_append_flow_offload(struct dp_flow_offload_item *offload) ovs_mutex_unlock(&dp_flow_offload.mutex); } +static int +partial_offload_egress_flow_del(struct dp_flow_offload_item *offload) +{ + struct dp_netdev_pmd_thread *pmd = offload->pmd; + struct dp_netdev_flow *flow = offload->flow; + const char *dpif_type_str = dpif_normalize_type(pmd->dp->class->type); + struct netdev *port; + int ret; + + port = netdev_ports_get(flow->egress_offload_port, dpif_type_str); + if (!port) { + return -1; + } + + /* Taking a global 'port_mutex' to fulfill thread safety + * restrictions for the netdev-offload-dpdk module. */ + ovs_mutex_lock(&pmd->dp->port_mutex); + ret = netdev_flow_del(port, &flow->mega_ufid, NULL); + ovs_mutex_unlock(&pmd->dp->port_mutex); + netdev_close(port); + + if (ret) { + return ret; + } + + flow->egress_offload_port = NULL; + flow->partial_actions_offloaded = false; + + VLOG_DBG_RL("%s: flow: %p mega_ufid: "UUID_FMT" pmd_id: %d\n", __func__, + flow, UUID_ARGS((struct uuid *)&flow->mega_ufid), + offload->flow->pmd_id); + return ret; +} + static int dp_netdev_flow_offload_del(struct dp_flow_offload_item *offload) { - return mark_to_flow_disassociate(offload->pmd, offload->flow); + if (unlikely(offload->flow->partial_actions_offloaded && + offload->flow->egress_offload_port != ODPP_NONE)) { + return partial_offload_egress_flow_del(offload); + } else { + return mark_to_flow_disassociate(offload->pmd, offload->flow); + } +} + +/* Structure to hold a nl_parsed OVS action */ +struct action_attr { + int type; /* OVS action type */ + struct nlattr *action; /* action attribute */ +}; + +/* + * Maxium number of actions to be parsed while selecting a flow for partial + * action offload. This number is currently based on the minimum number of + * attributes seen with the tunnel encap action (clone, tunnel_push, output). + * This number includes output action to a single egress device (uplink) and + * supports neither multiple clone() actions nor multiple output actions. + * This number could change if and when we support other actions or + * combinations of actions for partial offload. + */ +#define MAX_ACTION_ATTRS 3 /* Max # action attributes supported */ + +/* + * This function parses the list of OVS "actions" of length "actions_len", + * and returns them in an array of action "attrs", of size "max_attrs". + * The parsed number of actions is returned in "num_attrs". If the number + * of actions exceeds "max_attrs", parsing is stopped and E2BIG is returned. + * Otherwise, returns success (0). + */ +static int +parse_nlattr_actions(struct nlattr *actions, size_t actions_len, + struct action_attr *attrs, int max_attrs, int *num_attrs) +{ + const struct nlattr *a; + unsigned int left; + int num_actions = 0; + int n_attrs = 0; + int rc = 0; + int type; + + *num_attrs = 0; + + NL_ATTR_FOR_EACH (a, left, actions, actions_len) { + type = nl_attr_type(a); + + if (num_actions >= max_attrs) { + *num_attrs = num_actions; + return E2BIG; + } + + attrs[num_actions].type = type; + attrs[num_actions].action = a; + num_actions++; + if (type == OVS_ACTION_ATTR_CLONE) { + rc = parse_nlattr_actions(nl_attr_get(a), nl_attr_get_size(a), + &attrs[num_actions], + (max_attrs - num_actions), &n_attrs); + num_actions += n_attrs; + if (rc == E2BIG) { + *num_attrs = num_actions; + return rc; + } + } + } + + *num_attrs = num_actions; + return 0; +} + +/* This function determines if the given flow should be partially offloaded + * on the egress device, when the in-port is not offload-capable like a + * vhost-user port. The function currently supports offloading of only + * tunnel encap action. + */ +static bool +should_partial_offload_egress(struct netdev *in_netdev, + struct dp_flow_offload_item *offload, + struct netdev **egress_netdev) +{ + const char *dpif_type_str = + dpif_normalize_type(offload->pmd->dp->class->type); + struct action_attr attrs[MAX_ACTION_ATTRS]; + odp_port_t out_port = ODPP_NONE; + struct netdev *out_netdev; + int num_attrs = 0; + int type; + int rc; + + /* Support egress partial-offload only when in-port is vhost-user. */ + if (!is_dpdk_vhost_netdev(in_netdev)) { + return false; + } + + rc = parse_nlattr_actions(offload->actions, offload->actions_len, attrs, + MAX_ACTION_ATTRS, &num_attrs); + if (rc == E2BIG) { + /* Action list too big; decline partial offload */ + return false; + } + + /* Number of attrs expected with tunnel encap action */ + if (num_attrs < MAX_ACTION_ATTRS) { + return false; + } + + /* Only support clone sub-actions for now, tnl-push specifically. */ + if (attrs[0].type != OVS_ACTION_ATTR_CLONE || + attrs[1].type != OVS_ACTION_ATTR_TUNNEL_PUSH || + attrs[2].type != OVS_ACTION_ATTR_OUTPUT) { + return false; + } + + /* Egress partial-offload needs an output action at the end. */ + out_port = nl_attr_get_odp_port(attrs[2].action); + if (out_port == ODPP_NONE) { + return false; + } + + /* Support egress partial-offload only when out-port is offload capable. */ + out_netdev = netdev_ports_get(out_port, dpif_type_str); + if (!out_netdev || !netdev_dpdk_flow_api_supported(out_netdev)) { + return false; + } + + /* Flow can be egress partial-offloaded. */ + *egress_netdev = out_netdev; + offload->flow->egress_offload_port = out_port; + return true; } static int @@ -2552,7 +2716,9 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) bool modification = offload->op == DP_NETDEV_FLOW_OFFLOAD_OP_MOD; struct offload_info info; struct netdev *port; - uint32_t mark; + struct netdev *egress_port = NULL; + bool alloc_mark = true; + uint32_t mark = INVALID_FLOW_MARK; int ret; if (flow->dead) { @@ -2564,11 +2730,25 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) return -1; } - if (dp_netdev_alloc_flow_mark(flow, modification, &mark)) { - /* flow already offloaded */ + info.attr_egress = 0; + info.partial_actions = 0; + + if (unlikely(should_partial_offload_egress(port, offload, &egress_port))) { + if (egress_port) { netdev_close(port); - return 0; + port = egress_port; + info.attr_egress = 1; + alloc_mark = false; + } + info.partial_actions = 1; + } + + if (alloc_mark && dp_netdev_alloc_flow_mark(flow, modification, &mark)) { + /* flow already offloaded */ + netdev_close(port); + return 0; } + info.flow_mark = mark; /* Taking a global 'port_mutex' to fulfill thread safety restrictions for @@ -2585,17 +2765,24 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) goto err_free; } - if (!modification) { + if (unlikely(info.partial_actions && egress_port)) { + VLOG_DBG_RL("%s: flow: %p mega_ufid: "UUID_FMT" pmd_id: %d\n", + __func__, flow, UUID_ARGS((struct uuid *)&flow->mega_ufid), + flow->pmd_id); + flow->partial_actions_offloaded = true; + } else if (!modification) { megaflow_to_mark_associate(&flow->mega_ufid, mark); mark_to_flow_associate(mark, flow); } return 0; err_free: - if (!modification) { - flow_mark_free(mark); - } else { - mark_to_flow_disassociate(pmd, flow); + if (mark != INVALID_FLOW_MARK) { + if (!modification) { + flow_mark_free(mark); + } else { + mark_to_flow_disassociate(pmd, flow); + } } return -1; } @@ -2711,7 +2898,8 @@ dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread *pmd, ovs_assert(cls != NULL); dpcls_remove(cls, &flow->cr); cmap_remove(&pmd->flow_table, node, dp_netdev_flow_hash(&flow->ufid)); - if (flow->mark != INVALID_FLOW_MARK) { + if (flow->mark != INVALID_FLOW_MARK || (flow->partial_actions_offloaded + && flow->egress_offload_port != ODPP_NONE)) { queue_netdev_flow_del(pmd, flow); } flow->dead = true; @@ -3469,6 +3657,8 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, flow->dead = false; flow->batch = NULL; flow->mark = INVALID_FLOW_MARK; + flow->partial_actions_offloaded = false; + flow->egress_offload_port = ODPP_NONE; *CONST_CAST(unsigned *, &flow->pmd_id) = pmd->core_id; *CONST_CAST(struct flow *, &flow->flow) = match->flow; *CONST_CAST(ovs_u128 *, &flow->ufid) = *ufid; diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 2ed3cb125..ad384e101 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -57,6 +57,7 @@ static struct cmap ufid_to_rte_flow = CMAP_INITIALIZER; struct ufid_to_rte_flow_data { struct cmap_node node; ovs_u128 ufid; + uint32_t refcnt; struct rte_flow *rte_flow; bool actions_offloaded; struct dpif_flow_stats stats; @@ -97,6 +98,7 @@ ufid_to_rte_flow_associate(const ovs_u128 *ufid, ovs_assert(data_prev->rte_flow == NULL); } + data->refcnt = 1; data->ufid = *ufid; data->rte_flow = rte_flow; data->actions_offloaded = actions_offloaded; @@ -1494,7 +1496,8 @@ 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, + struct offload_info *info) { const struct nlattr *ca; unsigned int cleft; @@ -1519,8 +1522,11 @@ parse_clone_actions(struct netdev *netdev, 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; + /* add output action only if full-offload */ + if (!info->partial_actions) { + if (add_output_action(netdev, actions, ca)) { + return -1; + } } } else { VLOG_DBG_RL(&rl, @@ -1537,12 +1543,15 @@ static int parse_flow_actions(struct netdev *netdev, struct flow_actions *actions, struct nlattr *nl_actions, - size_t nl_actions_len) + size_t nl_actions_len, + struct offload_info *info) { struct nlattr *nla; size_t left; - add_count_action(actions); + if (!info->partial_actions) { + 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)) { @@ -1573,7 +1582,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, info)) { return -1; } } else { @@ -1595,15 +1604,22 @@ static struct rte_flow * netdev_offload_dpdk_actions(struct netdev *netdev, struct flow_patterns *patterns, struct nlattr *nl_actions, - size_t actions_len) + size_t actions_len, + struct offload_info *info) { - const struct rte_flow_attr flow_attr = { .ingress = 1, .transfer = 1 }; + struct rte_flow_attr flow_attr = { .ingress = 1, .transfer = 1 }; struct flow_actions actions = { .actions = NULL, .cnt = 0 }; struct rte_flow *flow = NULL; struct rte_flow_error error; int ret; - ret = parse_flow_actions(netdev, &actions, nl_actions, actions_len); + if (info->attr_egress) { + flow_attr.ingress = 0; + flow_attr.egress = 1; + flow_attr.transfer = 0; + } + + ret = parse_flow_actions(netdev, &actions, nl_actions, actions_len,info); if (ret) { goto out; } @@ -1635,8 +1651,15 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, } flow = netdev_offload_dpdk_actions(netdev, &patterns, nl_actions, - actions_len); - if (!flow) { + actions_len, info); + if (flow) { + if (info->partial_actions && info->attr_egress) { + /* actions_offloaded should be set to false with partial actions, + * since it is still considered as partial-offload and not + * full-offload. */ + actions_offloaded = false; + } + } else if (!(info->partial_actions && info->attr_egress)) { /* If we failed to offload the rule actions fallback to MARK+RSS * actions. */ @@ -1686,18 +1709,29 @@ netdev_offload_dpdk_flow_put(struct netdev *netdev, struct match *match, struct dpif_flow_stats *stats) { struct ufid_to_rte_flow_data *rte_flow_data; - int ret; + int ret = 0; - /* - * If an old rte_flow exists, it means it's a flow modification. - * Here destroy the old rte flow first before adding a new one. - */ rte_flow_data = ufid_to_rte_flow_data_find(ufid); if (rte_flow_data && rte_flow_data->rte_flow) { - ret = netdev_offload_dpdk_destroy_flow(netdev, ufid, - rte_flow_data->rte_flow); - if (ret < 0) { + if (unlikely(info->partial_actions && info->attr_egress)) { + /* In the case of partial action offload, the same mega-flow + * could be offloaded by multiple PMD threads. Avoid creating + * multiple rte_flows and just update the refcnt. + */ + VLOG_DBG_RL("%s: mega_ufid: "UUID_FMT" refcnt: %d\n", __func__, + UUID_ARGS((struct uuid *)ufid), rte_flow_data->refcnt); + rte_flow_data->refcnt++; return ret; + } else { + /* + * If an old rte_flow exists, it means it's a flow modification. + * Here destroy the old rte flow first before adding a new one. + */ + ret = netdev_offload_dpdk_destroy_flow(netdev, ufid, + rte_flow_data->rte_flow); + if (ret < 0) { + return ret; + } } } @@ -1719,6 +1753,12 @@ netdev_offload_dpdk_flow_del(struct netdev *netdev, const ovs_u128 *ufid, return -1; } + VLOG_DBG_RL("%s: mega_ufid: "UUID_FMT" refcnt: %d\n", __func__, + UUID_ARGS((struct uuid *)ufid), rte_flow_data->refcnt); + if (rte_flow_data->refcnt-- > 1) { + return 0; + } + if (stats) { memset(stats, 0, sizeof *stats); } diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 4c0ed2ae8..55fcc711c 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -67,6 +67,8 @@ struct offload_info { bool recirc_id_shared_with_tc; /* Indicates whever tc chains will be in * sync with datapath recirc ids. */ + uint8_t attr_egress; /* Egress direction offload */ + uint8_t partial_actions; /* Partial action offload; no forward action */ /* * The flow mark id assigened to the flow. If any pkts hit the flow,