drivers/net/ethernet/hisilicon/hns/hnae.h
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hns/hnae.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hns/hnae.h- Extension
.h- Size
- 20066 bytes
- Lines
- 708
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/delay.hlinux/device.hlinux/module.hlinux/netdevice.hlinux/notifier.hlinux/phy.hlinux/types.h
Detected Declarations
struct hnae_desc_cbstruct ring_statsstruct hnae_queuestruct hnae_ringstruct hnae_handlestruct hnae_buf_opsstruct hnae_queuestruct hnae_ae_opsstruct hnae_ae_devstruct hnae_handleenum hnae_led_stateenum hns_desc_typeenum hnae_loopenum hnae_port_typeenum hnae_media_typefunction Copyrightfunction ring_distfunction ring_spacefunction is_ring_emptyfunction hnae_reserve_buffer_mapfunction hnae_alloc_buffer_attachfunction hnae_buffer_detachfunction hnae_free_buffer_detachfunction hnae_replace_bufferfunction hnae_reuse_bufferfunction hnae_reinit_all_ring_descfunction hnae_reinit_all_ring_page_off
Annotated Snippet
struct hnae_desc_cb {
dma_addr_t dma; /* dma address of this desc */
void *buf; /* cpu addr for a desc */
/* priv data for the desc, e.g. skb when use with ip stack*/
void *priv;
u32 page_offset;
u32 length; /* length of the buffer */
u16 reuse_flag;
/* desc type, used by the ring user to mark the type of the priv data */
u16 type;
};
#define setflags(flags, bits) ((flags) |= (bits))
#define unsetflags(flags, bits) ((flags) &= ~(bits))
/* hnae_ring->flags fields */
#define RINGF_DIR 0x1 /* TX or RX ring, set if TX */
#define is_tx_ring(ring) ((ring)->flags & RINGF_DIR)
#define is_rx_ring(ring) (!is_tx_ring(ring))
#define ring_to_dma_dir(ring) (is_tx_ring(ring) ? \
DMA_TO_DEVICE : DMA_FROM_DEVICE)
struct ring_stats {
u64 io_err_cnt;
u64 sw_err_cnt;
u64 seg_pkt_cnt;
union {
struct {
u64 tx_pkts;
u64 tx_bytes;
u64 tx_err_cnt;
u64 restart_queue;
u64 tx_busy;
};
struct {
u64 rx_pkts;
u64 rx_bytes;
u64 rx_err_cnt;
u64 reuse_pg_cnt;
u64 err_pkt_len;
u64 non_vld_descs;
u64 err_bd_num;
u64 l2_err;
u64 l3l4_csum_err;
};
};
};
struct hnae_queue;
struct hnae_ring {
u8 __iomem *io_base; /* base io address for the ring */
struct hnae_desc *desc; /* dma map address space */
struct hnae_desc_cb *desc_cb;
struct hnae_queue *q;
int irq;
char ring_name[RCB_RING_NAME_LEN];
/* statistic */
struct ring_stats stats;
dma_addr_t desc_dma_addr;
u32 buf_size; /* size for hnae_desc->addr, preset by AE */
u16 desc_num; /* total number of desc */
u16 max_desc_num_per_pkt;
u16 max_raw_data_sz_per_desc;
u16 max_pkt_size;
int next_to_use; /* idx of next spare desc */
/* idx of lastest sent desc, the ring is empty when equal to
* next_to_use
*/
int next_to_clean;
int flags; /* ring attribute */
int irq_init_flag;
/* total rx bytes after last rx rate calucated */
u64 coal_last_rx_bytes;
unsigned long coal_last_jiffies;
u32 coal_param;
u32 coal_rx_rate; /* rx rate in MB */
};
#define ring_ptr_move_fw(ring, p) \
((ring)->p = ((ring)->p + 1) % (ring)->desc_num)
#define ring_ptr_move_bw(ring, p) \
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/delay.h`, `linux/device.h`, `linux/module.h`, `linux/netdevice.h`, `linux/notifier.h`, `linux/phy.h`, `linux/types.h`.
- Detected declarations: `struct hnae_desc_cb`, `struct ring_stats`, `struct hnae_queue`, `struct hnae_ring`, `struct hnae_handle`, `struct hnae_buf_ops`, `struct hnae_queue`, `struct hnae_ae_ops`, `struct hnae_ae_dev`, `struct hnae_handle`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.