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

libertas: clean up MONITOR_MODE command



Convert to a full direct command; previous code rolled a direct
command by handle but left the original indirect command code
lying around.

Signed-off-by: default avatarDan Williams <dcbw@redhat.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 98ec6218
Loading
Loading
Loading
Loading
+3 −54
Original line number Original line Diff line number Diff line
@@ -7,7 +7,6 @@
 */
 */


#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/if_arp.h>
#include <linux/ieee80211.h>
#include <linux/ieee80211.h>
#include <net/cfg80211.h>
#include <net/cfg80211.h>
#include <asm/unaligned.h>
#include <asm/unaligned.h>
@@ -1383,56 +1382,6 @@ static int lbs_cfg_del_key(struct wiphy *wiphy, struct net_device *netdev,
}
}





/***************************************************************************
 * Monitor mode
 */

/* like "struct cmd_ds_802_11_monitor_mode", but with cmd_header. Once we
 * get rid of WEXT, this should go into host.h */
struct cmd_monitor_mode {
	struct cmd_header hdr;

	__le16 action;
	__le16 mode;
} __packed;

static int lbs_enable_monitor_mode(struct lbs_private *priv, int mode)
{
	struct cmd_monitor_mode cmd;
	int ret;

	lbs_deb_enter(LBS_DEB_CFG80211);

	/*
	 * cmd       98 00
	 * size      0c 00
	 * sequence  xx xx
	 * result    00 00
	 * action    01 00    ACT_SET
	 * enable    01 00
	 */
	memset(&cmd, 0, sizeof(cmd));
	cmd.hdr.size = cpu_to_le16(sizeof(cmd));
	cmd.action = cpu_to_le16(CMD_ACT_SET);
	cmd.mode = cpu_to_le16(mode);

	ret = lbs_cmd_with_response(priv, CMD_802_11_MONITOR_MODE, &cmd);

	if (ret == 0)
		priv->dev->type = ARPHRD_IEEE80211_RADIOTAP;
	else
		priv->dev->type = ARPHRD_ETHER;

	lbs_deb_leave(LBS_DEB_CFG80211);
	return ret;
}






/***************************************************************************
/***************************************************************************
 * Get station
 * Get station
 */
 */
@@ -1558,17 +1507,17 @@ static int lbs_change_intf(struct wiphy *wiphy, struct net_device *dev,


	switch (type) {
	switch (type) {
	case NL80211_IFTYPE_MONITOR:
	case NL80211_IFTYPE_MONITOR:
		ret = lbs_enable_monitor_mode(priv, 1);
		ret = lbs_set_monitor_mode(priv, 1);
		break;
		break;
	case NL80211_IFTYPE_STATION:
	case NL80211_IFTYPE_STATION:
		if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR)
		if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR)
			ret = lbs_enable_monitor_mode(priv, 0);
			ret = lbs_set_monitor_mode(priv, 0);
		if (!ret)
		if (!ret)
			ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, 1);
			ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, 1);
		break;
		break;
	case NL80211_IFTYPE_ADHOC:
	case NL80211_IFTYPE_ADHOC:
		if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR)
		if (priv->wdev->iftype == NL80211_IFTYPE_MONITOR)
			ret = lbs_enable_monitor_mode(priv, 0);
			ret = lbs_set_monitor_mode(priv, 0);
		if (!ret)
		if (!ret)
			ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, 2);
			ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_BSS_TYPE, 2);
		break;
		break;
+25 −17
Original line number Original line Diff line number Diff line
@@ -6,6 +6,7 @@
#include <linux/kfifo.h>
#include <linux/kfifo.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/if_arp.h>


#include "decl.h"
#include "decl.h"
#include "cfg.h"
#include "cfg.h"
@@ -576,23 +577,35 @@ int lbs_set_tx_power(struct lbs_private *priv, s16 dbm)
	return ret;
	return ret;
}
}


