aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h16
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c94
4 files changed, 45 insertions, 74 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 75ef8d87c18e..9dc6e3cc247e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -1076,7 +1076,6 @@ struct iwl_priv {
1076 struct iwl3945_rxon_cmd staging39_rxon; 1076 struct iwl3945_rxon_cmd staging39_rxon;
1077 struct iwl3945_rxon_cmd recovery39_rxon; 1077 struct iwl3945_rxon_cmd recovery39_rxon;
1078 1078
1079 struct iwl3945_power_mgr power_data_39;
1080 struct iwl3945_notif_statistics statistics_39; 1079 struct iwl3945_notif_statistics statistics_39;
1081 1080
1082 struct iwl3945_station_entry stations_39[IWL_STATION_COUNT]; 1081 struct iwl3945_station_entry stations_39[IWL_STATION_COUNT];
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 0276d51d37ce..a4634595c59f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -60,14 +60,6 @@
60#define IWL_POWER_RANGE_1_MAX (10) 60#define IWL_POWER_RANGE_1_MAX (10)
61 61
62 62
63#define NOSLP __constant_cpu_to_le16(0), 0, 0
64#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
65#define SLP_TOUT(T) __constant_cpu_to_le32((T) * MSEC_TO_USEC)
66#define SLP_VEC(X0, X1, X2, X3, X4) {__constant_cpu_to_le32(X0), \
67 __constant_cpu_to_le32(X1), \
68 __constant_cpu_to_le32(X2), \
69 __constant_cpu_to_le32(X3), \
70 __constant_cpu_to_le32(X4)}
71 63
72#define IWL_POWER_ON_BATTERY IWL_POWER_INDEX_5 64#define IWL_POWER_ON_BATTERY IWL_POWER_INDEX_5
73#define IWL_POWER_ON_AC_DISASSOC IWL_POWER_MODE_CAM 65#define IWL_POWER_ON_AC_DISASSOC IWL_POWER_MODE_CAM
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index 476c2aa2bf75..859b60b5335c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -66,6 +66,14 @@ enum {
66 66
67/* Power management (not Tx power) structures */ 67/* Power management (not Tx power) structures */
68 68
69#define NOSLP __constant_cpu_to_le16(0), 0, 0
70#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
71#define SLP_TOUT(T) __constant_cpu_to_le32((T) * MSEC_TO_USEC)
72#define SLP_VEC(X0, X1, X2, X3, X4) {__constant_cpu_to_le32(X0), \
73 __constant_cpu_to_le32(X1), \
74 __constant_cpu_to_le32(X2), \
75 __constant_cpu_to_le32(X3), \
76 __constant_cpu_to_le32(X4)}
69struct iwl_power_vec_entry { 77struct iwl_power_vec_entry {
70 struct iwl_powertable_cmd cmd; 78 struct iwl_powertable_cmd cmd;
71 u8 no_dtim; 79 u8 no_dtim;
@@ -86,14 +94,6 @@ struct iwl_power_mgr {
86 u8 power_disabled; /* flag to disable using power saving level */ 94 u8 power_disabled; /* flag to disable using power saving level */
87}; 95};
88 96
89struct iwl3945_power_mgr {
90 spinlock_t lock;
91 struct iwl_power_vec_entry pwr_range_0[IWL_POWER_AC];
92 struct iwl_power_vec_entry pwr_range_1[IWL_POWER_AC];
93 u8 active_index;
94 u32 dtim_val;
95};
96
97void iwl_setup_power_deferred_work(struct iwl_priv *priv); 97void iwl_setup_power_deferred_work(struct iwl_priv *priv);
98void iwl_power_cancel_timeout(struct iwl_priv *priv); 98void iwl_power_cancel_timeout(struct iwl_priv *priv);
99int iwl_power_update_mode(struct iwl_priv *priv, bool force); 99int iwl_power_update_mode(struct iwl_priv *priv, bool force);
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 0301df581487..c9f6f8e86440 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -1324,55 +1324,41 @@ static void iwl3945_activate_qos(struct iwl_priv *priv, u8 force)
1324#define MSEC_TO_USEC 1024 1324#define MSEC_TO_USEC 1024
1325 1325
1326 1326
1327#define NOSLP __constant_cpu_to_le16(0), 0, 0
1328#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
1329#define SLP_TIMEOUT(T) __constant_cpu_to_le32((T) * MSEC_TO_USEC)
1330#define SLP_VEC(X0, X1, X2, X3, X4) {__constant_cpu_to_le32(X0), \
1331 __constant_cpu_to_le32(X1), \
1332 __constant_cpu_to_le32(X2), \
1333 __constant_cpu_to_le32(X3), \
1334 __constant_cpu_to_le32(X4)}
1335
1336/* default power management (not Tx power) table values */ 1327/* default power management (not Tx power) table values */
1337/* for TIM 0-10 */ 1328/* for TIM 0-10 */
1338static struct iwl_power_vec_entry range_0[IWL39_POWER_AC] = { 1329static struct iwl_power_vec_entry range_0[IWL_POWER_MAX] = {
1339 {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 1330 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
1340 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, 1331 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
1341 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(300), SLP_VEC(2, 4, 6, 7, 7)}, 0}, 1332 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 7)}, 0},
1342 {{SLP, SLP_TIMEOUT(50), SLP_TIMEOUT(100), SLP_VEC(2, 6, 9, 9, 10)}, 0}, 1333 {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 6, 9, 9, 10)}, 0},
1343 {{SLP, SLP_TIMEOUT(50), SLP_TIMEOUT(25), SLP_VEC(2, 7, 9, 9, 10)}, 1}, 1334 {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 10)}, 1},
1344 {{SLP, SLP_TIMEOUT(25), SLP_TIMEOUT(25), SLP_VEC(4, 7, 10, 10, 10)}, 1} 1335 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 10)}, 1}
1345}; 1336};
1346 1337
1347/* for TIM > 10 */ 1338/* for TIM > 10 */
1348static struct iwl_power_vec_entry range_1[IWL39_POWER_AC] = { 1339static struct iwl_power_vec_entry range_1[IWL_POWER_MAX] = {
1349 {{NOSLP, SLP_TIMEOUT(0), SLP_TIMEOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, 1340 {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0},
1350 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(500), 1341 {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
1351 SLP_VEC(1, 2, 3, 4, 0xFF)}, 0}, 1342 {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0},
1352 {{SLP, SLP_TIMEOUT(200), SLP_TIMEOUT(300), 1343 {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 6, 9, 9, 0xFF)}, 0},
1353 SLP_VEC(2, 4, 6, 7, 0xFF)}, 0}, 1344 {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0},
1354 {{SLP, SLP_TIMEOUT(50), SLP_TIMEOUT(100), 1345 {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0}
1355 SLP_VEC(2, 6, 9, 9, 0xFF)}, 0},
1356 {{SLP, SLP_TIMEOUT(50), SLP_TIMEOUT(25), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0},
1357 {{SLP, SLP_TIMEOUT(25), SLP_TIMEOUT(25),
1358 SLP_VEC(4, 7, 10, 10, 0xFF)}, 0}
1359}; 1346};
1360 1347
1361int iwl3945_power_init_handle(struct iwl_priv *priv) 1348int iwl3945_power_init_handle(struct iwl_priv *priv)
1362{ 1349{
1363 int rc = 0, i; 1350 int rc = 0, i;
1364 struct iwl3945_power_mgr *pow_data; 1351 struct iwl_power_mgr *pow_data;
1365 int size = sizeof(struct iwl_power_vec_entry) * IWL39_POWER_AC; 1352 int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_MAX;
1366 u16 pci_pm; 1353 u16 pci_pm;
1367 1354
1368 IWL_DEBUG_POWER("Initialize power \n"); 1355 IWL_DEBUG_POWER("Initialize power \n");
1369 1356
1370 pow_data = &(priv->power_data_39); 1357 pow_data = &priv->power_data;
1371 1358
1372 memset(pow_data, 0, sizeof(*pow_data)); 1359 memset(pow_data, 0, sizeof(*pow_data));
1373 1360
1374 pow_data->active_index = IWL_POWER_RANGE_0; 1361 pow_data->dtim_period = 1;
1375 pow_data->dtim_val = 0xffff;
1376 1362
1377 memcpy(&pow_data->pwr_range_0[0], &range_0[0], size); 1363 memcpy(&pow_data->pwr_range_0[0], &range_0[0], size);
1378 memcpy(&pow_data->pwr_range_1[0], &range_1[0], size); 1364 memcpy(&pow_data->pwr_range_1[0], &range_1[0], size);
@@ -1385,7 +1371,7 @@ int iwl3945_power_init_handle(struct iwl_priv *priv)
1385 1371
1386 IWL_DEBUG_POWER("adjust power command flags\n"); 1372 IWL_DEBUG_POWER("adjust power command flags\n");
1387 1373
1388 for (i = 0; i < IWL39_POWER_AC; i++) { 1374 for (i = 0; i < IWL_POWER_MAX; i++) {
1389 cmd = &pow_data->pwr_range_0[i].cmd; 1375 cmd = &pow_data->pwr_range_0[i].cmd;
1390 1376
1391 if (pci_pm & 0x1) 1377 if (pci_pm & 0x1)
@@ -1400,53 +1386,46 @@ int iwl3945_power_init_handle(struct iwl_priv *priv)
1400static int iwl3945_update_power_cmd(struct iwl_priv *priv, 1386static int iwl3945_update_power_cmd(struct iwl_priv *priv,
1401 struct iwl_powertable_cmd *cmd, u32 mode) 1387 struct iwl_powertable_cmd *cmd, u32 mode)
1402{ 1388{
1403 int rc = 0, i; 1389 struct iwl_power_mgr *pow_data;
1404 u8 skip;
1405 u32 max_sleep = 0;
1406 struct iwl_power_vec_entry *range; 1390 struct iwl_power_vec_entry *range;
1391 u32 max_sleep = 0;
1392 int i;
1407 u8 period = 0; 1393 u8 period = 0;
1408 struct iwl3945_power_mgr *pow_data; 1394 bool skip;
1409 1395
1410 if (mode > IWL_POWER_INDEX_5) { 1396 if (mode > IWL_POWER_INDEX_5) {
1411 IWL_DEBUG_POWER("Error invalid power mode \n"); 1397 IWL_DEBUG_POWER("Error invalid power mode \n");
1412 return -1; 1398 return -EINVAL;
1413 } 1399 }
1414 pow_data = &(priv->power_data_39); 1400 pow_data = &priv->power_data;
1415 1401
1416 if (pow_data->active_index == IWL_POWER_RANGE_0) 1402 if (pow_data->dtim_period < 10)
1417 range = &pow_data->pwr_range_0[0]; 1403 range = &pow_data->pwr_range_0[0];
1418 else 1404 else
1419 range = &pow_data->pwr_range_1[1]; 1405 range = &pow_data->pwr_range_1[1];
1420 1406
1421 memcpy(cmd, &range[mode].cmd, sizeof(struct iwl3945_powertable_cmd)); 1407 memcpy(cmd, &range[mode].cmd, sizeof(struct iwl3945_powertable_cmd));
1422 1408
1423#ifdef IWL_MAC80211_DISABLE
1424 if (priv->assoc_network != NULL) {
1425 unsigned long flags;
1426
1427 period = priv->assoc_network->tim.tim_period;
1428 }
1429#endif /*IWL_MAC80211_DISABLE */
1430 skip = range[mode].no_dtim;
1431 1409
1432 if (period == 0) { 1410 if (period == 0) {
1433 period = 1; 1411 period = 1;
1434 skip = 0; 1412 skip = false;
1413 } else {
1414 skip = !!range[mode].no_dtim;
1435 } 1415 }
1436 1416
1437 if (skip == 0) { 1417 if (skip) {
1438 max_sleep = period;
1439 cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
1440 } else {
1441 __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]; 1418 __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1];
1442 max_sleep = (le32_to_cpu(slp_itrvl) / period) * period; 1419 max_sleep = (le32_to_cpu(slp_itrvl) / period) * period;
1443 cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK; 1420 cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK;
1421 } else {
1422 max_sleep = period;
1423 cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
1444 } 1424 }
1445 1425
1446 for (i = 0; i < IWL_POWER_VEC_SIZE; i++) { 1426 for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
1447 if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) 1427 if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep)
1448 cmd->sleep_interval[i] = cpu_to_le32(max_sleep); 1428 cmd->sleep_interval[i] = cpu_to_le32(max_sleep);
1449 }
1450 1429
1451 IWL_DEBUG_POWER("Flags value = 0x%08X\n", cmd->flags); 1430 IWL_DEBUG_POWER("Flags value = 0x%08X\n", cmd->flags);
1452 IWL_DEBUG_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); 1431 IWL_DEBUG_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout));
@@ -1458,7 +1437,7 @@ static int iwl3945_update_power_cmd(struct iwl_priv *priv,
1458 le32_to_cpu(cmd->sleep_interval[3]), 1437 le32_to_cpu(cmd->sleep_interval[3]),
1459 le32_to_cpu(cmd->sleep_interval[4])); 1438 le32_to_cpu(cmd->sleep_interval[4]));
1460 1439
1461 return rc; 1440 return 0;
1462} 1441}
1463 1442
1464static int iwl3945_send_power_mode(struct iwl_priv *priv, u32 mode) 1443static int iwl3945_send_power_mode(struct iwl_priv *priv, u32 mode)
@@ -6086,6 +6065,7 @@ static void iwl3945_bss_info_changed(struct ieee80211_hw *hw,
6086 priv->beacon_int = bss_conf->beacon_int; 6065 priv->beacon_int = bss_conf->beacon_int;
6087 priv->timestamp = bss_conf->timestamp; 6066 priv->timestamp = bss_conf->timestamp;
6088 priv->assoc_capability = bss_conf->assoc_capability; 6067 priv->assoc_capability = bss_conf->assoc_capability;
6068 priv->power_data.dtim_period = bss_conf->dtim_period;
6089 priv->next_scan_jiffies = jiffies + 6069 priv->next_scan_jiffies = jiffies +
6090 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC; 6070 IWL_DELAY_NEXT_SCAN_AFTER_ASSOC;
6091 mutex_lock(&priv->mutex); 6071 mutex_lock(&priv->mutex);
@@ -6947,7 +6927,7 @@ static int iwl3945_init_drv(struct iwl_priv *priv)
6947 priv->ibss_beacon = NULL; 6927 priv->ibss_beacon = NULL;
6948 6928
6949 spin_lock_init(&priv->lock); 6929 spin_lock_init(&priv->lock);
6950 spin_lock_init(&priv->power_data_39.lock); 6930 spin_lock_init(&priv->power_data.lock);
6951 spin_lock_init(&priv->sta_lock); 6931 spin_lock_init(&priv->sta_lock);
6952 spin_lock_init(&priv->hcmd_lock); 6932 spin_lock_init(&priv->hcmd_lock);
6953 6933