From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3A35126BE2; Tue, 3 Sep 2024 20:57:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725397058; cv=none; b=ek51yhLEEAidHk+xn2kBcgw8hMnIY3OlQdbZp51J5PxVR7uB811HURXs13lDEznkOf0h31LJIw/5VFM4zfqKn1OYmgiqUdZUtJ7kTzXWi3kaFFplsuEXXk1B41L4a4JFoqaFLKaKyecuMb1YzAj89uYgnRYmkkQOo3OEEBBIUGg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725397058; c=relaxed/simple; bh=cjHxtsQ8zjzZhe7UJXgyGFidJuQT14w6eaGx7r1eCSo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pVsS2RkbzT8R7I9mxI7Rdqvk/xVmh1R+7E2lOblXUaR+7HwgRU2TAgbifK/q9bgVYsyja4hwZZvb2u8O0Lbr31vT++BgHePftSbap6Crxb814AZmgBIgWn7eG1neo3ClZYxviBd/dmv/ZnRhqh3PWPXfF3EfBIXEeoff9+gBMlQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UqWzmMFh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UqWzmMFh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC048C4CEC4; Tue, 3 Sep 2024 20:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725397057; bh=cjHxtsQ8zjzZhe7UJXgyGFidJuQT14w6eaGx7r1eCSo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UqWzmMFhPjIcEmGSRWqicfkG7opLjLFdfYbRLzJWYFZ56XS7lYB9xcUh/tAK3MWCF zDa5EiZgxmrrxEB9dshySBAWiE1sVqjaFCpFnlapq1quju9r2IHPF+qmSeUX0WbiQn LiOwEXFHf+nY2EQsXvzyksEyVPeH6gWkEjhV2wAlQC01I9w09b09qQHf5RWLFwlHiD HdeqtNF/1SS1CUjF0ku4mDPRtBSErvO8mjACuRJO55HZ3saLUM/hsBDo7Jerg7a5By zHYy4UpKL92L/xxZX0nq7CUx8WRaZpfCX5FtRDCLvzYWtx5wL4aBAoDpKHnfx4D6S/ /TvRrf9UwftRA== Date: Tue, 3 Sep 2024 13:57:33 -0700 From: Jakub Kicinski To: Mina Almasry Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, Donald Hunter , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , "=?UTF-8?B?QmrDtnJuIFTDtnBl?= =?UTF-8?B?bA==?=" , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Shuah Khan , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Sumit Semwal , "Christian =?UTF-8?B?S8O2bmln?=" , Pavel Begunkov , David Wei , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Bagas Sanjaya , Christoph Hellwig , Nikolay Aleksandrov , Taehee Yoo , Willem de Bruijn , Kaiyuan Zhang , Daniel Vetter Subject: Re: [PATCH net-next v24 03/13] netdev: support binding dma-buf to netdevice Message-ID: <20240903135733.53a83ce6@kernel.org> In-Reply-To: <20240831004313.3713467-4-almasrymina@google.com> References: <20240831004313.3713467-1-almasrymina@google.com> <20240831004313.3713467-4-almasrymina@google.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 31 Aug 2024 00:43:03 +0000 Mina Almasry wrote: > Add a netdev_dmabuf_binding struct which represents the > dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to > rx queues on the netdevice. On the binding, the dma_buf_attach > & dma_buf_map_attachment will occur. The entries in the sg_table from > mapping will be inserted into a genpool to make it ready > for allocation. > > The chunks in the genpool are owned by a dmabuf_chunk_owner struct which > holds the dma-buf offset of the base of the chunk and the dma_addr of > the chunk. Both are needed to use allocations that come from this chunk. > > We create a new type that represents an allocation from the genpool: > net_iov. We setup the net_iov allocation size in the > genpool to PAGE_SIZE for simplicity: to match the PAGE_SIZE normally > allocated by the page pool and given to the drivers. > > The user can unbind the dmabuf from the netdevice by closing the netlink > socket that established the binding. We do this so that the binding is > automatically unbound even if the userspace process crashes. > > The binding and unbinding leaves an indicator in struct netdev_rx_queue > that the given queue is bound, and the binding is actuated by resetting > the rx queue using the queue API. > > The netdev_dmabuf_binding struct is refcounted, and releases its > resources only when all the refs are released. Reviewed-by: Jakub Kicinski