net/core/netdev_rx_queue.c
Source file repositories/reference/linux-study-clean/net/core/netdev_rx_queue.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/netdev_rx_queue.c- Extension
.c- Size
- 9713 bytes
- Lines
- 350
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/ethtool_netlink.hlinux/netdevice.hnet/netdev_lock.hnet/netdev_queues.hnet/netdev_rx_queue.hnet/page_pool/memory_provider.hdev.hpage_pool_priv.h
Detected Declarations
function netdev_rx_queue_leasefunction netdev_rx_queue_unleasefunction netif_rxq_is_leasedfunction netif_lease_dir_okfunction netif_is_queue_leaseefunction __netif_get_rx_queue_leasefunction netif_rxq_has_unreadable_mpfunction netif_rxq_has_mpfunction netdev_rx_queue_reconfigfunction netdev_rx_queue_restartfunction __netif_mp_open_rxqfunction netif_mp_open_rxqfunction __netif_mp_close_rxqfunction netif_mp_close_rxqfunction __netif_mp_uninstall_rxqfunction netif_rxq_cleanup_unleaseexport netif_rxq_has_unreadable_mp
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
#include <linux/ethtool_netlink.h>
#include <linux/netdevice.h>
#include <net/netdev_lock.h>
#include <net/netdev_queues.h>
#include <net/netdev_rx_queue.h>
#include <net/page_pool/memory_provider.h>
#include "dev.h"
#include "page_pool_priv.h"
void netdev_rx_queue_lease(struct netdev_rx_queue *rxq_dst,
struct netdev_rx_queue *rxq_src)
{
netdev_assert_locked(rxq_src->dev);
netdev_assert_locked(rxq_dst->dev);
netdev_hold(rxq_src->dev, &rxq_src->lease_tracker, GFP_KERNEL);
WRITE_ONCE(rxq_src->lease, rxq_dst);
WRITE_ONCE(rxq_dst->lease, rxq_src);
}
void netdev_rx_queue_unlease(struct netdev_rx_queue *rxq_dst,
struct netdev_rx_queue *rxq_src)
{
netdev_assert_locked(rxq_dst->dev);
netdev_assert_locked(rxq_src->dev);
netif_rxq_cleanup_unlease(rxq_src, rxq_dst);
WRITE_ONCE(rxq_src->lease, NULL);
WRITE_ONCE(rxq_dst->lease, NULL);
netdev_put(rxq_src->dev, &rxq_src->lease_tracker);
}
bool netif_rxq_is_leased(struct net_device *dev, unsigned int rxq_idx)
{
if (rxq_idx < dev->real_num_rx_queues)
return READ_ONCE(__netif_get_rx_queue(dev, rxq_idx)->lease);
return false;
}
/* Virtual devices eligible for leasing have no dev->dev.parent, while
* physical devices always have one. Use this to enforce the correct
* lease traversal direction.
*/
static bool netif_lease_dir_ok(const struct net_device *dev,
enum netif_lease_dir dir)
{
if (dir == NETIF_VIRT_TO_PHYS && !dev->dev.parent)
return true;
if (dir == NETIF_PHYS_TO_VIRT && dev->dev.parent)
return true;
return false;
}
bool netif_is_queue_leasee(const struct net_device *dev)
{
return netif_lease_dir_ok(dev, NETIF_VIRT_TO_PHYS);
}
struct netdev_rx_queue *
__netif_get_rx_queue_lease(struct net_device **dev, unsigned int *rxq_idx,
enum netif_lease_dir dir)
{
struct net_device *orig_dev = *dev;
struct netdev_rx_queue *rxq = __netif_get_rx_queue(orig_dev, *rxq_idx);
if (rxq->lease) {
if (!netif_lease_dir_ok(orig_dev, dir))
return NULL;
rxq = rxq->lease;
*rxq_idx = get_netdev_rx_queue_index(rxq);
*dev = rxq->dev;
}
return rxq;
}
/* See also page_pool_is_unreadable() */
bool netif_rxq_has_unreadable_mp(struct net_device *dev, unsigned int rxq_idx)
{
if (rxq_idx < dev->real_num_rx_queues)
return __netif_get_rx_queue(dev, rxq_idx)->mp_params.mp_ops;
return false;
}
EXPORT_SYMBOL(netif_rxq_has_unreadable_mp);
Annotation
- Immediate include surface: `linux/ethtool_netlink.h`, `linux/netdevice.h`, `net/netdev_lock.h`, `net/netdev_queues.h`, `net/netdev_rx_queue.h`, `net/page_pool/memory_provider.h`, `dev.h`, `page_pool_priv.h`.
- Detected declarations: `function netdev_rx_queue_lease`, `function netdev_rx_queue_unlease`, `function netif_rxq_is_leased`, `function netif_lease_dir_ok`, `function netif_is_queue_leasee`, `function __netif_get_rx_queue_lease`, `function netif_rxq_has_unreadable_mp`, `function netif_rxq_has_mp`, `function netdev_rx_queue_reconfig`, `function netdev_rx_queue_restart`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.