1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright (c) 2018, Intel Corporation. */ 3 4#ifndef _ICE_OSDEP_H_ 5#define _ICE_OSDEP_H_ 6 7#include <linux/types.h> 8#include <linux/io.h> 9#ifndef CONFIG_64BIT 10#include <linux/io-64-nonatomic-lo-hi.h> 11#endif 12 13#define wr32(a, reg, value) writel((value), ((a)->hw_addr + (reg))) 14#define rd32(a, reg) readl((a)->hw_addr + (reg)) 15#define wr64(a, reg, value) writeq((value), ((a)->hw_addr + (reg))) 16#define rd64(a, reg) readq((a)->hw_addr + (reg)) 17 18#define ice_flush(a) rd32((a), GLGEN_STAT) 19#define ICE_M(m, s) ((m) << (s)) 20 21struct ice_dma_mem { 22 void *va; 23 dma_addr_t pa; 24 size_t size; 25}; 26 27#define ice_hw_to_dev(ptr) \ 28 (&(container_of((ptr), struct ice_pf, hw))->pdev->dev) 29 30#ifdef CONFIG_DYNAMIC_DEBUG 31#define ice_debug(hw, type, fmt, args...) \ 32 dev_dbg(ice_hw_to_dev(hw), fmt, ##args) 33 34#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 35 print_hex_dump_debug(KBUILD_MODNAME " ", \ 36 DUMP_PREFIX_OFFSET, rowsize, \ 37 groupsize, buf, len, false) 38#else 39#define ice_debug(hw, type, fmt, args...) \ 40do { \ 41 if ((type) & (hw)->debug_mask) \ 42 dev_info(ice_hw_to_dev(hw), fmt, ##args); \ 43} while (0) 44 45#ifdef DEBUG 46#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 47do { \ 48 if ((type) & (hw)->debug_mask) \ 49 print_hex_dump_debug(KBUILD_MODNAME, \ 50 DUMP_PREFIX_OFFSET, \ 51 rowsize, groupsize, buf, \ 52 len, false); \ 53} while (0) 54#else 55#define ice_debug_array(hw, type, rowsize, groupsize, buf, len) \ 56do { \ 57 struct ice_hw *hw_l = hw; \ 58 if ((type) & (hw_l)->debug_mask) { \ 59 u16 len_l = len; \ 60 u8 *buf_l = buf; \ 61 int i; \ 62 for (i = 0; i < (len_l - 16); i += 16) \ 63 ice_debug(hw_l, type, "0x%04X %16ph\n",\ 64 i, ((buf_l) + i)); \ 65 if (i < len_l) \ 66 ice_debug(hw_l, type, "0x%04X %*ph\n", \ 67 i, ((len_l) - i), ((buf_l) + i));\ 68 } \ 69} while (0) 70#endif /* DEBUG */ 71#endif /* CONFIG_DYNAMIC_DEBUG */ 72 73#endif /* _ICE_OSDEP_H_ */ 74