Browse Source

qcacmn: Process the negative AFC standard EIRP power values

When we receive a negative EIRP value from AFC APP with UINT, we treat it
as a positive value. See the following reasons why EIRP power value
was changed when we received it as a UINT.

1. In the reg_find_eirp_in_afc_eirp_obj function, the afc 'eirp_power'
(16-bit) value is in units of 0.01, and it is an unsigned integer. For
example, if the negative value is "-1400" then it becomes "64136". With
this value, when we try to get the original EIRP value using division
(eirp_obj->eirp_power / EIRP_PWR_SCALE(100)), it returns "641", but the
expected EIRP value is -14.

2. In the reg_get_sp_eirp function, both the variables 'afc_eirp_pwr'
(8-bit) and 'reg_sp_eirp_pwr'(16-bit) are declared as unsigned integers.
For example, when "-14," is assigned to "afc_eirp_pwr", it becomes "242".
And assuming 'reg_sp_eirp_pwr' is "36", the minimum of the two variables,
using QDF_MIN(afc_eirp_pwr, reg_sp_eirp_pwr), becomes "36", but the
expected minimum is "-14 or 242".

Process the positive or negative EIRP values that are received from AFC
application. Receive it as an int instead of an unint and typecast it to
int when we check for minimum value from afc power and standard power.

Change-Id: I255225e1f68ab897d36f3d4fbd5e5815a862460b
CRs-Fixed: 3398501
Jithender Miryala 2 years ago
parent
commit
3a915602b8

+ 1 - 1
umac/cmn_services/regulatory/inc/wlan_reg_afc.h

@@ -202,7 +202,7 @@ struct wlan_afc_resp_opclass_info {
  */
 struct wlan_afc_resp_eirp_info {
 	uint32_t channel_cfi;
-	uint32_t max_eirp_pwr;
+	int32_t  max_eirp_pwr;
 } qdf_packed;
 
 /**

+ 14 - 13
umac/regulatory/core/src/reg_services_common.c

@@ -9414,11 +9414,11 @@ static inline bool reg_is_320_opclass(qdf_freq_t freq, uint8_t op_class)
  *
  * Return: EIRP power
  */
-static uint8_t reg_find_eirp_in_afc_eirp_obj(struct wlan_objmgr_pdev *pdev,
-					     struct chan_eirp_obj *eirp_obj,
-					     qdf_freq_t freq,
-					     qdf_freq_t cen320,
-					     uint8_t op_class)
+static int8_t reg_find_eirp_in_afc_eirp_obj(struct wlan_objmgr_pdev *pdev,
+					    struct chan_eirp_obj *eirp_obj,
+					    qdf_freq_t freq,
+					    qdf_freq_t cen320,
+					    uint8_t op_class)
 {
 	uint8_t k;
 	uint8_t subchannels[NUM_20_MHZ_CHAN_IN_320_MHZ_CHAN];
@@ -9457,11 +9457,11 @@ static uint8_t reg_find_eirp_in_afc_eirp_obj(struct wlan_objmgr_pdev *pdev,
  *
  * Return: EIRP power
  */
-static uint8_t reg_find_eirp_in_afc_chan_obj(struct wlan_objmgr_pdev *pdev,
-					     struct afc_chan_obj *chan_obj,
-					     qdf_freq_t freq,
-					     qdf_freq_t cen320,
-					     uint8_t op_class)
+static int8_t reg_find_eirp_in_afc_chan_obj(struct wlan_objmgr_pdev *pdev,
+					    struct afc_chan_obj *chan_obj,
+					    qdf_freq_t freq,
+					    qdf_freq_t cen320,
+					    uint8_t op_class)
 {
 	uint8_t j;
 
@@ -9469,7 +9469,7 @@ static uint8_t reg_find_eirp_in_afc_chan_obj(struct wlan_objmgr_pdev *pdev,
 		return 0;
 
 	for (j = 0; j < chan_obj->num_chans; j++) {
-		uint8_t afc_eirp;
+		int8_t afc_eirp;
 		struct chan_eirp_obj *eirp_obj = &chan_obj->chan_eirp_info[j];
 
 		afc_eirp = reg_find_eirp_in_afc_eirp_obj(pdev, eirp_obj,
@@ -9675,7 +9675,8 @@ static uint8_t reg_get_sp_eirp(struct wlan_objmgr_pdev *pdev,
 			       bool is_client_list_lookup_needed,
 			       enum reg_6g_client_type client_type)
 {
-	uint8_t i, op_class = 0, chan_num = 0, afc_eirp_pwr = 0;
+	uint8_t i, op_class = 0, chan_num = 0;
+	int8_t afc_eirp_pwr = 0;
 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
 	struct regulatory_channel *sp_master_chan_list = NULL;
 	struct reg_fw_afc_power_event *power_info;
@@ -9757,7 +9758,7 @@ static uint8_t reg_get_sp_eirp(struct wlan_objmgr_pdev *pdev,
 						       &reg_sp_eirp_pwr);
 
 	if (afc_eirp_pwr)
-		return QDF_MIN(afc_eirp_pwr, reg_sp_eirp_pwr);
+		return QDF_MIN(afc_eirp_pwr, (int8_t)reg_sp_eirp_pwr);
 
 	return 0;
 }

+ 4 - 4
umac/regulatory/dispatcher/inc/reg_services_public_struct.h

@@ -990,7 +990,7 @@ struct regulatory_channel {
 	uint8_t chan_num;
 	enum channel_state state;
 	uint32_t chan_flags;
-	uint32_t tx_power;
+	int32_t tx_power;
 	uint16_t min_bw;
 	uint16_t max_bw;
 	uint8_t ant_gain;
@@ -1395,7 +1395,7 @@ struct afc_freq_obj {
  */
 struct chan_eirp_obj {
 	uint8_t cfi;
-	uint16_t eirp_power;
+	int16_t eirp_power;
 };
 
 /**
@@ -1871,7 +1871,7 @@ enum reg_phymode {
  */
 struct chan_power_info {
 	qdf_freq_t chan_cfreq;
-	uint8_t tx_power;
+	int8_t tx_power;
 };
 
 /**
@@ -1888,7 +1888,7 @@ struct chan_power_info {
  */
 struct reg_tpc_power_info {
 	bool is_psd_power;
-	uint8_t eirp_power;
+	int8_t eirp_power;
 	uint8_t power_type_6g;
 	uint8_t num_pwr_levels;
 	uint8_t reg_max[MAX_NUM_PWR_LEVEL];