From patchwork Thu Dec 14 02:05:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mina Almasry X-Patchwork-Id: 18025 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8267389dys; Wed, 13 Dec 2023 18:05:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGb1HR4RNpCGaWssbDntlpY4vb/Htq+I9r2+qqvY6weD09e8IpxAdZQYuCyzXNwLLHGrfKc X-Received: by 2002:a05:6808:1183:b0:3b8:b063:6bb2 with SMTP id j3-20020a056808118300b003b8b0636bb2mr11127208oil.97.1702519557304; Wed, 13 Dec 2023 18:05:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702519557; cv=none; d=google.com; s=arc-20160816; b=a6+kUTesUr1pnKHtYncQjsKLs6hcphPGxkF3s/AY+CJF4N3rYTJ2lf+LcHYEwKUQ83 izEuhSnzTQKnLTG2uxsFFMhVz9+a77U2cOwFdtwdzm5Em1XRJooFttMvjcmBG9xe/oHp AT7dcQjz47y9XDYmOX1kwp2UWhdkv9rFWUeU2FlGX/qIId6WTXdL48blGbfAdI/0zgwo lzRy2DDEz8w+NfDOo7DLAD0/wQbTqcM2cFmiZf03Wo1bloDbxCMdF7TE+sYehF69PaDK nR/aAnZ50h2aV9oeqEnjFNgYjDUiVjq1S3o3FahDw1xkNXWuC67Z9aKx7MQqobrI3mVm wgQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:mime-version:date:dkim-signature; bh=ZEZvumk7MgtmWweazFTl3ViX2nGxgFVZEAs/ufpHI5M=; fh=2cTpkOQdVNm4Kv9XaiKb49A4tmrQwCTD9dCd1XGCiM8=; b=hFUZDXOCjpr7VAqZELVSRkISTfQ1XeYgjfWd5a/RlJjDidmRp7TkCw5FxhQlXOAq6q IpULbnIWdA/wHOiKtDSaUrqIWV9/Om/oQ/XLmf731yVXQlR6qTCpSFrd09JB4W0IkMQg wfhwGv41ee7VLO3CKvnLo/GfvzwGG/3P7MZSmPv6zTZuQmnRaNp/5K/2mMbf40yUI8Qs wh5/utNPIoL5QxFdtOaEAucHVJxq9IWXoHv48AcWQn3aP1cTbvpgyeQhH7z+u6ygqpo0 hDQtPdTs24ywuLB8/sevGJ79ITHfzw8tg1SnVPs/3sFDeOEC6rEu9tJnTdRo2cAKLGl/ N9Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="neg1a/BI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id z5-20020a170902834500b001d06d30071dsi10057582pln.651.2023.12.13.18.05.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 18:05:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="neg1a/BI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id D13D18029AA4; Wed, 13 Dec 2023 18:05:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234147AbjLNCFb (ORCPT + 99 others); Wed, 13 Dec 2023 21:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjLNCF3 (ORCPT ); Wed, 13 Dec 2023 21:05:29 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B2C4F4 for ; Wed, 13 Dec 2023 18:05:36 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-db53919e062so8568495276.0 for ; Wed, 13 Dec 2023 18:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702519535; x=1703124335; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=ZEZvumk7MgtmWweazFTl3ViX2nGxgFVZEAs/ufpHI5M=; b=neg1a/BIWXM/MAD5vta/dZqWHpqOuN93ROqTn4BGpe7sZ4wN8/8Ef97zUZExi5sZMa sbNpaCN8Y9lMCARCHs7kLsvrYRsgCg1KQ31QfiRIFisLk1cODdNLIgD91pHEJswS07LI BN3xbzLnqsSkxRzONVykCYISbFDWgEyTc9xRYCmSlDawBwKYTityKpmsJo9PAsADJ36A j2OYub/q5FV7tQziph1lnp5mUsPHQBrfwj/RS17ErghJ/lOxzjMMDZ73WBuLU4hhIxRw yygMhm4UlW/OjUBbBmYeUqPpooairasFeuQGK+IC6Jq0xY1PMBN5yLIQAL4GR7rh3B5r BUrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702519535; x=1703124335; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZEZvumk7MgtmWweazFTl3ViX2nGxgFVZEAs/ufpHI5M=; b=Um05Err78eVZ83rPL95zBU6+7Xzd929J09LK6+TELimzRX75J/qpGimlEflQLv6cxs SLLf2dL7ztSr4UdUmYlCjgh3/2zP4+XCeszik6/LGvz521cLnzPHR0nLoCJ6lOaa7Om6 RVsGLXxRGVlIkJTp0pJc+GfDzWtTXASAf0W+WSSJvpUHrGAHSiwx50cY+ru06HsD0ys+ JunKJhe1g2gxWifNz7ihXNJdGOat/FFwyPaL3UoEuxLi5QkU8ksLE+gEK2gIAcPzawOp BSFUsr6bdY8jjZJZ/gVfK4kkCIjtFjDj/84drEOHQwA4Dw0LDtnPRgIizCf89tg3HD2R KOEw== X-Gm-Message-State: AOJu0YzYd4NTt6eLygeZHt92ZSbMggICl/NY2prPYCxQ9KgpKfipFqfo 5rOlTixCatDEiD11vT+x0DhOaK4NtsgSGiT25pljuWoDTYY39E5LNSUy8EZNRC0W8RwpAR7Ggpw QPW+w5leHO5qzw45BnpCitdYYqHmdkntJ4i6AgIlb3SPeoQddLwDBYdfPsEdOOtEhw/Y9u3bFQC DhU5JO/HA= X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:d31b:c1a:fb6a:2488]) (user=almasrymina job=sendgmr) by 2002:a5b:783:0:b0:db5:4766:e363 with SMTP id b3-20020a5b0783000000b00db54766e363mr77867ybq.6.1702519534471; Wed, 13 Dec 2023 18:05:34 -0800 (PST) Date: Wed, 13 Dec 2023 18:05:23 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231214020530.2267499-1-almasrymina@google.com> Subject: [RFC PATCH net-next v1 0/4] Abstract page from net stack From: Mina Almasry To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Cc: Mina Almasry , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Greg Kroah-Hartman , "Rafael J. Wysocki" , Sumit Semwal , " =?utf-8?q?Christian_K=C3=B6nig?= " , Michael Chan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , Jeroen de Borst , Praveen Kaligineedi , Shailend Chand , Yisen Zhuang , Salil Mehta , Jesse Brandeburg , Tony Nguyen , Thomas Petazzoni , Marcin Wojtas , Russell King , Sunil Goutham , Geetha sowjanya , Subbaraya Sundeep , hariprasad , Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , Matthias Brugger , AngeloGioacchino Del Regno , Saeed Mahameed , Leon Romanovsky , Horatiu Vultur , UNGLinuxDriver@microchip.com, "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Jassi Brar , Ilias Apalodimas , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Siddharth Vadapalli , Ravi Gunasekaran , Roger Quadros , Jiawen Wu , Mengyuan Lou , Ronak Doshi , VMware PV-Drivers Reviewers , Ryder Lee , Shayne Chen , Kalle Valo , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Stefan Hajnoczi , Stefano Garzarella , Shuah Khan , " =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= " , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Jason Gunthorpe , Shakeel Butt , Yunsheng Lin , Willem de Bruijn X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Wed, 13 Dec 2023 18:05:41 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785221147522338175 X-GMAIL-MSGID: 1785221147522338175 Currently these components in the net stack use the struct page directly: 1. Drivers. 2. Page pool. 3. skb_frag_t. To add support for new (non struct page) memory types to the net stack, we must first abstract the current memory type. Originally the plan was to reuse struct page* for the new memory types, and to set the LSB on the page* to indicate it's not really a page. However, for safe compiler type checking we need to introduce a new type. struct netmem is introduced to abstract the underlying memory type. Currently it's a no-op abstraction that is always a struct page underneath. In parallel there is an undergoing effort to add support for devmem to the net stack: https://lore.kernel.org/netdev/20231208005250.2910004-1-almasrymina@google.com/ Cc: Jason Gunthorpe Cc: Christian König Cc: Shakeel Butt Cc: Yunsheng Lin Cc: Willem de Bruijn Mina Almasry (4): vsock/virtio: use skb_frag_page() helper net: introduce abstraction for network memory net: add netmem_t to skb_frag_t net: page_pool: use netmem_t instead of struct page in API drivers/net/ethernet/broadcom/bnxt/bnxt.c | 15 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 8 ++- drivers/net/ethernet/engleder/tsnep_main.c | 22 +++--- drivers/net/ethernet/freescale/fec_main.c | 33 ++++++--- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 14 ++-- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 2 +- drivers/net/ethernet/intel/idpf/idpf_txrx.h | 15 ++-- drivers/net/ethernet/marvell/mvneta.c | 24 ++++--- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 18 +++-- .../marvell/octeontx2/nic/otx2_common.c | 8 ++- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 22 +++--- .../net/ethernet/mellanox/mlx5/core/en/xdp.c | 27 ++++--- .../net/ethernet/mellanox/mlx5/core/en_rx.c | 28 ++++---- .../ethernet/microchip/lan966x/lan966x_fdma.c | 16 +++-- drivers/net/ethernet/microsoft/mana/mana_en.c | 10 +-- drivers/net/ethernet/socionext/netsec.c | 25 ++++--- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 48 ++++++++----- drivers/net/ethernet/ti/cpsw.c | 11 +-- drivers/net/ethernet/ti/cpsw_new.c | 11 +-- drivers/net/ethernet/ti/cpsw_priv.c | 12 ++-- drivers/net/ethernet/wangxun/libwx/wx_lib.c | 18 +++-- drivers/net/veth.c | 5 +- drivers/net/vmxnet3/vmxnet3_drv.c | 7 +- drivers/net/vmxnet3/vmxnet3_xdp.c | 20 +++--- drivers/net/wireless/mediatek/mt76/dma.c | 4 +- drivers/net/wireless/mediatek/mt76/mt76.h | 5 +- .../net/wireless/mediatek/mt76/mt7915/mmio.c | 4 +- drivers/net/xen-netfront.c | 4 +- include/linux/skbuff.h | 11 ++- include/net/netmem.h | 35 +++++++++ include/net/page_pool/helpers.h | 72 ++++++++++--------- include/net/page_pool/types.h | 9 +-- net/bpf/test_run.c | 2 +- net/core/page_pool.c | 39 +++++----- net/core/skbuff.c | 2 +- net/core/xdp.c | 3 +- net/kcm/kcmsock.c | 9 ++- net/vmw_vsock/virtio_transport.c | 2 +- 38 files changed, 381 insertions(+), 239 deletions(-) create mode 100644 include/net/netmem.h