son_api.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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. #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. * 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_get_chan_flag() - get chan flag
  172. * @pdev: pointer to pdev
  173. * @freq: qdf_freq_t
  174. * @flag_160: If true, 160 channel info will be obtained;
  175. * otherwise 80+80, 80 channel info will be obtained
  176. * @chan_params: chan parameters
  177. *
  178. * Return: combination of enum qca_wlan_vendor_channel_prop_flags and
  179. * enum qca_wlan_vendor_channel_prop_flags_2
  180. */
  181. uint32_t wlan_son_get_chan_flag(struct wlan_objmgr_pdev *pdev,
  182. qdf_freq_t freq, bool flag_160,
  183. struct ch_params *chan_params);
  184. /**
  185. * wlan_son_peer_set_kickout_allow() - set the peer is allowed to kickout
  186. * @vdev: pointer to vdev
  187. * @peer: pointer to peer
  188. * @kickout_allow: kickout_allow to set
  189. *
  190. * Return: QDF_STATUS_SUCCESS on Success else failure.
  191. */
  192. QDF_STATUS wlan_son_peer_set_kickout_allow(struct wlan_objmgr_vdev *vdev,
  193. struct wlan_objmgr_peer *peer,
  194. bool kickout_allow);
  195. /**
  196. * wlan_son_cbs_init() - son cbs init
  197. *
  198. * Return: 0 if succeed
  199. */
  200. int wlan_son_cbs_init(void);
  201. /* wlan_son_cbs_deinit - son cbs deinit
  202. *
  203. * Return: 0 if succeed
  204. */
  205. int wlan_son_cbs_deinit(void);
  206. /* wlan_son_cbs_enable() - son cbs enable
  207. * @vdev: pointer to vdev
  208. *
  209. * Return: 0 if succeed
  210. */
  211. int wlan_son_cbs_enable(struct wlan_objmgr_vdev *vdev);
  212. /* wlan_son_cbs_disable() - son cbs disable
  213. * @vdev: pointer to vdev
  214. *
  215. * Return: 0 if succeed
  216. */
  217. int wlan_son_cbs_disable(struct wlan_objmgr_vdev *vdev);
  218. /* wlan_son_set_cbs() - son cbs set
  219. * @vdev: pointer to vdev
  220. * @enable: enable or disable son cbs
  221. *
  222. * Return: 0 if succeed
  223. */
  224. int wlan_son_set_cbs(struct wlan_objmgr_vdev *vdev,
  225. bool enable);
  226. /* wlan_son_set_cbs_wait_time() - cbs wait time configure
  227. * @vdev: pointer to vdev
  228. * @val: wait time value
  229. *
  230. * Return: 0 if succeed
  231. */
  232. int wlan_son_set_cbs_wait_time(struct wlan_objmgr_vdev *vdev,
  233. uint32_t val);
  234. /* wlan_son_set_cbs_dwell_split_time() - cbs dwell spilt time configure
  235. * @vdev: pointer to vdev
  236. * @val: dwell spilt time value
  237. *
  238. * Return: 0 if succeed
  239. */
  240. int wlan_son_set_cbs_dwell_split_time(struct wlan_objmgr_vdev *vdev,
  241. uint32_t val);
  242. #ifdef WLAN_FEATURE_SON
  243. /**
  244. * wlan_son_peer_is_kickout_allow() - Is peer is allowed to kickout
  245. * @vdev: pointer to vdev
  246. * @macaddr: mac addr of the peer
  247. *
  248. * Return: True if it is allowed to kickout.
  249. */
  250. bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev,
  251. uint8_t *macaddr);
  252. /**
  253. * wlan_son_ind_assoc_req_frm() - indicate assoc req frame to son
  254. * @vdev: pointer to vdev
  255. * @is_reassoc: true if it is reassoc req
  256. * @frame: frame body
  257. * @frame_len: frame body length
  258. * @status: assoc req frame is handled successfully
  259. *
  260. * Return: Void
  261. */
  262. void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
  263. uint8_t *macaddr, bool is_reassoc,
  264. uint8_t *frame, uint16_t frame_len,
  265. QDF_STATUS status);
  266. /**
  267. * wlan_son_deliver_tx_power() - notify son module of tx power
  268. * @vdev: vdev
  269. * @max_pwr: max power in dBm unit
  270. *
  271. * Return: 0 if event is sent successfully
  272. */
  273. int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev,
  274. int32_t max_pwr);
  275. /**
  276. * wlan_son_deliver_vdev_stop() - notify son module of vdev stop
  277. * @vdev: vdev
  278. *
  279. * Return: 0 if event is sent successfully
  280. */
  281. int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev);
  282. /**
  283. * wlan_son_deliver_inst_rssi() - notify son module of inst rssi
  284. * @vdev: vdev
  285. * @peer: peer device
  286. * @irssi: inst rssi above the noise floor in dB unit
  287. *
  288. * Return: 0 if event is sent successfully
  289. */
  290. int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev,
  291. struct wlan_objmgr_peer *peer,
  292. uint32_t irssi);
  293. /**
  294. * wlan_son_deliver_opmode() - notity user app of opmode
  295. * @vdev: vdev objmgr
  296. * @bw: channel width defined in enum eSirMacHTChannelWidth
  297. * @nss: supported rx nss
  298. * @addr: source addr
  299. *
  300. * Return: 0 if event is sent successfully
  301. */
  302. int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev,
  303. uint8_t bw,
  304. uint8_t nss,
  305. uint8_t *addr);
  306. /**
  307. * wlan_son_deliver_smps() - notity user app of smps
  308. * @vdev: vdev objmgr
  309. * @is_static: is_static
  310. * @addr: source addr
  311. *
  312. * Return: 0 if event is sent successfully
  313. */
  314. int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev,
  315. uint8_t is_static,
  316. uint8_t *addr);
  317. /**
  318. * wlan_son_deliver_rrm_rpt() - notity son module of rrm rpt
  319. * @vdev: vdev objmgr
  320. * @addr: sender addr
  321. * @frm: points to measurement report
  322. * @flen: frame length
  323. *
  324. * Return: 0 if event is sent successfully
  325. */
  326. int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev,
  327. uint8_t *addr,
  328. uint8_t *frm,
  329. uint32_t flen);
  330. /**
  331. * wlan_son_anqp_frame() - notify son module of mgmt frames
  332. * @vdev: vdev
  333. * @subtype: frame subtype
  334. * @frame: the 802.11 frame
  335. * @frame_len: frame length
  336. * @action_hdr: Action header of the frame
  337. * @macaddr: source mac address
  338. *
  339. * Return: 0 if event is sent successfully
  340. */
  341. int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype,
  342. uint8_t *frame, uint16_t frame_len, void *action_hdr,
  343. uint8_t *macaddr);
  344. /**
  345. * wlan_son_get_node_tx_power() - Gets the max transmit power for peer
  346. * @assoc_req_ies: assoc req ies
  347. *
  348. * Return: Returns the max tx power
  349. */
  350. uint8_t wlan_son_get_node_tx_power(struct element_info assoc_req_ies);
  351. /**
  352. * wlan_son_get_max_mcs() - calculate the max mcs supported by the node
  353. * @mode: current phymode
  354. * @supp_idx: max supported idx
  355. * @ext_idx: max extended idx
  356. * @ht_mcs_idx: max mcs index for HT
  357. * @vht_mcs_map: mcs map for VHT
  358. *
  359. * return: max_mcs for the node
  360. */
  361. uint8_t wlan_son_get_max_mcs(uint8_t mode, uint8_t supp_idx, uint8_t ext_idx,
  362. uint8_t ht_mcs_idx, uint8_t vht_mcs_map);
  363. /**
  364. * wlan_son_get_peer_rrm_info() - Get RRM info for peer
  365. * @assoc_req_ies: assoc req ies
  366. * @rrmcaps: rrm capabilities
  367. * @is_beacon_meas_supported: if beacon meas is supported
  368. *
  369. * Return: Returns QDF_STATUS_SUCCESS if succeed
  370. */
  371. QDF_STATUS wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies,
  372. uint8_t *rrmcaps,
  373. bool *is_beacon_meas_supported);
  374. #else
  375. static inline bool wlan_son_peer_is_kickout_allow(struct wlan_objmgr_vdev *vdev,
  376. uint8_t *macaddr)
  377. {
  378. return true;
  379. }
  380. static inline
  381. void wlan_son_ind_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
  382. uint8_t *macaddr, bool is_reassoc,
  383. uint8_t *frame, uint16_t frame_len,
  384. QDF_STATUS status)
  385. {
  386. }
  387. static inline
  388. int wlan_son_deliver_tx_power(struct wlan_objmgr_vdev *vdev,
  389. int32_t max_pwr)
  390. {
  391. return -EINVAL;
  392. }
  393. static inline
  394. int wlan_son_deliver_vdev_stop(struct wlan_objmgr_vdev *vdev)
  395. {
  396. return -EINVAL;
  397. }
  398. static inline
  399. int wlan_son_deliver_inst_rssi(struct wlan_objmgr_vdev *vdev,
  400. struct wlan_objmgr_peer *peer,
  401. uint32_t irssi)
  402. {
  403. return -EINVAL;
  404. }
  405. static inline
  406. int wlan_son_deliver_opmode(struct wlan_objmgr_vdev *vdev,
  407. uint8_t bw,
  408. uint8_t nss,
  409. uint8_t *addr)
  410. {
  411. return -EINVAL;
  412. }
  413. static inline
  414. int wlan_son_deliver_smps(struct wlan_objmgr_vdev *vdev,
  415. uint8_t is_static,
  416. uint8_t *addr)
  417. {
  418. return -EINVAL;
  419. }
  420. static inline
  421. int wlan_son_deliver_rrm_rpt(struct wlan_objmgr_vdev *vdev,
  422. uint8_t *mac_addr,
  423. uint8_t *frm,
  424. uint32_t flen)
  425. {
  426. return -EINVAL;
  427. }
  428. static inline
  429. int wlan_son_anqp_frame(struct wlan_objmgr_vdev *vdev, int subtype,
  430. uint8_t *frame, uint16_t frame_len, void *action_hdr,
  431. uint8_t *macaddr)
  432. {
  433. return -EINVAL;
  434. }
  435. static inline
  436. uint8_t wlan_son_get_node_tx_power(struct element_info assoc_req_ies)
  437. {
  438. return 0;
  439. }
  440. static inline
  441. uint8_t wlan_son_get_max_mcs(uint8_t mode, uint8_t supp_idx, uint8_t ext_idx,
  442. uint8_t ht_mcs_idx, uint8_t vht_mcs_map)
  443. {
  444. return 0;
  445. }
  446. static inline
  447. QDF_STATUS wlan_son_get_peer_rrm_info(struct element_info assoc_req_ies,
  448. uint8_t *rrmcaps,
  449. bool *is_beacon_meas_supported)
  450. {
  451. return QDF_STATUS_E_INVAL;
  452. }
  453. #endif /*WLAN_FEATURE_SON*/
  454. #endif