]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
libertas: clean up RSSI command
authorDan Williams <dcbw@redhat.com>
Tue, 27 Jul 2010 19:55:21 +0000 (12:55 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 27 Jul 2010 19:06:43 +0000 (15:06 -0400)
Convert to a full direct command; previous code rolled a direct
command by hand but left the original indirect command code intact
but disabled.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/cfg.c
drivers/net/wireless/libertas/cfg.h
drivers/net/wireless/libertas/cmd.c
drivers/net/wireless/libertas/cmd.h
drivers/net/wireless/libertas/cmdresp.c
drivers/net/wireless/libertas/defs.h
drivers/net/wireless/libertas/host.h
drivers/net/wireless/libertas/main.c

index 5110a771464bc0e248e8c1d114850d6cd71362c6..e90c56030e39a29d7bfa98396dd06d0e847952f9 100644 (file)
@@ -1386,39 +1386,6 @@ static int lbs_cfg_del_key(struct wiphy *wiphy, struct net_device *netdev,
  * Get station
  */
 
  * Get station
  */
 
-/*
- * Returns the signal or 0 in case of an error.
- */
-
-/* like "struct cmd_ds_802_11_rssi", but with cmd_header. Once we get rid
- * of WEXT, this should go into host.h */
-struct cmd_rssi {
-       struct cmd_header hdr;
-
-       __le16 n_or_snr;
-       __le16 nf;
-       __le16 avg_snr;
-       __le16 avg_nf;
-} __packed;
-
-static int lbs_get_signal(struct lbs_private *priv, s8 *signal, s8 *noise)
-{
-       struct cmd_rssi cmd;
-       int ret;
-
-       cmd.hdr.size = cpu_to_le16(sizeof(cmd));
-       cmd.n_or_snr = cpu_to_le16(DEFAULT_BCN_AVG_FACTOR);
-       ret = lbs_cmd_with_response(priv, CMD_802_11_RSSI, &cmd);
-
-       if (ret == 0) {
-               *signal = CAL_RSSI(le16_to_cpu(cmd.n_or_snr),
-                               le16_to_cpu(cmd.nf));
-               *noise  = CAL_NF(le16_to_cpu(cmd.nf));
-       }
-       return ret;
-}
-
-
 static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev,
                              u8 *mac, struct station_info *sinfo)
 {
 static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev,
                              u8 *mac, struct station_info *sinfo)
 {
@@ -1439,7 +1406,7 @@ static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev,
        sinfo->rx_packets = priv->dev->stats.rx_packets;
 
        /* Get current RSSI */
        sinfo->rx_packets = priv->dev->stats.rx_packets;
 
        /* Get current RSSI */
-       ret = lbs_get_signal(priv, &signal, &noise);
+       ret = lbs_get_rssi(priv, &signal, &noise);
        if (ret == 0) {
                sinfo->signal = signal;
                sinfo->filled |= STATION_INFO_SIGNAL;
        if (ret == 0) {
                sinfo->signal = signal;
                sinfo->filled |= STATION_INFO_SIGNAL;
@@ -1479,7 +1446,7 @@ static int lbs_get_survey(struct wiphy *wiphy, struct net_device *dev,
        survey->channel = ieee80211_get_channel(wiphy,
                ieee80211_channel_to_frequency(priv->channel));
 
        survey->channel = ieee80211_get_channel(wiphy,
                ieee80211_channel_to_frequency(priv->channel));
 
-       ret = lbs_get_signal(priv, &signal, &noise);
+       ret = lbs_get_rssi(priv, &signal, &noise);
        if (ret == 0) {
                survey->filled = SURVEY_INFO_NOISE_DBM;
                survey->noise = noise;
        if (ret == 0) {
                survey->filled = SURVEY_INFO_NOISE_DBM;
                survey->noise = noise;
index 756fb98f9f057233d64f648264b669b69ee2df28..e7ba4d84164da97e7767f0d378986452afe0dedc 100644 (file)
@@ -14,8 +14,6 @@ int lbs_reg_notifier(struct wiphy *wiphy,
                struct regulatory_request *request);
 
 /* All of those are TODOs: */
                struct regulatory_request *request);
 
 /* All of those are TODOs: */
-#define lbs_cmd_802_11_rssi(priv, cmdptr) (0)
-#define lbs_ret_802_11_rssi(priv, resp) (0)
 #define lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action) (0)
 #define lbs_ret_802_11_bcn_ctrl(priv, resp) (0)
 
 #define lbs_cmd_bcn_ctrl(priv, cmdptr, cmd_action) (0)
 #define lbs_ret_802_11_bcn_ctrl(priv, resp) (0)
 
index 4454988fc00b317d9c8422d9a3045a139e74189e..e95f80de7c5021862449c0e8f2edf97aa2b11a25 100644 (file)
@@ -12,6 +12,8 @@
 #include "cfg.h"
 #include "cmd.h"
 
 #include "cfg.h"
 #include "cmd.h"
 
+#define CAL_NF(nf)             ((s32)(-(s32)(nf)))
+#define CAL_RSSI(snr, nf)      ((s32)((s32)(snr) + CAL_NF(nf)))
 
 static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
 
 
 static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
 
@@ -690,6 +692,39 @@ out:
        return ret;
 }
 
        return ret;
 }
 
+/**
+ *  @brief Get current RSSI and noise floor
+ *
+ *  @param priv                A pointer to struct lbs_private structure
+ *  @param rssi                On successful return, signal level in mBm
+ *
+ *  @return            The channel on success, error on failure
+ */
+int lbs_get_rssi(struct lbs_private *priv, s8 *rssi, s8 *nf)
+{
+       struct cmd_ds_802_11_rssi cmd;
+       int ret = 0;
+
+       lbs_deb_enter(LBS_DEB_CMD);
+
+       BUG_ON(rssi == NULL);
+       BUG_ON(nf == NULL);
+
+       memset(&cmd, 0, sizeof(cmd));
+       cmd.hdr.size = cpu_to_le16(sizeof(cmd));
+       /* Average SNR over last 8 beacons */
+       cmd.n_or_snr = cpu_to_le16(8);
+
+       ret = lbs_cmd_with_response(priv, CMD_802_11_RSSI, &cmd);
+       if (ret == 0) {
+               *nf = CAL_NF(le16_to_cpu(cmd.nf));
+               *rssi = CAL_RSSI(le16_to_cpu(cmd.n_or_snr), le16_to_cpu(cmd.nf));
+       }
+
+       lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret);
+       return ret;
+}
+
 static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
                               u8 cmd_action, void *pdata_buf)
 {
 static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
                               u8 cmd_action, void *pdata_buf)
 {
@@ -1106,10 +1141,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf);
                break;
 
                ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf);
                break;
 
-       case CMD_802_11_RSSI:
-               ret = lbs_cmd_802_11_rssi(priv, cmdptr);
-               break;
-
        case CMD_802_11_SET_AFC:
        case CMD_802_11_GET_AFC:
 
        case CMD_802_11_SET_AFC:
        case CMD_802_11_GET_AFC:
 
index 1b9092f95676de692962bc65f66950da8aa4afa7..ec41380c4b29bb737a7ca18e0bb960acc2d6e9ff 100644 (file)
@@ -131,4 +131,6 @@ int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep);
 
 int lbs_set_monitor_mode(struct lbs_private *priv, int enable);
 
 
 int lbs_set_monitor_mode(struct lbs_private *priv, int enable);
 
