Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1813995rdb; Thu, 7 Dec 2023 09:22:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXPB1pcnQJMrjGHY0J380HCuP2pSzBHVIr/GaZGIePVn3Ugn/WEpFoE59X0Qe7gaA288wu X-Received: by 2002:a05:6a21:6d88:b0:18f:d156:5b12 with SMTP id wl8-20020a056a216d8800b0018fd1565b12mr3043102pzb.118.1701969741742; Thu, 07 Dec 2023 09:22:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701969741; cv=none; d=google.com; s=arc-20160816; b=bi6sbyQ5X6+UrkLLT/E4xziJs5+Ee+3hk0Da8Ign853qCjKlRvGvZP0LRc/Rm8CfjI bPySh4BemsSZWtLOofHOnI+s6YXuF8iz8iBJh7cYonaRDhirjAQ777inGEmew52xBnDA 1FMe5R+VZFQ2QrjSp5YU/xNcXac+ZmQg2FzyaRiRb73+9KWLBj8XqVF7NbfnycccLDTE AQfLMD1gsNoUfkBauK6j4uDJXIaKqTYFWG/zO7572GF633iAhyvvh9Gcci7iAXl8Voe9 csSHXbwgmsmInGWjdXh6nGkZrPPNDBmU5EZcSBxDd0gAFwncotS1xIKZWKRg+q9BgBqh T7fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=N47AawPdWa2StZqjhP4jlVVhaPFPlDZmEk0uleM9hII=; fh=QtEizEezWMPccSW0U8o1LFLT1SqErEb68UiNokAWV6o=; b=w+CS8RPJzm/x2SaS7ycUjOqnSL4z1X7SIIOY2TYn6pRwNO5keaiBCGcLZ1yKp8Qimt C8Cqf8G/OSTUMhIFbM/CqXaO4sdMMJpuXnHoukB7eZCP5Z5rCNDHeE4vuGaJfk0HDuX/ ApgT4cxpa6gceZB0HLgHLuWhhb40G256K7KlfTlahbCUOgJftF0QeeMB9efpLb/ITwpB JEQfEslYDMYItux8Sj55AX4dIwK5ImESe/mtAYcucCJiEotRhTrff86U10beM+GMHZ4D SRW/LQVEuke8Y/0UVslRCxrW2LEYqyJ7gfRo4mBih1iG7R2slbTqyPI+WY6YPDJejHOm pbDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CBwhfiF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id y20-20020a63e254000000b005c1ce3c9617si11007pgj.901.2023.12.07.09.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 09:22:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CBwhfiF5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id DF8DB82A516E; Thu, 7 Dec 2023 09:22:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443267AbjLGRWC (ORCPT + 99 others); Thu, 7 Dec 2023 12:22:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443192AbjLGRWB (ORCPT ); Thu, 7 Dec 2023 12:22:01 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C79CEA3; Thu, 7 Dec 2023 09:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701969727; x=1733505727; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=cxce2/w/Ev4WegPERyasoQSNccjGfNR/i9i/+gJ+2KM=; b=CBwhfiF5egY0nCYyELLU2H0hI4UjgaWZC0CSMA9y1eC0DvLWYP4QINfH jv4r4vsKm8/cW+Dh1XIbRhLSHltpCmbTDaa/eIzqXPQP75itLAQJ2IO5M d3oVrxuPOhPHg6RmlSH8IbkVKCMn70uBBUpWioL05SCC9edeyTdTI0NLa Sq4fVjTaVnjYKvvvMgc4gswqnk9lZIx1nzoI6RMfwFyd5g2qKVmYte2ZV zuO+nMCcHfOUVOzByfBQkicZZ+QtdJOXHjp+ehCvXgRz3i59vV+IPpMb9 1T+v/bZmxsE0aXdTmGjqP4CZOgZ1yAFip3ODBXm8l3FDNuJ0by1jJ2ekB w==; X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="374434623" X-IronPort-AV: E=Sophos;i="6.04,258,1695711600"; d="scan'208";a="374434623" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Dec 2023 09:21:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10917"; a="721548484" X-IronPort-AV: E=Sophos;i="6.04,258,1695711600"; d="scan'208";a="721548484" Received: from newjersey.igk.intel.com ([10.102.20.203]) by orsmga003.jf.intel.com with ESMTP; 07 Dec 2023 09:21:50 -0800 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Maciej Fijalkowski , Michal Kubiak , Larysa Zaremba , Alexander Duyck , Yunsheng Lin , David Christensen , Jesper Dangaard Brouer , Ilias Apalodimas , Paul Menzel , netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 00/12] net: intel: start The Great Code Dedup + Page Pool for iavf Date: Thu, 7 Dec 2023 18:19:58 +0100 Message-ID: <20231207172010.1441468-1-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 07 Dec 2023 09:22:18 -0800 (PST) Here's a two-shot: introduce Intel Ethernet common library (libie) and switch iavf to Page Pool. Details are in the commit messages; here's a 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 name that came to my mind was "libie" -- "Intel Ethernet common library". Also this sounds like "lovelie" (-> one word, no "lib I E" pls) and can be expanded as "lib Internet Explorer" :P 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?". The final destination is very ambitious: have only one unified driver for at least i40e, ice, iavf, and idpf with a struct ops for each generation. That's never gonna happen, right? But you still can at least try. PP conversion for iavf lands within the same series as these two are tied closely. libie will support Page Pool model only, so that 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 (12): page_pool: make sure frag API fields don't span between cachelines page_pool: don't use driver-set flags field directly net: intel: introduce Intel Ethernet common library iavf: kill "legacy-rx" for good iavf: drop page splitting and recycling page_pool: constify some read-only function arguments page_pool: add DMA-sync-for-CPU inline helper libie: add Rx buffer management (via Page Pool) iavf: pack iavf_ring more efficiently iavf: switch to Page Pool libie: add common queue stats iavf: switch queue stats to libie MAINTAINERS | 3 +- drivers/net/ethernet/intel/Kconfig | 6 + 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 | 72 +- 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 | 235 +------ drivers/net/ethernet/intel/iavf/iavf_main.c | 42 +- .../net/ethernet/intel/iavf/iavf_prototype.h | 7 - drivers/net/ethernet/intel/iavf/iavf_txrx.c | 624 ++++-------------- drivers/net/ethernet/intel/iavf/iavf_txrx.h | 174 +---- drivers/net/ethernet/intel/iavf/iavf_type.h | 90 --- .../net/ethernet/intel/iavf/iavf_virtchnl.c | 17 +- .../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/Kconfig | 9 + drivers/net/ethernet/intel/libie/Makefile | 7 + drivers/net/ethernet/intel/libie/rx.c | 179 +++++ drivers/net/ethernet/intel/libie/stats.c | 121 ++++ include/linux/net/intel/libie/rx.h | 259 ++++++++ include/linux/net/intel/libie/stats.h | 179 +++++ include/net/page_pool/helpers.h | 34 +- include/net/page_pool/types.h | 19 +- net/core/page_pool.c | 42 +- 29 files changed, 1058 insertions(+), 2057 deletions(-) create mode 100644 drivers/net/ethernet/intel/libie/Kconfig create mode 100644 drivers/net/ethernet/intel/libie/Makefile 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 changes :p From v5[0]: * drop Page Pool DMA shortcut: will pick up Eric's more global DMA sync optimization[1] and expand it to cover both IOMMU and direct DMA a bit later (Yunsheng); * drop per-queue Page Pool Ethtool stats: they are now exported via generic Netlink interface (Jakub); * #01: leave a comment why exactly this alignment (Jakub, Yunsheng); * #08: make use of page_pool_params::netdev when calculating PP params; * #08: rename ``libie_rx_queue`` -> ``libie_buf_queue``. From v4[2]: * make use of Jakub's &page_pool_params split; * #01: prevent frag fields from spanning into 2 cachelines after splitting &page_pool_params into fast and slow; * #02-03: bring back the DMA sync shortcut, now as a per-page flag (me, Yunsheng); * #04: let libie have its own Kconfig to stop further bloating of poor intel/Kconfig; * #06: merge page split-reuse-recycle drop into one commit (Alex); * #07: decouple constifying of several Page Pool function arguments into a separate commit, constify some more; * #09: stop abusing internal PP fields in the driver code (Yunsheng); * #09: calculate DMA sync size (::max_len) correctly: within one page, not one buffer (Yunsheng); * #10: decouple rearranging &iavf_ring into separate commit, optimize it even more; * #11: let the driver get back to the last descriptor to process after an skb allocation fail, don't drop it (Alex); * #11: stop touching unrelated stuff like watchdog timeout etc. (Alex); * fix "Return:" in the kdoc (now `W=12 C=1` is clean), misc typos. From v3[3]: * 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[4] 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[5]: * 0006: fix page_pool.h include in OcteonTX2 files (Jakub, Patchwork); * no functional changes. From v1[6]: * 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/20231124154732.1623518-1-aleksander.lobakin@intel.com [1] https://lore.kernel.org/netdev/20221115182841.2640176-1-edumazet@google.com [2] https://lore.kernel.org/netdev/20230705155551.1317583-1-aleksander.lobakin@intel.com [3] https://lore.kernel.org/netdev/20230530150035.1943669-1-aleksander.lobakin@intel.com [4] https://lore.kernel.org/netdev/20230629120226.14854-1-linyunsheng@huawei.com [5] https://lore.kernel.org/netdev/20230525125746.553874-1-aleksander.lobakin@intel.com [6] https://lore.kernel.org/netdev/20230516161841.37138-1-aleksander.lobakin@intel.com -- 2.43.0