Bläddra i källkod

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
Priyadarshnee Srinivasan 3 år sedan
förälder
incheckning
15ba95b476

+ 30 - 0
umac/regulatory/core/src/reg_build_chan_list.c

@@ -4679,4 +4679,34 @@ QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
 	reg_err("Invalid input bandwidth %hd", ch_bw);
 	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

+ 23 - 0
umac/regulatory/core/src/reg_build_chan_list.h

@@ -208,6 +208,21 @@ QDF_STATUS reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
 			  uint16_t ch_bw,
 			  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
  * 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;
 }
 
+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
 reg_is_supp_pwr_mode_invalid(enum supported_6g_pwr_types supp_pwr_mode)
 {

+ 22 - 0
umac/regulatory/dispatcher/inc/wlan_reg_services_api.h

@@ -2372,6 +2372,20 @@ QDF_STATUS wlan_reg_psd_2_eirp(struct wlan_objmgr_pdev *pdev,
 			       uint16_t ch_bw,
 			       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
  * 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;
 }
+
+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 */
 /**
  * wlan_reg_find_chwidth_from_bw () - Gets channel width for given

+ 6 - 0
umac/regulatory/dispatcher/src/wlan_reg_services_api.c

@@ -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_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
 wlan_reg_get_best_pwr_mode(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq,
 			   qdf_freq_t cen320,