airq.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright IBM Corp. 2002, 2007
  4. * Author(s): Ingo Adlung <adlung@de.ibm.com>
  5. * Cornelia Huck <cornelia.huck@de.ibm.com>
  6. * Arnd Bergmann <arndb@de.ibm.com>
  7. * Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
  8. */
  9. #ifndef _ASM_S390_AIRQ_H
  10. #define _ASM_S390_AIRQ_H
  11. #include <linux/bit_spinlock.h>
  12. struct airq_struct {
  13. struct hlist_node list; /* Handler queueing. */
  14. void (*handler)(struct airq_struct *); /* Thin-interrupt handler */
  15. u8 *lsi_ptr; /* Local-Summary-Indicator pointer */
  16. u8 lsi_mask; /* Local-Summary-Indicator mask */
  17. u8 isc; /* Interrupt-subclass */
  18. u8 flags;
  19. };
  20. #define AIRQ_PTR_ALLOCATED 0x01
  21. int register_adapter_interrupt(struct airq_struct *airq);
  22. void unregister_adapter_interrupt(struct airq_struct *airq);
  23. /* Adapter interrupt bit vector */
  24. struct airq_iv {
  25. unsigned long *vector; /* Adapter interrupt bit vector */
  26. unsigned long *avail; /* Allocation bit mask for the bit vector */
  27. unsigned long *bitlock; /* Lock bit mask for the bit vector */
  28. unsigned long *ptr; /* Pointer associated with each bit */
  29. unsigned int *data; /* 32 bit value associated with each bit */
  30. unsigned long bits; /* Number of bits in the vector */
  31. unsigned long end; /* Number of highest allocated bit + 1 */
  32. spinlock_t lock; /* Lock to protect alloc & free */
  33. };
  34. #define AIRQ_IV_ALLOC 1 /* Use an allocation bit mask */
  35. #define AIRQ_IV_BITLOCK 2 /* Allocate the lock bit mask */
  36. #define AIRQ_IV_PTR 4 /* Allocate the ptr array */
  37. #define AIRQ_IV_DATA 8 /* Allocate the data array */
  38. struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags);
  39. void airq_iv_release(struct airq_iv *iv);
  40. unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num);
  41. void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num);
  42. unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start,
  43. unsigned long end);
  44. static inline unsigned long airq_iv_alloc_bit(struct airq_iv *iv)
  45. {
  46. return airq_iv_alloc(iv, 1);
  47. }
  48. static inline void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit)
  49. {
  50. airq_iv_free(iv, bit, 1);
  51. }
  52. static inline unsigned long airq_iv_end(struct airq_iv *iv)
  53. {
  54. return iv->end;
  55. }
  56. static inline void airq_iv_lock(struct airq_iv *iv, unsigned long bit)
  57. {
  58. const unsigned long be_to_le = BITS_PER_LONG - 1;
  59. bit_spin_lock(bit ^ be_to_le, iv->bitlock);
  60. }
  61. static inline void airq_iv_unlock(struct airq_iv *iv, unsigned long bit)
  62. {
  63. const unsigned long be_to_le = BITS_PER_LONG - 1;
  64. bit_spin_unlock(bit ^ be_to_le, iv->bitlock);
  65. }
  66. static inline void airq_iv_set_data(struct airq_iv *iv, unsigned long bit,
  67. unsigned int data)
  68. {
  69. iv->data[bit] = data;
  70. }
  71. static inline unsigned int airq_iv_get_data(struct airq_iv *iv,
  72. unsigned long bit)
  73. {
  74. return iv->data[bit];
  75. }
  76. static inline void airq_iv_set_ptr(struct airq_iv *iv, unsigned long bit,
  77. unsigned long ptr)
  78. {
  79. iv->ptr[bit] = ptr;
  80. }
  81. static inline unsigned long airq_iv_get_ptr(struct airq_iv *iv,
  82. unsigned long bit)
  83. {
  84. return iv->ptr[bit];
  85. }
  86. #endif /* _ASM_S390_AIRQ_H */