drivers/scsi/snic/vnic_dev.c
Source file repositories/reference/linux-study-clean/drivers/scsi/snic/vnic_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/snic/vnic_dev.c- Extension
.c- Size
- 16325 bytes
- Lines
- 740
- 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_devfunction vnic_dev_discover_resfunction svnic_dev_get_res_countfunction svnic_dev_desc_ring_sizefunction svnic_dev_clear_desc_ringfunction svnic_dev_alloc_desc_ringfunction svnic_dev_free_desc_ringfunction _svnic_dev_cmd2function svnic_dev_init_devcmd2function vnic_dev_deinit_devcmd2function svnic_dev_cmdfunction svnic_dev_fw_infofunction svnic_dev_specfunction svnic_dev_stats_clearfunction svnic_dev_stats_dumpfunction svnic_dev_closefunction svnic_dev_enable_waitfunction svnic_dev_disablefunction svnic_dev_openfunction svnic_dev_open_donefunction svnic_dev_notify_setfunction svnic_dev_notify_unsetfunction vnic_dev_notify_readyfunction svnic_dev_initfunction svnic_dev_link_statusfunction svnic_dev_link_down_cntfunction svnic_dev_set_intr_modefunction svnic_dev_get_intr_modefunction svnic_dev_unregisterfunction svnic_dev_cmd_init
Annotated Snippet
struct devcmd2_controller {
struct vnic_wq_ctrl __iomem *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;
};
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;
struct vnic_stats *stats;
dma_addr_t stats_pa;
struct vnic_devcmd_fw_info *fw_info;
dma_addr_t fw_info_pa;
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 *svnic_dev_priv(struct vnic_dev *vdev)
{
return vdev->priv;
}
static int vnic_dev_discover_res(struct vnic_dev *vdev,
struct vnic_dev_bar *bar, unsigned int num_bars)
{
struct vnic_resource_header __iomem *rh;
struct vnic_resource __iomem *r;
u8 type;
if (num_bars == 0)
return -EINVAL;
if (bar->len < VNIC_MAX_RES_HDR_SIZE) {
pr_err("vNIC BAR0 res hdr length error\n");
return -EINVAL;
}
rh = bar->vaddr;
if (!rh) {
pr_err("vNIC BAR0 res hdr not mem-mapped\n");
return -EINVAL;
}
if (ioread32(&rh->magic) != VNIC_RES_MAGIC ||
ioread32(&rh->version) != VNIC_RES_VERSION) {
pr_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;
r++;
if (bar_num >= num_bars)
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`, `function vnic_dev_discover_res`, `function svnic_dev_get_res_count`, `function svnic_dev_desc_ring_size`, `function svnic_dev_clear_desc_ring`, `function svnic_dev_alloc_desc_ring`, `function svnic_dev_free_desc_ring`, `function _svnic_dev_cmd2`.
- 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.