drivers/net/hyperv/netvsc_bpf.c

Source file repositories/reference/linux-study-clean/drivers/net/hyperv/netvsc_bpf.c

File Facts

System
Linux kernel
Corpus path
drivers/net/hyperv/netvsc_bpf.c
Extension
.c
Size
6257 bytes
Lines
293
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

const struct net_device_ops *vf_ops;
	struct netvsc_stats_tx *tx_stats;
	struct netvsc_device *nvsc_dev;
	struct net_device *vf_netdev;
	int i, count = 0;
	u16 q_idx;

	/* Don't transmit if netvsc_device is gone */
	nvsc_dev = rcu_dereference_bh(ndev_ctx->nvdev);
	if (unlikely(!nvsc_dev || nvsc_dev->destroy))
		return 0;

	/* If VF is present and up then redirect packets to it.
	 * Skip the VF if it is marked down or has no carrier.
	 * If netpoll is in uses, then VF can not be used either.
	 */
	vf_netdev = rcu_dereference_bh(ndev_ctx->vf_netdev);
	if (vf_netdev && netif_running(vf_netdev) &&
	    netif_carrier_ok(vf_netdev) && !netpoll_tx_running(ndev) &&
	    vf_netdev->netdev_ops->ndo_xdp_xmit &&
	    ndev_ctx->data_path_is_vf) {
		vf_ops = vf_netdev->netdev_ops;
		return vf_ops->ndo_xdp_xmit(vf_netdev, n, frames, flags);
	}

	q_idx = smp_processor_id() % ndev->real_num_tx_queues;

	for (i = 0; i < n; i++) {
		if (netvsc_ndoxdp_xmit_fm(ndev, frames[i], q_idx))
			break;

		count++;
	}

	tx_stats = &nvsc_dev->chan_table[q_idx].tx_stats;

	u64_stats_update_begin(&tx_stats->syncp);
	tx_stats->xdp_xmit += count;
	u64_stats_update_end(&tx_stats->syncp);

	return count;
}

Annotation

Implementation Notes