1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright(c) 2004 Intel Corporation. All rights reserved.
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
9 * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
11 * Contact Information:
12 * James P. Ketrenos <ipw2100-admin@linux.intel.com>
13 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
16 #include <linux/compiler.h>
17 #include <linux/errno.h>
18 #include <linux/if_arp.h>
19 #include <linux/in6.h>
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/netdevice.h>
25 #include <linux/pci.h>
26 #include <linux/proc_fs.h>
27 #include <linux/skbuff.h>
28 #include <linux/slab.h>
29 #include <linux/tcp.h>
30 #include <linux/types.h>
31 #include <linux/wireless.h>
32 #include <linux/etherdevice.h>
33 #include <linux/uaccess.h>
37 u32 rt_global_debug_component
= COMP_ERR
;
38 EXPORT_SYMBOL(rt_global_debug_component
);
40 static inline int rtllib_networks_allocate(struct rtllib_device
*ieee
)
45 ieee
->networks
= kcalloc(MAX_NETWORK_COUNT
,
46 sizeof(struct rtllib_network
), GFP_KERNEL
);
53 static inline void rtllib_networks_free(struct rtllib_device
*ieee
)
57 kfree(ieee
->networks
);
58 ieee
->networks
= NULL
;
61 static inline void rtllib_networks_initialize(struct rtllib_device
*ieee
)
65 INIT_LIST_HEAD(&ieee
->network_free_list
);
66 INIT_LIST_HEAD(&ieee
->network_list
);
67 for (i
= 0; i
< MAX_NETWORK_COUNT
; i
++)
68 list_add_tail(&ieee
->networks
[i
].list
,
69 &ieee
->network_free_list
);
72 struct net_device
*alloc_rtllib(int sizeof_priv
)
74 struct rtllib_device
*ieee
= NULL
;
75 struct net_device
*dev
;
78 pr_debug("rtllib: Initializing...\n");
80 dev
= alloc_etherdev(sizeof(struct rtllib_device
) + sizeof_priv
);
82 pr_err("Unable to allocate net_device.\n");
85 ieee
= (struct rtllib_device
*)netdev_priv_rsl(dev
);
88 err
= rtllib_networks_allocate(ieee
);
90 pr_err("Unable to allocate beacon storage: %d\n", err
);
93 rtllib_networks_initialize(ieee
);
95 /* Default fragmentation threshold is maximum payload size */
96 ieee
->fts
= DEFAULT_FTS
;
97 ieee
->scan_age
= DEFAULT_MAX_SCAN_AGE
;
100 /* Default to enabling full open WEP with host based encrypt/decrypt */
101 ieee
->host_encrypt
= 1;
102 ieee
->host_decrypt
= 1;
103 ieee
->ieee802_1x
= 1; /* Default to supporting 802.1x */
105 ieee
->rtllib_ap_sec_type
= rtllib_ap_sec_type
;
107 spin_lock_init(&ieee
->lock
);
108 spin_lock_init(&ieee
->wpax_suitlist_lock
);
109 spin_lock_init(&ieee
->reorder_spinlock
);
110 atomic_set(&(ieee
->atm_swbw
), 0);
113 lib80211_crypt_info_init(&ieee
->crypt_info
, "RTLLIB", &ieee
->lock
);
115 ieee
->wpa_enabled
= 0;
116 ieee
->tkip_countermeasures
= 0;
117 ieee
->drop_unencrypted
= 0;
118 ieee
->privacy_invoked
= 0;
119 ieee
->ieee802_1x
= 1;
121 ieee
->hwsec_active
= 0;
123 memset(ieee
->swcamtable
, 0, sizeof(struct sw_cam_table
) * 32);
124 rtllib_softmac_init(ieee
);
126 ieee
->pHTInfo
= kzalloc(sizeof(struct rt_hi_throughput
), GFP_KERNEL
);
130 HTUpdateDefaultSetting(ieee
);
131 HTInitializeHTInfo(ieee
);
133 for (i
= 0; i
< IEEE_IBSS_MAC_HASH_SIZE
; i
++)
134 INIT_LIST_HEAD(&ieee
->ibss_mac_hash
[i
]);
136 for (i
= 0; i
< 17; i
++) {
137 ieee
->last_rxseq_num
[i
] = -1;
138 ieee
->last_rxfrag_num
[i
] = -1;
139 ieee
->last_packet_time
[i
] = 0;
148 EXPORT_SYMBOL(alloc_rtllib
);
150 void free_rtllib(struct net_device
*dev
)
152 struct rtllib_device
*ieee
= (struct rtllib_device
*)
153 netdev_priv_rsl(dev
);
155 kfree(ieee
->pHTInfo
);
156 ieee
->pHTInfo
= NULL
;
157 rtllib_softmac_free(ieee
);
159 lib80211_crypt_info_free(&ieee
->crypt_info
);
161 rtllib_networks_free(ieee
);
164 EXPORT_SYMBOL(free_rtllib
);
166 static int __init
rtllib_init(void)
171 static void __exit
rtllib_exit(void)
175 module_init(rtllib_init
);
176 module_exit(rtllib_exit
);
178 MODULE_LICENSE("GPL");