drivers/net/ethernet/cisco/enic/vnic_dev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/cisco/enic/vnic_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/cisco/enic/vnic_dev.c- Extension
.c- Size
- 29693 bytes
- Lines
- 1298
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/errno.hlinux/types.hlinux/pci.hlinux/delay.hlinux/if_ether.hvnic_resource.hvnic_devcmd.hvnic_dev.hvnic_wq.hvnic_stats.henic.h
Detected Declarations
function vnic_dev_discover_resfunction vnic_dev_get_res_countfunction vnic_dev_desc_ring_sizefunction vnic_dev_clear_desc_ringfunction vnic_dev_alloc_desc_ringfunction vnic_dev_free_desc_ringfunction _vnic_dev_cmdfunction _vnic_dev_cmd2function vnic_dev_init_devcmd1function vnic_dev_init_devcmd2function vnic_dev_deinit_devcmd2function vnic_dev_cmd_proxyfunction vnic_dev_cmd_no_proxyfunction vnic_dev_cmd_proxy_by_index_startfunction vnic_dev_cmd_proxy_endfunction vnic_dev_cmdfunction vnic_dev_capablefunction vnic_dev_fw_infofunction vnic_dev_specfunction vnic_dev_stats_dumpfunction vnic_dev_closefunction vnic_dev_enable_waitfunction vnic_dev_disablefunction vnic_dev_openfunction vnic_dev_open_donefunction vnic_dev_soft_resetfunction vnic_dev_soft_reset_donefunction vnic_dev_hang_resetfunction vnic_dev_hang_reset_donefunction vnic_dev_hang_notifyfunction vnic_dev_get_mac_addrfunction vnic_dev_packet_filterfunction vnic_dev_add_addrfunction vnic_dev_del_addrfunction vnic_dev_set_ig_vlan_rewrite_modefunction vnic_dev_notify_setcmdfunction vnic_dev_notify_setfunction vnic_dev_notify_unsetcmdfunction vnic_dev_notify_unsetfunction vnic_dev_notify_readyfunction vnic_dev_initfunction vnic_dev_deinitfunction vnic_dev_intr_coal_timer_info_defaultfunction vnic_dev_intr_coal_timer_infofunction vnic_dev_link_statusfunction vnic_dev_port_speedfunction vnic_dev_msg_lvlfunction vnic_dev_mtu
Annotated Snippet
switch (type) {
case RES_TYPE_WQ:
case RES_TYPE_RQ:
case RES_TYPE_CQ:
case RES_TYPE_INTR_CTRL:
case RES_TYPE_ADMIN_WQ:
case RES_TYPE_ADMIN_RQ:
case RES_TYPE_ADMIN_CQ:
/* each count is stride bytes long */
len = count * VNIC_RES_STRIDE;
if (len + bar_offset > bar[bar_num].len) {
vdev_err(vdev, "vNIC BAR0 resource %d out-of-bounds, offset 0x%x + size 0x%x > bar len 0x%lx\n",
type, bar_offset, len,
bar[bar_num].len);
return -EINVAL;
}
break;
case RES_TYPE_INTR_PBA_LEGACY:
case RES_TYPE_DEVCMD:
case RES_TYPE_DEVCMD2:
case RES_TYPE_SRIOV_INTR:
len = count;
break;
default:
continue;
}
vdev->res[type].count = count;
vdev->res[type].vaddr = (char __iomem *)bar[bar_num].vaddr +
bar_offset;
vdev->res[type].bus_addr = bar[bar_num].bus_addr + bar_offset;
}
return 0;
}
unsigned int vnic_dev_get_res_count(struct vnic_dev *vdev,
enum vnic_res_type type)
{
return vdev->res[type].count;
}
EXPORT_SYMBOL(vnic_dev_get_res_count);
void __iomem *vnic_dev_get_res(struct vnic_dev *vdev, enum vnic_res_type type,
unsigned int index)
{
if (!vdev->res[type].vaddr)
return NULL;
switch (type) {
case RES_TYPE_WQ:
case RES_TYPE_RQ:
case RES_TYPE_CQ:
case RES_TYPE_INTR_CTRL:
case RES_TYPE_ADMIN_WQ:
case RES_TYPE_ADMIN_RQ:
case RES_TYPE_ADMIN_CQ:
return (char __iomem *)vdev->res[type].vaddr +
index * VNIC_RES_STRIDE;
default:
return (char __iomem *)vdev->res[type].vaddr;
}
}
EXPORT_SYMBOL(vnic_dev_get_res);
static unsigned int vnic_dev_desc_ring_size(struct vnic_dev_ring *ring,
unsigned int desc_count, unsigned int desc_size)
{
/* Descriptor ring base address alignment in bytes*/
ring->base_align = VNIC_DESC_BASE_ALIGN;
/* A count of 0 means the maximum descriptors */
if (desc_count == 0)
desc_count = VNIC_DESC_MAX_COUNT;
/* Descriptor count aligned in groups of VNIC_DESC_COUNT_ALIGN descriptors */
ring->desc_count = ALIGN(desc_count, VNIC_DESC_COUNT_ALIGN);
/* Descriptor size alignment in bytes */
ring->desc_size = ALIGN(desc_size, VNIC_DESC_SIZE_ALIGN);
ring->size = ring->desc_count * ring->desc_size;
ring->size_unaligned = ring->size + ring->base_align;
return ring->size_unaligned;
}
void vnic_dev_clear_desc_ring(struct vnic_dev_ring *ring)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/types.h`, `linux/pci.h`, `linux/delay.h`, `linux/if_ether.h`, `vnic_resource.h`, `vnic_devcmd.h`.
- Detected declarations: `function vnic_dev_discover_res`, `function vnic_dev_get_res_count`, `function vnic_dev_desc_ring_size`, `function vnic_dev_clear_desc_ring`, `function vnic_dev_alloc_desc_ring`, `function vnic_dev_free_desc_ring`, `function _vnic_dev_cmd`, `function _vnic_dev_cmd2`, `function vnic_dev_init_devcmd1`, `function vnic_dev_init_devcmd2`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: integration implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.