186641094SJacob Keller /* Intel(R) Ethernet Switch Host Interface Driver 286641094SJacob Keller * Copyright(c) 2013 - 2016 Intel Corporation. 304a5aefbSAlexander Duyck * 404a5aefbSAlexander Duyck * This program is free software; you can redistribute it and/or modify it 504a5aefbSAlexander Duyck * under the terms and conditions of the GNU General Public License, 604a5aefbSAlexander Duyck * version 2, as published by the Free Software Foundation. 704a5aefbSAlexander Duyck * 804a5aefbSAlexander Duyck * This program is distributed in the hope it will be useful, but WITHOUT 904a5aefbSAlexander Duyck * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1004a5aefbSAlexander Duyck * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1104a5aefbSAlexander Duyck * more details. 1204a5aefbSAlexander Duyck * 1304a5aefbSAlexander Duyck * The full GNU General Public License is included in this distribution in 1404a5aefbSAlexander Duyck * the file called "COPYING". 1504a5aefbSAlexander Duyck * 1604a5aefbSAlexander Duyck * Contact Information: 1704a5aefbSAlexander Duyck * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> 1804a5aefbSAlexander Duyck * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 1904a5aefbSAlexander Duyck */ 2004a5aefbSAlexander Duyck 2104a5aefbSAlexander Duyck #ifndef _FM10K_COMMON_H_ 2204a5aefbSAlexander Duyck #define _FM10K_COMMON_H_ 2304a5aefbSAlexander Duyck 2404a5aefbSAlexander Duyck #include "fm10k_type.h" 2504a5aefbSAlexander Duyck 2604a5aefbSAlexander Duyck #define FM10K_REMOVED(hw_addr) unlikely(!(hw_addr)) 2704a5aefbSAlexander Duyck 2804a5aefbSAlexander Duyck /* PCI configuration read */ 2904a5aefbSAlexander Duyck u16 fm10k_read_pci_cfg_word(struct fm10k_hw *hw, u32 reg); 3004a5aefbSAlexander Duyck 3104a5aefbSAlexander Duyck /* read operations, indexed using DWORDS */ 3204a5aefbSAlexander Duyck u32 fm10k_read_reg(struct fm10k_hw *hw, int reg); 3304a5aefbSAlexander Duyck 3404a5aefbSAlexander Duyck /* write operations, indexed using DWORDS */ 3504a5aefbSAlexander Duyck #define fm10k_write_reg(hw, reg, val) \ 3604a5aefbSAlexander Duyck do { \ 37*ce4dad2cSJacob Keller u32 __iomem *hw_addr = READ_ONCE((hw)->hw_addr); \ 3804a5aefbSAlexander Duyck if (!FM10K_REMOVED(hw_addr)) \ 3904a5aefbSAlexander Duyck writel((val), &hw_addr[(reg)]); \ 4004a5aefbSAlexander Duyck } while (0) 4104a5aefbSAlexander Duyck 425f226ddbSAlexander Duyck /* Switch register write operations, index using DWORDS */ 435f226ddbSAlexander Duyck #define fm10k_write_sw_reg(hw, reg, val) \ 445f226ddbSAlexander Duyck do { \ 45*ce4dad2cSJacob Keller u32 __iomem *sw_addr = READ_ONCE((hw)->sw_addr); \ 465f226ddbSAlexander Duyck if (!FM10K_REMOVED(sw_addr)) \ 475f226ddbSAlexander Duyck writel((val), &sw_addr[(reg)]); \ 485f226ddbSAlexander Duyck } while (0) 495f226ddbSAlexander Duyck 5004a5aefbSAlexander Duyck /* read ctrl register which has no clear on read fields as PCIe flush */ 5104a5aefbSAlexander Duyck #define fm10k_write_flush(hw) fm10k_read_reg((hw), FM10K_CTRL) 52b6fec18fSAlexander Duyck s32 fm10k_get_bus_info_generic(struct fm10k_hw *hw); 53b6fec18fSAlexander Duyck s32 fm10k_get_invariants_generic(struct fm10k_hw *hw); 54b6fec18fSAlexander Duyck s32 fm10k_disable_queues_generic(struct fm10k_hw *hw, u16 q_cnt); 55b6fec18fSAlexander Duyck s32 fm10k_start_hw_generic(struct fm10k_hw *hw); 56b6fec18fSAlexander Duyck s32 fm10k_stop_hw_generic(struct fm10k_hw *hw); 57b6fec18fSAlexander Duyck u32 fm10k_read_hw_stats_32b(struct fm10k_hw *hw, u32 addr, 58b6fec18fSAlexander Duyck struct fm10k_hw_stat *stat); 59b6fec18fSAlexander Duyck #define fm10k_update_hw_base_32b(stat, delta) ((stat)->base_l += (delta)) 60b6fec18fSAlexander Duyck void fm10k_update_hw_stats_q(struct fm10k_hw *hw, struct fm10k_hw_stats_q *q, 61b6fec18fSAlexander Duyck u32 idx, u32 count); 62b6fec18fSAlexander Duyck #define fm10k_unbind_hw_stats_32b(s) ((s)->base_h = 0) 63b6fec18fSAlexander Duyck void fm10k_unbind_hw_stats_q(struct fm10k_hw_stats_q *q, u32 idx, u32 count); 64b6fec18fSAlexander Duyck s32 fm10k_get_host_state_generic(struct fm10k_hw *hw, bool *host_ready); 6504a5aefbSAlexander Duyck #endif /* _FM10K_COMMON_H_ */ 66