drivers/vdpa/octeon_ep/octep_vdpa_hw.c
Source file repositories/reference/linux-study-clean/drivers/vdpa/octeon_ep/octep_vdpa_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vdpa/octeon_ep/octep_vdpa_hw.c- Extension
.c- Size
- 14456 bytes
- Lines
- 550
- Domain
- Driver Families
- Bucket
- drivers/vdpa
- 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/iopoll.hlinux/build_bug.hoctep_vdpa.h
Detected Declarations
struct octep_mbox_hdrstruct octep_mbox_stsstruct octep_mboxenum octep_mbox_idsfunction octep_wait_for_mbox_availfunction octep_wait_for_mbox_rspfunction octep_write_hdrfunction octep_read_sigfunction octep_write_stsfunction octep_read_stsfunction octep_read32_wordfunction octep_write32_wordfunction octep_process_mboxfunction octep_mbox_initfunction octep_verify_featuresfunction octep_hw_get_statusfunction octep_hw_set_statusfunction octep_hw_resetfunction feature_sel_write_with_timeoutfunction octep_hw_get_dev_featuresfunction octep_hw_get_drv_featuresfunction octep_hw_set_drv_featuresfunction octep_write_queue_selectfunction octep_notify_queuefunction octep_read_dev_configfunction octep_set_vq_addressfunction octep_get_vq_statefunction octep_set_vq_statefunction octep_set_vq_numfunction octep_set_vq_readyfunction octep_get_vq_readyfunction octep_get_vq_sizefunction octep_get_config_sizefunction octep_pci_caps_readfunction octep_pci_signature_verifyfunction octep_vndr_data_processfunction octep_hw_caps_read
Annotated Snippet
struct octep_mbox_hdr {
u8 ver;
u8 rsvd1;
u16 id;
u16 rsvd2;
#define MBOX_REQ_SIG (0xdead)
#define MBOX_RSP_SIG (0xbeef)
u16 sig;
};
struct octep_mbox_sts {
u16 rsp:1;
u16 rc:15;
u16 rsvd;
};
struct octep_mbox {
struct octep_mbox_hdr hdr;
struct octep_mbox_sts sts;
u64 rsvd;
u32 data[];
};
static inline struct octep_mbox __iomem *octep_get_mbox(struct octep_hw *oct_hw)
{
return (struct octep_mbox __iomem *)(oct_hw->dev_cfg + MBOX_OFFSET);
}
static inline int octep_wait_for_mbox_avail(struct octep_mbox __iomem *mbox)
{
u32 val;
return readx_poll_timeout(ioread32, &mbox->sts, val, MBOX_AVAIL(val), 10,
OCTEP_HW_TIMEOUT);
}
static inline int octep_wait_for_mbox_rsp(struct octep_mbox __iomem *mbox)
{
u32 val;
return readx_poll_timeout(ioread32, &mbox->sts, val, MBOX_RSP(val), 10,
OCTEP_HW_TIMEOUT);
}
static inline void octep_write_hdr(struct octep_mbox __iomem *mbox, u16 id, u16 sig)
{
iowrite16(id, &mbox->hdr.id);
iowrite16(sig, &mbox->hdr.sig);
}
static inline u32 octep_read_sig(struct octep_mbox __iomem *mbox)
{
return ioread16(&mbox->hdr.sig);
}
static inline void octep_write_sts(struct octep_mbox __iomem *mbox, u32 sts)
{
iowrite32(sts, &mbox->sts);
}
static inline u32 octep_read_sts(struct octep_mbox __iomem *mbox)
{
return ioread32(&mbox->sts);
}
static inline u32 octep_read32_word(struct octep_mbox __iomem *mbox, u16 word_idx)
{
return ioread32(&mbox->data[word_idx]);
}
static inline void octep_write32_word(struct octep_mbox __iomem *mbox, u16 word_idx, u32 word)
{
return iowrite32(word, &mbox->data[word_idx]);
}
static int octep_process_mbox(struct octep_hw *oct_hw, u16 id, u16 qid, void *buffer,
u32 buf_size, bool write)
{
struct octep_mbox __iomem *mbox = octep_get_mbox(oct_hw);
struct pci_dev *pdev = oct_hw->pdev;
u32 *p = (u32 *)buffer;
u16 data_wds;
int ret, i;
u32 val;
if (!IS_ALIGNED(buf_size, 4))
return -EINVAL;
/* Make sure mbox space is available */
ret = octep_wait_for_mbox_avail(mbox);
Annotation
- Immediate include surface: `linux/iopoll.h`, `linux/build_bug.h`, `octep_vdpa.h`.
- Detected declarations: `struct octep_mbox_hdr`, `struct octep_mbox_sts`, `struct octep_mbox`, `enum octep_mbox_ids`, `function octep_wait_for_mbox_avail`, `function octep_wait_for_mbox_rsp`, `function octep_write_hdr`, `function octep_read_sig`, `function octep_write_sts`, `function octep_read_sts`.
- Atlas domain: Driver Families / drivers/vdpa.
- 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.