| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright 2002-2005, Instant802 Networks, Inc. | 
 | 3 |  * Copyright 2005-2006, Devicescape Software, Inc. | 
 | 4 |  * Copyright 2006-2007	Jiri Benc <jbenc@suse.cz> | 
 | 5 |  * | 
 | 6 |  * This program is free software; you can redistribute it and/or modify | 
 | 7 |  * it under the terms of the GNU General Public License version 2 as | 
 | 8 |  * published by the Free Software Foundation. | 
 | 9 |  */ | 
 | 10 |  | 
 | 11 | #include <net/mac80211.h> | 
 | 12 | #include <net/ieee80211_radiotap.h> | 
 | 13 | #include <linux/module.h> | 
 | 14 | #include <linux/init.h> | 
 | 15 | #include <linux/netdevice.h> | 
 | 16 | #include <linux/types.h> | 
 | 17 | #include <linux/slab.h> | 
 | 18 | #include <linux/skbuff.h> | 
 | 19 | #include <linux/etherdevice.h> | 
 | 20 | #include <linux/if_arp.h> | 
 | 21 | #include <linux/wireless.h> | 
 | 22 | #include <linux/rtnetlink.h> | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 23 | #include <linux/bitmap.h> | 
 | 24 | #include <net/cfg80211.h> | 
 | 25 |  | 
 | 26 | #include "ieee80211_common.h" | 
 | 27 | #include "ieee80211_i.h" | 
 | 28 | #include "ieee80211_rate.h" | 
 | 29 | #include "wep.h" | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 30 | #include "wme.h" | 
 | 31 | #include "aes_ccm.h" | 
 | 32 | #include "ieee80211_led.h" | 
 | 33 | #include "ieee80211_cfg.h" | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 34 | #include "debugfs.h" | 
 | 35 | #include "debugfs_netdev.h" | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 36 |  | 
 | 37 | /* privid for wiphys to determine whether they belong to us or not */ | 
 | 38 | void *mac80211_wiphy_privid = &mac80211_wiphy_privid; | 
 | 39 |  | 
 | 40 | /* See IEEE 802.1H for LLC/SNAP encapsulation/decapsulation */ | 
 | 41 | /* Ethernet-II snap header (RFC1042 for most EtherTypes) */ | 
| Johannes Berg | 571ecf6 | 2007-07-27 15:43:22 +0200 | [diff] [blame] | 42 | const unsigned char rfc1042_header[] = | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 43 | 	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; | 
 | 44 |  | 
 | 45 | /* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ | 
| Johannes Berg | 571ecf6 | 2007-07-27 15:43:22 +0200 | [diff] [blame] | 46 | const unsigned char bridge_tunnel_header[] = | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 47 | 	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 }; | 
 | 48 |  | 
 | 49 | /* No encapsulation header if EtherType < 0x600 (=length) */ | 
 | 50 | static const unsigned char eapol_header[] = | 
 | 51 | 	{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e }; | 
 | 52 |  | 
 | 53 |  | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 54 | /* | 
 | 55 |  * For seeing transmitted packets on monitor interfaces | 
 | 56 |  * we have a radiotap header too. | 
 | 57 |  */ | 
 | 58 | struct ieee80211_tx_status_rtap_hdr { | 
 | 59 | 	struct ieee80211_radiotap_header hdr; | 
 | 60 | 	__le16 tx_flags; | 
 | 61 | 	u8 data_retries; | 
 | 62 | } __attribute__ ((packed)); | 
 | 63 |  | 
 | 64 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 65 | static int rate_list_match(const int *rate_list, int rate) | 
 | 66 | { | 
 | 67 | 	int i; | 
 | 68 |  | 
 | 69 | 	if (!rate_list) | 
 | 70 | 		return 0; | 
 | 71 |  | 
 | 72 | 	for (i = 0; rate_list[i] >= 0; i++) | 
 | 73 | 		if (rate_list[i] == rate) | 
 | 74 | 			return 1; | 
 | 75 |  | 
 | 76 | 	return 0; | 
 | 77 | } | 
 | 78 |  | 
 | 79 |  | 
 | 80 | void ieee80211_prepare_rates(struct ieee80211_local *local, | 
 | 81 | 			     struct ieee80211_hw_mode *mode) | 
 | 82 | { | 
 | 83 | 	int i; | 
 | 84 |  | 
 | 85 | 	for (i = 0; i < mode->num_rates; i++) { | 
 | 86 | 		struct ieee80211_rate *rate = &mode->rates[i]; | 
 | 87 |  | 
 | 88 | 		rate->flags &= ~(IEEE80211_RATE_SUPPORTED | | 
 | 89 | 				 IEEE80211_RATE_BASIC); | 
 | 90 |  | 
 | 91 | 		if (local->supp_rates[mode->mode]) { | 
 | 92 | 			if (!rate_list_match(local->supp_rates[mode->mode], | 
 | 93 | 					     rate->rate)) | 
 | 94 | 				continue; | 
 | 95 | 		} | 
 | 96 |  | 
 | 97 | 		rate->flags |= IEEE80211_RATE_SUPPORTED; | 
 | 98 |  | 
 | 99 | 		/* Use configured basic rate set if it is available. If not, | 
 | 100 | 		 * use defaults that are sane for most cases. */ | 
 | 101 | 		if (local->basic_rates[mode->mode]) { | 
 | 102 | 			if (rate_list_match(local->basic_rates[mode->mode], | 
 | 103 | 					    rate->rate)) | 
 | 104 | 				rate->flags |= IEEE80211_RATE_BASIC; | 
 | 105 | 		} else switch (mode->mode) { | 
 | 106 | 		case MODE_IEEE80211A: | 
 | 107 | 			if (rate->rate == 60 || rate->rate == 120 || | 
 | 108 | 			    rate->rate == 240) | 
 | 109 | 				rate->flags |= IEEE80211_RATE_BASIC; | 
 | 110 | 			break; | 
 | 111 | 		case MODE_IEEE80211B: | 
 | 112 | 			if (rate->rate == 10 || rate->rate == 20) | 
 | 113 | 				rate->flags |= IEEE80211_RATE_BASIC; | 
 | 114 | 			break; | 
 | 115 | 		case MODE_ATHEROS_TURBO: | 
 | 116 | 			if (rate->rate == 120 || rate->rate == 240 || | 
 | 117 | 			    rate->rate == 480) | 
 | 118 | 				rate->flags |= IEEE80211_RATE_BASIC; | 
 | 119 | 			break; | 
 | 120 | 		case MODE_IEEE80211G: | 
 | 121 | 			if (rate->rate == 10 || rate->rate == 20 || | 
 | 122 | 			    rate->rate == 55 || rate->rate == 110) | 
 | 123 | 				rate->flags |= IEEE80211_RATE_BASIC; | 
 | 124 | 			break; | 
 | 125 | 		} | 
 | 126 |  | 
 | 127 | 		/* Set ERP and MANDATORY flags based on phymode */ | 
 | 128 | 		switch (mode->mode) { | 
 | 129 | 		case MODE_IEEE80211A: | 
 | 130 | 			if (rate->rate == 60 || rate->rate == 120 || | 
 | 131 | 			    rate->rate == 240) | 
 | 132 | 				rate->flags |= IEEE80211_RATE_MANDATORY; | 
 | 133 | 			break; | 
 | 134 | 		case MODE_IEEE80211B: | 
 | 135 | 			if (rate->rate == 10) | 
 | 136 | 				rate->flags |= IEEE80211_RATE_MANDATORY; | 
 | 137 | 			break; | 
 | 138 | 		case MODE_ATHEROS_TURBO: | 
 | 139 | 			break; | 
 | 140 | 		case MODE_IEEE80211G: | 
 | 141 | 			if (rate->rate == 10 || rate->rate == 20 || | 
 | 142 | 			    rate->rate == 55 || rate->rate == 110 || | 
 | 143 | 			    rate->rate == 60 || rate->rate == 120 || | 
 | 144 | 			    rate->rate == 240) | 
 | 145 | 				rate->flags |= IEEE80211_RATE_MANDATORY; | 
 | 146 | 			break; | 
 | 147 | 		} | 
 | 148 | 		if (ieee80211_is_erp_rate(mode->mode, rate->rate)) | 
 | 149 | 			rate->flags |= IEEE80211_RATE_ERP; | 
 | 150 | 	} | 
 | 151 | } | 
 | 152 |  | 
 | 153 |  | 
| Johannes Berg | 571ecf6 | 2007-07-27 15:43:22 +0200 | [diff] [blame] | 154 | void ieee80211_key_threshold_notify(struct net_device *dev, | 
 | 155 | 				    struct ieee80211_key *key, | 
 | 156 | 				    struct sta_info *sta) | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 157 | { | 
 | 158 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 159 | 	struct sk_buff *skb; | 
 | 160 | 	struct ieee80211_msg_key_notification *msg; | 
 | 161 |  | 
 | 162 | 	/* if no one will get it anyway, don't even allocate it. | 
 | 163 | 	 * unlikely because this is only relevant for APs | 
 | 164 | 	 * where the device must be open... */ | 
 | 165 | 	if (unlikely(!local->apdev)) | 
 | 166 | 		return; | 
 | 167 |  | 
 | 168 | 	skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) + | 
 | 169 | 			    sizeof(struct ieee80211_msg_key_notification)); | 
 | 170 | 	if (!skb) | 
 | 171 | 		return; | 
 | 172 |  | 
 | 173 | 	skb_reserve(skb, sizeof(struct ieee80211_frame_info)); | 
 | 174 | 	msg = (struct ieee80211_msg_key_notification *) | 
 | 175 | 		skb_put(skb, sizeof(struct ieee80211_msg_key_notification)); | 
 | 176 | 	msg->tx_rx_count = key->tx_rx_count; | 
 | 177 | 	memcpy(msg->ifname, dev->name, IFNAMSIZ); | 
 | 178 | 	if (sta) | 
 | 179 | 		memcpy(msg->addr, sta->addr, ETH_ALEN); | 
 | 180 | 	else | 
 | 181 | 		memset(msg->addr, 0xff, ETH_ALEN); | 
 | 182 |  | 
 | 183 | 	key->tx_rx_count = 0; | 
 | 184 |  | 
 | 185 | 	ieee80211_rx_mgmt(local, skb, NULL, | 
 | 186 | 			  ieee80211_msg_key_threshold_notification); | 
 | 187 | } | 
 | 188 |  | 
 | 189 |  | 
| Johannes Berg | 571ecf6 | 2007-07-27 15:43:22 +0200 | [diff] [blame] | 190 | u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len) | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 191 | { | 
 | 192 | 	u16 fc; | 
 | 193 |  | 
 | 194 | 	if (len < 24) | 
 | 195 | 		return NULL; | 
 | 196 |  | 
 | 197 | 	fc = le16_to_cpu(hdr->frame_control); | 
 | 198 |  | 
 | 199 | 	switch (fc & IEEE80211_FCTL_FTYPE) { | 
 | 200 | 	case IEEE80211_FTYPE_DATA: | 
 | 201 | 		switch (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) { | 
 | 202 | 		case IEEE80211_FCTL_TODS: | 
 | 203 | 			return hdr->addr1; | 
 | 204 | 		case (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS): | 
 | 205 | 			return NULL; | 
 | 206 | 		case IEEE80211_FCTL_FROMDS: | 
 | 207 | 			return hdr->addr2; | 
 | 208 | 		case 0: | 
 | 209 | 			return hdr->addr3; | 
 | 210 | 		} | 
 | 211 | 		break; | 
 | 212 | 	case IEEE80211_FTYPE_MGMT: | 
 | 213 | 		return hdr->addr3; | 
 | 214 | 	case IEEE80211_FTYPE_CTL: | 
 | 215 | 		if ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL) | 
 | 216 | 			return hdr->addr1; | 
 | 217 | 		else | 
 | 218 | 			return NULL; | 
 | 219 | 	} | 
 | 220 |  | 
 | 221 | 	return NULL; | 
 | 222 | } | 
 | 223 |  | 
 | 224 | int ieee80211_get_hdrlen(u16 fc) | 
 | 225 | { | 
 | 226 | 	int hdrlen = 24; | 
 | 227 |  | 
 | 228 | 	switch (fc & IEEE80211_FCTL_FTYPE) { | 
 | 229 | 	case IEEE80211_FTYPE_DATA: | 
 | 230 | 		if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) | 
 | 231 | 			hdrlen = 30; /* Addr4 */ | 
 | 232 | 		/* | 
 | 233 | 		 * The QoS Control field is two bytes and its presence is | 
 | 234 | 		 * indicated by the IEEE80211_STYPE_QOS_DATA bit. Add 2 to | 
 | 235 | 		 * hdrlen if that bit is set. | 
 | 236 | 		 * This works by masking out the bit and shifting it to | 
 | 237 | 		 * bit position 1 so the result has the value 0 or 2. | 
 | 238 | 		 */ | 
 | 239 | 		hdrlen += (fc & IEEE80211_STYPE_QOS_DATA) | 
 | 240 | 				>> (ilog2(IEEE80211_STYPE_QOS_DATA)-1); | 
 | 241 | 		break; | 
 | 242 | 	case IEEE80211_FTYPE_CTL: | 
 | 243 | 		/* | 
 | 244 | 		 * ACK and CTS are 10 bytes, all others 16. To see how | 
 | 245 | 		 * to get this condition consider | 
 | 246 | 		 *   subtype mask:   0b0000000011110000 (0x00F0) | 
 | 247 | 		 *   ACK subtype:    0b0000000011010000 (0x00D0) | 
 | 248 | 		 *   CTS subtype:    0b0000000011000000 (0x00C0) | 
 | 249 | 		 *   bits that matter:         ^^^      (0x00E0) | 
 | 250 | 		 *   value of those: 0b0000000011000000 (0x00C0) | 
 | 251 | 		 */ | 
 | 252 | 		if ((fc & 0xE0) == 0xC0) | 
 | 253 | 			hdrlen = 10; | 
 | 254 | 		else | 
 | 255 | 			hdrlen = 16; | 
 | 256 | 		break; | 
 | 257 | 	} | 
 | 258 |  | 
 | 259 | 	return hdrlen; | 
 | 260 | } | 
 | 261 | EXPORT_SYMBOL(ieee80211_get_hdrlen); | 
 | 262 |  | 
 | 263 | int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb) | 
 | 264 | { | 
 | 265 | 	const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr *) skb->data; | 
 | 266 | 	int hdrlen; | 
 | 267 |  | 
 | 268 | 	if (unlikely(skb->len < 10)) | 
 | 269 | 		return 0; | 
 | 270 | 	hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_control)); | 
 | 271 | 	if (unlikely(hdrlen > skb->len)) | 
 | 272 | 		return 0; | 
 | 273 | 	return hdrlen; | 
 | 274 | } | 
 | 275 | EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); | 
 | 276 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 277 |  | 
