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.

Dependency Surface

Detected Declarations

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

Implementation Notes