From nobody Tue Jan 14 14:33:15 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D294D153BED for ; Mon, 9 Dec 2024 17:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764995; cv=none; b=SpBypz0sdT5PkL3DPmQviE8l/2+Odu4lkXUl3o9zuQmBQHDNuOf/nd8JnPYpMOr6c3oFhHs1sO+2uu0QEVTkEmtv8ZI857gdYEBa1it/H2JkjqEfInXoy9LX7wsGH0EYgB8BgFiJ7MbjSNGPmBDSSjkuc79+m8SXCWwWN0pMH40= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764995; c=relaxed/simple; bh=inYtJTadn/ilQufeg2hRjROOpb6WnuRJ/R3Eo2kT9Ak=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=aDum5rytqRjck85lYCkP7H99+ghqKsGSBNBFDqmmZJPj2FnFmc9YfMGsrHfU9AqV5pvt3MHoqPxJOJ+zb3EkfZkrH30gA3Uy31qXl8qzShUi5s/JKimqNq7RcmMDOUaH4vr4zb1PBx4JRvpxq2PqX9VMrji0wDCYVyFfbLvad9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Orq2XtT/; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Orq2XtT/" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef7fbd99a6so2262748a91.1 for ; Mon, 09 Dec 2024 09:23:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733764992; x=1734369792; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=rD4fHb5o8v+27TSL8zHXq3Z19Qh3ytPkt3LCpxEoKxE=; b=Orq2XtT/ERZSUjmtMsQzAA1Gw68J824uikYBYqoub078MfbsKcLSi3YJUkRFw1jpYx MIUOyAqWij26W5nMpzukQDiqB82hqF7eAmDTdO8q/tgMejRjVR96trbCIsEVFwYJchHa j5B84v/YJiDnZakJ3K2lsutaJNUZZFG1RD/9e2TnuezaIfaoRCuK7JFpr/fxQDREXC13 VooRM4uFI7IgNWzkZ5/e/WL0yS5qQaH8AnpPued8EXjwrFWM9a4LkAlo02bSjBkfHW6i jP1+rAHp5h1Wl2PjEm1brlVY5iTCNXRbFuZVtYz02Pn0jddRevgSzoa+NrBRd2lvheEO fLjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733764992; x=1734369792; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=rD4fHb5o8v+27TSL8zHXq3Z19Qh3ytPkt3LCpxEoKxE=; b=X0nq+GuHIWkPknBZzLo0FD87TCxHIO0bycreYYvEs6gTMx+0Hp6byD2Zu7SOhY9KDM 8oa9+3pqgYCT7l227X/Ybyfi2mrOtQ9ZlgcpQdQP6NNEme+4te1X6GCkHMd4AjooUsyv PoJX0cxDglKbktFqcs9/odcw6mASv+r3o0Gc7mJ3+AR8p+HXx8MTOutRFCPMyBF08tzH PZpIUHb620WloFEQfwmpvael7+rM4yWUVLzTzyp/zqY2S0RwcbQA+LrKsdGoG8NjG3mH WW/e+8riu/DQRltYlaOh+c2jA4mpfHpfMlrb8wnNI89kT6bz6U9VnsevnETt1H3+GvXX CNLg== X-Forwarded-Encrypted: i=1; AJvYcCXJD4KeCV+DgLnPBgIY/mS1Nv0KCZuMr1moJtVEXOLKtuUerWA6PN79d7cqUvMOxLpBie8RfzoehY1x7RI=@vger.kernel.org X-Gm-Message-State: AOJu0YyGKVujsVCFfnQf7wt1JclrJK+isx7OBXBnARtdXsTFFxrvT/K1 cX4+VL7OWN8yLr/0mCADDQPQmjABEBaSzIZHm1ya+USApctrE6nSh4MMWH/b3YYU6GpvU1gufpN 1yebNY8eq0SnLue7n0y7o6w== X-Google-Smtp-Source: AGHT+IF/gnzzxrq5wZW7Oq+BE9snOE5665TQRiKiXV7o1WW6Cds5d4hj9kPz8o9cXdP519d70WJqMsaDSx1ufbKdtw== X-Received: from pjbpv2.prod.google.com ([2002:a17:90b:3c82:b0:2ef:82a8:7171]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:50:b0:2ee:c797:e27f with SMTP id 98e67ed59e1d1-2ef6ab296e5mr18017086a91.36.1733764992288; Mon, 09 Dec 2024 09:23:12 -0800 (PST) Date: Mon, 9 Dec 2024 17:23:04 +0000 In-Reply-To: <20241209172308.1212819-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241209172308.1212819-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241209172308.1212819-2-almasrymina@google.com> Subject: [PATCH net-next v3 1/5] net: page_pool: rename page_pool_alloc_netmem to *_netmems From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Kaiyuan Zhang , Willem de Bruijn , Samiullah Khawaja , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Jesper Dangaard Brouer , Ilias Apalodimas , Stanislav Fomichev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" page_pool_alloc_netmem (without an s) was the mirror of page_pool_alloc_pages (with an s), which was confusing. Rename to page_pool_alloc_netmems so it's the mirror of page_pool_alloc_pages. Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev --- include/net/page_pool/types.h | 2 +- net/core/page_pool.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index 1ea16b0e9c79..bd1170e16cff 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -242,7 +242,7 @@ struct page_pool { }; =20 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp); -netmem_ref page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp); +netmem_ref page_pool_alloc_netmems(struct page_pool *pool, gfp_t gfp); struct page *page_pool_alloc_frag(struct page_pool *pool, unsigned int *of= fset, unsigned int size, gfp_t gfp); netmem_ref page_pool_alloc_frag_netmem(struct page_pool *pool, diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 4c85b77cfdac..3c0e19e13e64 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -574,7 +574,7 @@ static noinline netmem_ref __page_pool_alloc_pages_slow= (struct page_pool *pool, /* For using page_pool replace: alloc_pages() API calls, but provide * synchronization guarantee for allocation side. */ -netmem_ref page_pool_alloc_netmem(struct page_pool *pool, gfp_t gfp) +netmem_ref page_pool_alloc_netmems(struct page_pool *pool, gfp_t gfp) { netmem_ref netmem; =20 @@ -590,11 +590,11 @@ netmem_ref page_pool_alloc_netmem(struct page_pool *p= ool, gfp_t gfp) netmem =3D __page_pool_alloc_pages_slow(pool, gfp); return netmem; } -EXPORT_SYMBOL(page_pool_alloc_netmem); +EXPORT_SYMBOL(page_pool_alloc_netmems); =20 struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp) { - return netmem_to_page(page_pool_alloc_netmem(pool, gfp)); + return netmem_to_page(page_pool_alloc_netmems(pool, gfp)); } EXPORT_SYMBOL(page_pool_alloc_pages); ALLOW_ERROR_INJECTION(page_pool_alloc_pages, NULL); @@ -957,7 +957,7 @@ netmem_ref page_pool_alloc_frag_netmem(struct page_pool= *pool, } =20 if (!netmem) { - netmem =3D page_pool_alloc_netmem(pool, gfp); + netmem =3D page_pool_alloc_netmems(pool, gfp); if (unlikely(!netmem)) { pool->frag_page =3D 0; return 0; --=20 2.47.0.338.g60cca15819-goog From nobody Tue Jan 14 14:33:15 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5BD4155C8A for ; Mon, 9 Dec 2024 17:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764996; cv=none; b=KtAjDWgdYFgWI7ThIfWfyAyQJZ7y94lKNe0qxCeAtFeyVusu053+xbf55El+aga7bwerewLHyIkmdeMHzXVPQqXbxk438Vg8NzSUrUS0QR9O7SO5RBVvC5kok9E2pGZUn2LOUclfzNvEyKXa0Yh+9gglaf5hj0mhu5R0nnvQf7w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764996; c=relaxed/simple; bh=lQfAFg7vJgxi9OjV7bauJ/1kar4rQKjYUxhdr7gNz1k=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r2pm3SIzhdkenK3QLCs0xmHTsayfyF4IyC8RRcXSEgzJ80Mqeo2Y4Qb3SOvX339KSbabdKAqKxB4asfchl5Dqi2SL86PcQrOIVmUnne05HFtNd9bRu8+UWS4jQ0sDZbJmWSCkDsUB6TJCdnZuQUn7Zx6kBlrzVO6lb+XqAphTIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=vNwLd3QY; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vNwLd3QY" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-216387ddda8so15332125ad.3 for ; Mon, 09 Dec 2024 09:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733764994; x=1734369794; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=nE0FAhiHaVprqthAMs1Dt/qkIqw0SXPDfEZZnxfWrQY=; b=vNwLd3QYoxul29btk5FKhqRyB4Su2Sha5BCLBu/N4LN3YA2Eoyf3Yw2WYuC/rL3RkJ G7L7hbFmqW3SadjRXiEcxK9bVuoT0EXom5qcyAVuIVN5zRQFZrrBnbcrN8FFogyH7qG7 A79Rf1bppg2K6E+R118lVTxUI15GDIcUH3ErKPx/n2FFNUv/KjXmsfwIIQnnYXcHbji3 gs9xGdWmoTuTAZ6wjlqTqaMFWJw90scVBXH2l9bo5nARvpPdwbz7vLFhW85zzZ0OF8oD b1PTPZg4ZuIQQLnCy81wBqLpsT4iT0oYm8K7aNkJNhaAEhcB2KYIyysGxO+pEZM9jhs2 w/WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733764994; x=1734369794; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=nE0FAhiHaVprqthAMs1Dt/qkIqw0SXPDfEZZnxfWrQY=; b=D9RPkiKo0DdpIkeBUgoOodma0hkzYuHfSNd6v9kuzzFvrLwViNortgUg+XOtQakRkY +DPRMYQ4T2W00HMwCTfN/owBJKiSkUpLEGba82Yn7VKlSVfqVqxXbiEMg5F9Ie/KelIq TA9WN+QVgJflX25NyS8Ml518qQ7we8PqLtQX6dXIKoGUds2BZ/rMUZBR35V/yQZYHK+K q/2dBpa5FDHh2vmTYzEQrG7pHU6UARMpzggpnLIx7jvfk5Fax+hZIcSQhjVc/HRhv3N+ bz3RsAPJnXejlUbW7qwGFr8cfbq5N+aja+YMZHGEHEi0V1/2v/WfKDZqPPne93JPGHZ4 s2Cg== X-Forwarded-Encrypted: i=1; AJvYcCUdIEgCacdKY5YA1YBQ2HnZPqP6/bgINI5RrcOLpJBOylXthxtHiCZeJNL+K/ByloZ6F9m/eO2J2ouQKIs=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5JaNz31nxWgkeS9+/PKfDFWQTkqeFTQGLxsWWo1VRjaV4r4Mu UycKOt4sA91X0j5hmc3td25P9Rihzi4dW/FNwyrI0Xwm49GYS5RXuXS4+lhWmlRPbci1JoWF6o4 lIkYIxsMWYV7YfgH2PsE0oQ== X-Google-Smtp-Source: AGHT+IFCo5TbvvYzh/ha90pLeOQqK6P9Tb30kFFDIMqZP/IEwwYWLejUgQjCQbcWae6bZ1ydijSIcF6G8vl7/+Coag== X-Received: from pljj21.prod.google.com ([2002:a17:902:c3d5:b0:212:4d11:70f5]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:c40d:b0:215:e98c:c5c1 with SMTP id d9443c01a7336-21614d5f937mr203578225ad.30.1733764993940; Mon, 09 Dec 2024 09:23:13 -0800 (PST) Date: Mon, 9 Dec 2024 17:23:05 +0000 In-Reply-To: <20241209172308.1212819-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241209172308.1212819-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241209172308.1212819-3-almasrymina@google.com> Subject: [PATCH net-next v3 2/5] net: page_pool: create page_pool_alloc_netmem From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Kaiyuan Zhang , Willem de Bruijn , Samiullah Khawaja , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Jesper Dangaard Brouer , Ilias Apalodimas , Stanislav Fomichev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Create page_pool_alloc_netmem to be the mirror of page_pool_alloc. This enables drivers that want currently use page_pool_alloc to transition to netmem by converting the call sites to page_pool_alloc_netmem. Signed-off-by: Mina Almasry Acked-by: Stanislav Fomichev --- include/net/page_pool/helpers.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helper= s.h index 793e6fd78bc5..8e548ff3044c 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -116,22 +116,22 @@ static inline struct page *page_pool_dev_alloc_frag(s= truct page_pool *pool, return page_pool_alloc_frag(pool, offset, size, gfp); } =20 -static inline struct page *page_pool_alloc(struct page_pool *pool, - unsigned int *offset, - unsigned int *size, gfp_t gfp) +static inline netmem_ref page_pool_alloc_netmem(struct page_pool *pool, + unsigned int *offset, + unsigned int *size, gfp_t gfp) { unsigned int max_size =3D PAGE_SIZE << pool->p.order; - struct page *page; + netmem_ref netmem; =20 if ((*size << 1) > max_size) { *size =3D max_size; *offset =3D 0; - return page_pool_alloc_pages(pool, gfp); + return page_pool_alloc_netmems(pool, gfp); } =20 - page =3D page_pool_alloc_frag(pool, offset, *size, gfp); - if (unlikely(!page)) - return NULL; + netmem =3D page_pool_alloc_frag_netmem(pool, offset, *size, gfp); + if (unlikely(!netmem)) + return 0; =20 /* There is very likely not enough space for another fragment, so append * the remaining size to the current fragment to avoid truesize @@ -142,7 +142,14 @@ static inline struct page *page_pool_alloc(struct page= _pool *pool, pool->frag_offset =3D max_size; } =20 - return page; + return netmem; +} + +static inline struct page *page_pool_alloc(struct page_pool *pool, + unsigned int *offset, + unsigned int *size, gfp_t gfp) +{ + return netmem_to_page(page_pool_alloc_netmem(pool, offset, size, gfp)); } =20 /** --=20 2.47.0.338.g60cca15819-goog From nobody Tue Jan 14 14:33:15 2025 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45C4B1B040D for ; Mon, 9 Dec 2024 17:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764997; cv=none; b=E1zHEogowSFE7prWC/CcITTHdR8OfdQ1WgsPnIRl7Zs4buYccpZml8oHWK1G26R/k++jvSdtiIdLVTBIHzhqKPVeWt/oZIWDCO6IZ3ssxMFYpCNJeW/vV3+F7CoTbsLVhWiGGSCiQqoKcXFjoPrMVjewYvzKvb3xF3tjnj89qOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764997; c=relaxed/simple; bh=RqJl83u5mUsQ1GGoNFG7LwEJNTXhU11e4cYe3HNOEy0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uxcKPOo9CUGO4AF2rvb59tbmAYDDCMWoxQLoaATz8zP0Iqrw9mC0i+k3LIuhhIbyI/YkVw0jHo6JVqsjwzYlYJrFCxy7J0yluydUYSVa/Q2/I0ZEGxJQEE/bkn30wJeEB0WqiuYMqPJ445uk4ix6TJ6WYHjgcmSGjMEsf3+FVYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=pEEVEtWf; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pEEVEtWf" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-2ef6ef9ba3fso3079061a91.2 for ; Mon, 09 Dec 2024 09:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733764995; x=1734369795; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Mz5RWYLKjoPvLP8MJgn8eUAzuErak4lvg0fVmbsg4yk=; b=pEEVEtWfb2MmbsnwcYCnWPtbnkoGDomW/KARFcceOysPQS1bloHXb5E0YRcDis7qw0 Kc1UQk3E+kfzskUeFx8OMZwhBjFcin6tV9b/KcyWC04apLP8AN2BBjtbbxUPi0AGs0Az O5Mq79poS0BxAijG/EqrQL12bWAI5a6GcLVYm+IyPWFG/iHB8cTxoEuwCGrNDHW0YpcZ WXKjcpu1VMNO3bc15tW/oQNyriJWhVpdxK0FoZn/4vc/Ldxcw/g47TPmLOy5ScsM+k7b CppNcvWyuZvGaqEx37gIeRNEfWvuySEfHvHjPmca+But0T98oSXBmZq/J2JraxfFxij6 u/Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733764995; x=1734369795; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Mz5RWYLKjoPvLP8MJgn8eUAzuErak4lvg0fVmbsg4yk=; b=qjL/fxkrf8je915qHSirEul1hMittLr2fv6nEdNiFddSgVCnBCB5Jyzv3jTrlQSqoL OLMXucoU5Xu3Dp8qL3XO7+11PBzaoMK9j+SjcHZgwpMIeBHXsULge18gFvr5fmYOd8p5 2Zzxst4wyqpfBmIf7EcrA1MoP1Sk2NiA5VKV9gbFyeTqnL4WhFRPgim52LmaH36K0S6s vbaMsWzbLq/0KOEz6TG6ZO+Gr/yDeqrpw145yaez7OExd0INioEFayZgEQPQO9a/Xdq/ A+/EAbH5fgE4VFYeSAPXILyERb+UMPrYTr4yqwSD3yqHi01mZQmjcoCmNUHQZSo0+jyY VzSg== X-Forwarded-Encrypted: i=1; AJvYcCVXBreG7hm4oC7OR7h+aeLWv9+xoRXfgKo8CrXePVEEouZH2u5aBE7S07IF9IYIeS1fPwIE7hlg2u/fzCc=@vger.kernel.org X-Gm-Message-State: AOJu0YxTMrOEFZFu8hBfLf9AWVCtMuTdD2gPLcHRp8TWAk4cO+aJqdeU SKNWvGcio63mYYEKwz3a48pbAUYqkDYBV1RxSOFbNvqgZBbVn4XregqCUM4xu7Kj8j/vhjoAl3y NONYFX2naqeYXCK7hYdYb0Q== X-Google-Smtp-Source: AGHT+IEPftCb4Wma3I6ceQ+nMsGCVDlESSWU7yvIQd8cUNgRVcxZksTsHMKUHY+m3zByd0dJJtyL5yltuD+o/Xbo/Q== X-Received: from pjuw15.prod.google.com ([2002:a17:90a:d60f:b0:2ef:977f:1108]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1d52:b0:2ee:f22a:61dd with SMTP id 98e67ed59e1d1-2efcf26e18fmr1739112a91.32.1733764995640; Mon, 09 Dec 2024 09:23:15 -0800 (PST) Date: Mon, 9 Dec 2024 17:23:06 +0000 In-Reply-To: <20241209172308.1212819-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241209172308.1212819-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241209172308.1212819-4-almasrymina@google.com> Subject: [PATCH net-next v3 3/5] page_pool: Set `dma_sync` to false for devmem memory provider From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Kaiyuan Zhang , Willem de Bruijn , Samiullah Khawaja , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Jesper Dangaard Brouer , Ilias Apalodimas , Jason Gunthorpe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Samiullah Khawaja Move the `dma_map` and `dma_sync` checks to `page_pool_init` to make them generic. Set dma_sync to false for devmem memory provider because the dma_sync APIs should not be used for dma_buf backed devmem memory provider. Cc: Jason Gunthorpe Signed-off-by: Samiullah Khawaja Signed-off-by: Mina Almasry --- net/core/devmem.c | 9 ++++----- net/core/page_pool.c | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/net/core/devmem.c b/net/core/devmem.c index 11b91c12ee11..826d0b00159f 100644 --- a/net/core/devmem.c +++ b/net/core/devmem.c @@ -331,11 +331,10 @@ int mp_dmabuf_devmem_init(struct page_pool *pool) if (!binding) return -EINVAL; =20 - if (!pool->dma_map) - return -EOPNOTSUPP; - - if (pool->dma_sync) - return -EOPNOTSUPP; + /* dma-buf dma addresses should not be used with + * dma_sync_for_cpu/device. Force disable dma_sync. + */ + pool->dma_sync =3D false; =20 if (pool->p.order !=3D 0) return -E2BIG; diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 3c0e19e13e64..060450082342 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -287,6 +287,9 @@ static int page_pool_init(struct page_pool *pool, } =20 if (pool->mp_priv) { + if (!pool->dma_map || !pool->dma_sync) + return -EOPNOTSUPP; + err =3D mp_dmabuf_devmem_init(pool); if (err) { pr_warn("%s() mem-provider init failed %d\n", __func__, --=20 2.47.0.338.g60cca15819-goog From nobody Tue Jan 14 14:33:15 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25E421C5CB3 for ; Mon, 9 Dec 2024 17:23:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764999; cv=none; b=YkMUl3HHpw+JeeOJ1wbu1jaWfDjSvSBqH18cC/0Xmd6+vJm/d3kNKHK96UvokyA+j59mkMnvqO/oui1y0iTbL2q0UHIivvgwXX5HFdrNzzmJpoLFqWMqp/Lj3lTu4Nt2mhqI97QpwY99kfq+TuWD9TRTvzZB5SjtPLbGlUAHvkk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733764999; c=relaxed/simple; bh=y+0q7ecX2wfaSQV7x9AchYm6ieZy/G+mBf9VGu8ONlY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=EJhRsTbYZH0S9Znfkk3crsW0koL9jcVW7J+NC/X1YO2gUwdv3p18oHjbF4jWHwSBUFWLdmSqVbpwcsFvWa5BbVzePKChRsnqHvm+Zh/aX3y115n6FWBT5QLHzd2feM+55yQTD7oJZapcTRBN8VIPKn9KMZciE8M5JksPPlZqFB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SHJs3bmg; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SHJs3bmg" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2166464e236so8303245ad.1 for ; Mon, 09 Dec 2024 09:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733764997; x=1734369797; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=CEh1qYJ/M3HaDxH8qCrcRAqwO6cCUt0cVdPWB5Prhx0=; b=SHJs3bmgl2cB0JZqcqagGJO+E83vGRMPHyZG396n7NfZhMrxm75zhkKmyG7g7x6S/O 9TYRUXScKSVuQ+c7/I4DE3PU5Q4N4136scn87HtHjS25KS/ClfHXQT5CC1EdBavib7zR BMF81G/Q6Exo8wbmxFVESFbQRwB+xnv9z89OXlvHQPOTPtA9ulmeWamG+wmZRqV4pXKi TUqXcXQA39SAO3vhXSKpgSy5LNywLask9SEH7epCnAoTp6JdpY6W2IAWCZOBU3lFxTfK U2sat8PyrZa8NvPxPXb5d4RLC6WSfsVElWeYOg1uA5S05xuXRUDO83m3p+DzU1QelYEJ KJzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733764997; x=1734369797; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CEh1qYJ/M3HaDxH8qCrcRAqwO6cCUt0cVdPWB5Prhx0=; b=ATLxobqT/eWrl9EeCQ3O6Ga3/Dokj7uBFhNb47zPZstjdL5qEgTwhzoXakCj+nQqhW Cdf+vbayQRUQ8y0vjjGl7cPHotpo2e0eJVijHvQknqnZb0+8lvFkmYWZtQ8hg1WocDiP UN+VgxKpSP5/UTNKW1Xo2spXxJ1MQ6HEg/0ysvLK8J/qbUBU9Luwpn7Xt+h/4eiJWlPK cDiVCLgiVEbhDpFW2blIM4qsKsigKYeMDXso0gUyX+EB/XAWMSMTvVsG9u4mwoApHrW/ ac720hSJ6LuJCeBiyMghoViccqBoYgKnl6ObvY4HBu7UomAY5cGDAz+DjjpdWp4HSDei kaZA== X-Forwarded-Encrypted: i=1; AJvYcCWKKo7uGhTiV6iDtPy10AtSbbWVWR9RRVYmIVjhuMpHTYzXsqqbRxxiplKOtEdqsSGBVCeZkc4T3w88J1g=@vger.kernel.org X-Gm-Message-State: AOJu0YyniACjQM1sVOyxxBbcI1mkYJHKVXBoilhLx8JdIQaOnyNijSBz iQ6s6thEpMCLWzPypMKqyQ4sxBWWgh2AxYAhRYRuou5mptFDDXI6swojoGTN0sx249fOUPBtsKg fPuBd+TgAWMjC8H7DC6tFdw== X-Google-Smtp-Source: AGHT+IE6zUeqCaOyPCPklZj3KhVRjOXzVz21jDuksCVu1g7fyKjAxUFvqujb6+uRlACw/CE7XgWaGIQwyzBhd7b9wQ== X-Received: from plru4.prod.google.com ([2002:a17:902:b284:b0:215:94db:1290]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2447:b0:216:3d72:1712 with SMTP id d9443c01a7336-2166a0a0bb1mr18781945ad.48.1733764997374; Mon, 09 Dec 2024 09:23:17 -0800 (PST) Date: Mon, 9 Dec 2024 17:23:07 +0000 In-Reply-To: <20241209172308.1212819-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241209172308.1212819-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241209172308.1212819-5-almasrymina@google.com> Subject: [PATCH net-next v3 4/5] page_pool: disable sync for cpu for dmabuf memory provider From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Kaiyuan Zhang , Willem de Bruijn , Samiullah Khawaja , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Jesper Dangaard Brouer , Ilias Apalodimas , Jason Gunthorpe Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" dmabuf dma-addresses should not be dma_sync'd for CPU/device. Typically its the driver responsibility to dma_sync for CPU, but the driver should not dma_sync for CPU if the netmem is actually coming from a dmabuf memory provider. The page_pool already exposes a helper for dma_sync_for_cpu: page_pool_dma_sync_for_cpu. Upgrade this existing helper to handle netmem, and have it skip dma_sync if the memory is from a dmabuf memory provider. Drivers should migrate to using this helper when adding support for netmem. Cc: Jason Gunthorpe Signed-off-by: Mina Almasry --- include/net/page_pool/helpers.h | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helper= s.h index 8e548ff3044c..ad4fed4a791c 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -429,9 +429,10 @@ static inline dma_addr_t page_pool_get_dma_addr(const = struct page *page) } =20 /** - * page_pool_dma_sync_for_cpu - sync Rx page for CPU after it's written by= HW + * page_pool_dma_sync_netmem_for_cpu - sync Rx page for CPU after it's wri= tten + * by HW * @pool: &page_pool the @page belongs to - * @page: page to sync + * @netmem: netmem to sync * @offset: offset from page start to "hard" start if using PP frags * @dma_sync_size: size of the data written to the page * @@ -440,16 +441,28 @@ static inline dma_addr_t page_pool_get_dma_addr(const= struct page *page) * Note that this version performs DMA sync unconditionally, even if the * associated PP doesn't perform sync-for-device. */ -static inline void page_pool_dma_sync_for_cpu(const struct page_pool *pool, - const struct page *page, - u32 offset, u32 dma_sync_size) +static inline void +page_pool_dma_sync_netmem_for_cpu(const struct page_pool *pool, + const netmem_ref netmem, u32 offset, + u32 dma_sync_size) { + if (pool->mp_priv) + return; + dma_sync_single_range_for_cpu(pool->p.dev, - page_pool_get_dma_addr(page), + page_pool_get_dma_addr_netmem(netmem), offset + pool->p.offset, dma_sync_size, page_pool_get_dma_dir(pool)); } =20 +static inline void page_pool_dma_sync_for_cpu(const struct page_pool *pool, + struct page *page, u32 offset, + u32 dma_sync_size) +{ + page_pool_dma_sync_netmem_for_cpu(pool, page_to_netmem(page), offset, + dma_sync_size); +} + static inline bool page_pool_put(struct page_pool *pool) { return refcount_dec_and_test(&pool->user_cnt); --=20 2.47.0.338.g60cca15819-goog From nobody Tue Jan 14 14:33:15 2025 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B78E21E9B23 for ; Mon, 9 Dec 2024 17:23:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733765002; cv=none; b=j55foGNo3nfPPxP2BTuPpRRPZW0lgJe++HcsEREuBEg7sKpEyv9syBg+ovxNND61zq3ge9Dz7oSDmk/0R8x0tLxAwIwdJ5MdgGIpEGKFPpEJWgHe3OWSUoTEnBvtw49Vlpcs0bGMsnFy5o1L/5IcP0gXI/5dqx51iJYq1emx+Fg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733765002; c=relaxed/simple; bh=bFEBgpIHiRCRmFB13zC6eRwjOnKNB5aS9cu/gmZUysw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gsU98lVdDOXScW6g2fUARhw0SoTdMruAWqaml/dA8ljwdwliJlFuhvRuSRkD5YDpoA+a0/5d95TU+Dtl9AufY/2HL24cifkg/0Ais+fxKZtxFuQ8yXegqC6rwWmnJQfztxs6MJuC7Qhu2zvx6yREnzrUhAHN5uORHrJQ36U1MzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Ek74C0ud; arc=none smtp.client-ip=209.85.210.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--almasrymina.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Ek74C0ud" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-72522df68a9so3733292b3a.2 for ; Mon, 09 Dec 2024 09:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1733764999; x=1734369799; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZQM2k5Y0cRnDWnUVVFZNmxP5ATTgTt6xLxZwaHOB548=; b=Ek74C0udRt0UTgoKRR9I3IQWjcvoCd0RQhaxTKY/aMxU+mqN6VRcsb9EM1tswTsdlS q5qPIDVj9K7MRqNKw1eVQRtlmpNU2XG+kuwFVu1giljiagxxGpiPAmeo1ovUExb+rA6L b+JD0jAQITs4blc8MTaD0VUELa5iVgnWpEKSZ2SDPnMn4Bf0nat/gwAkEVx9BXMW8Swy /au6ElFrnJ1fRzUBynm5M0j3+Guiqc9ArUc+Hbuaj29GMLv0f10uL8aa5sRYLIO4HJKb jrLEz72M6eenORG4lMJAxZ43iB0uzLeM1u8xPw/6jBKm1Bel+P3+ERmu5XYVrLn9FxxJ xkEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733764999; x=1734369799; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZQM2k5Y0cRnDWnUVVFZNmxP5ATTgTt6xLxZwaHOB548=; b=apMFvjr/WDWpJJtiEADDMSeOLL9KQcFZSdLmfKF9vEEU0p5bcX7x5kXVUMGKVIOmRK XukF1vw+SN9rEhhprudSUdVPqYpei7sdKB63waOYPLN59NkYDRIh2i5ykih41eB2+vQU ERJ2/eD9UqYDvx6GfrJNI8OTo6IfH5ZkVz0sEE+7Fj2TACVV3cqjGIA/q81prCmeAXLo E5SIqeWD5+5phuE3v4p/OTGh7I2ymoK79NCji+Pq3krDpSs2ZdVfOM8ghqsYSH4aRnB/ oGXXEMIJqvUPv0OmUFYrE5f0UJDD7ExxmnOb2ipRxLoL7IbMQAAP5mSfKTaT5z843iw/ T4/w== X-Forwarded-Encrypted: i=1; AJvYcCX/KqvZVfioZi8efhaw/oeICRGFesnb2fUhRFLNhlLGH9Sz5YtIIDrsoDwXU52+xmvo4++QUpksw8vu0UI=@vger.kernel.org X-Gm-Message-State: AOJu0Yzd6OHDCFXDJ7OzGOORZSERpBWvPJsPk3ggJLOFd6EIRw+JdUIq /PHADR8GT2MLhrus1BySpH1b1jgnlDMVyaqKaY9r1SPdQ2QJ1T6rc/mFPgcmPLUfEgDPUmFlg/o hNa4Bd3fYxam4Jg/qgsffYw== X-Google-Smtp-Source: AGHT+IHhNfJnVxuwnv9R4A+XXQzrx5pGpdsPzg0HIN1/IqhP/Lrmy6fFprFKab30nIaRS6AD+E2szGiPyRTX4XDhXA== X-Received: from pfbc2.prod.google.com ([2002:a05:6a00:ad02:b0:725:b17b:24bd]) (user=almasrymina job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:22c6:b0:725:9edd:dc30 with SMTP id d2e1a72fcca58-7273cb1af91mr1635221b3a.12.1733764999141; Mon, 09 Dec 2024 09:23:19 -0800 (PST) Date: Mon, 9 Dec 2024 17:23:08 +0000 In-Reply-To: <20241209172308.1212819-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20241209172308.1212819-1-almasrymina@google.com> X-Mailer: git-send-email 2.47.0.338.g60cca15819-goog Message-ID: <20241209172308.1212819-6-almasrymina@google.com> Subject: [PATCH net-next v3 5/5] net: Document memory provider driver support From: Mina Almasry To: netdev@vger.kernel.org, Jakub Kicinski , Mina Almasry , Pavel Begunkov , Kaiyuan Zhang , Willem de Bruijn , Samiullah Khawaja , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Simon Horman , Jonathan Corbet , Jesper Dangaard Brouer , Ilias Apalodimas Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document expectations from drivers looking to add support for device memory tcp or other memory provider based features. Signed-off-by: Mina Almasry --- Documentation/networking/index.rst | 1 + Documentation/networking/memory-provider.rst | 52 ++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 Documentation/networking/memory-provider.rst diff --git a/Documentation/networking/index.rst b/Documentation/networking/= index.rst index 46c178e564b3..c184e86a6ce1 100644 --- a/Documentation/networking/index.rst +++ b/Documentation/networking/index.rst @@ -73,6 +73,7 @@ Contents: l2tp lapb-module mac80211-injection + memory-provider mctp mpls-sysctl mptcp diff --git a/Documentation/networking/memory-provider.rst b/Documentation/n= etworking/memory-provider.rst new file mode 100644 index 000000000000..4eee3b01eb18 --- /dev/null +++ b/Documentation/networking/memory-provider.rst @@ -0,0 +1,52 @@ +.. SPDX-License-Identifier: GPL-2.0 + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Memory providers +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +Intro +=3D=3D=3D=3D=3D + +Device memory TCP, and likely more upcoming features, are reliant in memory +provider support in the driver. + + +Driver support +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +1. The driver must support page_pool. The driver must not do its own recyc= ling + on top of page_pool. + +2. The driver must support tcp-data-split ethtool option. + +3. The driver must use the page_pool netmem APIs. The netmem APIs are + currently 1-to-1 mapped with page APIs. Conversion to netmem should be + achievable by switching the page APIs to netmem APIs and tracking memor= y via + netmem_refs in the driver rather than struct page * : + + - page_pool_alloc -> page_pool_alloc_netmem + - page_pool_get_dma_addr -> page_pool_get_dma_addr_netmem + - page_pool_put_page -> page_pool_put_netmem + + Not all page APIs have netmem equivalents at the moment. If your driver + relies on a missing netmem API, feel free to add and propose to netdev@= or + reach out to almasrymina@google.com for help adding the netmem API. + +4. The driver must use the following PP_FLAGS: + + - PP_FLAG_DMA_MAP: netmem is not dma mappable by the driver. The driver + must delegate the dma mapping to the page_pool. + - PP_FLAG_DMA_SYNC_DEV: netmem dma addr is not necessarily dma-syncable + by the driver. The driver must delegate the dma syncing to the page_p= ool. + - PP_FLAG_ALLOW_UNREADABLE_NETMEM. The driver must specify this flag iff + tcp-data-split is enabled. In this case the netmem allocated by the + page_pool may be unreadable, and netmem_address() will return NULL to + indicate that. The driver must not assume that the netmem is readable. + +5. The driver must use page_pool_dma_sync_netmem_for_cpu() in lieu of + dma_sync_single_range_for_cpu(). For some memory providers, dma_syncing= for + CPU will be done by the page_pool, for others (particularly dmabuf memo= ry + provider), dma syncing for CPU is the responsibility of the userspace u= sing + dmabuf APIs. The driver must delegate the entire dma-syncing operation = to + the page_pool which will do it correctly. --=20 2.47.0.338.g60cca15819-goog