diff options
author | Ivo van Doorn <IvDoorn@gmail.com> | 2007-10-06 07:34:52 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:55:15 -0400 |
commit | 5c58ee51ff8c0aca74c225e0263bc5dd2b917781 (patch) | |
tree | a08e875dade8a6f55d45419b728b2b077cec6dc0 /drivers/net/wireless/rt2x00/rt2500pci.c | |
parent | 4f5af6eb3d17f8e343597ea99d97eb2f2905b2fb (diff) |
[PATCH] rt2x00: Reorganize configuration handler
Reorganize configuration handling by creating a extra
structure which contains precalculated values based
on the mac80211 values which are usefull for all
individual drivers.
This also fixes the preamble configuration problem,
up untill now preamble was never configured since
by default the rate->val value was used when changing
the mode.
Now rate->val will only be used to set the basic rate mask.
The preamble configuration will now be done correctly
through the erp_ie_changed callback function.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 147 |
1 files changed, 59 insertions, 88 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index c8c6a848be97..ff2d63267b19 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -295,100 +295,72 @@ static void rt2500pci_config_type(struct rt2x00_dev *rt2x00dev, const int type, | |||
295 | rt2x00pci_register_write(rt2x00dev, CSR14, reg); | 295 | rt2x00pci_register_write(rt2x00dev, CSR14, reg); |
296 | } | 296 | } |
297 | 297 | ||
298 | static void rt2500pci_config_rate(struct rt2x00_dev *rt2x00dev, const int rate) | 298 | static void rt2500pci_config_preamble(struct rt2x00_dev *rt2x00dev, |
299 | const int short_preamble, | ||
300 | const int ack_timeout, | ||
301 | const int ack_consume_time) | ||
299 | { | 302 | { |
300 | struct ieee80211_conf *conf = &rt2x00dev->hw->conf; | 303 | int preamble_mask; |
301 | u32 reg; | 304 | u32 reg; |
302 | u32 preamble; | ||
303 | u16 value; | ||
304 | |||
305 | if (DEVICE_GET_RATE_FIELD(rate, PREAMBLE)) | ||
306 | preamble = SHORT_PREAMBLE; | ||
307 | else | ||
308 | preamble = PREAMBLE; | ||
309 | 305 | ||
310 | reg = DEVICE_GET_RATE_FIELD(rate, RATEMASK) & DEV_BASIC_RATEMASK; | 306 | /* |
311 | rt2x00pci_register_write(rt2x00dev, ARCSR1, reg); | 307 | * When short preamble is enabled, we should set bit 0x08 |
308 | */ | ||
309 | preamble_mask = short_preamble << 3; | ||
312 | 310 | ||
313 | rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); | 311 | rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); |
314 | value = ((conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME) ? | 312 | rt2x00_set_field32(®, TXCSR1_ACK_TIMEOUT, ack_timeout); |
315 | SHORT_DIFS : DIFS) + | 313 | rt2x00_set_field32(®, TXCSR1_ACK_CONSUME_TIME, ack_consume_time); |
316 | PLCP + preamble + get_duration(ACK_SIZE, 10); | ||
317 | rt2x00_set_field32(®, TXCSR1_ACK_TIMEOUT, value); | ||
318 | value = SIFS + PLCP + preamble + get_duration(ACK_SIZE, 10); | ||
319 | rt2x00_set_field32(®, TXCSR1_ACK_CONSUME_TIME, value); | ||
320 | rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); | 314 | rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); |
321 | 315 | ||
322 | preamble = DEVICE_GET_RATE_FIELD(rate, PREAMBLE) ? 0x08 : 0x00; | ||
323 | |||
324 | rt2x00pci_register_read(rt2x00dev, ARCSR2, ®); | 316 | rt2x00pci_register_read(rt2x00dev, ARCSR2, ®); |
325 | rt2x00_set_field32(®, ARCSR2_SIGNAL, 0x00 | preamble); | 317 | rt2x00_set_field32(®, ARCSR2_SIGNAL, 0x00 | preamble_mask); |
326 | rt2x00_set_field32(®, ARCSR2_SERVICE, 0x04); | 318 | rt2x00_set_field32(®, ARCSR2_SERVICE, 0x04); |
327 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10)); | 319 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 10)); |
328 | rt2x00pci_register_write(rt2x00dev, ARCSR2, reg); | 320 | rt2x00pci_register_write(rt2x00dev, ARCSR2, reg); |
329 | 321 | ||
330 | rt2x00pci_register_read(rt2x00dev, ARCSR3, ®); | 322 | rt2x00pci_register_read(rt2x00dev, ARCSR3, ®); |
331 | rt2x00_set_field32(®, ARCSR3_SIGNAL, 0x01 | preamble); | 323 | rt2x00_set_field32(®, ARCSR3_SIGNAL, 0x01 | preamble_mask); |
332 | rt2x00_set_field32(®, ARCSR3_SERVICE, 0x04); | 324 | rt2x00_set_field32(®, ARCSR3_SERVICE, 0x04); |
333 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 20)); | 325 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 20)); |
334 | rt2x00pci_register_write(rt2x00dev, ARCSR3, reg); | 326 | rt2x00pci_register_write(rt2x00dev, ARCSR3, reg); |
335 | 327 | ||
336 | rt2x00pci_register_read(rt2x00dev, ARCSR4, ®); | 328 | rt2x00pci_register_read(rt2x00dev, ARCSR4, ®); |
337 | rt2x00_set_field32(®, ARCSR4_SIGNAL, 0x02 | preamble); | 329 | rt2x00_set_field32(®, ARCSR4_SIGNAL, 0x02 | preamble_mask); |
338 | rt2x00_set_field32(®, ARCSR4_SERVICE, 0x04); | 330 | rt2x00_set_field32(®, ARCSR4_SERVICE, 0x04); |
339 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 55)); | 331 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 55)); |
340 | rt2x00pci_register_write(rt2x00dev, ARCSR4, reg); | 332 | rt2x00pci_register_write(rt2x00dev, ARCSR4, reg); |
341 | 333 | ||
342 | rt2x00pci_register_read(rt2x00dev, ARCSR5, ®); | 334 | rt2x00pci_register_read(rt2x00dev, ARCSR5, ®); |
343 | rt2x00_set_field32(®, ARCSR5_SIGNAL, 0x03 | preamble); | 335 | rt2x00_set_field32(®, ARCSR5_SIGNAL, 0x03 | preamble_mask); |
344 | rt2x00_set_field32(®, ARCSR5_SERVICE, 0x84); | 336 | rt2x00_set_field32(®, ARCSR5_SERVICE, 0x84); |
345 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); | 337 | rt2x00_set_field32(®, ARCSR2_LENGTH, get_duration(ACK_SIZE, 110)); |
346 | rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); | 338 | rt2x00pci_register_write(rt2x00dev, ARCSR5, reg); |
347 | } | 339 | } |
348 | 340 | ||
349 | static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev, | 341 | static void rt2500pci_config_phymode(struct rt2x00_dev *rt2x00dev, |
350 | const int phymode) | 342 | const int basic_rate_mask) |
351 | { | 343 | { |
352 | struct ieee80211_hw_mode *mode; | 344 | rt2x00pci_register_write(rt2x00dev, ARCSR1, basic_rate_mask); |
353 | struct ieee80211_rate *rate; | ||
354 | |||
355 | if (phymode == MODE_IEEE80211A) | ||
356 | rt2x00dev->curr_hwmode = HWMODE_A; | ||
357 | else if (phymode == MODE_IEEE80211B) | ||
358 | rt2x00dev->curr_hwmode = HWMODE_B; | ||
359 | else | ||
360 | rt2x00dev->curr_hwmode = HWMODE_G; | ||
361 | |||
362 | mode = &rt2x00dev->hwmodes[rt2x00dev->curr_hwmode]; | ||
363 | rate = &mode->rates[mode->num_rates - 1]; | ||
364 | |||
365 | rt2500pci_config_rate(rt2x00dev, rate->val2); | ||
366 | } | 345 | } |
367 | 346 | ||
368 | static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, | 347 | static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, |
369 | const int index, const int channel, | 348 | struct rf_channel *rf, const int txpower) |
370 | const int txpower) | ||
371 | { | 349 | { |
372 | struct rf_channel reg; | ||
373 | u8 r70; | 350 | u8 r70; |
374 | 351 | ||
375 | /* | 352 | /* |
376 | * Fill rf_reg structure. | ||
377 | */ | ||
378 | memcpy(®, &rt2x00dev->spec.channels[index], sizeof(reg)); | ||
379 | |||
380 | /* | ||
381 | * Set TXpower. | 353 | * Set TXpower. |
382 | */ | 354 | */ |
383 | rt2x00_set_field32(®.rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower)); | 355 | rt2x00_set_field32(&rf->rf3, RF3_TXPOWER, TXPOWER_TO_DEV(txpower)); |
384 | 356 | ||
385 | /* | 357 | /* |
386 | * Switch on tuning bits. | 358 | * Switch on tuning bits. |
387 | * For RT2523 devices we do not need to update the R1 register. | 359 | * For RT2523 devices we do not need to update the R1 register. |
388 | */ | 360 | */ |
389 | if (!rt2x00_rf(&rt2x00dev->chip, RF2523)) | 361 | if (!rt2x00_rf(&rt2x00dev->chip, RF2523)) |
390 | rt2x00_set_field32(®.rf1, RF1_TUNER, 1); | 362 | rt2x00_set_field32(&rf->rf1, RF1_TUNER, 1); |
391 | rt2x00_set_field32(®.rf3, RF3_TUNER, 1); | 363 | rt2x00_set_field32(&rf->rf3, RF3_TUNER, 1); |
392 | 364 | ||
393 | /* | 365 | /* |
394 | * For RT2525 we should first set the channel to half band higher. | 366 | * For RT2525 we should first set the channel to half band higher. |
@@ -401,24 +373,24 @@ static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, | |||
401 | 0x00080d2e, 0x00080d3a | 373 | 0x00080d2e, 0x00080d3a |
402 | }; | 374 | }; |
403 | 375 | ||
404 | rt2500pci_rf_write(rt2x00dev, 1, reg.rf1); | 376 | rt2500pci_rf_write(rt2x00dev, 1, rf->rf1); |
405 | rt2500pci_rf_write(rt2x00dev, 2, vals[channel - 1]); | 377 | rt2500pci_rf_write(rt2x00dev, 2, vals[rf->channel - 1]); |
406 | rt2500pci_rf_write(rt2x00dev, 3, reg.rf3); | 378 | rt2500pci_rf_write(rt2x00dev, 3, rf->rf3); |
407 | if (reg.rf4) | 379 | if (rf->rf4) |
408 | rt2500pci_rf_write(rt2x00dev, 4, reg.rf4); | 380 | rt2500pci_rf_write(rt2x00dev, 4, rf->rf4); |
409 | } | 381 | } |
410 | 382 | ||
411 | rt2500pci_rf_write(rt2x00dev, 1, reg.rf1); | 383 | rt2500pci_rf_write(rt2x00dev, 1, rf->rf1); |
412 | rt2500pci_rf_write(rt2x00dev, 2, reg.rf2); | 384 | rt2500pci_rf_write(rt2x00dev, 2, rf->rf2); |
413 | rt2500pci_rf_write(rt2x00dev, 3, reg.rf3); | 385 | rt2500pci_rf_write(rt2x00dev, 3, rf->rf3); |
414 | if (reg.rf4) | 386 | if (rf->rf4) |
415 | rt2500pci_rf_write(rt2x00dev, 4, reg.rf4); | 387 | rt2500pci_rf_write(rt2x00dev, 4, rf->rf4); |
416 | 388 | ||
417 | /* | 389 | /* |
418 | * Channel 14 requires the Japan filter bit to be set. | 390 | * Channel 14 requires the Japan filter bit to be set. |
419 | */ | 391 | */ |
420 | r70 = 0x46; | 392 | r70 = 0x46; |
421 | rt2x00_set_field8(&r70, BBP_R70_JAPAN_FILTER, channel == 14); | 393 | rt2x00_set_field8(&r70, BBP_R70_JAPAN_FILTER, rf->channel == 14); |
422 | rt2500pci_bbp_write(rt2x00dev, 70, r70); | 394 | rt2500pci_bbp_write(rt2x00dev, 70, r70); |
423 | 395 | ||
424 | msleep(1); | 396 | msleep(1); |
@@ -428,17 +400,17 @@ static void rt2500pci_config_channel(struct rt2x00_dev *rt2x00dev, | |||
428 | * For RT2523 devices we do not need to update the R1 register. | 400 | * For RT2523 devices we do not need to update the R1 register. |
429 | */ | 401 | */ |
430 | if (!rt2x00_rf(&rt2x00dev->chip, RF2523)) { | 402 | if (!rt2x00_rf(&rt2x00dev->chip, RF2523)) { |
431 | rt2x00_set_field32(®.rf1, RF1_TUNER, 0); | 403 | rt2x00_set_field32(&rf->rf1, RF1_TUNER, 0); |
432 | rt2500pci_rf_write(rt2x00dev, 1, reg.rf1); | 404 | rt2500pci_rf_write(rt2x00dev, 1, rf->rf1); |
433 | } | 405 | } |
434 | 406 | ||
435 | rt2x00_set_field32(®.rf3, RF3_TUNER, 0); | 407 | rt2x00_set_field32(&rf->rf3, RF3_TUNER, 0); |
436 | rt2500pci_rf_write(rt2x00dev, 3, reg.rf3); | 408 | rt2500pci_rf_write(rt2x00dev, 3, rf->rf3); |
437 | 409 | ||
438 | /* | 410 | /* |
439 | * Clear false CRC during channel switch. | 411 | * Clear false CRC during channel switch. |
440 | */ | 412 | */ |
441 | rt2x00pci_register_read(rt2x00dev, CNT0, ®.rf1); | 413 | rt2x00pci_register_read(rt2x00dev, CNT0, &rf->rf1); |
442 | } | 414 | } |
443 | 415 | ||
444 | static void rt2500pci_config_txpower(struct rt2x00_dev *rt2x00dev, | 416 | static void rt2500pci_config_txpower(struct rt2x00_dev *rt2x00dev, |
@@ -525,26 +497,22 @@ static void rt2500pci_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
525 | } | 497 | } |
526 | 498 | ||
527 | static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, | 499 | static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, |
528 | const int short_slot_time, | 500 | struct rt2x00lib_conf *libconf) |
529 | const int beacon_int) | ||
530 | { | 501 | { |
531 | u32 reg; | 502 | u32 reg; |
532 | 503 | ||
533 | rt2x00pci_register_read(rt2x00dev, CSR11, ®); | 504 | rt2x00pci_register_read(rt2x00dev, CSR11, ®); |
534 | rt2x00_set_field32(®, CSR11_SLOT_TIME, | 505 | rt2x00_set_field32(®, CSR11_SLOT_TIME, libconf->slot_time); |
535 | short_slot_time ? SHORT_SLOT_TIME : SLOT_TIME); | ||
536 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); | 506 | rt2x00pci_register_write(rt2x00dev, CSR11, reg); |
537 | 507 | ||
538 | rt2x00pci_register_read(rt2x00dev, CSR18, ®); | 508 | rt2x00pci_register_read(rt2x00dev, CSR18, ®); |
539 | rt2x00_set_field32(®, CSR18_SIFS, SIFS); | 509 | rt2x00_set_field32(®, CSR18_SIFS, libconf->sifs); |
540 | rt2x00_set_field32(®, CSR18_PIFS, | 510 | rt2x00_set_field32(®, CSR18_PIFS, libconf->pifs); |
541 | short_slot_time ? SHORT_PIFS : PIFS); | ||
542 | rt2x00pci_register_write(rt2x00dev, CSR18, reg); | 511 | rt2x00pci_register_write(rt2x00dev, CSR18, reg); |
543 | 512 | ||
544 | rt2x00pci_register_read(rt2x00dev, CSR19, ®); | 513 | rt2x00pci_register_read(rt2x00dev, CSR19, ®); |
545 | rt2x00_set_field32(®, CSR19_DIFS, | 514 | rt2x00_set_field32(®, CSR19_DIFS, libconf->difs); |
546 | short_slot_time ? SHORT_DIFS : DIFS); | 515 | rt2x00_set_field32(®, CSR19_EIFS, libconf->eifs); |
547 | rt2x00_set_field32(®, CSR19_EIFS, EIFS); | ||
548 | rt2x00pci_register_write(rt2x00dev, CSR19, reg); | 516 | rt2x00pci_register_write(rt2x00dev, CSR19, reg); |
549 | 517 | ||
550 | rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); | 518 | rt2x00pci_register_read(rt2x00dev, TXCSR1, ®); |
@@ -553,30 +521,31 @@ static void rt2500pci_config_duration(struct rt2x00_dev *rt2x00dev, | |||
553 | rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); | 521 | rt2x00pci_register_write(rt2x00dev, TXCSR1, reg); |
554 | 522 | ||
555 | rt2x00pci_register_read(rt2x00dev, CSR12, ®); | 523 | rt2x00pci_register_read(rt2x00dev, CSR12, ®); |
556 | rt2x00_set_field32(®, CSR12_BEACON_INTERVAL, beacon_int * 16); | 524 | rt2x00_set_field32(®, CSR12_BEACON_INTERVAL, |
557 | rt2x00_set_field32(®, CSR12_CFP_MAX_DURATION, beacon_int * 16); | 525 | libconf->conf->beacon_int * 16); |
526 | rt2x00_set_field32(®, CSR12_CFP_MAX_DURATION, | ||
527 | libconf->conf->beacon_int * 16); | ||
558 | rt2x00pci_register_write(rt2x00dev, CSR12, reg); | 528 | rt2x00pci_register_write(rt2x00dev, CSR12, reg); |
559 | } | 529 | } |
560 | 530 | ||
561 | static void rt2500pci_config(struct rt2x00_dev *rt2x00dev, | 531 | static void rt2500pci_config(struct rt2x00_dev *rt2x00dev, |
562 | const unsigned int flags, | 532 | const unsigned int flags, |
563 | struct ieee80211_conf *conf) | 533 | struct rt2x00lib_conf *libconf) |
564 | { | 534 | { |
565 | int short_slot_time = conf->flags & IEEE80211_CONF_SHORT_SLOT_TIME; | ||
566 | |||
567 | if (flags & CONFIG_UPDATE_PHYMODE) | 535 | if (flags & CONFIG_UPDATE_PHYMODE) |
568 | rt2500pci_config_phymode(rt2x00dev, conf->phymode); | 536 | rt2500pci_config_phymode(rt2x00dev, libconf->basic_rates); |
569 | if (flags & CONFIG_UPDATE_CHANNEL) | 537 | if (flags & CONFIG_UPDATE_CHANNEL) |
570 | rt2500pci_config_channel(rt2x00dev, conf->channel_val, | 538 | rt2500pci_config_channel(rt2x00dev, &libconf->rf, |
571 | conf->channel, conf->power_level); | 539 | libconf->conf->power_level); |
572 | if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) | 540 | if ((flags & CONFIG_UPDATE_TXPOWER) && !(flags & CONFIG_UPDATE_CHANNEL)) |
573 | rt2500pci_config_txpower(rt2x00dev, conf->power_level); | 541 | rt2500pci_config_txpower(rt2x00dev, |
542 | libconf->conf->power_level); | ||
574 | if (flags & CONFIG_UPDATE_ANTENNA) | 543 | if (flags & CONFIG_UPDATE_ANTENNA) |
575 | rt2500pci_config_antenna(rt2x00dev, conf->antenna_sel_tx, | 544 | rt2500pci_config_antenna(rt2x00dev, |
576 | conf->antenna_sel_rx); | 545 | libconf->conf->antenna_sel_tx, |
546 | libconf->conf->antenna_sel_rx); | ||
577 | if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) | 547 | if (flags & (CONFIG_UPDATE_SLOT_TIME | CONFIG_UPDATE_BEACON_INT)) |
578 | rt2500pci_config_duration(rt2x00dev, short_slot_time, | 548 | rt2500pci_config_duration(rt2x00dev, libconf); |
579 | conf->beacon_int); | ||
580 | } | 549 | } |
581 | 550 | ||
582 | /* | 551 | /* |
@@ -1921,6 +1890,7 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = { | |||
1921 | .configure_filter = rt2500pci_configure_filter, | 1890 | .configure_filter = rt2500pci_configure_filter, |
1922 | .get_stats = rt2x00mac_get_stats, | 1891 | .get_stats = rt2x00mac_get_stats, |
1923 | .set_retry_limit = rt2500pci_set_retry_limit, | 1892 | .set_retry_limit = rt2500pci_set_retry_limit, |
1893 | .erp_ie_changed = rt2x00mac_erp_ie_changed, | ||
1924 | .conf_tx = rt2x00mac_conf_tx, | 1894 | .conf_tx = rt2x00mac_conf_tx, |
1925 | .get_tx_stats = rt2x00mac_get_tx_stats, | 1895 | .get_tx_stats = rt2x00mac_get_tx_stats, |
1926 | .get_tsf = rt2500pci_get_tsf, | 1896 | .get_tsf = rt2500pci_get_tsf, |
@@ -1946,6 +1916,7 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { | |||
1946 | .config_mac_addr = rt2500pci_config_mac_addr, | 1916 | .config_mac_addr = rt2500pci_config_mac_addr, |
1947 | .config_bssid = rt2500pci_config_bssid, | 1917 | .config_bssid = rt2500pci_config_bssid, |
1948 | .config_type = rt2500pci_config_type, | 1918 | .config_type = rt2500pci_config_type, |
1919 | .config_preamble = rt2500pci_config_preamble, | ||
1949 | .config = rt2500pci_config, | 1920 | .config = rt2500pci_config, |
1950 | }; | 1921 | }; |
1951 | 1922 | ||