Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp29290655rwd; Wed, 5 Jul 2023 09:41:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlEBL7chI0agFsm2PRAKd02Kzr6CYnCcFDat1Bz/51Ct3XH7sNrcaPtcs6C/s7IRAbQodpi9 X-Received: by 2002:a05:6a00:15c7:b0:674:8fe0:1262 with SMTP id o7-20020a056a0015c700b006748fe01262mr16725981pfu.18.1688575280444; Wed, 05 Jul 2023 09:41:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688575280; cv=none; d=google.com; s=arc-20160816; b=kZnzTB+6rGpwh9/iRdfgGJr74cDyIi5h74t530yD0VOqEDZHCihV/evLVv8iC26UdO /YBWvo1pKdyKEAp/AJKUKdxb1ZAKuI10qKIBQRSrkV1FKmIze4lKliQtYTXO9BwjxXsm E1Yaz7lvbyrw3Erj5VJBCQ4eobjRwImHLoOrsGDZe9w7jgaPSiHtZ7DQWDkskM0zBQop PoZHnrudBBJny5KpD8rWbWPq4LOHeTj+uhWJ4bM2TSeGUNZJ6gvt3nqhPpE/Uz7a8d9J +jBX20/1KcEELSSk8TT8T0QJgeur5z78ZYqPtPGdNKVBL1Xkw7rfjzoXNT7BvkaTHlqy h+Rw== 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=AIiZYhG0PdD5IcyNzRzumDPfTzwMcqNDFLE8Qi6+RL0=; fh=QtEizEezWMPccSW0U8o1LFLT1SqErEb68UiNokAWV6o=; b=EbWDToG5hc5XAmXYQWZUuoX5pFf5K1hlKmjXak7APlxEEamnRx5RZAAhcg+Xh96suM goi9vKRBfXnRYd8KYgQYiZF2j6Izon3W6KhAUD1JVYU0naj6MFxmmLl5UsjI0cXnYHpS fv+BdfRa3+C4VqVNpEE3XNiD7BTjJKNBOE3PLQl8/cLOE/QzzQTeyABylIk2q7RIuSXD G2nCt8XmgFxbrmsEoHJ+l1X2nrZFgX6XqiYiBTY06Agjgup9JZ/LwEpyTjKQ489Z0JWJ n0pItPY9BO+WaGFHdAsdLCLgOpgkRpetp8OVrt/Y8JtQ0LnduXA5R3mZT2s3+oJa3b1E fYsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SMn9aNsQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u127-20020a627985000000b0066957b1c0a0si13820375pfc.288.2023.07.05.09.41.07; Wed, 05 Jul 2023 09:41:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SMn9aNsQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233059AbjGEP5d (ORCPT + 99 others); Wed, 5 Jul 2023 11:57:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbjGEP5c (ORCPT ); Wed, 5 Jul 2023 11:57:32 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57F5FF0; Wed, 5 Jul 2023 08:57:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688572651; x=1720108651; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LyPMsf3C0/NaDYzoiwx7gQCCBQX3u+0J5fs1oCvaAiY=; b=SMn9aNsQZgttntTNE29U8xh63pJHrpsJF0oSxrBhq9caCy/0lzsrj/YI vZTyBJSLJaK8k2yEvmvPOIxw15+qXEbN0CFtKR8SgbzxAZ5TUz12unH3c 7mhX1kE/W96EWbTOMGplBfVgSmNw3i10TXMy6VByWyD64tgkMN5geXXZL 2cZTpHafNgq40ldfasC0zJT3ZOrcSf4IS+Z+N9622aOsLrY7OjolXa6XB /H75hCazFkMHACVZDXoLloBwlu6FaCGluzWDEP9TBPGcS5VYxUtCdatcL 3eK1E97A5TZ88eifbWITl5xN2Xc6z5C+9ebW9G3GvTlqIa2ulkxkkcMMd g==; X-IronPort-AV: E=McAfee;i="6600,9927,10762"; a="366863368" X-IronPort-AV: E=Sophos;i="6.01,183,1684825200"; d="scan'208";a="366863368" 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 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 RFC net-next v4 0/9] net: intel: start The Great Code Dedup + Page Pool for iavf 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.41.0