cxl-base.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2014 IBM Corp.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. #ifndef _MISC_CXL_BASE_H
  10. #define _MISC_CXL_BASE_H
  11. #include <misc/cxl.h>
  12. #ifdef CONFIG_CXL_BASE
  13. #define CXL_IRQ_RANGES 4
  14. struct cxl_irq_ranges {
  15. irq_hw_number_t offset[CXL_IRQ_RANGES];
  16. irq_hw_number_t range[CXL_IRQ_RANGES];
  17. };
  18. extern atomic_t cxl_use_count;
  19. static inline bool cxl_ctx_in_use(void)
  20. {
  21. return (atomic_read(&cxl_use_count) != 0);
  22. }
  23. static inline void cxl_ctx_get(void)
  24. {
  25. atomic_inc(&cxl_use_count);
  26. }
  27. static inline void cxl_ctx_put(void)
  28. {
  29. atomic_dec(&cxl_use_count);
  30. }
  31. struct cxl_afu *cxl_afu_get(struct cxl_afu *afu);
  32. void cxl_afu_put(struct cxl_afu *afu);
  33. void cxl_slbia(struct mm_struct *mm);
  34. bool cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu);
  35. void cxl_pci_disable_device(struct pci_dev *dev);
  36. int cxl_cx4_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type);
  37. void cxl_cx4_teardown_msi_irqs(struct pci_dev *pdev);
  38. #else /* CONFIG_CXL_BASE */
  39. static inline bool cxl_ctx_in_use(void) { return false; }
  40. static inline struct cxl_afu *cxl_afu_get(struct cxl_afu *afu) { return NULL; }
  41. static inline void cxl_afu_put(struct cxl_afu *afu) {}
  42. static inline void cxl_slbia(struct mm_struct *mm) {}
  43. static inline bool cxl_pci_associate_default_context(struct pci_dev *dev, struct cxl_afu *afu) { return false; }
  44. static inline void cxl_pci_disable_device(struct pci_dev *dev) {}
  45. static inline int cxl_cx4_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) { return -ENODEV; }
  46. static inline void cxl_cx4_teardown_msi_irqs(struct pci_dev *pdev) {}
  47. #endif /* CONFIG_CXL_BASE */
  48. #endif