From patchwork Tue Apr 18 19:04:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerhard Engleder X-Patchwork-Id: 13216084 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 E45B0C77B7D for ; Tue, 18 Apr 2023 19:05:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231727AbjDRTFM (ORCPT ); Tue, 18 Apr 2023 15:05:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232239AbjDRTFL (ORCPT ); Tue, 18 Apr 2023 15:05:11 -0400 Received: from mx25lb.world4you.com (mx25lb.world4you.com [81.19.149.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4E445FFB; Tue, 18 Apr 2023 12:05:08 -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=dsBWyfGRaFvX7bIHHJWds7X5trT0UrnBIVsiGmf6RdM=; b=soFGLSpHumQkc4ve8OtnLiww60 3e01a2d5lfxFHksFu0e0tqee4Bg3HkOlvR0VdC71SAscGzi/Yd6HkuD4PeX2ZTHYkuvKsXRmRvcGl ElOF7d2K4O1rLLjzaL7rUJhL4m4A9GT1g73nbNmMkAEFQeX+aDTM7LhyuItNC+A2GQwY=; Received: from [88.117.57.231] (helo=hornet.engleder.at) by mx25lb.world4you.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1poqdV-0002eV-I9; Tue, 18 Apr 2023 21:05:05 +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 v3 0/6] tsnep: XDP socket zero-copy support Date: Tue, 18 Apr 2023 21:04:53 +0200 Message-Id: <20230418190459.19326-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. v3: - use __netif_tx_lock_bh() (Paolo Abeni) - comment that rx->page_buffer is always zero terminated (Paolo Abeni) 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 | 863 ++++++++++++++++++--- drivers/net/ethernet/engleder/tsnep_xdp.c | 66 ++ 3 files changed, 822 insertions(+), 123 deletions(-) Reviewed-by: Maciej Fijalkowski