hif_exec.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (c) 2017 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. #ifndef __HIF_EXEC_H__
  19. #define __HIF_EXEC_H__
  20. #include <hif.h>
  21. struct hif_exec_context;
  22. struct hif_execution_ops {
  23. char *context_type;
  24. void (*schedule)(struct hif_exec_context *);
  25. void (*reschedule)(struct hif_exec_context *);
  26. void (*kill)(struct hif_exec_context *);
  27. };
  28. /**
  29. * hif_exec_context: only ever allocated as a subtype eg.
  30. * hif_tasklet_exec_context
  31. *
  32. * @context: context for the handler function to use.
  33. * @context_name: a pointer to a const string for debugging.
  34. * this should help whenever there could be ambiguity
  35. * in what type of context the void* context points to
  36. * @irq: irq handle coresponding to hw block
  37. * @os_irq: irq handle for irq_afinity
  38. * @cpu: the cpu this context should be affined to
  39. * @work_complete: Function call called when leaving the execution context to
  40. * determine if this context should reschedule or wait for an interrupt.
  41. * This function may be used as a hook for post processing.
  42. *
  43. * @irq_disable: called before scheduling the context.
  44. * @irq_enable: called when the context leaves polling mode
  45. */
  46. struct hif_exec_context {
  47. struct hif_execution_ops *sched_ops;
  48. struct hif_opaque_softc *hif;
  49. uint32_t numirq;
  50. uint32_t irq[HIF_MAX_GRP_IRQ];
  51. uint32_t os_irq[HIF_MAX_GRP_IRQ];
  52. uint32_t grp_id;
  53. uint32_t scale_bin_shift;
  54. const char *context_name;
  55. void *context;
  56. ext_intr_handler handler;
  57. bool (*work_complete)(struct hif_exec_context *, int work_done);
  58. void (*irq_enable)(struct hif_exec_context *);
  59. void (*irq_disable)(struct hif_exec_context *);
  60. uint8_t cpu;
  61. struct qca_napi_stat stats[NR_CPUS];
  62. bool inited;
  63. bool configured;
  64. bool irq_requested;
  65. bool irq_enabled;
  66. qdf_spinlock_t irq_lock;
  67. };
  68. /**
  69. * struct hif_tasklet_exec_context - exec_context for tasklets
  70. * @exec_ctx: inherited data type
  71. * @tasklet: tasklet structure for scheduling
  72. */
  73. struct hif_tasklet_exec_context {
  74. struct hif_exec_context exec_ctx;
  75. struct tasklet_struct tasklet;
  76. };
  77. /**
  78. * struct hif_napi_exec_context - exec_context for tasklets
  79. * @exec_ctx: inherited data type
  80. * @netdev: dummy net device associated with the napi context
  81. * @napi: napi structure used in scheduling
  82. */
  83. struct hif_napi_exec_context {
  84. struct hif_exec_context exec_ctx;
  85. struct net_device netdev; /* dummy net_dev */
  86. struct napi_struct napi;
  87. };
  88. static inline struct hif_napi_exec_context*
  89. hif_exec_get_napi(struct hif_exec_context *ctx)
  90. {
  91. return (struct hif_napi_exec_context *) ctx;
  92. }
  93. static inline struct hif_tasklet_exec_context*
  94. hif_exec_get_tasklet(struct hif_exec_context *ctx)
  95. {
  96. return (struct hif_tasklet_exec_context *) ctx;
  97. }
  98. struct hif_exec_context *hif_exec_create(enum hif_exec_type type,
  99. uint32_t scale);
  100. void hif_exec_destroy(struct hif_exec_context *ctx);
  101. int hif_grp_irq_configure(struct hif_softc *scn,
  102. struct hif_exec_context *hif_exec);
  103. irqreturn_t hif_ext_group_interrupt_handler(int irq, void *context);
  104. struct hif_exec_context *hif_exec_get_ctx(struct hif_opaque_softc *hif,
  105. uint8_t id);
  106. void hif_exec_kill(struct hif_opaque_softc *scn);
  107. #endif