drivers/net/dsa/microchip/ksz_dcb.c
Source file repositories/reference/linux-study-clean/drivers/net/dsa/microchip/ksz_dcb.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/dsa/microchip/ksz_dcb.c- Extension
.c- Size
- 17914 bytes
- Lines
- 613
- 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/dsa/ksz_common.hnet/dsa.hnet/dscp.hnet/ieee8021q.hksz_common.hksz_dcb.hksz8.h
Detected Declarations
struct ksz_apptrust_mapfunction ksz_get_default_port_prio_regfunction ksz_get_dscp_prio_regfunction ksz_get_apptrust_map_and_regfunction ksz_port_get_default_priofunction ksz_port_set_default_priofunction ksz_port_get_dscp_priofunction Mapfunction ksz_set_global_dscp_entryfunction ksz_init_global_dscp_mapfunction Mapfunction ksz_port_add_dscp_priofunction ksz_port_del_dscp_priofunction ksz_apptrust_errorfunction ksz_port_set_apptrust_validatefunction ksz_port_set_apptrustfunction ksz_port_get_apptrustfunction ksz_dcb_init_portfunction ksz_dcb_init
Annotated Snippet
struct ksz_apptrust_map {
u8 apptrust;
u8 bit;
};
static const struct ksz_apptrust_map ksz8_apptrust_map_to_bit[] = {
{ DCB_APP_SEL_PCP, KSZ8_PORT_802_1P_ENABLE },
{ IEEE_8021QAZ_APP_SEL_DSCP, KSZ8_PORT_DIFFSERV_ENABLE },
};
static const struct ksz_apptrust_map ksz9477_apptrust_map_to_bit[] = {
{ DCB_APP_SEL_PCP, KSZ9477_PORT_802_1P_PRIO_ENABLE },
{ IEEE_8021QAZ_APP_SEL_DSCP, KSZ9477_PORT_DIFFSERV_PRIO_ENABLE },
};
/* ksz_supported_apptrust[] - Supported apptrust selectors and Priority Order
* of Internal Priority Map (IPM) sources.
*
* This array defines the apptrust selectors supported by the hardware, where
* the index within the array indicates the priority of the selector - lower
* indices correspond to higher priority. This fixed priority scheme is due to
* the hardware's design, which does not support configurable priority among
* different priority sources.
*
* The priority sources, including Tail Tag, ACL, VLAN PCP and DSCP are ordered
* by the hardware's fixed logic, as detailed below. The order reflects a
* non-configurable precedence where certain types of priority information
* override others:
*
* 1. Tail Tag - Highest priority, overrides ACL, VLAN PCP, and DSCP priorities.
* 2. ACL - Overrides VLAN PCP and DSCP priorities.
* 3. VLAN PCP - Overrides DSCP priority.
* 4. DSCP - Lowest priority, does not override any other priority source.
*
* In this context, the array's lower index (higher priority) for
* 'DCB_APP_SEL_PCP' suggests its relative priority over
* 'IEEE_8021QAZ_APP_SEL_DSCP' within the system's fixed priority scheme.
*
* DCB_APP_SEL_PCP - Priority Code Point selector
* IEEE_8021QAZ_APP_SEL_DSCP - Differentiated Services Code Point selector
*/
static const u8 ksz_supported_apptrust[] = {
DCB_APP_SEL_PCP,
IEEE_8021QAZ_APP_SEL_DSCP,
};
static const char * const ksz_supported_apptrust_variants[] = {
"empty", "dscp", "pcp", "dscp pcp"
};
static void ksz_get_default_port_prio_reg(struct ksz_device *dev, int *reg,
u8 *mask, int *shift)
{
if (is_ksz8(dev)) {
*reg = KSZ8_REG_PORT_1_CTRL_0;
*mask = KSZ8_PORT_BASED_PRIO_M;
*shift = __bf_shf(KSZ8_PORT_BASED_PRIO_M);
if (ksz_is_ksz8463(dev))
*reg = KSZ8463_REG_PORT_1_CTRL_0;
} else {
*reg = KSZ9477_REG_PORT_MRI_MAC_CTRL;
*mask = KSZ9477_PORT_BASED_PRIO_M;
*shift = __bf_shf(KSZ9477_PORT_BASED_PRIO_M);
}
}
/**
* ksz_get_dscp_prio_reg - Retrieves the DSCP-to-priority-mapping register
* @dev: Pointer to the KSZ switch device structure
* @reg: Pointer to the register address to be set
* @per_reg: Pointer to the number of DSCP values per register
* @mask: Pointer to the mask to be set
*
* This function retrieves the DSCP to priority mapping register, the number of
* DSCP values per register, and the mask to be set.
*/
static void ksz_get_dscp_prio_reg(struct ksz_device *dev, int *reg,
int *per_reg, u8 *mask)
{
if (ksz_is_ksz87xx(dev) || ksz_is_8895_family(dev)) {
*reg = KSZ8765_REG_TOS_DSCP_CTRL;
*per_reg = 4;
*mask = GENMASK(1, 0);
} else if (ksz_is_ksz88x3(dev) || ksz_is_ksz8463(dev)) {
*reg = KSZ88X3_REG_TOS_DSCP_CTRL;
*per_reg = 4;
*mask = GENMASK(1, 0);
if (ksz_is_ksz8463(dev))
*reg = KSZ8463_REG_TOS_DSCP_CTRL;
} else {
Annotation
- Immediate include surface: `linux/dsa/ksz_common.h`, `net/dsa.h`, `net/dscp.h`, `net/ieee8021q.h`, `ksz_common.h`, `ksz_dcb.h`, `ksz8.h`.
- Detected declarations: `struct ksz_apptrust_map`, `function ksz_get_default_port_prio_reg`, `function ksz_get_dscp_prio_reg`, `function ksz_get_apptrust_map_and_reg`, `function ksz_port_get_default_prio`, `function ksz_port_set_default_prio`, `function ksz_port_get_dscp_prio`, `function Map`, `function ksz_set_global_dscp_entry`, `function ksz_init_global_dscp_map`.
- 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.