static int lbs_cmd_802_11_monitor_mode(struct cmd_ds_command *cmd,
/**
				      u16 cmd_action, void *pdata_buf)
 *  @brief Enable or disable monitor mode (only implemented on OLPC usb8388 FW)
 *
 *  @param priv        A pointer to struct lbs_private structure
 *  @param enable      1 to enable monitor mode, 0 to disable
 *
 *  @return            0 on success, error on failure
 */
int lbs_set_monitor_mode(struct lbs_private *priv, int enable)
{
{
	struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor;
	struct cmd_ds_802_11_monitor_mode cmd;
	int ret;


	cmd->command = cpu_to_le16(CMD_802_11_MONITOR_MODE);
	memset(&cmd, 0, sizeof(cmd));
	cmd->size =
	cmd.hdr.size = cpu_to_le16(sizeof(cmd));
	    cpu_to_le16(sizeof(struct cmd_ds_802_11_monitor_mode) +
	cmd.action = cpu_to_le16(CMD_ACT_SET);
			     sizeof(struct cmd_header));
	if (enable)
		cmd.mode = cpu_to_le16(0x1);

	lbs_deb_cmd("SET_MONITOR_MODE: %d\n", enable);


	monitor->action = cpu_to_le16(cmd_action);
	ret = lbs_cmd_with_response(priv, CMD_802_11_MONITOR_MODE, &cmd);
	if (cmd_action == CMD_ACT_SET) {
	if (ret == 0) {
		monitor->mode =
		priv->dev->type = enable ? ARPHRD_IEEE80211_RADIOTAP :
		    cpu_to_le16((u16) (*(u32 *) pdata_buf));
						ARPHRD_ETHER;
	}
	}


	return 0;
	lbs_deb_leave(LBS_DEB_CMD);
	return ret;
}
}


/**
/**
@@ -1093,11 +1106,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_MONITOR_MODE:
		ret = lbs_cmd_802_11_monitor_mode(cmdptr,
				          cmd_action, pdata_buf);
		break;

	case CMD_802_11_RSSI:
	case CMD_802_11_RSSI:
		ret = lbs_cmd_802_11_rssi(priv, cmdptr);
		ret = lbs_cmd_802_11_rssi(priv, cmdptr);
		break;
		break;
+2 −0
Original line number Original line Diff line number Diff line
@@ -129,4 +129,6 @@ int lbs_set_deep_sleep(struct lbs_private *priv, int deep_sleep);


int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep);
int lbs_set_host_sleep(struct lbs_private *priv, int host_sleep);


int lbs_set_monitor_mode(struct lbs_private *priv, int enable);

#endif /* _LBS_CMD_H */
#endif /* _LBS_CMD_H */
+3 −1
Original line number Original line Diff line number Diff line
@@ -675,7 +675,10 @@ struct cmd_ds_802_11_rf_tx_power {
	s8 minlevel;
	s8 minlevel;
} __packed;
} __packed;


/* MONITOR_MODE only exists in OLPC v5 firmware */
struct cmd_ds_802_11_monitor_mode {
struct cmd_ds_802_11_monitor_mode {
	struct cmd_header hdr;

	__le16 action;
	__le16 action;
	__le16 mode;
	__le16 mode;
} __packed;
} __packed;
@@ -966,7 +969,6 @@ struct cmd_ds_command {
	/* command Body */
	/* command Body */
	union {
	union {
		struct cmd_ds_802_11_ps_mode psmode;
		struct cmd_ds_802_11_ps_mode psmode;
		struct cmd_ds_802_11_monitor_mode monitor;
		struct cmd_ds_802_11_rssi rssi;
		struct cmd_ds_802_11_rssi rssi;
		struct cmd_ds_802_11_rssi_rsp rssirsp;
		struct cmd_ds_802_11_rssi_rsp rssirsp;
		struct cmd_ds_mac_reg_access macreg;
		struct cmd_ds_mac_reg_access macreg;