drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/huawei/hinic/hinic_hw_dev.c- Extension
.c- Size
- 31080 bytes
- Lines
- 1198
- 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.
- 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/kernel.hlinux/types.hlinux/pci.hlinux/device.hlinux/errno.hlinux/slab.hlinux/bitops.hlinux/delay.hlinux/jiffies.hlinux/log2.hlinux/err.hlinux/netdevice.hnet/devlink.hhinic_devlink.hhinic_sriov.hhinic_dev.hhinic_hw_if.hhinic_hw_eqs.hhinic_hw_mgmt.hhinic_hw_qp_ctxt.hhinic_hw_qp.hhinic_hw_io.hhinic_hw_dev.h
Detected Declarations
enum intr_typefunction parse_capabilityfunction get_capabilityfunction get_dev_capfunction init_msixfunction disable_msixfunction hinic_port_msg_cmdfunction hinic_hilink_msg_cmdfunction init_fw_ctxtfunction set_hw_ioctxtfunction wait_for_outbound_statefunction wait_for_db_statefunction clear_io_resourcesfunction set_resources_statefunction get_base_qpnfunction hinic_hwdev_ifupfunction hinic_hwdev_ifdownfunction hinic_hwdev_cb_registerfunction hinic_hwdev_cb_unregisterfunction nic_mgmt_msg_handlerfunction hinic_comm_recv_mgmt_self_cmd_regfunction hinic_comm_recv_mgmt_self_cmd_unregfunction comm_mgmt_msg_handlerfunction pf_fault_event_handlerfunction mgmt_watchdog_timeout_event_handlerfunction init_pfhwdevfunction free_pfhwdevfunction hinic_l2nic_resetfunction hinic_get_interrupt_cfgfunction hinic_set_interrupt_cfgfunction hinic_free_hwdevfunction hinic_hwdev_num_qpsfunction hinic_hwdev_msix_cnt_setfunction hinic_hwdev_msix_setfunction hinic_hwdev_hw_ci_addr_setfunction hinic_hwdev_set_msix_statefunction hinic_get_board_info
Annotated Snippet
if (err) {
dev_err(&pdev->dev, "Failed to get capability\n");
return err;
}
break;
default:
dev_err(&pdev->dev, "Unsupported PCI Function type\n");
return -EINVAL;
}
return 0;
}
/**
* init_msix - enable the msix and save the entries
* @hwdev: the NIC HW device
*
* Return 0 - Success, negative - Failure
**/
static int init_msix(struct hinic_hwdev *hwdev)
{
struct hinic_hwif *hwif = hwdev->hwif;
struct pci_dev *pdev = hwif->pdev;
int nr_irqs, num_aeqs, num_ceqs;
int i, err;
num_aeqs = HINIC_HWIF_NUM_AEQS(hwif);
num_ceqs = HINIC_HWIF_NUM_CEQS(hwif);
nr_irqs = MAX_IRQS(HINIC_MAX_QPS, num_aeqs, num_ceqs);
if (nr_irqs > HINIC_HWIF_NUM_IRQS(hwif))
nr_irqs = HINIC_HWIF_NUM_IRQS(hwif);
hwdev->msix_entries = devm_kcalloc(&pdev->dev, nr_irqs,
sizeof(*hwdev->msix_entries),
GFP_KERNEL);
if (!hwdev->msix_entries)
return -ENOMEM;
for (i = 0; i < nr_irqs; i++)
hwdev->msix_entries[i].entry = i;
err = pci_enable_msix_exact(pdev, hwdev->msix_entries, nr_irqs);
if (err) {
dev_err(&pdev->dev, "Failed to enable pci msix\n");
return err;
}
return 0;
}
/**
* disable_msix - disable the msix
* @hwdev: the NIC HW device
**/
static void disable_msix(struct hinic_hwdev *hwdev)
{
struct hinic_hwif *hwif = hwdev->hwif;
struct pci_dev *pdev = hwif->pdev;
pci_disable_msix(pdev);
}
/**
* hinic_port_msg_cmd - send port msg to mgmt
* @hwdev: the NIC HW device
* @cmd: the port command
* @buf_in: input buffer
* @in_size: input size
* @buf_out: output buffer
* @out_size: returned output size
*
* Return 0 - Success, negative - Failure
**/
int hinic_port_msg_cmd(struct hinic_hwdev *hwdev, enum hinic_port_cmd cmd,
void *buf_in, u16 in_size, void *buf_out, u16 *out_size)
{
struct hinic_pfhwdev *pfhwdev;
pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev);
return hinic_msg_to_mgmt(&pfhwdev->pf_to_mgmt, HINIC_MOD_L2NIC, cmd,
buf_in, in_size, buf_out, out_size,
HINIC_MGMT_MSG_SYNC);
}
int hinic_hilink_msg_cmd(struct hinic_hwdev *hwdev, enum hinic_hilink_cmd cmd,
void *buf_in, u16 in_size, void *buf_out,
u16 *out_size)
{
struct hinic_pfhwdev *pfhwdev;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/types.h`, `linux/pci.h`, `linux/device.h`, `linux/errno.h`, `linux/slab.h`, `linux/bitops.h`, `linux/delay.h`.
- Detected declarations: `enum intr_type`, `function parse_capability`, `function get_capability`, `function get_dev_cap`, `function init_msix`, `function disable_msix`, `function hinic_port_msg_cmd`, `function hinic_hilink_msg_cmd`, `function init_fw_ctxt`, `function set_hw_ioctxt`.
- 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.