mic_smpt.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Intel MIC Platform Software Stack (MPSS)
  3. *
  4. * Copyright(c) 2013 Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License, version 2, as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * The full GNU General Public License is included in this distribution in
  16. * the file called "COPYING".
  17. *
  18. * Intel MIC Host driver.
  19. *
  20. */
  21. #ifndef MIC_SMPT_H
  22. #define MIC_SMPT_H
  23. /**
  24. * struct mic_smpt_ops - MIC HW specific SMPT operations.
  25. * @init: Initialize hardware specific SMPT information in mic_smpt_hw_info.
  26. * @set: Set the value for a particular SMPT entry.
  27. */
  28. struct mic_smpt_ops {
  29. void (*init)(struct mic_device *mdev);
  30. void (*set)(struct mic_device *mdev, dma_addr_t dma_addr, u8 index);
  31. };
  32. /**
  33. * struct mic_smpt - MIC SMPT entry information.
  34. * @dma_addr: Base DMA address for this SMPT entry.
  35. * @ref_count: Number of active mappings for this SMPT entry in bytes.
  36. */
  37. struct mic_smpt {
  38. dma_addr_t dma_addr;
  39. s64 ref_count;
  40. };
  41. /**
  42. * struct mic_smpt_hw_info - MIC SMPT hardware specific information.
  43. * @num_reg: Number of SMPT registers.
  44. * @page_shift: System memory page shift.
  45. * @page_size: System memory page size.
  46. * @base: System address base.
  47. */
  48. struct mic_smpt_hw_info {
  49. u8 num_reg;
  50. u8 page_shift;
  51. u64 page_size;
  52. u64 base;
  53. };
  54. /**
  55. * struct mic_smpt_info - MIC SMPT information.
  56. * @entry: Array of SMPT entries.
  57. * @smpt_lock: Spin lock protecting access to SMPT data structures.
  58. * @info: Hardware specific SMPT information.
  59. * @ref_count: Number of active SMPT mappings (for debug).
  60. * @map_count: Number of SMPT mappings created (for debug).
  61. * @unmap_count: Number of SMPT mappings destroyed (for debug).
  62. */
  63. struct mic_smpt_info {
  64. struct mic_smpt *entry;
  65. spinlock_t smpt_lock;
  66. struct mic_smpt_hw_info info;
  67. s64 ref_count;
  68. s64 map_count;
  69. s64 unmap_count;
  70. };
  71. dma_addr_t mic_map_single(struct mic_device *mdev, void *va, size_t size);
  72. void mic_unmap_single(struct mic_device *mdev,
  73. dma_addr_t mic_addr, size_t size);
  74. dma_addr_t mic_map(struct mic_device *mdev,
  75. dma_addr_t dma_addr, size_t size);
  76. void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size);
  77. dma_addr_t mic_to_dma_addr(struct mic_device *mdev, dma_addr_t mic_addr);
  78. /**
  79. * mic_map_error - Check a MIC address for errors.
  80. *
  81. * @mdev: pointer to mic_device instance.
  82. *
  83. * returns Whether there was an error during mic_map..(..) APIs.
  84. */
  85. static inline bool mic_map_error(dma_addr_t mic_addr)
  86. {
  87. return !mic_addr;
  88. }
  89. int mic_smpt_init(struct mic_device *mdev);
  90. void mic_smpt_uninit(struct mic_device *mdev);
  91. void mic_smpt_restore(struct mic_device *mdev);
  92. #endif