drivers/net/ethernet/marvell/prestera/prestera_matchall.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/prestera/prestera_matchall.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/prestera/prestera_matchall.c- Extension
.c- Size
- 3309 bytes
- Lines
- 128
- 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/kernel.hlinux/list.hprestera.hprestera_hw.hprestera_flow.hprestera_flower.hprestera_matchall.hprestera_span.h
Detected Declarations
function prestera_mall_prio_checkfunction prestera_mall_prio_getfunction prestera_mall_prio_updatefunction prestera_mall_replacefunction list_for_each_entryfunction prestera_mall_destroy
Annotated Snippet
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/* Copyright (c) 2019-2022 Marvell International Ltd. All rights reserved */
#include <linux/kernel.h>
#include <linux/list.h>
#include "prestera.h"
#include "prestera_hw.h"
#include "prestera_flow.h"
#include "prestera_flower.h"
#include "prestera_matchall.h"
#include "prestera_span.h"
static int prestera_mall_prio_check(struct prestera_flow_block *block,
struct tc_cls_matchall_offload *f)
{
u32 flower_prio_min;
u32 flower_prio_max;
int err;
err = prestera_flower_prio_get(block, f->common.chain_index,
&flower_prio_min, &flower_prio_max);
if (err == -ENOENT)
/* No flower filters installed on this chain. */
return 0;
if (err) {
NL_SET_ERR_MSG(f->common.extack, "Failed to get flower priorities");
return err;
}
if (f->common.prio <= flower_prio_max && !block->ingress) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add in front of existing flower rules");
return -EOPNOTSUPP;
}
if (f->common.prio >= flower_prio_min && block->ingress) {
NL_SET_ERR_MSG(f->common.extack, "Failed to add behind of existing flower rules");
return -EOPNOTSUPP;
}
return 0;
}
int prestera_mall_prio_get(struct prestera_flow_block *block,
u32 *prio_min, u32 *prio_max)
{
if (!block->mall.bound)
return -ENOENT;
*prio_min = block->mall.prio_min;
*prio_max = block->mall.prio_max;
return 0;
}
static void prestera_mall_prio_update(struct prestera_flow_block *block,
struct tc_cls_matchall_offload *f)
{
block->mall.prio_min = min(block->mall.prio_min, f->common.prio);
block->mall.prio_max = max(block->mall.prio_max, f->common.prio);
}
int prestera_mall_replace(struct prestera_flow_block *block,
struct tc_cls_matchall_offload *f)
{
struct prestera_flow_block_binding *binding;
__be16 protocol = f->common.protocol;
struct flow_action_entry *act;
struct prestera_port *port;
int err;
if (!flow_offload_has_one_action(&f->rule->action)) {
NL_SET_ERR_MSG(f->common.extack,
"Only singular actions are supported");
return -EOPNOTSUPP;
}
act = &f->rule->action.entries[0];
if (!prestera_netdev_check(act->dev)) {
NL_SET_ERR_MSG(f->common.extack,
"Only Marvell Prestera port is supported");
return -EINVAL;
}
if (!tc_cls_can_offload_and_chain0(act->dev, &f->common))
return -EOPNOTSUPP;
if (act->id != FLOW_ACTION_MIRRED)
return -EOPNOTSUPP;
if (protocol != htons(ETH_P_ALL))
return -EOPNOTSUPP;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/list.h`, `prestera.h`, `prestera_hw.h`, `prestera_flow.h`, `prestera_flower.h`, `prestera_matchall.h`, `prestera_span.h`.
- Detected declarations: `function prestera_mall_prio_check`, `function prestera_mall_prio_get`, `function prestera_mall_prio_update`, `function prestera_mall_replace`, `function list_for_each_entry`, `function prestera_mall_destroy`.
- 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.