diff options
author | Dan Williams <dcbw@redhat.com> | 2007-12-11 15:50:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:06:49 -0500 |
commit | 8e3c91bb70372da692a5fefae9f698c94bb1e641 (patch) | |
tree | c8befebaafa59facde125257c626c3440a22f785 | |
parent | 79a9a37c1eb13bd645ec423c0c30b70838e7bf93 (diff) |
libertas: convert DATA_RATE to a direct command
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 93 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmd.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmdresp.c | 23 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/hostcmd.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/main.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/wext.c | 9 |
6 files changed, 83 insertions, 56 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 9d621fe7f08a..eff78792fc6f 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -706,30 +706,86 @@ static int lbs_cmd_802_11_rate_adapt_rateset(struct lbs_private *priv, | |||
706 | return 0; | 706 | return 0; |
707 | } | 707 | } |
708 | 708 | ||
709 | static int lbs_cmd_802_11_data_rate(struct lbs_private *priv, | 709 | /** |
710 | struct cmd_ds_command *cmd, | 710 | * @brief Get the current data rate |
711 | u16 cmd_action) | 711 | * |
712 | * @param priv A pointer to struct lbs_private structure | ||
713 | * | ||
714 | * @return The data rate on success, error on failure | ||
715 | */ | ||
716 | int lbs_get_data_rate(struct lbs_private *priv) | ||
712 | { | 717 | { |
713 | struct cmd_ds_802_11_data_rate *pdatarate = &cmd->params.drate; | 718 | struct cmd_ds_802_11_data_rate cmd; |
719 | int ret = -1; | ||
714 | 720 | ||
715 | lbs_deb_enter(LBS_DEB_CMD); | 721 | lbs_deb_enter(LBS_DEB_CMD); |
716 | 722 | ||
717 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_data_rate) + | 723 | memset(&cmd, 0, sizeof(cmd)); |
718 | S_DS_GEN); | 724 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); |
719 | cmd->command = cpu_to_le16(CMD_802_11_DATA_RATE); | 725 | cmd.action = cpu_to_le16(CMD_ACT_GET_TX_RATE); |
720 | memset(pdatarate, 0, sizeof(struct cmd_ds_802_11_data_rate)); | 726 | |
721 | pdatarate->action = cpu_to_le16(cmd_action); | 727 | ret = lbs_cmd_with_response(priv, CMD_802_11_DATA_RATE, cmd); |
722 | 728 | if (ret) | |
723 | if (cmd_action == CMD_ACT_SET_TX_FIX_RATE) { | 729 | goto out; |
724 | pdatarate->rates[0] = lbs_data_rate_to_fw_index(priv->cur_rate); | 730 | |
725 | lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n", | 731 | lbs_deb_hex(LBS_DEB_CMD, "DATA_RATE_RESP", (u8 *) &cmd, sizeof (cmd)); |
726 | priv->cur_rate); | 732 | |
727 | } else if (cmd_action == CMD_ACT_SET_TX_AUTO) { | 733 | ret = (int) lbs_fw_index_to_data_rate(cmd.rates[0]); |
734 | lbs_deb_cmd("DATA_RATE: current rate 0x%02x\n", ret); | ||
735 | |||
736 | out: | ||
737 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); | ||
738 | return ret; | ||
739 | } | ||
740 | |||
741 | /** | ||
742 | * @brief Set the data rate | ||
743 | * | ||
744 | * @param priv A pointer to struct lbs_private structure | ||
745 | * @param rate The desired data rate, or 0 to clear a locked rate | ||
746 | * | ||
747 | * @return 0 on success, error on failure | ||
748 | */ | ||
749 | int lbs_set_data_rate(struct lbs_private *priv, u8 rate) | ||
750 | { | ||
751 | struct cmd_ds_802_11_data_rate cmd; | ||
752 | int ret = 0; | ||
753 | |||
754 | lbs_deb_enter(LBS_DEB_CMD); | ||
755 | |||
756 | memset(&cmd, 0, sizeof(cmd)); | ||
757 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | ||
758 | |||
759 | if (rate > 0) { | ||
760 | cmd.action = cpu_to_le16(CMD_ACT_SET_TX_FIX_RATE); | ||
761 | cmd.rates[0] = lbs_data_rate_to_fw_index(rate); | ||
762 | if (cmd.rates[0] == 0) { | ||
763 | lbs_deb_cmd("DATA_RATE: invalid requested rate of" | ||
764 | " 0x%02X\n", rate); | ||
765 | ret = 0; | ||
766 | goto out; | ||
767 | } | ||
768 | lbs_deb_cmd("DATA_RATE: set fixed 0x%02X\n", cmd.rates[0]); | ||
769 | } else { | ||
770 | cmd.action = cpu_to_le16(CMD_ACT_SET_TX_AUTO); | ||
728 | lbs_deb_cmd("DATA_RATE: setting auto\n"); | 771 | lbs_deb_cmd("DATA_RATE: setting auto\n"); |
729 | } | 772 | } |
730 | 773 | ||
731 | lbs_deb_leave(LBS_DEB_CMD); | 774 | ret = lbs_cmd_with_response(priv, CMD_802_11_DATA_RATE, cmd); |
732 | return 0; | 775 | if (ret) |
776 | goto out; | ||
777 | |||
778 | lbs_deb_hex(LBS_DEB_CMD, "DATA_RATE_RESP", (u8 *) &cmd, sizeof (cmd)); | ||
779 | |||
780 | /* FIXME: get actual rates FW can do if this command actually returns | ||
781 | * all data rates supported. | ||
782 | */ | ||
783 | priv->cur_rate = lbs_fw_index_to_data_rate(cmd.rates[0]); | ||
784 | lbs_deb_cmd("DATA_RATE: current rate is 0x%02x\n", priv->cur_rate); | ||
785 | |||
786 | out: | ||
787 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); | ||
788 | return ret; | ||
733 | } | 789 | } |
734 | 790 | ||
735 | static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv, | 791 | static int lbs_cmd_mac_multicast_adr(struct lbs_private *priv, |
@@ -1348,9 +1404,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv, | |||
1348 | ret = lbs_cmd_802_11_radio_control(priv, cmdptr, cmd_action); | 1404 | ret = lbs_cmd_802_11_radio_control(priv, cmdptr, cmd_action); |
1349 | break; | 1405 | break; |
1350 | 1406 | ||
1351 | case CMD_802_11_DATA_RATE: | ||
1352 | ret = lbs_cmd_802_11_data_rate(priv, cmdptr, cmd_action); | ||
1353 | break; | ||
1354 | case CMD_802_11_RATE_ADAPT_RATESET: | 1407 | case CMD_802_11_RATE_ADAPT_RATESET: |
1355 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, | 1408 | ret = lbs_cmd_802_11_rate_adapt_rateset(priv, |
1356 | cmdptr, cmd_action); | 1409 | cmdptr, cmd_action); |
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h index 950acce3baaf..4bd6f56281f6 100644 --- a/drivers/net/wireless/libertas/cmd.h +++ b/drivers/net/wireless/libertas/cmd.h | |||
@@ -27,4 +27,7 @@ int lbs_update_hw_spec(struct lbs_private *priv); | |||
27 | int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, | 27 | int lbs_mesh_access(struct lbs_private *priv, uint16_t cmd_action, |
28 | struct cmd_ds_mesh_access *cmd); | 28 | struct cmd_ds_mesh_access *cmd); |
29 | 29 | ||
30 | int lbs_get_data_rate(struct lbs_private *priv); | ||
31 | int lbs_set_data_rate(struct lbs_private *priv, u8 rate); | ||
32 | |||
30 | #endif /* _LBS_CMD_H */ | 33 | #endif /* _LBS_CMD_H */ |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index 6ff705b49ddc..797c943457eb 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -325,26 +325,6 @@ static int lbs_ret_802_11_rate_adapt_rateset(struct lbs_private *priv, | |||
325 | return 0; | 325 | return 0; |
326 | } | 326 | } |
327 | 327 | ||
328 | static int lbs_ret_802_11_data_rate(struct lbs_private *priv, | ||
329 | struct cmd_ds_command *resp) | ||
330 | { | ||
331 | struct cmd_ds_802_11_data_rate *pdatarate = &resp->params.drate; | ||
332 | |||
333 | lbs_deb_enter(LBS_DEB_CMD); | ||
334 | |||
335 | lbs_deb_hex(LBS_DEB_CMD, "DATA_RATE_RESP", (u8 *) pdatarate, | ||
336 | sizeof(struct cmd_ds_802_11_data_rate)); | ||
337 | |||
338 | /* FIXME: get actual rates FW can do if this command actually returns | ||
339 | * all data rates supported. | ||
340 | */ | ||
341 | priv->cur_rate = lbs_fw_index_to_data_rate(pdatarate->rates[0]); | ||
342 | lbs_deb_cmd("DATA_RATE: current rate 0x%02x\n", priv->cur_rate); | ||
343 | |||
344 | lbs_deb_leave(LBS_DEB_CMD); | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static int lbs_ret_802_11_rf_channel(struct lbs_private *priv, | 328 | static int lbs_ret_802_11_rf_channel(struct lbs_private *priv, |
349 | struct cmd_ds_command *resp) | 329 | struct cmd_ds_command *resp) |
350 | { | 330 | { |
@@ -565,9 +545,6 @@ static inline int handle_cmd_response(struct lbs_private *priv, | |||
565 | ret = lbs_ret_802_11_enable_rsn(priv, resp); | 545 | ret = lbs_ret_802_11_enable_rsn(priv, resp); |
566 | break; | 546 | break; |
567 | 547 | ||
568 | case CMD_RET(CMD_802_11_DATA_RATE): | ||
569 | ret = lbs_ret_802_11_data_rate(priv, resp); | ||
570 | break; | ||
571 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): | 548 | case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET): |
572 | ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp); | 549 | ret = lbs_ret_802_11_rate_adapt_rateset(priv, resp); |
573 | break; | 550 | break; |
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h index d9b151a28801..d51010c47b5b 100644 --- a/drivers/net/wireless/libertas/hostcmd.h +++ b/drivers/net/wireless/libertas/hostcmd.h | |||
@@ -461,6 +461,8 @@ struct PS_CMD_ConfirmSleep { | |||
461 | }; | 461 | }; |
462 | 462 | ||
463 | struct cmd_ds_802_11_data_rate { | 463 | struct cmd_ds_802_11_data_rate { |
464 | struct cmd_header hdr; | ||
465 | |||
464 | __le16 action; | 466 | __le16 action; |
465 | __le16 reserved; | 467 | __le16 reserved; |
466 | u8 rates[MAX_RATES]; | 468 | u8 rates[MAX_RATES]; |
@@ -659,7 +661,6 @@ struct cmd_ds_command { | |||
659 | struct cmd_ds_802_11_rf_tx_power txp; | 661 | struct cmd_ds_802_11_rf_tx_power txp; |
660 | struct cmd_ds_802_11_rf_antenna rant; | 662 | struct cmd_ds_802_11_rf_antenna rant; |
661 | struct cmd_ds_802_11_monitor_mode monitor; | 663 | struct cmd_ds_802_11_monitor_mode monitor; |
662 | struct cmd_ds_802_11_data_rate drate; | ||
663 | struct cmd_ds_802_11_rate_adapt_rateset rateset; | 664 | struct cmd_ds_802_11_rate_adapt_rateset rateset; |
664 | struct cmd_ds_mac_multicast_adr madr; | 665 | struct cmd_ds_mac_multicast_adr madr; |
665 | struct cmd_ds_802_11_ad_hoc_join adj; | 666 | struct cmd_ds_802_11_ad_hoc_join adj; |
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index 7f6b3ccef0c2..2fe7ad0f8327 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -854,12 +854,8 @@ static int lbs_setup_firmware(struct lbs_private *priv) | |||
854 | 854 | ||
855 | lbs_set_mac_packet_filter(priv); | 855 | lbs_set_mac_packet_filter(priv); |
856 | 856 | ||
857 | /* Get the supported Data rates */ | 857 | ret = lbs_get_data_rate(priv); |
858 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_DATA_RATE, | 858 | if (ret < 0) { |
859 | CMD_ACT_GET_TX_RATE, | ||
860 | CMD_OPTION_WAITFORRSP, 0, NULL); | ||
861 | |||
862 | if (ret) { | ||
863 | ret = -1; | 859 | ret = -1; |
864 | goto done; | 860 | goto done; |
865 | } | 861 | } |
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 1e0b2245db56..e44c0ce804ed 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "join.h" | 19 | #include "join.h" |
20 | #include "wext.h" | 20 | #include "wext.h" |
21 | #include "assoc.h" | 21 | #include "assoc.h" |
22 | #include "cmd.h" | ||
22 | 23 | ||
23 | 24 | ||
24 | static inline void lbs_postpone_association_work(struct lbs_private *priv) | 25 | static inline void lbs_postpone_association_work(struct lbs_private *priv) |
@@ -962,8 +963,7 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, | |||
962 | struct iw_param *vwrq, char *extra) | 963 | struct iw_param *vwrq, char *extra) |
963 | { | 964 | { |
964 | struct lbs_private *priv = dev->priv; | 965 | struct lbs_private *priv = dev->priv; |
965 | u32 new_rate; | 966 | u8 new_rate = 0; |
966 | u16 action; | ||
967 | int ret = -EINVAL; | 967 | int ret = -EINVAL; |
968 | u8 rates[MAX_RATES + 1]; | 968 | u8 rates[MAX_RATES + 1]; |
969 | 969 | ||
@@ -972,7 +972,6 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, | |||
972 | 972 | ||
973 | /* Auto rate? */ | 973 | /* Auto rate? */ |
974 | if (vwrq->value == -1) { | 974 | if (vwrq->value == -1) { |
975 | action = CMD_ACT_SET_TX_AUTO; | ||
976 | priv->auto_rate = 1; | 975 | priv->auto_rate = 1; |
977 | priv->cur_rate = 0; | 976 | priv->cur_rate = 0; |
978 | } else { | 977 | } else { |
@@ -989,12 +988,10 @@ static int lbs_set_rate(struct net_device *dev, struct iw_request_info *info, | |||
989 | } | 988 | } |
990 | 989 | ||
991 | priv->cur_rate = new_rate; | 990 | priv->cur_rate = new_rate; |
992 | action = CMD_ACT_SET_TX_FIX_RATE; | ||
993 | priv->auto_rate = 0; | 991 | priv->auto_rate = 0; |
994 | } | 992 | } |
995 | 993 | ||
996 | ret = lbs_prepare_and_send_command(priv, CMD_802_11_DATA_RATE, | 994 | ret = lbs_set_data_rate(priv, new_rate); |
997 | action, CMD_OPTION_WAITFORRSP, 0, NULL); | ||
998 | 995 | ||
999 | out: | 996 | out: |
1000 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); | 997 | lbs_deb_leave_args(LBS_DEB_WEXT, "ret %d", ret); |