diff options
Diffstat (limited to 'drivers/net/wireless/mwifiex/sta_ioctl.c')
-rw-r--r-- | drivers/net/wireless/mwifiex/sta_ioctl.c | 124 |
1 files changed, 7 insertions, 117 deletions
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 6dff01650242..fb2136089a22 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c | |||
@@ -497,134 +497,24 @@ int mwifiex_disable_auto_ds(struct mwifiex_private *priv) | |||
497 | EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); | 497 | EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds); |
498 | 498 | ||
499 | /* | 499 | /* |
500 | * IOCTL request handler to get rate. | ||
501 | * | ||
502 | * This function prepares the correct firmware command and | ||
503 | * issues it to get the current rate if it is connected, | ||
504 | * otherwise, the function returns the lowest supported rate | ||
505 | * for the band. | ||
506 | */ | ||
507 | static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv, | ||
508 | struct mwifiex_rate_cfg *rate_cfg) | ||
509 | { | ||
510 | rate_cfg->is_rate_auto = priv->is_data_rate_auto; | ||
511 | return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, | ||
512 | HostCmd_ACT_GEN_GET, 0, NULL); | ||
513 | } | ||
514 | |||
515 | /* | ||
516 | * IOCTL request handler to set rate. | ||
517 | * | ||
518 | * This function prepares the correct firmware command and | ||
519 | * issues it to set the current rate. | ||
520 | * | ||
521 | * The function also performs validation checking on the supplied value. | ||
522 | */ | ||
523 | static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv, | ||
524 | struct mwifiex_rate_cfg *rate_cfg) | ||
525 | { | ||
526 | u8 rates[MWIFIEX_SUPPORTED_RATES]; | ||
527 | u8 *rate; | ||
528 | int rate_index, ret; | ||
529 | u16 bitmap_rates[MAX_BITMAP_RATES_SIZE]; | ||
530 | u32 i; | ||
531 | struct mwifiex_adapter *adapter = priv->adapter; | ||
532 | |||
533 | if (rate_cfg->is_rate_auto) { | ||
534 | memset(bitmap_rates, 0, sizeof(bitmap_rates)); | ||
535 | /* Support all HR/DSSS rates */ | ||
536 | bitmap_rates[0] = 0x000F; | ||
537 | /* Support all OFDM rates */ | ||
538 | bitmap_rates[1] = 0x00FF; | ||
539 | /* Support all HT-MCSs rate */ | ||
540 | for (i = 0; i < ARRAY_SIZE(priv->bitmap_rates) - 3; i++) | ||
541 | bitmap_rates[i + 2] = 0xFFFF; | ||
542 | bitmap_rates[9] = 0x3FFF; | ||
543 | } else { | ||
544 | memset(rates, 0, sizeof(rates)); | ||
545 | mwifiex_get_active_data_rates(priv, rates); | ||
546 | rate = rates; | ||
547 | for (i = 0; (rate[i] && i < MWIFIEX_SUPPORTED_RATES); i++) { | ||
548 | dev_dbg(adapter->dev, "info: rate=%#x wanted=%#x\n", | ||
549 | rate[i], rate_cfg->rate); | ||
550 | if ((rate[i] & 0x7f) == (rate_cfg->rate & 0x7f)) | ||
551 | break; | ||
552 | } | ||
553 | if ((i == MWIFIEX_SUPPORTED_RATES) || !rate[i]) { | ||
554 | dev_err(adapter->dev, "fixed data rate %#x is out " | ||
555 | "of range\n", rate_cfg->rate); | ||
556 | return -1; | ||
557 | } | ||
558 | memset(bitmap_rates, 0, sizeof(bitmap_rates)); | ||
559 | |||
560 | rate_index = mwifiex_data_rate_to_index(rate_cfg->rate); | ||
561 | |||
562 | /* Only allow b/g rates to be set */ | ||
563 | if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 && | ||
564 | rate_index <= MWIFIEX_RATE_INDEX_HRDSSS3) { | ||
565 | bitmap_rates[0] = 1 << rate_index; | ||
566 | } else { | ||
567 | rate_index -= 1; /* There is a 0x00 in the table */ | ||
568 | if (rate_index >= MWIFIEX_RATE_INDEX_OFDM0 && | ||
569 | rate_index <= MWIFIEX_RATE_INDEX_OFDM7) | ||
570 | bitmap_rates[1] = 1 << (rate_index - | ||
571 | MWIFIEX_RATE_INDEX_OFDM0); | ||
572 | } | ||
573 | } | ||
574 | |||
575 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG, | ||
576 | HostCmd_ACT_GEN_SET, 0, bitmap_rates); | ||
577 | |||
578 | return ret; | ||
579 | } | ||
580 | |||
581 | /* | ||
582 | * IOCTL request handler to set/get rate. | ||
583 | * | ||
584 | * This function can be used to set/get either the rate value or the | ||
585 | * rate index. | ||
586 | */ | ||
587 | static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv, | ||
588 | struct mwifiex_rate_cfg *rate_cfg) | ||
589 | { | ||
590 | int status; | ||
591 | |||
592 | if (!rate_cfg) | ||
593 | return -1; | ||
594 | |||
595 | if (rate_cfg->action == HostCmd_ACT_GEN_GET) | ||
596 | status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg); | ||
597 | else | ||
598 | status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg); | ||
599 | |||
600 | return status; | ||
601 | } | ||
602 | |||
603 | /* | ||
604 | * Sends IOCTL request to get the data rate. | 500 | * Sends IOCTL request to get the data rate. |
605 | * | 501 | * |
606 | * This function allocates the IOCTL request buffer, fills it | 502 | * This function allocates the IOCTL request buffer, fills it |
607 | * with requisite parameters and calls the IOCTL handler. | 503 | * with requisite parameters and calls the IOCTL handler. |
608 | */ | 504 | */ |
609 | int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, | 505 | int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate) |
610 | struct mwifiex_rate_cfg *rate) | ||
611 | { | 506 | { |
612 | int ret; | 507 | int ret; |
613 | 508 | ||
614 | memset(rate, 0, sizeof(struct mwifiex_rate_cfg)); | 509 | ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, |
615 | rate->action = HostCmd_ACT_GEN_GET; | 510 | HostCmd_ACT_GEN_GET, 0, NULL); |
616 | ret = mwifiex_rate_ioctl_cfg(priv, rate); | ||
617 | 511 | ||
618 | if (!ret) { | 512 | if (!ret) { |
619 | if (rate->is_rate_auto) | 513 | if (priv->is_data_rate_auto) |
620 | rate->rate = mwifiex_index_to_data_rate(priv, | 514 | *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate, |
621 | priv->tx_rate, | 515 | priv->tx_htinfo); |
622 | priv->tx_htinfo | ||
623 | ); | ||
624 | else | 516 | else |
625 | rate->rate = priv->data_rate; | 517 | *rate = priv->data_rate; |
626 | } else { | ||
627 | ret = -1; | ||
628 | } | 518 | } |
629 | 519 | ||
630 | return ret; | 520 | return ret; |