qcacmn: Update regulatory to use bitmap for band

Setband changes require support for 6G band. Using a bitmap
better supports the addition of new bands. Changes to support
this include:
	1. Update band_capability in regulatory pdev priv obj
	   to be a bitmap.
	2. Add API to convert between the bitmap and
	   enum band_info.
	3. Update channel list modifying function to include
	   case for 6G band.
	4. Update the get and set APIs to use uint32_t instead
	   of band_info.

Change-Id: Iff38fdd7cc540a0e471647de349d7fa57b3a8467
CRs-fixed: 2726285
This commit is contained in:
Lincoln Tran 2020-06-16 13:38:43 -07:00 • committed by snandini
commit 7a0d8efdaa
12 changed files with 114 additions and 46 deletions

View file

@ -254,17 +254,21 @@ static void reg_modify_chan_list_for_indoor_channels(
}
/**
* reg_modify_chan_list_for_band() - Based on the input band value, either
* disable 2GHz or 5GHz channels.
* reg_modify_chan_list_for_band() - Based on the input band bitmap, either
* disable 2GHz, 5GHz, or 6GHz channels.
* @chan_list: Pointer to regulatory channel list.
* @band_val: Input band value.
* @band_bitmap: Input bitmap of reg_wifi_band values.
*/
static void reg_modify_chan_list_for_band(struct regulatory_channel *chan_list,
enum band_info band_val)
uint32_t band_bitmap)
{
enum channel_enum chan_enum;
if (band_val == BAND_2G) {
if (!band_bitmap)
return;
if (!(band_bitmap & BIT(REG_BAND_5G))) {
reg_debug("disabling 5G");
for (chan_enum = MIN_5GHZ_CHANNEL;
chan_enum <= MAX_5GHZ_CHANNEL; chan_enum++) {
chan_list[chan_enum].chan_flags |=
@ -273,7 +277,8 @@ static void reg_modify_chan_list_for_band(struct regulatory_channel *chan_list,
}
}
if (band_val == BAND_5G) {
if (!(band_bitmap & BIT(REG_BAND_2G))) {
reg_debug("disabling 2G");
for (chan_enum = MIN_24GHZ_CHANNEL;
chan_enum <= MAX_24GHZ_CHANNEL; chan_enum++) {
chan_list[chan_enum].chan_flags |=
@ -281,6 +286,16 @@ static void reg_modify_chan_list_for_band(struct regulatory_channel *chan_list,
chan_list[chan_enum].state = CHANNEL_STATE_DISABLE;
}
}
if (!(band_bitmap & BIT(REG_BAND_6G))) {
reg_debug("disabling 6G");
for (chan_enum = MIN_6GHZ_CHANNEL;
chan_enum <= MAX_6GHZ_CHANNEL; chan_enum++) {
chan_list[chan_enum].chan_flags |=
REGULATORY_CHAN_DISABLED;
chan_list[chan_enum].state = CHANNEL_STATE_DISABLE;
}
}
}
/**

View file

@ -82,7 +82,8 @@ QDF_STATUS wlan_regulatory_psoc_obj_created_notification(
soc_reg_obj->offload_enabled = false;
soc_reg_obj->psoc_ptr = psoc;
soc_reg_obj->dfs_enabled = true;
soc_reg_obj->band_capability = BAND_ALL;
soc_reg_obj->band_capability = (BIT(REG_BAND_2G) | BIT(REG_BAND_5G) |
BIT(REG_BAND_6G));
soc_reg_obj->enable_11d_supp = false;
soc_reg_obj->indoor_chan_enabled = true;
soc_reg_obj->force_ssc_disable_indoor_channel = false;
@ -212,7 +213,7 @@ QDF_STATUS wlan_regulatory_pdev_obj_created_notification(
pdev_priv_obj->pdev_ptr = pdev;
pdev_priv_obj->dfs_enabled = psoc_priv_obj->dfs_enabled;
pdev_priv_obj->set_fcc_channel = false;
pdev_priv_obj->band_capability = psoc_priv_obj->band_capability;
pdev_priv_obj->band_capability = psoc_priv_obj->band_capability;
pdev_priv_obj->indoor_chan_enabled =
psoc_priv_obj->indoor_chan_enabled;
pdev_priv_obj->en_chan_144 = true;

View file

@ -91,6 +91,8 @@ struct chan_change_cbk_entry {
* country update is pending for pdev (phy_id).
* @world_country_pending: In this array, element[phy_id] is true if any world
* country update is pending for pdev (phy_id).
* @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the
* bit position value
* @ignore_fw_reg_offload_ind: Ignore FW reg offload indication
* @six_ghz_supported: whether 6ghz is supported
*/
@ -111,7 +113,7 @@ struct wlan_regulatory_psoc_priv_obj {
bool new_11d_ctry_pending[PSOC_MAX_PHY_REG_CAP];
bool world_country_pending[PSOC_MAX_PHY_REG_CAP];
bool dfs_enabled;
enum band_info band_capability;
uint32_t band_capability;
bool indoor_chan_enabled;
bool ignore_fw_reg_offload_ind;
bool enable_11d_supp_original;
@ -147,6 +149,8 @@ struct wlan_regulatory_psoc_priv_obj {
/**
* struct wlan_regulatory_pdev_priv_obj - wlan regulatory pdev private object
* @pdev_opened: whether pdev has been opened by application
* @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the
* bit position value
*/
struct wlan_regulatory_pdev_priv_obj {
struct regulatory_channel cur_chan_list[NUM_CHANNELS];
@ -174,7 +178,7 @@ struct wlan_regulatory_pdev_priv_obj {
qdf_freq_t range_5g_high;
bool dfs_enabled;
bool set_fcc_channel;
enum band_info band_capability;
uint32_t band_capability;
bool indoor_chan_enabled;
bool en_chan_144;
uint32_t wireless_modes;

View file

@ -3903,3 +3903,30 @@ enum reg_phymode reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
}
}
#endif /* CHECK_REG_PHYMODE */
#ifdef CONFIG_REG_CLIENT
enum band_info reg_band_bitmap_to_band_info(uint32_t band_bitmap)
{
if ((band_bitmap & BIT(REG_BAND_2G)) &&
(band_bitmap & BIT(REG_BAND_5G)) &&
(band_bitmap & BIT(REG_BAND_6G)))
return BAND_ALL;
else if ((band_bitmap & BIT(REG_BAND_5G)) &&
(band_bitmap & BIT(REG_BAND_6G)))
return BAND_5G;
else if ((band_bitmap & BIT(REG_BAND_2G)) &&
(band_bitmap & BIT(REG_BAND_6G)))
return BAND_2G;
else if ((band_bitmap & BIT(REG_BAND_2G)) &&
(band_bitmap & BIT(REG_BAND_5G)))
return BAND_ALL;
else if (band_bitmap & BIT(REG_BAND_2G))
return BAND_2G;
else if (band_bitmap & BIT(REG_BAND_5G))
return BAND_5G;
else if (band_bitmap & BIT(REG_BAND_6G))
return BAND_2G;
else
return BAND_UNKNOWN;
}
#endif

View file

@ -1146,4 +1146,18 @@ reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
}
#endif /* CHECK_REG_PHYMODE */
#ifdef CONFIG_REG_CLIENT
/**
* reg_band_bitmap_to_band_info() - Convert the band_bitmap to a band_info enum.
* Since band_info enum only has combinations for 2G and 5G, 6G is not
* considered in this function.
* @band_bitmap: bitmap on top of reg_wifi_band of bands enabled
*
* Return: BAND_ALL if both 2G and 5G band is enabled
* BAND_2G if 2G is enabled but 5G isn't
* BAND_5G if 5G is enabled but 2G isn't
*/
enum band_info reg_band_bitmap_to_band_info(uint32_t band_bitmap);
#endif
#endif

View file

@ -456,8 +456,7 @@ bool reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev *pdev)
}
#endif
QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev,
enum band_info band)
QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, uint32_t band_bitmap)
{
struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj;
struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
@ -471,8 +470,8 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev,
return QDF_STATUS_E_INVAL;
}
if (pdev_priv_obj->band_capability == band) {
reg_info("same band %d", band);
if (pdev_priv_obj->band_capability == band_bitmap) {
reg_info("same band %d", band_bitmap);
return QDF_STATUS_SUCCESS;
}
@ -488,8 +487,8 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev,
return QDF_STATUS_E_INVAL;
}
reg_info("set band_info: %d", band);
pdev_priv_obj->band_capability = band;
reg_info("set band bitmap: %d", band_bitmap);
pdev_priv_obj->band_capability = band_bitmap;
reg_compute_pdev_current_chan_list(pdev_priv_obj);
@ -499,11 +498,9 @@ QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev,
}
QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev,
enum band_info *band)
uint32_t *band_bitmap)
{
struct wlan_regulatory_psoc_priv_obj *psoc_priv_obj;
struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
struct wlan_objmgr_psoc *psoc;
pdev_priv_obj = reg_get_pdev_obj(pdev);
@ -512,20 +509,8 @@ QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev,
return QDF_STATUS_E_INVAL;
}
psoc = wlan_pdev_get_psoc(pdev);
if (!psoc) {
reg_err("psoc is NULL");
return QDF_STATUS_E_INVAL;
}
psoc_priv_obj = reg_get_psoc_obj(psoc);
if (!IS_VALID_PSOC_REG_OBJ(psoc_priv_obj)) {
reg_err("psoc reg component is NULL");
return QDF_STATUS_E_INVAL;
}
reg_debug("get band_info: %d", pdev_priv_obj->band_capability);
*band = pdev_priv_obj->band_capability;
reg_debug("get band bitmap: %d", pdev_priv_obj->band_capability);
*band_bitmap = pdev_priv_obj->band_capability;
return QDF_STATUS_SUCCESS;
}

