Skip to content

Commit a185045

Browse files
smolorzlinvjw
authored andcommitted
at76c50x-usb: Extract bssid from authentication frame
The driver at76c50x-usb is unable to authenticate with an AP since kernel 2.6.31 for the following reason: The join command of the firmware needs to be sent with the right bssid before any transmission can start. Before kernel 2.6.31 mac80211 informed its drivers about the changing bssid early enough for at76c50x-usb but during the development of 2.6.31 mac80211's behaviour changed. Now a new bssid is set after the association. This patch changes the tx routine of the driver at76c50x-usb in such a way that a new bssid is extracted from an authentication frame and the join command with that bssid is processed. Signed-off-by: Sebastian Smolorz <sesmo@gmx.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 41b4b28 commit a185045

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎drivers/net/wireless/at76c50x-usb.c‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com>
88
* Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org>
99
* Copyright (c) 2007 Kalle Valo <kalle.valo@iki.fi>
10+
* Copyright (c) 2010 Sebastian Smolorz <sesmo@gmx.net>
1011
*
1112
* This program is free software; you can redistribute it and/or
1213
* modify it under the terms of the GNU General Public License as
@@ -1685,6 +1686,22 @@ static int at76_join(struct at76_priv *priv)
16851686
return 0;
16861687
}
16871688

1689+
static void at76_work_join_bssid(struct work_struct *work)
1690+
{
1691+
struct at76_priv *priv = container_of(work, struct at76_priv,
1692+
work_join_bssid);
1693+
1694+
if (priv->device_unplugged)
1695+
return;
1696+
1697+
mutex_lock(&priv->mtx);
1698+
1699+
if (is_valid_ether_addr(priv->bssid))
1700+
at76_join(priv);
1701+
1702+
mutex_unlock(&priv->mtx);
1703+
}
1704+
16881705
static void at76_mac80211_tx_callback(struct urb *urb)
16891706
{
16901707
struct at76_priv *priv = urb->context;
@@ -1722,6 +1739,7 @@ static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
17221739
struct at76_priv *priv = hw->priv;
17231740
struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer;
17241741
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
1742+
struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
17251743
int padding, submit_len, ret;
17261744

17271745
at76_dbg(DBG_MAC80211, "%s()", __func__);
@@ -1732,6 +1750,21 @@ static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
17321750
return NETDEV_TX_BUSY;
17331751
}
17341752

1753+
/* The following code lines are important when the device is going to
1754+
* authenticate with a new bssid. The driver must send CMD_JOIN before
1755+
* an authentication frame is transmitted. For this to succeed, the
1756+
* correct bssid of the AP must be known. As mac80211 does not inform
1757+
* drivers about the bssid prior to the authentication process the
1758+
* following workaround is necessary. If the TX frame is an
1759+
* authentication frame extract the bssid and send the CMD_JOIN. */
1760+
if (mgmt->frame_control & cpu_to_le16(IEEE80211_STYPE_AUTH)) {
1761+
if (compare_ether_addr(priv->bssid, mgmt->bssid)) {
1762+
memcpy(priv->bssid, mgmt->bssid, ETH_ALEN);
1763+
ieee80211_queue_work(hw, &priv->work_join_bssid);
1764+
return NETDEV_TX_BUSY;
1765+
}
1766+
}
1767+
17351768
ieee80211_stop_queues(hw);
17361769

17371770
at76_ledtrig_tx_activity(); /* tell ledtrigger we send a packet */
@@ -1806,6 +1839,7 @@ static void at76_mac80211_stop(struct ieee80211_hw *hw)
18061839
at76_dbg(DBG_MAC80211, "%s()", __func__);
18071840

18081841
cancel_delayed_work(&priv->dwork_hw_scan);
1842+
cancel_work_sync(&priv->work_join_bssid);
18091843
cancel_work_sync(&priv->work_set_promisc);
18101844

18111845
mutex_lock(&priv->mtx);
@@ -2107,6 +2141,7 @@ static struct at76_priv *at76_alloc_new_device(struct usb_device *udev)
21072141
mutex_init(&priv->mtx);
21082142
INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc);
21092143
INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx);
2144+
INIT_WORK(&priv->work_join_bssid, at76_work_join_bssid);
21102145
INIT_DELAYED_WORK(&priv->dwork_hw_scan, at76_dwork_hw_scan);
21112146

21122147
tasklet_init(&priv->rx_tasklet, at76_rx_tasklet, 0);
@@ -2508,5 +2543,6 @@ MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>");
25082543
MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>");
25092544
MODULE_AUTHOR("Guido Guenther <agx@sigxcpu.org>");
25102545
MODULE_AUTHOR("Kalle Valo <kalle.valo@iki.fi>");
2546+
MODULE_AUTHOR("Sebastian Smolorz <sesmo@gmx.net>");
25112547
MODULE_DESCRIPTION(DRIVER_DESC);
25122548
MODULE_LICENSE("GPL");

‎drivers/net/wireless/at76c50x-usb.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ struct at76_priv {
387387
/* work queues */
388388
struct work_struct work_set_promisc;
389389
struct work_struct work_submit_rx;
390+
struct work_struct work_join_bssid;
390391
struct delayed_work dwork_hw_scan;
391392

392393
struct tasklet_struct rx_tasklet;

0 commit comments

Comments
 (0)