Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fb7663d authored by Dan Williams's avatar Dan Williams Committed by John W. Linville
Browse files

libertas: clean up RSSI command



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: default avatarDan Williams <dcbw@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent a45b6f4f
Loading
Loading
Loading
Loading
+2 −35
Original line number Original line Diff line number Diff line
@@ -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,
static int lbs_cfg_get_station(struct wiphy *wiphy, struct net_device *dev,
			      u8 *mac, struct station_info *sinfo)
			      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;
	sinfo->rx_packets = priv->dev->stats.rx_packets;


	/* Get current RSSI */
	/* Get current RSSI */
	ret = lbs_get_signal(priv, &signal, &noise);
	ret = lbs_get_rssi(priv, &signal, &noise);
	if (ret == 0) {
	if (ret == 0) {
		sinfo->signal = signal;
		sinfo->signal = signal;
		sinfo->filled |= STATION_INFO_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,
	survey->channel = ieee80211_get_channel(wiphy,
		ieee80211_channel_to_frequency(priv->channel));
		ieee80211_channel_to_frequency(priv->channel));


	ret = lbs_get_signal(priv, &signal, &noise);
	ret = lbs_get_rssi(priv, &signal, &noise);
	if (ret == 0) {
	if (ret == 0) {
		survey->filled = SURVEY_INFO_NOISE_DBM;
		survey->filled = SURVEY_INFO_NOISE_DBM;
		survey->noise = noise;
		survey->noise = noise;
+0 −2
Original line number Original line Diff line number Diff line
@@ -14,8 +14,6 @@ int lbs_reg_notifier(struct wiphy *wiphy,
		struct regulatory_request *request);
		struct regulatory_request *request);


/* All of those are TODOs: */
/* 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_cmd_bcn_ctrl(priv, cmdptr, cmd_action) (0)
#define lbs_ret_802_11_bcn_ctrl(priv, resp) (0)
#define lbs_ret_802_11_bcn_ctrl(priv, resp) (0)


+35 −4
Original line number Original line Diff line number Diff line
@@ -12,6 +12,8 @@
#include "cfg.h"
#include "cfg.h"
#include "cmd.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,
static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
			       u8 cmd_action, void *pdata_buf)
			       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);
		ret = lbs_cmd_reg_access(cmdptr, cmd_action, pdata_buf);
		break;
		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_SET_AFC:
	case CMD_802_11_GET_AFC:
	case CMD_802_11_GET_AFC:


+2 −0
Original line number Original line Diff line number Diff line
@@ -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 */
+0 −4
Original line number Original line Diff line number Diff line
@@ -172,10 +172,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
	case CMD_RET(CMD_802_11_BEACON_STOP):
	case CMD_RET(CMD_802_11_BEACON_STOP):
		break;
		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):
	case CMD_RET(CMD_802_11D_DOMAIN_INFO):
		ret = lbs_ret_802_11d_domain_info(resp);
		ret = lbs_ret_802_11d_domain_info(resp);
		break;
		break;
Loading