dp_wrap.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. /*
  2. * Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef _DP_WRAP_H_
  17. #define _DP_WRAP_H__
  18. #if ATH_SUPPORT_WRAP
  19. #if !WLAN_QWRAP_LEGACY
  20. #include "dp_wrap_struct.h"
  21. #include <dp_txrx.h>
  22. #include <cdp_txrx_cmn.h>
  23. #include <wlan_osif_priv.h>
  24. /**
  25. * dp_wrap_get_pdev_handle() - get wrap handle from pdev handle
  26. *
  27. * @pdev: handle to the objmgr pdev
  28. * Return: handle to wrap_pdev
  29. */
  30. static inline
  31. dp_pdev_wrap_t *dp_wrap_get_pdev_handle(struct wlan_objmgr_pdev *pdev)
  32. {
  33. ol_txrx_soc_handle soc;
  34. dp_txrx_pdev_handle_t *dp_hdl;
  35. soc = wlan_psoc_get_dp_handle(wlan_pdev_get_psoc(pdev));
  36. if (qdf_unlikely(!soc)) {
  37. qwrap_err(" soc handle is NULL");
  38. return NULL;
  39. }
  40. dp_hdl = (dp_txrx_pdev_handle_t *)cdp_pdev_get_dp_txrx_handle(soc,
  41. wlan_objmgr_pdev_get_pdev_id(pdev));
  42. if (qdf_unlikely(!dp_hdl)) {
  43. qwrap_err(" dp txrx handle is NULL");
  44. return NULL;
  45. }
  46. return &dp_hdl->wrap_pdev_hdl;
  47. }
  48. /**
  49. * dp_wrap_get_vdev_handle() - get wrap handle from vdev handle
  50. *
  51. * @vdev: handle to the objmgr vdev
  52. * Return: handle to wrap_vdev
  53. */
  54. static inline
  55. dp_vdev_wrap_t *dp_wrap_get_vdev_handle(struct wlan_objmgr_vdev *vdev)
  56. {
  57. ol_txrx_soc_handle soc;
  58. dp_vdev_txrx_handle_t *dp_hdl;
  59. soc = wlan_psoc_get_dp_handle(
  60. wlan_pdev_get_psoc(wlan_vdev_get_pdev(vdev)));
  61. if (qdf_unlikely(!soc)) {
  62. qwrap_err(" soc handle is NULL");
  63. return NULL;
  64. }
  65. dp_hdl = (dp_vdev_txrx_handle_t *)cdp_vdev_get_dp_ext_txrx_handle(soc,
  66. wlan_vdev_get_id(vdev));
  67. if (qdf_unlikely(!dp_hdl)) {
  68. qwrap_err(" dp txrx handle is NULL");
  69. return NULL;
  70. }
  71. return &dp_hdl->wrap_vdev_hdl;
  72. }
  73. /**
  74. * dp_wrap_get_mpsta_vdev() - get mpsta vdev
  75. *
  76. * @pdev: handle to pdev obj mgr
  77. * Return: mpsta vdev object
  78. */
  79. static
  80. struct wlan_objmgr_vdev *dp_wrap_get_mpsta_vdev(struct wlan_objmgr_pdev *pdev)
  81. {
  82. struct dp_wrap_pdev *wrap_pdev;
  83. if (!pdev)
  84. return NULL;
  85. wrap_pdev = dp_wrap_get_pdev_handle(pdev);
  86. if (!wrap_pdev)
  87. return NULL;
  88. return wrap_pdev->mpsta_vdev;
  89. }
  90. /**
  91. * dp_wrap_get_vdev() - get mpsta vdev
  92. *
  93. * @pdev: handle to pdev obj mgr
  94. * Return: wrap vdev object
  95. */
  96. static
  97. struct wlan_objmgr_vdev *dp_wrap_get_vdev(struct wlan_objmgr_pdev *pdev)
  98. {
  99. struct dp_wrap_pdev *wrap_pdev;
  100. if (!pdev)
  101. return NULL;
  102. wrap_pdev = dp_wrap_get_pdev_handle(pdev);
  103. if (!wrap_pdev)
  104. return NULL;
  105. return wrap_pdev->wrap_vdev;
  106. }
  107. /**
  108. * dp_wrap_vdev_is_mat_set() - Indicates whether mat translation is set
  109. *
  110. * @vdev: handle to the objmgr vdev.
  111. * Return: true if mat is set, false otherwise
  112. */
  113. static inline bool dp_wrap_vdev_is_mat_set(struct wlan_objmgr_vdev *vdev)
  114. {
  115. if (vdev && wlan_vdev_mlme_feat_ext_cap_get(vdev, WLAN_VDEV_FEXT_MAT))
  116. return true;
  117. else
  118. return false;
  119. }
  120. /**
  121. * dp_wrap_vdev_is_wired_psta() - Indicates whether vdev is wired psta.
  122. *
  123. * @vdev: handle to the objmgr vdev.
  124. * Return: true if wired psta, false otherwise.
  125. */
  126. static inline bool dp_wrap_vdev_is_wired_psta(struct wlan_objmgr_vdev *vdev)
  127. {
  128. if (vdev && wlan_vdev_mlme_feat_ext_cap_get(
  129. vdev, WLAN_VDEV_FEXT_WIRED_PSTA))
  130. return true;
  131. else
  132. return false;
  133. }
  134. /**
  135. * dp_wrap_vdev_is_psta() - Indicates whether vdev is of type PSTA.
  136. *
  137. * @vdev: handle to the objmgr vdev.
  138. * Return: True if psta, false otherwise
  139. */
  140. static inline bool dp_wrap_vdev_is_psta(struct wlan_objmgr_vdev *vdev)
  141. {
  142. if (vdev && wlan_vdev_mlme_feat_ext_cap_get(vdev, WLAN_VDEV_FEXT_PSTA))
  143. return true;
  144. else
  145. return false;
  146. }
  147. /**
  148. * dp_wrap_vdev_is_mpsta() - Indicates whether vdev is of type MPSTA.
  149. *
  150. * @vdev: handle to the objmgr vdev.
  151. * Return: True if mpsta, false otherwise.
  152. */
  153. static inline bool dp_wrap_vdev_is_mpsta(struct wlan_objmgr_vdev *vdev)
  154. {
  155. if (vdev && wlan_vdev_mlme_feat_ext_cap_get(
  156. vdev, WLAN_VDEV_FEXT_MPSTA))
  157. return true;
  158. else
  159. return false;
  160. }
  161. /**
  162. * dp_wrap_vdev_is_wrap() - Indicates whether vdev is of type WRAP.
  163. *
  164. * @vdev: handle to the objmgr vdev.
  165. * Return: True if wrap, false otherwise.
  166. */
  167. static bool dp_wrap_vdev_is_wrap(struct wlan_objmgr_vdev *vdev)
  168. {
  169. if (vdev && wlan_vdev_mlme_feat_ext_cap_get(vdev, WLAN_VDEV_FEXT_WRAP))
  170. return true;
  171. else
  172. return false;
  173. }
  174. /**
  175. * dp_wrap_vdev_get_nwrapvaps() - Get number of wrap vaps
  176. *
  177. * @pdev: handle to the objmgr pdev.
  178. * Return: wrap vaps count
  179. */
  180. static int dp_wrap_vdev_get_nwrapvaps(struct wlan_objmgr_pdev *pdev)
  181. {
  182. struct dp_wrap_pdev *wpdev;
  183. if (pdev) {
  184. wpdev = dp_wrap_get_pdev_handle(pdev);
  185. if (!wpdev) {
  186. qwrap_err(" wpdev is NULL");
  187. return 0;
  188. }
  189. return wpdev->nwrapvaps;
  190. }
  191. return 0;
  192. }
  193. /**
  194. * dp_wrap_vdev_get_npstavaps() - Get number of psta vaps
  195. *
  196. * @pdev: handle to the objmgr pdev.
  197. * Return: psta vaps count
  198. */
  199. static int dp_wrap_vdev_get_npstavaps(struct wlan_objmgr_pdev *pdev)
  200. {
  201. struct dp_wrap_pdev *wpdev;
  202. if (pdev) {
  203. wpdev = dp_wrap_get_pdev_handle(pdev);
  204. if (!wpdev) {
  205. qwrap_err(" wpdev is NULL");
  206. return 0;
  207. }
  208. return wpdev->npstavaps;
  209. }
  210. return 0;
  211. }
  212. /**
  213. * dp_wrap_pdev_set_isolation() - set isolation
  214. *
  215. * @pdev: handle to the objmgr pdev.
  216. * @isolation: handle to set isolation param
  217. * Return: void
  218. */
  219. static void
  220. dp_wrap_pdev_set_isolation(struct wlan_objmgr_pdev *pdev, int isolation)
  221. {
  222. struct dp_wrap_pdev *wpdev;
  223. if (pdev) {
  224. wpdev = dp_wrap_get_pdev_handle(pdev);
  225. if (!wpdev) {
  226. qwrap_err(" wpdev is NULL");
  227. return;
  228. }
  229. wpdev->wp_isolation = isolation;
  230. }
  231. }
  232. /**
  233. * dp_wrap_pdev_get_isolation() - Indicates whether isolation is set
  234. *
  235. * @pdev: handle to the objmgr pdev.
  236. * Return: isolation value
  237. */
  238. static int dp_wrap_pdev_get_isolation(struct wlan_objmgr_pdev *pdev)
  239. {
  240. struct dp_wrap_pdev *wpdev;
  241. if (pdev) {
  242. wpdev = dp_wrap_get_pdev_handle(pdev);
  243. if (!wpdev) {
  244. qwrap_err(" wpdev is NULL");
  245. return 0;
  246. }
  247. return wpdev->wp_isolation;
  248. }
  249. return 0;
  250. }
  251. /**
  252. * dp_wrap_vdev_get_oma() - Get OMA address of PSTA
  253. *
  254. * @pdev: handle to the objmgr vdev.
  255. * Return: PSTA OMA address
  256. */
  257. static u_int8_t *dp_wrap_vdev_get_oma(struct wlan_objmgr_vdev *vdev)
  258. {
  259. struct dp_wrap_vdev *wvdev;
  260. if (vdev) {
  261. wvdev = dp_wrap_get_vdev_handle(vdev);
  262. if (!wvdev) {
  263. qwrap_err(" wvdev is NULL");
  264. return NULL;
  265. }
  266. return &wvdev->wrap_dev_oma[0];
  267. }
  268. return NULL;
  269. }
  270. /**
  271. * dp_wrap_vdev_get_vma() - Get VMA address of PSTA
  272. *
  273. * @pdev: handle to the objmgr vdev.
  274. * Return: PSTA VMA address
  275. */
  276. static u_int8_t *dp_wrap_vdev_get_vma(struct wlan_objmgr_vdev *vdev)
  277. {
  278. struct dp_wrap_vdev *wvdev;
  279. if (vdev) {
  280. wvdev = dp_wrap_get_vdev_handle(vdev);
  281. if (!wvdev) {
  282. qwrap_err(" wvdev is NULL");
  283. return NULL;
  284. }
  285. return &wvdev->wrap_dev_vma[0];
  286. }
  287. return NULL;
  288. }
  289. /**
  290. * @brief Find vdev object based on MAC address.
  291. *
  292. * @param pdev Ptr to pdev obj mgr.
  293. * @param mac MAC address to look up.
  294. *
  295. * @return vdev objmgr on success
  296. * @return NULL on failure
  297. */
  298. static inline struct wlan_objmgr_vdev *dp_wrap_vdev_vma_find(
  299. struct wlan_objmgr_pdev *pdev, unsigned char *mac)
  300. {
  301. dp_vdev_wrap_t *wrap_vdev;
  302. int hash;
  303. rwlock_state_t lock_state;
  304. struct dp_wrap_pdev *wrap_pdev;
  305. struct dp_wrap_devt *wdt;
  306. if (!pdev)
  307. return NULL;
  308. wrap_pdev = dp_wrap_get_pdev_handle(pdev);
  309. if (!wrap_pdev)
  310. return NULL;
  311. wdt = &wrap_pdev->wp_devt;
  312. hash = WRAP_DEV_HASH(mac);
  313. OS_RWLOCK_READ_LOCK(&wdt->wdt_lock, &lock_state);
  314. LIST_FOREACH(wrap_vdev, &wdt->wdt_hash_vma[hash], wrap_dev_hash_vma) {
  315. if (qdf_is_macaddr_equal((struct qdf_mac_addr *)
  316. wrap_vdev->wrap_dev_vma, (struct qdf_mac_addr *)mac)) {
  317. OS_RWLOCK_READ_UNLOCK(&wdt->wdt_lock, &lock_state);
  318. return wrap_vdev->vdev;
  319. }
  320. }
  321. OS_RWLOCK_READ_UNLOCK(&wdt->wdt_lock, &lock_state);
  322. return NULL;
  323. }
  324. int dp_wrap_attach(struct wlan_objmgr_pdev *pdev);
  325. int dp_wrap_detach(struct wlan_objmgr_pdev *pdev);
  326. void dp_wrap_vdev_attach(struct wlan_objmgr_vdev *vdev);
  327. void dp_wrap_vdev_detach(struct wlan_objmgr_vdev *vdev);
  328. int dp_wrap_dev_add(struct wlan_objmgr_vdev *vdev);
  329. void dp_wrap_vdev_set_psta(struct wlan_objmgr_vdev *vdev);
  330. void dp_wrap_vdev_set_mpsta(struct wlan_objmgr_vdev *vdev);
  331. void dp_wrap_vdev_clear_psta(struct wlan_objmgr_vdev *vdev);
  332. void dp_wrap_vdev_set_wrap(struct wlan_objmgr_vdev *vdev);
  333. void dp_wrap_vdev_clear_wrap(struct wlan_objmgr_vdev *vdev);
  334. void dp_wrap_dev_remove(struct wlan_objmgr_vdev *vdev);
  335. void dp_wrap_dev_remove_vma(struct wlan_objmgr_vdev *vdev);
  336. int dp_wrap_rx_process(struct net_device **dev, struct wlan_objmgr_vdev *vdev,
  337. struct sk_buff *skb, int *nwifi);
  338. int dp_wrap_tx_process(struct net_device **dev, struct wlan_objmgr_vdev *vdev,
  339. struct sk_buff **skb);
  340. int dp_wrap_mat_tx(struct dp_wrap_vdev *wvdev, wbuf_t buf);
  341. int dp_wrap_mat_rx(struct dp_wrap_vdev *wvdev, wbuf_t buf);
  342. void dp_wrap_vdev_set_netdev(struct wlan_objmgr_vdev *vdev,
  343. struct net_device *dev);
  344. void dp_wrap_register_xmit_handler(struct wlan_objmgr_vdev *vdev,
  345. void (*wlan_vdev_xmit_queue)
  346. (struct net_device *dev, wbuf_t wbuf));
  347. #endif
  348. #endif
  349. #endif