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

p54: set_filter refactoring

p54_set_filter has a way too many unnecessary "magic" parameters and values.
This patch axes all superfluous parameters and gives most of the magic values appropriate names.
Signed-off-by: default avatarChristian Lamparter <chunkeey@web.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 0b7dcd96
...@@ -63,6 +63,7 @@ struct p54_common { ...@@ -63,6 +63,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;
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;
...@@ -70,6 +71,7 @@ struct p54_common { ...@@ -70,6 +71,7 @@ struct p54_common {
struct pda_pa_curve_data *curve_data; struct pda_pa_curve_data *curve_data;
u16 rxhw; u16 rxhw;
u8 version; u8 version;
u8 rx_antenna;
unsigned int tx_hdr_len; unsigned int tx_hdr_len;
void *cached_vdcf; void *cached_vdcf;
unsigned int fw_var; unsigned int fw_var;
......
...@@ -786,8 +786,7 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb) ...@@ -786,8 +786,7 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
} }
static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type, static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type,
const u8 *dst, const u8 *src, u8 antenna, const u8 *bssid)
u32 magic3, u32 magic8, u32 magic9)
{ {
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
struct p54_control_hdr *hdr; struct p54_control_hdr *hdr;
...@@ -806,19 +805,19 @@ static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type, ...@@ -806,19 +805,19 @@ static int p54_set_filter(struct ieee80211_hw *dev, u16 filter_type,
p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*filter)); p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*filter));
hdr->type = cpu_to_le16(P54_CONTROL_TYPE_FILTER_SET); hdr->type = cpu_to_le16(P54_CONTROL_TYPE_FILTER_SET);
filter->filter_type = cpu_to_le16(filter_type); priv->filter_type = filter->filter_type = cpu_to_le16(filter_type);
memcpy(filter->dst, dst, ETH_ALEN); memcpy(filter->mac_addr, priv->mac_addr, ETH_ALEN);
if (!src) if (!bssid)
memset(filter->src, ~0, ETH_ALEN); memset(filter->bssid, ~0, ETH_ALEN);
else else
memcpy(filter->src, src, ETH_ALEN); memcpy(filter->bssid, bssid, ETH_ALEN);
filter->antenna = antenna;
filter->magic3 = cpu_to_le32(magic3); filter->rx_antenna = priv->rx_antenna;
filter->basic_rate_mask = cpu_to_le32(0x15F);
filter->rx_addr = cpu_to_le32(priv->rx_end); filter->rx_addr = cpu_to_le32(priv->rx_end);
filter->max_rx = cpu_to_le16(priv->rx_mtu); filter->max_rx = cpu_to_le16(priv->rx_mtu);
filter->rxhw = cpu_to_le16(priv->rxhw); filter->rxhw = cpu_to_le16(priv->rxhw);
filter->magic8 = cpu_to_le16(magic8); filter->wakeup_timer = cpu_to_le16(500);
filter->magic9 = cpu_to_le16(magic9);
priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*filter), 1); priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*filter), 1);
return 0; return 0;
...@@ -1044,12 +1043,11 @@ static int p54_add_interface(struct ieee80211_hw *dev, ...@@ -1044,12 +1043,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, priv->mac_addr, NULL, 0, 1, 0, 0xF642); p54_set_filter(dev, 0, NULL);
p54_set_filter(dev, 0, priv->mac_addr, NULL, 1, 0, 0, 0xF642);
switch (conf->type) { switch (conf->type) {
case IEEE80211_IF_TYPE_STA: case IEEE80211_IF_TYPE_STA:
p54_set_filter(dev, 1, priv->mac_addr, NULL, 0, 0x15F, 0x1F4, 0); p54_set_filter(dev, 1, NULL);
break; break;
default: default:
BUG(); /* impossible */ BUG(); /* impossible */
...@@ -1067,7 +1065,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev, ...@@ -1067,7 +1065,7 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
priv->mode = IEEE80211_IF_TYPE_MNTR; priv->mode = IEEE80211_IF_TYPE_MNTR;
memset(priv->mac_addr, 0, ETH_ALEN); memset(priv->mac_addr, 0, ETH_ALEN);
p54_set_filter(dev, 0, priv->mac_addr, NULL, 2, 0, 0, 0); p54_set_filter(dev, 0, NULL);
} }
static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
...@@ -1076,6 +1074,8 @@ static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf) ...@@ -1076,6 +1074,8 @@ static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
mutex_lock(&priv->conf_mutex); mutex_lock(&priv->conf_mutex);
priv->rx_antenna = (conf->antenna_sel_rx == 0) ?
2 : conf->antenna_sel_tx - 1;
ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq)); ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq));
p54_set_vdcf(dev); p54_set_vdcf(dev);
mutex_unlock(&priv->conf_mutex); mutex_unlock(&priv->conf_mutex);
...@@ -1089,8 +1089,7 @@ static int p54_config_interface(struct ieee80211_hw *dev, ...@@ -1089,8 +1089,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, priv->mac_addr, conf->bssid, 0, 1, 0, 0xF642); p54_set_filter(dev, 0, conf->bssid);
p54_set_filter(dev, 0, priv->mac_addr, conf->bssid, 2, 0, 0, 0);
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);
...@@ -1108,11 +1107,9 @@ static void p54_configure_filter(struct ieee80211_hw *dev, ...@@ -1108,11 +1107,9 @@ 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, 0, priv->mac_addr, p54_set_filter(dev, 0, NULL);
NULL, 2, 0, 0, 0);
else else
p54_set_filter(dev, 0, priv->mac_addr, p54_set_filter(dev, 0, priv->bssid);
priv->bssid, 2, 0, 0, 0);
} }
} }
......
...@@ -214,17 +214,17 @@ struct p54_tx_control_allocdata { ...@@ -214,17 +214,17 @@ struct p54_tx_control_allocdata {
struct p54_tx_control_filter { struct p54_tx_control_filter {
__le16 filter_type; __le16 filter_type;
u8 dst[ETH_ALEN]; u8 mac_addr[ETH_ALEN];
u8 src[ETH_ALEN]; u8 bssid[ETH_ALEN];
u8 antenna; u8 rx_antenna;
u8 debug; u8 rx_align;
__le32 magic3; __le32 basic_rate_mask;
u8 rates[8]; // FIXME: what's this for? u8 rts_rates[8];
__le32 rx_addr; __le32 rx_addr;
__le16 max_rx; __le16 max_rx;
__le16 rxhw; __le16 rxhw;
__le16 magic8; __le16 wakeup_timer;
__le16 magic9; __le16 unalloc;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct p54_tx_control_channel { struct p54_tx_control_channel {
......
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