+int lbs_get_rssi(struct lbs_private *priv, s8 *snr, s8 *nf);
+
 #endif /* _LBS_CMD_H */
 #endif /* _LBS_CMD_H */
index a0d9482ef5e28351fe372933d7feb9c089e7228d..e51957c3ae4be1fb0a9a7c44b70edba3ee526ccb 100644 (file)
@@ -172,10 +172,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
        case CMD_RET(CMD_802_11_BEACON_STOP):
                break;
 
        case CMD_RET(CMD_802_11_BEACON_STOP):
                break;
 
-       case CMD_RET(CMD_802_11_RSSI):
-               ret = lbs_ret_802_11_rssi(priv, resp);
-               break;
-
        case CMD_RET(CMD_802_11D_DOMAIN_INFO):
                ret = lbs_ret_802_11d_domain_info(resp);
                break;
        case CMD_RET(CMD_802_11D_DOMAIN_INFO):
                ret = lbs_ret_802_11d_domain_info(resp);
                break;
index ea3f10ef4e0032c845a15cf973b1c9ffe925b504..da9833f00ee9826809b1635b84b92d87e7daae3a 100644 (file)
@@ -301,19 +301,6 @@ static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, in
 #define        BAND_G                  (0x02)
 #define ALL_802_11_BANDS       (BAND_B | BAND_G)
 
 #define        BAND_G                  (0x02)
 #define ALL_802_11_BANDS       (BAND_B | BAND_G)
 
