aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/p54
diff options
context:
space:
mode:
authorChristian Lamparter <chunkeey@web.de>2008-10-18 17:18:01 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-11-10 15:10:16 -0500
commit9e7f3f8e4acdc480584d6b5e6a6be5d1f7bda8fa (patch)
tree433f71d1213a487a1550b0c8924094d87624e9a0 /drivers/net/wireless/p54
parent9a8675d712d57da0993ad2e43b168c9585892097 (diff)
p54: more definitions form lmac_longbow.h and pda.h
This patch ports more useful features to p54 - PDR definitions for the synth chips & regulatory domain. - honour IEEE80211_TX_CTL_ASSIGN_SEQ flag, if it's set. - adds some lost mutex_lock & mutex_unlock. - replace two more "magic values" that sneaked past. Signed-off-by: Christian Lamparter <chunkeey@web.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/p54')
-rw-r--r--drivers/net/wireless/p54/p54common.c83
-rw-r--r--drivers/net/wireless/p54/p54common.h31
2 files changed, 82 insertions, 32 deletions
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index 8e5e1abfe88e..ae8d1f666314 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -221,10 +221,10 @@ int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
221 221
222 if (priv->fw_var >= 0x300) { 222 if (priv->fw_var >= 0x300) {
223 /* Firmware supports QoS, use it! */ 223 /* Firmware supports QoS, use it! */
224 priv->tx_stats[4].limit = 3; 224 priv->tx_stats[4].limit = 3; /* AC_VO */
225 priv->tx_stats[5].limit = 4; 225 priv->tx_stats[5].limit = 4; /* AC_VI */
226 priv->tx_stats[6].limit = 3; 226 priv->tx_stats[6].limit = 3; /* AC_BE */
227 priv->tx_stats[7].limit = 1; 227 priv->tx_stats[7].limit = 2; /* AC_BK */
228 dev->queues = 4; 228 dev->queues = 4;
229 } 229 }
230 230
@@ -436,12 +436,12 @@ static int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
436 goto err; 436 goto err;
437 } 437 }
438 438
439 priv->rxhw = synth & 0x07; 439 priv->rxhw = synth & PDR_SYNTH_FRONTEND_MASK;
440 if (priv->rxhw == 4) 440 if (priv->rxhw == 4)
441 p54_init_xbow_synth(dev); 441 p54_init_xbow_synth(dev);
442 if (!(synth & 0x40)) 442 if (!(synth & PDR_SYNTH_24_GHZ_DISABLED))
443 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; 443 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz;
444 if (!(synth & 0x80)) 444 if (!(synth & PDR_SYNTH_5_GHZ_DISABLED))
445 dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz; 445 dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz;
446 446
447 if (!is_valid_ether_addr(dev->wiphy->perm_addr)) { 447 if (!is_valid_ether_addr(dev->wiphy->perm_addr)) {
@@ -659,7 +659,7 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
659 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && 659 if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) &&
660 (!payload->status)) 660 (!payload->status))
661 info->flags |= IEEE80211_TX_STAT_ACK; 661 info->flags |= IEEE80211_TX_STAT_ACK;
662 if (payload->status & 0x02) 662 if (payload->status & P54_TX_PSM_CANCELLED)
663 info->flags |= IEEE80211_TX_STAT_TX_FILTERED; 663 info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
664 info->status.ack_signal = p54_rssi_to_dbm(dev, 664 info->status.ack_signal = p54_rssi_to_dbm(dev,
665 (int)payload->ack_rssi); 665 (int)payload->ack_rssi);
@@ -739,9 +739,9 @@ static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb)
739/* returns zero if skb can be reused */ 739/* returns zero if skb can be reused */
740int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb) 740int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
741{ 741{
742 u8 type = le16_to_cpu(*((__le16 *)skb->data)) >> 8; 742 u16 type = le16_to_cpu(*((__le16 *)skb->data));
743 743
744 if (type == 0x80) 744 if (type & P54_HDR_FLAG_CONTROL)
745 return p54_rx_control(dev, skb); 745 return p54_rx_control(dev, skb);
746 else 746 else
747 return p54_rx_data(dev, skb); 747 return p54_rx_data(dev, skb);
@@ -905,12 +905,13 @@ EXPORT_SYMBOL_GPL(p54_read_eeprom);
905static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb) 905static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
906{ 906{
907 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 907 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
908 struct ieee80211_tx_queue_stats *current_queue; 908 struct ieee80211_tx_queue_stats *current_queue = NULL;
909 struct p54_common *priv = dev->priv; 909 struct p54_common *priv = dev->priv;
910 struct p54_hdr *hdr; 910 struct p54_hdr *hdr;
911 struct p54_tx_data *txhdr; 911 struct p54_tx_data *txhdr;
912 size_t padding, len; 912 size_t padding, len;
913 int i, j, ridx; 913 int i, j, ridx;
914 u16 hdr_flags = 0;
914 u8 rate; 915 u8 rate;
915 u8 cts_rate = 0x20; 916 u8 cts_rate = 0x20;
916 u8 rc_flags; 917 u8 rc_flags;
@@ -932,9 +933,7 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
932 hdr = (struct p54_hdr *) skb_push(skb, sizeof(*hdr)); 933 hdr = (struct p54_hdr *) skb_push(skb, sizeof(*hdr));
933 934
934 if (padding) 935 if (padding)
935 hdr->flags = cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN); 936 hdr_flags |= P54_HDR_FLAG_DATA_ALIGN;
936 else
937 hdr->flags = cpu_to_le16(0);
938 hdr->len = cpu_to_le16(len); 937 hdr->len = cpu_to_le16(len);
939 hdr->type = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le16(1); 938 hdr->type = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le16(1);
940 hdr->rts_tries = info->control.rates[0].count; 939 hdr->rts_tries = info->control.rates[0].count;
@@ -1003,6 +1002,12 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1003 ridx++; 1002 ridx++;
1004 } 1003 }
1005 } 1004 }
1005
1006 if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
1007 hdr_flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
1008
1009 /* TODO: enable bursting */
1010 hdr->flags = cpu_to_le16(hdr_flags);
1006 hdr->tries = ridx; 1011 hdr->tries = ridx;
1007 txhdr->crypt_offset = 0; 1012 txhdr->crypt_offset = 0;
1008 txhdr->rts_rate_idx = 0; 1013 txhdr->rts_rate_idx = 0;
@@ -1021,6 +1026,10 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
1021 /* modifies skb->cb and with it info, so must be last! */ 1026 /* modifies skb->cb and with it info, so must be last! */
1022 if (unlikely(p54_assign_address(dev, skb, hdr, skb->len))) { 1027 if (unlikely(p54_assign_address(dev, skb, hdr, skb->len))) {
1023 skb_pull(skb, sizeof(*hdr) + sizeof(*txhdr) + padding); 1028 skb_pull(skb, sizeof(*hdr) + sizeof(*txhdr) + padding);
1029 if (current_queue) {
1030 current_queue->len--;
1031 current_queue->count--;
1032 }
1024 return NETDEV_TX_BUSY; 1033 return NETDEV_TX_BUSY;
1025 } 1034 }
1026 priv->tx(dev, skb, 0); 1035 priv->tx(dev, skb, 0);
@@ -1074,13 +1083,14 @@ static int p54_setup_mac(struct ieee80211_hw *dev, u16 mode, const u8 *bssid)
1074 return 0; 1083 return 0;
1075} 1084}
1076 1085
1077static int p54_set_freq(struct ieee80211_hw *dev, __le16 freq) 1086static int p54_set_freq(struct ieee80211_hw *dev, u16 frequency)
1078{ 1087{
1079 struct p54_common *priv = dev->priv; 1088 struct p54_common *priv = dev->priv;
1080 struct sk_buff *skb; 1089 struct sk_buff *skb;
1081 struct p54_scan *chan; 1090 struct p54_scan *chan;
1082 unsigned int i; 1091 unsigned int i;
1083 void *entry; 1092 void *entry;
1093 __le16 freq = cpu_to_le16(frequency);
1084 1094
1085 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*chan) + 1095 skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*chan) +
1086 sizeof(struct p54_hdr), P54_CONTROL_TYPE_SCAN, 1096 sizeof(struct p54_hdr), P54_CONTROL_TYPE_SCAN,
@@ -1237,6 +1247,7 @@ static int p54_start(struct ieee80211_hw *dev)
1237 struct p54_common *priv = dev->priv; 1247 struct p54_common *priv = dev->priv;
1238 int err; 1248 int err;
1239 1249
1250 mutex_lock(&priv->conf_mutex);
1240 err = priv->open(dev); 1251 err = priv->open(dev);
1241 if (!err) 1252 if (!err)
1242 priv->mode = NL80211_IFTYPE_MONITOR; 1253 priv->mode = NL80211_IFTYPE_MONITOR;
@@ -1248,6 +1259,7 @@ static int p54_start(struct ieee80211_hw *dev)
1248 if (!err) 1259 if (!err)
1249 err = p54_init_stats(dev); 1260 err = p54_init_stats(dev);
1250 1261
1262 mutex_unlock(&priv->conf_mutex);
1251 return err; 1263 return err;
1252} 1264}
1253 1265
@@ -1256,6 +1268,7 @@ static void p54_stop(struct ieee80211_hw *dev)
1256 struct p54_common *priv = dev->priv; 1268 struct p54_common *priv = dev->priv;
1257 struct sk_buff *skb; 1269 struct sk_buff *skb;
1258 1270
1271 mutex_lock(&priv->conf_mutex);
1259 del_timer(&priv->stats_timer); 1272 del_timer(&priv->stats_timer);
1260 p54_free_skb(dev, priv->cached_stats); 1273 p54_free_skb(dev, priv->cached_stats);
1261 priv->cached_stats = NULL; 1274 priv->cached_stats = NULL;
@@ -1265,6 +1278,7 @@ static void p54_stop(struct ieee80211_hw *dev)
1265 priv->stop(dev); 1278 priv->stop(dev);
1266 priv->tsf_high32 = priv->tsf_low32 = 0; 1279 priv->tsf_high32 = priv->tsf_low32 = 0;
1267 priv->mode = NL80211_IFTYPE_UNSPECIFIED; 1280 priv->mode = NL80211_IFTYPE_UNSPECIFIED;
1281 mutex_unlock(&priv->conf_mutex);
1268} 1282}
1269 1283
1270static int p54_add_interface(struct ieee80211_hw *dev, 1284static int p54_add_interface(struct ieee80211_hw *dev,
@@ -1272,14 +1286,18 @@ static int p54_add_interface(struct ieee80211_hw *dev,
1272{ 1286{
1273 struct p54_common *priv = dev->priv; 1287 struct p54_common *priv = dev->priv;
1274 1288
1275 if (priv->mode != NL80211_IFTYPE_MONITOR) 1289 mutex_lock(&priv->conf_mutex);
1290 if (priv->mode != NL80211_IFTYPE_MONITOR) {
1291 mutex_unlock(&priv->conf_mutex);
1276 return -EOPNOTSUPP; 1292 return -EOPNOTSUPP;
1293 }
1277 1294
1278 switch (conf->type) { 1295 switch (conf->type) {
1279 case NL80211_IFTYPE_STATION: 1296 case NL80211_IFTYPE_STATION:
1280 priv->mode = conf->type; 1297 priv->mode = conf->type;
1281 break; 1298 break;
1282 default: 1299 default:
1300 mutex_unlock(&priv->conf_mutex);
1283 return -EOPNOTSUPP; 1301 return -EOPNOTSUPP;
1284 } 1302 }
1285 1303
@@ -1298,6 +1316,7 @@ static int p54_add_interface(struct ieee80211_hw *dev,
1298 1316
1299 p54_set_leds(dev, 1, 0, 0); 1317 p54_set_leds(dev, 1, 0, 0);
1300 1318
1319 mutex_unlock(&priv->conf_mutex);
1301 return 0; 1320 return 0;
1302} 1321}
1303 1322
@@ -1305,9 +1324,12 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
1305 struct ieee80211_if_init_conf *conf) 1324 struct ieee80211_if_init_conf *conf)
1306{ 1325{
1307 struct p54_common *priv = dev->priv; 1326 struct p54_common *priv = dev->priv;
1327
1328 mutex_lock(&priv->conf_mutex);
1329 p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
1308 priv->mode = NL80211_IFTYPE_MONITOR; 1330 priv->mode = NL80211_IFTYPE_MONITOR;
1309 memset(priv->mac_addr, 0, ETH_ALEN); 1331 memset(priv->mac_addr, 0, ETH_ALEN);
1310 p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL); 1332 mutex_unlock(&priv->conf_mutex);
1311} 1333}
1312 1334
1313static int p54_config(struct ieee80211_hw *dev, u32 changed) 1335static int p54_config(struct ieee80211_hw *dev, u32 changed)
@@ -1319,7 +1341,7 @@ static int p54_config(struct ieee80211_hw *dev, u32 changed)
1319 mutex_lock(&priv->conf_mutex); 1341 mutex_lock(&priv->conf_mutex);
1320 priv->rx_antenna = 2; /* automatic */ 1342 priv->rx_antenna = 2; /* automatic */
1321 priv->output_power = conf->power_level << 2; 1343 priv->output_power = conf->power_level << 2;
1322 ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq)); 1344 ret = p54_set_freq(dev, conf->channel->center_freq);
1323 if (!ret) 1345 if (!ret)
1324 ret = p54_set_edcf(dev); 1346 ret = p54_set_edcf(dev);
1325 mutex_unlock(&priv->conf_mutex); 1347 mutex_unlock(&priv->conf_mutex);
@@ -1372,14 +1394,18 @@ static int p54_conf_tx(struct ieee80211_hw *dev, u16 queue,
1372 const struct ieee80211_tx_queue_params *params) 1394 const struct ieee80211_tx_queue_params *params)
1373{ 1395{
1374 struct p54_common *priv = dev->priv; 1396 struct p54_common *priv = dev->priv;
1397 int ret;
1375 1398
1399 mutex_lock(&priv->conf_mutex);
1376 if ((params) && !(queue > 4)) { 1400 if ((params) && !(queue > 4)) {
1377 P54_SET_QUEUE(priv->qos_params[queue], params->aifs, 1401 P54_SET_QUEUE(priv->qos_params[queue], params->aifs,
1378 params->cw_min, params->cw_max, params->txop); 1402 params->cw_min, params->cw_max, params->txop);
1379 } else 1403 } else
1380 return -EINVAL; 1404 ret = -EINVAL;
1381 1405 if (!ret)
1382 return p54_set_edcf(dev); 1406 ret = p54_set_edcf(dev);
1407 mutex_unlock(&priv->conf_mutex);
1408 return ret;
1383} 1409}
1384 1410
1385static int p54_init_xbow_synth(struct ieee80211_hw *dev) 1411static int p54_init_xbow_synth(struct ieee80211_hw *dev)
@@ -1488,19 +1514,14 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
1488 IEEE80211_HW_SIGNAL_DBM | 1514 IEEE80211_HW_SIGNAL_DBM |
1489 IEEE80211_HW_NOISE_DBM; 1515 IEEE80211_HW_NOISE_DBM;
1490 1516
1491 /*
1492 * XXX: when this driver gets support for any mode that
1493 * requires beacons (AP, MESH, IBSS) then it must
1494 * implement IEEE80211_TX_CTL_ASSIGN_SEQ.
1495 */
1496 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1517 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
1497 1518
1498 dev->channel_change_time = 1000; /* TODO: find actual value */ 1519 dev->channel_change_time = 1000; /* TODO: find actual value */
1499 priv->tx_stats[0].limit = 1; 1520 priv->tx_stats[0].limit = 1; /* Beacon queue */
1500 priv->tx_stats[1].limit = 1; 1521 priv->tx_stats[1].limit = 1; /* Probe queue for HW scan */
1501 priv->tx_stats[2].limit = 1; 1522 priv->tx_stats[2].limit = 3; /* queue for MLMEs */
1502 priv->tx_stats[3].limit = 1; 1523 priv->tx_stats[3].limit = 3; /* Broadcast / MC queue */
1503 priv->tx_stats[4].limit = 5; 1524 priv->tx_stats[4].limit = 5; /* Data */
1504 dev->queues = 1; 1525 dev->queues = 1;
1505 priv->noise = -94; 1526 priv->noise = -94;
1506 /* 1527 /*
diff --git a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h
index b1101feace69..8c8793cb2d79 100644
--- a/drivers/net/wireless/p54/p54common.h
+++ b/drivers/net/wireless/p54/p54common.h
@@ -25,6 +25,22 @@ struct bootrec {
25 u32 data[10]; 25 u32 data[10];
26} __attribute__((packed)); 26} __attribute__((packed));
27 27
28#define PDR_SYNTH_FRONTEND_MASK 0x0007
29#define PDR_SYNTH_IQ_CAL_MASK 0x0018
30#define PDR_SYNTH_IQ_CAL_PA_DETECTOR 0x0000
31#define PDR_SYNTH_IQ_CAL_DISABLED 0x0008
32#define PDR_SYNTH_IQ_CAL_ZIF 0x0010
33#define PDR_SYNTH_FAA_SWITCH_MASK 0x0020
34#define PDR_SYNTH_FAA_SWITCH_ENABLED 0x0001
35#define PDR_SYNTH_24_GHZ_MASK 0x0040
36#define PDR_SYNTH_24_GHZ_DISABLED 0x0040
37#define PDR_SYNTH_5_GHZ_MASK 0x0080
38#define PDR_SYNTH_5_GHZ_DISABLED 0x0080
39#define PDR_SYNTH_RX_DIV_MASK 0x0100
40#define PDR_SYNTH_RX_DIV_SUPPORTED 0x0100
41#define PDR_SYNTH_TX_DIV_MASK 0x0200
42#define PDR_SYNTH_TX_DIV_SUPPORTED 0x0200
43
28struct bootrec_exp_if { 44struct bootrec_exp_if {
29 __le16 role; 45 __le16 role;
30 __le16 if_id; 46 __le16 if_id;
@@ -210,6 +226,19 @@ struct pda_pa_curve_data {
210#define PDR_BASEBAND_REGISTERS 0x8000 226#define PDR_BASEBAND_REGISTERS 0x8000
211#define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001 227#define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001
212 228
229/* PDR definitions for default country & country list */
230#define PDR_COUNTRY_CERT_CODE 0x80
231#define PDR_COUNTRY_CERT_CODE_REAL 0x00
232#define PDR_COUNTRY_CERT_CODE_PSEUDO 0x80
233#define PDR_COUNTRY_CERT_BAND 0x40
234#define PDR_COUNTRY_CERT_BAND_2GHZ 0x00
235#define PDR_COUNTRY_CERT_BAND_5GHZ 0x40
236#define PDR_COUNTRY_CERT_IODOOR 0x30
237#define PDR_COUNTRY_CERT_IODOOR_BOTH 0x00
238#define PDR_COUNTRY_CERT_IODOOR_INDOOR 0x20
239#define PDR_COUNTRY_CERT_IODOOR_OUTDOOR 0x30
240#define PDR_COUNTRY_CERT_INDEX 0x0F
241
213/* stored in skb->cb */ 242/* stored in skb->cb */
214struct memrecord { 243struct memrecord {
215 u32 start_addr; 244 u32 start_addr;
@@ -507,7 +536,7 @@ struct p54_sta_unlock {
507} __attribute__ ((packed)); 536} __attribute__ ((packed));
508 537
509#define P54_TIM_CLEAR BIT(15) 538#define P54_TIM_CLEAR BIT(15)
510struct p54_tx_control_tim { 539struct p54_tim {
511 u8 count; 540 u8 count;
512 u8 padding[3]; 541 u8 padding[3];
513 __le16 entry[8]; 542 __le16 entry[8];