Sfoglia il codice sorgente

qcacmn: Add support to fetch min and max tx power

Add support to fetch min and max tx power from target for
a given set of mcs, nss, chainmask, bw, and other rate flags.

Change-Id: Iafe082db81503a52bdc704d4b71d86d23788fddb
CRs-Fixed: 2061802
Om Prakash Tripathi 7 anni fa
parent
commit
4d23cd7886
3 ha cambiato i file con 278 aggiunte e 12 eliminazioni
  1. 77 1
      wmi/inc/wmi_unified_param.h
  2. 89 4
      wmi/src/wmi_unified_non_tlv.c
  3. 112 7
      wmi/src/wmi_unified_tlv.c

+ 77 - 1
wmi/inc/wmi_unified_param.h

@@ -4230,15 +4230,79 @@ struct periodic_chan_stats_params {
 	bool enable;
 };
 
+/**
+ * enum wmi_host_packet_power_rate_flags: packer power rate flags
+ * @WMI_HOST_FLAG_RTSENA: RTS enabled
+ * @WMI_HOST_FLAG_CTSENA: CTS enabled
+ * @WMI_HOST_FLAG_STBC: STBC is set
+ * @WMI_HOST_FLAG_LDPC: LDPC is set
+ * @WMI_HOST_FLAG_TXBF: Tx Bf enabled
+ * @WMI_HOST_FLAG_MU2: MU2 data
+ * @WMI_HOST_FLAG_MU3: MU3 data
+ * @WMI_HOST_FLAG_SERIES1: Rate series 1
+ * @WMI_HOST_FLAG_SGI: Short gaurd interval
+ */
+enum wmi_host_packet_power_rate_flags {
+	WMI_HOST_FLAG_RTSENA        =  0x0001,
+	WMI_HOST_FLAG_CTSENA        =  0x0002,
+	WMI_HOST_FLAG_STBC          =  0x0004,
+	WMI_HOST_FLAG_LDPC          =  0x0008,
+	WMI_HOST_FLAG_TXBF          =  0x0010,
+	WMI_HOST_FLAG_MU2           =  0x0020,
+	WMI_HOST_FLAG_MU3           =  0x0040,
+	WMI_HOST_FLAG_SERIES1       =  0x0080,
+	WMI_HOST_FLAG_SGI           =  0x0100,
+};
+
+/**
+ * enum wmi_host_su_mu_ofdma_flags: packer power su mu ofdma flags
+ * @WMI_HOST_FLAG_SU: SU Data
+ * @WMI_HOST_FLAG_DL_MU_MIMO_AC: DL AC MU data
+ * @WMI_HOST_FLAG_DL_MU_MIMO_AX: DL AX MU data
+ * @WMI_HOST_FLAG_DL_OFDMA: DL OFDMA data
+ * @WMI_HOST_FLAG_UL_OFDMA: UL OFDMA data
+ * @WMI_HOST_FLAG_UL_MU_MIMO: UL MU data
+ */
+enum wmi_host_su_mu_ofdma_flags {
+	WMI_HOST_FLAG_SU            =  0x0001,
+	WMI_HOST_FLAG_DL_MU_MIMO_AC =  0x0002,
+	WMI_HOST_FLAG_DL_MU_MIMO_AX =  0x0003,
+	WMI_HOST_FLAG_DL_OFDMA      =  0x0004,
+	WMI_HOST_FLAG_UL_OFDMA      =  0x0005,
+	WMI_HOST_FLAG_UL_MU_MIMO    =  0x0006,
+};
+
+/**
+ * enum wmi_host_preamble_type: preamble type
+ * @WMI_HOST_PREAMBLE_OFDM: ofdm rate
+ * @WMI_HOST_PREAMBLE_CCK:  cck rate
+ * @WMI_HOST_PREAMBLE_HT: ht rate
+ * @WMI_HOST_PREAMBLE_VHT: vht rate
+ * @WMI_HOST_PREAMBLE_HE: 11ax he rate
+ */
+enum wmi_host_preamble_type {
+	WMI_HOST_PREAMBLE_OFDM  =  0,
+	WMI_HOST_PREAMBLE_CCK   =  1,
+	WMI_HOST_PREAMBLE_HT    =  2,
+	WMI_HOST_PREAMBLE_VHT   =  3,
+	WMI_HOST_PREAMBLE_HE    =  4,
+};
+
 /**
  * struct packet_power_info_params - packet power info params
+ * @chainmask: chain mask
+ * @chan_width: channel bandwidth
  * @rate_flags: rate flags
+ * @su_mu_ofdma: su/mu/ofdma flags
  * @nss: number of spatial streams
  * @preamble: preamble
  * @hw_rate:
  */
 struct packet_power_info_params {
+	uint16_t chainmask;
+	uint16_t chan_width;
 	uint16_t rate_flags;
+	uint16_t su_mu_ofdma;
 	uint16_t nss;
 	uint16_t preamble;
 	uint16_t hw_rate;
@@ -5807,6 +5871,18 @@ typedef struct {
 	uint32_t pdev_id;
 } wmi_host_pdev_nfcal_power_all_channels_event;
 
+/**
+ * enum wmi_host_pdev_tpc_event_offset: offsets of TPC events
+ * @WMI_HOST_TX_POWER_MAX: offset of max tx power
+ * @WMI_HOST_TX_POWER_MIN: offset of min tx power
+ * @WMI_HOST_TX_POWER_LEN: size of tpc values
+ */
+enum wmi_host_pdev_tpc_event_offset {
+	WMI_HOST_TX_POWER_MAX,
+	WMI_HOST_TX_POWER_MIN,
+	WMI_HOST_TX_POWER_LEN,
+};
+
 /**
  * struct wmi_host_pdev_tpc_event - WMI host pdev TPC event
  * @pdev_id: pdev_id
@@ -5814,7 +5890,7 @@ typedef struct {
  */
 typedef struct {
 	uint32_t pdev_id;
-	uint32_t tpc[1];
+	int32_t tpc[WMI_HOST_TX_POWER_LEN];
 } wmi_host_pdev_tpc_event;
 
 /**

+ 89 - 4
wmi/src/wmi_unified_non_tlv.c

@@ -4433,6 +4433,87 @@ send_nf_dbr_dbm_info_get_cmd_non_tlv(wmi_unified_t wmi_handle)
 				WMI_PDEV_GET_NFCAL_POWER_CMDID);
 }
 
+/**
+ * enum packet_power_non_tlv_flags: Target defined
+ * packet power rate flags
+ * @WMI_NON_TLV_FLAG_ONE_CHAIN: one chain
+ * @WMI_NON_TLV_FLAG_TWO_CHAIN: two chain
+ * @WMI_NON_TLV_FLAG_THREE_CHAIN: three chain
+ * @WMI_NON_TLV_FLAG_FOUR_CHAIN: four chain
+ * @WMI_NON_TLV_FLAG_STBC: STBC is set
+ * @WMI_NON_TLV_FLAG_40MHZ: 40MHz channel width
+ * @WMI_NON_TLV_FLAG_80MHZ: 80MHz channel width
+ * @WMI_NON_TLV_FLAG_1600MHZ: 1600MHz channel width
+ * @WMI_NON_TLV_FLAG_TXBF: Tx Bf enabled
+ * @WMI_NON_TLV_FLAG_RTSENA: RTS enabled
+ * @WMI_NON_TLV_FLAG_CTSENA: CTS enabled
+ * @WMI_NON_TLV_FLAG_LDPC: LDPC is set
+ * @WMI_NON_TLV_FLAG_SERIES1: Rate series 1
+ * @WMI_NON_TLV_FLAG_SGI: Short gaurd interval
+ * @WMI_NON_TLV_FLAG_MU2: MU2 data
+ * @WMI_NON_TLV_FLAG_MU3: MU3 data
+ */
+enum packet_power_non_tlv_flags {
+	WMI_NON_TLV_FLAG_ONE_CHAIN     = 0x0001,
+	WMI_NON_TLV_FLAG_TWO_CHAIN     = 0x0005,
+	WMI_NON_TLV_FLAG_THREE_CHAIN   = 0x0007,
+	WMI_NON_TLV_FLAG_FOUR_CHAIN    = 0x000F,
+	WMI_NON_TLV_FLAG_STBC          = 0x0010,
+	WMI_NON_TLV_FLAG_40MHZ         = 0x0020,
+	WMI_NON_TLV_FLAG_80MHZ         = 0x0040,
+	WMI_NON_TLV_FLAG_160MHZ        = 0x0080,
+	WMI_NON_TLV_FLAG_TXBF          = 0x0100,
+	WMI_NON_TLV_FLAG_RTSENA        = 0x0200,
+	WMI_NON_TLV_FLAG_CTSENA        = 0x0400,
+	WMI_NON_TLV_FLAG_LDPC          = 0x0800,
+	WMI_NON_TLV_FLAG_SERIES1       = 0x1000,
+	WMI_NON_TLV_FLAG_SGI           = 0x2000,
+	WMI_NON_TLV_FLAG_MU2           = 0x4000,
+	WMI_NON_TLV_FLAG_MU3           = 0x8000,
+};
+
+/**
+ * convert_to_power_info_rate_flags() - convert packet_power_info_params
+ * to FW understandable format
+ * @param: pointer to hold packet power info param
+ *
+ * @return FW understandable 16 bit rate flags
+ */
+static uint16_t
+convert_to_power_info_rate_flags(struct packet_power_info_params *param)
+{
+	uint16_t rateflags = 0;
+
+	if (param->chainmask)
+		rateflags |= (param->chainmask & 0xf);
+	if (param->chan_width == WMI_HOST_CHAN_WIDTH_40)
+		rateflags |= WMI_NON_TLV_FLAG_40MHZ;
+	if (param->chan_width == WMI_HOST_CHAN_WIDTH_80)
+		rateflags |= WMI_NON_TLV_FLAG_80MHZ;
+	if (param->chan_width == WMI_HOST_CHAN_WIDTH_160)
+		rateflags |= WMI_NON_TLV_FLAG_160MHZ;
+	if (param->rate_flags & WMI_HOST_FLAG_STBC)
+		rateflags |= WMI_NON_TLV_FLAG_STBC;
+	if (param->rate_flags & WMI_HOST_FLAG_LDPC)
+		rateflags |= WMI_NON_TLV_FLAG_LDPC;
+	if (param->rate_flags & WMI_HOST_FLAG_TXBF)
+		rateflags |= WMI_NON_TLV_FLAG_TXBF;
+	if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
+		rateflags |= WMI_NON_TLV_FLAG_RTSENA;
+	if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
+		rateflags |= WMI_NON_TLV_FLAG_CTSENA;
+	if (param->rate_flags & WMI_HOST_FLAG_SGI)
+		rateflags |= WMI_NON_TLV_FLAG_SGI;
+	if (param->rate_flags & WMI_HOST_FLAG_SERIES1)
+		rateflags |= WMI_NON_TLV_FLAG_SERIES1;
+	if (param->rate_flags & WMI_HOST_FLAG_MU2)
+		rateflags |= WMI_NON_TLV_FLAG_MU2;
+	if (param->rate_flags & WMI_HOST_FLAG_MU3)
+		rateflags |= WMI_NON_TLV_FLAG_MU3;
+
+	return rateflags;
+}
+
 /**
  * send_packet_power_info_get_cmd_non_tlv() - send request to get packet power
  * info to fw
@@ -4447,20 +4528,24 @@ send_packet_power_info_get_cmd_non_tlv(wmi_unified_t wmi_handle,
 {
 	wmi_pdev_get_tpc_cmd *cmd;
 	wmi_buf_t wmibuf;
-	 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd);
+	u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd);
 
 	wmibuf = wmi_buf_alloc(wmi_handle, len);
 	if (wmibuf == NULL)
 		return QDF_STATUS_E_NOMEM;
 
 	cmd = (wmi_pdev_get_tpc_cmd *)wmi_buf_data(wmibuf);
-	cmd->rate_flags = param->rate_flags;
+	cmd->rate_flags = convert_to_power_info_rate_flags(param);
 	cmd->nss = param->nss;
 	cmd->preamble = param->preamble;
 	cmd->hw_rate = param->hw_rate;
 	cmd->rsvd = 0x0;
-	qdf_print("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n", __func__,
-		__LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd));
+
+	WMI_LOGD("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
+		"rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
+		__func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
+		cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
+
 	return wmi_unified_cmd_send(wmi_handle, wmibuf, len,
 				   WMI_PDEV_GET_TPC_CMDID);
 }

+ 112 - 7
wmi/src/wmi_unified_tlv.c

@@ -10537,13 +10537,116 @@ send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
 	return QDF_STATUS_SUCCESS;
 }
 
+/**
+ * enum packet_power_tlv_flags: target defined
+ * packet power rate flags for TLV
+ * @WMI_TLV_FLAG_ONE_CHAIN: one chain
+ * @WMI_TLV_FLAG_TWO_CHAIN: two chain
+ * @WMI_TLV_FLAG_THREE_CHAIN: three chain
+ * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
+ * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
+ * @WMI_TLV_FLAG_SIX_CHAIN: six chain
+ * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
+ * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
+ * @WMI_TLV_FLAG_STBC: STBC is set
+ * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
+ * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
+ * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
+ * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
+ * @WMI_TLV_FLAG_RTSENA: RTS enabled
+ * @WMI_TLV_FLAG_CTSENA: CTS enabled
+ * @WMI_TLV_FLAG_LDPC: LDPC is set
+ * @WMI_TLV_FLAG_SGI: Short gaurd interval
+ * @WMI_TLV_FLAG_SU: SU Data
+ * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
+ * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
+ * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
+ * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
+ * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
+ *
+ * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
+ * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
+ * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
+ * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
+ */
+enum packet_power_tlv_flags {
+	WMI_TLV_FLAG_ONE_CHAIN         = 0x00000001,
+	WMI_TLV_FLAG_TWO_CHAIN         = 0x00000003,
+	WMI_TLV_FLAG_THREE_CHAIN       = 0x00000007,
+	WMI_TLV_FLAG_FOUR_CHAIN        = 0x0000000F,
+	WMI_TLV_FLAG_FIVE_CHAIN        = 0x0000001F,
+	WMI_TLV_FLAG_SIX_CHAIN         = 0x0000003F,
+	WMI_TLV_FLAG_SEVEN_CHAIN       = 0x0000007F,
+	WMI_TLV_FLAG_EIGHT_CHAIN       = 0x0000008F,
+	WMI_TLV_FLAG_STBC              = 0x00000100,
+	WMI_TLV_FLAG_40MHZ             = 0x00000200,
+	WMI_TLV_FLAG_80MHZ             = 0x00000300,
+	WMI_TLV_FLAG_160MHZ            = 0x00000400,
+	WMI_TLV_FLAG_TXBF              = 0x00000800,
+	WMI_TLV_FLAG_RTSENA            = 0x00001000,
+	WMI_TLV_FLAG_CTSENA            = 0x00002000,
+	WMI_TLV_FLAG_LDPC              = 0x00004000,
+	WMI_TLV_FLAG_SGI               = 0x00008000,
+	WMI_TLV_FLAG_SU                = 0x00100000,
+	WMI_TLV_FLAG_DL_MU_MIMO_AC     = 0x00200000,
+	WMI_TLV_FLAG_DL_MU_MIMO_AX     = 0x00300000,
+	WMI_TLV_FLAG_DL_OFDMA          = 0x00400000,
+	WMI_TLV_FLAG_UL_OFDMA          = 0x00500000,
+	WMI_TLV_FLAG_UL_MU_MIMO        = 0x00600000,
+
+	WMI_TLV_FLAG_CHAIN_MASK        = 0xff,
+	WMI_TLV_FLAG_BW_MASK           = 0x3,
+	WMI_TLV_FLAG_BW_SHIFT          = 9,
+	WMI_TLV_FLAG_SU_MU_OFDMA_MASK  = 0x7,
+	WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
+};
+
+/**
+ * convert_to_power_info_rate_flags() - convert packet_power_info_params
+ * to FW understandable format
+ * @param: pointer to hold packet power info param
+ *
+ * @return FW understandable 32 bit rate flags
+ */
+static uint32_t
+convert_to_power_info_rate_flags(struct packet_power_info_params *param)
+{
+	uint32_t rateflags = 0;
+
+	if (param->chainmask)
+		rateflags |=
+			(param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
+	if (param->chan_width)
+		rateflags |=
+			((param->chan_width & WMI_TLV_FLAG_BW_MASK)
+			 << WMI_TLV_FLAG_BW_SHIFT);
+	if (param->su_mu_ofdma)
+		rateflags |=
+			((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
+			 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
+	if (param->rate_flags & WMI_HOST_FLAG_STBC)
+		rateflags |= WMI_TLV_FLAG_STBC;
+	if (param->rate_flags & WMI_HOST_FLAG_LDPC)
+		rateflags |= WMI_TLV_FLAG_LDPC;
+	if (param->rate_flags & WMI_HOST_FLAG_TXBF)
+		rateflags |= WMI_TLV_FLAG_TXBF;
+	if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
+		rateflags |= WMI_TLV_FLAG_RTSENA;
+	if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
+		rateflags |= WMI_TLV_FLAG_CTSENA;
+	if (param->rate_flags & WMI_HOST_FLAG_SGI)
+		rateflags |= WMI_TLV_FLAG_SGI;
+
+	return rateflags;
+}
+
 /**
  * send_packet_power_info_get_cmd_tlv() - send request to get packet power
  * info to fw
  * @wmi_handle: wmi handle
  * @param: pointer to hold packet power info param
  *
- *  @return QDF_STATUS_SUCCESS  on success and -ve on failure.
+ * @return QDF_STATUS_SUCCESS  on success and -ve on failure.
  */
 static QDF_STATUS
 send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
@@ -10567,15 +10670,16 @@ send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
 				wmi_pdev_get_tpc_cmd_fixed_param));
 	cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
 								param->pdev_id);
-	cmd->rate_flags = param->rate_flags;
+	cmd->rate_flags = convert_to_power_info_rate_flags(param);
 	cmd->nss = param->nss;
 	cmd->preamble = param->preamble;
 	cmd->hw_rate = param->hw_rate;
-	WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
-		 __func__,
-		 __LINE__,
-		 WMI_PDEV_GET_TPC_CMDID,
-		 *((u_int32_t *)cmd));
+
+	WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
+		"rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
+		__func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
+		cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
+
 	if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
 				 WMI_PDEV_GET_TPC_CMDID)) {
 			WMI_LOGE(FL("Failed to get tpc command\n"));
@@ -19356,6 +19460,7 @@ static void populate_tlv_events_id(uint32_t *event_ids)
 		WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
 	event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
 	event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
+	event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
 }
 
 #ifndef CONFIG_MCL