162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright(c) 2013 - 2018 Intel Corporation. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _FM10K_COMMON_H_ 562306a36Sopenharmony_ci#define _FM10K_COMMON_H_ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include "fm10k_type.h" 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define FM10K_REMOVED(hw_addr) unlikely(!(hw_addr)) 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* PCI configuration read */ 1262306a36Sopenharmony_ciu16 fm10k_read_pci_cfg_word(struct fm10k_hw *hw, u32 reg); 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* read operations, indexed using DWORDS */ 1562306a36Sopenharmony_ciu32 fm10k_read_reg(struct fm10k_hw *hw, int reg); 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* write operations, indexed using DWORDS */ 1862306a36Sopenharmony_ci#define fm10k_write_reg(hw, reg, val) \ 1962306a36Sopenharmony_cido { \ 2062306a36Sopenharmony_ci u32 __iomem *hw_addr = READ_ONCE((hw)->hw_addr); \ 2162306a36Sopenharmony_ci if (!FM10K_REMOVED(hw_addr)) \ 2262306a36Sopenharmony_ci writel((val), &hw_addr[(reg)]); \ 2362306a36Sopenharmony_ci} while (0) 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci/* Switch register write operations, index using DWORDS */ 2662306a36Sopenharmony_ci#define fm10k_write_sw_reg(hw, reg, val) \ 2762306a36Sopenharmony_cido { \ 2862306a36Sopenharmony_ci u32 __iomem *sw_addr = READ_ONCE((hw)->sw_addr); \ 2962306a36Sopenharmony_ci if (!FM10K_REMOVED(sw_addr)) \ 3062306a36Sopenharmony_ci writel((val), &sw_addr[(reg)]); \ 3162306a36Sopenharmony_ci} while (0) 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ci/* read ctrl register which has no clear on read fields as PCIe flush */ 3462306a36Sopenharmony_ci#define fm10k_write_flush(hw) fm10k_read_reg((hw), FM10K_CTRL) 3562306a36Sopenharmony_cis32 fm10k_get_bus_info_generic(struct fm10k_hw *hw); 3662306a36Sopenharmony_cis32 fm10k_get_invariants_generic(struct fm10k_hw *hw); 3762306a36Sopenharmony_cis32 fm10k_disable_queues_generic(struct fm10k_hw *hw, u16 q_cnt); 3862306a36Sopenharmony_cis32 fm10k_start_hw_generic(struct fm10k_hw *hw); 3962306a36Sopenharmony_cis32 fm10k_stop_hw_generic(struct fm10k_hw *hw); 4062306a36Sopenharmony_ciu32 fm10k_read_hw_stats_32b(struct fm10k_hw *hw, u32 addr, 4162306a36Sopenharmony_ci struct fm10k_hw_stat *stat); 4262306a36Sopenharmony_ci#define fm10k_update_hw_base_32b(stat, delta) ((stat)->base_l += (delta)) 4362306a36Sopenharmony_civoid fm10k_update_hw_stats_q(struct fm10k_hw *hw, struct fm10k_hw_stats_q *q, 4462306a36Sopenharmony_ci u32 idx, u32 count); 4562306a36Sopenharmony_ci#define fm10k_unbind_hw_stats_32b(s) ((s)->base_h = 0) 4662306a36Sopenharmony_civoid fm10k_unbind_hw_stats_q(struct fm10k_hw_stats_q *q, u32 idx, u32 count); 4762306a36Sopenharmony_cis32 fm10k_get_host_state_generic(struct fm10k_hw *hw, bool *host_ready); 4862306a36Sopenharmony_ci#endif /* _FM10K_COMMON_H_ */ 49