qcacmn: Add wlan_reg_is_5ghz_op_class and wlan_reg_is_2ghz_op_class

Add APIs wlan_reg_is_5ghz_op_class and wlan_reg_is_2ghz_op_class,
to check if an input opclass is a 5ghz, and 2ghz opclass respectively.

Change-Id: I677b5e927ac9060f65b71eee838073348d06d4b2
CRs-Fixed: 2732373
This commit is contained in:
Hariharan Basuthkar 2020-07-14 23:44:33 +05:30 • committed by snandini
commit e7e30c3ce1
6 changed files with 127 additions and 13 deletions

View file

@ -972,4 +972,61 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
return QDF_STATUS_SUCCESS;
}
bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, uint8_t op_class)
{
return ((op_class >= MIN_6GHZ_OPER_CLASS) &&
(op_class <= MAX_6GHZ_OPER_CLASS));
}
/**
* reg_is_opclass_band_found - Check if the input opclass is 2G or 5G.
*
* @country - Pointer to country.
* @op_class - Operating class.
* @bandmask = Bitmask for band.
*
* Return : Return true if the input opclass' band (2Ghz or 5Ghz) matches one
* of bandmask's band.
*/
static bool reg_is_opclass_band_found(const uint8_t *country,
uint8_t op_class,
uint8_t bandmask)
{
const struct reg_dmn_op_class_map_t *op_class_tbl;
op_class_tbl = reg_get_class_from_country((uint8_t *)country);
while (op_class_tbl && op_class_tbl->op_class) {
if (op_class_tbl->op_class == op_class) {
qdf_freq_t freq = op_class_tbl->start_freq +
(op_class_tbl->channels[0] * FREQ_TO_CHAN_SCALE);
if ((bandmask & BIT(REG_BAND_5G)) &&
REG_IS_5GHZ_FREQ(freq))
return true;
if ((bandmask & BIT(REG_BAND_2G)) &&
REG_IS_24GHZ_CH_FREQ(freq))
return true;
return false;
}
op_class_tbl++;
}
reg_err_rl("Opclass %d is not found", op_class);
return false;
}
bool reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class)
{
return reg_is_opclass_band_found(country, op_class, BIT(REG_BAND_5G));
}
bool reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class)
{
return reg_is_opclass_band_found(country, op_class, BIT(REG_BAND_2G));
}
#endif

View file

@ -119,6 +119,27 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
uint8_t *n_opclasses,
uint8_t max_supp_op_class,
bool global_tbl_lookup);
/**
* reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass.
* @country: Country code.
* @op_class: Operating class.
*
* Return: Return true if input the opclass is a 5GHz opclass,
* else return false.
*/
bool reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class);
/**
* reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass.
* @country: Country code.
* @op_class: Operating class.
*
* Return: Return true if input the opclass is a 2.4GHz opclass,
* else return false.
*/
bool reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class);
#ifdef CONFIG_CHAN_FREQ_API
/**
@ -316,6 +337,18 @@ QDF_STATUS reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
return QDF_STATUS_E_FAILURE;
}
static inline
bool reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class)
{
return false;
}
static inline
bool reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class)
{
return false;
}
#ifdef CONFIG_CHAN_FREQ_API
static inline void

View file

@ -3881,12 +3881,6 @@ reg_set_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc, bool val)
return QDF_STATUS_SUCCESS;
}
bool reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev, uint8_t op_class)
{
return ((op_class >= MIN_6GHZ_OPER_CLASS) &&
(op_class <= MAX_6GHZ_OPER_CLASS));
}
#ifdef CONFIG_REG_CLIENT
bool reg_is_6ghz_supported(struct wlan_objmgr_psoc *psoc)
{

View file

@ -1139,13 +1139,13 @@ struct avoid_freq_ind_data {
struct unsafe_ch_list chan_list;
};
#define FIVEG_STARTING_FREQ 5000
#define TWOG_STARTING_FREQ 2407
#define TWOG_CHAN_14_IN_MHZ 2484
#define TWOG_CHAN_1_IN_MHZ 2412
#define TWOG_CHAN_5_IN_MHZ 2432
#define TWOG_CHAN_6_IN_MHZ 2437
#define TWOG_CHAN_13_IN_MHZ 2472
#define FIVEG_STARTING_FREQ 5000
#define TWOG_STARTING_FREQ 2407
#define TWOG_CHAN_14_IN_MHZ 2484
#define TWOG_CHAN_1_IN_MHZ 2412
#define TWOG_CHAN_5_IN_MHZ 2432
#define TWOG_CHAN_6_IN_MHZ 2437
#define TWOG_CHAN_13_IN_MHZ 2472
/**
* struct reg_ctl_params - reg ctl and regd info

View file

@ -1369,6 +1369,26 @@ uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
uint8_t op_class,
bool global_tbl_lookup);
/**
* wlan_reg_is_5ghz_op_class() - Check if the input opclass is a 5GHz opclass.
* @country: Country code.
* @op_class: Operating class.
*
* Return: Return true if input the opclass is a 5GHz opclass,
* else return false.
*/
bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class);
/**
* wlan_reg_is_2ghz_op_class() - Check if the input opclass is a 2.4GHz opclass.
* @country: Country code.
* @op_class: Operating class.
*
* Return: Return true if input the opclass is a 2.4GHz opclass,
* else return false.
*/
bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class);
/**
* wlan_reg_is_6ghz_op_class() - Whether 6ghz oper class
* @pdev: pdev ptr

View file

@ -1155,6 +1155,16 @@ uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
global_tbl_lookup);
}
bool wlan_reg_is_5ghz_op_class(const uint8_t *country, uint8_t op_class)
{
return reg_is_5ghz_op_class(country, op_class);
}
bool wlan_reg_is_2ghz_op_class(const uint8_t *country, uint8_t op_class)
{
return reg_is_2ghz_op_class(country, op_class);
}
bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
uint8_t op_class)
{