Pārlūkot izejas kodu

qcacld-3.0: add ini support for throttling period duty cycles

qcacld-2.0 to qcacld-3.0 propagation

Provide support to configure duty cycle by adding ini item for
different level duty cycle.

CRs-Fixed: 990798
Change-Id: I95e4f4af669fd50c5b9fc10ffc61fa5d447b5bcf
Poddar, Siddarth 9 gadi atpakaļ
vecāks
revīzija
8390502e2e

+ 17 - 0
core/dp/ol/inc/ol_cfg.h

@@ -45,6 +45,12 @@ enum wlan_frm_fmt {
 	wlan_frm_fmt_802_3,
 };
 
+/* Throttle period Different level Duty Cycle values*/
+#define THROTTLE_DUTY_CYCLE_LEVEL0 (0)
+#define THROTTLE_DUTY_CYCLE_LEVEL1 (50)
+#define THROTTLE_DUTY_CYCLE_LEVEL2 (75)
+#define THROTTLE_DUTY_CYCLE_LEVEL3 (94)
+
 struct wlan_ipa_uc_rsc_t {
 	u8 uc_offload_enabled;
 	u32 tx_max_buf_cnt;
@@ -70,6 +76,7 @@ struct txrx_pdev_cfg_t {
 	u32 max_vdev;
 	u32 max_nbuf_frags;
 	u32 throttle_period_ms;
+	u8 dutycycle_level[4];
 	enum wlan_frm_fmt frame_type;
 	u8 rx_fwd_disabled;
 	u8 is_packet_log_enabled;
@@ -333,6 +340,16 @@ int ol_cfg_rx_host_defrag_timeout_duplicate_check(ol_pdev_handle pdev);
  */
 int ol_cfg_throttle_period_ms(ol_pdev_handle pdev);
 
+/**
+ * brief Query for the duty cycle in percentage used for throttling for
+ * thermal mitigation
+ *
+ * @param pdev - handle to the physical device
+ * @param level - duty cycle level
+ * @return the duty cycle level in percentage
+ */
+int ol_cfg_throttle_duty_cycle_level(ol_pdev_handle pdev, int level);
+
 /**
  * brief Check whether full reorder offload is
  * enabled/disable by the host

+ 10 - 0
core/dp/txrx/ol_cfg.c

@@ -114,6 +114,10 @@ ol_pdev_handle ol_pdev_cfg_attach(qdf_device_t osdev,
 	cfg_ctx->vow_config = vow_config;
 	cfg_ctx->target_tx_credit = CFG_TGT_NUM_MSDU_DESC;
 	cfg_ctx->throttle_period_ms = 40;
+	cfg_ctx->dutycycle_level[0] = THROTTLE_DUTY_CYCLE_LEVEL0;
+	cfg_ctx->dutycycle_level[1] = THROTTLE_DUTY_CYCLE_LEVEL1;
+	cfg_ctx->dutycycle_level[2] = THROTTLE_DUTY_CYCLE_LEVEL2;
+	cfg_ctx->dutycycle_level[3] = THROTTLE_DUTY_CYCLE_LEVEL3;
 	cfg_ctx->rx_fwd_disabled = 0;
 	cfg_ctx->is_packet_log_enabled = 0;
 	cfg_ctx->is_full_reorder_offload = cfg_param.is_full_reorder_offload;
@@ -274,6 +278,12 @@ int ol_cfg_throttle_period_ms(ol_pdev_handle pdev)
 	return cfg->throttle_period_ms;
 }
 
+int ol_cfg_throttle_duty_cycle_level(ol_pdev_handle pdev, int level)
+{
+	struct txrx_pdev_cfg_t *cfg = (struct txrx_pdev_cfg_t *)pdev;
+	return cfg->dutycycle_level[level];
+}
+
 int ol_cfg_is_full_reorder_offload(ol_pdev_handle pdev)
 {
 	struct txrx_pdev_cfg_t *cfg = (struct txrx_pdev_cfg_t *)pdev;

+ 12 - 10
core/dp/txrx/ol_tx_queue.c

@@ -413,13 +413,8 @@ void ol_tx_throttle_set_level(struct ol_txrx_pdev_t *pdev, int level)
 		qdf_timer_start(&pdev->tx_throttle.phase_timer, ms);
 }
 
-/* This table stores the duty cycle for each level.
-   Example "on" time for level 2 with duty period 100ms is:
-   "on" time = duty_period_ms >> throttle_duty_cycle_table[2]
-   "on" time = 100 ms >> 2 = 25ms */
-static uint8_t g_throttle_duty_cycle_table[THROTTLE_LEVEL_MAX] = { 0, 1, 2, 4 };
-
-void ol_tx_throttle_init_period(struct ol_txrx_pdev_t *pdev, int period)
+void ol_tx_throttle_init_period(struct ol_txrx_pdev_t *pdev, int period,
+				uint8_t *dutycycle_level)
 {
 	int i;
 
@@ -429,8 +424,9 @@ void ol_tx_throttle_init_period(struct ol_txrx_pdev_t *pdev, int period)
 	TXRX_PRINT(TXRX_PRINT_LEVEL_WARN, "level  OFF  ON\n");
 	for (i = 0; i < THROTTLE_LEVEL_MAX; i++) {
 		pdev->tx_throttle.throttle_time_ms[i][THROTTLE_PHASE_ON] =
-			pdev->tx_throttle.throttle_period_ms >>
-			g_throttle_duty_cycle_table[i];
+			pdev->tx_throttle.throttle_period_ms -
+				((dutycycle_level[i] *
+				  pdev->tx_throttle.throttle_period_ms)/100);
 		pdev->tx_throttle.throttle_time_ms[i][THROTTLE_PHASE_OFF] =
 			pdev->tx_throttle.throttle_period_ms -
 			pdev->tx_throttle.throttle_time_ms[
@@ -446,6 +442,8 @@ void ol_tx_throttle_init_period(struct ol_txrx_pdev_t *pdev, int period)
 void ol_tx_throttle_init(struct ol_txrx_pdev_t *pdev)
 {
 	uint32_t throttle_period;
+	uint8_t dutycycle_level[THROTTLE_LEVEL_MAX];
+	int i;
 
 	pdev->tx_throttle.current_throttle_level = THROTTLE_LEVEL_0;
 	pdev->tx_throttle.current_throttle_phase = THROTTLE_PHASE_OFF;
@@ -453,7 +451,11 @@ void ol_tx_throttle_init(struct ol_txrx_pdev_t *pdev)
 
 	throttle_period = ol_cfg_throttle_period_ms(pdev->ctrl_pdev);
 
-	ol_tx_throttle_init_period(pdev, throttle_period);
+	for (i = 0; i < THROTTLE_LEVEL_MAX; i++)
+		dutycycle_level[i] =
+			ol_cfg_throttle_duty_cycle_level(pdev->ctrl_pdev, i);
+
+	ol_tx_throttle_init_period(pdev, throttle_period, &dutycycle_level[0]);
 
 	qdf_timer_init(pdev->osdev,
 			       &pdev->tx_throttle.phase_timer,

+ 30 - 0
core/hdd/inc/wlan_hdd_cfg.h

@@ -1476,6 +1476,32 @@ typedef enum {
 #define CFG_THROTTLE_PERIOD_MAX                (10000)
 #define CFG_THROTTLE_PERIOD_DEFAULT            (4000)
 
+/*
+ * Configure Throttle Period Different Level Duty Cycle in percentage
+ * When temperature measured is greater than threshold at particular level,
+ * then throtling level will get increased by one level and
+ * will reduce TX duty by the given percentage
+ */
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL0_NAME    "gThrottleDutyCycleLevel0"
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL0_MIN     (0)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL0_MAX     (0)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL0_DEFAULT (0)
+
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL1_NAME    "gThrottleDutyCycleLevel1"
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL1_MIN     (0)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL1_MAX     (100)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL1_DEFAULT (50)
+
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL2_NAME    "gThrottleDutyCycleLevel2"
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL2_MIN     (0)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL2_MAX     (100)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL2_DEFAULT (75)
+
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL3_NAME    "gThrottleDutyCycleLevel3"
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL3_MIN     (0)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL3_MAX     (100)
+#define CFG_THROTTLE_DUTY_CYCLE_LEVEL3_DEFAULT (94)
+
 #define CFG_THERMAL_TEMP_MIN_LEVEL0_NAME      "gThermalTempMinLevel0"
 #define CFG_THERMAL_TEMP_MIN_LEVEL0_MIN       (0)
 #define CFG_THERMAL_TEMP_MIN_LEVEL0_MAX       (1000)
@@ -3231,6 +3257,10 @@ struct hdd_config {
 	bool isP2pDeviceAddrAdministrated;
 	uint8_t thermalMitigationEnable;
 	uint32_t throttlePeriod;
+	uint32_t throttle_dutycycle_level0;
+	uint32_t throttle_dutycycle_level1;
+	uint32_t throttle_dutycycle_level2;
+	uint32_t throttle_dutycycle_level3;
 	uint8_t vhtChannelWidth;
 	uint8_t vhtRxMCS;
 	uint8_t vhtTxMCS;

+ 28 - 0
core/hdd/src/wlan_hdd_cfg.c

@@ -1996,6 +1996,34 @@ REG_TABLE_ENTRY g_registry_table[] = {
 		     CFG_THROTTLE_PERIOD_MIN,
 		     CFG_THROTTLE_PERIOD_MAX),
 
+	REG_VARIABLE(CFG_THROTTLE_DUTY_CYCLE_LEVEL0_NAME, WLAN_PARAM_Integer,
+		     struct hdd_config, throttle_dutycycle_level0,
+		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL0_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL0_MIN,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL0_MAX),
+
+	REG_VARIABLE(CFG_THROTTLE_DUTY_CYCLE_LEVEL1_NAME, WLAN_PARAM_Integer,
+		     struct hdd_config, throttle_dutycycle_level1,
+		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL1_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL1_MIN,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL1_MAX),
+
+	REG_VARIABLE(CFG_THROTTLE_DUTY_CYCLE_LEVEL2_NAME, WLAN_PARAM_Integer,
+		     struct hdd_config, throttle_dutycycle_level2,
+		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL2_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL2_MIN,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL2_MAX),
+
+	REG_VARIABLE(CFG_THROTTLE_DUTY_CYCLE_LEVEL3_NAME, WLAN_PARAM_Integer,
+		     struct hdd_config, throttle_dutycycle_level3,
+		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL3_DEFAULT,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL3_MIN,
+		     CFG_THROTTLE_DUTY_CYCLE_LEVEL3_MAX),
+
 	REG_VARIABLE(CFG_ENABLE_MODULATED_DTIM_NAME, WLAN_PARAM_Integer,
 		     struct hdd_config, enableModulatedDTIM,
 		     VAR_FLAGS_OPTIONAL | VAR_FLAGS_RANGE_CHECK_ASSUME_DEFAULT,

+ 9 - 0
core/hdd/src/wlan_hdd_main.c

@@ -5508,6 +5508,15 @@ static int hdd_init_thermal_info(hdd_context_t *hdd_ctx)
 		hdd_ctx->config->thermalMitigationEnable;
 	thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod;
 
+	thermal_param.sme_throttle_duty_cycle_tbl[0] =
+		hdd_ctx->config->throttle_dutycycle_level0;
+	thermal_param.sme_throttle_duty_cycle_tbl[1] =
+		hdd_ctx->config->throttle_dutycycle_level1;
+	thermal_param.sme_throttle_duty_cycle_tbl[2] =
+		hdd_ctx->config->throttle_dutycycle_level2;
+	thermal_param.sme_throttle_duty_cycle_tbl[3] =
+		hdd_ctx->config->throttle_dutycycle_level3;
+
 	thermal_param.smeThermalLevels[0].smeMinTempThreshold =
 		hdd_ctx->config->thermalTempMinLevel0;
 	thermal_param.smeThermalLevels[0].smeMaxTempThreshold =

+ 3 - 0
core/mac/inc/sir_api.h

@@ -3963,12 +3963,15 @@ typedef enum {
 	WLAN_WMA_MAX_THERMAL_LEVELS
 } t_thermal_level;
 
+#define WLAN_THROTTLE_DUTY_CYCLE_LEVEL_MAX (4)
+
 typedef struct {
 	/* Array of thermal levels */
 	t_thermal_level_info thermalLevels[WLAN_WMA_MAX_THERMAL_LEVELS];
 	uint8_t thermalCurrLevel;
 	uint8_t thermalMgmtEnabled;
 	uint32_t throttlePeriod;
+	uint8_t throttle_duty_cycle_tbl[WLAN_THROTTLE_DUTY_CYCLE_LEVEL_MAX];
 } t_thermal_mgmt, *tp_thermal_mgmt;
 
 typedef struct sSirTxPowerLimit {

+ 3 - 0
core/sme/inc/sme_api.h

@@ -159,11 +159,14 @@ typedef struct {
 } tSmeThermalLevelInfo;
 
 #define SME_MAX_THERMAL_LEVELS (4)
+#define SME_MAX_THROTTLE_LEVELS (4)
+
 typedef struct {
 	/* Array of thermal levels */
 	tSmeThermalLevelInfo smeThermalLevels[SME_MAX_THERMAL_LEVELS];
 	uint8_t smeThermalMgmtEnabled;
 	uint32_t smeThrottlePeriod;
+	uint8_t sme_throttle_duty_cycle_tbl[SME_MAX_THROTTLE_LEVELS];
 } tSmeThermalParams;
 
 typedef enum {

+ 10 - 0
core/sme/src/common/sme_api.c

@@ -12421,6 +12421,16 @@ QDF_STATUS sme_init_thermal_info(tHalHandle hHal, tSmeThermalParams thermalParam
 
 	pWmaParam->thermalMgmtEnabled = thermalParam.smeThermalMgmtEnabled;
 	pWmaParam->throttlePeriod = thermalParam.smeThrottlePeriod;
+
+	pWmaParam->throttle_duty_cycle_tbl[0] =
+		thermalParam.sme_throttle_duty_cycle_tbl[0];
+	pWmaParam->throttle_duty_cycle_tbl[1] =
+		thermalParam.sme_throttle_duty_cycle_tbl[1];
+	pWmaParam->throttle_duty_cycle_tbl[2] =
+		thermalParam.sme_throttle_duty_cycle_tbl[2];
+	pWmaParam->throttle_duty_cycle_tbl[3] =
+		thermalParam.sme_throttle_duty_cycle_tbl[3];
+
 	pWmaParam->thermalLevels[0].minTempThreshold =
 		thermalParam.smeThermalLevels[0].smeMinTempThreshold;
 	pWmaParam->thermalLevels[0].maxTempThreshold =

+ 12 - 1
core/wma/src/wma_data.c

@@ -1684,6 +1684,16 @@ QDF_STATUS wma_process_init_thermal_info(tp_wma_handle wma,
 	WMA_LOGD("TM enable %d period %d", pThermalParams->thermalMgmtEnabled,
 		 pThermalParams->throttlePeriod);
 
+	WMA_LOGD("Throttle Duty Cycle Level in percentage:\n"
+		 "0 %d\n"
+		 "1 %d\n"
+		 "2 %d\n"
+		 "3 %d",
+		 pThermalParams->throttle_duty_cycle_tbl[0],
+		 pThermalParams->throttle_duty_cycle_tbl[1],
+		 pThermalParams->throttle_duty_cycle_tbl[2],
+		 pThermalParams->throttle_duty_cycle_tbl[3]);
+
 	wma->thermal_mgmt_info.thermalMgmtEnabled =
 		pThermalParams->thermalMgmtEnabled;
 	wma->thermal_mgmt_info.thermalLevels[0].minTempThreshold =
@@ -1720,7 +1730,8 @@ QDF_STATUS wma_process_init_thermal_info(tp_wma_handle wma,
 
 	if (wma->thermal_mgmt_info.thermalMgmtEnabled) {
 		ol_tx_throttle_init_period(curr_pdev,
-					   pThermalParams->throttlePeriod);
+				pThermalParams->throttlePeriod,
+				&pThermalParams->throttle_duty_cycle_tbl[0]);
 
 		/* Get the temperature thresholds to set in firmware */
 		thermal_params.minTemp =