]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/staging/rtl8192e/rtllib_module.c
staging: rtl8192e: Rename dm_CheckTXPowerTracking_TSSI
[mirror_ubuntu-artful-kernel.git] / drivers / staging / rtl8192e / rtllib_module.c
CommitLineData
94a79942
LF
1/*******************************************************************************
2
3 Copyright(c) 2004 Intel Corporation. All rights reserved.
4
5 Portions of this file are based on the WEP enablement code provided by the
6 Host AP project hostap-drivers v0.1.3
7 Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
8 <jkmaline@cc.hut.fi>
9 Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
10
11 This program is free software; you can redistribute it and/or modify it
12 under the terms of version 2 of the GNU General Public License as
13 published by the Free Software Foundation.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 more details.
19
20 You should have received a copy of the GNU General Public License along with
21 this program; if not, write to the Free Software Foundation, Inc., 59
22 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 The full GNU General Public License is included in this distribution in the
25 file called LICENSE.
26
27 Contact Information:
28 James P. Ketrenos <ipw2100-admin@linux.intel.com>
29 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
30
31*******************************************************************************/
32
33#include <linux/compiler.h>
34#include <linux/errno.h>
35#include <linux/if_arp.h>
36#include <linux/in6.h>
37#include <linux/in.h>
38#include <linux/ip.h>
39#include <linux/kernel.h>
40#include <linux/module.h>
41#include <linux/netdevice.h>
42#include <linux/pci.h>
43#include <linux/proc_fs.h>
44#include <linux/skbuff.h>
45#include <linux/slab.h>
46#include <linux/tcp.h>
47#include <linux/types.h>
94a79942
LF
48#include <linux/wireless.h>
49#include <linux/etherdevice.h>
8567829a 50#include <linux/uaccess.h>
94a79942
LF
51#include <net/arp.h>
52
53#include "rtllib.h"
54
55
d37e0208
SM
56u32 rt_global_debug_component = COMP_ERR;
57EXPORT_SYMBOL(rt_global_debug_component);
58
59
94a79942
LF
60
61static inline int rtllib_networks_allocate(struct rtllib_device *ieee)
62{
63 if (ieee->networks)
64 return 0;
65
ec0dc6be 66 ieee->networks = kzalloc(
94a79942
LF
67 MAX_NETWORK_COUNT * sizeof(struct rtllib_network),
68 GFP_KERNEL);
b6b0012c 69 if (!ieee->networks)
94a79942 70 return -ENOMEM;
94a79942 71
94a79942
LF
72 return 0;
73}
74
75static inline void rtllib_networks_free(struct rtllib_device *ieee)
76{
77 if (!ieee->networks)
78 return;
94a79942 79 kfree(ieee->networks);
94a79942
LF
80 ieee->networks = NULL;
81}
82
83static inline void rtllib_networks_initialize(struct rtllib_device *ieee)
84{
85 int i;
86
87 INIT_LIST_HEAD(&ieee->network_free_list);
88 INIT_LIST_HEAD(&ieee->network_list);
89 for (i = 0; i < MAX_NETWORK_COUNT; i++)
8567829a
LF
90 list_add_tail(&ieee->networks[i].list,
91 &ieee->network_free_list);
94a79942
LF
92}
93
94a79942
LF
94struct net_device *alloc_rtllib(int sizeof_priv)
95{
96 struct rtllib_device *ieee = NULL;
97 struct net_device *dev;
8567829a 98 int i, err;
94a79942 99
def16d2e 100 pr_debug("rtllib: Initializing...\n");
94a79942
LF
101
102 dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
103 if (!dev) {
f0dddb1d 104 pr_err("Unable to allocate net_device.\n");
49d74d70 105 return NULL;
94a79942
LF
106 }
107 ieee = (struct rtllib_device *)netdev_priv_rsl(dev);
108 memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv);
109 ieee->dev = dev;
110
94a79942
LF
111 err = rtllib_networks_allocate(ieee);
112 if (err) {
f0dddb1d 113 pr_err("Unable to allocate beacon storage: %d\n", err);
94a79942
LF
114 goto failed;
115 }
116 rtllib_networks_initialize(ieee);
117
118
119 /* Default fragmentation threshold is maximum payload size */
120 ieee->fts = DEFAULT_FTS;
121 ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
122 ieee->open_wep = 1;
123
124 /* Default to enabling full open WEP with host based encrypt/decrypt */
125 ieee->host_encrypt = 1;
126 ieee->host_decrypt = 1;
127 ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
128
94a79942
LF
129 ieee->rtllib_ap_sec_type = rtllib_ap_sec_type;
130
131 spin_lock_init(&ieee->lock);
132 spin_lock_init(&ieee->wpax_suitlist_lock);
94a79942 133 spin_lock_init(&ieee->reorder_spinlock);
94a79942
LF
134 atomic_set(&(ieee->atm_swbw), 0);
135
3b148be0
SM
136 /* SAM FIXME */
137 lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock);
138
94a79942
LF
139 ieee->wpa_enabled = 0;
140 ieee->tkip_countermeasures = 0;
141 ieee->drop_unencrypted = 0;
142 ieee->privacy_invoked = 0;
143 ieee->ieee802_1x = 1;
144 ieee->raw_tx = 0;
145 ieee->hwsec_active = 0;
146
8567829a 147 memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
94a79942
LF
148 rtllib_softmac_init(ieee);
149
8567829a 150 ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL);
b6b0012c 151 if (ieee->pHTInfo == NULL)
94a79942 152 return NULL;
b6b0012c 153
94a79942
LF
154 HTUpdateDefaultSetting(ieee);
155 HTInitializeHTInfo(ieee);
156 TSInitialize(ieee);
157 for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
158 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
159
160 for (i = 0; i < 17; i++) {
161 ieee->last_rxseq_num[i] = -1;
162 ieee->last_rxfrag_num[i] = -1;
163 ieee->last_packet_time[i] = 0;
164 }
165
94a79942
LF
166 return dev;
167
168 failed:
49d74d70 169 free_netdev(dev);
94a79942
LF
170 return NULL;
171}
3b28499c 172EXPORT_SYMBOL(alloc_rtllib);
94a79942 173
94a79942
LF
174void free_rtllib(struct net_device *dev)
175{
8567829a
LF
176 struct rtllib_device *ieee = (struct rtllib_device *)
177 netdev_priv_rsl(dev);
d7613e53
LF
178
179 kfree(ieee->pHTInfo);
180 ieee->pHTInfo = NULL;
94a79942 181 rtllib_softmac_free(ieee);
0ddcf5fd 182
3b148be0 183 lib80211_crypt_info_free(&ieee->crypt_info);
94a79942
LF
184
185 rtllib_networks_free(ieee);
94a79942
LF
186 free_netdev(dev);
187}
3b28499c 188EXPORT_SYMBOL(free_rtllib);
94a79942 189
cf8ab8cf 190static int __init rtllib_init(void)
94a79942 191{
94a79942
LF
192 return 0;
193}
194
cf8ab8cf 195static void __exit rtllib_exit(void)
94a79942 196{
94a79942 197}
d37e0208
SM
198
199module_init(rtllib_init);
200module_exit(rtllib_exit);
201
202MODULE_LICENSE("GPL");