| Johannes Berg | 571ecf6 | 2007-07-27 15:43:22 +0200 | [diff] [blame] | 278 | int ieee80211_is_eapol(const struct sk_buff *skb) | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 279 | { | 
 | 280 | 	const struct ieee80211_hdr *hdr; | 
 | 281 | 	u16 fc; | 
 | 282 | 	int hdrlen; | 
 | 283 |  | 
 | 284 | 	if (unlikely(skb->len < 10)) | 
 | 285 | 		return 0; | 
 | 286 |  | 
 | 287 | 	hdr = (const struct ieee80211_hdr *) skb->data; | 
 | 288 | 	fc = le16_to_cpu(hdr->frame_control); | 
 | 289 |  | 
 | 290 | 	if (unlikely(!WLAN_FC_DATA_PRESENT(fc))) | 
 | 291 | 		return 0; | 
 | 292 |  | 
 | 293 | 	hdrlen = ieee80211_get_hdrlen(fc); | 
 | 294 |  | 
 | 295 | 	if (unlikely(skb->len >= hdrlen + sizeof(eapol_header) && | 
 | 296 | 		     memcmp(skb->data + hdrlen, eapol_header, | 
 | 297 | 			    sizeof(eapol_header)) == 0)) | 
 | 298 | 		return 1; | 
 | 299 |  | 
 | 300 | 	return 0; | 
 | 301 | } | 
 | 302 |  | 
 | 303 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 304 | void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx) | 
 | 305 | { | 
 | 306 | 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data; | 
 | 307 |  | 
 | 308 | 	hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); | 
 | 309 | 	if (tx->u.tx.extra_frag) { | 
 | 310 | 		struct ieee80211_hdr *fhdr; | 
 | 311 | 		int i; | 
 | 312 | 		for (i = 0; i < tx->u.tx.num_extra_frag; i++) { | 
 | 313 | 			fhdr = (struct ieee80211_hdr *) | 
 | 314 | 				tx->u.tx.extra_frag[i]->data; | 
 | 315 | 			fhdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); | 
 | 316 | 		} | 
 | 317 | 	} | 
 | 318 | } | 
 | 319 |  | 
 | 320 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 321 | static int ieee80211_frame_duration(struct ieee80211_local *local, size_t len, | 
 | 322 | 				    int rate, int erp, int short_preamble) | 
 | 323 | { | 
 | 324 | 	int dur; | 
 | 325 |  | 
 | 326 | 	/* calculate duration (in microseconds, rounded up to next higher | 
 | 327 | 	 * integer if it includes a fractional microsecond) to send frame of | 
 | 328 | 	 * len bytes (does not include FCS) at the given rate. Duration will | 
 | 329 | 	 * also include SIFS. | 
 | 330 | 	 * | 
 | 331 | 	 * rate is in 100 kbps, so divident is multiplied by 10 in the | 
 | 332 | 	 * DIV_ROUND_UP() operations. | 
 | 333 | 	 */ | 
 | 334 |  | 
 | 335 | 	if (local->hw.conf.phymode == MODE_IEEE80211A || erp || | 
 | 336 | 	    local->hw.conf.phymode == MODE_ATHEROS_TURBO) { | 
 | 337 | 		/* | 
 | 338 | 		 * OFDM: | 
 | 339 | 		 * | 
 | 340 | 		 * N_DBPS = DATARATE x 4 | 
 | 341 | 		 * N_SYM = Ceiling((16+8xLENGTH+6) / N_DBPS) | 
 | 342 | 		 *	(16 = SIGNAL time, 6 = tail bits) | 
 | 343 | 		 * TXTIME = T_PREAMBLE + T_SIGNAL + T_SYM x N_SYM + Signal Ext | 
 | 344 | 		 * | 
 | 345 | 		 * T_SYM = 4 usec | 
 | 346 | 		 * 802.11a - 17.5.2: aSIFSTime = 16 usec | 
 | 347 | 		 * 802.11g - 19.8.4: aSIFSTime = 10 usec + | 
 | 348 | 		 *	signal ext = 6 usec | 
 | 349 | 		 */ | 
 | 350 | 		/* FIX: Atheros Turbo may have different (shorter) duration? */ | 
 | 351 | 		dur = 16; /* SIFS + signal ext */ | 
 | 352 | 		dur += 16; /* 17.3.2.3: T_PREAMBLE = 16 usec */ | 
 | 353 | 		dur += 4; /* 17.3.2.3: T_SIGNAL = 4 usec */ | 
 | 354 | 		dur += 4 * DIV_ROUND_UP((16 + 8 * (len + 4) + 6) * 10, | 
 | 355 | 					4 * rate); /* T_SYM x N_SYM */ | 
 | 356 | 	} else { | 
 | 357 | 		/* | 
 | 358 | 		 * 802.11b or 802.11g with 802.11b compatibility: | 
 | 359 | 		 * 18.3.4: TXTIME = PreambleLength + PLCPHeaderTime + | 
 | 360 | 		 * Ceiling(((LENGTH+PBCC)x8)/DATARATE). PBCC=0. | 
 | 361 | 		 * | 
 | 362 | 		 * 802.11 (DS): 15.3.3, 802.11b: 18.3.4 | 
 | 363 | 		 * aSIFSTime = 10 usec | 
 | 364 | 		 * aPreambleLength = 144 usec or 72 usec with short preamble | 
 | 365 | 		 * aPLCPHeaderLength = 48 usec or 24 usec with short preamble | 
 | 366 | 		 */ | 
 | 367 | 		dur = 10; /* aSIFSTime = 10 usec */ | 
 | 368 | 		dur += short_preamble ? (72 + 24) : (144 + 48); | 
 | 369 |  | 
 | 370 | 		dur += DIV_ROUND_UP(8 * (len + 4) * 10, rate); | 
 | 371 | 	} | 
 | 372 |  | 
 | 373 | 	return dur; | 
 | 374 | } | 
 | 375 |  | 
 | 376 |  | 
 | 377 | /* Exported duration function for driver use */ | 
 | 378 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, | 
 | 379 | 					size_t frame_len, int rate) | 
 | 380 | { | 
 | 381 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 382 | 	u16 dur; | 
 | 383 | 	int erp; | 
 | 384 |  | 
 | 385 | 	erp = ieee80211_is_erp_rate(hw->conf.phymode, rate); | 
 | 386 | 	dur = ieee80211_frame_duration(local, frame_len, rate, | 
 | 387 | 				       erp, local->short_preamble); | 
 | 388 |  | 
 | 389 | 	return cpu_to_le16(dur); | 
 | 390 | } | 
 | 391 | EXPORT_SYMBOL(ieee80211_generic_frame_duration); | 
 | 392 |  | 
 | 393 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 394 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, | 
 | 395 | 			      size_t frame_len, | 
 | 396 | 			      const struct ieee80211_tx_control *frame_txctl) | 
 | 397 | { | 
 | 398 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 399 | 	struct ieee80211_rate *rate; | 
 | 400 | 	int short_preamble = local->short_preamble; | 
 | 401 | 	int erp; | 
 | 402 | 	u16 dur; | 
 | 403 |  | 
 | 404 | 	rate = frame_txctl->rts_rate; | 
 | 405 | 	erp = !!(rate->flags & IEEE80211_RATE_ERP); | 
 | 406 |  | 
 | 407 | 	/* CTS duration */ | 
 | 408 | 	dur = ieee80211_frame_duration(local, 10, rate->rate, | 
 | 409 | 				       erp, short_preamble); | 
 | 410 | 	/* Data frame duration */ | 
 | 411 | 	dur += ieee80211_frame_duration(local, frame_len, rate->rate, | 
 | 412 | 					erp, short_preamble); | 
 | 413 | 	/* ACK duration */ | 
 | 414 | 	dur += ieee80211_frame_duration(local, 10, rate->rate, | 
 | 415 | 					erp, short_preamble); | 
 | 416 |  | 
 | 417 | 	return cpu_to_le16(dur); | 
 | 418 | } | 
 | 419 | EXPORT_SYMBOL(ieee80211_rts_duration); | 
 | 420 |  | 
 | 421 |  | 
 | 422 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | 
 | 423 | 				    size_t frame_len, | 
 | 424 | 				    const struct ieee80211_tx_control *frame_txctl) | 
 | 425 | { | 
 | 426 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 427 | 	struct ieee80211_rate *rate; | 
 | 428 | 	int short_preamble = local->short_preamble; | 
 | 429 | 	int erp; | 
 | 430 | 	u16 dur; | 
 | 431 |  | 
 | 432 | 	rate = frame_txctl->rts_rate; | 
 | 433 | 	erp = !!(rate->flags & IEEE80211_RATE_ERP); | 
 | 434 |  | 
 | 435 | 	/* Data frame duration */ | 
 | 436 | 	dur = ieee80211_frame_duration(local, frame_len, rate->rate, | 
 | 437 | 				       erp, short_preamble); | 
 | 438 | 	if (!(frame_txctl->flags & IEEE80211_TXCTL_NO_ACK)) { | 
 | 439 | 		/* ACK duration */ | 
 | 440 | 		dur += ieee80211_frame_duration(local, 10, rate->rate, | 
 | 441 | 						erp, short_preamble); | 
 | 442 | 	} | 
 | 443 |  | 
 | 444 | 	return cpu_to_le16(dur); | 
 | 445 | } | 
 | 446 | EXPORT_SYMBOL(ieee80211_ctstoself_duration); | 
 | 447 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 448 | static int __ieee80211_if_config(struct net_device *dev, | 
 | 449 | 				 struct sk_buff *beacon, | 
 | 450 | 				 struct ieee80211_tx_control *control) | 
 | 451 | { | 
 | 452 | 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 453 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 454 | 	struct ieee80211_if_conf conf; | 
 | 455 | 	static u8 scan_bssid[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 
 | 456 |  | 
 | 457 | 	if (!local->ops->config_interface || !netif_running(dev)) | 
 | 458 | 		return 0; | 
 | 459 |  | 
 | 460 | 	memset(&conf, 0, sizeof(conf)); | 
 | 461 | 	conf.type = sdata->type; | 
 | 462 | 	if (sdata->type == IEEE80211_IF_TYPE_STA || | 
 | 463 | 	    sdata->type == IEEE80211_IF_TYPE_IBSS) { | 
 | 464 | 		if (local->sta_scanning && | 
 | 465 | 		    local->scan_dev == dev) | 
 | 466 | 			conf.bssid = scan_bssid; | 
 | 467 | 		else | 
 | 468 | 			conf.bssid = sdata->u.sta.bssid; | 
 | 469 | 		conf.ssid = sdata->u.sta.ssid; | 
 | 470 | 		conf.ssid_len = sdata->u.sta.ssid_len; | 
 | 471 | 		conf.generic_elem = sdata->u.sta.extra_ie; | 
 | 472 | 		conf.generic_elem_len = sdata->u.sta.extra_ie_len; | 
 | 473 | 	} else if (sdata->type == IEEE80211_IF_TYPE_AP) { | 
 | 474 | 		conf.ssid = sdata->u.ap.ssid; | 
 | 475 | 		conf.ssid_len = sdata->u.ap.ssid_len; | 
 | 476 | 		conf.generic_elem = sdata->u.ap.generic_elem; | 
 | 477 | 		conf.generic_elem_len = sdata->u.ap.generic_elem_len; | 
 | 478 | 		conf.beacon = beacon; | 
 | 479 | 		conf.beacon_control = control; | 
 | 480 | 	} | 
 | 481 | 	return local->ops->config_interface(local_to_hw(local), | 
 | 482 | 					   dev->ifindex, &conf); | 
 | 483 | } | 
 | 484 |  | 
 | 485 | int ieee80211_if_config(struct net_device *dev) | 
 | 486 | { | 
 | 487 | 	return __ieee80211_if_config(dev, NULL, NULL); | 
 | 488 | } | 
 | 489 |  | 
 | 490 | int ieee80211_if_config_beacon(struct net_device *dev) | 
 | 491 | { | 
 | 492 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 493 | 	struct ieee80211_tx_control control; | 
 | 494 | 	struct sk_buff *skb; | 
 | 495 |  | 
 | 496 | 	if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE)) | 
 | 497 | 		return 0; | 
 | 498 | 	skb = ieee80211_beacon_get(local_to_hw(local), dev->ifindex, &control); | 
 | 499 | 	if (!skb) | 
 | 500 | 		return -ENOMEM; | 
 | 501 | 	return __ieee80211_if_config(dev, skb, &control); | 
 | 502 | } | 
 | 503 |  | 
 | 504 | int ieee80211_hw_config(struct ieee80211_local *local) | 
 | 505 | { | 
 | 506 | 	struct ieee80211_hw_mode *mode; | 
 | 507 | 	struct ieee80211_channel *chan; | 
 | 508 | 	int ret = 0; | 
 | 509 |  | 
 | 510 | 	if (local->sta_scanning) { | 
 | 511 | 		chan = local->scan_channel; | 
 | 512 | 		mode = local->scan_hw_mode; | 
 | 513 | 	} else { | 
 | 514 | 		chan = local->oper_channel; | 
 | 515 | 		mode = local->oper_hw_mode; | 
 | 516 | 	} | 
 | 517 |  | 
 | 518 | 	local->hw.conf.channel = chan->chan; | 
 | 519 | 	local->hw.conf.channel_val = chan->val; | 
 | 520 | 	local->hw.conf.power_level = chan->power_level; | 
 | 521 | 	local->hw.conf.freq = chan->freq; | 
 | 522 | 	local->hw.conf.phymode = mode->mode; | 
 | 523 | 	local->hw.conf.antenna_max = chan->antenna_max; | 
 | 524 | 	local->hw.conf.chan = chan; | 
 | 525 | 	local->hw.conf.mode = mode; | 
 | 526 |  | 
 | 527 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 
 | 528 | 	printk(KERN_DEBUG "HW CONFIG: channel=%d freq=%d " | 
 | 529 | 	       "phymode=%d\n", local->hw.conf.channel, local->hw.conf.freq, | 
 | 530 | 	       local->hw.conf.phymode); | 
 | 531 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 
 | 532 |  | 
 | 533 | 	if (local->ops->config) | 
 | 534 | 		ret = local->ops->config(local_to_hw(local), &local->hw.conf); | 
 | 535 |  | 
 | 536 | 	return ret; | 
 | 537 | } | 
 | 538 |  | 
 | 539 |  | 
 | 540 | static int ieee80211_change_mtu(struct net_device *dev, int new_mtu) | 
 | 541 | { | 
 | 542 | 	/* FIX: what would be proper limits for MTU? | 
 | 543 | 	 * This interface uses 802.3 frames. */ | 
 | 544 | 	if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN - 24 - 6) { | 
 | 545 | 		printk(KERN_WARNING "%s: invalid MTU %d\n", | 
 | 546 | 		       dev->name, new_mtu); | 
 | 547 | 		return -EINVAL; | 
 | 548 | 	} | 
 | 549 |  | 
 | 550 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 
 | 551 | 	printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu); | 
 | 552 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 
 | 553 | 	dev->mtu = new_mtu; | 
 | 554 | 	return 0; | 
 | 555 | } | 
 | 556 |  | 
 | 557 |  | 
 | 558 | static int ieee80211_change_mtu_apdev(struct net_device *dev, int new_mtu) | 
 | 559 | { | 
 | 560 | 	/* FIX: what would be proper limits for MTU? | 
 | 561 | 	 * This interface uses 802.11 frames. */ | 
 | 562 | 	if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN) { | 
 | 563 | 		printk(KERN_WARNING "%s: invalid MTU %d\n", | 
 | 564 | 		       dev->name, new_mtu); | 
 | 565 | 		return -EINVAL; | 
 | 566 | 	} | 
 | 567 |  | 
 | 568 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG | 
 | 569 | 	printk(KERN_DEBUG "%s: setting MTU %d\n", dev->name, new_mtu); | 
 | 570 | #endif /* CONFIG_MAC80211_VERBOSE_DEBUG */ | 
 | 571 | 	dev->mtu = new_mtu; | 
 | 572 | 	return 0; | 
 | 573 | } | 
 | 574 |  | 
 | 575 | enum netif_tx_lock_class { | 
 | 576 | 	TX_LOCK_NORMAL, | 
 | 577 | 	TX_LOCK_MASTER, | 
 | 578 | }; | 
 | 579 |  | 
 | 580 | static inline void netif_tx_lock_nested(struct net_device *dev, int subclass) | 
 | 581 | { | 
 | 582 | 	spin_lock_nested(&dev->_xmit_lock, subclass); | 
 | 583 | 	dev->xmit_lock_owner = smp_processor_id(); | 
 | 584 | } | 
 | 585 |  | 
 | 586 | static void ieee80211_set_multicast_list(struct net_device *dev) | 
 | 587 | { | 
 | 588 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 589 | 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 590 | 	unsigned short flags; | 
 | 591 |  | 
 | 592 | 	netif_tx_lock_nested(local->mdev, TX_LOCK_MASTER); | 
 | 593 | 	if (((dev->flags & IFF_ALLMULTI) != 0) ^ (sdata->allmulti != 0)) { | 
 | 594 | 		if (sdata->allmulti) { | 
 | 595 | 			sdata->allmulti = 0; | 
 | 596 | 			local->iff_allmultis--; | 
 | 597 | 		} else { | 
 | 598 | 			sdata->allmulti = 1; | 
 | 599 | 			local->iff_allmultis++; | 
 | 600 | 		} | 
 | 601 | 	} | 
 | 602 | 	if (((dev->flags & IFF_PROMISC) != 0) ^ (sdata->promisc != 0)) { | 
 | 603 | 		if (sdata->promisc) { | 
 | 604 | 			sdata->promisc = 0; | 
 | 605 | 			local->iff_promiscs--; | 
 | 606 | 		} else { | 
 | 607 | 			sdata->promisc = 1; | 
 | 608 | 			local->iff_promiscs++; | 
 | 609 | 		} | 
 | 610 | 	} | 
 | 611 | 	if (dev->mc_count != sdata->mc_count) { | 
 | 612 | 		local->mc_count = local->mc_count - sdata->mc_count + | 
 | 613 | 				  dev->mc_count; | 
 | 614 | 		sdata->mc_count = dev->mc_count; | 
 | 615 | 	} | 
 | 616 | 	if (local->ops->set_multicast_list) { | 
 | 617 | 		flags = local->mdev->flags; | 
 | 618 | 		if (local->iff_allmultis) | 
 | 619 | 			flags |= IFF_ALLMULTI; | 
 | 620 | 		if (local->iff_promiscs) | 
 | 621 | 			flags |= IFF_PROMISC; | 
 | 622 | 		read_lock(&local->sub_if_lock); | 
 | 623 | 		local->ops->set_multicast_list(local_to_hw(local), flags, | 
 | 624 | 					      local->mc_count); | 
 | 625 | 		read_unlock(&local->sub_if_lock); | 
 | 626 | 	} | 
 | 627 | 	netif_tx_unlock(local->mdev); | 
 | 628 | } | 
 | 629 |  | 
 | 630 | struct dev_mc_list *ieee80211_get_mc_list_item(struct ieee80211_hw *hw, | 
 | 631 | 					       struct dev_mc_list *prev, | 
 | 632 | 					       void **ptr) | 
 | 633 | { | 
 | 634 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 635 | 	struct ieee80211_sub_if_data *sdata = *ptr; | 
 | 636 | 	struct dev_mc_list *mc; | 
 | 637 |  | 
 | 638 | 	if (!prev) { | 
 | 639 | 		WARN_ON(sdata); | 
 | 640 | 		sdata = NULL; | 
 | 641 | 	} | 
 | 642 | 	if (!prev || !prev->next) { | 
 | 643 | 		if (sdata) | 
 | 644 | 			sdata = list_entry(sdata->list.next, | 
 | 645 | 					   struct ieee80211_sub_if_data, list); | 
 | 646 | 		else | 
 | 647 | 			sdata = list_entry(local->sub_if_list.next, | 
 | 648 | 					   struct ieee80211_sub_if_data, list); | 
 | 649 | 		if (&sdata->list != &local->sub_if_list) | 
 | 650 | 			mc = sdata->dev->mc_list; | 
 | 651 | 		else | 
 | 652 | 			mc = NULL; | 
 | 653 | 	} else | 
 | 654 | 		mc = prev->next; | 
 | 655 |  | 
 | 656 | 	*ptr = sdata; | 
 | 657 | 	return mc; | 
 | 658 | } | 
 | 659 | EXPORT_SYMBOL(ieee80211_get_mc_list_item); | 
 | 660 |  | 
 | 661 | static struct net_device_stats *ieee80211_get_stats(struct net_device *dev) | 
 | 662 | { | 
 | 663 | 	struct ieee80211_sub_if_data *sdata; | 
 | 664 | 	sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 665 | 	return &(sdata->stats); | 
 | 666 | } | 
 | 667 |  | 
 | 668 | static void ieee80211_if_shutdown(struct net_device *dev) | 
 | 669 | { | 
 | 670 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 671 | 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 672 |  | 
 | 673 | 	ASSERT_RTNL(); | 
 | 674 | 	switch (sdata->type) { | 
 | 675 | 	case IEEE80211_IF_TYPE_STA: | 
 | 676 | 	case IEEE80211_IF_TYPE_IBSS: | 
 | 677 | 		sdata->u.sta.state = IEEE80211_DISABLED; | 
 | 678 | 		del_timer_sync(&sdata->u.sta.timer); | 
 | 679 | 		skb_queue_purge(&sdata->u.sta.skb_queue); | 
 | 680 | 		if (!local->ops->hw_scan && | 
 | 681 | 		    local->scan_dev == sdata->dev) { | 
 | 682 | 			local->sta_scanning = 0; | 
 | 683 | 			cancel_delayed_work(&local->scan_work); | 
 | 684 | 		} | 
 | 685 | 		flush_workqueue(local->hw.workqueue); | 
 | 686 | 		break; | 
 | 687 | 	} | 
 | 688 | } | 
 | 689 |  | 
 | 690 | static inline int identical_mac_addr_allowed(int type1, int type2) | 
 | 691 | { | 
 | 692 | 	return (type1 == IEEE80211_IF_TYPE_MNTR || | 
 | 693 | 		type2 == IEEE80211_IF_TYPE_MNTR || | 
 | 694 | 		(type1 == IEEE80211_IF_TYPE_AP && | 
 | 695 | 		 type2 == IEEE80211_IF_TYPE_WDS) || | 
 | 696 | 		(type1 == IEEE80211_IF_TYPE_WDS && | 
 | 697 | 		 (type2 == IEEE80211_IF_TYPE_WDS || | 
 | 698 | 		  type2 == IEEE80211_IF_TYPE_AP)) || | 
 | 699 | 		(type1 == IEEE80211_IF_TYPE_AP && | 
 | 700 | 		 type2 == IEEE80211_IF_TYPE_VLAN) || | 
 | 701 | 		(type1 == IEEE80211_IF_TYPE_VLAN && | 
 | 702 | 		 (type2 == IEEE80211_IF_TYPE_AP || | 
 | 703 | 		  type2 == IEEE80211_IF_TYPE_VLAN))); | 
 | 704 | } | 
 | 705 |  | 
 | 706 | static int ieee80211_master_open(struct net_device *dev) | 
 | 707 | { | 
 | 708 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 709 | 	struct ieee80211_sub_if_data *sdata; | 
 | 710 | 	int res = -EOPNOTSUPP; | 
 | 711 |  | 
 | 712 | 	read_lock(&local->sub_if_lock); | 
 | 713 | 	list_for_each_entry(sdata, &local->sub_if_list, list) { | 
 | 714 | 		if (sdata->dev != dev && netif_running(sdata->dev)) { | 
 | 715 | 			res = 0; | 
 | 716 | 			break; | 
 | 717 | 		} | 
 | 718 | 	} | 
 | 719 | 	read_unlock(&local->sub_if_lock); | 
 | 720 | 	return res; | 
 | 721 | } | 
 | 722 |  | 
 | 723 | static int ieee80211_master_stop(struct net_device *dev) | 
 | 724 | { | 
 | 725 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 726 | 	struct ieee80211_sub_if_data *sdata; | 
 | 727 |  | 
 | 728 | 	read_lock(&local->sub_if_lock); | 
 | 729 | 	list_for_each_entry(sdata, &local->sub_if_list, list) | 
 | 730 | 		if (sdata->dev != dev && netif_running(sdata->dev)) | 
 | 731 | 			dev_close(sdata->dev); | 
 | 732 | 	read_unlock(&local->sub_if_lock); | 
 | 733 |  | 
 | 734 | 	return 0; | 
 | 735 | } | 
 | 736 |  | 
 | 737 | static int ieee80211_mgmt_open(struct net_device *dev) | 
 | 738 | { | 
 | 739 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 740 |  | 
 | 741 | 	if (!netif_running(local->mdev)) | 
 | 742 | 		return -EOPNOTSUPP; | 
 | 743 | 	return 0; | 
 | 744 | } | 
 | 745 |  | 
 | 746 | static int ieee80211_mgmt_stop(struct net_device *dev) | 
 | 747 | { | 
 | 748 | 	return 0; | 
 | 749 | } | 
 | 750 |  | 
 | 751 | /* Check if running monitor interfaces should go to a "soft monitor" mode | 
 | 752 |  * and switch them if necessary. */ | 
 | 753 | static inline void ieee80211_start_soft_monitor(struct ieee80211_local *local) | 
 | 754 | { | 
 | 755 | 	struct ieee80211_if_init_conf conf; | 
 | 756 |  | 
 | 757 | 	if (local->open_count && local->open_count == local->monitors && | 
 | 758 | 	    !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER) && | 
 | 759 | 	    local->ops->remove_interface) { | 
 | 760 | 		conf.if_id = -1; | 
 | 761 | 		conf.type = IEEE80211_IF_TYPE_MNTR; | 
 | 762 | 		conf.mac_addr = NULL; | 
 | 763 | 		local->ops->remove_interface(local_to_hw(local), &conf); | 
 | 764 | 	} | 
 | 765 | } | 
 | 766 |  | 
 | 767 | /* Check if running monitor interfaces should go to a "hard monitor" mode | 
 | 768 |  * and switch them if necessary. */ | 
 | 769 | static void ieee80211_start_hard_monitor(struct ieee80211_local *local) | 
 | 770 | { | 
 | 771 | 	struct ieee80211_if_init_conf conf; | 
 | 772 |  | 
 | 773 | 	if (local->open_count && local->open_count == local->monitors && | 
| Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 774 | 	    !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) { | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 775 | 		conf.if_id = -1; | 
 | 776 | 		conf.type = IEEE80211_IF_TYPE_MNTR; | 
 | 777 | 		conf.mac_addr = NULL; | 
 | 778 | 		local->ops->add_interface(local_to_hw(local), &conf); | 
 | 779 | 	} | 
 | 780 | } | 
 | 781 |  | 
 | 782 | static int ieee80211_open(struct net_device *dev) | 
 | 783 | { | 
 | 784 | 	struct ieee80211_sub_if_data *sdata, *nsdata; | 
 | 785 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 786 | 	struct ieee80211_if_init_conf conf; | 
 | 787 | 	int res; | 
 | 788 |  | 
 | 789 | 	sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 790 | 	read_lock(&local->sub_if_lock); | 
 | 791 | 	list_for_each_entry(nsdata, &local->sub_if_list, list) { | 
 | 792 | 		struct net_device *ndev = nsdata->dev; | 
 | 793 |  | 
 | 794 | 		if (ndev != dev && ndev != local->mdev && netif_running(ndev) && | 
 | 795 | 		    compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 && | 
 | 796 | 		    !identical_mac_addr_allowed(sdata->type, nsdata->type)) { | 
 | 797 | 			read_unlock(&local->sub_if_lock); | 
 | 798 | 			return -ENOTUNIQ; | 
 | 799 | 		} | 
 | 800 | 	} | 
 | 801 | 	read_unlock(&local->sub_if_lock); | 
 | 802 |  | 
 | 803 | 	if (sdata->type == IEEE80211_IF_TYPE_WDS && | 
 | 804 | 	    is_zero_ether_addr(sdata->u.wds.remote_addr)) | 
 | 805 | 		return -ENOLINK; | 
 | 806 |  | 
 | 807 | 	if (sdata->type == IEEE80211_IF_TYPE_MNTR && local->open_count && | 
 | 808 | 	    !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) { | 
 | 809 | 		/* run the interface in a "soft monitor" mode */ | 
 | 810 | 		local->monitors++; | 
 | 811 | 		local->open_count++; | 
 | 812 | 		local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; | 
 | 813 | 		return 0; | 
 | 814 | 	} | 
 | 815 | 	ieee80211_start_soft_monitor(local); | 
 | 816 |  | 
| Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 817 | 	conf.if_id = dev->ifindex; | 
 | 818 | 	conf.type = sdata->type; | 
 | 819 | 	conf.mac_addr = dev->dev_addr; | 
 | 820 | 	res = local->ops->add_interface(local_to_hw(local), &conf); | 
 | 821 | 	if (res) { | 
 | 822 | 		if (sdata->type == IEEE80211_IF_TYPE_MNTR) | 
 | 823 | 			ieee80211_start_hard_monitor(local); | 
 | 824 | 		return res; | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 825 | 	} | 
 | 826 |  | 
 | 827 | 	if (local->open_count == 0) { | 
 | 828 | 		res = 0; | 
 | 829 | 		tasklet_enable(&local->tx_pending_tasklet); | 
 | 830 | 		tasklet_enable(&local->tasklet); | 
 | 831 | 		if (local->ops->open) | 
 | 832 | 			res = local->ops->open(local_to_hw(local)); | 
 | 833 | 		if (res == 0) { | 
 | 834 | 			res = dev_open(local->mdev); | 
 | 835 | 			if (res) { | 
 | 836 | 				if (local->ops->stop) | 
 | 837 | 					local->ops->stop(local_to_hw(local)); | 
 | 838 | 			} else { | 
 | 839 | 				res = ieee80211_hw_config(local); | 
 | 840 | 				if (res && local->ops->stop) | 
 | 841 | 					local->ops->stop(local_to_hw(local)); | 
 | 842 | 				else if (!res && local->apdev) | 
 | 843 | 					dev_open(local->apdev); | 
 | 844 | 			} | 
 | 845 | 		} | 
 | 846 | 		if (res) { | 
 | 847 | 			if (local->ops->remove_interface) | 
 | 848 | 				local->ops->remove_interface(local_to_hw(local), | 
 | 849 | 							    &conf); | 
 | 850 | 			return res; | 
 | 851 | 		} | 
 | 852 | 	} | 
 | 853 | 	local->open_count++; | 
 | 854 |  | 
 | 855 | 	if (sdata->type == IEEE80211_IF_TYPE_MNTR) { | 
 | 856 | 		local->monitors++; | 
 | 857 | 		local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP; | 
 | 858 | 	} else | 
 | 859 | 		ieee80211_if_config(dev); | 
 | 860 |  | 
 | 861 | 	if (sdata->type == IEEE80211_IF_TYPE_STA && | 
 | 862 | 	    !local->user_space_mlme) | 
 | 863 | 		netif_carrier_off(dev); | 
| Michael Wu | 52fb24c | 2007-05-20 09:44:00 -0700 | [diff] [blame] | 864 | 	else | 
 | 865 | 		netif_carrier_on(dev); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 866 |  | 
 | 867 | 	netif_start_queue(dev); | 
 | 868 | 	return 0; | 
 | 869 | } | 
 | 870 |  | 
 | 871 |  | 
 | 872 | static int ieee80211_stop(struct net_device *dev) | 
 | 873 | { | 
 | 874 | 	struct ieee80211_sub_if_data *sdata; | 
 | 875 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 876 |  | 
 | 877 | 	sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 878 |  | 
 | 879 | 	if (sdata->type == IEEE80211_IF_TYPE_MNTR && | 
 | 880 | 	    local->open_count > 1 && | 
 | 881 | 	    !(local->hw.flags & IEEE80211_HW_MONITOR_DURING_OPER)) { | 
 | 882 | 		/* remove "soft monitor" interface */ | 
 | 883 | 		local->open_count--; | 
 | 884 | 		local->monitors--; | 
 | 885 | 		if (!local->monitors) | 
 | 886 | 			local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; | 
 | 887 | 		return 0; | 
 | 888 | 	} | 
 | 889 |  | 
 | 890 | 	netif_stop_queue(dev); | 
 | 891 | 	ieee80211_if_shutdown(dev); | 
 | 892 |  | 
 | 893 | 	if (sdata->type == IEEE80211_IF_TYPE_MNTR) { | 
 | 894 | 		local->monitors--; | 
 | 895 | 		if (!local->monitors) | 
 | 896 | 			local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP; | 
 | 897 | 	} | 
 | 898 |  | 
 | 899 | 	local->open_count--; | 
 | 900 | 	if (local->open_count == 0) { | 
 | 901 | 		if (netif_running(local->mdev)) | 
 | 902 | 			dev_close(local->mdev); | 
 | 903 | 		if (local->apdev) | 
 | 904 | 			dev_close(local->apdev); | 
 | 905 | 		if (local->ops->stop) | 
 | 906 | 			local->ops->stop(local_to_hw(local)); | 
 | 907 | 		tasklet_disable(&local->tx_pending_tasklet); | 
 | 908 | 		tasklet_disable(&local->tasklet); | 
 | 909 | 	} | 
 | 910 | 	if (local->ops->remove_interface) { | 
 | 911 | 		struct ieee80211_if_init_conf conf; | 
 | 912 |  | 
 | 913 | 		conf.if_id = dev->ifindex; | 
 | 914 | 		conf.type = sdata->type; | 
 | 915 | 		conf.mac_addr = dev->dev_addr; | 
 | 916 | 		local->ops->remove_interface(local_to_hw(local), &conf); | 
 | 917 | 	} | 
 | 918 |  | 
 | 919 | 	ieee80211_start_hard_monitor(local); | 
 | 920 |  | 
 | 921 | 	return 0; | 
 | 922 | } | 
 | 923 |  | 
 | 924 |  | 
 | 925 | static int header_parse_80211(struct sk_buff *skb, unsigned char *haddr) | 
 | 926 | { | 
 | 927 | 	memcpy(haddr, skb_mac_header(skb) + 10, ETH_ALEN); /* addr2 */ | 
 | 928 | 	return ETH_ALEN; | 
 | 929 | } | 
 | 930 |  | 
