2007-09-26 04:57:13 +04:00
|
|
|
/*
|
2009-11-08 18:39:55 +03:00
|
|
|
Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
|
2007-09-26 04:57:13 +04:00
|
|
|
<http://rt2x00.serialmonkey.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the
|
|
|
|
Free Software Foundation, Inc.,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Module: rt2x00mac
|
|
|
|
Abstract: rt2x00 generic mac80211 routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include "rt2x00.h"
|
|
|
|
#include "rt2x00lib.h"
|
|
|
|
|
|
|
|
static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev,
|
2008-02-06 00:42:23 +03:00
|
|
|
struct data_queue *queue,
|
2008-05-15 14:55:29 +04:00
|
|
|
struct sk_buff *frag_skb)
|
2007-09-26 04:57:13 +04:00
|
|
|
{
|
2008-05-15 14:55:29 +04:00
|
|
|
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(frag_skb);
|
|
|
|
struct ieee80211_tx_info *rts_info;
|
2007-09-26 04:57:13 +04:00
|
|
|
struct sk_buff *skb;
|
2008-08-04 18:37:44 +04:00
|
|
|
unsigned int data_length;
|
2008-07-23 21:17:01 +04:00
|
|
|
int retval = 0;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-10-21 14:40:02 +04:00
|
|
|
if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
|
2008-08-04 18:37:44 +04:00
|
|
|
data_length = sizeof(struct ieee80211_cts);
|
2007-09-26 04:57:13 +04:00
|
|
|
else
|
2008-08-04 18:37:44 +04:00
|
|
|
data_length = sizeof(struct ieee80211_rts);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-08-04 18:37:44 +04:00
|
|
|
skb = dev_alloc_skb(data_length + rt2x00dev->hw->extra_tx_headroom);
|
2008-07-23 21:17:01 +04:00
|
|
|
if (unlikely(!skb)) {
|
2007-09-26 04:57:13 +04:00
|
|
|
WARNING(rt2x00dev, "Failed to create RTS/CTS frame.\n");
|
2008-07-23 21:17:01 +04:00
|
|
|
return -ENOMEM;
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
skb_reserve(skb, rt2x00dev->hw->extra_tx_headroom);
|
2008-08-04 18:37:44 +04:00
|
|
|
skb_put(skb, data_length);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-05-15 14:55:29 +04:00
|
|
|
/*
|
|
|
|
* Copy TX information over from original frame to
|
|
|
|
* RTS/CTS frame. Note that we set the no encryption flag
|
|
|
|
* since we don't want this frame to be encrypted.
|
|
|
|
* RTS frames should be acked, while CTS-to-self frames
|
|
|
|
* should not. The ready for TX flag is cleared to prevent
|
|
|
|
* it being automatically send when the descriptor is
|
|
|
|
* written to the hardware.
|
|
|
|
*/
|
|
|
|
memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb));
|
|
|
|
rts_info = IEEE80211_SKB_CB(skb);
|
2008-10-21 14:40:02 +04:00
|
|
|
rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_RTS_CTS;
|
|
|
|
rts_info->control.rates[0].flags &= ~IEEE80211_TX_RC_USE_CTS_PROTECT;
|
2008-05-15 14:55:29 +04:00
|
|
|
|
2008-10-21 14:40:02 +04:00
|
|
|
if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
|
2008-05-15 14:55:29 +04:00
|
|
|
rts_info->flags |= IEEE80211_TX_CTL_NO_ACK;
|
|
|
|
else
|
|
|
|
rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK;
|
|
|
|
|
2009-06-16 22:46:45 +04:00
|
|
|
/* Disable hardware encryption */
|
|
|
|
rts_info->control.hw_key = NULL;
|
2008-08-04 18:37:44 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RTS/CTS frame should use the length of the frame plus any
|
|
|
|
* encryption overhead that will be added by the hardware.
|
|
|
|
*/
|
2008-12-20 12:58:33 +03:00
|
|
|
data_length += rt2x00crypto_tx_overhead(rt2x00dev, skb);
|
2008-08-04 18:37:44 +04:00
|
|
|
|
2008-10-21 14:40:02 +04:00
|
|
|
if (tx_info->control.rates[0].flags & IEEE80211_TX_RC_USE_CTS_PROTECT)
|
2008-05-15 14:55:29 +04:00
|
|
|
ieee80211_ctstoself_get(rt2x00dev->hw, tx_info->control.vif,
|
2008-08-04 18:37:44 +04:00
|
|
|
frag_skb->data, data_length, tx_info,
|
2007-09-26 04:57:13 +04:00
|
|
|
(struct ieee80211_cts *)(skb->data));
|
|
|
|
else
|
2008-05-15 14:55:29 +04:00
|
|
|
ieee80211_rts_get(rt2x00dev->hw, tx_info->control.vif,
|
2008-08-04 18:37:44 +04:00
|
|
|
frag_skb->data, data_length, tx_info,
|
2007-09-26 04:57:13 +04:00
|
|
|
(struct ieee80211_rts *)(skb->data));
|
|
|
|
|
2009-11-19 03:08:30 +03:00
|
|
|
retval = rt2x00queue_write_tx_frame(queue, skb, true);
|
2008-07-23 21:17:01 +04:00
|
|
|
if (retval) {
|
2008-07-20 20:03:58 +04:00
|
|
|
dev_kfree_skb_any(skb);
|
2007-09-26 04:57:13 +04:00
|
|
|
WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n");
|
|
|
|
}
|
|
|
|
|
2008-07-23 21:17:01 +04:00
|
|
|
return retval;
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
|
2011-02-24 16:42:06 +03:00
|
|
|
void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
|
2007-09-26 04:57:13 +04:00
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2008-05-15 14:55:29 +04:00
|
|
|
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
|
2008-05-17 02:57:14 +04:00
|
|
|
enum data_queue_qid qid = skb_get_queue_mapping(skb);
|
2010-12-13 14:35:17 +03:00
|
|
|
struct data_queue *queue = NULL;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2007-09-25 22:55:39 +04:00
|
|
|
/*
|
|
|
|
* Mac80211 might be calling this function while we are trying
|
|
|
|
* to remove the device or perhaps suspending it.
|
|
|
|
* Note that we can only stop the TX queues inside the TX path
|
|
|
|
* due to possible race conditions in mac80211.
|
|
|
|
*/
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
|
2011-08-02 15:29:02 +04:00
|
|
|
goto exit_free_skb;
|
2007-09-25 22:55:39 +04:00
|
|
|
|
2007-09-26 04:57:13 +04:00
|
|
|
/*
|
2011-03-03 21:46:29 +03:00
|
|
|
* Use the ATIM queue if appropriate and present.
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2008-05-15 14:55:29 +04:00
|
|
|
if (tx_info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM &&
|
2011-04-18 17:27:06 +04:00
|
|
|
test_bit(REQUIRE_ATIM_QUEUE, &rt2x00dev->cap_flags))
|
2011-03-03 21:46:29 +03:00
|
|
|
qid = QID_ATIM;
|
|
|
|
|
|
|
|
queue = rt2x00queue_get_tx_queue(rt2x00dev, qid);
|
2008-02-06 00:42:23 +03:00
|
|
|
if (unlikely(!queue)) {
|
2007-09-26 04:57:13 +04:00
|
|
|
ERROR(rt2x00dev,
|
|
|
|
"Attempt to send packet over invalid queue %d.\n"
|
2008-04-21 21:00:47 +04:00
|
|
|
"Please file bug report to %s.\n", qid, DRV_PROJECT);
|
2011-08-02 15:29:02 +04:00
|
|
|
goto exit_free_skb;
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-06-03 22:29:57 +04:00
|
|
|
* If CTS/RTS is required. create and queue that frame first.
|
|
|
|
* Make sure we have at least enough entries available to send
|
|
|
|
* this CTS/RTS frame as well as the data frame.
|
2008-04-21 20:59:48 +04:00
|
|
|
* Note that when the driver has set the set_rts_threshold()
|
|
|
|
* callback function it doesn't need software generation of
|
2008-06-03 22:29:57 +04:00
|
|
|
* either RTS or CTS-to-self frame and handles everything
|
2008-04-21 20:59:48 +04:00
|
|
|
* inside the hardware.
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2011-02-20 15:55:46 +03:00
|
|
|
if (!rt2x00dev->ops->hw->set_rts_threshold &&
|
|
|
|
(tx_info->control.rates[0].flags & (IEEE80211_TX_RC_USE_RTS_CTS |
|
|
|
|
IEEE80211_TX_RC_USE_CTS_PROTECT))) {
|
2008-07-23 21:17:01 +04:00
|
|
|
if (rt2x00queue_available(queue) <= 1)
|
|
|
|
goto exit_fail;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-07-23 21:17:01 +04:00
|
|
|
if (rt2x00mac_tx_rts_cts(rt2x00dev, queue, skb))
|
|
|
|
goto exit_fail;
|
2008-01-07 01:38:34 +03:00
|
|
|
}
|
|
|
|
|
2011-03-03 21:41:03 +03:00
|
|
|
if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
|
2008-07-23 21:17:01 +04:00
|
|
|
goto exit_fail;
|
|
|
|
|
2012-03-09 15:39:54 +04:00
|
|
|
/*
|
|
|
|
* Pausing queue has to be serialized with rt2x00lib_txdone(). Note
|
|
|
|
* we should not use spin_lock_bh variant as bottom halve was already
|
|
|
|
* disabled before ieee80211_xmit() call.
|
|
|
|
*/
|
|
|
|
spin_lock(&queue->tx_lock);
|
2008-06-07 00:53:14 +04:00
|
|
|
if (rt2x00queue_threshold(queue))
|
2010-12-13 14:35:17 +03:00
|
|
|
rt2x00queue_pause_queue(queue);
|
2012-03-09 15:39:54 +04:00
|
|
|
spin_unlock(&queue->tx_lock);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2011-02-24 16:42:06 +03:00
|
|
|
return;
|
2008-07-23 21:17:01 +04:00
|
|
|
|
|
|
|
exit_fail:
|
2012-03-09 15:39:54 +04:00
|
|
|
spin_lock(&queue->tx_lock);
|
2011-04-18 17:26:37 +04:00
|
|
|
rt2x00queue_pause_queue(queue);
|
2012-03-09 15:39:54 +04:00
|
|
|
spin_unlock(&queue->tx_lock);
|
2011-08-02 15:29:02 +04:00
|
|
|
exit_free_skb:
|
2011-12-14 19:28:41 +04:00
|
|
|
ieee80211_free_txskb(hw, skb);
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_tx);
|
|
|
|
|
|
|
|
int rt2x00mac_start(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
|
2007-09-26 04:57:13 +04:00
|
|
|
return 0;
|
|
|
|
|
2008-01-07 01:40:07 +03:00
|
|
|
return rt2x00lib_start(rt2x00dev);
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_start);
|
|
|
|
|
|
|
|
void rt2x00mac_stop(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
|
2007-09-25 22:55:39 +04:00
|
|
|
return;
|
|
|
|
|
2008-01-07 01:40:07 +03:00
|
|
|
rt2x00lib_stop(rt2x00dev);
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_stop);
|
|
|
|
|
|
|
|
int rt2x00mac_add_interface(struct ieee80211_hw *hw,
|
2009-12-23 15:15:45 +03:00
|
|
|
struct ieee80211_vif *vif)
|
2007-09-26 04:57:13 +04:00
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2009-12-23 15:15:45 +03:00
|
|
|
struct rt2x00_intf *intf = vif_to_intf(vif);
|
2011-03-03 21:46:55 +03:00
|
|
|
struct data_queue *queue = rt2x00dev->bcn;
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
struct queue_entry *entry = NULL;
|
|
|
|
unsigned int i;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
/*
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
* Don't allow interfaces to be added
|
|
|
|
* the device has disappeared.
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
|
|
|
|
!test_bit(DEVICE_STATE_STARTED, &rt2x00dev->flags))
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
return -ENODEV;
|
|
|
|
|
2009-12-23 15:15:45 +03:00
|
|
|
switch (vif->type) {
|
2008-09-11 02:01:58 +04:00
|
|
|
case NL80211_IFTYPE_AP:
|
2008-08-06 18:18:31 +04:00
|
|
|
/*
|
|
|
|
* We don't support mixed combinations of
|
|
|
|
* sta and ap interfaces.
|
|
|
|
*/
|
|
|
|
if (rt2x00dev->intf_sta_count)
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if we exceeded the maximum amount
|
|
|
|
* of supported interfaces.
|
|
|
|
*/
|
|
|
|
if (rt2x00dev->intf_ap_count >= rt2x00dev->ops->max_ap_intf)
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
|
|
|
break;
|
2008-09-11 02:01:58 +04:00
|
|
|
case NL80211_IFTYPE_STATION:
|
|
|
|
case NL80211_IFTYPE_ADHOC:
|
2008-12-20 12:55:34 +03:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
2008-12-20 12:57:02 +03:00
|
|
|
case NL80211_IFTYPE_WDS:
|
2008-08-06 18:18:31 +04:00
|
|
|
/*
|
|
|
|
* We don't support mixed combinations of
|
|
|
|
* sta and ap interfaces.
|
|
|
|
*/
|
|
|
|
if (rt2x00dev->intf_ap_count)
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if we exceeded the maximum amount
|
|
|
|
* of supported interfaces.
|
|
|
|
*/
|
|
|
|
if (rt2x00dev->intf_sta_count >= rt2x00dev->ops->max_sta_intf)
|
|
|
|
return -ENOBUFS;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop through all beacon queues to find a free
|
|
|
|
* entry. Since there are as much beacon entries
|
|
|
|
* as the maximum interfaces, this search shouldn't
|
|
|
|
* fail.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < queue->limit; i++) {
|
|
|
|
entry = &queue->entries[i];
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_and_set_bit(ENTRY_BCN_ASSIGNED, &entry->flags))
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (unlikely(i == queue->limit))
|
2007-09-26 04:57:13 +04:00
|
|
|
return -ENOBUFS;
|
|
|
|
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
/*
|
|
|
|
* We are now absolutely sure the interface can be created,
|
|
|
|
* increase interface count and start initialization.
|
|
|
|
*/
|
|
|
|
|
2009-12-23 15:15:45 +03:00
|
|
|
if (vif->type == NL80211_IFTYPE_AP)
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
rt2x00dev->intf_ap_count++;
|
|
|
|
else
|
|
|
|
rt2x00dev->intf_sta_count++;
|
|
|
|
|
2009-08-09 01:55:18 +04:00
|
|
|
mutex_init(&intf->beacon_skb_mutex);
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
intf->beacon = entry;
|
|
|
|
|
2007-09-26 04:57:13 +04:00
|
|
|
/*
|
tree-wide: fix comment/printk typos
"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-11-01 22:38:34 +03:00
|
|
|
* The MAC address must be configured after the device
|
[PATCH] mac80211: revamp interface and filter configuration
Drivers are currently supposed to keep track of monitor
interfaces if they allow so-called "hard" monitor, and
they are also supposed to keep track of multicast etc.
This patch changes that, replaces the set_multicast_list()
callback with a new configure_filter() callback that takes
filter flags (FIF_*) instead of interface flags (IFF_*).
For a driver, this means it should open the filter as much
as necessary to get all frames requested by the filter flags.
Accordingly, the filter flags are named "positively", e.g.
FIF_ALLMULTI.
Multicast filtering is a bit special in that drivers that
have no multicast address filters need to allow multicast
frames through when either the FIF_ALLMULTI flag is set or
when the mc_count value is positive.
At the same time, drivers are no longer notified about
monitor interfaces at all, this means they now need to
implement the start() and stop() callbacks and the new
change_filter_flags() callback. Also, the start()/stop()
ordering changed, start() is now called *before* any
add_interface() as it really should be, and stop() after
any remove_interface().
The patch also changes the behaviour of setting the bssid
to multicast for scanning when IEEE80211_HW_NO_PROBE_FILTERING
is set; the IEEE80211_HW_NO_PROBE_FILTERING flag is removed
and the filter flag FIF_BCN_PRBRESP_PROMISC introduced.
This is a lot more efficient for hardware like b43 that
supports it and other hardware can still set the BSSID
to all-ones.
Driver modifications by Johannes Berg (b43 & iwlwifi), Michael Wu
(rtl8187, adm8211, and p54), Larry Finger (b43legacy), and
Ivo van Doorn (rt2x00).
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Michael Wu <flamingice@sourmilk.net>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2007-09-17 09:29:23 +04:00
|
|
|
* has been initialized. Otherwise the device can reset
|
|
|
|
* the MAC registers.
|
2010-07-24 21:32:25 +04:00
|
|
|
* The BSSID address must only be configured in AP mode,
|
|
|
|
* however we should not send an empty BSSID address for
|
|
|
|
* STA interfaces at this time, since this can cause
|
|
|
|
* invalid behavior in the device.
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2010-11-04 22:42:36 +03:00
|
|
|
rt2x00lib_config_intf(rt2x00dev, intf, vif->type,
|
2010-12-27 17:05:35 +03:00
|
|
|
vif->addr, NULL);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-03-31 17:24:53 +04:00
|
|
|
/*
|
|
|
|
* Some filters depend on the current working mode. We can force
|
|
|
|
* an update during the next configure_filter() run by mac80211 by
|
|
|
|
* resetting the current packet_filter state.
|
|
|
|
*/
|
|
|
|
rt2x00dev->packet_filter = 0;
|
|
|
|
|
2007-09-26 04:57:13 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_add_interface);
|
|
|
|
|
|
|
|
void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
|
2009-12-23 15:15:45 +03:00
|
|
|
struct ieee80211_vif *vif)
|
2007-09-26 04:57:13 +04:00
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2009-12-23 15:15:45 +03:00
|
|
|
struct rt2x00_intf *intf = vif_to_intf(vif);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
/*
|
2007-09-25 22:55:39 +04:00
|
|
|
* Don't allow interfaces to be remove while
|
|
|
|
* either the device has disappeared or when
|
|
|
|
* no interface is present.
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) ||
|
2009-12-23 15:15:45 +03:00
|
|
|
(vif->type == NL80211_IFTYPE_AP && !rt2x00dev->intf_ap_count) ||
|
|
|
|
(vif->type != NL80211_IFTYPE_AP && !rt2x00dev->intf_sta_count))
|
2007-09-26 04:57:13 +04:00
|
|
|
return;
|
|
|
|
|
2009-12-23 15:15:45 +03:00
|
|
|
if (vif->type == NL80211_IFTYPE_AP)
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
rt2x00dev->intf_ap_count--;
|
|
|
|
else
|
|
|
|
rt2x00dev->intf_sta_count--;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Release beacon entry so it is available for
|
|
|
|
* new interfaces again.
|
|
|
|
*/
|
2008-08-29 23:04:26 +04:00
|
|
|
clear_bit(ENTRY_BCN_ASSIGNED, &intf->beacon->flags);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure the bssid and mac address registers
|
|
|
|
* are cleared to prevent false ACKing of frames.
|
|
|
|
*/
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
rt2x00lib_config_intf(rt2x00dev, intf,
|
2008-09-11 02:01:58 +04:00
|
|
|
NL80211_IFTYPE_UNSPECIFIED, NULL, NULL);
|
2007-09-26 04:57:13 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface);
|
|
|
|
|
2008-10-09 14:18:51 +04:00
|
|
|
int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed)
|
2007-09-26 04:57:13 +04:00
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2008-10-09 14:18:51 +04:00
|
|
|
struct ieee80211_conf *conf = &hw->conf;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
/*
|
2009-07-17 23:39:19 +04:00
|
|
|
* mac80211 might be calling this function while we are trying
|
2007-09-25 22:55:39 +04:00
|
|
|
* to remove the device or perhaps suspending it.
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2008-08-29 23:04:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
|
2007-09-26 04:57:13 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*
|
2009-08-09 01:53:04 +04:00
|
|
|
* Some configuration parameters (e.g. channel and antenna values) can
|
|
|
|
* only be set when the radio is enabled, but do require the RX to
|
2010-07-11 14:24:47 +04:00
|
|
|
* be off. During this period we should keep link tuning enabled,
|
|
|
|
* if for any reason the link tuner must be reset, this will be
|
|
|
|
* handled by rt2x00lib_config().
|
2007-09-26 04:57:13 +04:00
|
|
|
*/
|
2010-12-13 14:35:17 +03:00
|
|
|
rt2x00queue_stop_queue(rt2x00dev->rx);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2009-08-09 01:53:04 +04:00
|
|
|
/*
|
|
|
|
* When we've just turned on the radio, we want to reprogram
|
|
|
|
* everything to ensure a consistent state
|
|
|
|
*/
|
|
|
|
rt2x00lib_config(rt2x00dev, conf, changed);
|
2008-07-21 13:52:44 +04:00
|
|
|
|
2009-08-09 01:53:04 +04:00
|
|
|
/*
|
|
|
|
* After the radio has been enabled we need to configure
|
|
|
|
* the antenna to the default settings. rt2x00lib_config_antenna()
|
|
|
|
* should determine if any action should be taken based on
|
|
|
|
* checking if diversity has been enabled or no antenna changes
|
|
|
|
* have been made since the last configuration change.
|
|
|
|
*/
|
|
|
|
rt2x00lib_config_antenna(rt2x00dev, rt2x00dev->default_ant);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2009-08-09 01:53:04 +04:00
|
|
|
/* Turn RX back on */
|
2010-12-13 14:35:17 +03:00
|
|
|
rt2x00queue_start_queue(rt2x00dev->rx);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_config);
|
|
|
|
|
2008-03-25 16:13:18 +03:00
|
|
|
void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
|
|
|
|
unsigned int changed_flags,
|
|
|
|
unsigned int *total_flags,
|
2009-08-17 18:16:53 +04:00
|
|
|
u64 multicast)
|
2008-03-25 16:13:18 +03:00
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mask off any flags we are going to ignore
|
|
|
|
* from the total_flags field.
|
|
|
|
*/
|
|
|
|
*total_flags &=
|
|
|
|
FIF_ALLMULTI |
|
|
|
|
FIF_FCSFAIL |
|
|
|
|
FIF_PLCPFAIL |
|
|
|
|
FIF_CONTROL |
|
2009-08-09 01:55:55 +04:00
|
|
|
FIF_PSPOLL |
|
2008-03-25 16:13:18 +03:00
|
|
|
FIF_OTHER_BSS |
|
|
|
|
FIF_PROMISC_IN_BSS;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Apply some rules to the filters:
|
|
|
|
* - Some filters imply different filters to be set.
|
|
|
|
* - Some things we can't filter out at all.
|
|
|
|
* - Multicast filter seems to kill broadcast traffic so never use it.
|
|
|
|
*/
|
|
|
|
*total_flags |= FIF_ALLMULTI;
|
|
|
|
if (*total_flags & FIF_OTHER_BSS ||
|
|
|
|
*total_flags & FIF_PROMISC_IN_BSS)
|
|
|
|
*total_flags |= FIF_PROMISC_IN_BSS | FIF_OTHER_BSS;
|
|
|
|
|
2009-08-09 01:55:55 +04:00
|
|
|
/*
|
|
|
|
* If the device has a single filter for all control frames,
|
|
|
|
* FIF_CONTROL and FIF_PSPOLL flags imply each other.
|
|
|
|
* And if the device has more than one filter for control frames
|
|
|
|
* of different types, but has no a separate filter for PS Poll frames,
|
|
|
|
* FIF_CONTROL flag implies FIF_PSPOLL.
|
|
|
|
*/
|
2011-04-18 17:27:06 +04:00
|
|
|
if (!test_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags)) {
|
2009-08-09 01:55:55 +04:00
|
|
|
if (*total_flags & FIF_CONTROL || *total_flags & FIF_PSPOLL)
|
|
|
|
*total_flags |= FIF_CONTROL | FIF_PSPOLL;
|
|
|
|
}
|
2011-04-18 17:27:06 +04:00
|
|
|
if (!test_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags)) {
|
2009-08-09 01:55:55 +04:00
|
|
|
if (*total_flags & FIF_CONTROL)
|
|
|
|
*total_flags |= FIF_PSPOLL;
|
|
|
|
}
|
|
|
|
|
2008-03-25 16:13:18 +03:00
|
|
|
/*
|
|
|
|
* Check if there is any work left for us.
|
|
|
|
*/
|
|
|
|
if (rt2x00dev->packet_filter == *total_flags)
|
|
|
|
return;
|
|
|
|
rt2x00dev->packet_filter = *total_flags;
|
|
|
|
|
2009-08-18 21:54:23 +04:00
|
|
|
rt2x00dev->ops->lib->config_filter(rt2x00dev, *total_flags);
|
2008-03-25 16:13:18 +03:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_configure_filter);
|
|
|
|
|
2010-07-11 14:27:26 +04:00
|
|
|
static void rt2x00mac_set_tim_iter(void *data, u8 *mac,
|
|
|
|
struct ieee80211_vif *vif)
|
|
|
|
{
|
|
|
|
struct rt2x00_intf *intf = vif_to_intf(vif);
|
|
|
|
|
|
|
|
if (vif->type != NL80211_IFTYPE_AP &&
|
|
|
|
vif->type != NL80211_IFTYPE_ADHOC &&
|
|
|
|
vif->type != NL80211_IFTYPE_MESH_POINT &&
|
|
|
|
vif->type != NL80211_IFTYPE_WDS)
|
|
|
|
return;
|
|
|
|
|
2010-12-27 17:06:57 +03:00
|
|
|
set_bit(DELAYED_UPDATE_BEACON, &intf->delayed_flags);
|
2010-07-11 14:27:26 +04:00
|
|
|
}
|
|
|
|
|
2009-07-28 20:58:54 +04:00
|
|
|
int rt2x00mac_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
|
|
|
|
bool set)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
|
2010-07-11 14:27:26 +04:00
|
|
|
if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ieee80211_iterate_active_interfaces_atomic(rt2x00dev->hw,
|
|
|
|
rt2x00mac_set_tim_iter,
|
|
|
|
rt2x00dev);
|
|
|
|
|
|
|
|
/* queue work to upodate the beacon template */
|
|
|
|
ieee80211_queue_work(rt2x00dev->hw, &rt2x00dev->intf_work);
|
2009-07-28 20:58:54 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_set_tim);
|
|
|
|
|
2008-08-04 18:37:44 +04:00
|
|
|
#ifdef CONFIG_RT2X00_LIB_CRYPTO
|
2008-12-20 12:58:33 +03:00
|
|
|
static void memcpy_tkip(struct rt2x00lib_crypto *crypto, u8 *key, u8 key_len)
|
|
|
|
{
|
|
|
|
if (key_len > NL80211_TKIP_DATA_OFFSET_ENCR_KEY)
|
2010-12-27 17:05:55 +03:00
|
|
|
memcpy(crypto->key,
|
2008-12-20 12:58:33 +03:00
|
|
|
&key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY],
|
|
|
|
sizeof(crypto->key));
|
|
|
|
|
|
|
|
if (key_len > NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY)
|
2010-12-27 17:05:55 +03:00
|
|
|
memcpy(crypto->tx_mic,
|
2008-12-20 12:58:33 +03:00
|
|
|
&key[NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY],
|
|
|
|
sizeof(crypto->tx_mic));
|
|
|
|
|
|
|
|
if (key_len > NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY)
|
2010-12-27 17:05:55 +03:00
|
|
|
memcpy(crypto->rx_mic,
|
2008-12-20 12:58:33 +03:00
|
|
|
&key[NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY],
|
|
|
|
sizeof(crypto->rx_mic));
|
|
|
|
}
|
|
|
|
|
2008-08-04 18:37:44 +04:00
|
|
|
int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
|
2008-12-29 14:55:09 +03:00
|
|
|
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
|
2008-08-04 18:37:44 +04:00
|
|
|
struct ieee80211_key_conf *key)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
int (*set_key) (struct rt2x00_dev *rt2x00dev,
|
|
|
|
struct rt2x00lib_crypto *crypto,
|
|
|
|
struct ieee80211_key_conf *key);
|
|
|
|
struct rt2x00lib_crypto crypto;
|
2008-12-29 14:55:09 +03:00
|
|
|
static const u8 bcast_addr[ETH_ALEN] =
|
|
|
|
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, };
|
2011-09-08 16:36:45 +04:00
|
|
|
struct rt2x00_sta *sta_priv = NULL;
|
2008-08-04 18:37:44 +04:00
|
|
|
|
2008-11-02 02:37:25 +03:00
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
|
|
|
|
return 0;
|
2012-05-28 13:53:11 +04:00
|
|
|
|
|
|
|
if (!test_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags))
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To support IBSS RSN, don't program group keys in IBSS, the
|
|
|
|
* hardware will then not attempt to decrypt the frames.
|
|
|
|
*/
|
|
|
|
if (vif->type == NL80211_IFTYPE_ADHOC &&
|
|
|
|
!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE))
|
2008-08-04 18:37:44 +04:00
|
|
|
return -EOPNOTSUPP;
|
2012-05-28 13:53:11 +04:00
|
|
|
|
|
|
|
if (key->keylen > 32)
|
2008-08-04 18:37:44 +04:00
|
|
|
return -ENOSPC;
|
|
|
|
|
|
|
|
memset(&crypto, 0, sizeof(crypto));
|
|
|
|
|
2011-09-08 16:34:22 +04:00
|
|
|
crypto.bssidx = rt2x00lib_get_bssidx(rt2x00dev, vif);
|
2008-08-04 18:37:44 +04:00
|
|
|
crypto.cipher = rt2x00crypto_key_to_cipher(key);
|
|
|
|
if (crypto.cipher == CIPHER_NONE)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
crypto.cmd = cmd;
|
2008-12-29 14:55:09 +03:00
|
|
|
|
2011-09-08 16:36:45 +04:00
|
|
|
if (sta) {
|
2008-12-29 14:55:09 +03:00
|
|
|
crypto.address = sta->addr;
|
2011-09-08 16:36:45 +04:00
|
|
|
sta_priv = sta_to_rt2x00_sta(sta);
|
|
|
|
crypto.wcid = sta_priv->wcid;
|
|
|
|
} else
|
2008-12-29 14:55:09 +03:00
|
|
|
crypto.address = bcast_addr;
|
2008-08-04 18:37:44 +04:00
|
|
|
|
2008-12-20 12:58:33 +03:00
|
|
|
if (crypto.cipher == CIPHER_TKIP)
|
|
|
|
memcpy_tkip(&crypto, &key->key[0], key->keylen);
|
|
|
|
else
|
2010-12-27 17:05:55 +03:00
|
|
|
memcpy(crypto.key, &key->key[0], key->keylen);
|
2008-08-04 18:37:44 +04:00
|
|
|
/*
|
|
|
|
* Each BSS has a maximum of 4 shared keys.
|
|
|
|
* Shared key index values:
|
|
|
|
* 0) BSS0 key0
|
|
|
|
* 1) BSS0 key1
|
|
|
|
* ...
|
|
|
|
* 4) BSS1 key0
|
|
|
|
* ...
|
|
|
|
* 8) BSS2 key0
|
|
|
|
* ...
|
|
|
|
* Both pairwise as shared key indeces are determined by
|
|
|
|
* driver. This is required because the hardware requires
|
|
|
|
* keys to be assigned in correct order (When key 1 is
|
|
|
|
* provided but key 0 is not, then the key is not found
|
|
|
|
* by the hardware during RX).
|
|
|
|
*/
|
2008-09-22 21:40:04 +04:00
|
|
|
if (cmd == SET_KEY)
|
|
|
|
key->hw_key_idx = 0;
|
2008-08-04 18:37:44 +04:00
|
|
|
|
|
|
|
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
|
|
|
|
set_key = rt2x00dev->ops->lib->config_pairwise_key;
|
|
|
|
else
|
|
|
|
set_key = rt2x00dev->ops->lib->config_shared_key;
|
|
|
|
|
|
|
|
if (!set_key)
|
|
|
|
return -EOPNOTSUPP;
|
|
|
|
|
|
|
|
return set_key(rt2x00dev, &crypto, key);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_set_key);
|
|
|
|
#endif /* CONFIG_RT2X00_LIB_CRYPTO */
|
|
|
|
|
2011-09-08 16:36:04 +04:00
|
|
|
int rt2x00mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct rt2x00_sta *sta_priv = sta_to_rt2x00_sta(sta);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's no space left in the device table store
|
|
|
|
* -1 as wcid but tell mac80211 everything went ok.
|
|
|
|
*/
|
|
|
|
if (rt2x00dev->ops->lib->sta_add(rt2x00dev, vif, sta))
|
|
|
|
sta_priv->wcid = -1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_sta_add);
|
|
|
|
|
|
|
|
int rt2x00mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_sta *sta)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct rt2x00_sta *sta_priv = sta_to_rt2x00_sta(sta);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we never sent the STA to the device no need to clean it up.
|
|
|
|
*/
|
|
|
|
if (sta_priv->wcid < 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return rt2x00dev->ops->lib->sta_remove(rt2x00dev, sta_priv->wcid);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_sta_remove);
|
|
|
|
|
2010-07-11 14:24:47 +04:00
|
|
|
void rt2x00mac_sw_scan_start(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2011-04-18 17:27:06 +04:00
|
|
|
set_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags);
|
2010-07-11 14:24:47 +04:00
|
|
|
rt2x00link_stop_tuner(rt2x00dev);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_sw_scan_start);
|
|
|
|
|
|
|
|
void rt2x00mac_sw_scan_complete(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2011-04-18 17:27:06 +04:00
|
|
|
clear_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags);
|
2010-07-11 14:24:47 +04:00
|
|
|
rt2x00link_start_tuner(rt2x00dev);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_sw_scan_complete);
|
|
|
|
|
2007-09-26 04:57:13 +04:00
|
|
|
int rt2x00mac_get_stats(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_low_level_stats *stats)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The dot11ACKFailureCount, dot11RTSFailureCount and
|
|
|
|
* dot11RTSSuccessCount are updated in interrupt time.
|
|
|
|
* dot11FCSErrorCount is updated in the link tuner.
|
|
|
|
*/
|
|
|
|
memcpy(stats, &rt2x00dev->low_level_stats, sizeof(*stats));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_get_stats);
|
|
|
|
|
2007-12-28 16:32:58 +03:00
|
|
|
void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif,
|
|
|
|
struct ieee80211_bss_conf *bss_conf,
|
|
|
|
u32 changes)
|
2007-10-06 15:34:52 +04:00
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
struct rt2x00_intf *intf = vif_to_intf(vif);
|
2009-04-23 18:13:26 +04:00
|
|
|
|
|
|
|
/*
|
2009-07-17 23:39:19 +04:00
|
|
|
* mac80211 might be calling this function while we are trying
|
2009-04-23 18:13:26 +04:00
|
|
|
* to remove the device or perhaps suspending it.
|
|
|
|
*/
|
|
|
|
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
2010-12-27 17:07:35 +03:00
|
|
|
* Update the BSSID.
|
2009-04-23 18:13:26 +04:00
|
|
|
*/
|
|
|
|
if (changes & BSS_CHANGED_BSSID)
|
|
|
|
rt2x00lib_config_intf(rt2x00dev, intf, vif->type, NULL,
|
2010-06-29 23:39:29 +04:00
|
|
|
bss_conf->bssid);
|
2009-04-23 18:13:26 +04:00
|
|
|
|
|
|
|
/*
|
2011-01-30 15:16:52 +03:00
|
|
|
* Update the beacon. This is only required on USB devices. PCI
|
|
|
|
* devices fetch beacons periodically.
|
2009-04-23 18:13:26 +04:00
|
|
|
*/
|
2011-01-30 15:16:52 +03:00
|
|
|
if (changes & BSS_CHANGED_BEACON && rt2x00_is_usb(rt2x00dev))
|
2011-01-30 15:16:03 +03:00
|
|
|
rt2x00queue_update_beacon(rt2x00dev, vif);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start/stop beaconing.
|
|
|
|
*/
|
|
|
|
if (changes & BSS_CHANGED_BEACON_ENABLED) {
|
|
|
|
if (!bss_conf->enable_beacon && intf->enable_beacon) {
|
|
|
|
rt2x00queue_clear_beacon(rt2x00dev, vif);
|
|
|
|
rt2x00dev->intf_beaconing--;
|
|
|
|
intf->enable_beacon = false;
|
|
|
|
|
|
|
|
if (rt2x00dev->intf_beaconing == 0) {
|
|
|
|
/*
|
|
|
|
* Last beaconing interface disabled
|
|
|
|
* -> stop beacon queue.
|
|
|
|
*/
|
|
|
|
mutex_lock(&intf->beacon_skb_mutex);
|
|
|
|
rt2x00queue_stop_queue(rt2x00dev->bcn);
|
|
|
|
mutex_unlock(&intf->beacon_skb_mutex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (bss_conf->enable_beacon && !intf->enable_beacon) {
|
|
|
|
rt2x00dev->intf_beaconing++;
|
|
|
|
intf->enable_beacon = true;
|
|
|
|
|
|
|
|
if (rt2x00dev->intf_beaconing == 1) {
|
|
|
|
/*
|
|
|
|
* First beaconing interface enabled
|
|
|
|
* -> start beacon queue.
|
|
|
|
*/
|
|
|
|
mutex_lock(&intf->beacon_skb_mutex);
|
|
|
|
rt2x00queue_start_queue(rt2x00dev->bcn);
|
|
|
|
mutex_unlock(&intf->beacon_skb_mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-10-06 15:34:52 +04:00
|
|
|
|
|
|
|
/*
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
* When the association status has changed we must reset the link
|
|
|
|
* tuner counter. This is because some drivers determine if they
|
|
|
|
* should perform link tuning based on the number of seconds
|
|
|
|
* while associated or not associated.
|
2007-10-06 15:34:52 +04:00
|
|
|
*/
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
if (changes & BSS_CHANGED_ASSOC) {
|
|
|
|
rt2x00dev->link.count = 0;
|
2007-10-06 15:34:52 +04:00
|
|
|
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
if (bss_conf->assoc)
|
|
|
|
rt2x00dev->intf_associated++;
|
|
|
|
else
|
|
|
|
rt2x00dev->intf_associated--;
|
2008-03-31 17:53:44 +04:00
|
|
|
|
2009-08-18 22:33:12 +04:00
|
|
|
rt2x00leds_led_assoc(rt2x00dev, !!rt2x00dev->intf_associated);
|
2012-04-02 15:21:06 +04:00
|
|
|
|
|
|
|
clear_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags);
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
}
|
2007-10-06 15:34:52 +04:00
|
|
|
|
2012-04-02 15:21:06 +04:00
|
|
|
/*
|
|
|
|
* Check for access point which do not support 802.11e . We have to
|
|
|
|
* generate data frames sequence number in S/W for such AP, because
|
|
|
|
* of H/W bug.
|
|
|
|
*/
|
|
|
|
if (changes & BSS_CHANGED_QOS && !bss_conf->qos)
|
|
|
|
set_bit(CONFIG_QOS_DISABLED, &rt2x00dev->flags);
|
|
|
|
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
/*
|
2008-03-10 00:46:18 +03:00
|
|
|
* When the erp information has changed, we should perform
|
|
|
|
* additional configuration steps. For all other changes we are done.
|
rt2x00: Add per-interface structure
Rework the interface handling. Delete the interface structure
and replace it with a per-interface structure. This changes the
way rt2x00 handles the active interface drastically.
Copy ieee80211_bss_conf to the this rt2x00_intf structure during
the bss_info_changed() callback function. This will allow us to
reference it later, and removes the requirement for the device flag
SHORT_PREAMBLE flag which is interface specific.
Drivers receive the option to give the maximum number of virtual
interfaces the device can handle. Virtual interface support:
rt2400pci: 1 sta or 1 ap, * monitor interfaces
rt2500pci: 1 sta or 1 ap, * monitor interfaces
rt2500usb: 1 sta or 1 ap, * monitor interfaces
rt61pci: 1 sta or 4 ap, * monitor interfaces
rt73usb: 1 sta or 4 ap, * monitor interfaces
At the moment none of the drivers support AP and STA interfaces
simultaneously, this is a hardware limitation so future support
will be very unlikely.
Each interface structure receives its dedicated beacon entry,
with this we can easily work with beaconing while multiple master
mode interfaces are currently active.
The configuration handlers for the MAC, BSSID and type are
often called together since they all belong to the interface
configuration. Merge the 3 configuration calls and cleanup
the API between rt2x00lib and the drivers. While we are cleaning
up the interface configuration anyway, we might as well clean up
the configuration handler as well.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2008-02-03 17:49:59 +03:00
|
|
|
*/
|
2010-09-08 22:56:32 +04:00
|
|
|
if (changes & (BSS_CHANGED_ERP_CTS_PROT | BSS_CHANGED_ERP_PREAMBLE |
|
|
|
|
BSS_CHANGED_ERP_SLOT | BSS_CHANGED_BASIC_RATES |
|
2010-10-02 13:28:34 +04:00
|
|
|
BSS_CHANGED_BEACON_INT | BSS_CHANGED_HT))
|
2010-09-08 22:56:32 +04:00
|
|
|
rt2x00lib_config_erp(rt2x00dev, intf, bss_conf, changes);
|
2007-10-06 15:34:52 +04:00
|
|
|
}
|
2007-12-28 16:32:58 +03:00
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_bss_info_changed);
|
2007-10-06 15:34:52 +04:00
|
|
|
|
2011-10-02 12:15:52 +04:00
|
|
|
int rt2x00mac_conf_tx(struct ieee80211_hw *hw,
|
|
|
|
struct ieee80211_vif *vif, u16 queue_idx,
|
2007-09-26 04:57:13 +04:00
|
|
|
const struct ieee80211_tx_queue_params *params)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2008-02-06 00:42:23 +03:00
|
|
|
struct data_queue *queue;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2011-03-03 21:38:55 +03:00
|
|
|
queue = rt2x00queue_get_tx_queue(rt2x00dev, queue_idx);
|
2008-02-06 00:42:23 +03:00
|
|
|
if (unlikely(!queue))
|
2007-09-26 04:57:13 +04:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The passed variables are stored as real value ((2^n)-1).
|
|
|
|
* Ralink registers require to know the bit number 'n'.
|
|
|
|
*/
|
2008-02-03 17:47:30 +03:00
|
|
|
if (params->cw_min > 0)
|
2008-02-06 00:42:23 +03:00
|
|
|
queue->cw_min = fls(params->cw_min);
|
2007-09-26 04:57:13 +04:00
|
|
|
else
|
2008-02-06 00:42:23 +03:00
|
|
|
queue->cw_min = 5; /* cw_min: 2^5 = 32. */
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-02-03 17:47:30 +03:00
|
|
|
if (params->cw_max > 0)
|
2008-02-06 00:42:23 +03:00
|
|
|
queue->cw_max = fls(params->cw_max);
|
2007-09-26 04:57:13 +04:00
|
|
|
else
|
2008-02-06 00:42:23 +03:00
|
|
|
queue->cw_max = 10; /* cw_min: 2^10 = 1024. */
|
2007-09-26 04:57:13 +04:00
|
|
|
|
2008-07-15 13:08:24 +04:00
|
|
|
queue->aifs = params->aifs;
|
2008-08-29 23:05:45 +04:00
|
|
|
queue->txop = params->txop;
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
INFO(rt2x00dev,
|
2008-08-29 23:05:45 +04:00
|
|
|
"Configured TX queue %d - CWmin: %d, CWmax: %d, Aifs: %d, TXop: %d.\n",
|
|
|
|
queue_idx, queue->cw_min, queue->cw_max, queue->aifs, queue->txop);
|
2007-09-26 04:57:13 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_conf_tx);
|
2009-07-01 17:17:35 +04:00
|
|
|
|
|
|
|
void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
2009-08-17 20:53:24 +04:00
|
|
|
bool active = !!rt2x00dev->ops->lib->rfkill_poll(rt2x00dev);
|
2009-07-01 17:17:35 +04:00
|
|
|
|
2009-08-17 20:53:24 +04:00
|
|
|
wiphy_rfkill_set_hw_state(hw->wiphy, !active);
|
2009-07-01 17:17:35 +04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_rfkill_poll);
|
2010-11-04 22:40:11 +03:00
|
|
|
|
|
|
|
void rt2x00mac_flush(struct ieee80211_hw *hw, bool drop)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct data_queue *queue;
|
|
|
|
|
2010-12-13 14:35:40 +03:00
|
|
|
tx_queue_for_each(rt2x00dev, queue)
|
|
|
|
rt2x00queue_flush_queue(queue, drop);
|
2010-11-04 22:40:11 +03:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_flush);
|
2011-04-18 17:34:41 +04:00
|
|
|
|
2011-04-18 17:35:12 +04:00
|
|
|
int rt2x00mac_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct link_ant *ant = &rt2x00dev->link.ant;
|
|
|
|
struct antenna_setup *def = &rt2x00dev->default_ant;
|
|
|
|
struct antenna_setup setup;
|
|
|
|
|
|
|
|
// The antenna value is not supposed to be 0,
|
|
|
|
// or exceed the maximum number of antenna's.
|
|
|
|
if (!tx_ant || (tx_ant & ~3) || !rx_ant || (rx_ant & ~3))
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
// When the client tried to configure the antenna to or from
|
|
|
|
// diversity mode, we must reset the default antenna as well
|
|
|
|
// as that controls the diversity switch.
|
|
|
|
if (ant->flags & ANTENNA_TX_DIVERSITY && tx_ant != 3)
|
|
|
|
ant->flags &= ~ANTENNA_TX_DIVERSITY;
|
|
|
|
if (ant->flags & ANTENNA_RX_DIVERSITY && rx_ant != 3)
|
|
|
|
ant->flags &= ~ANTENNA_RX_DIVERSITY;
|
|
|
|
|
|
|
|
// If diversity is being enabled, check if we need hardware
|
|
|
|
// or software diversity. In the latter case, reset the value,
|
|
|
|
// and make sure we update the antenna flags to have the
|
|
|
|
// link tuner pick up the diversity tuning.
|
|
|
|
if (tx_ant == 3 && def->tx == ANTENNA_SW_DIVERSITY) {
|
|
|
|
tx_ant = ANTENNA_SW_DIVERSITY;
|
|
|
|
ant->flags |= ANTENNA_TX_DIVERSITY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rx_ant == 3 && def->rx == ANTENNA_SW_DIVERSITY) {
|
|
|
|
rx_ant = ANTENNA_SW_DIVERSITY;
|
|
|
|
ant->flags |= ANTENNA_RX_DIVERSITY;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup.tx = tx_ant;
|
|
|
|
setup.rx = rx_ant;
|
|
|
|
|
|
|
|
rt2x00lib_config_antenna(rt2x00dev, setup);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_set_antenna);
|
|
|
|
|
|
|
|
int rt2x00mac_get_antenna(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct link_ant *ant = &rt2x00dev->link.ant;
|
|
|
|
struct antenna_setup *active = &rt2x00dev->link.ant.active;
|
|
|
|
|
|
|
|
// When software diversity is active, we must report this to the
|
|
|
|
// client and not the current active antenna state.
|
|
|
|
if (ant->flags & ANTENNA_TX_DIVERSITY)
|
|
|
|
*tx_ant = ANTENNA_HW_DIVERSITY;
|
|
|
|
else
|
|
|
|
*tx_ant = active->tx;
|
|
|
|
|
|
|
|
if (ant->flags & ANTENNA_RX_DIVERSITY)
|
|
|
|
*rx_ant = ANTENNA_HW_DIVERSITY;
|
|
|
|
else
|
|
|
|
*rx_ant = active->rx;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_get_antenna);
|
|
|
|
|
2011-04-18 17:34:41 +04:00
|
|
|
void rt2x00mac_get_ringparam(struct ieee80211_hw *hw,
|
|
|
|
u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct data_queue *queue;
|
|
|
|
|
|
|
|
tx_queue_for_each(rt2x00dev, queue) {
|
|
|
|
*tx += queue->length;
|
|
|
|
*tx_max += queue->limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
*rx = rt2x00dev->rx->length;
|
|
|
|
*rx_max = rt2x00dev->rx->limit;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_get_ringparam);
|
2011-07-07 01:00:21 +04:00
|
|
|
|
|
|
|
bool rt2x00mac_tx_frames_pending(struct ieee80211_hw *hw)
|
|
|
|
{
|
|
|
|
struct rt2x00_dev *rt2x00dev = hw->priv;
|
|
|
|
struct data_queue *queue;
|
|
|
|
|
|
|
|
tx_queue_for_each(rt2x00dev, queue) {
|
|
|
|
if (!rt2x00queue_empty(queue))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(rt2x00mac_tx_frames_pending);
|