drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c- Extension
.c- Size
- 10300 bytes
- Lines
- 409
- 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/dcbnl.hsparx5_port.h
Detected Declarations
enum sparx5_dcb_apptrust_valuesfunction sparx5_dcb_app_validatefunction sparx5_dcb_apptrust_validatefunction sparx5_dcb_apptrust_containsfunction sparx5_dcb_app_updatefunction sparx5_dcb_ieee_dscp_setdelfunction sparx5_dcb_ieee_delappfunction sparx5_dcb_ieee_setappfunction sparx5_dcb_setapptrustfunction sparx5_dcb_getapptrustfunction sparx5_dcb_delrewrfunction sparx5_dcb_setrewrfunction sparx5_dcb_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/* Microchip Sparx5 Switch driver
*
* Copyright (c) 2022 Microchip Technology Inc. and its subsidiaries.
*/
#include <net/dcbnl.h>
#include "sparx5_port.h"
enum sparx5_dcb_apptrust_values {
SPARX5_DCB_APPTRUST_EMPTY,
SPARX5_DCB_APPTRUST_DSCP,
SPARX5_DCB_APPTRUST_PCP,
SPARX5_DCB_APPTRUST_DSCP_PCP,
__SPARX5_DCB_APPTRUST_MAX
};
static const struct sparx5_dcb_apptrust {
u8 selectors[IEEE_8021QAZ_APP_SEL_MAX + 1];
int nselectors;
} *sparx5_port_apptrust[SPX5_PORTS];
static const char *sparx5_dcb_apptrust_names[__SPARX5_DCB_APPTRUST_MAX] = {
[SPARX5_DCB_APPTRUST_EMPTY] = "empty",
[SPARX5_DCB_APPTRUST_DSCP] = "dscp",
[SPARX5_DCB_APPTRUST_PCP] = "pcp",
[SPARX5_DCB_APPTRUST_DSCP_PCP] = "dscp pcp"
};
/* Sparx5 supported apptrust policies */
static const struct sparx5_dcb_apptrust
sparx5_dcb_apptrust_policies[__SPARX5_DCB_APPTRUST_MAX] = {
/* Empty *must* be first */
[SPARX5_DCB_APPTRUST_EMPTY] = { { 0 }, 0 },
[SPARX5_DCB_APPTRUST_DSCP] = { { IEEE_8021QAZ_APP_SEL_DSCP }, 1 },
[SPARX5_DCB_APPTRUST_PCP] = { { DCB_APP_SEL_PCP }, 1 },
[SPARX5_DCB_APPTRUST_DSCP_PCP] = { { IEEE_8021QAZ_APP_SEL_DSCP,
DCB_APP_SEL_PCP }, 2 },
};
/* Validate app entry.
*
* Check for valid selectors and valid protocol and priority ranges.
*/
static int sparx5_dcb_app_validate(struct net_device *dev,
const struct dcb_app *app)
{
int err = 0;
switch (app->selector) {
/* Default priority checks */
case IEEE_8021QAZ_APP_SEL_ETHERTYPE:
if (app->protocol != 0)
err = -EINVAL;
else if (app->priority >= SPX5_PRIOS)
err = -ERANGE;
break;
/* Dscp checks */
case IEEE_8021QAZ_APP_SEL_DSCP:
if (app->protocol >= SPARX5_PORT_QOS_DSCP_COUNT)
err = -EINVAL;
else if (app->priority >= SPX5_PRIOS)
err = -ERANGE;
break;
/* Pcp checks */
case DCB_APP_SEL_PCP:
if (app->protocol >= SPARX5_PORT_QOS_PCP_DEI_COUNT)
err = -EINVAL;
else if (app->priority >= SPX5_PRIOS)
err = -ERANGE;
break;
default:
err = -EINVAL;
break;
}
if (err)
netdev_err(dev, "Invalid entry: %d:%d\n", app->protocol,
app->priority);
return err;
}
/* Validate apptrust configuration.
*
* Return index of supported apptrust configuration if valid, otherwise return
* error.
*/
static int sparx5_dcb_apptrust_validate(struct net_device *dev, u8 *selectors,
Annotation
- Immediate include surface: `net/dcbnl.h`, `sparx5_port.h`.
- Detected declarations: `enum sparx5_dcb_apptrust_values`, `function sparx5_dcb_app_validate`, `function sparx5_dcb_apptrust_validate`, `function sparx5_dcb_apptrust_contains`, `function sparx5_dcb_app_update`, `function sparx5_dcb_ieee_dscp_setdel`, `function sparx5_dcb_ieee_delapp`, `function sparx5_dcb_ieee_setapp`, `function sparx5_dcb_setapptrust`, `function sparx5_dcb_getapptrust`.
- 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.