Commit 5e73444e authored by Christian Lamparter's avatar Christian Lamparter Committed by John W. Linville

p54: borrow some setup code from stlc45xx

This patch initialize all remaining values which are necessary for
SPI firmwares.
Signed-off-by: default avatarChristian Lamparter <chunkeey@web.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b92f30d6
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
enum control_frame_types { enum control_frame_types {
P54_CONTROL_TYPE_FILTER_SET = 0, P54_CONTROL_TYPE_SETUP = 0,
P54_CONTROL_TYPE_CHANNEL_CHANGE, P54_CONTROL_TYPE_CHANNEL_CHANGE,
P54_CONTROL_TYPE_FREQDONE, P54_CONTROL_TYPE_FREQDONE,
P54_CONTROL_TYPE_DCFINIT, P54_CONTROL_TYPE_DCFINIT,
...@@ -80,7 +80,7 @@ struct p54_common { ...@@ -80,7 +80,7 @@ struct p54_common {
struct mutex conf_mutex; struct mutex conf_mutex;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
__le16 filter_type; u16 mac_mode;
struct pda_iq_autocal_entry *iq_autocal; struct pda_iq_autocal_entry *iq_autocal;
unsigned int iq_autocal_len; unsigned int iq_autocal_len;
struct pda_channel_output_limit *output_limit; struct pda_channel_output_limit *output_limit;
......
...@@ -1018,43 +1018,48 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb) ...@@ -1018,43 +1018,48 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
return 0; return 0;
} }
static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type, static int p54_setup_mac(struct ieee80211_hw *dev, u16 mode, const u8 *bssid)
const u8 *bssid)
{ {
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
struct sk_buff *skb; struct sk_buff *skb;
struct p54_tx_control_filter *filter; struct p54_setup_mac *setup;
u16 data_len = sizeof(struct p54_control_hdr) + sizeof(*filter);
if (priv->fw_var < 0x500) skb = p54_alloc_skb(dev, 0x8001, sizeof(struct p54_control_hdr) +
data_len += P54_TX_CONTROL_FILTER_V1_LEN; sizeof(*setup), P54_CONTROL_TYPE_SETUP,
else
data_len += P54_TX_CONTROL_FILTER_V2_LEN;
skb = p54_alloc_skb(dev, 0x8001, data_len, P54_CONTROL_TYPE_FILTER_SET,
GFP_ATOMIC); GFP_ATOMIC);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
filter = (struct p54_tx_control_filter *) skb_put(skb, sizeof(*filter)); setup = (struct p54_setup_mac *) skb_put(skb, sizeof(*setup));
filter->filter_type = priv->filter_type = cpu_to_le16(filter_type); priv->mac_mode = mode;
memcpy(filter->mac_addr, priv->mac_addr, ETH_ALEN); setup->mac_mode = cpu_to_le16(mode);
memcpy(setup->mac_addr, priv->mac_addr, ETH_ALEN);
if (!bssid) if (!bssid)
memset(filter->bssid, ~0, ETH_ALEN); memset(setup->bssid, ~0, ETH_ALEN);
else else
memcpy(filter->bssid, bssid, ETH_ALEN); memcpy(setup->bssid, bssid, ETH_ALEN);
filter->rx_antenna = priv->rx_antenna; setup->rx_antenna = priv->rx_antenna;
if (priv->fw_var < 0x500) { if (priv->fw_var < 0x500) {
filter->v1.basic_rate_mask = cpu_to_le32(0x15f); setup->v1.basic_rate_mask = cpu_to_le32(0x15f);
filter->v1.rx_addr = cpu_to_le32(priv->rx_end); setup->v1.rx_addr = cpu_to_le32(priv->rx_end);
filter->v1.max_rx = cpu_to_le16(priv->rx_mtu); setup->v1.max_rx = cpu_to_le16(priv->rx_mtu);
filter->v1.rxhw = cpu_to_le16(priv->rxhw); setup->v1.rxhw = cpu_to_le16(priv->rxhw);
filter->v1.wakeup_timer = cpu_to_le16(500); setup->v1.wakeup_timer = cpu_to_le16(500);
setup->v1.unalloc0 = cpu_to_le16(0);
} else { } else {
filter->v2.rx_addr = cpu_to_le32(priv->rx_end); setup->v2.rx_addr = cpu_to_le32(priv->rx_end);
filter->v2.max_rx = cpu_to_le16(priv->rx_mtu); setup->v2.max_rx = cpu_to_le16(priv->rx_mtu);
filter->v2.rxhw = cpu_to_le16(priv->rxhw); setup->v2.rxhw = cpu_to_le16(priv->rxhw);
filter->v2.timer = cpu_to_le16(1000); setup->v2.timer = cpu_to_le16(1000);
setup->v2.truncate = cpu_to_le16(48896);
setup->v2.basic_rate_mask = cpu_to_le32(0x15f);
setup->v2.sbss_offset = 0;
setup->v2.mcast_window = 0;
setup->v2.rx_rssi_threshold = 0;
setup->v2.rx_ed_threshold = 0;
setup->v2.ref_clock = cpu_to_le32(644245094);
setup->v2.lpf_bandwidth = cpu_to_le16(65535);
setup->v2.osc_start_delay = cpu_to_le16(65535);
} }
priv->tx(dev, skb, 1); priv->tx(dev, skb, 1);
return 0; return 0;
...@@ -1272,11 +1277,11 @@ static int p54_add_interface(struct ieee80211_hw *dev, ...@@ -1272,11 +1277,11 @@ static int p54_add_interface(struct ieee80211_hw *dev,
memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN);
p54_set_filter(dev, 0, NULL); p54_setup_mac(dev, 0, NULL);
switch (conf->type) { switch (conf->type) {
case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_STATION:
p54_set_filter(dev, 1, NULL); p54_setup_mac(dev, 1, NULL);
break; break;
default: default:
BUG(); /* impossible */ BUG(); /* impossible */
...@@ -1294,7 +1299,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev, ...@@ -1294,7 +1299,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
priv->mode = NL80211_IFTYPE_MONITOR; priv->mode = NL80211_IFTYPE_MONITOR;
memset(priv->mac_addr, 0, ETH_ALEN); memset(priv->mac_addr, 0, ETH_ALEN);
p54_set_filter(dev, 0, NULL); p54_setup_mac(dev, 0, NULL);
} }
static int p54_config(struct ieee80211_hw *dev, u32 changed) static int p54_config(struct ieee80211_hw *dev, u32 changed)
...@@ -1320,7 +1325,7 @@ static int p54_config_interface(struct ieee80211_hw *dev, ...@@ -1320,7 +1325,7 @@ static int p54_config_interface(struct ieee80211_hw *dev,
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
mutex_lock(&priv->conf_mutex); mutex_lock(&priv->conf_mutex);
p54_set_filter(dev, 0, conf->bssid); p54_setup_mac(dev, 0, conf->bssid);
p54_set_leds(dev, 1, !is_multicast_ether_addr(conf->bssid), 0); p54_set_leds(dev, 1, !is_multicast_ether_addr(conf->bssid), 0);
memcpy(priv->bssid, conf->bssid, ETH_ALEN); memcpy(priv->bssid, conf->bssid, ETH_ALEN);
mutex_unlock(&priv->conf_mutex); mutex_unlock(&priv->conf_mutex);
...@@ -1342,20 +1347,16 @@ static void p54_configure_filter(struct ieee80211_hw *dev, ...@@ -1342,20 +1347,16 @@ static void p54_configure_filter(struct ieee80211_hw *dev,
if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
if (*total_flags & FIF_BCN_PRBRESP_PROMISC) if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
p54_set_filter(dev, le16_to_cpu(priv->filter_type), p54_setup_mac(dev, priv->mac_mode, NULL);
NULL);
else else
p54_set_filter(dev, le16_to_cpu(priv->filter_type), p54_setup_mac(dev, priv->mac_mode, priv->bssid);
priv->bssid);
} }
if (changed_flags & FIF_PROMISC_IN_BSS) { if (changed_flags & FIF_PROMISC_IN_BSS) {
if (*total_flags & FIF_PROMISC_IN_BSS) if (*total_flags & FIF_PROMISC_IN_BSS)
p54_set_filter(dev, le16_to_cpu(priv->filter_type) | p54_setup_mac(dev, priv->mac_mode | 0x8, NULL);
0x8, NULL);
else else
p54_set_filter(dev, le16_to_cpu(priv->filter_type) & p54_setup_mac(dev, priv->mac_mode & ~0x8, priv->bssid);
~0x8, priv->bssid);
} }
} }
......
...@@ -219,8 +219,8 @@ struct p54_tx_control_allocdata { ...@@ -219,8 +219,8 @@ struct p54_tx_control_allocdata {
u8 align[0]; u8 align[0];
} __attribute__ ((packed)); } __attribute__ ((packed));
struct p54_tx_control_filter { struct p54_setup_mac {
__le16 filter_type; __le16 mac_mode;
u8 mac_addr[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
u8 rx_antenna; u8 rx_antenna;
...@@ -240,15 +240,19 @@ struct p54_tx_control_filter { ...@@ -240,15 +240,19 @@ struct p54_tx_control_filter {
__le16 max_rx; __le16 max_rx;
__le16 rxhw; __le16 rxhw;
__le16 timer; __le16 timer;
__le16 unalloc0; __le16 truncate;
__le32 unalloc1; __le32 basic_rate_mask;
u8 sbss_offset;
u8 mcast_window;
u8 rx_rssi_threshold;
u8 rx_ed_threshold;
__le32 ref_clock;
__le16 lpf_bandwidth;
__le16 osc_start_delay;
} v2 __attribute__ ((packed)); } v2 __attribute__ ((packed));
} __attribute__ ((packed)); } __attribute__ ((packed));
} __attribute__ ((packed)); } __attribute__ ((packed));
#define P54_TX_CONTROL_FILTER_V1_LEN (sizeof(struct p54_tx_control_filter))
#define P54_TX_CONTROL_FILTER_V2_LEN (sizeof(struct p54_tx_control_filter)-8)
struct p54_tx_control_channel { struct p54_tx_control_channel {
__le16 flags; __le16 flags;
__le16 dwell; __le16 dwell;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment