]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/rtl8192e/rtllib_module.c
staging: rtl8192e: Fix trivial LONG_LINE errors
[karo-tx-linux.git] / drivers / staging / rtl8192e / rtllib_module.c
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>
48 #include <linux/wireless.h>
49 #include <linux/etherdevice.h>
50 #include <linux/uaccess.h>
51 #include <net/arp.h>
52
53 #include "rtllib.h"
54
55
56 u32 rt_global_debug_component = COMP_ERR;
57 EXPORT_SYMBOL(rt_global_debug_component);
58
59
60 void _setup_timer(struct timer_list *ptimer, void *fun, unsigned long data)
61 {
62         ptimer->function = fun;
63         ptimer->data = data;
64         init_timer(ptimer);
65 }
66
67 static inline int rtllib_networks_allocate(struct rtllib_device *ieee)
68 {
69         if (ieee->networks)
70                 return 0;
71
72         ieee->networks = kzalloc(
73                 MAX_NETWORK_COUNT * sizeof(struct rtllib_network),
74                 GFP_KERNEL);
75         if (!ieee->networks)
76                 return -ENOMEM;
77
78         return 0;
79 }
80
81 static inline void rtllib_networks_free(struct rtllib_device *ieee)
82 {
83         if (!ieee->networks)
84                 return;
85         kfree(ieee->networks);
86         ieee->networks = NULL;
87 }
88
89 static inline void rtllib_networks_initialize(struct rtllib_device *ieee)
90 {
91         int i;
92
93         INIT_LIST_HEAD(&ieee->network_free_list);
94         INIT_LIST_HEAD(&ieee->network_list);
95         for (i = 0; i < MAX_NETWORK_COUNT; i++)
96                 list_add_tail(&ieee->networks[i].list,
97                               &ieee->network_free_list);
98 }
99
100 struct net_device *alloc_rtllib(int sizeof_priv)
101 {
102         struct rtllib_device *ieee = NULL;
103         struct net_device *dev;
104         int i, err;
105
106         pr_debug("rtllib: Initializing...\n");
107
108         dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
109         if (!dev) {
110                 pr_err("Unable to allocate net_device.\n");
111                 return NULL;
112         }
113         ieee = (struct rtllib_device *)netdev_priv_rsl(dev);
114         memset(ieee, 0, sizeof(struct rtllib_device)+sizeof_priv);
115         ieee->dev = dev;
116
117         err = rtllib_networks_allocate(ieee);
118         if (err) {
119                 pr_err("Unable to allocate beacon storage: %d\n", err);
120                 goto failed;
121         }
122         rtllib_networks_initialize(ieee);
123
124
125         /* Default fragmentation threshold is maximum payload size */
126         ieee->fts = DEFAULT_FTS;
127         ieee->scan_age = DEFAULT_MAX_SCAN_AGE;
128         ieee->open_wep = 1;
129
130         /* Default to enabling full open WEP with host based encrypt/decrypt */
131         ieee->host_encrypt = 1;
132         ieee->host_decrypt = 1;
133         ieee->ieee802_1x = 1; /* Default to supporting 802.1x */
134
135         ieee->rtllib_ap_sec_type = rtllib_ap_sec_type;
136
137         spin_lock_init(&ieee->lock);
138         spin_lock_init(&ieee->wpax_suitlist_lock);
139         spin_lock_init(&ieee->bw_spinlock);
140         spin_lock_init(&ieee->reorder_spinlock);
141         atomic_set(&(ieee->atm_chnlop), 0);
142         atomic_set(&(ieee->atm_swbw), 0);
143
144         /* SAM FIXME */
145         lib80211_crypt_info_init(&ieee->crypt_info, "RTLLIB", &ieee->lock);
146
147         ieee->bHalfNMode = false;
148         ieee->wpa_enabled = 0;
149         ieee->tkip_countermeasures = 0;
150         ieee->drop_unencrypted = 0;
151         ieee->privacy_invoked = 0;
152         ieee->ieee802_1x = 1;
153         ieee->raw_tx = 0;
154         ieee->hwsec_active = 0;
155
156         memset(ieee->swcamtable, 0, sizeof(struct sw_cam_table) * 32);
157         rtllib_softmac_init(ieee);
158
159         ieee->pHTInfo = kzalloc(sizeof(struct rt_hi_throughput), GFP_KERNEL);
160         if (ieee->pHTInfo == NULL)
161                 return NULL;
162
163         HTUpdateDefaultSetting(ieee);
164         HTInitializeHTInfo(ieee);
165         TSInitialize(ieee);
166         for (i = 0; i < IEEE_IBSS_MAC_HASH_SIZE; i++)
167                 INIT_LIST_HEAD(&ieee->ibss_mac_hash[i]);
168
169         for (i = 0; i < 17; i++) {
170                 ieee->last_rxseq_num[i] = -1;
171                 ieee->last_rxfrag_num[i] = -1;
172                 ieee->last_packet_time[i] = 0;
173         }
174
175         return dev;
176
177  failed:
178         free_netdev(dev);
179         return NULL;
180 }
181 EXPORT_SYMBOL(alloc_rtllib);
182
183 void free_rtllib(struct net_device *dev)
184 {
185         struct rtllib_device *ieee = (struct rtllib_device *)
186                                       netdev_priv_rsl(dev);
187
188         kfree(ieee->pHTInfo);
189         ieee->pHTInfo = NULL;
190         rtllib_softmac_free(ieee);
191
192         lib80211_crypt_info_free(&ieee->crypt_info);
193
194         rtllib_networks_free(ieee);
195         free_netdev(dev);
196 }
197 EXPORT_SYMBOL(free_rtllib);
198
199 static int __init rtllib_init(void)
200 {
201         return 0;
202 }
203
204 static void __exit rtllib_exit(void)
205 {
206 }
207
208 module_init(rtllib_init);
209 module_exit(rtllib_exit);
210
211 MODULE_LICENSE("GPL");