2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Abstract: rt2x00 generic configuration routines.
27 * Set enviroment defines for rt2x00.h
29 #define DRV_NAME "rt2x00lib"
31 #include <linux/kernel.h>
32 #include <linux/module.h>
35 #include "rt2x00lib.h"
39 * The MAC and BSSID addressess are simple array of bytes,
40 * these arrays are little endian, so when sending the addressess
41 * to the drivers, copy the it into a endian-signed variable.
43 * Note that all devices (except rt2500usb) have 32 bits
44 * register word sizes. This means that whatever variable we
45 * pass _must_ be a multiple of 32 bits. Otherwise the device
46 * might not accept what we are sending to it.
47 * This will also make it easier for the driver to write
48 * the data to the device.
50 * Also note that when NULL is passed as address the
51 * we will send 00:00:00:00:00 to the device to clear the address.
52 * This will prevent the device being confused when it wants
53 * to ACK frames or consideres itself associated.
55 void rt2x00lib_config_mac_addr(struct rt2x00_dev *rt2x00dev, u8 *mac)
59 memset(®, 0, sizeof(reg));
61 memcpy(®, mac, ETH_ALEN);
63 rt2x00dev->ops->lib->config_mac_addr(rt2x00dev, ®[0]);
66 void rt2x00lib_config_bssid(struct rt2x00_dev *rt2x00dev, u8 *bssid)
70 memset(®, 0, sizeof(reg));
72 memcpy(®, bssid, ETH_ALEN);
74 rt2x00dev->ops->lib->config_bssid(rt2x00dev, ®[0]);
77 void rt2x00lib_config_type(struct rt2x00_dev *rt2x00dev, const int type)
82 case IEEE80211_IF_TYPE_IBSS:
83 case IEEE80211_IF_TYPE_AP:
84 tsf_sync = TSF_SYNC_BEACON;
86 case IEEE80211_IF_TYPE_STA:
87 tsf_sync = TSF_SYNC_INFRA;
90 tsf_sync = TSF_SYNC_NONE;
94 rt2x00dev->ops->lib->config_type(rt2x00dev, type, tsf_sync);
97 void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
98 struct ieee80211_conf *conf, const int force_config)
103 * In some situations we want to force all configurations
104 * to be reloaded (When resuming for instance).
107 flags = CONFIG_UPDATE_ALL;
112 * Check which configuration options have been
113 * updated and should be send to the device.
115 if (rt2x00dev->rx_status.phymode != conf->phymode)
116 flags |= CONFIG_UPDATE_PHYMODE;
117 if (rt2x00dev->rx_status.channel != conf->channel)
118 flags |= CONFIG_UPDATE_CHANNEL;
119 if (rt2x00dev->tx_power != conf->power_level)
120 flags |= CONFIG_UPDATE_TXPOWER;
121 if (rt2x00dev->rx_status.antenna == conf->antenna_sel_rx)
122 flags |= CONFIG_UPDATE_ANTENNA;
125 * The following configuration options are never
126 * stored anywhere and will always be updated.
128 flags |= CONFIG_UPDATE_SLOT_TIME;
129 flags |= CONFIG_UPDATE_BEACON_INT;
132 rt2x00dev->ops->lib->config(rt2x00dev, flags, conf);
135 * Some configuration changes affect the link quality
136 * which means we need to reset the link tuner.
138 if (flags & (CONFIG_UPDATE_CHANNEL | CONFIG_UPDATE_ANTENNA))
139 rt2x00lib_reset_link_tuner(rt2x00dev);
141 rt2x00dev->rx_status.phymode = conf->phymode;
142 rt2x00dev->rx_status.freq = conf->freq;
143 rt2x00dev->rx_status.channel = conf->channel;
144 rt2x00dev->tx_power = conf->power_level;
145 rt2x00dev->rx_status.antenna = conf->antenna_sel_rx;