mic_intr.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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_INTR_H_
  22. #define _MIC_INTR_H_
  23. /*
  24. * The minimum number of msix vectors required for normal operation.
  25. * 3 for virtio network, console and block devices.
  26. * 1 for card shutdown notifications.
  27. */
  28. #define MIC_MIN_MSIX 4
  29. #define MIC_NUM_OFFSETS 32
  30. /**
  31. * mic_intr_source - The type of source that will generate
  32. * the interrupt.The number of types needs to be in sync with
  33. * MIC_NUM_INTR_TYPES
  34. *
  35. * MIC_INTR_DB: The source is a doorbell
  36. * MIC_INTR_DMA: The source is a DMA channel
  37. * MIC_INTR_ERR: The source is an error interrupt e.g. SBOX ERR
  38. * MIC_NUM_INTR_TYPES: Total number of interrupt sources.
  39. */
  40. enum mic_intr_type {
  41. MIC_INTR_DB = 0,
  42. MIC_INTR_DMA,
  43. MIC_INTR_ERR,
  44. MIC_NUM_INTR_TYPES
  45. };
  46. /**
  47. * struct mic_intr_info - Contains h/w specific interrupt sources
  48. * information.
  49. *
  50. * @intr_start_idx: Contains the starting indexes of the
  51. * interrupt types.
  52. * @intr_len: Contains the length of the interrupt types.
  53. */
  54. struct mic_intr_info {
  55. u16 intr_start_idx[MIC_NUM_INTR_TYPES];
  56. u16 intr_len[MIC_NUM_INTR_TYPES];
  57. };
  58. /**
  59. * struct mic_irq_info - OS specific irq information
  60. *
  61. * @next_avail_src: next available doorbell that can be assigned.
  62. * @msix_entries: msix entries allocated while setting up MSI-x
  63. * @mic_msi_map: The MSI/MSI-x mapping information.
  64. * @num_vectors: The number of MSI/MSI-x vectors that have been allocated.
  65. * @cb_ida: callback ID allocator to track the callbacks registered.
  66. * @mic_intr_lock: spinlock to protect the interrupt callback list.
  67. * @cb_list: Array of callback lists one for each source.
  68. */
  69. struct mic_irq_info {
  70. int next_avail_src;
  71. struct msix_entry *msix_entries;
  72. u32 *mic_msi_map;
  73. u16 num_vectors;
  74. struct ida cb_ida;
  75. spinlock_t mic_intr_lock;
  76. struct list_head *cb_list;
  77. };
  78. /**
  79. * struct mic_intr_cb - Interrupt callback structure.
  80. *
  81. * @func: The callback function
  82. * @data: Private data of the requester.
  83. * @cb_id: The callback id. Identifies this callback.
  84. * @list: list head pointing to the next callback structure.
  85. */
  86. struct mic_intr_cb {
  87. irqreturn_t (*func) (int irq, void *data);
  88. void *data;
  89. int cb_id;
  90. struct list_head list;
  91. };
  92. /**
  93. * struct mic_irq - opaque pointer used as cookie
  94. */
  95. struct mic_irq;
  96. /* Forward declaration */
  97. struct mic_device;
  98. /**
  99. * struct mic_hw_intr_ops: MIC HW specific interrupt operations
  100. * @intr_init: Initialize H/W specific interrupt information.
  101. * @enable_interrupts: Enable interrupts from the hardware.
  102. * @disable_interrupts: Disable interrupts from the hardware.
  103. * @program_msi_to_src_map: Update MSI mapping registers with
  104. * irq information.
  105. * @read_msi_to_src_map: Read MSI mapping registers containing
  106. * irq information.
  107. */
  108. struct mic_hw_intr_ops {
  109. void (*intr_init)(struct mic_device *mdev);
  110. void (*enable_interrupts)(struct mic_device *mdev);
  111. void (*disable_interrupts)(struct mic_device *mdev);
  112. void (*program_msi_to_src_map) (struct mic_device *mdev,
  113. int idx, int intr_src, bool set);
  114. u32 (*read_msi_to_src_map) (struct mic_device *mdev,
  115. int idx);
  116. };
  117. int mic_next_db(struct mic_device *mdev);
  118. struct mic_irq *mic_request_irq(struct mic_device *mdev,
  119. irqreturn_t (*func)(int irq, void *data),
  120. const char *name, void *data, int intr_src,
  121. enum mic_intr_type type);
  122. void mic_free_irq(struct mic_device *mdev,
  123. struct mic_irq *cookie, void *data);
  124. int mic_setup_interrupts(struct mic_device *mdev, struct pci_dev *pdev);
  125. void mic_free_interrupts(struct mic_device *mdev, struct pci_dev *pdev);
  126. void mic_intr_restore(struct mic_device *mdev);
  127. #endif