diff options
-rw-r--r-- | drivers/net/wireless/libertas/cfg.c | 37 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cfg.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 39 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmd.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmdresp.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/defs.h | 13 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/host.h | 24 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/main.c | 7 |
8 files changed, 51 insertions, 77 deletions
diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index 5110a771464b..e90c56030e39 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c | |||
@@ -1386,39 +1386,6 @@ static int lbs_cfg_del_key(struct wiphy *wiphy, struct net_device *netdev, | |||
1386 | * Get station | 1386 | * Get station |
1387 | */ | 1387 | */ |
1388 | 1388 | ||
1389 | /* | ||
1390 | * Returns the signal or 0 in case of an error. | ||
1391 | */ | ||
1392 | |||
1393 | /* like "struct cmd_ds_802_11_rssi", but with cmd_header. Once we get rid | ||
1394 | * of WEXT, this should go into host.h */ | ||
1395 | struct cmd_rssi { | ||
1396 | struct cmd_header hdr; | ||
1397 | |||
1398 | __le16 n_or_snr; | ||
1399 | __le16 nf; | ||
1400 | __le16 avg_snr; | ||
1401 | __le16 avg_nf; | ||
1402 | } __packed; | ||
1403 | |||
1404 | static int lbs_get_signal(struct lbs_private *priv, s8 *signal, s8 *noise) | ||
1405 | { | ||
1406 | struct cmd_rssi cmd; | ||
1407 | int ret; | ||
1408 | |||
1409 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | ||
1410 | cmd.n_or_snr = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR); | ||
1411 | ret = lbs_cmd_with_response(priv, CMD_802_11_RSSI, &cmd); | ||
1412 | |||
1413 | if (ret == 0) { | ||
1414 | *signal = CAL_RSSI(le16_to_cpu(cmd.n_or_snr), | ||
1415 | le16_to_cpu(cmd.nf)); | ||
1416 | *noise = CAL_NF(le16_to_cpu(cmd.nf)); | ||
1417 | } | ||
1418 | return ret; | ||
1419 | } | ||
1420 | |||
1421 | |||
1422 | static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev, | 1389 | static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev, |
1423 | u8 *mac, struct station_info *sinfo) | 1390 | u8 *mac, struct station_info *sinfo) |
1424 | { | 1391 | { |
@@ -1439,7 +1406,7 @@ static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev, | |||
1439 | sinfo->rx_packets = priv->dev->stats.rx_packets; | 1406 | sinfo->rx_packets = priv->dev->stats.rx_packets; |
1440 | 1407 | ||
1441 | /* Get current RSSI */ | 1408 | /* Get current RSSI */ |
1442 | ret = lbs_get_signal(priv, &signal, &noise); | 1409 | ret = lbs_get_rssi(priv, &signal, &noise); |
1443 | if (ret == 0) { | 1410 | if (ret == 0) { |
1444 | sinfo->signal = signal; | 1411 | sinfo->signal = signal; |
1445 | sinfo->filled |= STATION_INFO_SIGNAL; | 1412 | sinfo->filled |= STATION_INFO_SIGNAL; |
@@ -1479,7 +1446,7 @@ static int lbs_get_survey(struct wiphy *wiphy, struct net_device *dev, | |||
1479 | survey->channel = ieee80211_get_channel(wiphy, | 1446 | survey->channel = ieee80211_get_channel(wiphy, |
1480 | ieee80211_channel_to_frequency(priv->channel)); | 1447 | ieee80211_channel_to_frequency(priv->channel)); |
1481 | 1448 | ||
1482 | ret = lbs_get_signal(priv, &signal, &noise); | 1449 | ret = lbs_get_rssi(priv, &signal, &noise); |
1483 | if (ret == 0) { | 1450 | if (ret == 0) { |
1484 | survey->filled = SURVEY_INFO_NOISE_DBM; | 1451 | survey->filled = SURVEY_INFO_NOISE_DBM; |
1485 | survey->noise = noise; | 1452 | survey->noise = noise; |
diff --git a/drivers/net/wireless/libertas/cfg.h b/drivers/net/wireless/libertas/cfg.h index 756fb98f9f05..e7ba4d84164d 100644 --- a/drivers/net/wireless/libertas/cfg.h +++ b/drivers/net/wireless/libertas/cfg.h | |||
@@ -14,8 +14,6 @@ int lbs_reg_notifier(struct wiphy *wiphy, | |||
14 | struct regulatory_request *request); | 14 | struct regulatory_request *request); |
15 | 15 | ||
16 | /* All of those are TODOs: */ | 16 | /* All of those are TODOs: */ |
17 | #define lbs_cmd_802_11_rssi(priv, cmdptr) (0) | ||
18 | #define lbs_ret_802_11_rssi(priv, resp) (0) | ||
19 | #define lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action) (0) | 17 | #define lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action) (0) |
20 | #define lbs_ret_802_11_bcn_ctrl(priv, resp) (0) | 18 | #define lbs_ret_802_11_bcn_ctrl(priv, resp) (0) |
21 | 19 | ||
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 4454988fc00b..e95f80de7c50 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -12,6 +12,8 @@ | |||
12 | #include "cfg.h" | 12 | #include "cfg.h" |
13 | #include "cmd.h" | 13 | #include "cmd.h" |
14 | 14 | ||
15 | #define CAL_NF(nf) ((s32)(-(s32)(nf))) | ||
16 | #define CAL_RSSI(snr, nf) ((s32)((s32)(snr) + CAL_NF(nf))) | ||
15 | 17 | ||
16 | static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv); | 18 | static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv); |
17 | 19 | ||
@@ -690,6 +692,39 @@ out: | |||
690 | return ret; | 692 | return ret; |
691 | } | 693 | } |
692 | 694 | ||
695 | /** | ||
696 | * @brief Get current RSSI and noise floor | ||
697 | * | ||
698 | * @param priv A pointer to struct lbs_private structure | ||
699 | * @param rssi On successful return, signal level in mBm | ||
700 | * | ||
701 | * @return The channel on success, error on failure | ||
702 | */ | ||
703 | int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf) | ||
704 | { | ||
705 | struct cmd_ds_802_11_rssi cmd; | ||
706 | int ret = 0; | ||
707 | |||
708 | lbs_deb_enter(LBS_DEB_CMD); | ||
709 | |||
710 | BUG_ON(rssi == NULL); | ||
711 | BUG_ON(nf == NULL); | ||
712 | |||
713 | memset(&cmd, 0, sizeof(cmd)); | ||
714 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | ||
715 | /* Average SNR over last 8 beacons */ | ||
716 | cmd.n_or_snr = cpu_to_le16(8); | ||
717 | |||
718 | ret = lbs_cmd_with_response(priv, CMD_802_11_RSSI, &cmd); | ||
719 | if (ret == 0) { | ||
720 | *nf = CAL_NF(le16_to_cpu(cmd.nf)); | ||
721 | *rssi = CAL_RSSI(le16_to_cpu(cmd.n_or_snr), le16_to_cpu(cmd.nf)); | ||
722 | } | ||
723 | |||
724 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); | ||
725 | return ret; | ||
726 | } | ||
727 | |||
693 | static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr, | 728 | static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr, |
694 | u8 cmd_action, void *pdata_buf) | 729 | u8 cmd_action, void *pdata_buf) |
695 | { | 730 | { |
@@ -1106,10 +1141,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv, | |||
1106 | ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf); | 1141 | ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf); |
1107 | break; | 1142 | break; |
1108 | 1143 | ||
1109 | case CMD_802_11_RSSI: | ||
1110 | ret = lbs_cmd_802_11_rssi(priv, cmdptr); | ||
1111 | break; | ||
1112 | |||
1113 | case CMD_802_11_SET_AFC: | 1144 | case CMD_802_11_SET_AFC: |
1114 | case CMD_802_11_GET_AFC: | 1145 | case CMD_802_11_GET_AFC: |
1115 | 1146 | ||
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h index 1b9092f95676..ec41380c4b29 100644 --- a/drivers/net/wireless/libertas/cmd.h +++ b/drivers/net/wireless/libertas/cmd.h | |||
@@ -131,4 +131,6 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep); | |||
131 | 131 | ||
132 | int lbs_set_monitor_mode(struct lbs_private *priv, int enable); | 132 | int lbs_set_monitor_mode(struct lbs_private *priv, int enable); |
133 | 133 | ||
134 | int lbs_get_rssi(struct lbs_private *priv, s8 *snr, s8 *nf); | ||
135 | |||
134 | #endif /* _LBS_CMD_H */ | 136 | #endif /* _LBS_CMD_H */ |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index a0d9482ef5e2..e51957c3ae4b 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -172,10 +172,6 @@ static inline int handle_cmd_response(struct lbs_private *priv, | |||
172 | case CMD_RET(CMD_802_11_BEACON_STOP): | 172 | case CMD_RET(CMD_802_11_BEACON_STOP): |
173 | break; | 173 | break; |
174 | 174 | ||
175 | case CMD_RET(CMD_802_11_RSSI): | ||
176 | ret = lbs_ret_802_11_rssi(priv, resp); | ||
177 | break; | ||
178 | |||
179 | case CMD_RET(CMD_802_11D_DOMAIN_INFO): | 175 | case CMD_RET(CMD_802_11D_DOMAIN_INFO): |
180 | ret = lbs_ret_802_11d_domain_info(resp); | 176 | ret = lbs_ret_802_11d_domain_info(resp); |
181 | break; | 177 | break; |
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h index ea3f10ef4e00..da9833f00ee9 100644 --- a/drivers/net/wireless/libertas/defs.h +++ b/drivers/net/wireless/libertas/defs.h | |||
@@ -301,19 +301,6 @@ static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, in | |||
301 | #define BAND_G (0x02) | 301 | #define BAND_G (0x02) |
302 | #define ALL_802_11_BANDS (BAND_B | BAND_G) | 302 | #define ALL_802_11_BANDS (BAND_B | BAND_G) |
303 | 303 | ||
304 | /** MACRO DEFINITIONS */ | ||
305 | #define CAL_NF(NF) ((s32)(-(s32)(NF))) | ||
306 | #define CAL_RSSI(SNR, NF) ((s32)((s32)(SNR) + CAL_NF(NF))) | ||
307 | #define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI))) | ||
308 | |||
309 | #define DEFAULT_BCN_AVG_FACTOR 8 | ||
310 | #define DEFAULT_DATA_AVG_FACTOR 8 | ||
311 | #define AVG_SCALE 100 | ||
312 | #define CAL_AVG_SNR_NF(AVG, SNRNF, N) \ | ||
313 | (((AVG) == 0) ? ((u16)(SNRNF) * AVG_SCALE) : \ | ||
314 | ((((int)(AVG) * (N -1)) + ((u16)(SNRNF) * \ | ||
315 | AVG_SCALE)) / N)) | ||
316 | |||
317 | #define MAX_RATES 14 | 304 | #define MAX_RATES 14 |
318 | 305 | ||
319 | #define MAX_LEDS 8 | 306 | #define MAX_LEDS 8 |
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h index dd67334765ef..0517ec3d4ba3 100644 --- a/drivers/net/wireless/libertas/host.h +++ b/drivers/net/wireless/libertas/host.h | |||
@@ -644,19 +644,19 @@ struct cmd_ds_802_11_rf_channel { | |||
644 | } __packed; | 644 | } __packed; |
645 | 645 | ||
646 | struct cmd_ds_802_11_rssi { | 646 | struct cmd_ds_802_11_rssi { |
647 | /* weighting factor */ | 647 | struct cmd_header hdr; |
648 | __le16 N; | ||
649 | 648 | ||
650 | __le16 reserved_0; | 649 | /* request: number of beacons (N) to average the SNR and NF over |
651 | __le16 reserved_1; | 650 | * response: SNR of most recent beacon |
652 | __le16 reserved_2; | 651 | */ |
653 | } __packed; | 652 | __le16 n_or_snr; |
654 | 653 | ||
655 | struct cmd_ds_802_11_rssi_rsp { | 654 | /* The following fields are only set in the response. |
656 | __le16 SNR; | 655 | * In the request these are reserved and should be set to 0. |
657 | __le16 noisefloor; | 656 | */ |
658 | __le16 avgSNR; | 657 | __le16 nf; /* most recent beacon noise floor */ |
659 | __le16 avgnoisefloor; | 658 | __le16 avg_snr; /* average SNR weighted by N from request */ |
659 | __le16 avg_nf; /* average noise floor weighted by N from request */ | ||
660 | } __packed; | 660 | } __packed; |
661 | 661 | ||
662 | struct cmd_ds_802_11_mac_address { | 662 | struct cmd_ds_802_11_mac_address { |
@@ -969,8 +969,6 @@ struct cmd_ds_command { | |||
969 | /* command Body */ | 969 | /* command Body */ |
970 | union { | 970 | union { |
971 | struct cmd_ds_802_11_ps_mode psmode; | 971 | struct cmd_ds_802_11_ps_mode psmode; |
972 | struct cmd_ds_802_11_rssi rssi; | ||
973 | struct cmd_ds_802_11_rssi_rsp rssirsp; | ||
974 | struct cmd_ds_mac_reg_access macreg; | 972 | struct cmd_ds_mac_reg_access macreg; |
975 | struct cmd_ds_bbp_reg_access bbpreg; | 973 | struct cmd_ds_bbp_reg_access bbpreg; |
976 | struct cmd_ds_rf_reg_access rfreg; | 974 | struct cmd_ds_rf_reg_access rfreg; |
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index 2a0b590a93f1..cfd0af6725d4 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c | |||
@@ -157,12 +157,7 @@ static void lbs_tx_timeout(struct net_device *dev) | |||
157 | to kick it somehow? */ | 157 | to kick it somehow? */ |
158 | lbs_host_to_card_done(priv); | 158 | lbs_host_to_card_done(priv); |
159 | 159 | ||
160 | /* More often than not, this actually happens because the | 160 | /* FIXME: reset the card */ |
161 | firmware has crapped itself -- rather than just a very | ||
162 | busy medium. So send a harmless command, and if/when | ||
163 | _that_ times out, we'll kick it in the head. */ | ||
164 | lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, | ||
165 | 0, 0, NULL); | ||
166 | 161 | ||
167 | lbs_deb_leave(LBS_DEB_TX); | 162 | lbs_deb_leave(LBS_DEB_TX); |
168 | } | 163 | } |