qcacmn: Add reg API to convert eirp to PSD power

Add reg API to convert eirp to PSD power based on the
formula: psd = eirp - ten_log10(channel bw)

CRs-Fixed: 3210379
Change-Id: I93506f8262f3fd752e22326e0604d6c8ec5383c9
This commit is contained in:
Priyadarshnee Srinivasan
2022-06-10 13:20:47 +05:30
committed by Madan Koyyalamudi
parent 86bce6b44b
commit 15ba95b476
4 changed files with 81 additions and 0 deletions

View File

@@ -4679,4 +4679,34 @@ QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
reg_err("Invalid input bandwidth %hd", ch_bw); reg_err("Invalid input bandwidth %hd", ch_bw);
return QDF_STATUS_E_FAILURE; return QDF_STATUS_E_FAILURE;
} }
QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw,
int16_t eirp,
int16_t *psd)
{
struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
int16_t ten_log10_bw;
uint8_t i;
uint8_t num_bws;
pdev_priv_obj = reg_get_pdev_obj(pdev);
if (!IS_VALID_PDEV_REG_OBJ(pdev_priv_obj)) {
reg_err("reg pdev private obj is NULL");
return QDF_STATUS_E_FAILURE;
}
/* EIRP = PSD + (10 * log10(CH_BW)) */
num_bws = QDF_ARRAY_SIZE(bw_to_10log10_map);
for (i = 0; i < num_bws; i++) {
if (ch_bw == bw_to_10log10_map[i].bw) {
ten_log10_bw = bw_to_10log10_map[i].ten_l_ten;
*psd = eirp - ten_log10_bw;
return QDF_STATUS_SUCCESS;
}
}
reg_err("Invalid input bandwidth %hd", ch_bw);
return QDF_STATUS_E_FAILURE;
}
#endif #endif

View File

@@ -208,6 +208,21 @@ QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw, uint16_t ch_bw,
int16_t *eirp); int16_t *eirp);
/**
* reg_eirp_2_psd() - Calculate PSD from EIRP and bandwidth
* channel list
* @pdev: pdev pointer
* @ch_bw: Bandwdith of a channel in MHz (20/40/80/160/320 etc)
* @eirp: EIRP power in dBm
* @psd: Power Spectral Density in dBm/MHz
*
* Return: QDF_STATUS
*/
QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw,
int16_t eirp,
int16_t *psd);
/** /**
* reg_is_supp_pwr_mode_invalid - Indicates if the given 6G power mode is * reg_is_supp_pwr_mode_invalid - Indicates if the given 6G power mode is
* one of the valid power modes enumerated by enum supported_6g_pwr_types * one of the valid power modes enumerated by enum supported_6g_pwr_types
@@ -259,6 +274,14 @@ static inline QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
return QDF_STATUS_E_FAILURE; return QDF_STATUS_E_FAILURE;
} }
static inline QDF_STATUS reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw,
int16_t eirp,
int16_t *psd)
{
return QDF_STATUS_E_FAILURE;
}
static inline bool static inline bool
reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode) reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode)
{ {

View File

@@ -2372,6 +2372,20 @@ QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw, uint16_t ch_bw,
int16_t *eirp); int16_t *eirp);
/**
* wlan_reg_eirp_2_psd() - Calculate PSD poewr from EIRP and bandwidth
* @pdev: pdev pointer
* @ch_bw: Bandwidth of a channel in MHz (20/40/80/160/320 etc)
* @eirp: EIRP power in dBm
* @psd: Power Spectral Density in dBm/MHz
*
* Return: QDF_STATUS
*/
QDF_STATUS wlan_reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw,
int16_t eirp,
int16_t *psd);
/** /**
* wlan_reg_get_best_pwr_mode() - Get the best power mode based on input freq * wlan_reg_get_best_pwr_mode() - Get the best power mode based on input freq
* and bandwidth. The mode that provides the best EIRP is the best power mode. * and bandwidth. The mode that provides the best EIRP is the best power mode.
@@ -2408,6 +2422,14 @@ static inline QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
{ {
return QDF_STATUS_E_FAILURE; return QDF_STATUS_E_FAILURE;
} }
static inline QDF_STATUS wlan_reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev,
uint16_t ch_bw,
int16_t eirp,
int16_t *psd)
{
return QDF_STATUS_E_FAILURE;
}
#endif /* CONFIG_BAND_6GHZ */ #endif /* CONFIG_BAND_6GHZ */
/** /**
* wlan_reg_find_chwidth_from_bw () - Gets channel width for given * wlan_reg_find_chwidth_from_bw () - Gets channel width for given

View File

@@ -1816,6 +1816,12 @@ QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
qdf_export_symbol(wlan_reg_psd_2_eirp); qdf_export_symbol(wlan_reg_psd_2_eirp);
QDF_STATUS wlan_reg_eirp_2_psd(struct wlan_objmgr_pdev *pdev, uint16_t ch_bw,
int16_t eirp, int16_t *psd)
{
return reg_eirp_2_psd(pdev, ch_bw, eirp, psd);
}
enum reg_6g_ap_type enum reg_6g_ap_type
wlan_reg_get_best_pwr_mode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq, wlan_reg_get_best_pwr_mode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
qdf_freq_t cen320, qdf_freq_t cen320,