2008-10-15 02:04:35

by Christian Lamparter

[permalink] [raw]
Subject: [PATCH 6/6] p54: integrate parts of lmac_longbow.h and other parts of stlc45xx

This patch removes most/all? of the "magic" numbers and unknown structu=
re=20
variables inside the code and replaces them with meaningful prototypes.

Signed-off-by: Christian Lamparter <[email protected]>
---
diff -Nurp a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireles=
s/p54/p54common.c
--- a/drivers/net/wireless/p54/p54common.c 2008-10-15 03:04:38.00000000=
0 +0200
+++ b/drivers/net/wireless/p54/p54common.c 2008-10-15 02:59:26.00000000=
0 +0200
@@ -5,8 +5,11 @@
* Copyright (c) 2007, Christian Lamparter <[email protected]>
* Copyright 2008, Johannes Berg <[email protected]>
*
- * Based on the islsm (softmac prism54) driver, which is:
- * Copyright 2004-2006 Jean-Baptiste Note <[email protected]>, et al.
+ * Based on:
+ * - the islsm (softmac prism54) driver, which is:
+ * Copyright 2004-2006 Jean-Baptiste Note <[email protected]>, et al.
+ * - stlc45xx driver
+ * =C3=82 Copyright (C) 2008 Nokia Corporation and/or its subsidiary(=
-ies).
*
* This program is free software; you can redistribute it and/or modif=
y
* it under the terms of the GNU General Public License version 2 as
@@ -481,13 +484,13 @@ static int p54_rssi_to_dbm(struct ieee80
static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
{
struct p54_common *priv =3D dev->priv;
- struct p54_rx_hdr *hdr =3D (struct p54_rx_hdr *) skb->data;
+ struct p54_rx_data *hdr =3D (struct p54_rx_data *) skb->data;
struct ieee80211_rx_status rx_status =3D {0};
u16 freq =3D le16_to_cpu(hdr->freq);
size_t header_len =3D sizeof(*hdr);
u32 tsf32;
=20
- if (!(hdr->magic & cpu_to_le16(0x0001))) {
+ if (!(hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_IN_FCS_GOOD))) {
if (priv->filter_flags & FIF_FCSFAIL)
rx_status.flag |=3D RX_FLAG_FAILED_FCS_CRC;
else
@@ -512,7 +515,7 @@ static int p54_rx_data(struct ieee80211_
=20
rx_status.flag |=3D RX_FLAG_TSFT;
=20
- if (hdr->magic & cpu_to_le16(0x4000))
+ if (hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN))
header_len +=3D hdr->align[0];
=20
skb_pull(skb, header_len);
@@ -571,7 +574,7 @@ void p54_free_skb(struct ieee80211_hw *d
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
kfree_skb(skb);
=20
- if (freed >=3D priv->headroom + sizeof(struct p54_control_hdr) + 48 +
+ if (freed >=3D priv->headroom + sizeof(struct p54_hdr) + 48 +
IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
p54_wake_free_queues(dev);
}
@@ -580,8 +583,8 @@ EXPORT_SYMBOL_GPL(p54_free_skb);
static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff=
*skb)
{
struct p54_common *priv =3D dev->priv;
- struct p54_control_hdr *hdr =3D (struct p54_control_hdr *) skb->data;
- struct p54_frame_sent_hdr *payload =3D (struct p54_frame_sent_hdr *) =
hdr->data;
+ struct p54_hdr *hdr =3D (struct p54_hdr *) skb->data;
+ struct p54_frame_sent *payload =3D (struct p54_frame_sent *) hdr->dat=
a;
struct sk_buff *entry =3D (struct sk_buff *) priv->tx_queue.next;
u32 addr =3D le32_to_cpu(hdr->req_id) - priv->headroom;
struct memrecord *range =3D NULL;
@@ -593,8 +596,8 @@ static void p54_rx_frame_sent(struct iee
spin_lock_irqsave(&priv->tx_queue.lock, flags);
while (entry !=3D (struct sk_buff *)&priv->tx_queue) {
struct ieee80211_tx_info *info =3D IEEE80211_SKB_CB(entry);
- struct p54_control_hdr *entry_hdr;
- struct p54_tx_control_allocdata *entry_data;
+ struct p54_hdr *entry_hdr;
+ struct p54_tx_data *entry_data;
int pad =3D 0;
=20
range =3D (void *)info->rate_driver_data;
@@ -628,13 +631,13 @@ static void p54_rx_frame_sent(struct iee
BUILD_BUG_ON(offsetof(struct ieee80211_tx_info,
status.ampdu_ack_len) !=3D 23);
=20
- entry_hdr =3D (struct p54_control_hdr *) entry->data;
- entry_data =3D (struct p54_tx_control_allocdata *) entry_hdr->data;
- if ((entry_hdr->magic1 & cpu_to_le16(0x4000)) !=3D 0)
+ entry_hdr =3D (struct p54_hdr *) entry->data;
+ entry_data =3D (struct p54_tx_data *) entry_hdr->data;
+ if (entry_hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN))
pad =3D entry_data->align[0];
=20
/* walk through the rates array and adjust the counts */
- count =3D payload->retries;
+ count =3D payload->tries;
for (idx =3D 0; idx < 4; idx++) {
if (count >=3D info->status.rates[idx].count) {
count -=3D info->status.rates[idx].count;
@@ -662,7 +665,7 @@ static void p54_rx_frame_sent(struct iee
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
=20
out:
- if (freed >=3D priv->headroom + sizeof(struct p54_control_hdr) + 48 +
+ if (freed >=3D priv->headroom + sizeof(struct p54_hdr) + 48 +
IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
p54_wake_free_queues(dev);
}
@@ -670,7 +673,7 @@ out:
static void p54_rx_eeprom_readback(struct ieee80211_hw *dev,
struct sk_buff *skb)
{
- struct p54_control_hdr *hdr =3D (struct p54_control_hdr *) skb->data;
+ struct p54_hdr *hdr =3D (struct p54_hdr *) skb->data;
struct p54_eeprom_lm86 *eeprom =3D (struct p54_eeprom_lm86 *) hdr->da=
ta;
struct p54_common *priv =3D dev->priv;
=20
@@ -685,7 +688,7 @@ static void p54_rx_eeprom_readback(struc
static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb=
)
{
struct p54_common *priv =3D dev->priv;
- struct p54_control_hdr *hdr =3D (struct p54_control_hdr *) skb->data;
+ struct p54_hdr *hdr =3D (struct p54_hdr *) skb->data;
struct p54_statistics *stats =3D (struct p54_statistics *) hdr->data;
u32 tsf32 =3D le32_to_cpu(stats->tsf32);
=20
@@ -705,7 +708,7 @@ static void p54_rx_stats(struct ieee8021
=20
static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *sk=
b)
{
- struct p54_control_hdr *hdr =3D (struct p54_control_hdr *) skb->data;
+ struct p54_hdr *hdr =3D (struct p54_hdr *) skb->data;
=20
switch (le16_to_cpu(hdr->type)) {
case P54_CONTROL_TYPE_TXDONE:
@@ -750,7 +753,7 @@ EXPORT_SYMBOL_GPL(p54_rx);
* allocated areas.
*/
static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff=
*skb,
- struct p54_control_hdr *data, u32 len)
+ struct p54_hdr *data, u32 len)
{
struct p54_common *priv =3D dev->priv;
struct sk_buff *entry =3D priv->tx_queue.next;
@@ -807,7 +810,7 @@ static int p54_assign_address(struct iee
__skb_queue_after(&priv->tx_queue, target_skb, skb);
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);
=20
- if (largest_hole < priv->headroom + sizeof(struct p54_control_hdr) +
+ if (largest_hole < priv->headroom + sizeof(struct p54_hdr) +
48 + IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom)
ieee80211_stop_queues(dev);
=20
@@ -819,7 +822,7 @@ static struct sk_buff *p54_alloc_skb(str
u16 hdr_flags, u16 len, u16 type, gfp_t memflags)
{
struct p54_common *priv =3D dev->priv;
- struct p54_control_hdr *hdr;
+ struct p54_hdr *hdr;
struct sk_buff *skb;
=20
skb =3D __dev_alloc_skb(len + priv->tx_hdr_len, memflags);
@@ -827,11 +830,11 @@ static struct sk_buff *p54_alloc_skb(str
return NULL;
skb_reserve(skb, priv->tx_hdr_len);
=20
- hdr =3D (struct p54_control_hdr *) skb_put(skb, sizeof(*hdr));
- hdr->magic1 =3D cpu_to_le16(hdr_flags);
+ hdr =3D (struct p54_hdr *) skb_put(skb, sizeof(*hdr));
+ hdr->flags =3D cpu_to_le16(hdr_flags);
hdr->len =3D cpu_to_le16(len - sizeof(*hdr));
hdr->type =3D cpu_to_le16(type);
- hdr->retry1 =3D hdr->retry2 =3D 0;
+ hdr->tries =3D hdr->rts_tries =3D 0;
=20
if (unlikely(p54_assign_address(dev, skb, hdr, len))) {
kfree_skb(skb);
@@ -843,7 +846,7 @@ static struct sk_buff *p54_alloc_skb(str
int p54_read_eeprom(struct ieee80211_hw *dev)
{
struct p54_common *priv =3D dev->priv;
- struct p54_control_hdr *hdr =3D NULL;
+ struct p54_hdr *hdr =3D NULL;
struct p54_eeprom_lm86 *eeprom_hdr;
struct sk_buff *skb;
size_t eeprom_size =3D 0x2020, offset =3D 0, blocksize;
@@ -899,8 +902,8 @@ static int p54_tx(struct ieee80211_hw *d
struct ieee80211_tx_info *info =3D IEEE80211_SKB_CB(skb);
struct ieee80211_tx_queue_stats *current_queue;
struct p54_common *priv =3D dev->priv;
- struct p54_control_hdr *hdr;
- struct p54_tx_control_allocdata *txhdr;
+ struct p54_hdr *hdr;
+ struct p54_tx_data *txhdr;
size_t padding, len;
int i, j, ridx;
u8 rate;
@@ -920,17 +923,16 @@ static int p54_tx(struct ieee80211_hw *d
padding =3D (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr=
))) & 3;
len =3D skb->len;
=20
- txhdr =3D (struct p54_tx_control_allocdata *)
- skb_push(skb, sizeof(*txhdr) + padding);
- hdr =3D (struct p54_control_hdr *) skb_push(skb, sizeof(*hdr));
+ txhdr =3D (struct p54_tx_data *) skb_push(skb, sizeof(*txhdr) + paddi=
ng);
+ hdr =3D (struct p54_hdr *) skb_push(skb, sizeof(*hdr));
=20
if (padding)
- hdr->magic1 =3D cpu_to_le16(0x4010);
+ hdr->flags =3D cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN);
else
- hdr->magic1 =3D cpu_to_le16(0x0010);
+ hdr->flags =3D cpu_to_le16(0);
hdr->len =3D cpu_to_le16(len);
hdr->type =3D (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le=
16(1);
- hdr->retry1 =3D info->control.rates[0].count;
+ hdr->rts_tries =3D info->control.rates[0].count;
=20
/*
* we register the rates in perfect order, and
@@ -996,16 +998,18 @@ static int p54_tx(struct ieee80211_hw *d
ridx++;
}
}
- hdr->retry2 =3D ridx;
-
+ hdr->tries =3D ridx;
+ txhdr->crypt_offset =3D 0;
+ txhdr->rts_rate_idx =3D 0;
txhdr->key_type =3D 0;
txhdr->key_len =3D 0;
txhdr->hw_queue =3D skb_get_queue_mapping(skb) + 4;
+ txhdr->backlog =3D 32;
+ memset(txhdr->durations, 0, sizeof(txhdr->durations));
txhdr->tx_antenna =3D (info->antenna_sel_tx =3D=3D 0) ?
2 : info->antenna_sel_tx - 1;
txhdr->output_power =3D priv->output_power;
- txhdr->cts_rate =3D (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
- 0 : cts_rate;
+ txhdr->cts_rate =3D cts_rate;
if (padding)
txhdr->align[0] =3D padding;
=20
@@ -1024,13 +1028,13 @@ static int p54_setup_mac(struct ieee8021
struct sk_buff *skb;
struct p54_setup_mac *setup;
=20
- skb =3D p54_alloc_skb(dev, 0x8001, sizeof(struct p54_tx_control_hdr) =
+
- sizeof(*setup), P54_CONTROL_TYPE_SETUP,
+ skb =3D p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*setup)=
+
+ sizeof(struct p54_hdr), P54_CONTROL_TYPE_SETUP,
GFP_ATOMIC);
if (!skb)
return -ENOMEM;
=20
- setup =3D (struct p54_tx_control_filter *) skb_put(skb, sizeof(*filte=
r));
+ setup =3D (struct p54_setup_mac *) skb_put(skb, sizeof(*setup));
priv->mac_mode =3D mode;
setup->mac_mode =3D cpu_to_le16(mode);
memcpy(setup->mac_addr, priv->mac_addr, ETH_ALEN);
@@ -1069,19 +1073,19 @@ static int p54_set_freq(struct ieee80211
{
struct p54_common *priv =3D dev->priv;
struct sk_buff *skb;
- struct p54_tx_control_channel *chan;
+ struct p54_scan *chan;
unsigned int i;
- size_t data_len =3D sizeof(struct p54_control_hdr) + sizeof(*chan);
void *entry;
=20
- skb =3D p54_alloc_skb(dev, 0x8001, data_len,
- P54_CONTROL_TYPE_CHANNEL_CHANGE, GFP_ATOMIC);
+ skb =3D p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*chan) =
+
+ sizeof(struct p54_hdr), P54_CONTROL_TYPE_SCAN,
+ GFP_ATOMIC);
if (!skb)
return -ENOMEM;
=20
- chan =3D (struct p54_tx_control_channel *) skb_put(skb, sizeof(*chan)=
);
+ chan =3D (struct p54_scan *) skb_put(skb, sizeof(*chan));
memset(chan->padding1, 0, sizeof(chan->padding1));
- chan->flags =3D cpu_to_le16(0x1);
+ chan->mode =3D cpu_to_le16(P54_SCAN_EXIT);
chan->dwell =3D cpu_to_le16(0x0);
=20
for (i =3D 0; i < priv->iq_autocal_len; i++) {
@@ -1132,13 +1136,13 @@ static int p54_set_freq(struct ieee80211
}
=20
if (priv->fw_var < 0x500) {
- data_len =3D P54_TX_CONTROL_CHANNEL_V1_LEN;
chan->v1.rssical_mul =3D cpu_to_le16(130);
chan->v1.rssical_add =3D cpu_to_le16(0xfe70);
} else {
chan->v2.rssical_mul =3D cpu_to_le16(130);
chan->v2.rssical_add =3D cpu_to_le16(0xfe70);
chan->v2.basic_rate_mask =3D cpu_to_le32(0x15f);
+ memset(chan->v2.rts_rates, 0, 8);
}
priv->tx(dev, skb, 1);
return 0;
@@ -1153,15 +1157,15 @@ static int p54_set_leds(struct ieee80211
{
struct p54_common *priv =3D dev->priv;
struct sk_buff *skb;
- struct p54_tx_control_led *led;
+ struct p54_led *led;
=20
- skb =3D p54_alloc_skb(dev, 0x8001, sizeof(*led) +
- sizeof(struct p54_control_hdr),
- P54_CONTROL_TYPE_LED, GFP_ATOMIC);
+ skb =3D p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*led) +
+ sizeof(struct p54_hdr), P54_CONTROL_TYPE_LED,
+ GFP_ATOMIC);
if (!skb)
return -ENOMEM;
=20
- led =3D (struct p54_tx_control_led *)skb_put(skb, sizeof(*led));
+ led =3D (struct p54_led *)skb_put(skb, sizeof(*led));
led->mode =3D cpu_to_le16(mode);
led->led_permanent =3D cpu_to_le16(link);
led->led_temporary =3D cpu_to_le16(act);
@@ -1184,8 +1188,9 @@ static int p54_set_edcf(struct ieee80211
struct sk_buff *skb;
struct p54_edcf *edcf;
=20
- skb =3D p54_alloc_skb(dev, 0x8001, sizeof(struct p54_control_hdr) +
- sizeof(*edcf), P54_CONTROL_TYPE_DCFINIT, GFP_ATOMIC);
+ skb =3D p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*edcf) =
+
+ sizeof(struct p54_hdr), P54_CONTROL_TYPE_DCFINIT,
+ GFP_ATOMIC);
if (!skb)
return -ENOMEM;
=20
@@ -1212,11 +1217,9 @@ static int p54_init_stats(struct ieee802
{
struct p54_common *priv =3D dev->priv;
=20
- priv->cached_stats =3D p54_alloc_skb(dev, 0x8000,
- sizeof(struct p54_control_hdr) +
- sizeof(struct p54_statistics),
- P54_CONTROL_TYPE_STAT_READBACK,
- GFP_KERNEL);
+ priv->cached_stats =3D p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL,
+ sizeof(struct p54_hdr) + sizeof(struct p54_statistics),
+ P54_CONTROL_TYPE_STAT_READBACK, GFP_KERNEL);
if (!priv->cached_stats)
return -ENOMEM;
=20
@@ -1277,11 +1280,11 @@ static int p54_add_interface(struct ieee
=20
memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
=20
- p54_setup_mac(dev, 0, NULL);
+ p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
=20
switch (conf->type) {
case NL80211_IFTYPE_STATION:
- p54_setup_mac(dev, 1, NULL);
+ p54_setup_mac(dev, P54_FILTER_TYPE_STATION, NULL);
break;
default:
BUG(); /* impossible */
@@ -1299,7 +1302,7 @@ static void p54_remove_interface(struct=20
struct p54_common *priv =3D dev->priv;
priv->mode =3D NL80211_IFTYPE_MONITOR;
memset(priv->mac_addr, 0, ETH_ALEN);
- p54_setup_mac(dev, 0, NULL);
+ p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
}
=20
static int p54_config(struct ieee80211_hw *dev, u32 changed)
@@ -1325,7 +1328,7 @@ static int p54_config_interface(struct i
struct p54_common *priv =3D dev->priv;
=20
mutex_lock(&priv->conf_mutex);
- p54_setup_mac(dev, 0, conf->bssid);
+ p54_setup_mac(dev, P54_FILTER_TYPE_STATION, conf->bssid);
p54_set_leds(dev, 1, !is_multicast_ether_addr(conf->bssid), 0);
memcpy(priv->bssid, conf->bssid, ETH_ALEN);
mutex_unlock(&priv->conf_mutex);
@@ -1378,15 +1381,16 @@ static int p54_init_xbow_synth(struct ie
{
struct p54_common *priv =3D dev->priv;
struct sk_buff *skb;
- struct p54_tx_control_xbow_synth *xbow;
+ struct p54_xbow_synth *xbow;
=20
- skb =3D p54_alloc_skb(dev, 0x8001, sizeof(struct p54_control_hdr) +
- sizeof(*xbow), P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
+ skb =3D p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*xbow) =
+
+ sizeof(struct p54_hdr),
+ P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
GFP_KERNEL);
if (!skb)
return -ENOMEM;
=20
- xbow =3D (struct p54_tx_control_xbow_synth *)skb_put(skb, sizeof(*xbo=
w));
+ xbow =3D (struct p54_xbow_synth *)skb_put(skb, sizeof(*xbow));
xbow->magic1 =3D cpu_to_le16(0x1);
xbow->magic2 =3D cpu_to_le16(0x2);
xbow->freq =3D cpu_to_le16(5390);
@@ -1504,8 +1508,8 @@ struct ieee80211_hw *p54_init_common(siz
*/
dev->max_rates =3D 4;
dev->max_rate_tries =3D 7;
- dev->extra_tx_headroom =3D sizeof(struct p54_control_hdr) + 4 +
- sizeof(struct p54_tx_control_allocdata);
+ dev->extra_tx_headroom =3D sizeof(struct p54_hdr) + 4 +
+ sizeof(struct p54_tx_data);
=20
mutex_init(&priv->conf_mutex);
init_completion(&priv->eeprom_comp);
diff -Nurp a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireles=
s/p54/p54common.h
--- a/drivers/net/wireless/p54/p54common.h 2008-10-15 02:22:59.00000000=
0 +0200
+++ b/drivers/net/wireless/p54/p54common.h 2008-10-14 21:34:12.00000000=
0 +0200
@@ -33,6 +33,13 @@ struct bootrec_exp_if {
__le16 top_compat;
} __attribute__((packed));
=20
+#define BR_DESC_PRIV_CAP_WEP BIT(0)
+#define BR_DESC_PRIV_CAP_TKIP BIT(1)
+#define BR_DESC_PRIV_CAP_MICHAEL BIT(2)
+#define BR_DESC_PRIV_CAP_CCX_CP BIT(3)
+#define BR_DESC_PRIV_CAP_CCX_MIC BIT(4)
+#define BR_DESC_PRIV_CAP_AESCCMP BIT(5)
+
struct bootrec_desc {
__le16 modes;
__le16 flags;
@@ -40,7 +47,12 @@ struct bootrec_desc {
__le32 rx_end;
u8 headroom;
u8 tailroom;
- u8 unimportant[6];
+ u8 tx_queues;
+ u8 tx_depth;
+ u8 privacy_caps;
+ u8 rx_keycache_size;
+ u8 time_size;
+ u8 padding;
u8 rates[16];
u8 padding2[4];
__le16 rx_mtu;
@@ -56,6 +68,34 @@ struct bootrec_desc {
#define BR_CODE_END_OF_BRA 0xFF0000FF
#define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF
=20
+#define P54_HDR_FLAG_CONTROL BIT(15)
+#define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0))
+
+#define P54_HDR_FLAG_DATA_ALIGN BIT(14)
+#define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0)
+#define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1)
+#define P54_HDR_FLAG_DATA_OUT_SEQNR BIT(2)
+#define P54_HDR_FLAG_DATA_OUT_BIT3 BIT(3)
+#define P54_HDR_FLAG_DATA_OUT_BURST BIT(4)
+#define P54_HDR_FLAG_DATA_OUT_NOCANCEL BIT(5)
+#define P54_HDR_FLAG_DATA_OUT_CLEARTIM BIT(6)
+#define P54_HDR_FLAG_DATA_OUT_HITCHHIKE BIT(7)
+#define P54_HDR_FLAG_DATA_OUT_COMPRESS BIT(8)
+#define P54_HDR_FLAG_DATA_OUT_CONCAT BIT(9)
+#define P54_HDR_FLAG_DATA_OUT_PCS_ACCEPT BIT(10)
+#define P54_HDR_FLAG_DATA_OUT_WAITEOSP BIT(11)
+
+#define P54_HDR_FLAG_DATA_IN_FCS_GOOD BIT(0)
+#define P54_HDR_FLAG_DATA_IN_MATCH_MAC BIT(1)
+#define P54_HDR_FLAG_DATA_IN_MCBC BIT(2)
+#define P54_HDR_FLAG_DATA_IN_BEACON BIT(3)
+#define P54_HDR_FLAG_DATA_IN_MATCH_BSS BIT(4)
+#define P54_HDR_FLAG_DATA_IN_BCAST_BSS BIT(5)
+#define P54_HDR_FLAG_DATA_IN_DATA BIT(6)
+#define P54_HDR_FLAG_DATA_IN_TRUNCATED BIT(7)
+#define P54_HDR_FLAG_DATA_IN_BIT8 BIT(8)
+#define P54_HDR_FLAG_DATA_IN_TRANSPARENT BIT(9)
+
/* PDA defines are Copyright (C) 2005 Nokia Corporation (taken from is=
lsm_pda.h) */
=20
struct pda_entry {
@@ -182,36 +222,91 @@ struct p54_eeprom_lm86 {
u8 data[0];
} __attribute__ ((packed));
=20
-struct p54_rx_hdr {
- __le16 magic;
+enum p54_rx_decrypt_status {
+ P54_DECRYPT_NONE =3D 0,
+ P54_DECRYPT_OK,
+ P54_DECRYPT_NOKEY,
+ P54_DECRYPT_NOMICHAEL,
+ P54_DECRYPT_NOCKIPMIC,
+ P54_DECRYPT_FAIL_WEP,
+ P54_DECRYPT_FAIL_TKIP,
+ P54_DECRYPT_FAIL_MICAHEL,
+ P54_DECRYPT_FAIL_CKIPKP,
+ P54_DECRYPT_FAIL_CKIPMIC,
+ P54_DECRYPT_FAIL_AESCCMP
+};
+
+struct p54_rx_data {
+ __le16 flags;
__le16 len;
__le16 freq;
u8 antenna;
u8 rate;
u8 rssi;
u8 quality;
- u16 unknown2;
+ u8 decrypt_status;
+ u8 rssi_raw;
__le32 tsf32;
__le32 unalloc0;
u8 align[0];
} __attribute__ ((packed));
=20
-struct p54_frame_sent_hdr {
+enum p54_trap_type {
+ P54_TRAP_SCAN =3D 0,
+ P54_TRAP_TIMER,
+ P54_TRAP_BEACON_TX,
+ P54_TRAP_FAA_RADIO_ON,
+ P54_TRAP_FAA_RADIO_OFF,
+ P54_TRAP_RADAR,
+ P54_TRAP_NO_BEACON,
+ P54_TRAP_TBTT,
+ P54_TRAP_SCO_ENTER,
+ P54_TRAP_SCO_EXIT
+};
+
+struct p54_trap {
+ __le16 event;
+ __le16 frequency;
+} __attribute__ ((packed));
+
+enum p54_frame_sent_status {
+ P54_TX_OK =3D 0,
+ P54_TX_FAILED,
+ P54_TX_PSM,
+ P54_TX_PSM_CANCELLED
+};
+
+struct p54_frame_sent {
u8 status;
- u8 retries;
- __le16 ack_rssi;
+ u8 tries;
+ u8 ack_rssi;
+ u8 quality;
__le16 seq;
- u16 rate;
+ u8 antenna;
+ u8 padding;
} __attribute__ ((packed));
=20
-struct p54_tx_control_allocdata {
+enum p54_tx_data_crypt {
+ P54_CRYPTO_NONE =3D 0,
+ P54_CRYPTO_WEP,
+ P54_CRYPTO_TKIP,
+ P54_CRYPTO_TKIPMICHAEL,
+ P54_CRYPTO_CCX_WEPMIC,
+ P54_CRYPTO_CCX_KPMIC,
+ P54_CRYPTO_CCX_KP,
+ P54_CRYPTO_AESCCMP
+};
+
+struct p54_tx_data {
u8 rateset[8];
- u8 unalloc0[2];
+ u8 rts_rate_idx;
+ u8 crypt_offset;
u8 key_type;
u8 key_len;
u8 key[16];
u8 hw_queue;
- u8 unalloc1[9];
+ u8 backlog;
+ __le16 durations[4];
u8 tx_antenna;
u8 output_power;
u8 cts_rate;
@@ -219,6 +314,16 @@ struct p54_tx_control_allocdata {
u8 align[0];
} __attribute__ ((packed));
=20
+#define P54_FILTER_TYPE_NONE 0
+#define P54_FILTER_TYPE_STATION BIT(0)
+#define P54_FILTER_TYPE_IBSS BIT(1)
+#define P54_FILTER_TYPE_AP BIT(2)
+#define P54_FILTER_TYPE_TRANSPARENT BIT(3)
+#define P54_FILTER_TYPE_PROMISCUOUS BIT(4)
+#define P54_FILTER_TYPE_HIBERNATE BIT(5)
+#define P54_FILTER_TYPE_NOACK BIT(6)
+#define P54_FILTER_TYPE_RX_DISABLED BIT(7)
+
struct p54_setup_mac {
__le16 mac_mode;
u8 mac_addr[ETH_ALEN];
@@ -253,8 +358,16 @@ struct p54_setup_mac {
} __attribute__ ((packed));
} __attribute__ ((packed));
=20
-struct p54_tx_control_channel {
- __le16 flags;
+#define P54_SETUP_V1_LEN 40
+#define P54_SETUP_V2_LEN (sizeof(struct p54_setup_mac))
+
+#define P54_SCAN_EXIT BIT(0)
+#define P54_SCAN_TRAP BIT(1)
+#define P54_SCAN_ACTIVE BIT(2)
+#define P54_SCAN_FILTER BIT(3)
+
+struct p54_scan {
+ __le16 mode;
__le16 dwell;
u8 padding1[20];
struct pda_iq_autocal_entry iq_autocal;
@@ -277,17 +390,17 @@ struct p54_tx_control_channel {
=20
struct {
__le32 basic_rate_mask;
- u8 rts_rates[8];
+ u8 rts_rates[8];
__le16 rssical_mul;
__le16 rssical_add;
} v2 __attribute__ ((packed));
} __attribute__ ((packed));
} __attribute__ ((packed));
=20
-#define P54_TX_CONTROL_CHANNEL_V1_LEN (sizeof(struct p54_tx_control_ch=
annel)-12)
-#define P54_TX_CONTROL_CHANNEL_V2_LEN (sizeof(struct p54_tx_control_ch=
annel))
+#define P54_SCAN_V1_LEN (sizeof(struct p54_scan)-12)
+#define P54_SCAN_V2_LEN (sizeof(struct p54_scan))
=20
-struct p54_tx_control_led {
+struct p54_led {
__le16 mode;
__le16 led_temporary;
__le16 led_permanent;
@@ -315,14 +428,103 @@ struct p54_statistics {
__le32 tsf32;
__le32 airtime;
__le32 noise;
- __le32 unkn[10]; /* CCE / CCA / RADAR */
+ __le32 sample_noise[8];
+ __le32 sample_cca;
+ __le32 sample_tx;
} __attribute__ ((packed));
=20
-struct p54_tx_control_xbow_synth {
+struct p54_xbow_synth {
__le16 magic1;
__le16 magic2;
__le16 freq;
u32 padding[5];
} __attribute__ ((packed));
=20
+struct p54_timer {
+ __le32 interval;
+} __attribute__ ((packed));
+
+struct p54_keycache {
+ u8 entry;
+ u8 key_id;
+ u8 mac[ETH_ALEN];
+ u8 padding[2];
+ u8 key_type;
+ u8 key_len;
+ u8 key[24];
+} __attribute__ ((packed));
+
+struct p54_burst {
+ u8 flags;
+ u8 queue;
+ u8 backlog;
+ u8 pad;
+ __le16 durations[32];
+} __attribute__ ((packed));
+
+struct p54_psm_interval {
+ __le16 interval;
+ __le16 periods;
+} __attribute__ ((packed));
+
+#define P54_PSM BIT(0)
+#define P54_PSM_DTIM BIT(1)
+#define P54_PSM_MCBC BIT(2)
+#define P54_PSM_CHECKSUM BIT(3)
+#define P54_PSM_SKIP_MORE_DATA BIT(4)
+#define P54_PSM_BEACON_TIMEOUT BIT(5)
+#define P54_PSM_HFOSLEEP BIT(6)
+#define P54_PSM_AUTOSWITCH_SLEEP BIT(7)
+#define P54_PSM_LPIT BIT(8)
+#define P54_PSM_BF_UCAST_SKIP BIT(9)
+#define P54_PSM_BF_MCAST_SKIP BIT(10)
+
+struct p54_psm {
+ __le16 mode;
+ __le16 aid;
+ struct p54_psm_interval intervals[4];
+ u8 beacon_rssi_skip_max;
+ u8 rssi_delta_threshold;
+ u8 nr;
+ u8 exclude[1];
+} __attribute__ ((packed));
+
+#define MC_FILTER_ADDRESS_NUM 4
+
+struct p54_group_address_table {
+ __le16 filter_enable;
+ __le16 num_address;
+ u8 mac_list[MC_FILTER_ADDRESS_NUM][ETH_ALEN];
+} __attribute__ ((packed));
+
+struct p54_txcancel {
+ __le32 req_id;
+} __attribute__ ((packed));
+
+struct p54_sta_unlock {
+ u8 addr[ETH_ALEN];
+ u16 padding;
+} __attribute__ ((packed));
+
+#define P54_TIM_CLEAR BIT(15)
+struct p54_tx_control_tim {
+ u8 count;
+ u8 padding[3];
+ __le16 entry[8];
+} __attribute__ ((packed));
+
+struct p54_cce_quiet {
+ __le32 period;
+} __attribute__ ((packed));
+
+struct p54_bt_balancer {
+ __le16 prio_thresh;
+ __le16 acl_thresh;
+} __attribute__ ((packed));
+
+struct p54_arp_table {
+ __le16 filter_enable;
+ u8 ipv4_addr[4];
+} __attribute__ ((packed));
+
#endif /* P54COMMON_H */
diff -Nurp a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/=
p54.h
--- a/drivers/net/wireless/p54/p54.h 2008-10-15 03:03:57.000000000 +020=
0
+++ b/drivers/net/wireless/p54/p54.h 2008-10-14 21:26:45.000000000 +020=
0
@@ -14,17 +14,17 @@
* published by the Free Software Foundation.
*/
=20
-enum control_frame_types {
+enum p54_control_frame_types {
P54_CONTROL_TYPE_SETUP =3D 0,
- P54_CONTROL_TYPE_CHANNEL_CHANGE,
- P54_CONTROL_TYPE_FREQDONE,
+ P54_CONTROL_TYPE_SCAN,
+ P54_CONTROL_TYPE_TRAP,
P54_CONTROL_TYPE_DCFINIT,
- P54_CONTROL_TYPE_ENCRYPTION,
+ P54_CONTROL_TYPE_RX_KEYCACHE,
P54_CONTROL_TYPE_TIM,
- P54_CONTROL_TYPE_POWERMGT,
- P54_CONTROL_TYPE_FREEQUEUE,
+ P54_CONTROL_TYPE_PSM,
+ P54_CONTROL_TYPE_TXCANCEL,
P54_CONTROL_TYPE_TXDONE,
- P54_CONTROL_TYPE_PING,
+ P54_CONTROL_TYPE_BURST,
P54_CONTROL_TYPE_STAT_READBACK,
P54_CONTROL_TYPE_BBP,
P54_CONTROL_TYPE_EEPROM_READBACK,
@@ -37,15 +37,20 @@ enum control_frame_types {
P54_CONTROL_TYPE_XBOW_SYNTH_CFG,
P54_CONTROL_TYPE_CCE_QUIET,
P54_CONTROL_TYPE_PSM_STA_UNLOCK,
+ P54_CONTROL_TYPE_PCS,
+ P54_CONTROL_TYPE_BT_BALANCER =3D 28,
+ P54_CONTROL_TYPE_GROUP_ADDRESS_TABLE =3D 30,
+ P54_CONTROL_TYPE_ARPTABLE =3D 31,
+ P54_CONTROL_TYPE_BT_OPTIONS =3D 35
};
=20
-struct p54_control_hdr {
- __le16 magic1;
+struct p54_hdr {
+ __le16 flags;
__le16 len;
__le32 req_id;
- __le16 type; /* enum control_frame_types */
- u8 retry1;
- u8 retry2;
+ __le16 type; /* enum p54_control_frame_types */
+ u8 rts_tries;
+ u8 tries;
u8 data[0];
} __attribute__ ((packed));
=20
diff -Nurp a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p=
54/p54pci.c
--- a/drivers/net/wireless/p54/p54pci.c 2008-10-15 02:18:19.000000000 +=
0200
+++ b/drivers/net/wireless/p54/p54pci.c 2008-10-14 22:06:54.000000000 +=
0200
@@ -326,7 +326,7 @@ static void p54p_tx(struct ieee80211_hw=20
PCI_DMA_TODEVICE);
desc =3D &ring_control->tx_data[i];
desc->host_addr =3D cpu_to_le32(mapping);
- desc->device_addr =3D ((struct p54_control_hdr *)skb->data)->req_id;
+ desc->device_addr =3D ((struct p54_hdr *)skb->data)->req_id;
desc->len =3D cpu_to_le16(skb->len);
desc->flags =3D 0;
=20
diff -Nurp a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p=
54/p54usb.c
--- a/drivers/net/wireless/p54/p54usb.c 2008-10-15 02:18:19.000000000 +=
0200
+++ b/drivers/net/wireless/p54/p54usb.c 2008-10-14 22:07:39.000000000 +=
0200
@@ -230,7 +230,7 @@ static void p54u_tx_3887(struct ieee8021
=20
usb_fill_bulk_urb(addr_urb, priv->udev,
usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
- &((struct p54_control_hdr *)skb->data)->req_id, 4,
+ &((struct p54_hdr *)skb->data)->req_id, 4,
p54u_tx_cb, dev);
usb_fill_bulk_urb(data_urb, priv->udev,
usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA),
@@ -262,7 +262,7 @@ static void p54u_tx_lm87(struct ieee8021
struct urb *data_urb;
struct lm87_tx_hdr *hdr;
__le32 checksum;
- __le32 addr =3D ((struct p54_control_hdr *)skb->data)->req_id;
+ __le32 addr =3D ((struct p54_hdr *)skb->data)->req_id;
=20
data_urb =3D usb_alloc_urb(0, GFP_ATOMIC);
if (!data_urb)
@@ -313,8 +313,8 @@ static void p54u_tx_net2280(struct ieee8
=20
hdr =3D (void *)skb_push(skb, sizeof(*hdr));
memset(hdr, 0, sizeof(*hdr));
- hdr->device_addr =3D ((struct p54_control_hdr *)skb->data)->req_id;
- hdr->len =3D cpu_to_le16(skb->len + sizeof(struct p54_control_hdr));
+ hdr->device_addr =3D ((struct p54_hdr *)skb->data)->req_id;
+ hdr->len =3D cpu_to_le16(skb->len + sizeof(struct p54_hdr));
=20
usb_fill_bulk_urb(int_urb, priv->udev,
usb_sndbulkpipe(priv->udev, P54U_PIPE_DEV), reg, sizeof(*reg),


2008-10-16 21:16:03

by Christian Lamparter

[permalink] [raw]
Subject: Re: [PATCH 7/6] p54: integrate parts of lmac_longbow.h and other parts of stlc45xx

On Thursday 16 October 2008 17:46:18 Larry Finger wrote:
> The following change of ack_rssi from __le16 to u8 generates the sparse warning
> "drivers/net/wireless/p54/p54common.c:660:5: warning: cast to restricted __le16":
>
> > +struct p54_frame_sent {
> > u8 status;
> > - u8 retries;
> > - __le16 ack_rssi;
> > + u8 tries;
> > + u8 ack_rssi;
> > + u8 quality;
>
> The statement in question is:
>
> info->status.ack_signal = p54_rssi_to_dbm(dev,
> le16_to_cpu(payload->ack_rssi));
>
thanks! now I have to figure out why sparse doesn't work.?

BTW: I made a new diff for AP/AD-HOC, could you get it working with b43?

Regards,
Chr
---
diff -Nurp a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
--- a/drivers/net/wireless/p54/p54common.c 2008-10-16 23:06:55.000000000 +0200
+++ b/drivers/net/wireless/p54/p54common.c 2008-10-16 23:12:20.000000000 +0200
@@ -436,12 +436,12 @@ static int p54_parse_eeprom(struct ieee8
goto err;
}

- priv->rxhw = synth & 0x07;
+ priv->rxhw = synth & PDR_SYNTH_FRONTEND_MASK;
if (priv->rxhw == 4)
p54_init_xbow_synth(dev);
- if (!(synth & 0x40))
+ if (!(synth & PDR_SYNTH_24_GHZ_DISABLED))
dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz;
- if (!(synth & 0x80))
+ if (!(synth & PDR_SYNTH_5_GHZ_DISABLED))
dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz;

if (!is_valid_ether_addr(dev->wiphy->perm_addr)) {
@@ -626,6 +626,12 @@ static void p54_rx_frame_sent(struct iee
__skb_unlink(entry, &priv->tx_queue);
spin_unlock_irqrestore(&priv->tx_queue.lock, flags);

+ if (unlikely(entry == priv->cached_beacon)) {
+ kfree_skb(entry);
+ priv->cached_beacon = NULL;
+ goto out;
+ }
+
/*
* Clear manually, ieee80211_tx_info_clear_status would
* clear the counts too and we need them.
@@ -711,6 +717,35 @@ static void p54_rx_stats(struct ieee8021
mod_timer(&priv->stats_timer, jiffies + 5 * HZ);
}

+static void p54_rx_trap(struct ieee80211_hw *dev, struct sk_buff *skb)
+{
+ struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
+ struct p54_trap *trap = (struct p54_trap *) hdr->data;
+ u16 event = le16_to_cpu(trap->event);
+ u16 freq = le16_to_cpu(trap->frequency);
+
+ switch (event) {
+ case P54_TRAP_BEACON_TX:
+ break;
+ case P54_TRAP_RADAR:
+ printk(KERN_INFO "%s: radar (freq:%d MHz)\n",
+ wiphy_name(dev->wiphy), freq);
+ break;
+ case P54_TRAP_NO_BEACON:
+ break;
+ case P54_TRAP_SCAN:
+ break;
+ case P54_TRAP_TBTT:
+ break;
+ case P54_TRAP_TIMER:
+ break;
+ default:
+ printk(KERN_INFO "%s: received event:%x freq:%d\n",
+ wiphy_name(dev->wiphy), event, freq);
+ break;
+ }
+}
+
static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb)
{
struct p54_hdr *hdr = (struct p54_hdr *) skb->data;
@@ -719,6 +754,9 @@ static int p54_rx_control(struct ieee802
case P54_CONTROL_TYPE_TXDONE:
p54_rx_frame_sent(dev, skb);
break;
+ case P54_CONTROL_TYPE_TRAP:
+ p54_rx_trap(dev, skb);
+ break;
case P54_CONTROL_TYPE_BBP:
break;
case P54_CONTROL_TYPE_STAT_READBACK:
@@ -739,9 +777,9 @@ static int p54_rx_control(struct ieee802
/* returns zero if skb can be reused */
int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
{
- u8 type = le16_to_cpu(*((__le16 *)skb->data)) >> 8;
+ u16 type = le16_to_cpu(*((__le16 *)skb->data));

- if (type == 0x80)
+ if (type & P54_HDR_FLAG_CONTROL)
return p54_rx_control(dev, skb);
else
return p54_rx_data(dev, skb);
@@ -902,41 +940,164 @@ free:
}
EXPORT_SYMBOL_GPL(p54_read_eeprom);

+static int p54_set_tim(struct ieee80211_hw *dev, struct ieee80211_sta *sta,
+ bool set)
+{
+ struct p54_common *priv = dev->priv;
+ struct sk_buff *skb;
+ struct p54_tim *tim;
+
+ skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET,
+ sizeof(struct p54_hdr) + sizeof(*tim),
+ P54_CONTROL_TYPE_TIM, GFP_KERNEL);
+ if (!skb)
+ return -ENOMEM;
+
+ tim = (struct p54_tim *) skb_put(skb, sizeof(*tim));
+ tim->count = 1;
+ tim->entry[0] = cpu_to_le16(set ? (sta->aid | 0x8000) : sta->aid);
+ priv->tx(dev, skb, 1);
+ return 0;
+}
+
+#ifndef WLAN_FC_GET_TYPE
+#define WLAN_FC_GET_TYPE(fc) (fc & IEEE80211_FCTL_FTYPE)
+#define WLAN_FC_GET_STYPE(fc) (fc & IEEE80211_FCTL_STYPE)
+#endif
+
+static int p54_sta_unlock(struct ieee80211_hw *dev, u8 *addr)
+{
+ struct p54_common *priv = dev->priv;
+ struct sk_buff *skb;
+ struct p54_sta_unlock *sta;
+
+ skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET,
+ sizeof(struct p54_hdr) + sizeof(*sta),
+ P54_CONTROL_TYPE_PSM_STA_UNLOCK, GFP_ATOMIC);
+ if (!skb)
+ return -ENOMEM;
+
+ sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta));
+ memcpy(sta->addr, addr, ETH_ALEN);
+ priv->tx(dev, skb, 1);
+ return 0;
+}
+
+static int p54_tx_cancel(struct ieee80211_hw *dev, struct sk_buff *entry)
+{
+ struct p54_common *priv = dev->priv;
+ struct sk_buff *skb;
+ struct p54_hdr *hdr;
+ struct p54_txcancel *cancel;
+
+ skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET,
+ sizeof(struct p54_hdr) + sizeof(*cancel),
+ P54_CONTROL_TYPE_TXCANCEL, GFP_ATOMIC);
+ if (!skb)
+ return -ENOMEM;
+
+ hdr = (void *)entry->data;
+ cancel = (struct p54_txcancel *)skb_put(skb, sizeof(*cancel));
+ cancel->req_id = hdr->req_id;
+ priv->tx(dev, skb, 1);
+ return 0;
+}
+
+static int p54_tx_fill(struct ieee80211_hw *dev, struct sk_buff *skb,
+ struct ieee80211_tx_info* info, u8 *queue, size_t *extra_len,
+ u16 *flags, u16 *aid)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct p54_common *priv = dev->priv;
+ u16 fc = le16_to_cpu(hdr->frame_control);
+ int ret = 0;
+
+ if (unlikely(WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT)) {
+ switch (WLAN_FC_GET_STYPE(fc)) {
+ case IEEE80211_STYPE_BEACON:
+ *aid = 0;
+ *queue = 0;
+ *extra_len = IEEE80211_MAX_TIM_LEN;
+ *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP;
+ return 0;
+ case IEEE80211_STYPE_PROBE_RESP:
+ *aid = 0;
+ *queue = 2;
+ *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP |
+ P54_HDR_FLAG_DATA_OUT_NOCANCEL;
+ return 0;
+ default:
+ *queue = 2;
+ ret = 0;
+ }
+ } else {
+ *queue += 4;
+ ret = 1;
+ }
+
+ switch (priv->mode) {
+ case NL80211_IFTYPE_STATION:
+ *aid = 1;
+ break;
+ case NL80211_IFTYPE_AP:
+ if (is_multicast_ether_addr(hdr->addr1)) {
+ *aid = 0;
+ *queue = 3;
+ return 0;
+ }
+ case NL80211_IFTYPE_ADHOC:
+ if (info->control.sta)
+ *aid = info->control.sta->aid;
+ else
+ *flags = P54_HDR_FLAG_DATA_OUT_NOCANCEL;
+ }
+ return ret;
+}
+
static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct ieee80211_tx_queue_stats *current_queue;
+ struct ieee80211_tx_queue_stats *current_queue = NULL;
struct p54_common *priv = dev->priv;
struct p54_hdr *hdr;
struct p54_tx_data *txhdr;
- size_t padding, len;
+ size_t padding, len, tim_len;
int i, j, ridx;
- u8 rate;
+ u16 hdr_flags = 0, aid = 0;
+ u8 rate, queue;
u8 cts_rate = 0x20;
u8 rc_flags;
u8 calculated_tries[4];
u8 nrates = 0, nremaining = 8;

- current_queue = &priv->tx_stats[skb_get_queue_mapping(skb) + 4];
- if (unlikely(current_queue->len > current_queue->limit))
- return NETDEV_TX_BUSY;
- current_queue->len++;
- current_queue->count++;
- if (current_queue->len == current_queue->limit)
- ieee80211_stop_queue(dev, skb_get_queue_mapping(skb));
+ queue = skb_get_queue_mapping(skb);
+
+ if (p54_tx_fill(dev, skb, info, &queue, &tim_len, &hdr_flags, &aid)) {
+ current_queue = &priv->tx_stats[queue];
+ if (unlikely(current_queue->len > current_queue->limit))
+ return NETDEV_TX_BUSY;
+ current_queue->len++;
+ current_queue->count++;
+ if (current_queue->len == current_queue->limit)
+ ieee80211_stop_queue(dev, skb_get_queue_mapping(skb));
+ }

padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3;
len = skb->len;

+ if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) {
+ if (info->control.sta)
+ if (p54_sta_unlock(dev, info->control.sta->addr))
+ return -ENOMEM;
+ }
+
txhdr = (struct p54_tx_data *) skb_push(skb, sizeof(*txhdr) + padding);
hdr = (struct p54_hdr *) skb_push(skb, sizeof(*hdr));

if (padding)
- hdr->flags = cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN);
- else
- hdr->flags = cpu_to_le16(0);
+ hdr_flags |= P54_HDR_FLAG_DATA_ALIGN;
hdr->len = cpu_to_le16(len);
- hdr->type = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 0 : cpu_to_le16(1);
+ hdr->type = cpu_to_le16(aid);
hdr->rts_tries = info->control.rates[0].count;

/*
@@ -1003,12 +1164,18 @@ static int p54_tx(struct ieee80211_hw *d
ridx++;
}
}
+
+ if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ)
+ hdr_flags |= P54_HDR_FLAG_DATA_OUT_SEQNR;
+
+ /* TODO: enable bursting */
+ hdr->flags = cpu_to_le16(hdr_flags);
hdr->tries = ridx;
txhdr->crypt_offset = 0;
txhdr->rts_rate_idx = 0;
txhdr->key_type = 0;
txhdr->key_len = 0;
- txhdr->hw_queue = skb_get_queue_mapping(skb) + 4;
+ txhdr->hw_queue = queue;
txhdr->backlog = 32;
memset(txhdr->durations, 0, sizeof(txhdr->durations));
txhdr->tx_antenna = (info->antenna_sel_tx == 0) ?
@@ -1019,9 +1186,13 @@ static int p54_tx(struct ieee80211_hw *d
txhdr->align[0] = padding;

/* modifies skb->cb and with it info, so must be last! */
- if (unlikely(p54_assign_address(dev, skb, hdr, skb->len))) {
+ if (unlikely(p54_assign_address(dev, skb, hdr, skb->len + tim_len))) {
skb_pull(skb, sizeof(*hdr) + sizeof(*txhdr) + padding);
- return NETDEV_TX_BUSY;
+ if (current_queue) {
+ current_queue->len--;
+ current_queue->count--;
+ }
+ return -ENOMEM;
}
priv->tx(dev, skb, 0);
return 0;
@@ -1232,11 +1403,93 @@ static int p54_init_stats(struct ieee802
return 0;
}

+static int p54_beacon_tim(struct sk_buff *skb)
+{
+ /*
+ * the good excuse for this mess is ... the firmware.
+ * The dummy TIM MUST be at the end of the beacon frame,
+ * because it'll be overwritten!
+ */
+
+ struct ieee80211_mgmt *mgmt = (void *)skb->data;
+ u8 *pos, *end;
+
+ if (skb->len <= sizeof(mgmt)) {
+ printk(KERN_ERR "p54: beacon is too short!\n");
+ return -EINVAL;
+ }
+
+ pos = (u8 *)mgmt->u.beacon.variable;
+ end = skb->data + skb->len;
+ while (pos < end) {
+ if (pos + 2 + pos[1] > end) {
+ printk(KERN_ERR "p54: parsing beacon failed\n");
+ return -EINVAL;
+ }
+
+ if (pos[0] == WLAN_EID_TIM) {
+ u8 dtim_len = pos[1];
+ u8 dtim_period = pos[3];
+ u8 *next = pos + 2 + dtim_len;
+
+ if (dtim_len < 3) {
+ printk(KERN_ERR "p54: invalid dtim len!\n");
+ return -EINVAL;
+ }
+ memmove(pos, next, end - next);
+
+ if (dtim_len > 3)
+ skb_trim(skb, skb->len - (dtim_len - 3));
+
+ pos = end - (dtim_len + 2);
+
+ /* add the dummy at the end */
+ pos[0] = WLAN_EID_TIM;
+ pos[1] = 3;
+ pos[2] = 0;
+ pos[3] = dtim_period;
+ pos[4] = 0;
+ return 0;
+ }
+ pos += 2 + pos[1];
+ }
+ return 0;
+}
+
+static int p54_beacon_update(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif)
+{
+ struct p54_common *priv = dev->priv;
+ struct sk_buff *beacon;
+ int ret;
+
+ if (priv->cached_beacon) {
+ p54_tx_cancel(dev, priv->cached_beacon);
+ msleep(10);
+ }
+
+ beacon = ieee80211_beacon_get(dev, vif);
+ if (!beacon)
+ return -ENOMEM;
+ ret = p54_beacon_tim(beacon);
+ if (ret)
+ return ret;
+ ret = p54_tx(dev, beacon);
+ if (ret)
+ return ret;
+ priv->cached_beacon = beacon;
+ priv->tsf_high32 = 0;
+ priv->tsf_low32 = 0;
+
+ return 0;
+}
+
static int p54_start(struct ieee80211_hw *dev)
{
struct p54_common *priv = dev->priv;
int err;

+ mutex_lock(&priv->conf_mutex);
err = priv->open(dev);
if (!err)
priv->mode = NL80211_IFTYPE_MONITOR;
@@ -1247,7 +1500,7 @@ static int p54_start(struct ieee80211_hw
err = p54_set_edcf(dev);
if (!err)
err = p54_init_stats(dev);
-
+ mutex_unlock(&priv->conf_mutex);
return err;
}

@@ -1256,15 +1509,22 @@ static void p54_stop(struct ieee80211_hw
struct p54_common *priv = dev->priv;
struct sk_buff *skb;

+ mutex_lock(&priv->conf_mutex);
del_timer(&priv->stats_timer);
p54_free_skb(dev, priv->cached_stats);
priv->cached_stats = NULL;
+ if (priv->cached_beacon)
+ p54_tx_cancel(dev, priv->cached_beacon);
+
while ((skb = skb_dequeue(&priv->tx_queue)))
kfree_skb(skb);

+ kfree(priv->cached_beacon);
+ priv->cached_beacon = NULL;
priv->stop(dev);
priv->tsf_high32 = priv->tsf_low32 = 0;
priv->mode = NL80211_IFTYPE_UNSPECIFIED;
+ mutex_unlock(&priv->conf_mutex);
}

static int p54_add_interface(struct ieee80211_hw *dev,
@@ -1272,14 +1532,20 @@ static int p54_add_interface(struct ieee
{
struct p54_common *priv = dev->priv;

- if (priv->mode != NL80211_IFTYPE_MONITOR)
+ mutex_lock(&priv->conf_mutex);
+ if (priv->mode != NL80211_IFTYPE_MONITOR) {
+ mutex_unlock(&priv->conf_mutex);
return -EOPNOTSUPP;
+ }

switch (conf->type) {
case NL80211_IFTYPE_STATION:
+ case NL80211_IFTYPE_ADHOC:
+ case NL80211_IFTYPE_AP:
priv->mode = conf->type;
break;
default:
+ mutex_unlock(&priv->conf_mutex);
return -EOPNOTSUPP;
}

@@ -1291,6 +1557,12 @@ static int p54_add_interface(struct ieee
case NL80211_IFTYPE_STATION:
p54_setup_mac(dev, P54_FILTER_TYPE_STATION, NULL);
break;
+ case NL80211_IFTYPE_AP:
+ p54_setup_mac(dev, P54_FILTER_TYPE_AP, priv->mac_addr);
+ break;
+ case NL80211_IFTYPE_ADHOC:
+ p54_setup_mac(dev, P54_FILTER_TYPE_IBSS, NULL);
+ break;
default:
BUG(); /* impossible */
break;
@@ -1298,6 +1570,7 @@ static int p54_add_interface(struct ieee

p54_set_leds(dev, 1, 0, 0);

+ mutex_unlock(&priv->conf_mutex);
return 0;
}

@@ -1305,9 +1578,14 @@ static void p54_remove_interface(struct
struct ieee80211_if_init_conf *conf)
{
struct p54_common *priv = dev->priv;
+
+ mutex_lock(&priv->conf_mutex);
+ if (priv->cached_beacon)
+ p54_tx_cancel(dev, priv->cached_beacon);
+ p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
priv->mode = NL80211_IFTYPE_MONITOR;
memset(priv->mac_addr, 0, ETH_ALEN);
- p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
+ mutex_unlock(&priv->conf_mutex);
}

static int p54_config(struct ieee80211_hw *dev, u32 changed)
@@ -1331,13 +1609,41 @@ static int p54_config_interface(struct i
struct ieee80211_if_conf *conf)
{
struct p54_common *priv = dev->priv;
+ int ret = 0;

mutex_lock(&priv->conf_mutex);
- p54_setup_mac(dev, P54_FILTER_TYPE_STATION, conf->bssid);
- p54_set_leds(dev, 1, !is_multicast_ether_addr(conf->bssid), 0);
- memcpy(priv->bssid, conf->bssid, ETH_ALEN);
+ switch (priv->mode) {
+ case NL80211_IFTYPE_STATION:
+ ret = p54_setup_mac(dev, P54_FILTER_TYPE_STATION, conf->bssid);
+ if (ret)
+ goto out;
+ ret = p54_set_leds(dev, 1,
+ !is_multicast_ether_addr(conf->bssid), 0);
+ if (ret)
+ goto out;
+ memcpy(priv->bssid, conf->bssid, ETH_ALEN);
+ break;
+ case NL80211_IFTYPE_AP:
+ case NL80211_IFTYPE_ADHOC:
+ memcpy(priv->bssid, conf->bssid, ETH_ALEN);
+ ret = p54_set_freq(dev, dev->conf.channel->center_freq);
+ if (ret)
+ goto out;
+ ret = p54_setup_mac(dev, priv->mac_mode, priv->bssid);
+ if (ret)
+ goto out;
+ if (conf->changed & IEEE80211_IFCC_BEACON) {
+ ret = p54_beacon_update(dev, vif);
+ if (ret)
+ goto out;
+ ret = p54_set_edcf(dev);
+ if (ret)
+ goto out;
+ }
+ }
+out:
mutex_unlock(&priv->conf_mutex);
- return 0;
+ return ret;
}

static void p54_configure_filter(struct ieee80211_hw *dev,
@@ -1372,14 +1678,17 @@ static int p54_conf_tx(struct ieee80211_
const struct ieee80211_tx_queue_params *params)
{
struct p54_common *priv = dev->priv;
+ int ret;

+ mutex_lock(&priv->conf_mutex);
if ((params) && !(queue > 4)) {
P54_SET_QUEUE(priv->qos_params[queue], params->aifs,
params->cw_min, params->cw_max, params->txop);
} else
return -EINVAL;
-
- return p54_set_edcf(dev);
+ ret = p54_set_edcf(dev);
+ mutex_unlock(&priv->conf_mutex);
+ return ret;
}

static int p54_init_xbow_synth(struct ieee80211_hw *dev)
@@ -1462,6 +1771,7 @@ static const struct ieee80211_ops p54_op
.stop = p54_stop,
.add_interface = p54_add_interface,
.remove_interface = p54_remove_interface,
+ .set_tim = p54_set_tim,
.config = p54_config,
.config_interface = p54_config_interface,
.bss_info_changed = p54_bss_info_changed,
@@ -1483,8 +1793,7 @@ struct ieee80211_hw *p54_init_common(siz
priv = dev->priv;
priv->mode = NL80211_IFTYPE_UNSPECIFIED;
skb_queue_head_init(&priv->tx_queue);
- dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */
- IEEE80211_HW_RX_INCLUDES_FCS |
+ dev->flags = IEEE80211_HW_RX_INCLUDES_FCS |
IEEE80211_HW_SIGNAL_DBM |
IEEE80211_HW_NOISE_DBM;

@@ -1493,14 +1802,16 @@ struct ieee80211_hw *p54_init_common(siz
* requires beacons (AP, MESH, IBSS) then it must
* implement IEEE80211_TX_CTL_ASSIGN_SEQ.
*/
- dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
+ dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION |
+ NL80211_IFTYPE_ADHOC |
+ NL80211_IFTYPE_AP);

dev->channel_change_time = 1000; /* TODO: find actual value */
- priv->tx_stats[0].limit = 1;
- priv->tx_stats[1].limit = 1;
- priv->tx_stats[2].limit = 1;
- priv->tx_stats[3].limit = 1;
- priv->tx_stats[4].limit = 5;
+ priv->tx_stats[0].limit = 1; /* Beacon queue */
+ priv->tx_stats[1].limit = 1; /* Probe queue for HW scan */
+ priv->tx_stats[2].limit = 3; /* queue for MLMEs */
+ priv->tx_stats[3].limit = 3; /* Broadcast / MC queue */
+ priv->tx_stats[4].limit = 5; /* Data */
dev->queues = 1;
priv->noise = -94;
/*
diff -Nurp a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h
--- a/drivers/net/wireless/p54/p54common.h 2008-10-15 19:24:42.000000000 +0200
+++ b/drivers/net/wireless/p54/p54common.h 2008-10-16 22:56:34.000000000 +0200
@@ -25,6 +25,22 @@ struct bootrec {
u32 data[10];
} __attribute__((packed));

+#define PDR_SYNTH_FRONTEND_MASK 0x0007
+#define PDR_SYNTH_IQ_CAL_MASK 0x0018
+#define PDR_SYNTH_IQ_CAL_PA_DETECTOR 0x0000
+#define PDR_SYNTH_IQ_CAL_DISABLED 0x0008
+#define PDR_SYNTH_IQ_CAL_ZIF 0x0010
+#define PDR_SYNTH_FAA_SWITCH_MASK 0x0020
+#define PDR_SYNTH_FAA_SWITCH_ENABLED 0x0001
+#define PDR_SYNTH_24_GHZ_MASK 0x0040
+#define PDR_SYNTH_24_GHZ_DISABLED 0x0040
+#define PDR_SYNTH_5_GHZ_MASK 0x0080
+#define PDR_SYNTH_5_GHZ_DISABLED 0x0080
+#define PDR_SYNTH_RX_DIV_MASK 0x0100
+#define PDR_SYNTH_RX_DIV_SUPPORTED 0x0100
+#define PDR_SYNTH_TX_DIV_MASK 0x0200
+#define PDR_SYNTH_TX_DIV_SUPPORTED 0x0200
+
struct bootrec_exp_if {
__le16 role;
__le16 if_id;
@@ -210,6 +226,19 @@ struct pda_pa_curve_data {
#define PDR_BASEBAND_REGISTERS 0x8000
#define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001

+/* PDR definitions for default country & country list */
+#define PDR_COUNTRY_CERT_CODE 0x80
+#define PDR_COUNTRY_CERT_CODE_REAL 0x00
+#define PDR_COUNTRY_CERT_CODE_PSEUDO 0x80
+#define PDR_COUNTRY_CERT_BAND 0x40
+#define PDR_COUNTRY_CERT_BAND_2GHZ 0x00
+#define PDR_COUNTRY_CERT_BAND_5GHZ 0x40
+#define PDR_COUNTRY_CERT_IODOOR 0x30
+#define PDR_COUNTRY_CERT_IODOOR_BOTH 0x00
+#define PDR_COUNTRY_CERT_IODOOR_INDOOR 0x20
+#define PDR_COUNTRY_CERT_IODOOR_OUTDOOR 0x30
+#define PDR_COUNTRY_CERT_INDEX 0x0F
+
/* stored in skb->cb */
struct memrecord {
u32 start_addr;
@@ -507,7 +536,7 @@ struct p54_sta_unlock {
} __attribute__ ((packed));

#define P54_TIM_CLEAR BIT(15)
-struct p54_tx_control_tim {
+struct p54_tim {
u8 count;
u8 padding[3];
__le16 entry[8];
diff -Nurp a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
--- a/drivers/net/wireless/p54/p54.h 2008-10-15 19:24:42.000000000 +0200
+++ b/drivers/net/wireless/p54/p54.h 2008-10-16 23:12:48.000000000 +0200
@@ -108,6 +108,7 @@ struct p54_common {
struct timer_list stats_timer;
struct completion stats_comp;
struct sk_buff *cached_stats;
+ struct sk_buff *cached_beacon;
int noise;
void *eeprom;
struct completion eeprom_comp;

2008-10-17 00:35:56

by Harvey Harrison

[permalink] [raw]
Subject: Re: [PATCH 7/6] p54: integrate parts of lmac_longbow.h and other parts of stlc45xx

On Thu, 2008-10-16 at 23:20 +0200, Christian Lamparter wrote:
> On Thursday 16 October 2008 17:46:18 Larry Finger wrote:
> > The following change of ack_rssi from __le16 to u8 generates the sparse warning
> > "drivers/net/wireless/p54/p54common.c:660:5: warning: cast to restricted __le16":
> >

> @@ -739,9 +777,9 @@ static int p54_rx_control(struct ieee802
> /* returns zero if skb can be reused */
> int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
> {
> - u8 type = le16_to_cpu(*((__le16 *)skb->data)) >> 8;
> + u16 type = le16_to_cpu(*((__le16 *)skb->data));

u16 type = le16_to_cpup((__le16 *)skb->data);

> +
> +#ifndef WLAN_FC_GET_TYPE
> +#define WLAN_FC_GET_TYPE(fc) (fc & IEEE80211_FCTL_FTYPE)
> +#define WLAN_FC_GET_STYPE(fc) (fc & IEEE80211_FCTL_STYPE)
> +#endif
> +

Suggest you look into some of the helpers in ieee80211.h

> +
> +static int p54_tx_fill(struct ieee80211_hw *dev, struct sk_buff *skb,
> + struct ieee80211_tx_info* info, u8 *queue, size_t *extra_len,
> + u16 *flags, u16 *aid)
> +{
> + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
> + struct p54_common *priv = dev->priv;
> + u16 fc = le16_to_cpu(hdr->frame_control);

__le16 fc = hdr->frame_control;

> + int ret = 0;
> +
> + if (unlikely(WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT)) {

ieee80211_is_mgmt(fc);

> + switch (WLAN_FC_GET_STYPE(fc)) {

Not sure what the prevailing wisdom is here, switch to if /else if using
the helpers ieee80211_is_beacon(fc), ieee80211_is_probe_resp to do
compile-time byteswaps.

or
switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)
case cpu_to_le16(IEEE80211_STYPE_BEACON):

etc.

> + case IEEE80211_STYPE_BEACON:
> + *aid = 0;
> + *queue = 0;
> + *extra_len = IEEE80211_MAX_TIM_LEN;
> + *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP;
> + return 0;
> + case IEEE80211_STYPE_PROBE_RESP:
> + *aid = 0;
> + *queue = 2;
> + *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP |
> + P54_HDR_FLAG_DATA_OUT_NOCANCEL;
> + return 0;
> + default:
> + *queue = 2;
> + ret = 0;

return?

Cheers,

Harvey


2008-10-16 15:46:18

by Larry Finger

[permalink] [raw]
Subject: Re: [PATCH 6/6] p54: integrate parts of lmac_longbow.h and other parts of stlc45xx

Christian Lamparter wrote:
> This patch removes most/all? of the "magic" numbers and unknown structure
> variables inside the code and replaces them with meaningful prototypes.
>
> Signed-off-by: Christian Lamparter <[email protected]>
> ---

The following change of ack_rssi from __le16 to u8 generates the sparse warning
"drivers/net/wireless/p54/p54common.c:660:5: warning: cast to restricted __le16":

> +struct p54_frame_sent {
> u8 status;
> - u8 retries;
> - __le16 ack_rssi;
> + u8 tries;
> + u8 ack_rssi;
> + u8 quality;

The statement in question is:

info->status.ack_signal = p54_rssi_to_dbm(dev,
le16_to_cpu(payload->ack_rssi));

The following patch fixes the warning:

Index: wireless-testing/drivers/net/wireless/p54/p54common.c
===================================================================
--- wireless-testing.orig/drivers/net/wireless/p54/p54common.c
+++ wireless-testing/drivers/net/wireless/p54/p54common.c
@@ -657,7 +657,7 @@ static void p54_rx_frame_sent(struct iee
if (payload->status & 0x02)
info->flags |= IEEE80211_TX_STAT_TX_FILTERED;
info->status.ack_signal = p54_rssi_to_dbm(dev,
- le16_to_cpu(payload->ack_rssi));
+ (int)payload->ack_rssi);
skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
ieee80211_tx_status_irqsafe(dev, entry);
goto out;

Larry



2008-10-17 01:12:57

by Christian Lamparter

[permalink] [raw]
Subject: Re: [PATCH 7/6] p54: integrate parts of lmac_longbow.h and other parts of stlc45xx

On Friday 17 October 2008 00:30:21 Harvey Harrison wrote:
> On Thu, 2008-10-16 at 23:20 +0200, Christian Lamparter wrote:
> > On Thursday 16 October 2008 17:46:18 Larry Finger wrote:
> > > The following change of ack_rssi from __le16 to u8 generates the sparse warning
> > > "drivers/net/wireless/p54/p54common.c:660:5: warning: cast to restricted __le16":
> > >
>
> > @@ -739,9 +777,9 @@ static int p54_rx_control(struct ieee802
> > /* returns zero if skb can be reused */
> > int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb)
> > {
> > - u8 type = le16_to_cpu(*((__le16 *)skb->data)) >> 8;
> > + u16 type = le16_to_cpu(*((__le16 *)skb->data));
>
> u16 type = le16_to_cpup((__le16 *)skb->data);
>
should be fixed in [PATCH 1/3] p54: more definitions form lmac_longbow.h and pda.h
> > +
> > +#ifndef WLAN_FC_GET_TYPE
> > +#define WLAN_FC_GET_TYPE(fc) (fc & IEEE80211_FCTL_FTYPE)
> > +#define WLAN_FC_GET_STYPE(fc) (fc & IEEE80211_FCTL_STYPE)
> > +#endif
> > +
>
> Suggest you look into some of the helpers in ieee80211.h
ohh well, I could have updated that code ;-)
>
> > +
> > +static int p54_tx_fill(struct ieee80211_hw *dev, struct sk_buff *skb,
> > + struct ieee80211_tx_info* info, u8 *queue, size_t *extra_len,
> > + u16 *flags, u16 *aid)
> > +{
> > + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
> > + struct p54_common *priv = dev->priv;
> > + u16 fc = le16_to_cpu(hdr->frame_control);
>
> __le16 fc = hdr->frame_control;
>
> > + int ret = 0;
> > +
> > + if (unlikely(WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT)) {
>
> ieee80211_is_mgmt(fc);
>
> > + switch (WLAN_FC_GET_STYPE(fc)) {
>
> Not sure what the prevailing wisdom is here, switch to if /else if using
> the helpers ieee80211_is_beacon(fc), ieee80211_is_probe_resp to do
> compile-time byteswaps.
>
> or
> switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)
> case cpu_to_le16(IEEE80211_STYPE_BEACON):
>
> etc.
k!
>
> > + case IEEE80211_STYPE_BEACON:
> > + *aid = 0;
> > + *queue = 0;
> > + *extra_len = IEEE80211_MAX_TIM_LEN;
> > + *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP;
> > + return 0;
> > + case IEEE80211_STYPE_PROBE_RESP:
> > + *aid = 0;
> > + *queue = 2;
> > + *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP |
> > + P54_HDR_FLAG_DATA_OUT_NOCANCEL;
> > + return 0;
> > + default:
> > + *queue = 2;
> > + ret = 0;
>
> return?
return?
p54 has 8 queues:
- 4 WME queues which neatly fit into mac80211's concept... (that's when we return 1)
- the other 4 don't. that's when we return 0.
(otherwise, we won't stop the WME queue for no reason)

Thanks,
Chr