Message ID | 20231217080913.2025973-3-almasrymina@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-2502-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp599340dyi; Sun, 17 Dec 2023 00:10:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRzqoehH1+EtAb2qjr/lnUtFJLP9FmUS1WSHnCgq1JIGcHoaI1nEODBGhEfLNSyG0Z8X42 X-Received: by 2002:a17:906:7487:b0:a23:533d:d6f9 with SMTP id e7-20020a170906748700b00a23533dd6f9mr64990ejl.140.1702800649489; Sun, 17 Dec 2023 00:10:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702800649; cv=none; d=google.com; s=arc-20160816; b=nFB+KuuG2NAqH3Jia3+5WqIZ4ysBLBjUd/ldC1X+XRtSWBV7/PVwGvjA+ufDAxlVkQ q/0iCb/P/Lu5gtpXgtf6AW9JrBdRxc6/Av/HyS1y2vREn2VqRgntD8jXV/OPLEdI0/cP 3NLaitAI0peQfjKY4nuKkfW7IEHwgFC8mCkHoT2T/odCRLirXIqgVJBxaJi0Yzoh7APH UXYbSN7Nzg0idZLDUaHBlqQUW2BwEIQWWFrvzLsCegVOdY/9b63bIRyCQZGexdB2q3Un k2kOYiWVrRmS0h/lCI0tyQ+vWkSuMFbYUNO6JaW8ZKSQBa5DYmh2llVfl5y5aJbCmaca vp8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=cjUSNe+bIsKYLrf1i8KK45ElvyWQbESYTUWNmf5dvpE=; fh=5+YZn3qid70ipf23l+1Skq9YU3IOegijAT5j4LrIkeM=; b=jAwUv+0WVv82TcOKLxCbRXYXNg/sqX669NBU/RMRNyDBWGsPQ7cmoToyJinh7hF8m5 y21Oo/9GNzvpe4WaQQTH+4htyFUEbHrr+4Akg8rA0GAcTtWEigvKi8DCRBhyOe48BF+V 5ywezfXBlS6osaeh4bX/LWGa6oHxPSw+/i8MPTGAcszRBIRyD643J/dGVd6TZgwmmyGd nYfC/FkDbT+vYjTfuLINggBLu6nTtqF/B/ZVktsNbNwUSQLGLDk22RuzyIrRhtlrHzGG hT6cHH8QVqrfwVBWrOnrH9kcjY9OH79gzAvpKUr+W4ufOm1xwl/QddeCqYEh/1INNKwU MOUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=XROIEh4b; spf=pass (google.com: domain of linux-kernel+bounces-2502-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2502-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qk12-20020a170906d9cc00b00a1cdf89bc57si8524597ejb.186.2023.12.17.00.10.49 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Dec 2023 00:10:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-2502-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=XROIEh4b; spf=pass (google.com: domain of linux-kernel+bounces-2502-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-2502-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 20E461F22274 for <ouuuleilei@gmail.com>; Sun, 17 Dec 2023 08:10:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F4CE7474; Sun, 17 Dec 2023 08:09:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XROIEh4b" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 6F63B3FD4 for <linux-kernel@vger.kernel.org>; Sun, 17 Dec 2023 08:09:23 +0000 (UTC) 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 Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-5d42c43d8daso19668647b3.0 for <linux-kernel@vger.kernel.org>; Sun, 17 Dec 2023 00:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702800562; x=1703405362; 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=cjUSNe+bIsKYLrf1i8KK45ElvyWQbESYTUWNmf5dvpE=; b=XROIEh4bGgdrndOSm9jbSvu/lJDWD00B4DbDZByFo/MxPcJ85or4uECojjFSkMK4ZD ibVrYGUmRtje4D7dI528n7428RlpqK066moAEOtiMdn20OC4eFceePYIoiG8BqQMf5cr FJwF3nPtM+Cqur/gtLfMWqC40KodwQvJNLxRMTXwL+XWLJbTBO6BS+x5dxAWztrlbMjZ 8q80Bzgbl9q2SWhT8i8mLL2HFbQhXooEY114ApKFg3KEariBeItyEKxoNS8TCqeE8hER m+a3KO8Xvi6+8xI6fg4KcsnZb0ixBdNFYjhsgtz6lRco5LuHWPOhfRvc+SpihSp5HlSO zQdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702800562; x=1703405362; 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=cjUSNe+bIsKYLrf1i8KK45ElvyWQbESYTUWNmf5dvpE=; b=A1+vhWgIbSLRZmM1SBIdAKBg6fidSwwdTuUNSys/nFOfSagM2cuaLPCAz7eiOsjM7o RJHMvathAncLFvJJZrOTsjdGFCmmnZgMsINEM4+dUlekOKydSgltw0soOiuugdYyVm1R ZvMqhSRcAQj+73ibJKNOCSYwbNYv9yEr6C1RyasTumHyok/NAPd4DxXvAo04wz2GzxmP BoiwHDebpa9XCWvISSQFsfNenZmPbSyyujygBHpjAk6TV6f1xfs+jW/a1z3Pt5Y4+Dps E3Q82NqUbLkIQqn8LA6VLWotncc0p1wCs1DW+PFYIv79QWbuoSsJwSnopDm5QWjRcvuH oHzQ== X-Gm-Message-State: AOJu0YxbLfHLsLUpF7o7AmSWYmCkucm00RTDnXftAb6guSsim+UsOYBj ALpx0sW+BcxFK7BpuHxlZiUlAp29pBvhH/7LwvWpXuJeGFIn38AEt4VYOhZnAeygD5gPeVl4kT8 zVGMXf+I17nGNHjFd/NPNBrXs5N+W3gGBiYEbt/PQqQj//oWkUOtWDtS60WjhkmP0eGry05moA4 X1q9MHK1g= X-Received: from almasrymina.svl.corp.google.com ([2620:15c:2c4:200:3eb4:e132:f78a:5ba9]) (user=almasrymina job=sendgmr) by 2002:a05:690c:2c83:b0:5e5:d445:d9a9 with SMTP id ep3-20020a05690c2c8300b005e5d445d9a9mr237216ywb.3.1702800562290; Sun, 17 Dec 2023 00:09:22 -0800 (PST) Date: Sun, 17 Dec 2023 00:09:10 -0800 In-Reply-To: <20231217080913.2025973-1-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20231217080913.2025973-1-almasrymina@google.com> X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231217080913.2025973-3-almasrymina@google.com> Subject: [PATCH net-next v2 2/3] net: introduce abstraction for network memory From: Mina Almasry <almasrymina@google.com> To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux.dev Cc: Mina Almasry <almasrymina@google.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Stefano Garzarella <sgarzare@redhat.com>, Jason Gunthorpe <jgg@nvidia.com>, " =?utf-8?q?Christian_K=C3=B6nig?= " <christian.koenig@amd.com>, Shakeel Butt <shakeelb@google.com>, Yunsheng Lin <linyunsheng@huawei.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785515893784812730 X-GMAIL-MSGID: 1785515893784812730 |
Series |
Abstract page from net stack
|
|
Commit Message
Mina Almasry
Dec. 17, 2023, 8:09 a.m. UTC
Add the netmem_t type, an abstraction for network memory.
To add support for new memory types to the net stack, we must first
abstract the current memory type from the net stack. Currently parts of
the net stack use struct page directly:
- page_pool
- drivers
- skb_frag_t
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 compiler type checking we need to introduce a new type.
netmem_t 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/
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
v2:
- Use container_of instead of a type cast (David).
---
include/net/netmem.h | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 include/net/netmem.h
diff --git a/include/net/netmem.h b/include/net/netmem.h new file mode 100644 index 000000000000..b60b00216704 --- /dev/null +++ b/include/net/netmem.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * netmem.h + * Author: Mina Almasry <almasrymina@google.com> + * Copyright (C) 2023 Google LLC + */ + +#ifndef _NET_NETMEM_H +#define _NET_NETMEM_H + +struct netmem { + union { + struct page page; + + /* Stub to prevent compiler implicitly converting from page* + * to netmem_t* and vice versa. + * + * Other memory type(s) net stack would like to support + * can be added to this union. + */ + void *addr; + }; +}; + +static inline struct page *netmem_to_page(struct netmem *netmem) +{ + return &netmem->page; +} + +static inline struct netmem *page_to_netmem(struct page *page) +{ + return container_of(page, struct netmem, page); +} + +#endif /* _NET_NETMEM_H */