drivers/scsi/fnic/vnic_wq_copy.h
Source file repositories/reference/linux-study-clean/drivers/scsi/fnic/vnic_wq_copy.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/fnic/vnic_wq_copy.h- Extension
.h- Size
- 3129 bytes
- Lines
- 117
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hvnic_wq.hfcpio.h
Detected Declarations
struct vnic_wq_copyfunction vnic_wq_copy_desc_availfunction vnic_wq_copy_desc_in_usefunction vnic_wq_copy_postfunction vnic_wq_copy_desc_processfunction vnic_wq_copy_service
Annotated Snippet
struct vnic_wq_copy {
unsigned int index;
struct vnic_dev *vdev;
struct vnic_wq_ctrl __iomem *ctrl; /* memory-mapped */
struct vnic_dev_ring ring;
unsigned to_use_index;
unsigned to_clean_index;
};
static inline unsigned int vnic_wq_copy_desc_avail(struct vnic_wq_copy *wq)
{
return wq->ring.desc_avail;
}
static inline unsigned int vnic_wq_copy_desc_in_use(struct vnic_wq_copy *wq)
{
return wq->ring.desc_count - 1 - wq->ring.desc_avail;
}
static inline void *vnic_wq_copy_next_desc(struct vnic_wq_copy *wq)
{
struct fcpio_host_req *desc = wq->ring.descs;
return &desc[wq->to_use_index];
}
static inline void vnic_wq_copy_post(struct vnic_wq_copy *wq)
{
((wq->to_use_index + 1) == wq->ring.desc_count) ?
(wq->to_use_index = 0) : (wq->to_use_index++);
wq->ring.desc_avail--;
/* Adding write memory barrier prevents compiler and/or CPU
* reordering, thus avoiding descriptor posting before
* descriptor is initialized. Otherwise, hardware can read
* stale descriptor fields.
*/
wmb();
iowrite32(wq->to_use_index, &wq->ctrl->posted_index);
}
static inline void vnic_wq_copy_desc_process(struct vnic_wq_copy *wq, u16 index)
{
unsigned int cnt;
if (wq->to_clean_index <= index)
cnt = (index - wq->to_clean_index) + 1;
else
cnt = wq->ring.desc_count - wq->to_clean_index + index + 1;
wq->to_clean_index = ((index + 1) % wq->ring.desc_count);
wq->ring.desc_avail += cnt;
}
static inline void vnic_wq_copy_service(struct vnic_wq_copy *wq,
u16 completed_index,
void (*q_service)(struct vnic_wq_copy *wq,
struct fcpio_host_req *wq_desc))
{
struct fcpio_host_req *wq_desc = wq->ring.descs;
unsigned int curr_index;
while (1) {
if (q_service)
(*q_service)(wq, &wq_desc[wq->to_clean_index]);
wq->ring.desc_avail++;
curr_index = wq->to_clean_index;
/* increment the to-clean index so that we start
* with an unprocessed index next time we enter the loop
*/
((wq->to_clean_index + 1) == wq->ring.desc_count) ?
(wq->to_clean_index = 0) : (wq->to_clean_index++);
if (curr_index == completed_index)
break;
/* we have cleaned all the entries */
if ((completed_index == (u16)-1) &&
(wq->to_clean_index == wq->to_use_index))
break;
}
}
void vnic_wq_copy_enable(struct vnic_wq_copy *wq);
Annotation
- Immediate include surface: `linux/pci.h`, `vnic_wq.h`, `fcpio.h`.
- Detected declarations: `struct vnic_wq_copy`, `function vnic_wq_copy_desc_avail`, `function vnic_wq_copy_desc_in_use`, `function vnic_wq_copy_post`, `function vnic_wq_copy_desc_process`, `function vnic_wq_copy_service`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source 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.