1  /*
2   * Copyright (c) 2023 Qualcomm Innovation Center, Inc. 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  
17  /**
18   * DOC: contains policy manager ll_sap definitions specific to the ll_sap module
19   */
20  #ifndef WLAN_POLICY_MGR_LL_SAP_H
21  #define WLAN_POLICY_MGR_LL_SAP_H
22  
23  #include "wlan_objmgr_psoc_obj.h"
24  
25  #ifdef WLAN_FEATURE_LL_LT_SAP
26  /**
27   * policy_mgr_ll_lt_sap_get_valid_freq() - Check and get valid frequency for
28   * the current interface (SAP/P2PGO/LL_LT_SAP)
29   * @psoc: PSOC object
30   * @pdev: PDEV pointer
31   * @vdev_id: Vdev id of the current interface
32   * @sap_ch_freq: Frequency of the current interface
33   * @cc_switch_mode: Channel switch mode
34   * @new_sap_freq: Updated frequency
35   * @is_ll_lt_sap_present: Indicates if ll_lt_sap is present or not
36   *
37   * This API checks if ll_lt_sap is present or not and if ll_lt_sap is present
38   * then if current frequency of the ll_lt_sap or concurrent SAP or concurrent
39   * P2PGO is valid or not according to ll_lt_sap concurrency, if valid, does not
40   * fill anything in the new_sap_freq and if not valid, update the new_sap_freq
41   * with some new valid frequency.
42   *
43   * Return: true/false
44   */
45  void policy_mgr_ll_lt_sap_get_valid_freq(struct wlan_objmgr_psoc *psoc,
46  					 struct wlan_objmgr_pdev *pdev,
47  					 uint8_t vdev_id,
48  					 qdf_freq_t sap_ch_freq,
49  					 uint8_t cc_switch_mode,
50  					 qdf_freq_t *new_sap_freq,
51  					 bool *is_ll_lt_sap_present);
52  
53  /**
54   * wlan_policy_mgr_get_ll_lt_sap_vdev_id() - Get ll_lt_sap vdev id
55   * @psoc: PSOC object
56   *
57   * API to find ll_lt_sap vdev id
58   *
59   * Return: vdev id
60   */
61  uint8_t wlan_policy_mgr_get_ll_lt_sap_vdev_id(struct wlan_objmgr_psoc *psoc);
62  
63  /**
64   * __policy_mgr_is_ll_lt_sap_restart_required() - Check in ll_lt_sap restart is
65   * required
66   * @psoc: PSOC object
67   * @func: Function pointer of the caller function.
68   *
69   * This API checks if ll_lt_sap restart is required or not
70   *
71   * Return: true/false
72   */
73  bool __policy_mgr_is_ll_lt_sap_restart_required(struct wlan_objmgr_psoc *psoc,
74  						const char *func);
75  
76  #define policy_mgr_is_ll_lt_sap_restart_required(psoc) \
77  	__policy_mgr_is_ll_lt_sap_restart_required(psoc, __func__)
78  
79  /**
80   * policy_mgr_ll_lt_sap_restart_concurrent_sap() - Check and restart
81   * concurrent SAP or ll_lt_sap
82   * @psoc: PSOC object
83   * @is_ll_lt_sap_enabled: Indicates if ll_lt_sap is getting enabled or
84   * getting disabled
85   *
86   * This API checks and restarts concurrent SAP or ll_lt_sap when ll_lt_sap comes
87   * up or goes down.
88   * Concurrent SAP and ll_lt_sap should always be on different MAC.
89   * restart the concurrent SAP in below scenario:
90   * If ll_lt_sap is coming up and HW is not sbs capable and concurrent SAP is
91   * operating on 5 GHz, then move concurrent SAP to 2.4 Ghz MAC to allow
92   * ll_lt_sap on 5 GHz
93   * If ll_lt_sap is going down and if concurrent SAP is on 2.4 GHz then try to
94   * restart concurrent SAP on its original user configured frequency
95   * If ll_lt_sap interface has come up and in parallel if some other interface
96   * comes up on the ll_lt_sap frequency, then ll_lt_sap needs to be restarted.
97   *
98   * Return: None
99   */
100  void policy_mgr_ll_lt_sap_restart_concurrent_sap(struct wlan_objmgr_psoc *psoc,
101  						 bool is_ll_lt_sap_enabled);
102  #else
103  
104  static inline bool
policy_mgr_is_ll_lt_sap_restart_required(struct wlan_objmgr_psoc * psoc)105  policy_mgr_is_ll_lt_sap_restart_required(struct wlan_objmgr_psoc *psoc)
106  {
107  	return false;
108  }
109  
110  static inline
policy_mgr_ll_lt_sap_get_valid_freq(struct wlan_objmgr_psoc * psoc,struct wlan_objmgr_pdev * pdev,uint8_t vdev_id,qdf_freq_t sap_ch_freq,uint8_t cc_switch_mode,qdf_freq_t * new_sap_freq,bool * is_ll_lt_sap_present)111  void policy_mgr_ll_lt_sap_get_valid_freq(struct wlan_objmgr_psoc *psoc,
112  					 struct wlan_objmgr_pdev *pdev,
113  					 uint8_t vdev_id,
114  					 qdf_freq_t sap_ch_freq,
115  					 uint8_t cc_switch_mode,
116  					 qdf_freq_t *new_sap_freq,
117  					 bool *is_ll_lt_sap_present)
118  {
119  }
120  
121  static inline
wlan_policy_mgr_get_ll_lt_sap_vdev_id(struct wlan_objmgr_psoc * psoc)122  uint8_t wlan_policy_mgr_get_ll_lt_sap_vdev_id(struct wlan_objmgr_psoc *psoc)
123  {
124  	return WLAN_INVALID_VDEV_ID;
125  }
126  
127  static inline void
policy_mgr_ll_lt_sap_restart_concurrent_sap(struct wlan_objmgr_psoc * psoc,bool is_ll_lt_sap_enabled)128  policy_mgr_ll_lt_sap_restart_concurrent_sap(struct wlan_objmgr_psoc *psoc,
129  					    bool is_ll_lt_sap_enabled)
130  {
131  }
132  #endif
133  #endif /* WLAN_POLICY_MGR_LL_SAP_H */
134