son_api.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  2. * Copyright (c) 2021, The Linux Foundation. All rights reserved.
  3. * Copyright (c) 2021-2023 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. #include <qdf_trace.h>
  26. #define son_alert(format, args...) \
  27. QDF_TRACE_FATAL(QDF_MODULE_ID_SON, format, ## args)
  28. #define son_err(format, args...) \
  29. QDF_TRACE_ERROR(QDF_MODULE_ID_SON, format, ## args)
  30. #define son_warn(format, args...) \
  31. QDF_TRACE_WARN(QDF_MODULE_ID_SON, format, ## args)
  32. #define son_info(format, args...) \
  33. QDF_TRACE_INFO(QDF_MODULE_ID_SON, format, ## args)
  34. #define son_debug(format, args...) \
  35. QDF_TRACE_DEBUG(QDF_MODULE_ID_SON, format, ## args)
  36. #define son_nofl_alert(format, args...) \
  37. QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  38. #define son_nofl_err(format, args...) \
  39. QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  40. #define son_nofl_warn(format, args...) \
  41. QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  42. #define son_nofl_info(format, args...) \
  43. QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  44. #define son_nofl_debug(format, args...) \
  45. QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  46. #define son_alert_rl(format, args...) \
  47. QDF_TRACE_FATAL_RL(QDF_MODULE_ID_SON, format, ## args)
  48. #define son_err_rl(format, args...) \
  49. QDF_TRACE_ERROR_RL(QDF_MODULE_ID_SON, format, ## args)
  50. #define son_warn_rl(format, args...) \
  51. QDF_TRACE_WARN_RL(QDF_MODULE_ID_SON, format, ## args)
  52. #define son_info_rl(format, args...) \
  53. QDF_TRACE_INFO_RL(QDF_MODULE_ID_SON, format, ## args)
  54. #define son_debug_rl(format, args...) \
  55. QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_SON, format, ## args)
  56. #define son_nofl_alert_rl(format, args...) \
  57. QDF_TRACE_FATAL_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  58. #define son_nofl_err_rl(format, args...) \
  59. QDF_TRACE_ERROR_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  60. #define son_nofl_warn_rl(format, args...) \
  61. QDF_TRACE_WARN_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  62. #define son_nofl_info_rl(format, args...) \
  63. QDF_TRACE_INFO_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  64. #define son_nofl_debug_rl(format, args...) \
  65. QDF_TRACE_DEBUG_RL_NO_FL(QDF_MODULE_ID_SON, format, ## args)
  66. #define TOTAL_DWELL_TIME 200
  67. #define CBS_DEFAULT_RESTTIME 500 /* msec */
  68. #define CBS_DEFAULT_DWELL_TIME 50 /* msec */
  69. #define CBS_DEFAULT_WAIT_TIME 1000 /* 1 sec */
  70. #define CBS_DEFAULT_DWELL_SPLIT_TIME 50 /* msec */
  71. #define CBS_DEFAULT_DWELL_REST_TIME 500 /* msec */
  72. #define CBS_DEFAULT_MIN_REST_TIME 50 /* msec */
  73. #define DEFAULT_BEACON_INTERVAL 100
  74. #define CBS_DWELL_TIME_10MS 10
  75. #define CBS_DWELL_TIME_25MS 25
  76. #define CBS_DWELL_TIME_50MS 50
  77. #define CBS_DWELL_TIME_75MS 75
  78. #define MIN_SCAN_OFFSET_ARRAY_SIZE 0
  79. #define MAX_SCAN_OFFSET_ARRAY_SIZE 9
  80. #define SCAN_START_OFFSET_MIN 26
  81. #define DEFAULT_SCAN_MAX_REST_TIME 500
  82. /**
  83. * enum son_cbs_state - son cbs state enumeration
  84. * @CBS_INIT: init state
  85. * @CBS_SCAN: scanning state
  86. * @CBS_REST: rest state
  87. * @CBS_RANK: rank state
  88. * @CBS_WAIT: wait state
  89. */
  90. enum son_cbs_state {
  91. CBS_INIT,
  92. CBS_SCAN,
  93. CBS_REST,
  94. CBS_RANK,
  95. CBS_WAIT,
  96. };
  97. /**
  98. * struct son_cbs - son cbs struction
  99. * @vdev: vdev
  100. * @cbs_lock: cbs spin lock
  101. * @cbs_timer: cbs timer
  102. * @cbs_state: cbs state
  103. * @cbs_scan_requestor: scan requestor
  104. * @cbs_scan_id: scan id
  105. * @dwell_time: dwell time configuration
  106. * @rest_time: rest time configuration
  107. * @wait_time: wait time configuration
  108. * @scan_intvl_time: interval time configuration
  109. * @scan_params: scan params
  110. * @max_dwell_split_cnt: max dwell split counter
  111. * @dwell_split_cnt: dwell split counter
  112. * @scan_offset: scan offset array
  113. * @scan_dwell_rest: scan dwell rest array
  114. * @min_dwell_rest_time: nub dwell rest time
  115. * @dwell_split_time: dwell split time
  116. * @max_arr_size_used: max array size used
  117. */
  118. struct son_cbs {
  119. struct wlan_objmgr_vdev *vdev;
  120. spinlock_t cbs_lock;
  121. qdf_timer_t cbs_timer;
  122. enum son_cbs_state cbs_state;
  123. wlan_scan_requester cbs_scan_requestor;
  124. wlan_scan_id cbs_scan_id;
  125. uint32_t dwell_time;
  126. uint32_t rest_time;
  127. uint32_t wait_time;
  128. int32_t scan_intvl_time;
  129. struct scan_start_request scan_params;
  130. uint8_t max_dwell_split_cnt;
  131. int8_t dwell_split_cnt;
  132. uint32_t scan_offset[10];
  133. uint32_t scan_dwell_rest[10];
  134. uint32_t min_dwell_rest_time;
  135. uint32_t dwell_split_time;
  136. uint8_t max_arr_size_used;
  137. };
  138. /**
  139. * typedef mlme_deliver_cb() - cb to deliver mlme event
  140. * @vdev: pointer to vdev
  141. * @event_len: event length
  142. * @event_buf: event buffer
  143. *
  144. * Return: 0 if event is sent successfully
  145. */
  146. typedef int (*mlme_deliver_cb)(struct wlan_objmgr_vdev *vdev,
  147. uint32_t event_len,
  148. const uint8_t *event_buf);
  149. /**
  150. * enum SON_MLME_DELIVER_CB_TYPE - mlme deliver cb type
  151. * @SON_MLME_DELIVER_CB_TYPE_OPMODE: cb to deliver opmode
  152. * @SON_MLME_DELIVER_CB_TYPE_SMPS: cb to deliver smps
  153. */
  154. enum SON_MLME_DELIVER_CB_TYPE {
  155. SON_MLME_DELIVER_CB_TYPE_OPMODE,
  156. SON_MLME_DELIVER_CB_TYPE_SMPS,
  157. };
  158. /**
  159. * wlan_son_register_mlme_deliver_cb - register mlme deliver cb
  160. * @psoc: pointer to psoc
  161. * @cb: mlme deliver cb
  162. * @type: mlme deliver cb type
  163. *
  164. * Return: QDF_STATUS
  165. */
  166. QDF_STATUS
  167. wlan_son_register_mlme_deliver_cb(struct wlan_objmgr_psoc *psoc,
  168. mlme_deliver_cb cb,
  169. enum SON_MLME_DELIVER_CB_TYPE type);
  170. /**
  171. * wlan_son_peer_ext_stat_enable() - sends EXT stats command to FW
  172. * @pdev: pointer to pdev
  173. * @mac_addr: MAC address of the target peer
  174. * @vdev: Pointer to vdev
  175. * @stats_count: Stats count
  176. * @enable: Enable / disable ext stats
  177. *
  178. * Return: QDF_STATUS_SUCCESS on success else failure
  179. */
  180. QDF_STATUS wlan_son_peer_ext_stat_enable(struct wlan_objmgr_pdev *pdev,
  181. uint8_t *mac_addr,
  182. struct wlan_objmgr_vdev *vdev,
  183. uint32_t stats_count,
  184. uint32_t enable);
  185. /**
  186. * wlan_son_peer_req_inst_stats() - Requests for instantaneous stats for
  187. * the target mac_addr from FW via
  188. * WMI_REQUEST_STATS_CMDID.
  189. * @pdev: pointer to pdev
  190. * @mac_addr: MAC address of the target peer
  191. * @vdev: Pointer to vdev
  192. *
  193. * Return: QDF_STATUS_SUCCESS on success else failure
  194. */
  195. QDF_STATUS wlan_son_peer_req_inst_stats(struct wlan_objmgr_pdev *pdev,
  196. uint8_t *mac_addr,
  197. struct wlan_objmgr_vdev *vdev);
  198. /**
  199. * wlan_son_get_chan_flag() - get chan flag
  200. * @pdev: pointer to pdev
  201. * @freq: qdf_freq_t
  202. * @flag_160: If true, 160 channel info will be obtained;
  203. * otherwise 80+80, 80 channel info will be obtained
  204. * @chan_params: chan parameters
  205. *
  206. * Return: combination of enum qca_wlan_vendor_channel_prop_flags and
  207. * enum qca_wlan_vendor_channel_prop_flags_2
  208. */
  209. uint32_t wlan_son_get_chan_flag(struct wlan_objmgr_pdev *pdev,
  210. qdf_freq_t freq, bool flag_160,
  211. struct ch_params *chan_params);
  212. /**
  213. * wlan_son_peer_set_kickout_allow() - set the peer is allowed to kickout
  214. * @vdev: pointer to vdev
  215. * @peer: pointer to peer
  216. * @kickout_allow: kickout_allow to set
  217. *
  218. * Return: QDF_STATUS_SUCCESS on Success else failure.
  219. */
  220. QDF_STATUS wlan_son_peer_set_kickout_allow(struct wlan_objmgr_vdev *vdev,
  221. struct wlan_objmgr_peer *peer,
  222. bool kickout_allow);
  223. /**
  224. * wlan_son_cbs_init() - son cbs init
  225. *
  226. * Return: 0 if succeed
  227. */
  228. int wlan_son_cbs_init(void);
  229. /* wlan_son_cbs_deinit - son cbs deinit
  230. *
  231. * Return: 0 if succeed
  232. */
  233. int wlan_son_cbs_deinit(void);
  234. /* wlan_son_cbs_enable() - son cbs enable
  235. * @vdev: pointer to vdev
  236. *
  237. * Return: 0 if succeed
  238. */
  239. int wlan_son_cbs_enable(struct wlan_objmgr_vdev *vdev);
  240. /* wlan_son_cbs_disable() - son cbs disable
  241. * @vdev: pointer to vdev
  242. *
  243. * Return: 0 if succeed
  244. */
  245. int wlan_son_cbs_disable(struct wlan_objmgr_vdev *vdev);
  246. /* wlan_son_set_cbs() - son cbs set
  247. * @vdev: pointer to vdev
  248. * @enable: enable or disable son cbs
  249. *
  250. * Return: 0 if succeed
  251. */
  252. int wlan_son_set_cbs(struct wlan_objmgr_vdev *vdev,
  253. bool enable);
  254. /* wlan_son_set_cbs_wait_time() - cbs wait time configure
  255. * @vdev: pointer to vdev
  256. * @val: wait time value
  257. *
  258. * Return: 0 if succeed
  259. */
  260. int wlan_son_set_cbs_wait_time(struct wlan_objmgr_vdev *vdev,
  261. uint32_t val);
  262. /* wlan_son_set_cbs_dwell_split_time() - cbs dwell spilt time configure
  263. * @vdev: pointer to vdev
  264. * @val: dwell spilt time value
  265. *
  266. * Return: 0 if succeed
  267. */
  268. int wlan_son_set_cbs_dwell_split_time(struct wlan_objmgr_vdev *vdev,
  269. uint32_t val);
  270. /**
  271. * wlan_son_vdev_get_supported_txrx_streams() - get supported spatial streams
  272. * @vdev: pointer to vdev
  273. * @num_tx_streams: pointer to number of tx streams
  274. * @num_rx_streams: pointer to number of rx streams
  275. *
  276. * Return: QDF_STATUS_SUCCESS on Success else failure.
  277. */
  278. QDF_STATUS
  279. wlan_son_vdev_get_supported_txrx_streams(struct wlan_objmgr_vdev *vdev,
  280. uint32_t *num_tx_streams,
  281. uint32_t *num_rx_streams);
  282. #ifdef WLAN_FEATURE_SON
  283. /**
  284. * wlan_son_peer_is_kickout_allow() - Is peer is allowed to kickout
  285. * @vdev: pointer to vdev
  286. * @macaddr: mac addr of the peer
  287. *
  288. * Return: True if it is allowed to kickout.
  289. */
  290. bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev,
  291. uint8_t *macaddr);
  292. /**
  293. * wlan_son_ind_assoc_req_frm() - indicate assoc req frame to son
  294. * @vdev: pointer to vdev
  295. * @macaddr: MAC address
  296. * @is_reassoc: true if it is reassoc req
  297. * @frame: frame body
  298. * @frame_len: frame body length
  299. * @status: assoc req frame is handled successfully
  300. *
  301. * Return: Void
  302. */
  303. void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
  304. uint8_t *macaddr, bool is_reassoc,
  305. uint8_t *frame, uint16_t frame_len,
  306. QDF_STATUS status);
  307. /**
  308. * wlan_son_deliver_tx_power() - notify son module of tx power
  309. * @vdev: vdev
  310. * @max_pwr: max power in dBm unit
  311. *
  312. * Return: 0 if event is sent successfully
  313. */
  314. int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev,
  315. int32_t max_pwr);
  316. /**
  317. * wlan_son_deliver_vdev_stop() - notify son module of vdev stop
  318. * @vdev: vdev
  319. *
  320. * Return: 0 if event is sent successfully
  321. */
  322. int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev);
  323. /**
  324. * wlan_son_deliver_inst_rssi() - notify son module of inst rssi
  325. * @vdev: vdev
  326. * @peer: peer device
  327. * @irssi: inst rssi above the noise floor in dB unit
  328. *
  329. * Return: 0 if event is sent successfully
  330. */
  331. int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev,
  332. struct wlan_objmgr_peer *peer,
  333. uint32_t irssi);
  334. /**
  335. * wlan_son_deliver_opmode() - notify user app of opmode
  336. * @vdev: vdev objmgr
  337. * @bw: channel width defined in enum eSirMacHTChannelWidth
  338. * @nss: supported rx nss
  339. * @addr: source addr
  340. *
  341. * Return: 0 if event is sent successfully
  342. */
  343. int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev,
  344. uint8_t bw,
  345. uint8_t nss,
  346. uint8_t *addr);
  347. /**
  348. * wlan_son_deliver_smps() - notify user app of smps
  349. * @vdev: vdev objmgr
  350. * @is_static: is_static
  351. * @addr: source addr
  352. *
  353. * Return: 0 if event is sent successfully
  354. */
  355. int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev,
  356. uint8_t is_static,
  357. uint8_t *addr);
  358. /**
  359. * wlan_son_deliver_rrm_rpt() - notify son module of rrm rpt
  360. * @vdev: vdev objmgr
  361. * @addr: sender addr
  362. * @frm: points to measurement report
  363. * @flen: frame length
  364. *
  365. * Return: 0 if event is sent successfully
  366. */
  367. int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev,
  368. uint8_t *addr,
  369. uint8_t *frm,
  370. uint32_t flen);
  371. /**
  372. * wlan_son_anqp_frame() - notify son module of mgmt frames
  373. * @vdev: vdev
  374. * @subtype: frame subtype
  375. * @frame: the 802.11 frame
  376. * @frame_len: frame length
  377. * @action_hdr: Action header of the frame
  378. * @macaddr: source mac address
  379. *
  380. * Return: 0 if event is sent successfully
  381. */
  382. int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype,
  383. uint8_t *frame, uint16_t frame_len, void *action_hdr,
  384. uint8_t *macaddr);
  385. /**
  386. * wlan_son_get_node_tx_power() - Gets the max transmit power for peer
  387. * @assoc_req_ies: assoc req ies
  388. *
  389. * Return: Returns the max tx power
  390. */
  391. uint8_t wlan_son_get_node_tx_power(struct element_info assoc_req_ies);
  392. /**
  393. * wlan_son_get_peer_rrm_info() - Get RRM info for peer
  394. * @assoc_req_ies: assoc req ies
  395. * @rrmcaps: rrm capabilities
  396. * @is_beacon_meas_supported: if beacon meas is supported
  397. *
  398. * Return: Returns QDF_STATUS_SUCCESS if succeed
  399. */
  400. QDF_STATUS wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies,
  401. uint8_t *rrmcaps,
  402. bool *is_beacon_meas_supported);
  403. #else
  404. static inline bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev,
  405. uint8_t *macaddr)
  406. {
  407. return true;
  408. }
  409. static inline
  410. void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
  411. uint8_t *macaddr, bool is_reassoc,
  412. uint8_t *frame, uint16_t frame_len,
  413. QDF_STATUS status)
  414. {
  415. }
  416. static inline
  417. int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev,
  418. int32_t max_pwr)
  419. {
  420. return -EINVAL;
  421. }
  422. static inline
  423. int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev)
  424. {
  425. return -EINVAL;
  426. }
  427. static inline
  428. int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev,
  429. struct wlan_objmgr_peer *peer,
  430. uint32_t irssi)
  431. {
  432. return -EINVAL;
  433. }
  434. static inline
  435. int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev,
  436. uint8_t bw,
  437. uint8_t nss,
  438. uint8_t *addr)
  439. {
  440. return -EINVAL;
  441. }
  442. static inline
  443. int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev,
  444. uint8_t is_static,
  445. uint8_t *addr)
  446. {
  447. return -EINVAL;
  448. }
  449. static inline
  450. int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev,
  451. uint8_t *mac_addr,
  452. uint8_t *frm,
  453. uint32_t flen)
  454. {
  455. return -EINVAL;
  456. }
  457. static inline
  458. int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype,
  459. uint8_t *frame, uint16_t frame_len, void *action_hdr,
  460. uint8_t *macaddr)
  461. {
  462. return -EINVAL;
  463. }
  464. static inline
  465. uint8_t wlan_son_get_node_tx_power(struct element_info assoc_req_ies)
  466. {
  467. return 0;
  468. }
  469. static inline
  470. QDF_STATUS wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies,
  471. uint8_t *rrmcaps,
  472. bool *is_beacon_meas_supported)
  473. {
  474. return QDF_STATUS_E_INVAL;
  475. }
  476. #endif /*WLAN_FEATURE_SON*/
  477. #endif