-/** MACRO DEFINITIONS */
-#define CAL_NF(NF)                     ((s32)(-(s32)(NF)))
-#define CAL_RSSI(SNR, NF)              ((s32)((s32)(SNR) + CAL_NF(NF)))
-#define SCAN_RSSI(RSSI)                        (0x100 - ((u8)(RSSI)))
-
-#define DEFAULT_BCN_AVG_FACTOR         8
-#define DEFAULT_DATA_AVG_FACTOR                8
-#define AVG_SCALE                      100
-#define CAL_AVG_SNR_NF(AVG, SNRNF, N)         \
-                        (((AVG) == 0) ? ((u16)(SNRNF) * AVG_SCALE) : \
-                        ((((int)(AVG) * (N -1)) + ((u16)(SNRNF) * \
-                        AVG_SCALE))  / N))
-
 #define MAX_RATES                      14
 
 #define        MAX_LEDS                        8
 #define MAX_RATES                      14
 
 #define        MAX_LEDS                        8
index dd67334765ef927d51a184059ff221fe33bf136b..0517ec3d4ba3a263e716d42c5175229d57a23c30 100644 (file)
@@ -644,19 +644,19 @@ struct cmd_ds_802_11_rf_channel {
 } __packed;
 
 struct cmd_ds_802_11_rssi {
 } __packed;
 
 struct cmd_ds_802_11_rssi {
-       /* weighting factor */
-       __le16 N;
+       struct cmd_header hdr;
 
 
-       __le16 reserved_0;
-       __le16 reserved_1;
-       __le16 reserved_2;
-} __packed;
+       /* request:  number of beacons (N) to average the SNR and NF over
+        * response: SNR of most recent beacon
+        */
+       __le16 n_or_snr;
 
 
-struct cmd_ds_802_11_rssi_rsp {
-       __le16 SNR;
-       __le16 noisefloor;
-       __le16 avgSNR;
-       __le16 avgnoisefloor;
+       /* The following fields are only set in the response.
+        * In the request these are reserved and should be set to 0.
+        */
+       __le16 nf;       /* most recent beacon noise floor */
+       __le16 avg_snr;  /* average SNR weighted by N from request */
+       __le16 avg_nf;   /* average noise floor weighted by N from request */
 } __packed;
 
 struct cmd_ds_802_11_mac_address {
 } __packed;
 
 struct cmd_ds_802_11_mac_address {
@@ -969,8 +969,6 @@ struct cmd_ds_command {
        /* command Body */
        union {
                struct cmd_ds_802_11_ps_mode psmode;
        /* command Body */
        union {
                struct cmd_ds_802_11_ps_mode psmode;
-               struct cmd_ds_802_11_rssi rssi;
-               struct cmd_ds_802_11_rssi_rsp rssirsp;
                struct cmd_ds_mac_reg_access macreg;
                struct cmd_ds_bbp_reg_access bbpreg;
                struct cmd_ds_rf_reg_access rfreg;
                struct cmd_ds_mac_reg_access macreg;
                struct cmd_ds_bbp_reg_access bbpreg;
                struct cmd_ds_rf_reg_access rfreg;
index 2a0b590a93f1098e79e0c9ba7219807045dbe27a..cfd0af6725d48406105d06bc92988e4d73187a1c 100644 (file)
@@ -157,12 +157,7 @@ static void lbs_tx_timeout(struct net_device *dev)
           to kick it somehow? */
        lbs_host_to_card_done(priv);
 
           to kick it somehow? */
        lbs_host_to_card_done(priv);
 
-       /* More often than not, this actually happens because the
-          firmware has crapped itself -- rather than just a very
-          busy medium. So send a harmless command, and if/when
-          _that_ times out, we'll kick it in the head. */
-       lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
-                                    0, 0, NULL);
+       /* FIXME: reset the card */
 
        lbs_deb_leave(LBS_DEB_TX);
 }
 
        lbs_deb_leave(LBS_DEB_TX);
 }