hif_napi.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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_INT_STATE : 0 : internal - shut off/disable
  59. * EVT_CPU_STATE : (cpu << 16)|state: CPU hotplug events
  60. * EVT_TPUT_STATE : (high/low) : tput trigger
  61. * EVT_USR_SERIAL : num-serial_calls : WMA/ROAMING-START/IND
  62. * EVT_USR_NORMAL : N/A : WMA/ROAMING-END
  63. */
  64. enum qca_napi_event {
  65. NAPI_EVT_INVALID,
  66. NAPI_EVT_INI_FILE,
  67. NAPI_EVT_CMD_STATE,
  68. NAPI_EVT_INT_STATE,
  69. NAPI_EVT_CPU_STATE,
  70. NAPI_EVT_TPUT_STATE,
  71. NAPI_EVT_USR_SERIAL,
  72. NAPI_EVT_USR_NORMAL
  73. };
  74. /**
  75. * Macros to map ids -returned by ...create()- to pipes and vice versa
  76. */
  77. #define NAPI_ID2PIPE(i) ((i)-1)
  78. #define NAPI_PIPE2ID(p) ((p)+1)
  79. int hif_napi_lro_flush_cb_register(struct hif_opaque_softc *hif_hdl,
  80. void (lro_flush_handler)(void *),
  81. void *(lro_init_handler)(void));
  82. void hif_napi_lro_flush_cb_deregister(struct hif_opaque_softc *hif_hdl,
  83. void (lro_deinit_cb)(void *));
  84. void *hif_napi_get_lro_info(struct hif_opaque_softc *hif_hdl, int napi_id);
  85. #ifdef FEATURE_NAPI
  86. /**
  87. * NAPI HIF API
  88. *
  89. * the declarations below only apply to the case
  90. * where FEATURE_NAPI is defined
  91. */
  92. int hif_napi_create(struct hif_opaque_softc *hif,
  93. int (*poll)(struct napi_struct *, int),
  94. int budget,
  95. int scale);
  96. int hif_napi_destroy(struct hif_opaque_softc *hif,
  97. uint8_t id,
  98. int force);
  99. struct qca_napi_data *hif_napi_get_all(struct hif_opaque_softc *hif);
  100. int hif_napi_event(struct hif_opaque_softc *hif,
  101. enum qca_napi_event event,
  102. void *data);
  103. /* called from the ISR within hif, so, ce is known */
  104. int hif_napi_enabled(struct hif_opaque_softc *hif, int ce);
  105. /* called from hdd (napi_poll), using napi id as a selector */
  106. void hif_napi_enable_irq(struct hif_opaque_softc *hif, int id);
  107. /* called by ce_tasklet.c::ce_dispatch_interrupt*/
  108. int hif_napi_schedule(struct hif_opaque_softc *scn, int ce_id);
  109. /* called by hdd_napi, which is called by kernel */
  110. int hif_napi_poll(struct hif_opaque_softc *hif_ctx,
  111. struct napi_struct *napi, int budget);
  112. #ifdef FEATURE_NAPI_DEBUG
  113. #define NAPI_DEBUG(fmt, ...) \
  114. qdf_print("wlan: NAPI: %s:%d "fmt, __func__, __LINE__, ##__VA_ARGS__);
  115. #else
  116. #define NAPI_DEBUG(fmt, ...) /* NO-OP */
  117. #endif /* FEATURE NAPI_DEBUG */
  118. #define HNC_ANY_CPU (-1)
  119. #define HNC_ACT_RELOCATE (0)
  120. #define HNC_ACT_COLLAPSE (1)
  121. #define HNC_ACT_DISPERSE (-1)
  122. /**
  123. * Local interface to HIF implemented functions of NAPI CPU affinity management.
  124. * Note:
  125. * 1- The symbols in this file are NOT supposed to be used by any
  126. * entity other than hif_napi.c
  127. * 2- The symbols are valid only if HELIUMPLUS is defined. They are otherwise
  128. * mere wrappers.
  129. *
  130. */
  131. #ifndef HELIUMPLUS
  132. /**
  133. * stub functions
  134. */
  135. /* fw-declare to make compiler happy */
  136. struct qca_napi_data;
  137. static inline int hif_napi_cpu_init(struct hif_opaque_softc *hif)
  138. { return 0; }
  139. static inline int hif_napi_cpu_deinit(struct hif_opaque_softc *hif)
  140. { return 0; }
  141. static inline int hif_napi_serialize(struct hif_opaque_softc *hif, int is_on)
  142. { return -EPERM; }
  143. #else /* HELIUMPLUS - NAPI CPU symbols are valid */
  144. /*
  145. * prototype signatures
  146. */
  147. int hif_napi_cpu_init(struct hif_opaque_softc *hif);
  148. int hif_napi_cpu_deinit(struct hif_opaque_softc *hif);
  149. int hif_napi_cpu_migrate(struct qca_napi_data *napid, int cpu, int action);
  150. int hif_napi_cpu_blacklist(bool is_on);
  151. int hif_napi_serialize(struct hif_opaque_softc *hif, int is_on);
  152. #endif /* HELIUMPLUS */
  153. #else /* ! defined(FEATURE_NAPI) */
  154. /**
  155. * Stub API
  156. *
  157. * The declarations in this section are valid only
  158. * when FEATURE_NAPI has *not* been defined.
  159. */
  160. #define NAPI_DEBUG(fmt, ...) /* NO-OP */
  161. static inline int hif_napi_create(struct hif_opaque_softc *hif,
  162. uint8_t pipe_id,
  163. int (*poll)(struct napi_struct *, int),
  164. int budget,
  165. int scale)
  166. { return -EPERM; }
  167. static inline int hif_napi_destroy(struct hif_opaque_softc *hif,
  168. uint8_t id,
  169. int force)
  170. { return -EPERM; }
  171. static inline struct qca_napi_data *hif_napi_get_all(
  172. struct hif_opaque_softc *hif)
  173. { return NULL; }
  174. static inline int hif_napi_event(struct hif_opaque_softc *hif,
  175. enum qca_napi_event event,
  176. void *data)
  177. { return -EPERM; }
  178. /* called from the ISR within hif, so, ce is known */
  179. static inline int hif_napi_enabled(struct hif_opaque_softc *hif, int ce)
  180. { return 0; }
  181. /* called from hdd (napi_poll), using napi id as a selector */
  182. static inline void hif_napi_enable_irq(struct hif_opaque_softc *hif, int id)
  183. { return; }
  184. static inline int hif_napi_schedule(struct hif_opaque_softc *hif, int ce_id)
  185. { return 0; }
  186. static inline int hif_napi_poll(struct napi_struct *napi, int budget)
  187. { return -EPERM; }
  188. #endif /* FEATURE_NAPI */
  189. static inline int hif_ext_napi_enabled(struct hif_opaque_softc *hif, int ce)
  190. { return 0; }
  191. static inline int hif_napi_schedule_grp(struct hif_opaque_softc *hif,
  192. uint32_t grp_id)
  193. { return 0; }
  194. #endif /* __HIF_NAPI_H__ */