drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c- Extension
.c- Size
- 18043 bytes
- Lines
- 630
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/init.hlinux/netdevice.hlinux/etherdevice.hlinux/platform_device.hhns_dsaf_ppe.h
Detected Declarations
function Copyrightfunction hns_ppe_set_rss_keyfunction hns_ppe_set_indir_tablefunction hns_ppe_common_get_ioaddrfunction hns_ppe_common_get_cfgfunction hns_ppe_common_free_cfgfunction hns_ppe_get_cfgfunction hns_ppe_cnt_clr_cefunction hns_ppe_set_vlan_stripfunction hns_ppe_checksum_hwfunction hns_ppe_set_qid_modefunction hns_ppe_set_qidfunction hns_ppe_set_port_modefunction hns_ppe_common_init_hwfunction hns_ppe_exc_irq_enfunction hns_ppe_wait_tx_fifo_cleanfunction hns_ppe_init_hwfunction hns_ppe_uninit_hwfunction hns_ppe_uninit_exfunction hns_ppe_uninitfunction hns_ppe_reset_commonfunction hns_ppe_update_statsfunction hns_ppe_get_sset_countfunction hns_ppe_get_regs_countfunction hns_ppe_get_stringsfunction hns_ppe_get_statsfunction hns_ppe_initfunction hns_ppe_get_regs
Annotated Snippet
switch (dsaf_mode) {
case DSAF_MODE_ENABLE_FIX:
case DSAF_MODE_DISABLE_FIX:
qid_mode = PPE_QID_MODE0;
hns_ppe_set_qid(ppe_common, 0);
break;
case DSAF_MODE_ENABLE_0VM:
case DSAF_MODE_DISABLE_2PORT_64VM:
qid_mode = PPE_QID_MODE3;
break;
case DSAF_MODE_ENABLE_8VM:
case DSAF_MODE_DISABLE_2PORT_16VM:
qid_mode = PPE_QID_MODE4;
break;
case DSAF_MODE_ENABLE_16VM:
case DSAF_MODE_DISABLE_6PORT_0VM:
qid_mode = PPE_QID_MODE5;
break;
case DSAF_MODE_ENABLE_32VM:
case DSAF_MODE_DISABLE_6PORT_16VM:
qid_mode = PPE_QID_MODE2;
break;
case DSAF_MODE_ENABLE_128VM:
case DSAF_MODE_DISABLE_6PORT_4VM:
qid_mode = PPE_QID_MODE1;
break;
case DSAF_MODE_DISABLE_2PORT_8VM:
qid_mode = PPE_QID_MODE7;
break;
case DSAF_MODE_DISABLE_6PORT_2VM:
qid_mode = PPE_QID_MODE6;
break;
default:
dev_err(ppe_common->dev,
"get ppe queue mode failed! dsaf_mode=%d\n",
dsaf_mode);
return -EINVAL;
}
hns_ppe_set_qid_mode(ppe_common, qid_mode);
}
dsaf_set_dev_bit(ppe_common, PPE_COM_COMMON_CNT_CLR_CE_REG,
PPE_COMMON_CNT_CLR_CE_B, 1);
return 0;
}
/*clr ppe exception irq*/
static void hns_ppe_exc_irq_en(struct hns_ppe_cb *ppe_cb, int en)
{
u32 clr_vlue = 0xfffffffful;
u32 msk_vlue = en ? 0xfffffffful : 0; /*1 is en, 0 is dis*/
u32 vld_msk = 0;
/*only care bit 0,1,7*/
dsaf_set_bit(vld_msk, 0, 1);
dsaf_set_bit(vld_msk, 1, 1);
dsaf_set_bit(vld_msk, 7, 1);
/*clr sts**/
dsaf_write_dev(ppe_cb, PPE_RINT_REG, clr_vlue);
/*for some reserved bits, so set 0**/
dsaf_write_dev(ppe_cb, PPE_INTEN_REG, msk_vlue & vld_msk);
}
int hns_ppe_wait_tx_fifo_clean(struct hns_ppe_cb *ppe_cb)
{
int wait_cnt;
u32 val;
wait_cnt = 0;
while (wait_cnt++ < HNS_MAX_WAIT_CNT) {
val = dsaf_read_dev(ppe_cb, PPE_CURR_TX_FIFO0_REG) & 0x3ffU;
if (!val)
break;
usleep_range(100, 200);
}
if (wait_cnt >= HNS_MAX_WAIT_CNT) {
dev_err(ppe_cb->dev, "hns ppe tx fifo clean wait timeout, still has %u pkt.\n",
val);
return -EBUSY;
}
return 0;
}
/**
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/init.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `hns_dsaf_ppe.h`.
- Detected declarations: `function Copyright`, `function hns_ppe_set_rss_key`, `function hns_ppe_set_indir_table`, `function hns_ppe_common_get_ioaddr`, `function hns_ppe_common_get_cfg`, `function hns_ppe_common_free_cfg`, `function hns_ppe_get_cfg`, `function hns_ppe_cnt_clr_ce`, `function hns_ppe_set_vlan_strip`, `function hns_ppe_checksum_hw`.
- 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.