// 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 … #define VALID_MSIX_IDX(attr, msix_index) … #define WAIT_HWIF_READY_TIMEOUT … #define HINIC_SELFTEST_RESULT … /** * 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) { … } /** * 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) { … } /** * 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) { … } enum hinic_outbound_state hinic_outbound_state_get(struct hinic_hwif *hwif) { … } void hinic_outbound_state_set(struct hinic_hwif *hwif, enum hinic_outbound_state outbound_state) { … } enum hinic_db_state hinic_db_state_get(struct hinic_hwif *hwif) { … } void hinic_db_state_set(struct hinic_hwif *hwif, enum hinic_db_state db_state) { … } void hinic_set_msix_state(struct hinic_hwif *hwif, u16 msix_idx, enum hinic_msix_state flag) { … } /** * hwif_ready - test if the HW is ready for use * @hwif: the HW interface of a pci function device * * Return 0 - Success, negative - Failure **/ static int hwif_ready(struct hinic_hwif *hwif) { … } static int wait_hwif_ready(struct hinic_hwif *hwif) { … } /** * set_hwif_attr - set the attributes in the relevant members in hwif * @hwif: the HW interface of a pci function device * @attr0: the first attribute that was read from the hw * @attr1: the second attribute that was read from the hw * @attr2: the third attribute that was read from the hw **/ static void set_hwif_attr(struct hinic_hwif *hwif, u32 attr0, u32 attr1, u32 attr2) { … } /** * read_hwif_attr - read the attributes and set members in hwif * @hwif: the HW interface of a pci function device **/ static void read_hwif_attr(struct hinic_hwif *hwif) { … } /** * set_ppf - try to set hwif as ppf and set the type of hwif in this case * @hwif: the HW interface of a pci function device **/ static void set_ppf(struct hinic_hwif *hwif) { … } /** * set_dma_attr - set the dma attributes in the HW * @hwif: the HW interface of a pci function device * @entry_idx: the entry index in the dma table * @st: PCIE TLP steering tag * @at: PCIE TLP AT field * @ph: PCIE TLP Processing Hint field * @no_snooping: PCIE TLP No snooping * @tph_en: PCIE TLP Processing Hint Enable **/ static void set_dma_attr(struct hinic_hwif *hwif, u32 entry_idx, u8 st, u8 at, u8 ph, enum hinic_pcie_nosnoop no_snooping, enum hinic_pcie_tph tph_en) { … } /** * dma_attr_init - initialize the default dma attributes * @hwif: the HW interface of a pci function device **/ static void dma_attr_init(struct hinic_hwif *hwif) { … } u16 hinic_glb_pf_vf_offset(struct hinic_hwif *hwif) { … } u16 hinic_global_func_id_hw(struct hinic_hwif *hwif) { … } u16 hinic_pf_id_of_vf_hw(struct hinic_hwif *hwif) { … } static void __print_selftest_reg(struct hinic_hwif *hwif) { … } /** * hinic_init_hwif - initialize the hw interface * @hwif: the HW interface of a pci function device * @pdev: the pci device for accessing PCI resources * * Return 0 - Success, negative - Failure **/ int hinic_init_hwif(struct hinic_hwif *hwif, struct pci_dev *pdev) { … } /** * hinic_free_hwif - free the HW interface * @hwif: the HW interface of a pci function device **/ void hinic_free_hwif(struct hinic_hwif *hwif) { … }