drivers/scsi/fnic/vnic_dev.c
Source file repositories/reference/linux-study-clean/drivers/scsi/fnic/vnic_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fnic/vnic_dev.c- Extension
.c- Size
- 20822 bytes
- Lines
- 948
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.hlinux/slab.hvnic_resource.hvnic_devcmd.hvnic_dev.hvnic_stats.hvnic_wq.h
Detected Declarations
struct devcmd2_controllerstruct vnic_resstruct vnic_devenum vnic_proxy_typefunction 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_cmd1function vnic_dev_cmd2function vnic_dev_init_devcmd1function vnic_dev_init_devcmd2function vnic_dev_deinit_devcmd2function vnic_dev_cmd_no_proxyfunction vnic_dev_cmdfunction vnic_dev_fw_infofunction vnic_dev_specfunction vnic_dev_stats_clearfunction vnic_dev_stats_dumpfunction vnic_dev_closefunction vnic_dev_enablefunction vnic_dev_disablefunction vnic_dev_openfunction vnic_dev_open_donefunction vnic_dev_soft_resetfunction vnic_dev_soft_reset_donefunction vnic_dev_hang_notifyfunction vnic_dev_mac_addrfunction vnic_dev_packet_filterfunction vnic_dev_add_addrfunction vnic_dev_del_addrfunction vnic_dev_notify_setfunction vnic_dev_notify_unsetfunction vnic_dev_notify_readyfunction vnic_dev_initfunction vnic_dev_set_default_vlanfunction vnic_dev_link_statusfunction vnic_dev_port_speedfunction vnic_dev_msg_lvlfunction vnic_dev_mtufunction vnic_dev_link_down_cntfunction vnic_dev_set_intr_modefunction vnic_dev_get_intr_modefunction vnic_dev_unregisterfunction vnic_dev_cmd_init
Annotated Snippet
struct devcmd2_controller {
struct vnic_wq_ctrl *wq_ctrl;
struct vnic_dev_ring results_ring;
struct vnic_wq wq;
struct vnic_devcmd2 *cmd_ring;
struct devcmd2_result *result;
u16 next_result;
u16 result_size;
int color;
};
enum vnic_proxy_type {
PROXY_NONE,
PROXY_BY_BDF,
PROXY_BY_INDEX,
};
struct vnic_res {
void __iomem *vaddr;
unsigned int count;
};
struct vnic_dev {
void *priv;
struct pci_dev *pdev;
struct vnic_res res[RES_TYPE_MAX];
enum vnic_dev_intr_mode intr_mode;
struct vnic_devcmd __iomem *devcmd;
struct vnic_devcmd_notify *notify;
struct vnic_devcmd_notify notify_copy;
dma_addr_t notify_pa;
u32 *linkstatus;
dma_addr_t linkstatus_pa;
struct vnic_stats *stats;
dma_addr_t stats_pa;
struct vnic_devcmd_fw_info *fw_info;
dma_addr_t fw_info_pa;
enum vnic_proxy_type proxy;
u32 proxy_index;
u64 args[VNIC_DEVCMD_NARGS];
struct devcmd2_controller *devcmd2;
int (*devcmd_rtn)(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
int wait);
};
#define VNIC_MAX_RES_HDR_SIZE \
(sizeof(struct vnic_resource_header) + \
sizeof(struct vnic_resource) * RES_TYPE_MAX)
#define VNIC_RES_STRIDE 128
void *vnic_dev_priv(struct vnic_dev *vdev)
{
return vdev->priv;
}
static int vnic_dev_discover_res(struct vnic_dev *vdev,
struct vnic_dev_bar *bar)
{
struct vnic_resource_header __iomem *rh;
struct vnic_resource __iomem *r;
u8 type;
if (bar->len < VNIC_MAX_RES_HDR_SIZE) {
printk(KERN_ERR "vNIC BAR0 res hdr length error\n");
return -EINVAL;
}
rh = bar->vaddr;
if (!rh) {
printk(KERN_ERR "vNIC BAR0 res hdr not mem-mapped\n");
return -EINVAL;
}
if (ioread32(&rh->magic) != VNIC_RES_MAGIC ||
ioread32(&rh->version) != VNIC_RES_VERSION) {
printk(KERN_ERR "vNIC BAR0 res magic/version error "
"exp (%lx/%lx) curr (%x/%x)\n",
VNIC_RES_MAGIC, VNIC_RES_VERSION,
ioread32(&rh->magic), ioread32(&rh->version));
return -EINVAL;
}
r = (struct vnic_resource __iomem *)(rh + 1);
while ((type = ioread8(&r->type)) != RES_TYPE_EOL) {
u8 bar_num = ioread8(&r->bar);
u32 bar_offset = ioread32(&r->bar_offset);
u32 count = ioread32(&r->count);
u32 len;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/errno.h`, `linux/types.h`, `linux/pci.h`, `linux/delay.h`, `linux/if_ether.h`, `linux/slab.h`, `vnic_resource.h`.
- Detected declarations: `struct devcmd2_controller`, `struct vnic_res`, `struct vnic_dev`, `enum vnic_proxy_type`, `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`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.