drivers/vdpa/pds/cmds.c
Source file repositories/reference/linux-study-clean/drivers/vdpa/pds/cmds.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vdpa/pds/cmds.c- Extension
.c- Size
- 5898 bytes
- Lines
- 186
- 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/vdpa.hlinux/virtio_pci_modern.hlinux/pds/pds_common.hlinux/pds/pds_core_if.hlinux/pds/pds_adminq.hlinux/pds/pds_auxbus.hvdpa_dev.haux_drv.hcmds.h
Detected Declarations
function pds_vdpa_init_hwfunction pds_vdpa_cmd_resetfunction pds_vdpa_cmd_set_statusfunction pds_vdpa_cmd_set_macfunction pds_vdpa_cmd_set_max_vq_pairsfunction pds_vdpa_cmd_init_vqfunction pds_vdpa_cmd_reset_vq
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright(c) 2023 Advanced Micro Devices, Inc */
#include <linux/vdpa.h>
#include <linux/virtio_pci_modern.h>
#include <linux/pds/pds_common.h>
#include <linux/pds/pds_core_if.h>
#include <linux/pds/pds_adminq.h>
#include <linux/pds/pds_auxbus.h>
#include "vdpa_dev.h"
#include "aux_drv.h"
#include "cmds.h"
int pds_vdpa_init_hw(struct pds_vdpa_device *pdsv)
{
struct pds_auxiliary_dev *padev = pdsv->vdpa_aux->padev;
struct device *dev = &padev->aux_dev.dev;
union pds_core_adminq_cmd cmd = {
.vdpa_init.opcode = PDS_VDPA_CMD_INIT,
.vdpa_init.vdpa_index = pdsv->vdpa_index,
.vdpa_init.vf_id = cpu_to_le16(pdsv->vdpa_aux->vf_id),
};
union pds_core_adminq_comp comp = {};
int err;
/* Initialize the vdpa/virtio device */
err = pds_client_adminq_cmd(padev, &cmd, sizeof(cmd.vdpa_init),
&comp, 0);
if (err)
dev_dbg(dev, "Failed to init hw, status %d: %pe\n",
comp.status, ERR_PTR(err));
return err;
}
int pds_vdpa_cmd_reset(struct pds_vdpa_device *pdsv)
{
struct pds_auxiliary_dev *padev = pdsv->vdpa_aux->padev;
struct device *dev = &padev->aux_dev.dev;
union pds_core_adminq_cmd cmd = {
.vdpa.opcode = PDS_VDPA_CMD_RESET,
.vdpa.vdpa_index = pdsv->vdpa_index,
.vdpa.vf_id = cpu_to_le16(pdsv->vdpa_aux->vf_id),
};
union pds_core_adminq_comp comp = {};
int err;
err = pds_client_adminq_cmd(padev, &cmd, sizeof(cmd.vdpa), &comp, 0);
if (err)
dev_dbg(dev, "Failed to reset hw, status %d: %pe\n",
comp.status, ERR_PTR(err));
return err;
}
int pds_vdpa_cmd_set_status(struct pds_vdpa_device *pdsv, u8 status)
{
struct pds_auxiliary_dev *padev = pdsv->vdpa_aux->padev;
struct device *dev = &padev->aux_dev.dev;
union pds_core_adminq_cmd cmd = {
.vdpa_status.opcode = PDS_VDPA_CMD_STATUS_UPDATE,
.vdpa_status.vdpa_index = pdsv->vdpa_index,
.vdpa_status.vf_id = cpu_to_le16(pdsv->vdpa_aux->vf_id),
.vdpa_status.status = status,
};
union pds_core_adminq_comp comp = {};
int err;
err = pds_client_adminq_cmd(padev, &cmd, sizeof(cmd.vdpa_status), &comp, 0);
if (err)
dev_dbg(dev, "Failed to set status to %#x, error status %d: %pe\n",
status, comp.status, ERR_PTR(err));
return err;
}
int pds_vdpa_cmd_set_mac(struct pds_vdpa_device *pdsv, u8 *mac)
{
struct pds_auxiliary_dev *padev = pdsv->vdpa_aux->padev;
struct device *dev = &padev->aux_dev.dev;
union pds_core_adminq_cmd cmd = {
.vdpa_setattr.opcode = PDS_VDPA_CMD_SET_ATTR,
.vdpa_setattr.vdpa_index = pdsv->vdpa_index,
.vdpa_setattr.vf_id = cpu_to_le16(pdsv->vdpa_aux->vf_id),
.vdpa_setattr.attr = PDS_VDPA_ATTR_MAC,
};
union pds_core_adminq_comp comp = {};
int err;
Annotation
- Immediate include surface: `linux/vdpa.h`, `linux/virtio_pci_modern.h`, `linux/pds/pds_common.h`, `linux/pds/pds_core_if.h`, `linux/pds/pds_adminq.h`, `linux/pds/pds_auxbus.h`, `vdpa_dev.h`, `aux_drv.h`.
- Detected declarations: `function pds_vdpa_init_hw`, `function pds_vdpa_cmd_reset`, `function pds_vdpa_cmd_set_status`, `function pds_vdpa_cmd_set_mac`, `function pds_vdpa_cmd_set_max_vq_pairs`, `function pds_vdpa_cmd_init_vq`, `function pds_vdpa_cmd_reset_vq`.
- 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.