drivers/net/ethernet/qualcomm/ppe/ppe_debugfs.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/qualcomm/ppe/ppe_debugfs.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/qualcomm/ppe/ppe_debugfs.c
Extension
.c
Size
22376 bytes
Lines
848
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 ppe_debugfs_entry {
	const char *name;
	enum ppe_cnt_type counter_type;
	struct ppe_device *ppe;
};

static const struct ppe_debugfs_entry debugfs_files[] = {
	{
		.name			= "bm",
		.counter_type		= PPE_CNT_BM,
	},
	{
		.name			= "parse",
		.counter_type		= PPE_CNT_PARSE,
	},
	{
		.name			= "port_rx",
		.counter_type		= PPE_CNT_PORT_RX,
	},
	{
		.name			= "vlan_rx",
		.counter_type		= PPE_CNT_VLAN_RX,
	},
	{
		.name			= "l2_forward",
		.counter_type		= PPE_CNT_L2_FWD,
	},
	{
		.name			= "cpu_code",
		.counter_type		= PPE_CNT_CPU_CODE,
	},
	{
		.name			= "vlan_tx",
		.counter_type		= PPE_CNT_VLAN_TX,
	},
	{
		.name			= "port_tx",
		.counter_type		= PPE_CNT_PORT_TX,
	},
	{
		.name			= "qm",
		.counter_type		= PPE_CNT_QM,
	},
};

static int ppe_pkt_cnt_get(struct ppe_device *ppe_dev, u32 reg,
			   enum ppe_cnt_size_type cnt_type,
			   u32 *cnt, u32 *drop_cnt)
{
	u32 drop_pkt_cnt[PPE_DROP_PKT_CNT_TBL_SIZE];
	u32 pkt_cnt[PPE_PKT_CNT_TBL_SIZE];
	u32 value;
	int ret;

	switch (cnt_type) {
	case PPE_PKT_CNT_SIZE_1WORD:
		ret = regmap_read(ppe_dev->regmap, reg, &value);
		if (ret)
			return ret;

		*cnt = value;
		break;
	case PPE_PKT_CNT_SIZE_3WORD:
		ret = regmap_bulk_read(ppe_dev->regmap, reg,
				       pkt_cnt, ARRAY_SIZE(pkt_cnt));
		if (ret)
			return ret;

		*cnt = PPE_GET_PKT_CNT(pkt_cnt);
		break;
	case PPE_PKT_CNT_SIZE_5WORD:
		ret = regmap_bulk_read(ppe_dev->regmap, reg,
				       drop_pkt_cnt, ARRAY_SIZE(drop_pkt_cnt));
		if (ret)
			return ret;

		*cnt = PPE_GET_PKT_CNT(drop_pkt_cnt);

		/* Drop counter with low 24 bits. */
		value  = PPE_GET_DROP_PKT_CNT_LOW(drop_pkt_cnt);
		*drop_cnt = FIELD_PREP(GENMASK(23, 0), value);

		/* Drop counter with high 8 bits. */
		value  = PPE_GET_DROP_PKT_CNT_HIGH(drop_pkt_cnt);
		*drop_cnt |= FIELD_PREP(GENMASK(31, 24), value);
		break;
	}

	return 0;
}

Annotation

Implementation Notes