nan_ucfg_api.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. /*
  2. * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for
  5. * any purpose with or without fee is hereby granted, provided that the
  6. * above copyright notice and this permission notice appear in all
  7. * copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  10. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  11. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  12. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  13. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  14. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  16. * PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * DOC: contains interface prototypes for OS_IF layer
  20. */
  21. #ifndef _NAN_UCFG_API_H_
  22. #define _NAN_UCFG_API_H_
  23. #include "wlan_objmgr_cmn.h"
  24. #include "nan_public_structs.h"
  25. #ifdef WLAN_FEATURE_NAN
  26. #define ucfg_nan_set_ndi_state(vdev, state) \
  27. __ucfg_nan_set_ndi_state(vdev, state, __func__)
  28. /**
  29. * ucfg_nan_set_ndi_state: set ndi state
  30. * @vdev: pointer to vdev object
  31. * @state: value to set
  32. * @func: Caller of this API
  33. *
  34. * Return: status of operation
  35. */
  36. QDF_STATUS __ucfg_nan_set_ndi_state(struct wlan_objmgr_vdev *vdev,
  37. enum nan_datapath_state state,
  38. const char *func);
  39. /**
  40. * ucfg_nan_psoc_open: Setup NAN priv object params on PSOC open
  41. * @psoc: Pointer to PSOC object
  42. *
  43. * Return: QDF Status of operation
  44. */
  45. QDF_STATUS ucfg_nan_psoc_open(struct wlan_objmgr_psoc *psoc);
  46. /**
  47. * ucfg_nan_psoc_close: Clean up NAN priv data on PSOC close
  48. * @psoc: Pointer to PSOC object
  49. *
  50. * Return: None
  51. */
  52. void ucfg_nan_psoc_close(struct wlan_objmgr_psoc *psoc);
  53. /**
  54. * ucfg_nan_get_ndi_state: get ndi state from vdev obj
  55. * @vdev: pointer to vdev object
  56. *
  57. * Return: ndi state
  58. */
  59. enum nan_datapath_state ucfg_nan_get_ndi_state(struct wlan_objmgr_vdev *vdev);
  60. /**
  61. * ucfg_nan_set_active_peers: set active ndi peer
  62. * @vdev: pointer to vdev object
  63. * @val: value to set
  64. *
  65. * Return: status of operation
  66. */
  67. QDF_STATUS ucfg_nan_set_active_peers(struct wlan_objmgr_vdev *vdev,
  68. uint32_t val);
  69. /**
  70. * ucfg_nan_get_active_peers: get active ndi peer from vdev obj
  71. * @vdev: pointer to vdev object
  72. *
  73. * Return: active ndi peer
  74. */
  75. uint32_t ucfg_nan_get_active_peers(struct wlan_objmgr_vdev *vdev);
  76. /**
  77. * ucfg_nan_set_ndp_create_transaction_id: set ndp create transaction id
  78. * @vdev: pointer to vdev object
  79. * @val: value to set
  80. *
  81. * Return: status of operation
  82. */
  83. QDF_STATUS ucfg_nan_set_ndp_create_transaction_id(struct wlan_objmgr_vdev *vdev,
  84. uint16_t val);
  85. /**
  86. * ucfg_nan_get_ndp_create_transaction_id: get ndp create transaction id
  87. * vdev obj
  88. * @vdev: pointer to vdev object
  89. *
  90. * Return: ndp create transaction_id
  91. */
  92. uint16_t ucfg_nan_get_ndp_create_transaction_id(struct wlan_objmgr_vdev *vdev);
  93. /**
  94. * ucfg_nan_set_ndp_delete_transaction_id: set ndp delete transaction id
  95. * @vdev: pointer to vdev object
  96. * @val: value to set
  97. *
  98. * Return: status of operation
  99. */
  100. QDF_STATUS ucfg_nan_set_ndp_delete_transaction_id(struct wlan_objmgr_vdev *vdev,
  101. uint16_t val);
  102. /**
  103. * ucfg_nan_get_ndp_delete_transaction_id: get ndp delete transaction id from
  104. * vdev obj
  105. * @vdev: pointer to vdev object
  106. *
  107. * Return: ndp delete transaction_id
  108. */
  109. uint16_t ucfg_nan_get_ndp_delete_transaction_id(struct wlan_objmgr_vdev *vdev);
  110. /**
  111. * ucfg_nan_set_ndi_delete_rsp_reason: set ndi delete response reason
  112. * @vdev: pointer to vdev object
  113. * @val: value to set
  114. *
  115. * Return: status of operation
  116. */
  117. QDF_STATUS ucfg_nan_set_ndi_delete_rsp_reason(struct wlan_objmgr_vdev *vdev,
  118. uint32_t val);
  119. /**
  120. * ucfg_nan_get_ndi_delete_rsp_reason: get ndi delete response reason from vdev
  121. * obj
  122. * @vdev: pointer to vdev object
  123. *
  124. * Return: ndi delete rsp reason
  125. */
  126. uint32_t ucfg_nan_get_ndi_delete_rsp_reason(struct wlan_objmgr_vdev *vdev);
  127. /**
  128. * ucfg_nan_set_ndi_delete_rsp_status: set ndi delete response reason
  129. * @vdev: pointer to vdev object
  130. * @val: value to set
  131. *
  132. * Return: status of operation
  133. */
  134. QDF_STATUS ucfg_nan_set_ndi_delete_rsp_status(struct wlan_objmgr_vdev *vdev,
  135. uint32_t val);
  136. /**
  137. * ucfg_nan_get_ndi_delete_rsp_status: get ndi delete response status from vdev
  138. * obj
  139. * @vdev: pointer to vdev object
  140. *
  141. * Return: ndi delete rsp status
  142. */
  143. uint32_t ucfg_nan_get_ndi_delete_rsp_status(struct wlan_objmgr_vdev *vdev);
  144. /**
  145. * ucfg_nan_get_callbacks: ucfg API to return callbacks
  146. * @psoc: pointer to psoc object
  147. * @cb_obj: callback struct to populate
  148. *
  149. * Return: callback struct on success, NULL otherwise
  150. */
  151. QDF_STATUS ucfg_nan_get_callbacks(struct wlan_objmgr_psoc *psoc,
  152. struct nan_callbacks *cb_obj);
  153. /**
  154. * ucfg_nan_req_processor: ucfg API to be called from HDD/OS_IF to
  155. * process nan datapath initiator request from userspace
  156. * @vdev: nan vdev pointer
  157. * @in_req: NDP request
  158. * @psoc: pointer to psoc object
  159. * @req_type: type of request
  160. *
  161. * Return: status of operation
  162. */
  163. QDF_STATUS ucfg_nan_req_processor(struct wlan_objmgr_vdev *vdev,
  164. void *in_req, uint32_t req_type);
  165. /**
  166. * ucfg_nan_datapath_event_handler: ucfg API to be called from legacy code to
  167. * post events to os_if/hdd layer
  168. * @psoc: pointer to psoc object
  169. * @vdev: pointer to vdev object
  170. * @type: message type
  171. * @msg: msg buffer
  172. *
  173. * Return: None
  174. */
  175. void ucfg_nan_datapath_event_handler(struct wlan_objmgr_psoc *psoc,
  176. struct wlan_objmgr_vdev *vdev,
  177. uint32_t type, void *msg);
  178. /**
  179. * ucfg_nan_register_hdd_callbacks: ucfg API to set hdd callbacks
  180. * @psoc: pointer to psoc object
  181. * @cb_obj: structs containing callbacks
  182. * @os_if_event_handler: os if event handler callback
  183. *
  184. * Return: status of operation
  185. */
  186. int ucfg_nan_register_hdd_callbacks(struct wlan_objmgr_psoc *psoc,
  187. struct nan_callbacks *cb_obj);
  188. /*
  189. * ucfg_nan_register_lim_callbacks: ucfg API to set lim callbacks
  190. * @psoc: pointer to psoc object
  191. * @cb_obj: structs containing callbacks
  192. *
  193. * Return: status of operation
  194. */
  195. int ucfg_nan_register_lim_callbacks(struct wlan_objmgr_psoc *psoc,
  196. struct nan_callbacks *cb_obj);
  197. /**
  198. * ucfg_nan_get_callbacks: ucfg API to return callbacks
  199. * @psoc: pointer to psoc object
  200. * @cb_obj: callback struct to populate
  201. *
  202. * Return: callback struct on success, NULL otherwise
  203. */
  204. QDF_STATUS ucfg_nan_get_callbacks(struct wlan_objmgr_psoc *psoc,
  205. struct nan_callbacks *cb_obj);
  206. /**
  207. * ucfg_nan_discovery_req: ucfg API for NAN Discovery related requests
  208. * @in_req: NAN request
  209. * @req_type: Request type
  210. *
  211. * Return: status of operation
  212. */
  213. QDF_STATUS ucfg_nan_discovery_req(void *in_req, uint32_t req_type);
  214. /**
  215. * ucfg_is_nan_conc_control_supported() - is NAN concurrency controlled by host
  216. * @psoc: pointer to psoc object
  217. *
  218. * This function returns NAN concurrency support status
  219. *
  220. * Return: True if NAN concurrency is controlled by host, False otherwise
  221. */
  222. bool ucfg_is_nan_conc_control_supported(struct wlan_objmgr_psoc *psoc);
  223. /**
  224. * ucfg_is_nan_dbs_supported() - ucfg API to query NAN DBS support
  225. * @psoc: pointer to psoc object
  226. *
  227. * This function returns NAN DBS support status
  228. *
  229. * Return: True if NAN DBS is supported, False otherwise
  230. */
  231. bool ucfg_is_nan_dbs_supported(struct wlan_objmgr_psoc *psoc);
  232. /**
  233. * ucfg_is_ndi_dbs_supported() - ucfg API to query NAN Datapath DBS support
  234. * @psoc: pointer to psoc object
  235. *
  236. * This function returns NDI DBS support status
  237. *
  238. * Return: True if NDI DBS is supported, False otherwise
  239. */
  240. bool ucfg_is_ndi_dbs_supported(struct wlan_objmgr_psoc *psoc);
  241. /**
  242. * ucfg_is_nan_dbs_supported() - ucfg API to query NAN SAP support
  243. * @psoc: pointer to psoc object
  244. *
  245. * This function returns NAN SAP support status
  246. *
  247. * Return: True if NAN SAP is supported, False otherwise
  248. */
  249. bool ucfg_is_nan_sap_supported(struct wlan_objmgr_psoc *psoc);
  250. /**
  251. * ucfg_is_nan_enable_allowed() - ucfg API to query if NAN Discovery is
  252. * allowed
  253. * @psoc: pointer to psoc object
  254. * @nan_ch_freq: NAN Discovery primary social channel
  255. *
  256. * Return: True if NAN Discovery enable is allowed, False otherwise
  257. */
  258. bool ucfg_is_nan_enable_allowed(struct wlan_objmgr_psoc *psoc,
  259. uint32_t nan_ch_freq);
  260. /**
  261. * ucfg_is_nan_disc_active() - ucfg API to query if NAN Discovery is
  262. * active
  263. * @psoc: pointer to psoc object
  264. *
  265. * Return: True if NAN Discovery is active, False otherwise
  266. */
  267. bool ucfg_is_nan_disc_active(struct wlan_objmgr_psoc *psoc);
  268. /**
  269. * ucfg_nan_set_tgt_caps: ucfg API to set the NAN capabilities of the Target
  270. * @psoc: pointer to psoc object
  271. * @nan_caps: pointer to the structure of NAN capability bits
  272. *
  273. * Return: status of operation
  274. */
  275. void ucfg_nan_set_tgt_caps(struct wlan_objmgr_psoc *psoc,
  276. struct nan_tgt_caps *nan_caps);
  277. /**
  278. * ucfg_nan_disable_concurrency: ucfg API to explicitly disable NAN Discovery
  279. * @psoc: pointer to psoc object
  280. *
  281. * Return: None
  282. */
  283. void ucfg_nan_disable_concurrency(struct wlan_objmgr_psoc *psoc);
  284. /**
  285. * ucfg_nan_register_wma_callbacks: ucfg API to register WMA callbacks
  286. * @psoc: pointer to psoc object
  287. * @cb_obj: Pointer to NAN callback structure
  288. *
  289. * Return: status of operation
  290. */
  291. int ucfg_nan_register_wma_callbacks(struct wlan_objmgr_psoc *psoc,
  292. struct nan_callbacks *cb_obj);
  293. /**
  294. * ucfg_nan_check_and_disable_unsupported_ndi: ucfg API to check if NAN Datapath
  295. * is active on multiple NDI's and disable the unsupported concurrencies.
  296. * @psoc: pointer to psoc object
  297. * @force: When set forces NDI disable
  298. *
  299. * Return: QDF_STATUS
  300. */
  301. QDF_STATUS
  302. ucfg_nan_check_and_disable_unsupported_ndi(struct wlan_objmgr_psoc *psoc,
  303. bool force);
  304. /**
  305. * ucfg_ndi_remove_entry_from_policy_mgr() - API to remove NDI entry from
  306. * policy manager.
  307. * @vdev: vdev pointer for NDI interface
  308. *
  309. * Return: QDF_STATUS
  310. */
  311. QDF_STATUS ucfg_ndi_remove_entry_from_policy_mgr(struct wlan_objmgr_vdev *vdev);
  312. /**
  313. * ucfg_nan_is_enable_disable_in_progress() - Is NAN enable/disable in progress
  314. * @psoc: Pointer to PSOC object
  315. *
  316. * Return: True if NAN discovery enable/disable is in progress, false otherwise
  317. */
  318. bool ucfg_nan_is_enable_disable_in_progress(struct wlan_objmgr_psoc *psoc);
  319. /**
  320. * ucfg_nan_is_sta_ndp_concurrency_allowed() - Indicates if NDP is allowed
  321. * @psoc: pointer to psoc object
  322. * @vdev: pointer to vdev object
  323. *
  324. * If STA+NDI(NDPs) exist and another NDI tries to establish
  325. * NDP, then reject the second NDI(NDP).
  326. *
  327. * Return: true if allowed, false otherwise
  328. */
  329. bool ucfg_nan_is_sta_ndp_concurrency_allowed(struct wlan_objmgr_psoc *psoc,
  330. struct wlan_objmgr_vdev *vdev);
  331. /**
  332. * ucfg_nan_set_vdev_creation_supp_by_fw()- Set the NAN separate vdev psoc param
  333. * @psoc: pointer to psoc object
  334. * @set: True if firmware supports NAN separate vdev feature
  335. *
  336. * Cache the value of set in NAN psoc object param.
  337. *
  338. * Return: None
  339. */
  340. void
  341. ucfg_nan_set_vdev_creation_supp_by_fw(struct wlan_objmgr_psoc *psoc, bool set);
  342. /**
  343. * ucfg_nan_is_vdev_creation_allowed()- Get support for NAN vdev creation
  344. * @psoc: pointer to psoc object
  345. *
  346. * Return: True if NAN vdev creation is allowed by host and firmware else false
  347. */
  348. bool ucfg_nan_is_vdev_creation_allowed(struct wlan_objmgr_psoc *psoc);
  349. /**
  350. * ucfg_nan_is_sta_nan_ndi_4_port_allowed- Get support for 4 port (STA +
  351. * NAN Disc + NDI + NDI)
  352. * @psoc: pointer to psoc object
  353. *
  354. * Return: True if 4 port concurrency allowed or not.
  355. */
  356. bool ucfg_nan_is_sta_nan_ndi_4_port_allowed(struct wlan_objmgr_psoc *psoc);
  357. /**
  358. * ucfg_disable_nan_discovery() - Disable NAN discovery
  359. * @psoc: pointer to psoc object
  360. * @data: Data to be sent to NAN discovery engine, which runs in firmware
  361. * @data_len: Length of the data
  362. *
  363. * Send NAN disable request to firmware by setting the mandatory
  364. * params(disable_2g_discovery, disable_5g_discovery) along
  365. * with the data, if provided.
  366. *
  367. * Return: status of operation
  368. */
  369. QDF_STATUS ucfg_disable_nan_discovery(struct wlan_objmgr_psoc *psoc,
  370. uint8_t *data, uint32_t data_len);
  371. /**
  372. * ucfg_nan_disable_ndi() - Disable the NDI with given vdev_id
  373. * @psoc: pointer to psoc object
  374. * @ndi_vdev_id: vdev_id of the NDI to be disabled
  375. *
  376. * Disable all the NDPs present on the given NDI by sending NDP_END_ALL
  377. * to firmware. Firmwere sends an immediate response(NDP_HOST_UPDATE) with
  378. * ndp_disable param as 1 followed by NDP_END indication for all the NDPs.
  379. *
  380. * Return: status of operation
  381. */
  382. QDF_STATUS
  383. ucfg_nan_disable_ndi(struct wlan_objmgr_psoc *psoc, uint32_t ndi_vdev_id);
  384. /**
  385. * ucfg_get_nan_feature_config() - Get NAN feature bitmap
  386. * @psoc: pointer to psoc object
  387. * @nan_feature_config: NAN feature config bitmap to be enabled in firmware
  388. *
  389. * Return: QDF_STATUS
  390. */
  391. QDF_STATUS ucfg_get_nan_feature_config(struct wlan_objmgr_psoc *psoc,
  392. uint32_t *nan_feature_config);
  393. /**
  394. * ucfg_is_nan_vdev() - Check if the current vdev supports NAN or not
  395. * @vdev: pointer to vdev object
  396. *
  397. * Return true
  398. * 1. If the VDEV type is NAN_DISC or
  399. * 2. If the VDEV type is STA and nan_separate_iface feature is not supported
  400. *
  401. * Return: Bool
  402. */
  403. bool ucfg_is_nan_vdev(struct wlan_objmgr_vdev *vdev);
  404. #else /* WLAN_FEATURE_NAN */
  405. static inline
  406. void ucfg_nan_set_tgt_caps(struct wlan_objmgr_psoc *psoc,
  407. struct nan_tgt_caps *nan_caps)
  408. {
  409. }
  410. static inline void ucfg_nan_disable_concurrency(struct wlan_objmgr_psoc *psoc)
  411. {
  412. }
  413. static inline QDF_STATUS
  414. ucfg_nan_check_and_disable_unsupported_ndi(struct wlan_objmgr_psoc *psoc,
  415. bool force)
  416. {
  417. return QDF_STATUS_SUCCESS;
  418. }
  419. static inline QDF_STATUS ucfg_nan_psoc_open(struct wlan_objmgr_psoc *psoc)
  420. {
  421. return QDF_STATUS_SUCCESS;
  422. }
  423. static inline void ucfg_nan_psoc_close(struct wlan_objmgr_psoc *psoc)
  424. {
  425. }
  426. static inline bool ucfg_is_nan_disc_active(struct wlan_objmgr_psoc *psoc)
  427. {
  428. return false;
  429. }
  430. static inline
  431. enum nan_datapath_state ucfg_nan_get_ndi_state(struct wlan_objmgr_vdev *vdev)
  432. {
  433. return NAN_DATA_INVALID_STATE;
  434. }
  435. static inline
  436. bool ucfg_nan_is_enable_disable_in_progress(struct wlan_objmgr_psoc *psoc)
  437. {
  438. return false;
  439. }
  440. static inline
  441. bool ucfg_nan_is_sta_ndp_concurrency_allowed(struct wlan_objmgr_psoc *psoc,
  442. struct wlan_objmgr_vdev *vdev)
  443. {
  444. return false;
  445. }
  446. static inline void
  447. ucfg_nan_set_vdev_creation_supp_by_fw(struct wlan_objmgr_psoc *psoc, bool set)
  448. {
  449. }
  450. static inline
  451. bool ucfg_nan_is_vdev_creation_allowed(struct wlan_objmgr_psoc *psoc)
  452. {
  453. return false;
  454. }
  455. static inline
  456. bool ucfg_nan_is_sta_nan_ndi_4_port_allowed(struct wlan_objmgr_psoc *psoc)
  457. {
  458. return false;
  459. }
  460. static inline
  461. QDF_STATUS ucfg_disable_nan_discovery(struct wlan_objmgr_psoc *psoc,
  462. uint8_t *data, uint32_t data_len)
  463. {
  464. return QDF_STATUS_SUCCESS;
  465. }
  466. static inline
  467. QDF_STATUS
  468. ucfg_nan_disable_ndi(struct wlan_objmgr_psoc *psoc, uint32_t ndi_vdev_id)
  469. {
  470. return QDF_STATUS_E_INVAL;
  471. }
  472. static inline
  473. bool ucfg_is_nan_conc_control_supported(struct wlan_objmgr_psoc *psoc)
  474. {
  475. return false;
  476. }
  477. static inline
  478. QDF_STATUS ucfg_get_nan_feature_config(struct wlan_objmgr_psoc *psoc,
  479. uint32_t *nan_feature_config)
  480. {
  481. return QDF_STATUS_SUCCESS;
  482. }
  483. static inline
  484. bool ucfg_is_nan_vdev(struct wlan_objmgr_vdev *vdev)
  485. {
  486. return false;
  487. }
  488. #endif /* WLAN_FEATURE_NAN */
  489. #endif /* _NAN_UCFG_API_H_ */