net/core/devmem.h
Source file repositories/reference/linux-study-clean/net/core/devmem.h
File Facts
- System
- Linux kernel
- Corpus path
net/core/devmem.h- Extension
.h- Size
- 6737 bytes
- Lines
- 244
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/netmem.hnet/netdev_netlink.h
Detected Declarations
struct netlink_ext_ackstruct net_devmem_dmabuf_bindingstruct dmabuf_genpool_chunk_ownerstruct net_devmem_dmabuf_bindingfunction net_devmem_iov_to_chunk_ownerfunction net_devmem_iov_bindingfunction net_devmem_iov_binding_idfunction net_iov_virtual_addrfunction net_devmem_dmabuf_binding_getfunction net_devmem_dmabuf_binding_putfunction net_devmem_dmabuf_binding_putfunction net_devmem_unbind_dmabuffunction net_devmem_alloc_dmabuffunction net_devmem_free_dmabuffunction net_devmem_iov_binding_idfunction net_devmem_get_bindingfunction net_devmem_get_niov_atfunction net_devmem_iov_binding
Annotated Snippet
struct net_devmem_dmabuf_binding {
struct dma_buf *dmabuf;
struct dma_buf_attachment *attachment;
struct sg_table *sgt;
/* Physical NIC that does the actual DMA for this binding. */
struct net_device *dev;
/* Opaque cookie identifying the virtual device (e.g. netkit) the user
* called bind-tx on. Used only for pointer comparison. Never
* dereferenced.
*/
void *vdev;
struct gen_pool *chunk_pool;
/* Protect dev */
struct mutex lock;
/* The user holds a ref (via the netlink API) for as long as they want
* the binding to remain alive. Each page pool using this binding holds
* a ref to keep the binding alive. The page_pool does not release the
* ref until all the net_iovs allocated from this binding are released
* back to the page_pool.
*
* The binding undos itself and unmaps the underlying dmabuf once all
* those refs are dropped and the binding is no longer desired or in
* use.
*
* net_devmem_get_net_iov() on dmabuf net_iovs will increment this
* reference, making sure that the binding remains alive until all the
* net_iovs are no longer used. net_iovs allocated from this binding
* that are stuck in the TX path for any reason (such as awaiting
* retransmits) hold a reference to the binding until the skb holding
* them is freed.
*/
struct percpu_ref ref;
/* The list of bindings currently active. Used for netlink to notify us
* of the user dropping the bind.
*/
struct list_head list;
/* rxq's this binding is active on. */
struct xarray bound_rxqs;
/* ID of this binding. Globally unique to all bindings currently
* active.
*/
u32 id;
/* DMA direction, FROM_DEVICE for Rx binding, TO_DEVICE for Tx. */
enum dma_data_direction direction;
/* Array of net_iov pointers for this binding, sorted by virtual
* address. This array is convenient to map the virtual addresses to
* net_iovs in the TX path.
*/
struct net_iov **tx_vec;
struct work_struct unbind_w;
};
#if defined(CONFIG_NET_DEVMEM)
/* Owner of the dma-buf chunks inserted into the gen pool. Each scatterlist
* entry from the dmabuf is inserted into the genpool as a chunk, and needs
* this owner struct to keep track of some metadata necessary to create
* allocations from this chunk.
*/
struct dmabuf_genpool_chunk_owner {
struct net_iov_area area;
struct net_devmem_dmabuf_binding *binding;
/* dma_addr of the start of the chunk. */
dma_addr_t base_dma_addr;
};
void __net_devmem_dmabuf_binding_free(struct work_struct *wq);
struct net_devmem_dmabuf_binding *
net_devmem_bind_dmabuf(struct net_device *dev, void *vdev,
struct device *dma_dev,
enum dma_data_direction direction,
unsigned int dmabuf_fd, struct netdev_nl_sock *priv,
struct netlink_ext_ack *extack);
struct net_devmem_dmabuf_binding *net_devmem_lookup_dmabuf(u32 id);
void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *binding);
int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx,
struct net_devmem_dmabuf_binding *binding,
struct netlink_ext_ack *extack);
static inline struct dmabuf_genpool_chunk_owner *
net_devmem_iov_to_chunk_owner(const struct net_iov *niov)
{
struct net_iov_area *owner = net_iov_owner(niov);
Annotation
- Immediate include surface: `net/netmem.h`, `net/netdev_netlink.h`.
- Detected declarations: `struct netlink_ext_ack`, `struct net_devmem_dmabuf_binding`, `struct dmabuf_genpool_chunk_owner`, `struct net_devmem_dmabuf_binding`, `function net_devmem_iov_to_chunk_owner`, `function net_devmem_iov_binding`, `function net_devmem_iov_binding_id`, `function net_iov_virtual_addr`, `function net_devmem_dmabuf_binding_get`, `function net_devmem_dmabuf_binding_put`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.