2007-09-26 08:57:13 +08:00
|
|
|
/*
|
2009-11-08 23:39:55 +08:00
|
|
|
Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
|
2007-09-26 08:57:13 +08: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
|
2013-12-06 19:32:11 +08:00
|
|
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2007-09-26 08:57:13 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Module: rt2x00lib
|
|
|
|
Abstract: rt2x00 generic configuration routines.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include "rt2x00.h"
|
|
|
|
#include "rt2x00lib.h"
|
|
|
|
|
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 22:49:59 +08:00
|
|
|
void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
|
|
|
|
struct rt2x00_intf *intf,
|
2008-09-11 06:01:58 +08:00
|
|
|
enum nl80211_iftype type,
|
2009-01-21 19:47:05 +08:00
|
|
|
const u8 *mac, const u8 *bssid)
|
2007-09-26 08:57:13 +08: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 22:49:59 +08:00
|
|
|
struct rt2x00intf_conf conf;
|
|
|
|
unsigned int flags = 0;
|
2007-09-26 08:57:13 +08: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 22:49:59 +08:00
|
|
|
conf.type = type;
|
2007-10-06 20:14:29 +08:00
|
|
|
|
|
|
|
switch (type) {
|
2008-09-11 06:01:58 +08:00
|
|
|
case NL80211_IFTYPE_ADHOC:
|
2010-07-11 18:30:13 +08:00
|
|
|
conf.sync = TSF_SYNC_ADHOC;
|
|
|
|
break;
|
2008-09-11 06:01:58 +08:00
|
|
|
case NL80211_IFTYPE_AP:
|
2008-12-20 17:55:34 +08:00
|
|
|
case NL80211_IFTYPE_MESH_POINT:
|
2008-12-20 17:57:02 +08:00
|
|
|
case NL80211_IFTYPE_WDS:
|
2010-07-11 18:30:13 +08:00
|
|
|
conf.sync = TSF_SYNC_AP_NONE;
|
2007-10-06 20:14:29 +08:00
|
|
|
break;
|
2008-09-11 06:01:58 +08:00
|
|
|
case NL80211_IFTYPE_STATION:
|
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 22:49:59 +08:00
|
|
|
conf.sync = TSF_SYNC_INFRA;
|
2007-10-06 20:14:29 +08:00
|
|
|
break;
|
|
|
|
default:
|
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 22:49:59 +08:00
|
|
|
conf.sync = TSF_SYNC_NONE;
|
2007-10-06 20:14:29 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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 22:49:59 +08:00
|
|
|
/*
|
|
|
|
* Note that when NULL is passed as address we will send
|
|
|
|
* 00:00:00:00:00 to the device to clear the address.
|
|
|
|
* This will prevent the device being confused when it wants
|
2011-03-31 09:57:33 +08:00
|
|
|
* to ACK frames or considers itself associated.
|
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 22:49:59 +08:00
|
|
|
*/
|
2010-12-27 22:05:55 +08:00
|
|
|
memset(conf.mac, 0, sizeof(conf.mac));
|
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 22:49:59 +08:00
|
|
|
if (mac)
|
2010-12-27 22:05:55 +08:00
|
|
|
memcpy(conf.mac, mac, ETH_ALEN);
|
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 22:49:59 +08:00
|
|
|
|
2010-12-27 22:05:55 +08:00
|
|
|
memset(conf.bssid, 0, sizeof(conf.bssid));
|
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 22:49:59 +08:00
|
|
|
if (bssid)
|
2010-12-27 22:05:55 +08:00
|
|
|
memcpy(conf.bssid, bssid, ETH_ALEN);
|
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 22:49:59 +08:00
|
|
|
|
|
|
|
flags |= CONFIG_UPDATE_TYPE;
|
|
|
|
if (mac || (!rt2x00dev->intf_ap_count && !rt2x00dev->intf_sta_count))
|
|
|
|
flags |= CONFIG_UPDATE_MAC;
|
|
|
|
if (bssid || (!rt2x00dev->intf_ap_count && !rt2x00dev->intf_sta_count))
|
|
|
|
flags |= CONFIG_UPDATE_BSSID;
|
|
|
|
|
|
|
|
rt2x00dev->ops->lib->config_intf(rt2x00dev, intf, &conf, flags);
|
|
|
|
}
|
|
|
|
|
2008-03-10 05:46:18 +08:00
|
|
|
void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev,
|
|
|
|
struct rt2x00_intf *intf,
|
2010-09-09 02:56:32 +08:00
|
|
|
struct ieee80211_bss_conf *bss_conf,
|
|
|
|
u32 changed)
|
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 22:49:59 +08:00
|
|
|
{
|
2008-03-10 05:46:18 +08:00
|
|
|
struct rt2x00lib_erp erp;
|
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 22:49:59 +08:00
|
|
|
|
2008-03-10 05:46:18 +08:00
|
|
|
memset(&erp, 0, sizeof(erp));
|
|
|
|
|
|
|
|
erp.short_preamble = bss_conf->use_short_preamble;
|
2008-07-09 21:12:06 +08:00
|
|
|
erp.cts_protection = bss_conf->use_cts_prot;
|
|
|
|
|
2008-10-30 00:17:57 +08:00
|
|
|
erp.slot_time = bss_conf->use_short_slot ? SHORT_SLOT_TIME : SLOT_TIME;
|
|
|
|
erp.sifs = SIFS;
|
|
|
|
erp.pifs = bss_conf->use_short_slot ? SHORT_PIFS : PIFS;
|
|
|
|
erp.difs = bss_conf->use_short_slot ? SHORT_DIFS : DIFS;
|
|
|
|
erp.eifs = bss_conf->use_short_slot ? SHORT_EIFS : EIFS;
|
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 22:49:59 +08:00
|
|
|
|
2008-10-30 00:17:57 +08:00
|
|
|
erp.basic_rates = bss_conf->basic_rates;
|
2009-05-22 01:16:46 +08:00
|
|
|
erp.beacon_int = bss_conf->beacon_int;
|
2008-10-30 00:17:57 +08:00
|
|
|
|
2011-04-30 23:18:18 +08:00
|
|
|
/* Update the AID, this is needed for dynamic PS support */
|
|
|
|
rt2x00dev->aid = bss_conf->assoc ? bss_conf->aid : 0;
|
2012-05-23 04:13:05 +08:00
|
|
|
rt2x00dev->last_beacon = bss_conf->sync_tsf;
|
2011-04-30 23:18:18 +08:00
|
|
|
|
2009-05-24 03:09:28 +08:00
|
|
|
/* Update global beacon interval time, this is needed for PS support */
|
|
|
|
rt2x00dev->beacon_int = bss_conf->beacon_int;
|
|
|
|
|
2010-10-02 17:28:34 +08:00
|
|
|
if (changed & BSS_CHANGED_HT)
|
|
|
|
erp.ht_opmode = bss_conf->ht_operation_mode;
|
|
|
|
|
2010-09-09 02:56:32 +08:00
|
|
|
rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp, changed);
|
2007-09-26 08:57:13 +08:00
|
|
|
}
|
|
|
|
|
2007-10-13 22:26:36 +08:00
|
|
|
void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
|
2009-08-09 05:53:04 +08:00
|
|
|
struct antenna_setup config)
|
2007-10-13 22:26:36 +08:00
|
|
|
{
|
2009-08-09 05:53:04 +08:00
|
|
|
struct link_ant *ant = &rt2x00dev->link.ant;
|
2008-12-03 01:20:22 +08:00
|
|
|
struct antenna_setup *def = &rt2x00dev->default_ant;
|
|
|
|
struct antenna_setup *active = &rt2x00dev->link.ant.active;
|
|
|
|
|
2008-11-02 07:38:10 +08:00
|
|
|
/*
|
2011-04-18 21:35:12 +08:00
|
|
|
* When the caller tries to send the SW diversity,
|
|
|
|
* we must update the ANTENNA_RX_DIVERSITY flag to
|
|
|
|
* enable the antenna diversity in the link tuner.
|
|
|
|
*
|
|
|
|
* Secondly, we must guarentee we never send the
|
|
|
|
* software antenna diversity command to the driver.
|
2008-11-02 07:38:10 +08:00
|
|
|
*/
|
2011-04-18 21:35:12 +08:00
|
|
|
if (!(ant->flags & ANTENNA_RX_DIVERSITY)) {
|
|
|
|
if (config.rx == ANTENNA_SW_DIVERSITY) {
|
|
|
|
ant->flags |= ANTENNA_RX_DIVERSITY;
|
|
|
|
|
|
|
|
if (def->rx == ANTENNA_SW_DIVERSITY)
|
|
|
|
config.rx = ANTENNA_B;
|
|
|
|
else
|
|
|
|
config.rx = def->rx;
|
|
|
|
}
|
|
|
|
} else if (config.rx == ANTENNA_SW_DIVERSITY)
|
2009-08-09 05:53:04 +08:00
|
|
|
config.rx = active->rx;
|
2007-10-13 22:26:36 +08:00
|
|
|
|
2011-04-18 21:35:12 +08:00
|
|
|
if (!(ant->flags & ANTENNA_TX_DIVERSITY)) {
|
|
|
|
if (config.tx == ANTENNA_SW_DIVERSITY) {
|
|
|
|
ant->flags |= ANTENNA_TX_DIVERSITY;
|
|
|
|
|
|
|
|
if (def->tx == ANTENNA_SW_DIVERSITY)
|
|
|
|
config.tx = ANTENNA_B;
|
|
|
|
else
|
|
|
|
config.tx = def->tx;
|
|
|
|
}
|
|
|
|
} else if (config.tx == ANTENNA_SW_DIVERSITY)
|
2009-08-09 05:53:04 +08:00
|
|
|
config.tx = active->tx;
|
|
|
|
|
2007-10-27 19:39:28 +08:00
|
|
|
/*
|
|
|
|
* Antenna setup changes require the RX to be disabled,
|
|
|
|
* else the changes will be ignored by the device.
|
|
|
|
*/
|
2008-08-30 03:04:26 +08:00
|
|
|
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
2010-12-13 19:35:17 +08:00
|
|
|
rt2x00queue_stop_queue(rt2x00dev->rx);
|
2007-10-27 19:39:28 +08:00
|
|
|
|
2007-10-13 22:26:36 +08:00
|
|
|
/*
|
|
|
|
* Write new antenna setup to device and reset the link tuner.
|
|
|
|
* The latter is required since we need to recalibrate the
|
|
|
|
* noise-sensitivity ratio for the new setup.
|
|
|
|
*/
|
2009-08-09 05:53:04 +08:00
|
|
|
rt2x00dev->ops->lib->config_ant(rt2x00dev, &config);
|
2008-10-30 00:17:57 +08:00
|
|
|
|
2008-12-20 17:53:29 +08:00
|
|
|
rt2x00link_reset_tuner(rt2x00dev, true);
|
2007-10-13 22:26:36 +08:00
|
|
|
|
2009-08-09 05:53:04 +08:00
|
|
|
memcpy(active, &config, sizeof(config));
|
2007-10-27 19:39:28 +08:00
|
|
|
|
2008-08-30 03:04:26 +08:00
|
|
|
if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
|
2010-12-13 19:35:17 +08:00
|
|
|
rt2x00queue_start_queue(rt2x00dev->rx);
|
2007-10-13 22:26:36 +08:00
|
|
|
}
|
|
|
|
|
2011-04-18 21:33:41 +08:00
|
|
|
static u16 rt2x00ht_center_channel(struct rt2x00_dev *rt2x00dev,
|
|
|
|
struct ieee80211_conf *conf)
|
|
|
|
{
|
|
|
|
struct hw_mode_spec *spec = &rt2x00dev->spec;
|
|
|
|
int center_channel;
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize center channel to current channel.
|
|
|
|
*/
|
2013-03-25 23:26:57 +08:00
|
|
|
center_channel = spec->channels[conf->chandef.chan->hw_value].channel;
|
2011-04-18 21:33:41 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Adjust center channel to HT40+ and HT40- operation.
|
|
|
|
*/
|
|
|
|
if (conf_is_ht40_plus(conf))
|
|
|
|
center_channel += 2;
|
|
|
|
else if (conf_is_ht40_minus(conf))
|
|
|
|
center_channel -= (center_channel == 14) ? 1 : 2;
|
|
|
|
|
|
|
|
for (i = 0; i < spec->num_channels; i++)
|
|
|
|
if (spec->channels[i].channel == center_channel)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
WARN_ON(1);
|
2013-03-25 23:26:57 +08:00
|
|
|
return conf->chandef.chan->hw_value;
|
2011-04-18 21:33:41 +08:00
|
|
|
}
|
|
|
|
|
2007-09-26 02:55:39 +08:00
|
|
|
void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
|
2008-10-30 00:17:57 +08:00
|
|
|
struct ieee80211_conf *conf,
|
|
|
|
unsigned int ieee80211_flags)
|
2007-09-26 08:57:13 +08:00
|
|
|
{
|
2007-10-06 19:34:52 +08:00
|
|
|
struct rt2x00lib_conf libconf;
|
2010-06-03 16:52:08 +08:00
|
|
|
u16 hw_value;
|
2011-04-30 23:18:18 +08:00
|
|
|
u16 autowake_timeout;
|
|
|
|
u16 beacon_int;
|
|
|
|
u16 beacon_diff;
|
2007-09-26 08:57:13 +08:00
|
|
|
|
2007-10-06 19:34:52 +08:00
|
|
|
memset(&libconf, 0, sizeof(libconf));
|
|
|
|
|
2008-10-30 00:17:57 +08:00
|
|
|
libconf.conf = conf;
|
2007-10-06 19:34:52 +08:00
|
|
|
|
2008-10-30 00:17:57 +08:00
|
|
|
if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL) {
|
2012-04-04 22:15:33 +08:00
|
|
|
if (!conf_is_ht(conf))
|
|
|
|
set_bit(CONFIG_HT_DISABLED, &rt2x00dev->flags);
|
|
|
|
else
|
|
|
|
clear_bit(CONFIG_HT_DISABLED, &rt2x00dev->flags);
|
|
|
|
|
2010-06-03 16:52:08 +08:00
|
|
|
if (conf_is_ht40(conf)) {
|
2011-04-18 21:27:06 +08:00
|
|
|
set_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags);
|
2010-06-03 16:52:08 +08:00
|
|
|
hw_value = rt2x00ht_center_channel(rt2x00dev, conf);
|
|
|
|
} else {
|
2011-04-18 21:27:06 +08:00
|
|
|
clear_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags);
|
2013-03-25 23:26:57 +08:00
|
|
|
hw_value = conf->chandef.chan->hw_value;
|
2010-06-03 16:52:08 +08:00
|
|
|
}
|
2009-04-26 22:09:32 +08:00
|
|
|
|
2007-10-06 19:34:52 +08:00
|
|
|
memcpy(&libconf.rf,
|
2010-06-03 16:52:08 +08:00
|
|
|
&rt2x00dev->spec.channels[hw_value],
|
2007-10-06 19:34:52 +08:00
|
|
|
sizeof(libconf.rf));
|
2008-08-04 22:38:47 +08:00
|
|
|
|
|
|
|
memcpy(&libconf.channel,
|
2010-06-03 16:52:08 +08:00
|
|
|
&rt2x00dev->spec.channels_info[hw_value],
|
2008-08-04 22:38:47 +08:00
|
|
|
sizeof(libconf.channel));
|
2012-02-16 21:40:57 +08:00
|
|
|
|
|
|
|
/* Used for VCO periodic calibration */
|
|
|
|
rt2x00dev->rf_channel = libconf.rf.channel;
|
2007-10-06 19:34:52 +08:00
|
|
|
}
|
|
|
|
|
2011-04-30 23:18:18 +08:00
|
|
|
if (test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) &&
|
|
|
|
(ieee80211_flags & IEEE80211_CONF_CHANGE_PS))
|
|
|
|
cancel_delayed_work_sync(&rt2x00dev->autowakeup_work);
|
|
|
|
|
2007-10-06 19:34:52 +08:00
|
|
|
/*
|
|
|
|
* Start configuration.
|
|
|
|
*/
|
2008-10-30 00:17:57 +08:00
|
|
|
rt2x00dev->ops->lib->config(rt2x00dev, &libconf, ieee80211_flags);
|
2007-09-26 08:57:13 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some configuration changes affect the link quality
|
|
|
|
* which means we need to reset the link tuner.
|
|
|
|
*/
|
2008-10-30 00:17:57 +08:00
|
|
|
if (ieee80211_flags & IEEE80211_CONF_CHANGE_CHANNEL)
|
2008-12-20 17:53:29 +08:00
|
|
|
rt2x00link_reset_tuner(rt2x00dev, false);
|
2007-09-26 08:57:13 +08:00
|
|
|
|
2011-06-04 22:48:54 +08:00
|
|
|
if (test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags) &&
|
|
|
|
test_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags) &&
|
2011-04-30 23:18:18 +08:00
|
|
|
(ieee80211_flags & IEEE80211_CONF_CHANGE_PS) &&
|
|
|
|
(conf->flags & IEEE80211_CONF_PS)) {
|
|
|
|
beacon_diff = (long)jiffies - (long)rt2x00dev->last_beacon;
|
|
|
|
beacon_int = msecs_to_jiffies(rt2x00dev->beacon_int);
|
|
|
|
|
|
|
|
if (beacon_diff > beacon_int)
|
|
|
|
beacon_diff = 0;
|
|
|
|
|
|
|
|
autowake_timeout = (conf->max_sleep_period * beacon_int) - beacon_diff;
|
|
|
|
queue_delayed_work(rt2x00dev->workqueue,
|
|
|
|
&rt2x00dev->autowakeup_work,
|
|
|
|
autowake_timeout - 15);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (conf->flags & IEEE80211_CONF_PS)
|
|
|
|
set_bit(CONFIG_POWERSAVING, &rt2x00dev->flags);
|
|
|
|
else
|
|
|
|
clear_bit(CONFIG_POWERSAVING, &rt2x00dev->flags);
|
|
|
|
|
2013-03-25 23:26:57 +08:00
|
|
|
rt2x00dev->curr_band = conf->chandef.chan->band;
|
|
|
|
rt2x00dev->curr_freq = conf->chandef.chan->center_freq;
|
2007-09-26 08:57:13 +08:00
|
|
|
rt2x00dev->tx_power = conf->power_level;
|
2008-12-03 01:20:04 +08:00
|
|
|
rt2x00dev->short_retry = conf->short_frame_max_tx_count;
|
|
|
|
rt2x00dev->long_retry = conf->long_frame_max_tx_count;
|
2007-09-26 08:57:13 +08:00
|
|
|
}
|