drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-devlink.c- Extension
.c- Size
- 9227 bytes
- Lines
- 289
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
dpaa2-eth.h
Detected Declarations
function dpaa2_eth_dl_info_getfunction dpaa2_eth_dl_trap_item_lookupfunction dpaa2_eth_dl_trap_initfunction dpaa2_eth_dl_trap_action_setfunction dpaa2_eth_dl_trap_group_action_setfunction dpaa2_eth_dl_allocfunction dpaa2_eth_dl_freefunction dpaa2_eth_dl_registerfunction dpaa2_eth_dl_unregisterfunction dpaa2_eth_dl_port_addfunction dpaa2_eth_dl_port_delfunction dpaa2_eth_dl_traps_registerfunction dpaa2_eth_dl_traps_unregister
Annotated Snippet
if (faf_bits[i].position < 32) {
/* Low part of FAF.
* position ranges from 31 to 0, mask from 0 to 31.
*/
mask = 1ull << (31 - faf_bits[i].position);
faf_word = __le32_to_cpu(fapr->faf_lo);
} else {
/* High part of FAF.
* position ranges from 95 to 32, mask from 0 to 63.
*/
mask = 1ull << (63 - (faf_bits[i].position - 32));
faf_word = __le64_to_cpu(fapr->faf_hi);
}
if (faf_word & mask)
return dpaa2_eth_dl_trap_item_lookup(priv, faf_bits[i].trap_id);
}
return NULL;
}
static int dpaa2_eth_dl_trap_init(struct devlink *devlink,
const struct devlink_trap *trap,
void *trap_ctx)
{
struct dpaa2_eth_devlink_priv *dl_priv = devlink_priv(devlink);
struct dpaa2_eth_priv *priv = dl_priv->dpaa2_priv;
struct dpaa2_eth_trap_item *dpaa2_eth_trap_item;
dpaa2_eth_trap_item = dpaa2_eth_dl_trap_item_lookup(priv, trap->id);
if (WARN_ON(!dpaa2_eth_trap_item))
return -ENOENT;
dpaa2_eth_trap_item->trap_ctx = trap_ctx;
return 0;
}
static int dpaa2_eth_dl_trap_action_set(struct devlink *devlink,
const struct devlink_trap *trap,
enum devlink_trap_action action,
struct netlink_ext_ack *extack)
{
/* No support for changing the action of an independent packet trap,
* only per trap group - parser error drops
*/
NL_SET_ERR_MSG_MOD(extack,
"Cannot change trap action independently of group");
return -EOPNOTSUPP;
}
static int dpaa2_eth_dl_trap_group_action_set(struct devlink *devlink,
const struct devlink_trap_group *group,
enum devlink_trap_action action,
struct netlink_ext_ack *extack)
{
struct dpaa2_eth_devlink_priv *dl_priv = devlink_priv(devlink);
struct dpaa2_eth_priv *priv = dl_priv->dpaa2_priv;
struct net_device *net_dev = priv->net_dev;
struct device *dev = net_dev->dev.parent;
struct dpni_error_cfg err_cfg = {0};
int err;
if (group->id != DEVLINK_TRAP_GROUP_GENERIC_ID_PARSER_ERROR_DROPS)
return -EOPNOTSUPP;
/* Configure handling of frames marked as errors from the parser */
err_cfg.errors = DPAA2_FAS_RX_ERR_MASK;
err_cfg.set_frame_annotation = 1;
switch (action) {
case DEVLINK_TRAP_ACTION_DROP:
err_cfg.error_action = DPNI_ERROR_ACTION_DISCARD;
break;
case DEVLINK_TRAP_ACTION_TRAP:
err_cfg.error_action = DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE;
break;
default:
return -EOPNOTSUPP;
}
err = dpni_set_errors_behavior(priv->mc_io, 0, priv->mc_token, &err_cfg);
if (err) {
dev_err(dev, "dpni_set_errors_behavior failed\n");
return err;
}
return 0;
}
static const struct devlink_ops dpaa2_eth_devlink_ops = {
.info_get = dpaa2_eth_dl_info_get,
Annotation
- Immediate include surface: `dpaa2-eth.h`.
- Detected declarations: `function dpaa2_eth_dl_info_get`, `function dpaa2_eth_dl_trap_item_lookup`, `function dpaa2_eth_dl_trap_init`, `function dpaa2_eth_dl_trap_action_set`, `function dpaa2_eth_dl_trap_group_action_set`, `function dpaa2_eth_dl_alloc`, `function dpaa2_eth_dl_free`, `function dpaa2_eth_dl_register`, `function dpaa2_eth_dl_unregister`, `function dpaa2_eth_dl_port_add`.
- 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.