qdf_net_if.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for
  6. * any purpose with or without fee is hereby granted, provided that the
  7. * above copyright notice and this permission notice appear in all
  8. * copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  11. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  12. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  13. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  14. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  15. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  16. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  17. * PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. /**
  20. * DOC: qdf_net_if
  21. * QCA driver framework (QDF) network interface management APIs
  22. */
  23. #if !defined(__QDF_NET_IF_H)
  24. #define __QDF_NET_IF_H
  25. /* Include Files */
  26. #include <qdf_types.h>
  27. #include <i_qdf_net_if.h>
  28. struct qdf_net_if;
  29. #ifdef ENHANCED_OS_ABSTRACTION
  30. /**
  31. * qdf_net_if_create_dummy_if() - create dummy interface
  32. * @nif: interface handle
  33. *
  34. * This function will create a dummy network interface
  35. *
  36. * Return: QDF_STATUS_SUCCESS on success
  37. */
  38. QDF_STATUS
  39. qdf_net_if_create_dummy_if(struct qdf_net_if *nif);
  40. /**
  41. * qdf_net_if_get_dev_by_name() - Find a network device by its name
  42. * @nif_name: network device name
  43. *
  44. * This function retrieves the network device by its name
  45. *
  46. * Return: qdf network device
  47. */
  48. struct qdf_net_if *
  49. qdf_net_if_get_dev_by_name(char *nif_name);
  50. /**
  51. * qdf_net_if_release_dev() - Release reference to network device
  52. * @nif: network device
  53. *
  54. * This function releases reference to the network device
  55. *
  56. * Return: QDF_STATUS_SUCCESS on success
  57. */
  58. QDF_STATUS
  59. qdf_net_if_release_dev(struct qdf_net_if *nif);
  60. /**
  61. * qdf_net_if_hold_dev() - Hold reference to network device
  62. * @nif: network device
  63. *
  64. * This function holds reference to the network device
  65. *
  66. * Return: QDF_STATUS_SUCCESS on success
  67. */
  68. QDF_STATUS
  69. qdf_net_if_hold_dev(struct qdf_net_if *nif);
  70. /**
  71. * qdf_napi_enable() - Enable the napi schedule
  72. * @napi: NAPI context
  73. *
  74. * This function resume NAPI from being scheduled on this context
  75. *
  76. * Return: NONE
  77. */
  78. void qdf_napi_enable(struct napi_struct *napi);
  79. /**
  80. * qdf_napi_disable() - Disable the napi schedule
  81. * @napi: NAPI context
  82. *
  83. * This function suspends NAPI from being scheduled on this context
  84. *
  85. * Return: NONE
  86. */
  87. void qdf_napi_disable(struct napi_struct *napi);
  88. /**
  89. * qdf_netif_napi_add - initialize a NAPI context
  90. * @netdev: network device
  91. * @napi: NAPI context
  92. * @poll: polling function
  93. * @weight: default weight
  94. *
  95. * Return: NONE
  96. */
  97. void qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
  98. int (*poll)(struct napi_struct *, int), int weight);
  99. /**
  100. * qdf_netif_napi_del - remove a NAPI context
  101. * @napi: NAPI context
  102. *
  103. * Return: NONE
  104. */
  105. void qdf_netif_napi_del(struct napi_struct *napi);
  106. /**
  107. * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
  108. * @ndev: net_device
  109. * @src_addr: source mac address
  110. * @len: length
  111. *
  112. * This function updates dev_addr in net_device
  113. *
  114. * Return: void
  115. */
  116. void
  117. qdf_net_update_net_device_dev_addr(struct net_device *ndev,
  118. const void *src_addr,
  119. size_t len);
  120. #else /* ENHANCED_OS_ABSTRACTION */
  121. static inline QDF_STATUS
  122. qdf_net_if_create_dummy_if(struct qdf_net_if *nif)
  123. {
  124. return __qdf_net_if_create_dummy_if(nif);
  125. }
  126. static inline struct qdf_net_if *
  127. qdf_net_if_get_dev_by_name(char *nif_name)
  128. {
  129. return __qdf_net_if_get_dev_by_name(nif_name);
  130. }
  131. static inline QDF_STATUS
  132. qdf_net_if_release_dev(struct qdf_net_if *nif)
  133. {
  134. return __qdf_net_if_release_dev(nif);
  135. }
  136. static inline QDF_STATUS
  137. qdf_net_if_hold_dev(struct qdf_net_if *nif)
  138. {
  139. return __qdf_net_if_hold_dev(nif);
  140. }
  141. /**
  142. * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
  143. * @ndev: net_device
  144. * @src_addr: source mac address
  145. * @len: length
  146. *
  147. * This function updates dev_addr in net_device
  148. *
  149. * Return: void
  150. */
  151. static inline void
  152. qdf_net_update_net_device_dev_addr(struct net_device *ndev,
  153. const void *src_addr,
  154. size_t len)
  155. {
  156. __qdf_net_update_net_device_dev_addr(ndev, src_addr, len);
  157. }
  158. static inline void
  159. qdf_napi_enable(struct napi_struct *napi)
  160. {
  161. __qdf_napi_enable(napi);
  162. }
  163. static inline void
  164. qdf_napi_disable(struct napi_struct *napi)
  165. {
  166. __qdf_napi_disable(napi);
  167. }
  168. static inline void
  169. qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
  170. int (*poll)(struct napi_struct *, int), int weight)
  171. {
  172. __qdf_netif_napi_add(netdev, napi, poll, weight);
  173. }
  174. static inline void
  175. qdf_netif_napi_del(struct napi_struct *napi)
  176. {
  177. __qdf_netif_napi_del(napi);
  178. }
  179. #endif /* ENHANCED_OS_ABSTRACTION */
  180. /**
  181. * qdf_net_if_get_devname() - Retrieve netdevice name
  182. * @nif: Abstraction of netdevice
  183. *
  184. * Return: netdevice name
  185. */
  186. char *qdf_net_if_get_devname(struct qdf_net_if *nif);
  187. #endif /* __QDF_NET_IF_H */