aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ar9170
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@web.de>2009-06-01 15:42:01 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-03 14:05:12 -0400
commit29ceff5d58afbb2c98bb748057788f02b8db20e5 (patch)
tree1e31eb16449a70b8d41f2e3a1806db27cb383d33 /drivers/net/wireless/ath/ar9170
parentd7433390e49152101c1b31c08e38caf2a05a1169 (diff)
ar9170: introduce functions for MAC programming
This patch introduces 3 new function which are used to update the MAC state, whenever needed... e.g: after a band switch. Signed-off-by: Christian Lamparter <chunkeey@web.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ar9170')
-rw-r--r--drivers/net/wireless/ath/ar9170/ar9170.h3
-rw-r--r--drivers/net/wireless/ath/ar9170/mac.c49
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c58
3 files changed, 81 insertions, 29 deletions
diff --git a/drivers/net/wireless/ath/ar9170/ar9170.h b/drivers/net/wireless/ath/ar9170/ar9170.h
index 17bd3eaf3e03..77dc64710273 100644
--- a/drivers/net/wireless/ath/ar9170/ar9170.h
+++ b/drivers/net/wireless/ath/ar9170/ar9170.h
@@ -215,6 +215,9 @@ int ar9170_update_multicast(struct ar9170 *ar);
215int ar9170_update_frame_filter(struct ar9170 *ar); 215int ar9170_update_frame_filter(struct ar9170 *ar);
216int ar9170_set_operating_mode(struct ar9170 *ar); 216int ar9170_set_operating_mode(struct ar9170 *ar);
217int ar9170_set_beacon_timers(struct ar9170 *ar); 217int ar9170_set_beacon_timers(struct ar9170 *ar);
218int ar9170_set_dyn_sifs_ack(struct ar9170 *ar);
219int ar9170_set_slot_time(struct ar9170 *ar);
220int ar9170_set_basic_rates(struct ar9170 *ar);
218int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry); 221int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
219int ar9170_update_beacon(struct ar9170 *ar); 222int ar9170_update_beacon(struct ar9170 *ar);
220void ar9170_new_beacon(struct work_struct *work); 223void ar9170_new_beacon(struct work_struct *work);
diff --git a/drivers/net/wireless/ath/ar9170/mac.c b/drivers/net/wireless/ath/ar9170/mac.c
index 706262fb0924..d9f1f46de183 100644
--- a/drivers/net/wireless/ath/ar9170/mac.c
+++ b/drivers/net/wireless/ath/ar9170/mac.c
@@ -38,6 +38,55 @@
38#include "ar9170.h" 38#include "ar9170.h"
39#include "cmd.h" 39#include "cmd.h"
40 40
41int ar9170_set_dyn_sifs_ack(struct ar9170 *ar)
42{
43 u32 val;
44
45 if (conf_is_ht40(&ar->hw->conf))
46 val = 0x010a;
47 else {
48 if (ar->hw->conf.channel->band == IEEE80211_BAND_2GHZ)
49 val = 0x105;
50 else
51 val = 0x104;
52 }
53
54 return ar9170_write_reg(ar, AR9170_MAC_REG_DYNAMIC_SIFS_ACK, val);
55}
56
57int ar9170_set_slot_time(struct ar9170 *ar)
58{
59 u32 slottime = 20;
60
61 if (!ar->vif)
62 return 0;
63
64 if ((ar->hw->conf.channel->band == IEEE80211_BAND_5GHZ) ||
65 ar->vif->bss_conf.use_short_slot)
66 slottime = 9;
67
68 return ar9170_write_reg(ar, AR9170_MAC_REG_SLOT_TIME, slottime << 10);
69}
70
71int ar9170_set_basic_rates(struct ar9170 *ar)
72{
73 u8 cck, ofdm;
74
75 if (!ar->vif)
76 return 0;
77
78 ofdm = ar->vif->bss_conf.basic_rates >> 4;
79
80 /* FIXME: is still necessary? */
81 if (ar->hw->conf.channel->band == IEEE80211_BAND_5GHZ)
82 cck = 0;
83 else
84 cck = ar->vif->bss_conf.basic_rates & 0xf;
85
86 return ar9170_write_reg(ar, AR9170_MAC_REG_BASIC_RATE,
87 ofdm << 8 | cck);
88}
89
41int ar9170_set_qos(struct ar9170 *ar) 90int ar9170_set_qos(struct ar9170 *ar)
42{ 91{
43 ar9170_regwrite_begin(ar); 92 ar9170_regwrite_begin(ar);
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 99df9ddae9cb..c54c42e5391f 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -1344,15 +1344,21 @@ static int ar9170_op_config(struct ieee80211_hw *hw, u32 changed)
1344 } 1344 }
1345 1345
1346 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { 1346 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
1347
1348 /* adjust slot time for 5 GHz */
1349 err = ar9170_set_slot_time(ar);
1350 if (err)
1351 goto out;
1352
1353 err = ar9170_set_dyn_sifs_ack(ar);
1354 if (err)
1355 goto out;
1356
1347 err = ar9170_set_channel(ar, hw->conf.channel, 1357 err = ar9170_set_channel(ar, hw->conf.channel,
1348 AR9170_RFI_NONE, 1358 AR9170_RFI_NONE,
1349 nl80211_to_ar9170(hw->conf.channel_type)); 1359 nl80211_to_ar9170(hw->conf.channel_type));
1350 if (err) 1360 if (err)
1351 goto out; 1361 goto out;
1352 /* adjust slot time for 5 GHz */
1353 if (hw->conf.channel->band == IEEE80211_BAND_5GHZ)
1354 err = ar9170_write_reg(ar, AR9170_MAC_REG_SLOT_TIME,
1355 9 << 10);
1356 } 1362 }
1357 1363
1358out: 1364out:
@@ -1464,15 +1470,19 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
1464 if (changed & BSS_CHANGED_BSSID) { 1470 if (changed & BSS_CHANGED_BSSID) {
1465 memcpy(ar->bssid, bss_conf->bssid, ETH_ALEN); 1471 memcpy(ar->bssid, bss_conf->bssid, ETH_ALEN);
1466 err = ar9170_set_operating_mode(ar); 1472 err = ar9170_set_operating_mode(ar);
1473 if (err)
1474 goto out;
1467 } 1475 }
1468 1476
1469 if (changed & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED)) { 1477 if (changed & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED)) {
1470 err = ar9170_update_beacon(ar); 1478 err = ar9170_update_beacon(ar);
1471 if (!err) 1479 if (err)
1472 ar9170_set_beacon_timers(ar); 1480 goto out;
1473 }
1474 1481
1475 ar9170_regwrite_begin(ar); 1482 err = ar9170_set_beacon_timers(ar);
1483 if (err)
1484 goto out;
1485 }
1476 1486
1477 if (changed & BSS_CHANGED_ASSOC) { 1487 if (changed & BSS_CHANGED_ASSOC) {
1478 ar->state = bss_conf->assoc ? AR9170_ASSOCIATED : ar->state; 1488 ar->state = bss_conf->assoc ? AR9170_ASSOCIATED : ar->state;
@@ -1483,8 +1493,11 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
1483#endif /* CONFIG_AR9170_LEDS */ 1493#endif /* CONFIG_AR9170_LEDS */
1484 } 1494 }
1485 1495
1486 if (changed & BSS_CHANGED_BEACON_INT) 1496 if (changed & BSS_CHANGED_BEACON_INT) {
1487 err = ar9170_set_beacon_timers(ar); 1497 err = ar9170_set_beacon_timers(ar);
1498 if (err)
1499 goto out;
1500 }
1488 1501
1489 if (changed & BSS_CHANGED_HT) { 1502 if (changed & BSS_CHANGED_HT) {
1490 /* TODO */ 1503 /* TODO */
@@ -1492,31 +1505,18 @@ static void ar9170_op_bss_info_changed(struct ieee80211_hw *hw,
1492 } 1505 }
1493 1506
1494 if (changed & BSS_CHANGED_ERP_SLOT) { 1507 if (changed & BSS_CHANGED_ERP_SLOT) {
1495 u32 slottime = 20; 1508 err = ar9170_set_slot_time(ar);
1496 1509 if (err)
1497 if (bss_conf->use_short_slot) 1510 goto out;
1498 slottime = 9;
1499
1500 ar9170_regwrite(AR9170_MAC_REG_SLOT_TIME, slottime << 10);
1501 } 1511 }
1502 1512
1503 if (changed & BSS_CHANGED_BASIC_RATES) { 1513 if (changed & BSS_CHANGED_BASIC_RATES) {
1504 u32 cck, ofdm; 1514 err = ar9170_set_basic_rates(ar);
1505 1515 if (err)
1506 if (hw->conf.channel->band == IEEE80211_BAND_5GHZ) { 1516 goto out;
1507 ofdm = bss_conf->basic_rates;
1508 cck = 0;
1509 } else {
1510 /* four cck rates */
1511 cck = bss_conf->basic_rates & 0xf;
1512 ofdm = bss_conf->basic_rates >> 4;
1513 }
1514 ar9170_regwrite(AR9170_MAC_REG_BASIC_RATE,
1515 ofdm << 8 | cck);
1516 } 1517 }
1517 1518
1518 ar9170_regwrite_finish(); 1519out:
1519 err = ar9170_regwrite_result();
1520 mutex_unlock(&ar->mutex); 1520 mutex_unlock(&ar->mutex);
1521} 1521}
1522 1522