From patchwork Wed Jul 5 15:55:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 1803846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=7pgXYEBm; dkim-atps=neutral Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qx4773Jb8z20Pf for ; Thu, 6 Jul 2023 01:57:39 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id D86B382051; Wed, 5 Jul 2023 15:57:36 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org D86B382051 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1688572656; bh=5QRNbBEEkZ+8SgEEaOPKFOsAUkRixA7ej21JlEG8/ts=; h=From:To:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:Cc:From; b=7pgXYEBm7vgz0Ee4G8fkIz2RB1UmJ9UgAWXAf9+kJNRGvgUC0+Efylp09DUITSYwC xkJo2EwbDlf4llXGDh1Ij7zCcAaTPGIm/+MiNUpw6JJa86wCFQjunrZvZhuHF4GOaO b+ucn7mB+El7jtRtYGB/3Jrs+wl6vAiqlZpQBBwR11vMA5tOupH9yaeEhZlrMQRBeO h3Wr5i78Tq1FdlwNsqOflBZeguO/URWysrw2iliTBG2H6r3rTyW4u+1Za21Bq42a/E 3V3gXZo8GNOzUckfzBpIVcbyozeuEVD7rOWHAD61RH4EwokoUX+X2ni5V5hw+dKfFQ LY+uxfsui7Eqw== 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 HY2So2j04wdV; Wed, 5 Jul 2023 15:57:35 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id AC3158206E; Wed, 5 Jul 2023 15:57:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org AC3158206E X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id C36731BF2CE for ; Wed, 5 Jul 2023 15:57:34 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9933F40489 for ; Wed, 5 Jul 2023 15:57:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9933F40489 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 vzH2f7oDNUFk for ; Wed, 5 Jul 2023 15:57:32 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 7A44B40106 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by smtp2.osuosl.org (Postfix) with ESMTPS id 7A44B40106 for ; Wed, 5 Jul 2023 15:57:32 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="366863373" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="366863373" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Jul 2023 08:57:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="789205538" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="789205538" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmsmga004.fm.intel.com with ESMTP; 05 Jul 2023 08:57:25 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Date: Wed, 5 Jul 2023 17:55:42 +0200 Message-ID: <20230705155551.1317583-1-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688572652; x=1720108652; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LyPMsf3C0/NaDYzoiwx7gQCCBQX3u+0J5fs1oCvaAiY=; b=D+lLJJg8gd6QfWumxScGr9oNrzuIRb1KzMoOnz+19ohCGcn2BFmdesIF lxvK6hS2pCgwg4jKGDvgN24IiSsrFulmPAZ7XDW3tGgzMPLtWvXqbnDer YFCWafo6FvzoXxPRVjV/ndLmZnX+spxFoeIk/VWpVOdeWvEXnFSiciPfY 407QO2O9igD0sZ3hlDLnxbEjpWyKqNozWw/8JSn+Atx3YxrSzLWyFsM2i o7p7LaCJxb27PkeQ7ueRE6hOLLjOdFgHd3HQGeb5EDtTZuq5J86Oi5jIH gti4q8Mr0PNGQD1yJ+Ujjc9sDheOMj6KlHywybITQWn2BwyKTabKCn9bL w==; X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=D+lLJJg8 Subject: [Intel-wired-lan] [PATCH RFC net-next v4 0/9] net: intel: start The Great Code Dedup + Page Pool for iavf X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paul Menzel , Jesper Dangaard Brouer , Larysa Zaremba , netdev@vger.kernel.org, Alexander Duyck , Ilias Apalodimas , linux-kernel@vger.kernel.org, Yunsheng Lin , Michal Kubiak , intel-wired-lan@lists.osuosl.org, David Christensen Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Here's a two-shot: introduce Intel Ethernet common library (libie) and switch iavf to Page Pool. Details in the commit messages; here's summary: Not a secret there's a ton of code duplication between two and more Intel ethernet modules. Before introducing new changes, which would need to be copied over again, start decoupling the already existing duplicate functionality into a new module, which will be shared between several Intel Ethernet drivers. The first thing that came to my mind was "libie" -- "Intel Ethernet common library". Also this sounds like "lovelie" and can be expanded as "lib Internet Explorer" :P I'm open for anything else (but justified). The series is only the beginning. From now on, adding every new feature or doing any good driver refactoring will remove much more lines than add for quite some time. There's a basic roadmap with some deduplications planned already, not speaking of that touching every line now asks: "can I share this?". PP conversion for iavf lands within the same series as these two are tied closely. libie will support Page Pool model only, so a driver can't use much of the lib until it's converted. iavf is only the example, the rest will eventually be converted soon on a per-driver basis. That is when it gets really interesting. Stay tech. Alexander Lobakin (9): net: intel: introduce Intel Ethernet common library iavf: kill "legacy-rx" for good iavf: drop page splitting and recycling net: page_pool: add DMA-sync-for-CPU inline helpers libie: add Rx buffer management (via Page Pool) iavf: switch to Page Pool libie: add common queue stats libie: add per-queue Page Pool stats iavf: switch queue stats to libie MAINTAINERS | 3 +- drivers/net/ethernet/intel/Kconfig | 11 + drivers/net/ethernet/intel/Makefile | 1 + drivers/net/ethernet/intel/i40e/i40e_common.c | 253 -------- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + .../net/ethernet/intel/i40e/i40e_prototype.h | 7 - drivers/net/ethernet/intel/i40e/i40e_txrx.c | 74 +-- drivers/net/ethernet/intel/i40e/i40e_type.h | 88 --- drivers/net/ethernet/intel/iavf/iavf.h | 2 +- drivers/net/ethernet/intel/iavf/iavf_common.c | 253 -------- .../net/ethernet/intel/iavf/iavf_ethtool.c | 226 +------ drivers/net/ethernet/intel/iavf/iavf_main.c | 44 +- .../net/ethernet/intel/iavf/iavf_prototype.h | 7 - drivers/net/ethernet/intel/iavf/iavf_txrx.c | 608 ++++-------------- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 176 +---- drivers/net/ethernet/intel/iavf/iavf_type.h | 90 --- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 20 +- .../net/ethernet/intel/ice/ice_lan_tx_rx.h | 316 --------- drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 74 +-- drivers/net/ethernet/intel/libie/Makefile | 7 + drivers/net/ethernet/intel/libie/internal.h | 23 + drivers/net/ethernet/intel/libie/rx.c | 183 ++++++ drivers/net/ethernet/intel/libie/stats.c | 190 ++++++ include/linux/net/intel/libie/rx.h | 241 +++++++ include/linux/net/intel/libie/stats.h | 214 ++++++ include/net/page_pool.h | 49 +- 27 files changed, 1137 insertions(+), 2025 deletions(-) create mode 100644 drivers/net/ethernet/intel/libie/Makefile create mode 100644 drivers/net/ethernet/intel/libie/internal.h create mode 100644 drivers/net/ethernet/intel/libie/rx.c create mode 100644 drivers/net/ethernet/intel/libie/stats.c create mode 100644 include/linux/net/intel/libie/rx.h create mode 100644 include/linux/net/intel/libie/stats.h --- Directly to net-next, has non-Intel code change (#4) :p Based on the PP "hybrid" allocation series[0] and requires it to work. From v3[1]: * base on the latest net-next, update bloat-o-meter and perf stats; * split generic PP optimizations into a separate series; * drop "optimize hotpath a bunch" commit: a lot of [controversial] changes in one place, worth own series (Alex); * 02: pick Rev-by (Alex); * 03: move in-place recycling removal here from the dropped patch; * 05: new, add libie Rx buffer API separatelly from IAVF changes; * 05-06: use new "hybrid" allocation API from[0] to reduce memory usage when a page can fit more than 1 truesize (also asked by David); * 06: merge with "always use order-0 page" commit to reduce diffs and simplify things (Alex); * 09: fix page_alloc_fail counter. From v2[2]: * 0006: fix page_pool.h include in OcteonTX2 files (Jakub, Patchwork); * no functional changes. From v1[3]: * 0006: new (me, Jakub); * 0008: give the helpers more intuitive names (Jakub, Ilias); * -^-: also expand their kdoc a bit for the same reason; * -^-: fix kdoc copy-paste issue (Patchwork, Jakub); * 0011: drop `inline` from C file (Patchwork, Jakub). [0] https://lore.kernel.org/netdev/20230629120226.14854-1-linyunsheng@huawei.com [1] https://lore.kernel.org/netdev/20230530150035.1943669-1-aleksander.lobakin@intel.com [2] https://lore.kernel.org/netdev/20230525125746.553874-1-aleksander.lobakin@intel.com [3] https://lore.kernel.org/netdev/20230516161841.37138-1-aleksander.lobakin@intel.com