diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt73usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 103 |
1 files changed, 35 insertions, 68 deletions
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index 9e1bf4d77e10..984117fe1f5e 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -308,57 +308,40 @@ static void rt73usb_config_type(struct rt2x00_dev *rt2x00dev, const int type, | |||
308 | rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg); | 308 | rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg); |
309 | } | 309 | } |
310 | 310 | ||
311 | static void rt73usb_config_rate(struct rt2x00_dev *rt2x00dev, const int rate) | 311 | static void rt73usb_config_preamble(struct rt2x00_dev *rt2x00dev, |
312 | const int short_preamble, | ||
313 | const int ack_timeout, | ||
314 | const int ack_consume_time) | ||
312 | { | 315 | { |
313 | struct ieee80211_conf *conf = &rt2x00dev->hw->conf; | ||
314 | u32 reg; | 316 | u32 reg; |
315 | u32 value; | ||
316 | u32 preamble; | ||
317 | 317 | ||
318 | if (DEVICE_GET_RATE_FIELD(rate, PREAMBLE)) | 318 | /* |
319 | preamble = SHORT_PREAMBLE; | 319 | * When in atomic context, reschedule and let rt2x00lib |
320 | else | 320 | * call this function again. |
321 | preamble = PREAMBLE; | 321 | */ |
322 | 322 | if (in_atomic()) { | |
323 | reg = DEVICE_GET_RATE_FIELD(rate, RATEMASK) & DEV_BASIC_RATEMASK; | 323 | queue_work(rt2x00dev->hw->workqueue, &rt2x00dev->config_work); |
324 | 324 | return; | |
325 | rt73usb_register_write(rt2x00dev, TXRX_CSR5, reg); | 325 | } |
326 | 326 | ||
327 | rt73usb_register_read(rt2x00dev, TXRX_CSR0, ®); | 327 | rt73usb_register_read(rt2x00dev, TXRX_CSR0, ®); |
328 | value = ((conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) ? | 328 | rt2x00_set_field32(®, TXRX_CSR0_RX_ACK_TIMEOUT, ack_timeout); |
329 | SHORT_DIFS : DIFS) + | ||
330 | PLCP + preamble + get_duration(ACK_SIZE, 10); | ||
331 | rt2x00_set_field32(®, TXRX_CSR0_RX_ACK_TIMEOUT, value); | ||
332 | rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg); | 329 | rt73usb_register_write(rt2x00dev, TXRX_CSR0, reg); |
333 | 330 | ||
334 | rt73usb_register_read(rt2x00dev, TXRX_CSR4, ®); | 331 | rt73usb_register_read(rt2x00dev, TXRX_CSR4, ®); |
335 | rt2x00_set_field32(®, TXRX_CSR4_AUTORESPOND_PREAMBLE, | 332 | rt2x00_set_field32(®, TXRX_CSR4_AUTORESPOND_PREAMBLE, |
336 | (preamble == SHORT_PREAMBLE)); | 333 | !!short_preamble); |
337 | rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); | 334 | rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); |
338 | } | 335 | } |
339 | 336 | ||
340 | static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev, | 337 | static void rt73usb_config_phymode(struct rt2x00_dev *rt2x00dev, |
341 | const int phymode) | 338 | const int basic_rate_mask) |
342 | { | 339 | { |
343 | struct ieee80211_hw_mode *mode; | 340 | rt73usb_register_write(rt2x00dev, TXRX_CSR5, basic_rate_mask); |
344 | struct ieee80211_rate *rate; | ||
345 | |||
346 | if (phymode == MODE_IEEE80211A) | ||
347 | rt2x00dev->curr_hwmode = HWMODE_A; | ||
348 | else if (phymode == MODE_IEEE80211B) | ||
349 | rt2x00dev->curr_hwmode = HWMODE_B; | ||
350 | else | ||
351 | rt2x00dev->curr_hwmode = HWMODE_G; | ||
352 | |||
353 | mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode]; | ||
354 | rate = &mode->rates[mode->num_rates - 1]; | ||
355 | |||
356 | rt73usb_config_rate(rt2x00dev, rate->val2); | ||
357 | } | 341 | } |
358 | 342 | ||
359 | static void rt73usb_config_lock_channel(struct rt2x00_dev *rt2x00dev, | 343 | static void rt73usb_config_channel(struct rt2x00_dev *rt2x00dev, |
360 | struct rf_channel *rf, | 344 | struct rf_channel *rf, const int txpower) |
361 | const int txpower) | ||
362 | { | 345 | { |
363 | u8 r3; | 346 | u8 r3; |
364 | u8 r94; | 347 | u8 r94; |
@@ -399,20 +382,6 @@ static void rt73usb_config_lock_channel(struct rt2x00_dev *rt2x00dev, | |||
399 | udelay(10); | 382 | udelay(10); |
400 | } | 383 | } |
401 | 384 | ||
402 | static void rt73usb_config_channel(struct rt2x00_dev *rt2x00dev, | ||
403 | const int index, const int channel, | ||
404 | const int txpower) | ||
405 | { | ||
406 | struct rf_channel rf; | ||
407 | |||
408 | /* | ||
409 | * Fill rf_reg structure. | ||
410 | */ | ||
411 | memcpy(&rf, &rt2x00dev->spec.channels[index], sizeof(rf)); | ||
412 | |||
413 | rt73usb_config_lock_channel(rt2x00dev, &rf, txpower); | ||
414 | } | ||
415 | |||
416 | static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev, | 385 | static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev, |
417 | const int txpower) | 386 | const int txpower) |
418 | { | 387 | { |
@@ -423,7 +392,7 @@ static void rt73usb_config_txpower(struct rt2x00_dev *rt2x00dev, | |||
423 | rt2x00_rf_read(rt2x00dev, 3, &rf.rf3); | 392 | rt2x00_rf_read(rt2x00dev, 3, &rf.rf3); |
424 | rt2x00_rf_read(rt2x00dev, 4, &rf.rf4); | 393 | rt2x00_rf_read(rt2x00dev, 4, &rf.rf4); |
425 | 394 | ||
426 | rt73usb_config_lock_channel(rt2x00dev, &rf, txpower); | 395 | rt73usb_config_channel(rt2x00dev, &rf, txpower); |
427 | } | 396 | } |
428 | 397 | ||
429 | static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, | 398 | static void rt73usb_config_antenna_5x(struct rt2x00_dev *rt2x00dev, |
@@ -577,20 +546,18 @@ static void rt73usb_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
577 | } | 546 | } |
578 | 547 | ||
579 | static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev, | 548 | static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev, |
580 | const int short_slot_time, | 549 | struct rt2x00lib_conf *libconf) |
581 | const int beacon_int) | ||
582 | { | 550 | { |
583 | u32 reg; | 551 | u32 reg; |
584 | 552 | ||
585 | rt73usb_register_read(rt2x00dev, MAC_CSR9, ®); | 553 | rt73usb_register_read(rt2x00dev, MAC_CSR9, ®); |
586 | rt2x00_set_field32(®, MAC_CSR9_SLOT_TIME, | 554 | rt2x00_set_field32(®, MAC_CSR9_SLOT_TIME, libconf->slot_time); |
587 | short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME); | ||
588 | rt73usb_register_write(rt2x00dev, MAC_CSR9, reg); | 555 | rt73usb_register_write(rt2x00dev, MAC_CSR9, reg); |
589 | 556 | ||
590 | rt73usb_register_read(rt2x00dev, MAC_CSR8, ®); | 557 | rt73usb_register_read(rt2x00dev, MAC_CSR8, ®); |
591 | rt2x00_set_field32(®, MAC_CSR8_SIFS, SIFS); | 558 | rt2x00_set_field32(®, MAC_CSR8_SIFS, libconf->sifs); |
592 | rt2x00_set_field32(®, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3); | 559 | rt2x00_set_field32(®, MAC_CSR8_SIFS_AFTER_RX_OFDM, 3); |
593 | rt2x00_set_field32(®, MAC_CSR8_EIFS, EIFS); | 560 | rt2x00_set_field32(®, MAC_CSR8_EIFS, libconf->eifs); |
594 | rt73usb_register_write(rt2x00dev, MAC_CSR8, reg); | 561 | rt73usb_register_write(rt2x00dev, MAC_CSR8, reg); |
595 | 562 | ||
596 | rt73usb_register_read(rt2x00dev, TXRX_CSR0, ®); | 563 | rt73usb_register_read(rt2x00dev, TXRX_CSR0, ®); |
@@ -602,29 +569,27 @@ static void rt73usb_config_duration(struct rt2x00_dev *rt2x00dev, | |||
602 | rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); | 569 | rt73usb_register_write(rt2x00dev, TXRX_CSR4, reg); |
603 | 570 | ||
604 | rt73usb_register_read(rt2x00dev, TXRX_CSR9, ®); | 571 | rt73usb_register_read(rt2x00dev, TXRX_CSR9, ®); |
605 | rt2x00_set_field32(®, TXRX_CSR9_BEACON_INTERVAL, beacon_int * 16); | 572 | rt2x00_set_field32(®, TXRX_CSR9_BEACON_INTERVAL, |
573 | libconf->conf->beacon_int * 16); | ||
606 | rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg); | 574 | rt73usb_register_write(rt2x00dev, TXRX_CSR9, reg); |
607 | } | 575 | } |
608 | 576 | ||
609 | static void rt73usb_config(struct rt2x00_dev *rt2x00dev, | 577 | static void rt73usb_config(struct rt2x00_dev *rt2x00dev, |
610 | const unsigned int flags, | 578 | const unsigned int flags, |
611 | struct ieee80211_conf *conf) | 579 | struct rt2x00lib_conf *libconf) |
612 | { | 580 | { |
613 | int short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME; | ||
614 | |||
615 | if (flags & CONFIG_UPDATE_PHYMODE) | 581 | if (flags & CONFIG_UPDATE_PHYMODE) |
616 | rt73usb_config_phymode(rt2x00dev, conf->phymode); | 582 | rt73usb_config_phymode(rt2x00dev, libconf->basic_rates); |
617 | if (flags & CONFIG_UPDATE_CHANNEL) | 583 | if (flags & CONFIG_UPDATE_CHANNEL) |
618 | rt73usb_config_channel(rt2x00dev, conf->channel_val, | 584 | rt73usb_config_channel(rt2x00dev, &libconf->rf, |
619 | conf->channel, conf->power_level); | 585 | libconf->conf->power_level); |
620 | if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) | 586 | if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) |
621 | rt73usb_config_txpower(rt2x00dev, conf->power_level); | 587 | rt73usb_config_txpower(rt2x00dev, libconf->conf->power_level); |
622 | if (flags & CONFIG_UPDATE_ANTENNA) | 588 | if (flags & CONFIG_UPDATE_ANTENNA) |
623 | rt73usb_config_antenna(rt2x00dev, conf->antenna_sel_tx, | 589 | rt73usb_config_antenna(rt2x00dev, libconf->conf->antenna_sel_tx, |
624 | conf->antenna_sel_rx); | 590 | libconf->conf->antenna_sel_rx); |
625 | if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) | 591 | if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) |
626 | rt73usb_config_duration(rt2x00dev, short_slot_time, | 592 | rt73usb_config_duration(rt2x00dev, libconf); |
627 | conf->beacon_int); | ||
628 | } | 593 | } |
629 | 594 | ||
630 | /* | 595 | /* |
@@ -2002,6 +1967,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = { | |||
2002 | .configure_filter = rt73usb_configure_filter, | 1967 | .configure_filter = rt73usb_configure_filter, |
2003 | .get_stats = rt2x00mac_get_stats, | 1968 | .get_stats = rt2x00mac_get_stats, |
2004 | .set_retry_limit = rt73usb_set_retry_limit, | 1969 | .set_retry_limit = rt73usb_set_retry_limit, |
1970 | .erp_ie_changed = rt2x00mac_erp_ie_changed, | ||
2005 | .conf_tx = rt2x00mac_conf_tx, | 1971 | .conf_tx = rt2x00mac_conf_tx, |
2006 | .get_tx_stats = rt2x00mac_get_tx_stats, | 1972 | .get_tx_stats = rt2x00mac_get_tx_stats, |
2007 | #if 0 | 1973 | #if 0 |
@@ -2032,6 +1998,7 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { | |||
2032 | .config_mac_addr = rt73usb_config_mac_addr, | 1998 | .config_mac_addr = rt73usb_config_mac_addr, |
2033 | .config_bssid = rt73usb_config_bssid, | 1999 | .config_bssid = rt73usb_config_bssid, |
2034 | .config_type = rt73usb_config_type, | 2000 | .config_type = rt73usb_config_type, |
2001 | .config_preamble = rt73usb_config_preamble, | ||
2035 | .config = rt73usb_config, | 2002 | .config = rt73usb_config, |
2036 | }; | 2003 | }; |
2037 | 2004 | ||