drivers/net/ethernet/amd/pds_core/devlink.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amd/pds_core/devlink.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/amd/pds_core/devlink.c
Extension
.c
Size
4737 bytes
Lines
182
Domain
Driver Families
Bucket
drivers/net
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.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2023 Advanced Micro Devices, Inc */

#include "core.h"
#include <linux/pds/pds_auxbus.h>

static struct
pdsc_viftype *pdsc_dl_find_viftype_by_id(struct pdsc *pdsc,
					 enum devlink_param_type dl_id)
{
	int vt;

	if (!pdsc->viftype_status)
		return NULL;

	for (vt = 0; vt < PDS_DEV_TYPE_MAX; vt++) {
		if (pdsc->viftype_status[vt].dl_id == dl_id)
			return &pdsc->viftype_status[vt];
	}

	return NULL;
}

int pdsc_dl_enable_get(struct devlink *dl, u32 id,
		       struct devlink_param_gset_ctx *ctx,
		       struct netlink_ext_ack *extack)
{
	struct pdsc *pdsc = devlink_priv(dl);
	struct pdsc_viftype *vt_entry;

	vt_entry = pdsc_dl_find_viftype_by_id(pdsc, id);
	if (!vt_entry)
		return -ENOENT;

	ctx->val.vbool = vt_entry->enabled;

	return 0;
}

int pdsc_dl_enable_set(struct devlink *dl, u32 id,
		       struct devlink_param_gset_ctx *ctx,
		       struct netlink_ext_ack *extack)
{
	struct pdsc *pdsc = devlink_priv(dl);
	struct pdsc_viftype *vt_entry;
	int err = 0;
	int vf_id;

	vt_entry = pdsc_dl_find_viftype_by_id(pdsc, id);
	if (!vt_entry || !vt_entry->supported)
		return -EOPNOTSUPP;

	if (vt_entry->enabled == ctx->val.vbool)
		return 0;

	vt_entry->enabled = ctx->val.vbool;
	for (vf_id = 0; vf_id < pdsc->num_vfs; vf_id++) {
		struct pdsc *vf = pdsc->vfs[vf_id].vf;

		if (ctx->val.vbool)
			err = pdsc_auxbus_dev_add(vf, pdsc, vt_entry->vif_id,
						  &pdsc->vfs[vf_id].padev);
		else
			pdsc_auxbus_dev_del(vf, pdsc, &pdsc->vfs[vf_id].padev);
	}

	return err;
}

int pdsc_dl_enable_validate(struct devlink *dl, u32 id,
			    union devlink_param_value *val,
			    struct netlink_ext_ack *extack)
{
	struct pdsc *pdsc = devlink_priv(dl);
	struct pdsc_viftype *vt_entry;

	vt_entry = pdsc_dl_find_viftype_by_id(pdsc, id);
	if (!vt_entry || !vt_entry->supported)
		return -EOPNOTSUPP;

	if (!pdsc->viftype_status[vt_entry->vif_id].supported)
		return -ENODEV;

	return 0;
}

int pdsc_dl_flash_update(struct devlink *dl,
			 struct devlink_flash_update_params *params,
			 struct netlink_ext_ack *extack)
{

Annotation

Implementation Notes