From patchwork Sat Apr 15 14:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Engleder X-Patchwork-Id: 13212545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E779C77B76 for ; Sat, 15 Apr 2023 14:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbjDOOnF (ORCPT ); Sat, 15 Apr 2023 10:43:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbjDOOnE (ORCPT ); Sat, 15 Apr 2023 10:43:04 -0400 Received: from mx23lb.world4you.com (mx23lb.world4you.com [81.19.149.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9EC455A1; Sat, 15 Apr 2023 07:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=engleder-embedded.com; s=dkim11; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MUqpw3CxRF8s0DjevM/XGQafhBrPUW4nHhQJdpRlLV0=; b=n9vIRmcZthmPAtGZ/XeF63wmoF yZvQ5SSOLhrUq/Jq7tyUfMv5D3xUD9U7sXQYH2LzJqdbvJBR+XhddqXxfJvE58X5j7OUnztwCiM8K mgOWeZPQNO+HJwC5KlcvPhWAFdJ1/a5Qa9VlE5PUa77CK/V0s26mX2FBvDZO/DH4hbVA=; Received: from [88.117.57.231] (helo=hornet.engleder.at) by mx23lb.world4you.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pnh7C-0003zN-OI; Sat, 15 Apr 2023 16:42:58 +0200 From: Gerhard Engleder To: netdev@vger.kernel.org, bpf@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com, pabeni@redhat.com, bjorn@kernel.org, magnus.karlsson@intel.com, maciej.fijalkowski@intel.com, jonathan.lemon@gmail.com, Gerhard Engleder Subject: [PATCH net-next v2 0/6] tsnep: XDP socket zero-copy support Date: Sat, 15 Apr 2023 16:42:50 +0200 Message-Id: <20230415144256.27884-1-gerhard@engleder-embedded.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-AV-Do-Run: Yes X-ACL-Warn: X-W4Y-Internal Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Implement XDP socket zero-copy support for tsnep driver. I tried to follow existing drivers like igc as far as possible. But one main difference is that tsnep does not need any reconfiguration for XDP BPF program setup. So I decided to keep this behavior no matter if a XSK pool is used or not. As a result, tsnep starts using the XSK pool even if no XDP BPF program is available. Another difference is that I tried to prevent potentially failing allocations during XSK pool setup. E.g. both memory models for page pool and XSK pool are registered all the time. Thus, XSK pool setup cannot end up with not working queues. Some prework is done to reduce the last two XSK commits to actual XSK changes. v2: - eliminate modulo op in TX/RX path (Maciej Fijalkowski) - eliminate retval variable in tsnep_rx_alloc_zc() (Maciej Fijalkowski) - scope variable entry within loop (Maciej Fijalkowski) - use DMA_ATTR_SKIP_CPU_SYNC directly (Maciej Fijalkowski) - union for page/xdp in tsnep_rx_entry (Maciej Fijalkowski) - provide performance numbers (Maciej Fijalkowski) - use xsk_buff_alloc_batch() (Maciej Fijalkowski) - use xsk_tx_peek_release_desc_batch() (Maciej Fijalkowski) - don't call tsnep_rx_reopen() if netdev is down - init adapter pointer of queue only once Gerhard Engleder (6): tsnep: Replace modulo operation with mask tsnep: Rework TX/RX queue initialization tsnep: Add functions for queue enable/disable tsnep: Move skb receive action to separate function tsnep: Add XDP socket zero-copy RX support tsnep: Add XDP socket zero-copy TX support drivers/net/ethernet/engleder/tsnep.h | 16 +- drivers/net/ethernet/engleder/tsnep_main.c | 864 ++++++++++++++++++--- drivers/net/ethernet/engleder/tsnep_xdp.c | 66 ++ 3 files changed, 823 insertions(+), 123 deletions(-)