From patchwork Tue Jun 14 22:13:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1643441 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LhjZAOkC; dkim-atps=neutral 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 (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LN2lY5vfTz9vGL for ; Wed, 15 Jun 2022 08:14:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6CBF441900; Tue, 14 Jun 2022 22:13:56 +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 2f18T7q3FtyO; Tue, 14 Jun 2022 22:13:54 +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 7F764418B7; Tue, 14 Jun 2022 22:13:52 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 74EF1C0085; Tue, 14 Jun 2022 22:13:50 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4DAA2C0085 for ; Tue, 14 Jun 2022 22:13:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 3D0F1813E4 for ; Tue, 14 Jun 2022 22:13:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp1.osuosl.org (amavisd-new); dkim=pass (1024-bit key) header.d=redhat.com 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 TAX48hFVIMp7 for ; Tue, 14 Jun 2022 22:13:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1F505813A8 for ; Tue, 14 Jun 2022 22:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655244822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=C8TwY4KGNZ9PNrMcJ496C7/Ck7CL7yrvGS27N4EG1qE=; b=LhjZAOkC99X9p/Cx8I5eM/t2eRaNU5V9ET2iL6DwPVNuWBDqoaikouCrU1sJwbMEgsAUbB wFK7ced095nd1D8NnSPml8qk6pvNt85aK4E0bIXdk9aYOZ7Oilc46b3vz5nZo3OV8Prxjb ejLo+fV34FvRXc+PE6GLOp7CI+N0cEo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-404-zxbQh8OmO_Gsp_P-gxehWQ-1; Tue, 14 Jun 2022 18:13:39 -0400 X-MC-Unique: zxbQh8OmO_Gsp_P-gxehWQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88DE3299E765; Tue, 14 Jun 2022 22:13:39 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.18.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2A35D492C3B; Tue, 14 Jun 2022 22:13:39 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Tue, 14 Jun 2022 18:13:15 -0400 Message-Id: <20220614221317.1028795-8-mkp@redhat.com> In-Reply-To: <20220614221317.1028795-7-mkp@redhat.com> References: <20220614221317.1028795-1-mkp@redhat.com> <20220614221317.1028795-2-mkp@redhat.com> <20220614221317.1028795-3-mkp@redhat.com> <20220614221317.1028795-4-mkp@redhat.com> <20220614221317.1028795-5-mkp@redhat.com> <20220614221317.1028795-6-mkp@redhat.com> <20220614221317.1028795-7-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mkp@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: Flavio Leitner , maxime.coquelin@redhat.com, david.marchand@redhat.com Subject: [ovs-dev] [PATCH 08/10] Document netdev 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: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Flavio Leitner Document the implementation of netdev hardware offloading in userspace datapath. Signed-off-by: Flavio Leitner Signed-off-by: Mike Pattrick Co-authored-by: Mike Pattrick --- Documentation/automake.mk | 1 + Documentation/topics/index.rst | 1 + Documentation/topics/nic-offloads.rst | 95 +++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 Documentation/topics/nic-offloads.rst diff --git a/Documentation/automake.mk b/Documentation/automake.mk index 6c2c57739..a5f6d562b 100644 --- a/Documentation/automake.mk +++ b/Documentation/automake.mk @@ -50,6 +50,7 @@ DOC_SOURCE = \ Documentation/topics/integration.rst \ Documentation/topics/language-bindings.rst \ Documentation/topics/networking-namespaces.rst \ + Documentation/topics/nic-offloads.rst \ Documentation/topics/openflow.rst \ Documentation/topics/ovs-extensions.rst \ Documentation/topics/ovsdb-relay.rst \ diff --git a/Documentation/topics/index.rst b/Documentation/topics/index.rst index 90d4c66e6..c4c11f4f1 100644 --- a/Documentation/topics/index.rst +++ b/Documentation/topics/index.rst @@ -44,6 +44,7 @@ OVS openflow bonding networking-namespaces + nic-offloads ovsdb-relay ovsdb-replication dpdk/index diff --git a/Documentation/topics/nic-offloads.rst b/Documentation/topics/nic-offloads.rst new file mode 100644 index 000000000..5959c65ad --- /dev/null +++ b/Documentation/topics/nic-offloads.rst @@ -0,0 +1,95 @@ +.. + Licensed under the Apache License, Version 2.0 (the "License"); you may + not use this file except in compliance with the License. You may obtain + a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + License for the specific language governing permissions and limitations + under the License. + + Convention for heading levels in Open vSwitch documentation: + + ======= Heading 0 (reserved for the title in a document) + ------- Heading 1 + ~~~~~~~ Heading 2 + +++++++ Heading 3 + ''''''' Heading 4 + + Avoid deeper levels because they do not render well. + +============ +NIC Offloads +============ + +This document explains the internals of Open vSwitch support for NIC offloads. + +Design +------ + +The Open vSwitch should strive to forward packets as they arrive regardless +if the checksum is correct, for example. However, it cannot fix existing +problems. Therefore, when the packet has the checksum verified or it the +packet is known to be good, the checksum calculation can be offloaded to +the NIC, otherwise updates can be made as long as the previous situation +doesn't change. For example, a packet has corrupted IP checksum can be +accepted, a flow rule can change the IP destination address to another +address. In that case, OVS needs to partially recompute the checksum +instead of offloading or calculate all of it again which would fix the +existing issue. + +The drivers can set flags indicating if the checksum is good or bad. +The checksum is considered unverified if no flag is set. + +When a packet ingress the data path with good checksum, OVS should +enable checksum offload by default. This allows the data path to +postpone checksum updates until the packet egress the data path. + +When a packet egress the data path, the packet flags and the egress +port flags are verified to make sure all required NIC offload +features to send out the packet are available. If not, the data +path will fall back to equivalent software implementation. + + +Drivers +------- + +When the driver initiates, it should set the flags to tell the data path +which offload features are supported. For example, if the driver supports +IP checksum offloading, then netdev->ol_flags should set the flag +NETDEV_OFFLOAD_TX_IPV4_CSUM. + + +Rules +----- +1) OVS should strive to forward all packets regardless of checksum. + +2) OVS must not correct a bad packet/checksum. + +3) Packet with flag DP_PACKET_OL_RX_IP_CSUM_GOOD means that the + IP checksum is present in the packet and it is good. + +4) Packet with flag DP_PACKET_OL_RX_IP_CSUM_BAD means that the + IP checksum is present in the packet and it is BAD. Extra care + should be taken to not fix the packet during data path processing. + +5) The ingress packet parser can only set DP_PACKET_OL_TX_IP_CSUM + if the packet has DP_PACKET_OL_RX_L4_CKSUM_GOOD to not violate + rule #2. + +6) Packet with flag DP_PACKET_OL_TX_IPV4 is a IPv4 packet. + +7) Packet with flag DP_PACKET_OL_TX_IPV6 is a IPv6 packet. + +8) Packet with flag DP_PACKET_OL_TX_IP_CSUM tells the data path + to skip updating the IP checksum if the packet is modified. The + IP checksum will be calculated by the egress port if that + supports IP checksum offload, otherwise the IP checksum will + be done in software before handing over the packet to the port. + +9) When there are modifications to the packet that requires checksum + update, the data path needs to remove DP_PACKET_OL_RX_IP_CSUM_GOOD + flag, otherwise the checksum is assumed to be good in the packet.