ice_osdep.h 2.0 KB

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