qdf_net_if.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. /*
  2. * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2022 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_napi_enable() - Enable the napi schedule
  62. * @napi: NAPI context
  63. *
  64. * This function resume NAPI from being scheduled on this context
  65. *
  66. * Return: NONE
  67. */
  68. void qdf_napi_enable(struct napi_struct *napi);
  69. /**
  70. * qdf_napi_disable() - Disable the napi schedule
  71. * @napi: NAPI context
  72. *
  73. * This function suspends NAPI from being scheduled on this context
  74. *
  75. * Return: NONE
  76. */
  77. void qdf_napi_disable(struct napi_struct *napi);
  78. /**
  79. * qdf_netif_napi_add - initialize a NAPI context
  80. * @netdev: network device
  81. * @napi: NAPI context
  82. * @poll: polling function
  83. * @weight: default weight
  84. *
  85. * Return: NONE
  86. */
  87. void qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
  88. int (*poll)(struct napi_struct *, int), int weight);
  89. /**
  90. * qdf_netif_napi_del - remove a NAPI context
  91. * @napi: NAPI context
  92. *
  93. * Return: NONE
  94. */
  95. void qdf_netif_napi_del(struct napi_struct *napi);
  96. /**
  97. * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
  98. * @ndev: net_device
  99. * @src_addr: source mac address
  100. * @len: length
  101. *
  102. * This function updates dev_addr in net_device
  103. *
  104. * Return: void
  105. */
  106. void
  107. qdf_net_update_net_device_dev_addr(struct net_device *ndev,
  108. const void *src_addr,
  109. size_t len);
  110. #else /* ENHANCED_OS_ABSTRACTION */
  111. static inline QDF_STATUS
  112. qdf_net_if_create_dummy_if(struct qdf_net_if *nif)
  113. {
  114. return __qdf_net_if_create_dummy_if(nif);
  115. }
  116. static inline struct qdf_net_if *
  117. qdf_net_if_get_dev_by_name(char *nif_name)
  118. {
  119. return __qdf_net_if_get_dev_by_name(nif_name);
  120. }
  121. static inline QDF_STATUS
  122. qdf_net_if_release_dev(struct qdf_net_if *nif)
  123. {
  124. return __qdf_net_if_release_dev(nif);
  125. }
  126. /**
  127. * qdf_net_update_net_device_dev_addr() - update net_device dev_addr
  128. * @ndev: net_device
  129. * @src_addr: source mac address
  130. * @len: length
  131. *
  132. * This function updates dev_addr in net_device
  133. *
  134. * Return: void
  135. */
  136. static inline void
  137. qdf_net_update_net_device_dev_addr(struct net_device *ndev,
  138. const void *src_addr,
  139. size_t len)
  140. {
  141. __qdf_net_update_net_device_dev_addr(ndev, src_addr, len);
  142. }
  143. static inline void
  144. qdf_napi_enable(struct napi_struct *napi)
  145. {
  146. __qdf_napi_enable(napi);
  147. }
  148. static inline void
  149. qdf_napi_disable(struct napi_struct *napi)
  150. {
  151. __qdf_napi_disable(napi);
  152. }
  153. static inline void
  154. qdf_netif_napi_add(struct net_device *netdev, struct napi_struct *napi,
  155. int (*poll)(struct napi_struct *, int), int weight)
  156. {
  157. __qdf_netif_napi_add(netdev, napi, poll, weight);
  158. }
  159. static inline void
  160. qdf_netif_napi_del(struct napi_struct *napi)
  161. {
  162. __qdf_netif_napi_del(napi);
  163. }
  164. #endif /* ENHANCED_OS_ABSTRACTION */
  165. /**
  166. * qdf_net_if_get_devname() - Retrieve netdevice name
  167. * @nif: Abstraction of netdevice
  168. *
  169. * Return: netdevice name
  170. */
  171. char *qdf_net_if_get_devname(struct qdf_net_if *nif);
  172. #endif /* __QDF_NET_IF_H */