caps.c
Go to the documentation of this file.
00001 /*------------------------------------------------------------------------------
00002  *-------------------------        ATH5K Driver          -----------------------
00003  *------------------------------------------------------------------------------
00004  *                                                           V1.0  08/02/2010
00005  *
00006  *
00007  *  Feb 2010 - Samuel Cabrero <samuelcabrero@gmail.com>
00008  *              Initial release
00009  *
00010  *  ----------------------------------------------------------------------------
00011  *  Copyright (C) 2000-2010, Universidad de Zaragoza, SPAIN
00012  *
00013  *  Autors:
00014  *              Samuel Cabrero        <samuelcabrero@gmail.com>
00015  *              Danilo Tardioli       <dantard@unizar.es>
00016  *              Jose Luis Villarroel  <jlvilla@unizar.es>
00017  *
00018  *  This is a simplified version of the original ath5k driver. It should work 
00019  *  with all Atheros 5xxx WLAN cards. The 802.11 layer have been removed so it
00020  *  just send and receive frames over the air, as if it were an Ethernet bus
00021  *  interface.
00022  *
00023  *  Please read ath5k_interface.h for instructions.
00024  *
00025  *  This program is distributed under the terms of GPL version 2 and in the 
00026  *  hope that it will be useful, but WITHOUT ANY WARRANTY; without even the 
00027  *  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00028  *  See the GNU General Public License for more details.
00029  *
00030  *----------------------------------------------------------------------------*/
00031 /*
00032  * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
00033  * Copyright (c) 2006-2008 Nick Kossifidis <mickflemm@gmail.com>
00034  * Copyright (c) 2007-2008 Jiri Slaby <jirislaby@gmail.com>
00035  *
00036  * Permission to use, copy, modify, and distribute this software for any
00037  * purpose with or without fee is hereby granted, provided that the above
00038  * copyright notice and this permission notice appear in all copies.
00039  *
00040  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00041  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00042  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00043  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00044  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00045  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00046  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00047  *
00048  */
00049 
00050 /**************\
00051 * Capabilities *
00052 \**************/
00053 
00054 #include "ath5k.h"
00055 #include "reg.h"
00056 #include "debug.h"
00057 #include "base.h"
00058 
00059 /*
00060  * Fill the capabilities struct
00061  * TODO: Merge this with EEPROM code when we are done with it
00062  */
00063 int ath5k_hw_set_capabilities(struct ath5k_hw *ah)
00064 {
00065         u16 ee_header;
00066 
00067         ATH5K_TRACE(ah->ah_sc);
00068         /* Capabilities stored in the EEPROM */
00069         ee_header = ah->ah_capabilities.cap_eeprom.ee_header;
00070 
00071         if (ah->ah_version == AR5K_AR5210) {
00072                 /*
00073                  * Set radio capabilities
00074                  * (The AR5110 only supports the middle 5GHz band)
00075                  */
00076                 ah->ah_capabilities.cap_range.range_5ghz_min = 5120;
00077                 ah->ah_capabilities.cap_range.range_5ghz_max = 5430;
00078                 ah->ah_capabilities.cap_range.range_2ghz_min = 0;
00079                 ah->ah_capabilities.cap_range.range_2ghz_max = 0;
00080 
00081                 /* Set supported modes */
00082                 __set_bit(AR5K_MODE_11A, ah->ah_capabilities.cap_mode);
00083                 __set_bit(AR5K_MODE_11A_TURBO, ah->ah_capabilities.cap_mode);
00084         } else {
00085                 /*
00086                  * XXX The tranceiver supports frequencies from 4920 to 6100GHz
00087                  * XXX and from 2312 to 2732GHz. There are problems with the
00088                  * XXX current ieee80211 implementation because the IEEE
00089                  * XXX channel mapping does not support negative channel
00090                  * XXX numbers (2312MHz is channel -19). Of course, this
00091                  * XXX doesn't matter because these channels are out of range
00092                  * XXX but some regulation domains like MKK (Japan) will
00093                  * XXX support frequencies somewhere around 4.8GHz.
00094                  */
00095 
00096                 /*
00097                  * Set radio capabilities
00098                  */
00099 
00100                 if (AR5K_EEPROM_HDR_11A(ee_header)) {
00101                         /* 4920 */
00102                         ah->ah_capabilities.cap_range.range_5ghz_min = 5005;
00103                         ah->ah_capabilities.cap_range.range_5ghz_max = 6100;
00104 
00105                         /* Set supported modes */
00106                         __set_bit(AR5K_MODE_11A,
00107                                         ah->ah_capabilities.cap_mode);
00108                         __set_bit(AR5K_MODE_11A_TURBO,
00109                                         ah->ah_capabilities.cap_mode);
00110                         if (ah->ah_version == AR5K_AR5212)
00111                                 __set_bit(AR5K_MODE_11G_TURBO,
00112                                                 ah->ah_capabilities.cap_mode);
00113                 }
00114 
00115                 /* Enable  802.11b if a 2GHz capable radio (2111/5112) is
00116                  * connected */
00117                 if (AR5K_EEPROM_HDR_11B(ee_header) ||
00118                     (AR5K_EEPROM_HDR_11G(ee_header) &&
00119                      ah->ah_version != AR5K_AR5211)) {
00120                         /* 2312 */
00121                         ah->ah_capabilities.cap_range.range_2ghz_min = 2412;
00122                         ah->ah_capabilities.cap_range.range_2ghz_max = 2732;
00123 
00124                         if (AR5K_EEPROM_HDR_11B(ee_header))
00125                                 __set_bit(AR5K_MODE_11B,
00126                                                 ah->ah_capabilities.cap_mode);
00127 
00128                         if (AR5K_EEPROM_HDR_11G(ee_header) &&
00129                             ah->ah_version != AR5K_AR5211)
00130                                 __set_bit(AR5K_MODE_11G,
00131                                                 ah->ah_capabilities.cap_mode);
00132                 }
00133         }
00134 
00135         /* Set number of supported TX queues */
00136         if (ah->ah_version == AR5K_AR5210)
00137                 ah->ah_capabilities.cap_queues.q_tx_num =
00138                         AR5K_NUM_TX_QUEUES_NOQCU;
00139         else
00140                 ah->ah_capabilities.cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES;
00141 
00142         return 0;
00143 }
00144 
00145 /* Main function used by the driver part to check caps */
00146 int ath5k_hw_get_capability(struct ath5k_hw *ah,
00147                 enum ath5k_capability_type cap_type,
00148                 u32 capability, u32 *result)
00149 {
00150         ATH5K_TRACE(ah->ah_sc);
00151 
00152         switch (cap_type) {
00153         case AR5K_CAP_NUM_TXQUEUES:
00154                 if (result) {
00155                         if (ah->ah_version == AR5K_AR5210)
00156                                 *result = AR5K_NUM_TX_QUEUES_NOQCU;
00157                         else
00158                                 *result = AR5K_NUM_TX_QUEUES;
00159                         goto yes;
00160                 }
00161         case AR5K_CAP_VEOL:
00162                 goto yes;
00163         case AR5K_CAP_COMPRESSION:
00164                 if (ah->ah_version == AR5K_AR5212)
00165                         goto yes;
00166                 else
00167                         goto no;
00168         case AR5K_CAP_BURST:
00169                 goto yes;
00170         case AR5K_CAP_TPC:
00171                 goto yes;
00172         case AR5K_CAP_BSSIDMASK:
00173                 if (ah->ah_version == AR5K_AR5212)
00174                         goto yes;
00175                 else
00176                         goto no;
00177         case AR5K_CAP_XR:
00178                 if (ah->ah_version == AR5K_AR5212)
00179                         goto yes;
00180                 else
00181                         goto no;
00182         default:
00183                 goto no;
00184         }
00185 
00186 no:
00187         return -EINVAL;
00188 yes:
00189         return 0;
00190 }
00191 
00192 /*
00193  * TODO: Following functions should be part of a new function
00194  * set_capability
00195  */
00196 
00197 int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid,
00198                 u16 assoc_id)
00199 {
00200         ATH5K_TRACE(ah->ah_sc);
00201 
00202         if (ah->ah_version == AR5K_AR5210) {
00203                 AR5K_REG_DISABLE_BITS(ah, AR5K_STA_ID1,
00204                         AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
00205                 return 0;
00206         }
00207 
00208         return -EIO;
00209 }
00210 
00211 int ath5k_hw_disable_pspoll(struct ath5k_hw *ah)
00212 {
00213         ATH5K_TRACE(ah->ah_sc);
00214 
00215         if (ah->ah_version == AR5K_AR5210) {
00216                 AR5K_REG_ENABLE_BITS(ah, AR5K_STA_ID1,
00217                         AR5K_STA_ID1_NO_PSPOLL | AR5K_STA_ID1_DEFAULT_ANTENNA);
00218                 return 0;
00219         }
00220 
00221         return -EIO;
00222 }


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Fri Jan 3 2014 12:07:54