View file

@ -188,20 +188,20 @@ QDF_STATUS reg_cache_channel_state(struct wlan_objmgr_pdev *pdev,
/**
* reg_set_band() - Sets the band information for the PDEV
* @pdev: The physical dev to set the band for
* @band: The set band parameters to configure for the physical device
* @band_bitmap: The set band parameters to configure for the physical device
*
* Return: QDF_STATUS
*/
QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, enum band_info band);
QDF_STATUS reg_set_band(struct wlan_objmgr_pdev *pdev, uint32_t band_bitmap);
/**
* reg_get_band() - Get the band information for the PDEV
* @pdev: The physical dev to get the band for
* @band: The band parameters of the physical device
* @band_bitmap: The band parameters of the physical device
*
* Return: QDF_STATUS
*/
QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, enum band_info *band);
QDF_STATUS reg_get_band(struct wlan_objmgr_pdev *pdev, uint32_t *band_bitmap);
/**
* reg_set_fcc_constraint() - Apply fcc constraints on channels 12/13
@ -627,4 +627,5 @@ static inline void set_disable_channel_state(
{
}
#endif
#endif

View file

@ -965,7 +965,7 @@ struct reg_config_vars {
uint32_t enable_11d_support;
uint32_t scan_11d_interval;
uint32_t userspace_ctry_priority;
enum band_info band_capability;
uint32_t band_capability;
uint32_t dfs_enabled;
uint32_t indoor_chan_enabled;
uint32_t force_ssc_disable_indoor_channel;

View file

@ -1442,4 +1442,17 @@ wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
}
#endif /* CHECK_REG_PHYMODE */
#ifdef CONFIG_REG_CLIENT
/**
* wlan_reg_band_bitmap_to_band_info() - Convert the band_bitmap to a
* band_info enum
* @band_bitmap: bitmap on top of reg_wifi_band of bands enabled
*
* Return: BAND_ALL if both 2G and 5G band is enabled
* BAND_2G if 2G is enabled but 5G isn't
* BAND_5G if 5G is enabled but 2G isn't
*/
enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap);
#endif
#endif

