irqbypass.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * IRQ offload/bypass manager
  4. *
  5. * Copyright (C) 2015 Red Hat, Inc.
  6. * Copyright (c) 2015 Linaro Ltd.
  7. */
  8. #ifndef IRQBYPASS_H
  9. #define IRQBYPASS_H
  10. #include <linux/list.h>
  11. struct irq_bypass_consumer;
  12. /*
  13. * Theory of operation
  14. *
  15. * The IRQ bypass manager is a simple set of lists and callbacks that allows
  16. * IRQ producers (ex. physical interrupt sources) to be matched to IRQ
  17. * consumers (ex. virtualization hardware that allows IRQ bypass or offload)
  18. * via a shared token (ex. eventfd_ctx). Producers and consumers register
  19. * independently. When a token match is found, the optional @stop callback
  20. * will be called for each participant. The pair will then be connected via
  21. * the @add_* callbacks, and finally the optional @start callback will allow
  22. * any final coordination. When either participant is unregistered, the
  23. * process is repeated using the @del_* callbacks in place of the @add_*
  24. * callbacks. Match tokens must be unique per producer/consumer, 1:N pairings
  25. * are not supported.
  26. */
  27. /**
  28. * struct irq_bypass_producer - IRQ bypass producer definition
  29. * @node: IRQ bypass manager private list management
  30. * @token: opaque token to match between producer and consumer (non-NULL)
  31. * @irq: Linux IRQ number for the producer device
  32. * @add_consumer: Connect the IRQ producer to an IRQ consumer (optional)
  33. * @del_consumer: Disconnect the IRQ producer from an IRQ consumer (optional)
  34. * @stop: Perform any quiesce operations necessary prior to add/del (optional)
  35. * @start: Perform any startup operations necessary after add/del (optional)
  36. *
  37. * The IRQ bypass producer structure represents an interrupt source for
  38. * participation in possible host bypass, for instance an interrupt vector
  39. * for a physical device assigned to a VM.
  40. */
  41. struct irq_bypass_producer {
  42. struct list_head node;
  43. void *token;
  44. int irq;
  45. int (*add_consumer)(struct irq_bypass_producer *,
  46. struct irq_bypass_consumer *);
  47. void (*del_consumer)(struct irq_bypass_producer *,
  48. struct irq_bypass_consumer *);
  49. void (*stop)(struct irq_bypass_producer *);
  50. void (*start)(struct irq_bypass_producer *);
  51. };
  52. /**
  53. * struct irq_bypass_consumer - IRQ bypass consumer definition
  54. * @node: IRQ bypass manager private list management
  55. * @token: opaque token to match between producer and consumer (non-NULL)
  56. * @add_producer: Connect the IRQ consumer to an IRQ producer
  57. * @del_producer: Disconnect the IRQ consumer from an IRQ producer
  58. * @stop: Perform any quiesce operations necessary prior to add/del (optional)
  59. * @start: Perform any startup operations necessary after add/del (optional)
  60. *
  61. * The IRQ bypass consumer structure represents an interrupt sink for
  62. * participation in possible host bypass, for instance a hypervisor may
  63. * support offloads to allow bypassing the host entirely or offload
  64. * portions of the interrupt handling to the VM.
  65. */
  66. struct irq_bypass_consumer {
  67. struct list_head node;
  68. void *token;
  69. int (*add_producer)(struct irq_bypass_consumer *,
  70. struct irq_bypass_producer *);
  71. void (*del_producer)(struct irq_bypass_consumer *,
  72. struct irq_bypass_producer *);
  73. void (*stop)(struct irq_bypass_consumer *);
  74. void (*start)(struct irq_bypass_consumer *);
  75. };
  76. int irq_bypass_register_producer(struct irq_bypass_producer *);
  77. void irq_bypass_unregister_producer(struct irq_bypass_producer *);
  78. int irq_bypass_register_consumer(struct irq_bypass_consumer *);
  79. void irq_bypass_unregister_consumer(struct irq_bypass_consumer *);
  80. #endif /* IRQBYPASS_H */