son_api.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. /*
  2. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. *
  5. * Permission to use, copy, modify, and/or distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  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. /**
  17. * DOC : contains interface prototypes for son api
  18. */
  19. #ifndef _SON_API_H_
  20. #define _SON_API_H_
  21. #include <qdf_types.h>
  22. #include <wlan_objmgr_peer_obj.h>
  23. #include <wlan_objmgr_pdev_obj.h>
  24. #include <reg_services_public_struct.h>
  25. #define TOTAL_DWELL_TIME 200
  26. #define CBS_DEFAULT_RESTTIME 500 /* msec */
  27. #define CBS_DEFAULT_DWELL_TIME 50 /* msec */
  28. #define CBS_DEFAULT_WAIT_TIME 1000 /* 1 sec */
  29. #define CBS_DEFAULT_DWELL_SPLIT_TIME 50 /* msec */
  30. #define CBS_DEFAULT_DWELL_REST_TIME 500 /* msec */
  31. #define CBS_DEFAULT_MIN_REST_TIME 50 /* msec */
  32. #define DEFAULT_BEACON_INTERVAL 100
  33. #define CBS_DWELL_TIME_10MS 10
  34. #define CBS_DWELL_TIME_25MS 25
  35. #define CBS_DWELL_TIME_50MS 50
  36. #define CBS_DWELL_TIME_75MS 75
  37. #define MIN_SCAN_OFFSET_ARRAY_SIZE 0
  38. #define MAX_SCAN_OFFSET_ARRAY_SIZE 9
  39. #define SCAN_START_OFFSET_MIN 26
  40. #define DEFAULT_SCAN_MAX_REST_TIME 500
  41. /**
  42. * enum son_cbs_state - son cbs state enumeration
  43. * @CBS_INIT: init state
  44. * @CBS_SCAN: scanning state
  45. * @CBS_REST: rest state
  46. * @CBS_RANK: rank state
  47. * @CBS_WAIT: wait state
  48. */
  49. enum son_cbs_state {
  50. CBS_INIT,
  51. CBS_SCAN,
  52. CBS_REST,
  53. CBS_RANK,
  54. CBS_WAIT,
  55. };
  56. /**
  57. * struct son_cbs - son cbs struction
  58. * @vdev: vdev
  59. * @cbs_lock: cbs spin lock
  60. * @cbs_timer: cbs timer
  61. * @cbs_state: cbs state
  62. * @cbs_scan_requestor: scan requestor
  63. * @cbs_scan_id: scan id
  64. * @dwell_time: dwell time configuration
  65. * @rest_time: rest time configuration
  66. * @wait_time: wait time configuration
  67. * @scan_intvl_time: interval time configuration
  68. * @scan_params: scan params
  69. * @max_dwell_split_cnt: max dwell split counter
  70. * @dwell_split_cnt: dwell split counter
  71. * @scan_offset: scan offset array
  72. * @scan_dwell_rest: scan dwell rest array
  73. * @min_dwell_rest_time: nub dwell rest time
  74. * @dwell_split_time: dwell split time
  75. * @max_arr_size_used: max array size used
  76. */
  77. struct son_cbs {
  78. struct wlan_objmgr_vdev *vdev;
  79. spinlock_t cbs_lock;
  80. qdf_timer_t cbs_timer;
  81. enum son_cbs_state cbs_state;
  82. wlan_scan_requester cbs_scan_requestor;
  83. wlan_scan_id cbs_scan_id;
  84. uint32_t dwell_time;
  85. uint32_t rest_time;
  86. uint32_t wait_time;
  87. int32_t scan_intvl_time;
  88. struct scan_start_request scan_params;
  89. uint8_t max_dwell_split_cnt;
  90. int8_t dwell_split_cnt;
  91. uint32_t scan_offset[10];
  92. uint32_t scan_dwell_rest[10];
  93. uint32_t min_dwell_rest_time;
  94. uint32_t dwell_split_time;
  95. uint8_t max_arr_size_used;
  96. };
  97. /**
  98. * mlme_deliver_cb - cb to deliver mlme event
  99. * @vdev: pointer to vdev
  100. * @event_len: event length
  101. * @event_buf: event buffer
  102. *
  103. * @Return: 0 if event is sent successfully
  104. */
  105. typedef int (*mlme_deliver_cb)(struct wlan_objmgr_vdev *vdev,
  106. uint32_t event_len,
  107. const uint8_t *event_buf);
  108. /**
  109. * enum SON_MLME_DELIVER_CB_TYPE - mlme deliver cb type
  110. * @SON_MLME_DELIVER_CB_TYPE_OPMODE: cb to deliver opmode
  111. * @SON_MLME_DELIVER_CB_TYPE_SMPS: cb to deliver smps
  112. */
  113. enum SON_MLME_DELIVER_CB_TYPE {
  114. SON_MLME_DELIVER_CB_TYPE_OPMODE,
  115. SON_MLME_DELIVER_CB_TYPE_SMPS,
  116. };
  117. /**
  118. * wlan_son_register_mlme_deliver_cb - register mlme deliver cb
  119. * @psoc: pointer to psoc
  120. * @cb: mlme deliver cb
  121. * @type: mlme deliver cb type
  122. *
  123. * Return: QDF_STATUS
  124. */
  125. QDF_STATUS
  126. wlan_son_register_mlme_deliver_cb(struct wlan_objmgr_psoc *psoc,
  127. mlme_deliver_cb cb,
  128. enum SON_MLME_DELIVER_CB_TYPE type);
  129. /**
  130. * wlan_son_get_chan_flag() - get chan flag
  131. * @pdev: pointer to pdev
  132. * @freq: qdf_freq_t
  133. * @flag_160: If true, 160 channel info will be obtained;
  134. * otherwise 80+80, 80 channel info will be obtained
  135. * @chan_params: chan parameters
  136. *
  137. * Return: combination of enum qca_wlan_vendor_channel_prop_flags and
  138. * enum qca_wlan_vendor_channel_prop_flags_2
  139. */
  140. uint32_t wlan_son_get_chan_flag(struct wlan_objmgr_pdev *pdev,
  141. qdf_freq_t freq, bool flag_160,
  142. struct ch_params *chan_params);
  143. /**
  144. * wlan_son_peer_set_kickout_allow() - set the peer is allowed to kickout
  145. * @vdev: pointer to vdev
  146. * @peer: pointer to peer
  147. * @kickout_allow: kickout_allow to set
  148. *
  149. * Return: QDF_STATUS_SUCCESS on Success else failure.
  150. */
  151. QDF_STATUS wlan_son_peer_set_kickout_allow(struct wlan_objmgr_vdev *vdev,
  152. struct wlan_objmgr_peer *peer,
  153. bool kickout_allow);
  154. /**
  155. * wlan_son_cbs_init() - son cbs init
  156. *
  157. * Return: 0 if succeed
  158. */
  159. int wlan_son_cbs_init(void);
  160. /* wlan_son_cbs_deinit - son cbs deinit
  161. *
  162. * Return: 0 if succeed
  163. */
  164. int wlan_son_cbs_deinit(void);
  165. /* wlan_son_cbs_enable() - son cbs enable
  166. * @vdev: pointer to vdev
  167. *
  168. * Return: 0 if succeed
  169. */
  170. int wlan_son_cbs_enable(struct wlan_objmgr_vdev *vdev);
  171. /* wlan_son_cbs_disable() - son cbs disable
  172. * @vdev: pointer to vdev
  173. *
  174. * Return: 0 if succeed
  175. */
  176. int wlan_son_cbs_disable(struct wlan_objmgr_vdev *vdev);
  177. /* wlan_son_set_cbs() - son cbs set
  178. * @vdev: pointer to vdev
  179. * @enable: enable or disable son cbs
  180. *
  181. * Return: 0 if succeed
  182. */
  183. int wlan_son_set_cbs(struct wlan_objmgr_vdev *vdev,
  184. bool enable);
  185. /* wlan_son_set_cbs_wait_time() - cbs wait time configure
  186. * @vdev: pointer to vdev
  187. * @val: wait time value
  188. *
  189. * Return: 0 if succeed
  190. */
  191. int wlan_son_set_cbs_wait_time(struct wlan_objmgr_vdev *vdev,
  192. uint32_t val);
  193. /* wlan_son_set_cbs_dwell_split_time() - cbs dwell spilt time configure
  194. * @vdev: pointer to vdev
  195. * @val: dwell spilt time value
  196. *
  197. * Return: 0 if succeed
  198. */
  199. int wlan_son_set_cbs_dwell_split_time(struct wlan_objmgr_vdev *vdev,
  200. uint32_t val);
  201. #ifdef WLAN_FEATURE_SON
  202. /**
  203. * wlan_son_peer_is_kickout_allow() - Is peer is allowed to kickout
  204. * @vdev: pointer to vdev
  205. * @macaddr: mac addr of the peer
  206. *
  207. * Return: True if it is allowed to kickout.
  208. */
  209. bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev,
  210. uint8_t *macaddr);
  211. /**
  212. * wlan_son_ind_assoc_req_frm() - indicate assoc req frame to son
  213. * @vdev: pointer to vdev
  214. * @is_reassoc: true if it is reassoc req
  215. * @frame: frame body
  216. * @frame_len: frame body length
  217. * @status: assoc req frame is handled successfully
  218. *
  219. * Return: Void
  220. */
  221. void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
  222. uint8_t *macaddr, bool is_reassoc,
  223. uint8_t *frame, uint16_t frame_len,
  224. QDF_STATUS status);
  225. /**
  226. * wlan_son_deliver_tx_power() - notify son module of tx power
  227. * @vdev: vdev
  228. * @max_pwr: max power in dBm unit
  229. *
  230. * Return: 0 if event is sent successfully
  231. */
  232. int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev,
  233. int32_t max_pwr);
  234. /**
  235. * wlan_son_deliver_vdev_stop() - notify son module of vdev stop
  236. * @vdev: vdev
  237. *
  238. * Return: 0 if event is sent successfully
  239. */
  240. int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev);
  241. /**
  242. * wlan_son_deliver_inst_rssi() - notify son module of inst rssi
  243. * @vdev: vdev
  244. * @peer: peer device
  245. * @irssi: inst rssi above the noise floor in dB unit
  246. *
  247. * Return: 0 if event is sent successfully
  248. */
  249. int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev,
  250. struct wlan_objmgr_peer *peer,
  251. uint32_t irssi);
  252. /**
  253. * wlan_son_deliver_opmode() - notity user app of opmode
  254. * @vdev: vdev objmgr
  255. * @bw: channel width defined in enum eSirMacHTChannelWidth
  256. * @nss: supported rx nss
  257. * @addr: source addr
  258. *
  259. * Return: 0 if event is sent successfully
  260. */
  261. int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev,
  262. uint8_t bw,
  263. uint8_t nss,
  264. uint8_t *addr);
  265. /**
  266. * wlan_son_deliver_smps() - notity user app of smps
  267. * @vdev: vdev objmgr
  268. * @is_static: is_static
  269. * @addr: source addr
  270. *
  271. * Return: 0 if event is sent successfully
  272. */
  273. int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev,
  274. uint8_t is_static,
  275. uint8_t *addr);
  276. /**
  277. * wlan_son_deliver_rrm_rpt() - notity son module of rrm rpt
  278. * @vdev: vdev objmgr
  279. * @addr: sender addr
  280. * @frm: points to measurement report
  281. * @flen: frame length
  282. *
  283. * Return: 0 if event is sent successfully
  284. */
  285. int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev,
  286. uint8_t *addr,
  287. uint8_t *frm,
  288. uint32_t flen);
  289. /**
  290. * wlan_son_anqp_frame() - notify son module of mgmt frames
  291. * @vdev: vdev
  292. * @subtype: frame subtype
  293. * @frame: the 802.11 frame
  294. * @frame_len: frame length
  295. * @action_hdr: Action header of the frame
  296. * @macaddr: source mac address
  297. *
  298. * Return: 0 if event is sent successfully
  299. */
  300. int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype,
  301. uint8_t *frame, uint16_t frame_len, void *action_hdr,
  302. uint8_t *macaddr);
  303. #else
  304. static inline bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev,
  305. uint8_t *macaddr)
  306. {
  307. return true;
  308. }
  309. static inline
  310. void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
  311. uint8_t *macaddr, bool is_reassoc,
  312. uint8_t *frame, uint16_t frame_len,
  313. QDF_STATUS status)
  314. {
  315. }
  316. static inline
  317. int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev,
  318. int32_t max_pwr)
  319. {
  320. return -EINVAL;
  321. }
  322. static inline
  323. int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev)
  324. {
  325. return -EINVAL;
  326. }
  327. static inline
  328. int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev,
  329. struct wlan_objmgr_peer *peer,
  330. uint32_t irssi)
  331. {
  332. return -EINVAL;
  333. }
  334. static inline
  335. int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev,
  336. uint8_t bw,
  337. uint8_t nss,
  338. uint8_t *addr)
  339. {
  340. return -EINVAL;
  341. }
  342. static inline
  343. int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev,
  344. uint8_t is_static,
  345. uint8_t *addr)
  346. {
  347. return -EINVAL;
  348. }
  349. static inline
  350. int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev,
  351. uint8_t *mac_addr,
  352. uint8_t *frm,
  353. uint32_t flen)
  354. {
  355. return -EINVAL;
  356. }
  357. static inline
  358. int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype,
  359. uint8_t *frame, uint16_t frame_len, void *action_hdr,
  360. uint8_t *macaddr)
  361. {
  362. return -EINVAL;
  363. }
  364. #endif /*WLAN_FEATURE_SON*/
  365. #endif