drivers/net/ethernet/huawei/hinic/hinic_hw_if.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_hw_if.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_hw_if.c- Extension
.c- Size
- 11209 bytes
- Lines
- 420
- 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/pci.hlinux/device.hlinux/errno.hlinux/io.hlinux/types.hlinux/bitops.hlinux/delay.hhinic_hw_csr.hhinic_hw_if.h
Detected Declarations
function Copyrightfunction hinic_msix_attr_cnt_clearfunction hinic_set_pf_actionfunction hinic_outbound_state_getfunction hinic_outbound_state_setfunction hinic_db_state_getfunction hinic_db_state_setfunction hinic_set_msix_statefunction hwif_readyfunction wait_hwif_readyfunction set_hwif_attrfunction read_hwif_attrfunction set_ppffunction set_dma_attrfunction dma_attr_initfunction hinic_glb_pf_vf_offsetfunction hinic_global_func_id_hwfunction hinic_pf_id_of_vf_hwfunction __print_selftest_regfunction hinic_init_hwiffunction hinic_free_hwif
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Huawei HiNIC PCI Express Linux driver
* Copyright(c) 2017 Huawei Technologies Co., Ltd
*/
#include <linux/pci.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/io.h>
#include <linux/types.h>
#include <linux/bitops.h>
#include <linux/delay.h>
#include "hinic_hw_csr.h"
#include "hinic_hw_if.h"
#define PCIE_ATTR_ENTRY 0
#define VALID_MSIX_IDX(attr, msix_index) ((msix_index) < (attr)->num_irqs)
#define WAIT_HWIF_READY_TIMEOUT 10000
#define HINIC_SELFTEST_RESULT 0x883C
/**
* hinic_msix_attr_set - set message attribute for msix entry
* @hwif: the HW interface of a pci function device
* @msix_index: msix_index
* @pending_limit: the maximum pending interrupt events (unit 8)
* @coalesc_timer: coalesc period for interrupt (unit 8 us)
* @lli_timer: replenishing period for low latency credit (unit 8 us)
* @lli_credit_limit: maximum credits for low latency msix messages (unit 8)
* @resend_timer: maximum wait for resending msix (unit coalesc period)
*
* Return 0 - Success, negative - Failure
**/
int hinic_msix_attr_set(struct hinic_hwif *hwif, u16 msix_index,
u8 pending_limit, u8 coalesc_timer,
u8 lli_timer, u8 lli_credit_limit,
u8 resend_timer)
{
u32 msix_ctrl, addr;
if (!VALID_MSIX_IDX(&hwif->attr, msix_index))
return -EINVAL;
msix_ctrl = HINIC_MSIX_ATTR_SET(pending_limit, PENDING_LIMIT) |
HINIC_MSIX_ATTR_SET(coalesc_timer, COALESC_TIMER) |
HINIC_MSIX_ATTR_SET(lli_timer, LLI_TIMER) |
HINIC_MSIX_ATTR_SET(lli_credit_limit, LLI_CREDIT) |
HINIC_MSIX_ATTR_SET(resend_timer, RESEND_TIMER);
addr = HINIC_CSR_MSIX_CTRL_ADDR(msix_index);
hinic_hwif_write_reg(hwif, addr, msix_ctrl);
return 0;
}
/**
* hinic_msix_attr_cnt_clear - clear message attribute counters for msix entry
* @hwif: the HW interface of a pci function device
* @msix_index: msix_index
*
* Return 0 - Success, negative - Failure
**/
int hinic_msix_attr_cnt_clear(struct hinic_hwif *hwif, u16 msix_index)
{
u32 msix_ctrl, addr;
if (!VALID_MSIX_IDX(&hwif->attr, msix_index))
return -EINVAL;
msix_ctrl = HINIC_MSIX_CNT_SET(1, RESEND_TIMER);
addr = HINIC_CSR_MSIX_CNT_ADDR(msix_index);
hinic_hwif_write_reg(hwif, addr, msix_ctrl);
return 0;
}
/**
* hinic_set_pf_action - set action on pf channel
* @hwif: the HW interface of a pci function device
* @action: action on pf channel
**/
void hinic_set_pf_action(struct hinic_hwif *hwif, enum hinic_pf_action action)
{
u32 attr5;
if (HINIC_IS_VF(hwif))
Annotation
- Immediate include surface: `linux/pci.h`, `linux/device.h`, `linux/errno.h`, `linux/io.h`, `linux/types.h`, `linux/bitops.h`, `linux/delay.h`, `hinic_hw_csr.h`.
- Detected declarations: `function Copyright`, `function hinic_msix_attr_cnt_clear`, `function hinic_set_pf_action`, `function hinic_outbound_state_get`, `function hinic_outbound_state_set`, `function hinic_db_state_get`, `function hinic_db_state_set`, `function hinic_set_msix_state`, `function hwif_ready`, `function wait_hwif_ready`.
- 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.