View file

@ -33,22 +33,23 @@ typedef QDF_STATUS (*reg_event_cb)(void *status_struct);
/**
* ucfg_reg_set_band() - Sets the band information for the PDEV
* @pdev: The physical pdev to set the band for
* @band: The set band parameter to configure for the physical device
* @band_bitmap: The band bitmap parameter (over reg_wifi_band) to configure
* for the physical device
*
* Return: QDF_STATUS
*/
QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev,
enum band_info band);
uint32_t band_bitmap);
/**
* ucfg_reg_get_band() - Gets the band information for the PDEV
* @pdev: The physical pdev to get the band for
* @band: The band parameter of the physical device
* @band_bitmap: The band parameter of the physical device
*
* Return: QDF_STATUS
*/
QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev,
enum band_info *band);
uint32_t *band_bitmap);
/**
* ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event

View file

@ -1205,3 +1205,10 @@ enum reg_phymode wlan_reg_get_max_phymode(struct wlan_objmgr_pdev *pdev,
return reg_get_max_phymode(pdev, phy_in, freq);
}
#endif /* CHECK_REG_PHYMODE */
#ifdef CONFIG_REG_CLIENT
enum band_info wlan_reg_band_bitmap_to_band_info(uint32_t band_bitmap)
{
return reg_band_bitmap_to_band_info(band_bitmap);
}
#endif

View file

@ -119,15 +119,15 @@ QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
#ifdef CONFIG_REG_CLIENT
QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev,
enum band_info band)
uint32_t band_bitmap)
{
return reg_set_band(pdev, band);
return reg_set_band(pdev, band_bitmap);
}
QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev,
enum band_info *band)
uint32_t *band_bitmap)
{
return reg_get_band(pdev, band);
return reg_get_band(pdev, band_bitmap);
}
/**