drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_hw_eqs.c- Extension
.c- Size
- 25990 bytes
- Lines
- 997
- 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/kernel.hlinux/types.hlinux/errno.hlinux/pci.hlinux/device.hlinux/workqueue.hlinux/interrupt.hlinux/slab.hlinux/dma-mapping.hlinux/log2.hasm/byteorder.hasm/barrier.hhinic_hw_dev.hhinic_hw_csr.hhinic_hw_if.hhinic_hw_eqs.h
Detected Declarations
enum eq_int_modeenum eq_arm_statefunction hinic_aeq_register_hw_cbfunction hinic_aeq_unregister_hw_cbfunction hinic_ceq_register_cbfunction hinic_ceq_unregister_cbfunction eq_cons_idx_checksum_setfunction eq_update_cifunction aeq_irq_handlerfunction ceq_event_handlerfunction ceq_irq_handlerfunction eq_irq_handlerfunction eq_irq_workfunction ceq_taskletfunction aeq_interruptfunction ceq_interruptfunction get_ctrl0_valfunction set_ctrl0function get_ctrl1_valfunction set_ctrl1function set_ceq_ctrl_regfunction set_eq_ctrlsfunction aeq_elements_initfunction ceq_elements_initfunction alloc_eq_pagesfunction free_eq_pagesfunction init_eqfunction remove_eqfunction hinic_aeqs_initfunction hinic_aeqs_freefunction hinic_ceqs_initfunction hinic_ceqs_freefunction hinic_dump_ceq_infofunction hinic_dump_aeq_info
Annotated Snippet
if (event >= HINIC_MAX_AEQ_EVENTS) {
dev_err(&pdev->dev, "Unknown AEQ Event %d\n", event);
return;
}
if (!HINIC_EQ_ELEM_DESC_GET(aeqe_desc, SRC)) {
hwe_cb = &aeqs->hwe_cb[event];
size = HINIC_EQ_ELEM_DESC_GET(aeqe_desc, SIZE);
eqe_state = cmpxchg(&hwe_cb->hwe_state,
HINIC_EQE_ENABLED,
HINIC_EQE_ENABLED |
HINIC_EQE_RUNNING);
if (eqe_state == HINIC_EQE_ENABLED &&
hwe_cb->hwe_handler)
hwe_cb->hwe_handler(hwe_cb->handle,
aeqe_curr->data, size);
else
dev_err(&pdev->dev, "Unhandled AEQ Event %d\n",
event);
hwe_cb->hwe_state &= ~HINIC_EQE_RUNNING;
}
eq->cons_idx++;
if (eq->cons_idx == eq->q_len) {
eq->cons_idx = 0;
eq->wrapped = !eq->wrapped;
}
}
}
/**
* ceq_event_handler - handler for the ceq events
* @ceqs: ceqs part of the chip
* @ceqe: ceq element that describes the event
**/
static void ceq_event_handler(struct hinic_ceqs *ceqs, u32 ceqe)
{
struct hinic_hwif *hwif = ceqs->hwif;
struct pci_dev *pdev = hwif->pdev;
struct hinic_ceq_cb *ceq_cb;
enum hinic_ceq_type event;
unsigned long eqe_state;
event = CEQE_TYPE(ceqe);
if (event >= HINIC_MAX_CEQ_EVENTS) {
dev_err(&pdev->dev, "Unknown CEQ event, event = %d\n", event);
return;
}
ceq_cb = &ceqs->ceq_cb[event];
eqe_state = cmpxchg(&ceq_cb->ceqe_state,
HINIC_EQE_ENABLED,
HINIC_EQE_ENABLED | HINIC_EQE_RUNNING);
if (eqe_state == HINIC_EQE_ENABLED && ceq_cb->handler)
ceq_cb->handler(ceq_cb->handle, CEQE_DATA(ceqe));
else
dev_err(&pdev->dev, "Unhandled CEQ Event %d\n", event);
ceq_cb->ceqe_state &= ~HINIC_EQE_RUNNING;
}
/**
* ceq_irq_handler - handler for the CEQ event
* @eq: the Completion Event Queue that received the event
**/
static void ceq_irq_handler(struct hinic_eq *eq)
{
struct hinic_ceqs *ceqs = ceq_to_ceqs(eq);
u32 ceqe;
int i;
for (i = 0; i < eq->q_len; i++) {
ceqe = *(GET_CURR_CEQ_ELEM(eq));
/* Data in HW is in Big endian Format */
ceqe = be32_to_cpu(ceqe);
/* HW toggles the wrapped bit, when it adds eq element event */
if (HINIC_EQ_ELEM_DESC_GET(ceqe, WRAPPED) == eq->wrapped)
break;
ceq_event_handler(ceqs, ceqe);
eq->cons_idx++;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/errno.h`, `linux/pci.h`, `linux/device.h`, `linux/workqueue.h`, `linux/interrupt.h`, `linux/slab.h`.
- Detected declarations: `enum eq_int_mode`, `enum eq_arm_state`, `function hinic_aeq_register_hw_cb`, `function hinic_aeq_unregister_hw_cb`, `function hinic_ceq_register_cb`, `function hinic_ceq_unregister_cb`, `function eq_cons_idx_checksum_set`, `function eq_update_ci`, `function aeq_irq_handler`, `function ceq_event_handler`.
- 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.