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.
- 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
net/devlink.hi40e.hi40e_devlink.h
Detected Declarations
enum i40e_devlink_version_typefunction i40e_max_mac_per_vf_setfunction i40e_max_mac_per_vf_getfunction i40e_info_get_dsnfunction i40e_info_fw_mgmtfunction i40e_info_fw_mgmt_buildfunction i40e_info_fw_apifunction i40e_info_pbafunction i40e_devlink_info_putfunction i40e_devlink_info_getfunction i40e_free_pffunction i40e_devlink_registerfunction i40e_devlink_unregisterfunction i40e_devlink_set_switch_idfunction i40e_devlink_create_portfunction i40e_devlink_destroy_port
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
- Immediate include surface: `net/devlink.h`, `i40e.h`, `i40e_devlink.h`.
- Detected declarations: `enum i40e_devlink_version_type`, `function i40e_max_mac_per_vf_set`, `function i40e_max_mac_per_vf_get`, `function i40e_info_get_dsn`, `function i40e_info_fw_mgmt`, `function i40e_info_fw_mgmt_build`, `function i40e_info_fw_api`, `function i40e_info_pba`, `function i40e_devlink_info_put`, `function i40e_devlink_info_get`.
- Atlas domain: Driver Families / drivers/net.
- 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.