irqbypass.h 3.6 KB

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