drivers/net/ethernet/amazon/ena/ena_devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amazon/ena/ena_devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amazon/ena/ena_devlink.c- Extension
.c- Size
- 5153 bytes
- Lines
- 215
- 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
linux/pci.hena_devlink.hena_phc.h
Detected Declarations
function ena_devlink_enable_phc_validatefunction ena_devlink_params_getfunction ena_devlink_disable_phc_paramfunction ena_devlink_port_registerfunction ena_devlink_port_unregisterfunction ena_devlink_reload_downfunction ena_devlink_reload_upfunction ena_devlink_configure_paramsfunction ena_devlink_configure_params_cleanfunction ena_devlink_freefunction ena_devlink_registerfunction ena_devlink_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
/* Copyright (c) Amazon.com, Inc. or its affiliates.
* All rights reserved.
*/
#include "linux/pci.h"
#include "ena_devlink.h"
#include "ena_phc.h"
static int ena_devlink_enable_phc_validate(struct devlink *devlink, u32 id,
union devlink_param_value *val,
struct netlink_ext_ack *extack)
{
struct ena_adapter *adapter = ENA_DEVLINK_PRIV(devlink);
if (!val->vbool)
return 0;
if (!ena_com_phc_supported(adapter->ena_dev)) {
NL_SET_ERR_MSG_MOD(extack, "Device doesn't support PHC");
return -EOPNOTSUPP;
}
return 0;
}
static const struct devlink_param ena_devlink_params[] = {
DEVLINK_PARAM_GENERIC(ENABLE_PHC,
BIT(DEVLINK_PARAM_CMODE_DRIVERINIT),
NULL,
NULL,
ena_devlink_enable_phc_validate),
};
void ena_devlink_params_get(struct devlink *devlink)
{
struct ena_adapter *adapter = ENA_DEVLINK_PRIV(devlink);
union devlink_param_value val;
int err;
err = devl_param_driverinit_value_get(devlink,
DEVLINK_PARAM_GENERIC_ID_ENABLE_PHC,
&val);
if (err) {
netdev_err(adapter->netdev, "Failed to query PHC param\n");
return;
}
ena_phc_enable(adapter, val.vbool);
}
void ena_devlink_disable_phc_param(struct devlink *devlink)
{
union devlink_param_value value;
devl_lock(devlink);
value.vbool = false;
devl_param_driverinit_value_set(devlink,
DEVLINK_PARAM_GENERIC_ID_ENABLE_PHC,
&value);
devl_unlock(devlink);
}
static void ena_devlink_port_register(struct devlink *devlink)
{
struct ena_adapter *adapter = ENA_DEVLINK_PRIV(devlink);
struct devlink_port_attrs attrs = {};
attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
devlink_port_attrs_set(&adapter->devlink_port, &attrs);
devl_port_register(devlink, &adapter->devlink_port, 0);
}
static void ena_devlink_port_unregister(struct devlink *devlink)
{
struct ena_adapter *adapter = ENA_DEVLINK_PRIV(devlink);
devl_port_unregister(&adapter->devlink_port);
}
static int ena_devlink_reload_down(struct devlink *devlink,
bool netns_change,
enum devlink_reload_action action,
enum devlink_reload_limit limit,
struct netlink_ext_ack *extack)
{
struct ena_adapter *adapter = ENA_DEVLINK_PRIV(devlink);
if (netns_change) {
NL_SET_ERR_MSG_MOD(extack,
Annotation
- Immediate include surface: `linux/pci.h`, `ena_devlink.h`, `ena_phc.h`.
- Detected declarations: `function ena_devlink_enable_phc_validate`, `function ena_devlink_params_get`, `function ena_devlink_disable_phc_param`, `function ena_devlink_port_register`, `function ena_devlink_port_unregister`, `function ena_devlink_reload_down`, `function ena_devlink_reload_up`, `function ena_devlink_configure_params`, `function ena_devlink_configure_params_clean`, `function ena_devlink_free`.
- 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.