drivers/net/ethernet/intel/i40e/i40e_devlink.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/i40e/i40e_devlink.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/i40e/i40e_devlink.c
Extension
.c
Size
7254 bytes
Lines
287
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 Intel Corporation. */

#include <net/devlink.h>
#include "i40e.h"
#include "i40e_devlink.h"

static int i40e_max_mac_per_vf_set(struct devlink *devlink,
				   u32 id,
				   struct devlink_param_gset_ctx *ctx,
				   struct netlink_ext_ack *extack)
{
	struct i40e_pf *pf = devlink_priv(devlink);

	if (pf->num_alloc_vfs > 0) {
		NL_SET_ERR_MSG_MOD(extack,
				   "Cannot change max_mac_per_vf while SR-IOV is enabled");
		return -EBUSY;
	}

	pf->max_mac_per_vf = ctx->val.vu32;
	return 0;
}

static int i40e_max_mac_per_vf_get(struct devlink *devlink,
				   u32 id,
				   struct devlink_param_gset_ctx *ctx,
				   struct netlink_ext_ack *extack)
{
	struct i40e_pf *pf = devlink_priv(devlink);

	ctx->val.vu32 = pf->max_mac_per_vf;
	return 0;
}

static const struct devlink_param i40e_dl_params[] = {
	DEVLINK_PARAM_GENERIC(MAX_MAC_PER_VF,
			      BIT(DEVLINK_PARAM_CMODE_RUNTIME),
			      i40e_max_mac_per_vf_get,
			      i40e_max_mac_per_vf_set,
			      NULL),
};

static void i40e_info_get_dsn(struct i40e_pf *pf, char *buf, size_t len)
{
	u8 dsn[8];

	put_unaligned_be64(pci_get_dsn(pf->pdev), dsn);

	snprintf(buf, len, "%8phD", dsn);
}

static void i40e_info_fw_mgmt(struct i40e_hw *hw, char *buf, size_t len)
{
	struct i40e_adminq_info *aq = &hw->aq;

	snprintf(buf, len, "%u.%u", aq->fw_maj_ver, aq->fw_min_ver);
}

static void i40e_info_fw_mgmt_build(struct i40e_hw *hw, char *buf, size_t len)
{
	struct i40e_adminq_info *aq = &hw->aq;

	snprintf(buf, len, "%05d", aq->fw_build);
}

static void i40e_info_fw_api(struct i40e_hw *hw, char *buf, size_t len)
{
	struct i40e_adminq_info *aq = &hw->aq;

	snprintf(buf, len, "%u.%u", aq->api_maj_ver, aq->api_min_ver);
}

static void i40e_info_pba(struct i40e_hw *hw, char *buf, size_t len)
{
	buf[0] = '\0';
	if (hw->pba_id)
		strscpy(buf, hw->pba_id, len);
}

enum i40e_devlink_version_type {
	I40E_DL_VERSION_FIXED,
	I40E_DL_VERSION_RUNNING,
};

static int i40e_devlink_info_put(struct devlink_info_req *req,
				 enum i40e_devlink_version_type type,
				 const char *key, const char *value)
{
	if (!strlen(value))

Annotation

Implementation Notes