hif_napi.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. #ifndef __HIF_NAPI_H__
  27. #define __HIF_NAPI_H__
  28. /**
  29. * DOC: hif_napi.h
  30. *
  31. * Interface to HIF implemented functions of NAPI.
  32. * These are used by hdd_napi.
  33. */
  34. /* CLD headers */
  35. #include <hif.h> /* struct hif_opaque_softc; */
  36. /**
  37. * common stuff
  38. * The declarations until #ifdef FEATURE_NAPI below
  39. * are valid whether or not FEATURE_NAPI has been
  40. * defined.
  41. */
  42. /**
  43. * NAPI manages the following states:
  44. * NAPI state: per NAPI instance, ENABLED/DISABLED
  45. * CPU state: per CPU, DOWN/UP
  46. * TPUT state: global, LOW/HI
  47. *
  48. * "Dynamic" changes to state of various NAPI structures are
  49. * managed by NAPI events. The events may be produced by
  50. * various detection points. With each event, some data is
  51. * sent. The main event handler in hif_napi handles and makes
  52. * the state changes.
  53. *
  54. * event : data : generated
  55. * ---------------:------------------:------------------
  56. * EVT_INI_FILE : cfg->napi_enable : after ini file processed
  57. * EVT_CMD_STATE : cmd arg : by the vendor cmd
  58. * EVT_CPU_STATE : (cpu << 16)|state: CPU hotplug events
  59. * EVT_TPUT_STATE : (high/low) : tput trigger
  60. */
  61. enum qca_napi_event {
  62. NAPI_EVT_INVALID,
  63. NAPI_EVT_INI_FILE,
  64. NAPI_EVT_CMD_STATE,
  65. NAPI_EVT_CPU_STATE,
  66. NAPI_EVT_TPUT_STATE,
  67. };
  68. /**
  69. * Macros to map ids -returned by ...create()- to pipes and vice versa
  70. */
  71. #define NAPI_ID2PIPE(i) ((i)-1)
  72. #define NAPI_PIPE2ID(p) ((p)+1)
  73. #ifdef FEATURE_NAPI
  74. /**
  75. * NAPI HIF API
  76. *
  77. * the declarations below only apply to the case
  78. * where FEATURE_NAPI is defined
  79. */
  80. int hif_napi_create(struct hif_opaque_softc *hif,
  81. int (*poll)(struct napi_struct *, int),
  82. int budget,
  83. int scale);
  84. int hif_napi_destroy(struct hif_opaque_softc *hif,
  85. uint8_t id,
  86. int force);
  87. struct qca_napi_data *hif_napi_get_all(struct hif_opaque_softc *hif);
  88. int hif_napi_event(struct hif_opaque_softc *hif,
  89. enum qca_napi_event event,
  90. void *data);
  91. /* called from the ISR within hif, so, ce is known */
  92. int hif_napi_enabled(struct hif_opaque_softc *hif, int ce);
  93. /* called from hdd (napi_poll), using napi id as a selector */
  94. void hif_napi_enable_irq(struct hif_opaque_softc *hif, int id);
  95. /* called by ce_tasklet.c::ce_dispatch_interrupt*/
  96. int hif_napi_schedule(struct hif_opaque_softc *scn, int ce_id);
  97. /* called by hdd_napi, which is called by kernel */
  98. int hif_napi_poll(struct hif_opaque_softc *hif_ctx,
  99. struct napi_struct *napi, int budget);
  100. #ifdef FEATURE_NAPI_DEBUG
  101. #define NAPI_DEBUG(fmt, ...) \
  102. qdf_print("wlan: NAPI: %s:%d "fmt, __func__, __LINE__, ##__VA_ARGS__);
  103. #else
  104. #define NAPI_DEBUG(fmt, ...) /* NO-OP */
  105. #endif /* FEATURE NAPI_DEBUG */
  106. #define HNC_ANY_CPU (-1)
  107. #define HNC_ACT_RELOCATE (0)
  108. #define HNC_ACT_COLLAPSE (1)
  109. #define HNC_ACT_DISPERSE (-1)
  110. /**
  111. * Local interface to HIF implemented functions of NAPI CPU affinity management.
  112. * Note:
  113. * 1- The symbols in this file are NOT supposed to be used by any
  114. * entity other than hif_napi.c
  115. * 2- The symbols are valid only if HELIUMPLUS is defined. They are otherwise
  116. * mere wrappers.
  117. *
  118. */
  119. #ifndef HELIUMPLUS
  120. /**
  121. * stub functions
  122. */
  123. /* fw-declare to make compiler happy */
  124. struct qca_napi_data;
  125. static inline int hif_napi_cpu_init(void *ctx) { return 0; }
  126. static inline int hif_napi_cpu_deinit(void *ctx) { return 0; }
  127. #else /* HELIUMPLUS - NAPI CPU symbols are valid */
  128. /*
  129. * prototype signatures
  130. */
  131. int hif_napi_cpu_init(void *);
  132. int hif_napi_cpu_deinit(void *);
  133. int hif_napi_cpu_migrate(struct qca_napi_data *napid, int cpu, int action);
  134. int hif_napi_cpu_blacklist(bool is_on);
  135. #endif /* HELIUMPLUS */
  136. #else /* ! defined(FEATURE_NAPI) */
  137. /**
  138. * Stub API
  139. *
  140. * The declarations in this section are valid only
  141. * when FEATURE_NAPI has *not* been defined.
  142. */
  143. #define NAPI_DEBUG(fmt, ...) /* NO-OP */
  144. static inline int hif_napi_create(struct hif_opaque_softc *hif,
  145. uint8_t pipe_id,
  146. int (*poll)(struct napi_struct *, int),
  147. int budget,
  148. int scale)
  149. { return -EPERM; }
  150. static inline int hif_napi_destroy(struct hif_opaque_softc *hif,
  151. uint8_t id,
  152. int force)
  153. { return -EPERM; }
  154. static inline struct qca_napi_data *hif_napi_get_all(
  155. struct hif_opaque_softc *hif)
  156. { return NULL; }
  157. static inline int hif_napi_event(struct hif_opaque_softc *hif,
  158. enum qca_napi_event event,
  159. void *data)
  160. { return -EPERM; }
  161. /* called from the ISR within hif, so, ce is known */
  162. static inline int hif_napi_enabled(struct hif_opaque_softc *hif, int ce)
  163. { return 0; }
  164. /* called from hdd (napi_poll), using napi id as a selector */
  165. static inline void hif_napi_enable_irq(struct hif_opaque_softc *hif, int id)
  166. { return; }
  167. static inline int hif_napi_schedule(struct hif_opaque_softc *hif, int ce_id)
  168. { return 0; }
  169. static inline int hif_napi_poll(struct napi_struct *napi, int budget)
  170. { return -EPERM; }
  171. #endif /* FEATURE_NAPI */
  172. #endif /* __HIF_NAPI_H__ */