| Johannes Berg | 571ecf6 | 2007-07-27 15:43:22 +0200 | [diff] [blame] | 931 | struct ieee80211_rate * | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 932 | ieee80211_get_rate(struct ieee80211_local *local, int phymode, int hw_rate) | 
 | 933 | { | 
 | 934 | 	struct ieee80211_hw_mode *mode; | 
 | 935 | 	int r; | 
 | 936 |  | 
 | 937 | 	list_for_each_entry(mode, &local->modes_list, list) { | 
 | 938 | 		if (mode->mode != phymode) | 
 | 939 | 			continue; | 
 | 940 | 		for (r = 0; r < mode->num_rates; r++) { | 
 | 941 | 			struct ieee80211_rate *rate = &mode->rates[r]; | 
 | 942 | 			if (rate->val == hw_rate || | 
 | 943 | 			    (rate->flags & IEEE80211_RATE_PREAMBLE2 && | 
 | 944 | 			     rate->val2 == hw_rate)) | 
 | 945 | 				return rate; | 
 | 946 | 		} | 
 | 947 | 	} | 
 | 948 |  | 
 | 949 | 	return NULL; | 
 | 950 | } | 
 | 951 |  | 
 | 952 | static void | 
 | 953 | ieee80211_fill_frame_info(struct ieee80211_local *local, | 
 | 954 | 			  struct ieee80211_frame_info *fi, | 
 | 955 | 			  struct ieee80211_rx_status *status) | 
 | 956 | { | 
 | 957 | 	if (status) { | 
 | 958 | 		struct timespec ts; | 
 | 959 | 		struct ieee80211_rate *rate; | 
 | 960 |  | 
 | 961 | 		jiffies_to_timespec(jiffies, &ts); | 
 | 962 | 		fi->hosttime = cpu_to_be64((u64) ts.tv_sec * 1000000 + | 
 | 963 | 					   ts.tv_nsec / 1000); | 
 | 964 | 		fi->mactime = cpu_to_be64(status->mactime); | 
 | 965 | 		switch (status->phymode) { | 
 | 966 | 		case MODE_IEEE80211A: | 
 | 967 | 			fi->phytype = htonl(ieee80211_phytype_ofdm_dot11_a); | 
 | 968 | 			break; | 
 | 969 | 		case MODE_IEEE80211B: | 
 | 970 | 			fi->phytype = htonl(ieee80211_phytype_dsss_dot11_b); | 
 | 971 | 			break; | 
 | 972 | 		case MODE_IEEE80211G: | 
 | 973 | 			fi->phytype = htonl(ieee80211_phytype_pbcc_dot11_g); | 
 | 974 | 			break; | 
 | 975 | 		case MODE_ATHEROS_TURBO: | 
 | 976 | 			fi->phytype = | 
 | 977 | 				htonl(ieee80211_phytype_dsss_dot11_turbo); | 
 | 978 | 			break; | 
 | 979 | 		default: | 
 | 980 | 			fi->phytype = htonl(0xAAAAAAAA); | 
 | 981 | 			break; | 
 | 982 | 		} | 
 | 983 | 		fi->channel = htonl(status->channel); | 
 | 984 | 		rate = ieee80211_get_rate(local, status->phymode, | 
 | 985 | 					  status->rate); | 
 | 986 | 		if (rate) { | 
 | 987 | 			fi->datarate = htonl(rate->rate); | 
 | 988 | 			if (rate->flags & IEEE80211_RATE_PREAMBLE2) { | 
 | 989 | 				if (status->rate == rate->val) | 
 | 990 | 					fi->preamble = htonl(2); /* long */ | 
 | 991 | 				else if (status->rate == rate->val2) | 
 | 992 | 					fi->preamble = htonl(1); /* short */ | 
 | 993 | 			} else | 
 | 994 | 				fi->preamble = htonl(0); | 
 | 995 | 		} else { | 
 | 996 | 			fi->datarate = htonl(0); | 
 | 997 | 			fi->preamble = htonl(0); | 
 | 998 | 		} | 
 | 999 |  | 
 | 1000 | 		fi->antenna = htonl(status->antenna); | 
 | 1001 | 		fi->priority = htonl(0xffffffff); /* no clue */ | 
 | 1002 | 		fi->ssi_type = htonl(ieee80211_ssi_raw); | 
 | 1003 | 		fi->ssi_signal = htonl(status->ssi); | 
 | 1004 | 		fi->ssi_noise = 0x00000000; | 
 | 1005 | 		fi->encoding = 0; | 
 | 1006 | 	} else { | 
 | 1007 | 		/* clear everything because we really don't know. | 
 | 1008 | 		 * the msg_type field isn't present on monitor frames | 
 | 1009 | 		 * so we don't know whether it will be present or not, | 
 | 1010 | 		 * but it's ok to not clear it since it'll be assigned | 
 | 1011 | 		 * anyway */ | 
 | 1012 | 		memset(fi, 0, sizeof(*fi) - sizeof(fi->msg_type)); | 
 | 1013 |  | 
 | 1014 | 		fi->ssi_type = htonl(ieee80211_ssi_none); | 
 | 1015 | 	} | 
 | 1016 | 	fi->version = htonl(IEEE80211_FI_VERSION); | 
 | 1017 | 	fi->length = cpu_to_be32(sizeof(*fi) - sizeof(fi->msg_type)); | 
 | 1018 | } | 
 | 1019 |  | 
 | 1020 | /* this routine is actually not just for this, but also | 
 | 1021 |  * for pushing fake 'management' frames into userspace. | 
 | 1022 |  * it shall be replaced by a netlink-based system. */ | 
 | 1023 | void | 
 | 1024 | ieee80211_rx_mgmt(struct ieee80211_local *local, struct sk_buff *skb, | 
 | 1025 | 		  struct ieee80211_rx_status *status, u32 msg_type) | 
 | 1026 | { | 
 | 1027 | 	struct ieee80211_frame_info *fi; | 
 | 1028 | 	const size_t hlen = sizeof(struct ieee80211_frame_info); | 
 | 1029 | 	struct ieee80211_sub_if_data *sdata; | 
 | 1030 |  | 
 | 1031 | 	skb->dev = local->apdev; | 
 | 1032 |  | 
 | 1033 | 	sdata = IEEE80211_DEV_TO_SUB_IF(local->apdev); | 
 | 1034 |  | 
 | 1035 | 	if (skb_headroom(skb) < hlen) { | 
 | 1036 | 		I802_DEBUG_INC(local->rx_expand_skb_head); | 
 | 1037 | 		if (pskb_expand_head(skb, hlen, 0, GFP_ATOMIC)) { | 
 | 1038 | 			dev_kfree_skb(skb); | 
 | 1039 | 			return; | 
 | 1040 | 		} | 
 | 1041 | 	} | 
 | 1042 |  | 
 | 1043 | 	fi = (struct ieee80211_frame_info *) skb_push(skb, hlen); | 
 | 1044 |  | 
 | 1045 | 	ieee80211_fill_frame_info(local, fi, status); | 
 | 1046 | 	fi->msg_type = htonl(msg_type); | 
 | 1047 |  | 
 | 1048 | 	sdata->stats.rx_packets++; | 
 | 1049 | 	sdata->stats.rx_bytes += skb->len; | 
 | 1050 |  | 
 | 1051 | 	skb_set_mac_header(skb, 0); | 
 | 1052 | 	skb->ip_summed = CHECKSUM_UNNECESSARY; | 
 | 1053 | 	skb->pkt_type = PACKET_OTHERHOST; | 
 | 1054 | 	skb->protocol = htons(ETH_P_802_2); | 
 | 1055 | 	memset(skb->cb, 0, sizeof(skb->cb)); | 
 | 1056 | 	netif_rx(skb); | 
 | 1057 | } | 
 | 1058 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1059 | int ieee80211_radar_status(struct ieee80211_hw *hw, int channel, | 
 | 1060 | 			   int radar, int radar_type) | 
 | 1061 | { | 
 | 1062 | 	struct sk_buff *skb; | 
 | 1063 | 	struct ieee80211_radar_info *msg; | 
 | 1064 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1065 |  | 
 | 1066 | 	if (!local->apdev) | 
 | 1067 | 		return 0; | 
 | 1068 |  | 
 | 1069 | 	skb = dev_alloc_skb(sizeof(struct ieee80211_frame_info) + | 
 | 1070 | 			    sizeof(struct ieee80211_radar_info)); | 
 | 1071 |  | 
 | 1072 | 	if (!skb) | 
 | 1073 | 		return -ENOMEM; | 
 | 1074 | 	skb_reserve(skb, sizeof(struct ieee80211_frame_info)); | 
 | 1075 |  | 
 | 1076 | 	msg = (struct ieee80211_radar_info *) | 
 | 1077 | 		skb_put(skb, sizeof(struct ieee80211_radar_info)); | 
 | 1078 | 	msg->channel = channel; | 
 | 1079 | 	msg->radar = radar; | 
 | 1080 | 	msg->radar_type = radar_type; | 
 | 1081 |  | 
 | 1082 | 	ieee80211_rx_mgmt(local, skb, NULL, ieee80211_msg_radar); | 
 | 1083 | 	return 0; | 
 | 1084 | } | 
 | 1085 | EXPORT_SYMBOL(ieee80211_radar_status); | 
 | 1086 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1087 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1088 | static void ieee80211_stat_refresh(unsigned long data) | 
 | 1089 | { | 
 | 1090 | 	struct ieee80211_local *local = (struct ieee80211_local *) data; | 
 | 1091 | 	struct sta_info *sta; | 
 | 1092 | 	struct ieee80211_sub_if_data *sdata; | 
 | 1093 |  | 
 | 1094 | 	if (!local->stat_time) | 
 | 1095 | 		return; | 
 | 1096 |  | 
 | 1097 | 	/* go through all stations */ | 
 | 1098 | 	spin_lock_bh(&local->sta_lock); | 
 | 1099 | 	list_for_each_entry(sta, &local->sta_list, list) { | 
 | 1100 | 		sta->channel_use = (sta->channel_use_raw / local->stat_time) / | 
 | 1101 | 			CHAN_UTIL_PER_10MS; | 
 | 1102 | 		sta->channel_use_raw = 0; | 
 | 1103 | 	} | 
 | 1104 | 	spin_unlock_bh(&local->sta_lock); | 
 | 1105 |  | 
 | 1106 | 	/* go through all subinterfaces */ | 
 | 1107 | 	read_lock(&local->sub_if_lock); | 
 | 1108 | 	list_for_each_entry(sdata, &local->sub_if_list, list) { | 
 | 1109 | 		sdata->channel_use = (sdata->channel_use_raw / | 
 | 1110 | 				      local->stat_time) / CHAN_UTIL_PER_10MS; | 
 | 1111 | 		sdata->channel_use_raw = 0; | 
 | 1112 | 	} | 
 | 1113 | 	read_unlock(&local->sub_if_lock); | 
 | 1114 |  | 
 | 1115 | 	/* hardware interface */ | 
 | 1116 | 	local->channel_use = (local->channel_use_raw / | 
 | 1117 | 			      local->stat_time) / CHAN_UTIL_PER_10MS; | 
 | 1118 | 	local->channel_use_raw = 0; | 
 | 1119 |  | 
 | 1120 | 	local->stat_timer.expires = jiffies + HZ * local->stat_time / 100; | 
 | 1121 | 	add_timer(&local->stat_timer); | 
 | 1122 | } | 
 | 1123 |  | 
 | 1124 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1125 | void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, | 
 | 1126 | 				 struct sk_buff *skb, | 
 | 1127 | 				 struct ieee80211_tx_status *status) | 
 | 1128 | { | 
 | 1129 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1130 | 	struct ieee80211_tx_status *saved; | 
 | 1131 | 	int tmp; | 
 | 1132 |  | 
 | 1133 | 	skb->dev = local->mdev; | 
 | 1134 | 	saved = kmalloc(sizeof(struct ieee80211_tx_status), GFP_ATOMIC); | 
 | 1135 | 	if (unlikely(!saved)) { | 
 | 1136 | 		if (net_ratelimit()) | 
 | 1137 | 			printk(KERN_WARNING "%s: Not enough memory, " | 
 | 1138 | 			       "dropping tx status", skb->dev->name); | 
 | 1139 | 		/* should be dev_kfree_skb_irq, but due to this function being | 
 | 1140 | 		 * named _irqsafe instead of just _irq we can't be sure that | 
 | 1141 | 		 * people won't call it from non-irq contexts */ | 
 | 1142 | 		dev_kfree_skb_any(skb); | 
 | 1143 | 		return; | 
 | 1144 | 	} | 
 | 1145 | 	memcpy(saved, status, sizeof(struct ieee80211_tx_status)); | 
 | 1146 | 	/* copy pointer to saved status into skb->cb for use by tasklet */ | 
 | 1147 | 	memcpy(skb->cb, &saved, sizeof(saved)); | 
 | 1148 |  | 
 | 1149 | 	skb->pkt_type = IEEE80211_TX_STATUS_MSG; | 
 | 1150 | 	skb_queue_tail(status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS ? | 
 | 1151 | 		       &local->skb_queue : &local->skb_queue_unreliable, skb); | 
 | 1152 | 	tmp = skb_queue_len(&local->skb_queue) + | 
 | 1153 | 		skb_queue_len(&local->skb_queue_unreliable); | 
 | 1154 | 	while (tmp > IEEE80211_IRQSAFE_QUEUE_LIMIT && | 
 | 1155 | 	       (skb = skb_dequeue(&local->skb_queue_unreliable))) { | 
 | 1156 | 		memcpy(&saved, skb->cb, sizeof(saved)); | 
 | 1157 | 		kfree(saved); | 
 | 1158 | 		dev_kfree_skb_irq(skb); | 
 | 1159 | 		tmp--; | 
 | 1160 | 		I802_DEBUG_INC(local->tx_status_drop); | 
 | 1161 | 	} | 
 | 1162 | 	tasklet_schedule(&local->tasklet); | 
 | 1163 | } | 
 | 1164 | EXPORT_SYMBOL(ieee80211_tx_status_irqsafe); | 
 | 1165 |  | 
 | 1166 | static void ieee80211_tasklet_handler(unsigned long data) | 
 | 1167 | { | 
 | 1168 | 	struct ieee80211_local *local = (struct ieee80211_local *) data; | 
 | 1169 | 	struct sk_buff *skb; | 
 | 1170 | 	struct ieee80211_rx_status rx_status; | 
 | 1171 | 	struct ieee80211_tx_status *tx_status; | 
 | 1172 |  | 
 | 1173 | 	while ((skb = skb_dequeue(&local->skb_queue)) || | 
 | 1174 | 	       (skb = skb_dequeue(&local->skb_queue_unreliable))) { | 
 | 1175 | 		switch (skb->pkt_type) { | 
 | 1176 | 		case IEEE80211_RX_MSG: | 
 | 1177 | 			/* status is in skb->cb */ | 
 | 1178 | 			memcpy(&rx_status, skb->cb, sizeof(rx_status)); | 
 | 1179 | 			/* Clear skb->type in order to not confuse kernel | 
 | 1180 | 			 * netstack. */ | 
 | 1181 | 			skb->pkt_type = 0; | 
 | 1182 | 			__ieee80211_rx(local_to_hw(local), skb, &rx_status); | 
 | 1183 | 			break; | 
 | 1184 | 		case IEEE80211_TX_STATUS_MSG: | 
 | 1185 | 			/* get pointer to saved status out of skb->cb */ | 
 | 1186 | 			memcpy(&tx_status, skb->cb, sizeof(tx_status)); | 
 | 1187 | 			skb->pkt_type = 0; | 
 | 1188 | 			ieee80211_tx_status(local_to_hw(local), | 
 | 1189 | 					    skb, tx_status); | 
 | 1190 | 			kfree(tx_status); | 
 | 1191 | 			break; | 
 | 1192 | 		default: /* should never get here! */ | 
 | 1193 | 			printk(KERN_ERR "%s: Unknown message type (%d)\n", | 
 | 1194 | 			       local->mdev->name, skb->pkt_type); | 
 | 1195 | 			dev_kfree_skb(skb); | 
 | 1196 | 			break; | 
 | 1197 | 		} | 
 | 1198 | 	} | 
 | 1199 | } | 
 | 1200 |  | 
 | 1201 |  | 
 | 1202 | /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to | 
 | 1203 |  * make a prepared TX frame (one that has been given to hw) to look like brand | 
 | 1204 |  * new IEEE 802.11 frame that is ready to go through TX processing again. | 
 | 1205 |  * Also, tx_packet_data in cb is restored from tx_control. */ | 
 | 1206 | static void ieee80211_remove_tx_extra(struct ieee80211_local *local, | 
 | 1207 | 				      struct ieee80211_key *key, | 
 | 1208 | 				      struct sk_buff *skb, | 
 | 1209 | 				      struct ieee80211_tx_control *control) | 
 | 1210 | { | 
 | 1211 | 	int hdrlen, iv_len, mic_len; | 
 | 1212 | 	struct ieee80211_tx_packet_data *pkt_data; | 
 | 1213 |  | 
 | 1214 | 	pkt_data = (struct ieee80211_tx_packet_data *)skb->cb; | 
 | 1215 | 	pkt_data->ifindex = control->ifindex; | 
 | 1216 | 	pkt_data->mgmt_iface = (control->type == IEEE80211_IF_TYPE_MGMT); | 
 | 1217 | 	pkt_data->req_tx_status = !!(control->flags & IEEE80211_TXCTL_REQ_TX_STATUS); | 
 | 1218 | 	pkt_data->do_not_encrypt = !!(control->flags & IEEE80211_TXCTL_DO_NOT_ENCRYPT); | 
 | 1219 | 	pkt_data->requeue = !!(control->flags & IEEE80211_TXCTL_REQUEUE); | 
 | 1220 | 	pkt_data->queue = control->queue; | 
 | 1221 |  | 
 | 1222 | 	hdrlen = ieee80211_get_hdrlen_from_skb(skb); | 
 | 1223 |  | 
 | 1224 | 	if (!key) | 
 | 1225 | 		goto no_key; | 
 | 1226 |  | 
 | 1227 | 	switch (key->alg) { | 
 | 1228 | 	case ALG_WEP: | 
 | 1229 | 		iv_len = WEP_IV_LEN; | 
 | 1230 | 		mic_len = WEP_ICV_LEN; | 
 | 1231 | 		break; | 
 | 1232 | 	case ALG_TKIP: | 
 | 1233 | 		iv_len = TKIP_IV_LEN; | 
 | 1234 | 		mic_len = TKIP_ICV_LEN; | 
 | 1235 | 		break; | 
 | 1236 | 	case ALG_CCMP: | 
 | 1237 | 		iv_len = CCMP_HDR_LEN; | 
 | 1238 | 		mic_len = CCMP_MIC_LEN; | 
 | 1239 | 		break; | 
 | 1240 | 	default: | 
 | 1241 | 		goto no_key; | 
 | 1242 | 	} | 
 | 1243 |  | 
 | 1244 | 	if (skb->len >= mic_len && key->force_sw_encrypt) | 
 | 1245 | 		skb_trim(skb, skb->len - mic_len); | 
 | 1246 | 	if (skb->len >= iv_len && skb->len > hdrlen) { | 
 | 1247 | 		memmove(skb->data + iv_len, skb->data, hdrlen); | 
 | 1248 | 		skb_pull(skb, iv_len); | 
 | 1249 | 	} | 
 | 1250 |  | 
 | 1251 | no_key: | 
 | 1252 | 	{ | 
 | 1253 | 		struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 
 | 1254 | 		u16 fc = le16_to_cpu(hdr->frame_control); | 
 | 1255 | 		if ((fc & 0x8C) == 0x88) /* QoS Control Field */ { | 
 | 1256 | 			fc &= ~IEEE80211_STYPE_QOS_DATA; | 
 | 1257 | 			hdr->frame_control = cpu_to_le16(fc); | 
 | 1258 | 			memmove(skb->data + 2, skb->data, hdrlen - 2); | 
 | 1259 | 			skb_pull(skb, 2); | 
 | 1260 | 		} | 
 | 1261 | 	} | 
 | 1262 | } | 
 | 1263 |  | 
 | 1264 |  | 
 | 1265 | void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, | 
 | 1266 | 			 struct ieee80211_tx_status *status) | 
 | 1267 | { | 
 | 1268 | 	struct sk_buff *skb2; | 
 | 1269 | 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | 
 | 1270 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1271 | 	u16 frag, type; | 
 | 1272 | 	u32 msg_type; | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1273 | 	struct ieee80211_tx_status_rtap_hdr *rthdr; | 
 | 1274 | 	struct ieee80211_sub_if_data *sdata; | 
 | 1275 | 	int monitors; | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1276 |  | 
 | 1277 | 	if (!status) { | 
 | 1278 | 		printk(KERN_ERR | 
 | 1279 | 		       "%s: ieee80211_tx_status called with NULL status\n", | 
 | 1280 | 		       local->mdev->name); | 
 | 1281 | 		dev_kfree_skb(skb); | 
 | 1282 | 		return; | 
 | 1283 | 	} | 
 | 1284 |  | 
 | 1285 | 	if (status->excessive_retries) { | 
 | 1286 | 		struct sta_info *sta; | 
 | 1287 | 		sta = sta_info_get(local, hdr->addr1); | 
 | 1288 | 		if (sta) { | 
 | 1289 | 			if (sta->flags & WLAN_STA_PS) { | 
 | 1290 | 				/* The STA is in power save mode, so assume | 
 | 1291 | 				 * that this TX packet failed because of that. | 
 | 1292 | 				 */ | 
 | 1293 | 				status->excessive_retries = 0; | 
 | 1294 | 				status->flags |= IEEE80211_TX_STATUS_TX_FILTERED; | 
 | 1295 | 			} | 
 | 1296 | 			sta_info_put(sta); | 
 | 1297 | 		} | 
 | 1298 | 	} | 
 | 1299 |  | 
 | 1300 | 	if (status->flags & IEEE80211_TX_STATUS_TX_FILTERED) { | 
 | 1301 | 		struct sta_info *sta; | 
 | 1302 | 		sta = sta_info_get(local, hdr->addr1); | 
 | 1303 | 		if (sta) { | 
 | 1304 | 			sta->tx_filtered_count++; | 
 | 1305 |  | 
 | 1306 | 			/* Clear the TX filter mask for this STA when sending | 
 | 1307 | 			 * the next packet. If the STA went to power save mode, | 
 | 1308 | 			 * this will happen when it is waking up for the next | 
 | 1309 | 			 * time. */ | 
 | 1310 | 			sta->clear_dst_mask = 1; | 
 | 1311 |  | 
 | 1312 | 			/* TODO: Is the WLAN_STA_PS flag always set here or is | 
 | 1313 | 			 * the race between RX and TX status causing some | 
 | 1314 | 			 * packets to be filtered out before 80211.o gets an | 
 | 1315 | 			 * update for PS status? This seems to be the case, so | 
 | 1316 | 			 * no changes are likely to be needed. */ | 
 | 1317 | 			if (sta->flags & WLAN_STA_PS && | 
 | 1318 | 			    skb_queue_len(&sta->tx_filtered) < | 
 | 1319 | 			    STA_MAX_TX_BUFFER) { | 
 | 1320 | 				ieee80211_remove_tx_extra(local, sta->key, | 
 | 1321 | 							  skb, | 
 | 1322 | 							  &status->control); | 
 | 1323 | 				skb_queue_tail(&sta->tx_filtered, skb); | 
 | 1324 | 			} else if (!(sta->flags & WLAN_STA_PS) && | 
 | 1325 | 				   !(status->control.flags & IEEE80211_TXCTL_REQUEUE)) { | 
 | 1326 | 				/* Software retry the packet once */ | 
 | 1327 | 				status->control.flags |= IEEE80211_TXCTL_REQUEUE; | 
 | 1328 | 				ieee80211_remove_tx_extra(local, sta->key, | 
 | 1329 | 							  skb, | 
 | 1330 | 							  &status->control); | 
 | 1331 | 				dev_queue_xmit(skb); | 
 | 1332 | 			} else { | 
 | 1333 | 				if (net_ratelimit()) { | 
 | 1334 | 					printk(KERN_DEBUG "%s: dropped TX " | 
 | 1335 | 					       "filtered frame queue_len=%d " | 
 | 1336 | 					       "PS=%d @%lu\n", | 
 | 1337 | 					       local->mdev->name, | 
 | 1338 | 					       skb_queue_len( | 
 | 1339 | 						       &sta->tx_filtered), | 
 | 1340 | 					       !!(sta->flags & WLAN_STA_PS), | 
 | 1341 | 					       jiffies); | 
 | 1342 | 				} | 
 | 1343 | 				dev_kfree_skb(skb); | 
 | 1344 | 			} | 
 | 1345 | 			sta_info_put(sta); | 
 | 1346 | 			return; | 
 | 1347 | 		} | 
 | 1348 | 	} else { | 
 | 1349 | 		/* FIXME: STUPID to call this with both local and local->mdev */ | 
 | 1350 | 		rate_control_tx_status(local, local->mdev, skb, status); | 
 | 1351 | 	} | 
 | 1352 |  | 
 | 1353 | 	ieee80211_led_tx(local, 0); | 
 | 1354 |  | 
 | 1355 | 	/* SNMP counters | 
 | 1356 | 	 * Fragments are passed to low-level drivers as separate skbs, so these | 
 | 1357 | 	 * are actually fragments, not frames. Update frame counters only for | 
 | 1358 | 	 * the first fragment of the frame. */ | 
 | 1359 |  | 
 | 1360 | 	frag = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG; | 
 | 1361 | 	type = le16_to_cpu(hdr->frame_control) & IEEE80211_FCTL_FTYPE; | 
 | 1362 |  | 
 | 1363 | 	if (status->flags & IEEE80211_TX_STATUS_ACK) { | 
 | 1364 | 		if (frag == 0) { | 
 | 1365 | 			local->dot11TransmittedFrameCount++; | 
 | 1366 | 			if (is_multicast_ether_addr(hdr->addr1)) | 
 | 1367 | 				local->dot11MulticastTransmittedFrameCount++; | 
 | 1368 | 			if (status->retry_count > 0) | 
 | 1369 | 				local->dot11RetryCount++; | 
 | 1370 | 			if (status->retry_count > 1) | 
 | 1371 | 				local->dot11MultipleRetryCount++; | 
 | 1372 | 		} | 
 | 1373 |  | 
 | 1374 | 		/* This counter shall be incremented for an acknowledged MPDU | 
 | 1375 | 		 * with an individual address in the address 1 field or an MPDU | 
 | 1376 | 		 * with a multicast address in the address 1 field of type Data | 
 | 1377 | 		 * or Management. */ | 
 | 1378 | 		if (!is_multicast_ether_addr(hdr->addr1) || | 
 | 1379 | 		    type == IEEE80211_FTYPE_DATA || | 
 | 1380 | 		    type == IEEE80211_FTYPE_MGMT) | 
 | 1381 | 			local->dot11TransmittedFragmentCount++; | 
 | 1382 | 	} else { | 
 | 1383 | 		if (frag == 0) | 
 | 1384 | 			local->dot11FailedCount++; | 
 | 1385 | 	} | 
 | 1386 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1387 | 	msg_type = (status->flags & IEEE80211_TX_STATUS_ACK) ? | 
 | 1388 | 		ieee80211_msg_tx_callback_ack : ieee80211_msg_tx_callback_fail; | 
 | 1389 |  | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1390 | 	/* this was a transmitted frame, but now we want to reuse it */ | 
 | 1391 | 	skb_orphan(skb); | 
 | 1392 |  | 
 | 1393 | 	if ((status->control.flags & IEEE80211_TXCTL_REQ_TX_STATUS) && | 
 | 1394 | 	    local->apdev) { | 
 | 1395 | 		if (local->monitors) { | 
 | 1396 | 			skb2 = skb_clone(skb, GFP_ATOMIC); | 
 | 1397 | 		} else { | 
 | 1398 | 			skb2 = skb; | 
 | 1399 | 			skb = NULL; | 
 | 1400 | 		} | 
 | 1401 |  | 
 | 1402 | 		if (skb2) | 
 | 1403 | 			/* Send frame to hostapd */ | 
 | 1404 | 			ieee80211_rx_mgmt(local, skb2, NULL, msg_type); | 
 | 1405 |  | 
 | 1406 | 		if (!skb) | 
 | 1407 | 			return; | 
 | 1408 | 	} | 
 | 1409 |  | 
 | 1410 | 	if (!local->monitors) { | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1411 | 		dev_kfree_skb(skb); | 
 | 1412 | 		return; | 
 | 1413 | 	} | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1414 |  | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1415 | 	/* send frame to monitor interfaces now */ | 
 | 1416 |  | 
 | 1417 | 	if (skb_headroom(skb) < sizeof(*rthdr)) { | 
 | 1418 | 		printk(KERN_ERR "ieee80211_tx_status: headroom too small\n"); | 
 | 1419 | 		dev_kfree_skb(skb); | 
 | 1420 | 		return; | 
 | 1421 | 	} | 
 | 1422 |  | 
 | 1423 | 	rthdr = (struct ieee80211_tx_status_rtap_hdr*) | 
 | 1424 | 				skb_push(skb, sizeof(*rthdr)); | 
 | 1425 |  | 
 | 1426 | 	memset(rthdr, 0, sizeof(*rthdr)); | 
 | 1427 | 	rthdr->hdr.it_len = cpu_to_le16(sizeof(*rthdr)); | 
 | 1428 | 	rthdr->hdr.it_present = | 
 | 1429 | 		cpu_to_le32((1 << IEEE80211_RADIOTAP_TX_FLAGS) | | 
 | 1430 | 			    (1 << IEEE80211_RADIOTAP_DATA_RETRIES)); | 
 | 1431 |  | 
 | 1432 | 	if (!(status->flags & IEEE80211_TX_STATUS_ACK) && | 
 | 1433 | 	    !is_multicast_ether_addr(hdr->addr1)) | 
 | 1434 | 		rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_FAIL); | 
 | 1435 |  | 
 | 1436 | 	if ((status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) && | 
 | 1437 | 	    (status->control.flags & IEEE80211_TXCTL_USE_CTS_PROTECT)) | 
 | 1438 | 		rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_CTS); | 
 | 1439 | 	else if (status->control.flags & IEEE80211_TXCTL_USE_RTS_CTS) | 
 | 1440 | 		rthdr->tx_flags |= cpu_to_le16(IEEE80211_RADIOTAP_F_TX_RTS); | 
 | 1441 |  | 
 | 1442 | 	rthdr->data_retries = status->retry_count; | 
 | 1443 |  | 
 | 1444 | 	read_lock(&local->sub_if_lock); | 
 | 1445 | 	monitors = local->monitors; | 
 | 1446 | 	list_for_each_entry(sdata, &local->sub_if_list, list) { | 
 | 1447 | 		/* | 
 | 1448 | 		 * Using the monitors counter is possibly racy, but | 
 | 1449 | 		 * if the value is wrong we simply either clone the skb | 
 | 1450 | 		 * once too much or forget sending it to one monitor iface | 
 | 1451 | 		 * The latter case isn't nice but fixing the race is much | 
 | 1452 | 		 * more complicated. | 
 | 1453 | 		 */ | 
 | 1454 | 		if (!monitors || !skb) | 
 | 1455 | 			goto out; | 
 | 1456 |  | 
 | 1457 | 		if (sdata->type == IEEE80211_IF_TYPE_MNTR) { | 
 | 1458 | 			if (!netif_running(sdata->dev)) | 
 | 1459 | 				continue; | 
 | 1460 | 			monitors--; | 
 | 1461 | 			if (monitors) | 
 | 1462 | 				skb2 = skb_clone(skb, GFP_KERNEL); | 
 | 1463 | 			else | 
 | 1464 | 				skb2 = NULL; | 
 | 1465 | 			skb->dev = sdata->dev; | 
 | 1466 | 			/* XXX: is this sufficient for BPF? */ | 
 | 1467 | 			skb_set_mac_header(skb, 0); | 
 | 1468 | 			skb->ip_summed = CHECKSUM_UNNECESSARY; | 
 | 1469 | 			skb->pkt_type = PACKET_OTHERHOST; | 
 | 1470 | 			skb->protocol = htons(ETH_P_802_2); | 
 | 1471 | 			memset(skb->cb, 0, sizeof(skb->cb)); | 
 | 1472 | 			netif_rx(skb); | 
 | 1473 | 			skb = skb2; | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1474 | 		} | 
 | 1475 | 	} | 
 | 1476 |  out: | 
 | 1477 | 	read_unlock(&local->sub_if_lock); | 
 | 1478 | 	if (skb) | 
 | 1479 | 		dev_kfree_skb(skb); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1480 | } | 
 | 1481 | EXPORT_SYMBOL(ieee80211_tx_status); | 
 | 1482 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1483 |  | 
 | 1484 | int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr) | 
 | 1485 | { | 
 | 1486 | 	struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 
 | 1487 | 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 1488 | 	struct sta_info *sta; | 
 | 1489 |  | 
 | 1490 | 	if (compare_ether_addr(remote_addr, sdata->u.wds.remote_addr) == 0) | 
 | 1491 | 		return 0; | 
 | 1492 |  | 
 | 1493 | 	/* Create STA entry for the new peer */ | 
 | 1494 | 	sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL); | 
 | 1495 | 	if (!sta) | 
 | 1496 | 		return -ENOMEM; | 
 | 1497 | 	sta_info_put(sta); | 
 | 1498 |  | 
 | 1499 | 	/* Remove STA entry for the old peer */ | 
 | 1500 | 	sta = sta_info_get(local, sdata->u.wds.remote_addr); | 
 | 1501 | 	if (sta) { | 
 | 1502 | 		sta_info_put(sta); | 
 | 1503 | 		sta_info_free(sta, 0); | 
 | 1504 | 	} else { | 
 | 1505 | 		printk(KERN_DEBUG "%s: could not find STA entry for WDS link " | 
 | 1506 | 		       "peer " MAC_FMT "\n", | 
 | 1507 | 		       dev->name, MAC_ARG(sdata->u.wds.remote_addr)); | 
 | 1508 | 	} | 
 | 1509 |  | 
 | 1510 | 	/* Update WDS link data */ | 
 | 1511 | 	memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN); | 
 | 1512 |  | 
 | 1513 | 	return 0; | 
 | 1514 | } | 
 | 1515 |  | 
 | 1516 | /* Must not be called for mdev and apdev */ | 
 | 1517 | void ieee80211_if_setup(struct net_device *dev) | 
 | 1518 | { | 
 | 1519 | 	ether_setup(dev); | 
 | 1520 | 	dev->hard_start_xmit = ieee80211_subif_start_xmit; | 
 | 1521 | 	dev->wireless_handlers = &ieee80211_iw_handler_def; | 
 | 1522 | 	dev->set_multicast_list = ieee80211_set_multicast_list; | 
 | 1523 | 	dev->change_mtu = ieee80211_change_mtu; | 
 | 1524 | 	dev->get_stats = ieee80211_get_stats; | 
 | 1525 | 	dev->open = ieee80211_open; | 
 | 1526 | 	dev->stop = ieee80211_stop; | 
 | 1527 | 	dev->uninit = ieee80211_if_reinit; | 
 | 1528 | 	dev->destructor = ieee80211_if_free; | 
 | 1529 | } | 
 | 1530 |  | 
 | 1531 | void ieee80211_if_mgmt_setup(struct net_device *dev) | 
 | 1532 | { | 
 | 1533 | 	ether_setup(dev); | 
 | 1534 | 	dev->hard_start_xmit = ieee80211_mgmt_start_xmit; | 
 | 1535 | 	dev->change_mtu = ieee80211_change_mtu_apdev; | 
 | 1536 | 	dev->get_stats = ieee80211_get_stats; | 
 | 1537 | 	dev->open = ieee80211_mgmt_open; | 
 | 1538 | 	dev->stop = ieee80211_mgmt_stop; | 
 | 1539 | 	dev->type = ARPHRD_IEEE80211_PRISM; | 
 | 1540 | 	dev->hard_header_parse = header_parse_80211; | 
 | 1541 | 	dev->uninit = ieee80211_if_reinit; | 
 | 1542 | 	dev->destructor = ieee80211_if_free; | 
 | 1543 | } | 
 | 1544 |  | 
 | 1545 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, | 
 | 1546 | 				 const char *name) | 
 | 1547 | { | 
 | 1548 | 	struct rate_control_ref *ref, *old; | 
 | 1549 |  | 
 | 1550 | 	ASSERT_RTNL(); | 
 | 1551 | 	if (local->open_count || netif_running(local->mdev) || | 
 | 1552 | 	    (local->apdev && netif_running(local->apdev))) | 
 | 1553 | 		return -EBUSY; | 
 | 1554 |  | 
 | 1555 | 	ref = rate_control_alloc(name, local); | 
 | 1556 | 	if (!ref) { | 
 | 1557 | 		printk(KERN_WARNING "%s: Failed to select rate control " | 
 | 1558 | 		       "algorithm\n", local->mdev->name); | 
 | 1559 | 		return -ENOENT; | 
 | 1560 | 	} | 
 | 1561 |  | 
 | 1562 | 	old = local->rate_ctrl; | 
 | 1563 | 	local->rate_ctrl = ref; | 
 | 1564 | 	if (old) { | 
 | 1565 | 		rate_control_put(old); | 
 | 1566 | 		sta_info_flush(local, NULL); | 
 | 1567 | 	} | 
 | 1568 |  | 
 | 1569 | 	printk(KERN_DEBUG "%s: Selected rate control " | 
 | 1570 | 	       "algorithm '%s'\n", local->mdev->name, | 
 | 1571 | 	       ref->ops->name); | 
 | 1572 |  | 
 | 1573 |  | 
 | 1574 | 	return 0; | 
 | 1575 | } | 
 | 1576 |  | 
 | 1577 | static void rate_control_deinitialize(struct ieee80211_local *local) | 
 | 1578 | { | 
 | 1579 | 	struct rate_control_ref *ref; | 
 | 1580 |  | 
 | 1581 | 	ref = local->rate_ctrl; | 
 | 1582 | 	local->rate_ctrl = NULL; | 
 | 1583 | 	rate_control_put(ref); | 
 | 1584 | } | 
 | 1585 |  | 
 | 1586 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | 
 | 1587 | 					const struct ieee80211_ops *ops) | 
 | 1588 | { | 
 | 1589 | 	struct net_device *mdev; | 
 | 1590 | 	struct ieee80211_local *local; | 
 | 1591 | 	struct ieee80211_sub_if_data *sdata; | 
 | 1592 | 	int priv_size; | 
 | 1593 | 	struct wiphy *wiphy; | 
 | 1594 |  | 
 | 1595 | 	/* Ensure 32-byte alignment of our private data and hw private data. | 
 | 1596 | 	 * We use the wiphy priv data for both our ieee80211_local and for | 
 | 1597 | 	 * the driver's private data | 
 | 1598 | 	 * | 
 | 1599 | 	 * In memory it'll be like this: | 
 | 1600 | 	 * | 
 | 1601 | 	 * +-------------------------+ | 
 | 1602 | 	 * | struct wiphy	    | | 
 | 1603 | 	 * +-------------------------+ | 
 | 1604 | 	 * | struct ieee80211_local  | | 
 | 1605 | 	 * +-------------------------+ | 
 | 1606 | 	 * | driver's private data   | | 
 | 1607 | 	 * +-------------------------+ | 
 | 1608 | 	 * | 
 | 1609 | 	 */ | 
 | 1610 | 	priv_size = ((sizeof(struct ieee80211_local) + | 
 | 1611 | 		      NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST) + | 
 | 1612 | 		    priv_data_len; | 
 | 1613 |  | 
 | 1614 | 	wiphy = wiphy_new(&mac80211_config_ops, priv_size); | 
 | 1615 |  | 
 | 1616 | 	if (!wiphy) | 
 | 1617 | 		return NULL; | 
 | 1618 |  | 
 | 1619 | 	wiphy->privid = mac80211_wiphy_privid; | 
 | 1620 |  | 
 | 1621 | 	local = wiphy_priv(wiphy); | 
 | 1622 | 	local->hw.wiphy = wiphy; | 
 | 1623 |  | 
 | 1624 | 	local->hw.priv = (char *)local + | 
 | 1625 | 			 ((sizeof(struct ieee80211_local) + | 
 | 1626 | 			   NETDEV_ALIGN_CONST) & ~NETDEV_ALIGN_CONST); | 
 | 1627 |  | 
| Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 1628 | 	BUG_ON(!ops->tx); | 
 | 1629 | 	BUG_ON(!ops->config); | 
 | 1630 | 	BUG_ON(!ops->add_interface); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1631 | 	local->ops = ops; | 
 | 1632 |  | 
 | 1633 | 	/* for now, mdev needs sub_if_data :/ */ | 
 | 1634 | 	mdev = alloc_netdev(sizeof(struct ieee80211_sub_if_data), | 
 | 1635 | 			    "wmaster%d", ether_setup); | 
 | 1636 | 	if (!mdev) { | 
 | 1637 | 		wiphy_free(wiphy); | 
 | 1638 | 		return NULL; | 
 | 1639 | 	} | 
 | 1640 |  | 
 | 1641 | 	sdata = IEEE80211_DEV_TO_SUB_IF(mdev); | 
 | 1642 | 	mdev->ieee80211_ptr = &sdata->wdev; | 
 | 1643 | 	sdata->wdev.wiphy = wiphy; | 
 | 1644 |  | 
 | 1645 | 	local->hw.queues = 1; /* default */ | 
 | 1646 |  | 
 | 1647 | 	local->mdev = mdev; | 
 | 1648 | 	local->rx_pre_handlers = ieee80211_rx_pre_handlers; | 
 | 1649 | 	local->rx_handlers = ieee80211_rx_handlers; | 
 | 1650 | 	local->tx_handlers = ieee80211_tx_handlers; | 
 | 1651 |  | 
 | 1652 | 	local->bridge_packets = 1; | 
 | 1653 |  | 
 | 1654 | 	local->rts_threshold = IEEE80211_MAX_RTS_THRESHOLD; | 
 | 1655 | 	local->fragmentation_threshold = IEEE80211_MAX_FRAG_THRESHOLD; | 
 | 1656 | 	local->short_retry_limit = 7; | 
 | 1657 | 	local->long_retry_limit = 4; | 
 | 1658 | 	local->hw.conf.radio_enabled = 1; | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1659 |  | 
 | 1660 | 	local->enabled_modes = (unsigned int) -1; | 
 | 1661 |  | 
 | 1662 | 	INIT_LIST_HEAD(&local->modes_list); | 
 | 1663 |  | 
 | 1664 | 	rwlock_init(&local->sub_if_lock); | 
 | 1665 | 	INIT_LIST_HEAD(&local->sub_if_list); | 
 | 1666 |  | 
 | 1667 | 	INIT_DELAYED_WORK(&local->scan_work, ieee80211_sta_scan_work); | 
 | 1668 | 	init_timer(&local->stat_timer); | 
 | 1669 | 	local->stat_timer.function = ieee80211_stat_refresh; | 
 | 1670 | 	local->stat_timer.data = (unsigned long) local; | 
 | 1671 | 	ieee80211_rx_bss_list_init(mdev); | 
 | 1672 |  | 
 | 1673 | 	sta_info_init(local); | 
 | 1674 |  | 
 | 1675 | 	mdev->hard_start_xmit = ieee80211_master_start_xmit; | 
 | 1676 | 	mdev->open = ieee80211_master_open; | 
 | 1677 | 	mdev->stop = ieee80211_master_stop; | 
 | 1678 | 	mdev->type = ARPHRD_IEEE80211; | 
 | 1679 | 	mdev->hard_header_parse = header_parse_80211; | 
 | 1680 |  | 
 | 1681 | 	sdata->type = IEEE80211_IF_TYPE_AP; | 
 | 1682 | 	sdata->dev = mdev; | 
 | 1683 | 	sdata->local = local; | 
 | 1684 | 	sdata->u.ap.force_unicast_rateidx = -1; | 
 | 1685 | 	sdata->u.ap.max_ratectrl_rateidx = -1; | 
 | 1686 | 	ieee80211_if_sdata_init(sdata); | 
 | 1687 | 	list_add_tail(&sdata->list, &local->sub_if_list); | 
 | 1688 |  | 
 | 1689 | 	tasklet_init(&local->tx_pending_tasklet, ieee80211_tx_pending, | 
 | 1690 | 		     (unsigned long)local); | 
 | 1691 | 	tasklet_disable(&local->tx_pending_tasklet); | 
 | 1692 |  | 
 | 1693 | 	tasklet_init(&local->tasklet, | 
 | 1694 | 		     ieee80211_tasklet_handler, | 
 | 1695 | 		     (unsigned long) local); | 
 | 1696 | 	tasklet_disable(&local->tasklet); | 
 | 1697 |  | 
 | 1698 | 	skb_queue_head_init(&local->skb_queue); | 
 | 1699 | 	skb_queue_head_init(&local->skb_queue_unreliable); | 
 | 1700 |  | 
 | 1701 | 	return local_to_hw(local); | 
 | 1702 | } | 
 | 1703 | EXPORT_SYMBOL(ieee80211_alloc_hw); | 
 | 1704 |  | 
 | 1705 | int ieee80211_register_hw(struct ieee80211_hw *hw) | 
 | 1706 | { | 
 | 1707 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1708 | 	const char *name; | 
 | 1709 | 	int result; | 
 | 1710 |  | 
 | 1711 | 	result = wiphy_register(local->hw.wiphy); | 
 | 1712 | 	if (result < 0) | 
 | 1713 | 		return result; | 
 | 1714 |  | 
 | 1715 | 	name = wiphy_dev(local->hw.wiphy)->driver->name; | 
 | 1716 | 	local->hw.workqueue = create_singlethread_workqueue(name); | 
 | 1717 | 	if (!local->hw.workqueue) { | 
 | 1718 | 		result = -ENOMEM; | 
 | 1719 | 		goto fail_workqueue; | 
 | 1720 | 	} | 
 | 1721 |  | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1722 | 	/* | 
 | 1723 | 	 * The hardware needs headroom for sending the frame, | 
 | 1724 | 	 * and we need some headroom for passing the frame to monitor | 
 | 1725 | 	 * interfaces, but never both at the same time. | 
 | 1726 | 	 */ | 
| Jiri Benc | 33ccad3 | 2007-07-18 17:10:44 +0200 | [diff] [blame] | 1727 | 	local->tx_headroom = max_t(unsigned int , local->hw.extra_tx_headroom, | 
 | 1728 | 				   sizeof(struct ieee80211_tx_status_rtap_hdr)); | 
| Johannes Berg | b306f45 | 2007-07-10 19:32:08 +0200 | [diff] [blame] | 1729 |  | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1730 | 	debugfs_hw_add(local); | 
 | 1731 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1732 | 	local->hw.conf.beacon_int = 1000; | 
 | 1733 |  | 
 | 1734 | 	local->wstats_flags |= local->hw.max_rssi ? | 
 | 1735 | 			       IW_QUAL_LEVEL_UPDATED : IW_QUAL_LEVEL_INVALID; | 
 | 1736 | 	local->wstats_flags |= local->hw.max_signal ? | 
 | 1737 | 			       IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID; | 
 | 1738 | 	local->wstats_flags |= local->hw.max_noise ? | 
 | 1739 | 			       IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID; | 
 | 1740 | 	if (local->hw.max_rssi < 0 || local->hw.max_noise < 0) | 
 | 1741 | 		local->wstats_flags |= IW_QUAL_DBM; | 
 | 1742 |  | 
 | 1743 | 	result = sta_info_start(local); | 
 | 1744 | 	if (result < 0) | 
 | 1745 | 		goto fail_sta_info; | 
 | 1746 |  | 
 | 1747 | 	rtnl_lock(); | 
 | 1748 | 	result = dev_alloc_name(local->mdev, local->mdev->name); | 
 | 1749 | 	if (result < 0) | 
 | 1750 | 		goto fail_dev; | 
 | 1751 |  | 
 | 1752 | 	memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); | 
 | 1753 | 	SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy)); | 
 | 1754 |  | 
 | 1755 | 	result = register_netdevice(local->mdev); | 
 | 1756 | 	if (result < 0) | 
 | 1757 | 		goto fail_dev; | 
 | 1758 |  | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1759 | 	ieee80211_debugfs_add_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); | 
 | 1760 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1761 | 	result = ieee80211_init_rate_ctrl_alg(local, NULL); | 
 | 1762 | 	if (result < 0) { | 
 | 1763 | 		printk(KERN_DEBUG "%s: Failed to initialize rate control " | 
 | 1764 | 		       "algorithm\n", local->mdev->name); | 
 | 1765 | 		goto fail_rate; | 
 | 1766 | 	} | 
 | 1767 |  | 
 | 1768 | 	result = ieee80211_wep_init(local); | 
 | 1769 |  | 
 | 1770 | 	if (result < 0) { | 
 | 1771 | 		printk(KERN_DEBUG "%s: Failed to initialize wep\n", | 
 | 1772 | 		       local->mdev->name); | 
 | 1773 | 		goto fail_wep; | 
 | 1774 | 	} | 
 | 1775 |  | 
 | 1776 | 	ieee80211_install_qdisc(local->mdev); | 
 | 1777 |  | 
 | 1778 | 	/* add one default STA interface */ | 
 | 1779 | 	result = ieee80211_if_add(local->mdev, "wlan%d", NULL, | 
 | 1780 | 				  IEEE80211_IF_TYPE_STA); | 
 | 1781 | 	if (result) | 
 | 1782 | 		printk(KERN_WARNING "%s: Failed to add default virtual iface\n", | 
 | 1783 | 		       local->mdev->name); | 
 | 1784 |  | 
 | 1785 | 	local->reg_state = IEEE80211_DEV_REGISTERED; | 
 | 1786 | 	rtnl_unlock(); | 
 | 1787 |  | 
 | 1788 | 	ieee80211_led_init(local); | 
 | 1789 |  | 
 | 1790 | 	return 0; | 
 | 1791 |  | 
 | 1792 | fail_wep: | 
 | 1793 | 	rate_control_deinitialize(local); | 
 | 1794 | fail_rate: | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1795 | 	ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev)); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1796 | 	unregister_netdevice(local->mdev); | 
 | 1797 | fail_dev: | 
 | 1798 | 	rtnl_unlock(); | 
 | 1799 | 	sta_info_stop(local); | 
 | 1800 | fail_sta_info: | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1801 | 	debugfs_hw_del(local); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1802 | 	destroy_workqueue(local->hw.workqueue); | 
 | 1803 | fail_workqueue: | 
 | 1804 | 	wiphy_unregister(local->hw.wiphy); | 
 | 1805 | 	return result; | 
 | 1806 | } | 
 | 1807 | EXPORT_SYMBOL(ieee80211_register_hw); | 
 | 1808 |  | 
 | 1809 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, | 
 | 1810 | 			      struct ieee80211_hw_mode *mode) | 
 | 1811 | { | 
 | 1812 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1813 | 	struct ieee80211_rate *rate; | 
 | 1814 | 	int i; | 
 | 1815 |  | 
 | 1816 | 	INIT_LIST_HEAD(&mode->list); | 
 | 1817 | 	list_add_tail(&mode->list, &local->modes_list); | 
 | 1818 |  | 
 | 1819 | 	local->hw_modes |= (1 << mode->mode); | 
 | 1820 | 	for (i = 0; i < mode->num_rates; i++) { | 
 | 1821 | 		rate = &(mode->rates[i]); | 
 | 1822 | 		rate->rate_inv = CHAN_UTIL_RATE_LCM / rate->rate; | 
 | 1823 | 	} | 
 | 1824 | 	ieee80211_prepare_rates(local, mode); | 
 | 1825 |  | 
 | 1826 | 	if (!local->oper_hw_mode) { | 
 | 1827 | 		/* Default to this mode */ | 
 | 1828 | 		local->hw.conf.phymode = mode->mode; | 
 | 1829 | 		local->oper_hw_mode = local->scan_hw_mode = mode; | 
 | 1830 | 		local->oper_channel = local->scan_channel = &mode->channels[0]; | 
 | 1831 | 		local->hw.conf.mode = local->oper_hw_mode; | 
 | 1832 | 		local->hw.conf.chan = local->oper_channel; | 
 | 1833 | 	} | 
 | 1834 |  | 
 | 1835 | 	if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) | 
| Daniel Drake | fd8bacc | 2007-06-09 19:07:14 +0100 | [diff] [blame] | 1836 | 		ieee80211_set_default_regdomain(mode); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1837 |  | 
 | 1838 | 	return 0; | 
 | 1839 | } | 
 | 1840 | EXPORT_SYMBOL(ieee80211_register_hwmode); | 
 | 1841 |  | 
 | 1842 | void ieee80211_unregister_hw(struct ieee80211_hw *hw) | 
 | 1843 | { | 
 | 1844 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1845 | 	struct ieee80211_sub_if_data *sdata, *tmp; | 
 | 1846 | 	struct list_head tmp_list; | 
 | 1847 | 	int i; | 
 | 1848 |  | 
 | 1849 | 	tasklet_kill(&local->tx_pending_tasklet); | 
 | 1850 | 	tasklet_kill(&local->tasklet); | 
 | 1851 |  | 
 | 1852 | 	rtnl_lock(); | 
 | 1853 |  | 
 | 1854 | 	BUG_ON(local->reg_state != IEEE80211_DEV_REGISTERED); | 
 | 1855 |  | 
 | 1856 | 	local->reg_state = IEEE80211_DEV_UNREGISTERED; | 
 | 1857 | 	if (local->apdev) | 
 | 1858 | 		ieee80211_if_del_mgmt(local); | 
 | 1859 |  | 
 | 1860 | 	write_lock_bh(&local->sub_if_lock); | 
 | 1861 | 	list_replace_init(&local->sub_if_list, &tmp_list); | 
 | 1862 | 	write_unlock_bh(&local->sub_if_lock); | 
 | 1863 |  | 
 | 1864 | 	list_for_each_entry_safe(sdata, tmp, &tmp_list, list) | 
 | 1865 | 		__ieee80211_if_del(local, sdata); | 
 | 1866 |  | 
 | 1867 | 	rtnl_unlock(); | 
 | 1868 |  | 
 | 1869 | 	if (local->stat_time) | 
 | 1870 | 		del_timer_sync(&local->stat_timer); | 
 | 1871 |  | 
 | 1872 | 	ieee80211_rx_bss_list_deinit(local->mdev); | 
 | 1873 | 	ieee80211_clear_tx_pending(local); | 
 | 1874 | 	sta_info_stop(local); | 
 | 1875 | 	rate_control_deinitialize(local); | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1876 | 	debugfs_hw_del(local); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1877 |  | 
 | 1878 | 	for (i = 0; i < NUM_IEEE80211_MODES; i++) { | 
 | 1879 | 		kfree(local->supp_rates[i]); | 
 | 1880 | 		kfree(local->basic_rates[i]); | 
 | 1881 | 	} | 
 | 1882 |  | 
 | 1883 | 	if (skb_queue_len(&local->skb_queue) | 
 | 1884 | 			|| skb_queue_len(&local->skb_queue_unreliable)) | 
 | 1885 | 		printk(KERN_WARNING "%s: skb_queue not empty\n", | 
 | 1886 | 		       local->mdev->name); | 
 | 1887 | 	skb_queue_purge(&local->skb_queue); | 
 | 1888 | 	skb_queue_purge(&local->skb_queue_unreliable); | 
 | 1889 |  | 
 | 1890 | 	destroy_workqueue(local->hw.workqueue); | 
 | 1891 | 	wiphy_unregister(local->hw.wiphy); | 
 | 1892 | 	ieee80211_wep_free(local); | 
 | 1893 | 	ieee80211_led_exit(local); | 
 | 1894 | } | 
 | 1895 | EXPORT_SYMBOL(ieee80211_unregister_hw); | 
 | 1896 |  | 
 | 1897 | void ieee80211_free_hw(struct ieee80211_hw *hw) | 
 | 1898 | { | 
 | 1899 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1900 |  | 
 | 1901 | 	ieee80211_if_free(local->mdev); | 
 | 1902 | 	wiphy_free(local->hw.wiphy); | 
 | 1903 | } | 
 | 1904 | EXPORT_SYMBOL(ieee80211_free_hw); | 
 | 1905 |  | 
 | 1906 | void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue) | 
 | 1907 | { | 
 | 1908 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1909 |  | 
 | 1910 | 	if (test_and_clear_bit(IEEE80211_LINK_STATE_XOFF, | 
 | 1911 | 			       &local->state[queue])) { | 
 | 1912 | 		if (test_bit(IEEE80211_LINK_STATE_PENDING, | 
 | 1913 | 			     &local->state[queue])) | 
 | 1914 | 			tasklet_schedule(&local->tx_pending_tasklet); | 
 | 1915 | 		else | 
 | 1916 | 			if (!ieee80211_qdisc_installed(local->mdev)) { | 
 | 1917 | 				if (queue == 0) | 
 | 1918 | 					netif_wake_queue(local->mdev); | 
 | 1919 | 			} else | 
 | 1920 | 				__netif_schedule(local->mdev); | 
 | 1921 | 	} | 
 | 1922 | } | 
 | 1923 | EXPORT_SYMBOL(ieee80211_wake_queue); | 
 | 1924 |  | 
 | 1925 | void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue) | 
 | 1926 | { | 
 | 1927 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1928 |  | 
 | 1929 | 	if (!ieee80211_qdisc_installed(local->mdev) && queue == 0) | 
 | 1930 | 		netif_stop_queue(local->mdev); | 
 | 1931 | 	set_bit(IEEE80211_LINK_STATE_XOFF, &local->state[queue]); | 
 | 1932 | } | 
 | 1933 | EXPORT_SYMBOL(ieee80211_stop_queue); | 
 | 1934 |  | 
 | 1935 | void ieee80211_start_queues(struct ieee80211_hw *hw) | 
 | 1936 | { | 
 | 1937 | 	struct ieee80211_local *local = hw_to_local(hw); | 
 | 1938 | 	int i; | 
 | 1939 |  | 
 | 1940 | 	for (i = 0; i < local->hw.queues; i++) | 
 | 1941 | 		clear_bit(IEEE80211_LINK_STATE_XOFF, &local->state[i]); | 
 | 1942 | 	if (!ieee80211_qdisc_installed(local->mdev)) | 
 | 1943 | 		netif_start_queue(local->mdev); | 
 | 1944 | } | 
 | 1945 | EXPORT_SYMBOL(ieee80211_start_queues); | 
 | 1946 |  | 
 | 1947 | void ieee80211_stop_queues(struct ieee80211_hw *hw) | 
 | 1948 | { | 
 | 1949 | 	int i; | 
 | 1950 |  | 
 | 1951 | 	for (i = 0; i < hw->queues; i++) | 
 | 1952 | 		ieee80211_stop_queue(hw, i); | 
 | 1953 | } | 
 | 1954 | EXPORT_SYMBOL(ieee80211_stop_queues); | 
 | 1955 |  | 
 | 1956 | void ieee80211_wake_queues(struct ieee80211_hw *hw) | 
 | 1957 | { | 
 | 1958 | 	int i; | 
 | 1959 |  | 
 | 1960 | 	for (i = 0; i < hw->queues; i++) | 
 | 1961 | 		ieee80211_wake_queue(hw, i); | 
 | 1962 | } | 
 | 1963 | EXPORT_SYMBOL(ieee80211_wake_queues); | 
 | 1964 |  | 
 | 1965 | struct net_device_stats *ieee80211_dev_stats(struct net_device *dev) | 
 | 1966 | { | 
 | 1967 | 	struct ieee80211_sub_if_data *sdata; | 
 | 1968 | 	sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 
 | 1969 | 	return &sdata->stats; | 
 | 1970 | } | 
 | 1971 |  | 
 | 1972 | static int __init ieee80211_init(void) | 
 | 1973 | { | 
 | 1974 | 	struct sk_buff *skb; | 
 | 1975 | 	int ret; | 
 | 1976 |  | 
 | 1977 | 	BUILD_BUG_ON(sizeof(struct ieee80211_tx_packet_data) > sizeof(skb->cb)); | 
 | 1978 |  | 
 | 1979 | 	ret = ieee80211_wme_register(); | 
 | 1980 | 	if (ret) { | 
 | 1981 | 		printk(KERN_DEBUG "ieee80211_init: failed to " | 
 | 1982 | 		       "initialize WME (err=%d)\n", ret); | 
 | 1983 | 		return ret; | 
 | 1984 | 	} | 
 | 1985 |  | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1986 | 	ieee80211_debugfs_netdev_init(); | 
| Daniel Drake | fd8bacc | 2007-06-09 19:07:14 +0100 | [diff] [blame] | 1987 | 	ieee80211_regdomain_init(); | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1988 |  | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1989 | 	return 0; | 
 | 1990 | } | 
 | 1991 |  | 
 | 1992 |  | 
 | 1993 | static void __exit ieee80211_exit(void) | 
 | 1994 | { | 
 | 1995 | 	ieee80211_wme_unregister(); | 
| Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 1996 | 	ieee80211_debugfs_netdev_exit(); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1997 | } | 
 | 1998 |  | 
 | 1999 |  | 
| Johannes Berg | ca9938f | 2007-09-11 12:50:32 +0200 | [diff] [blame] | 2000 | subsys_initcall(ieee80211_init); | 
| Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 2001 | module_exit(ieee80211_exit); | 
 | 2002 |  | 
 | 2003 | MODULE_DESCRIPTION("IEEE 802.11 subsystem"); | 
 | 2004 | MODULE_LICENSE("GPL"); |