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

Commit 965f8bbc authored by Luis Carlos Cobo's avatar Luis Carlos Cobo Committed by David S. Miller
Browse files

[PATCH] libertas: monitor mode support for OLPC firmware



Driver support for the monitor mode support that will be available in the next
OLPC 'bleeding edge' Marvell firmware release (most likely, 5.110.16.p2).

To activate monitor mode,

echo mode > /sys/class/net/{ethX,mshX}/device/libertas_rtap

where mode is the hex mask that specifies which frames to sniff (in short, 0x1
for data, 0x2 for all management but beacons, 0x4 for beacons). Any non zero
mode will activate the monitor mode, inhibiting transmission in ethX and mshX
interfaces and routing all the incoming traffic to a new rtapX interface that
will output the packets in 802.11+radiotap headers format.

Signed-off-by: default avatarLuis Carlos Cobo <luisca@cozybit.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9483f031
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -565,6 +565,26 @@ static int wlan_cmd_802_11_rf_tx_power(wlan_private * priv,
	return 0;
}

static int wlan_cmd_802_11_monitor_mode(wlan_private * priv,
				      struct cmd_ds_command *cmd,
				      u16 cmd_action, void *pdata_buf)
{
	struct cmd_ds_802_11_monitor_mode *monitor = &cmd->params.monitor;

	cmd->command = cpu_to_le16(CMD_802_11_MONITOR_MODE);
	cmd->size =
	    cpu_to_le16(sizeof(struct cmd_ds_802_11_monitor_mode) +
			     S_DS_GEN);

	monitor->action = cpu_to_le16(cmd_action);
	if (cmd_action == CMD_ACT_SET) {
		monitor->mode =
		    cpu_to_le16((u16) (*(u32 *) pdata_buf));
	}

	return 0;
}

static int wlan_cmd_802_11_rate_adapt_rateset(wlan_private * priv,
					      struct cmd_ds_command *cmd,
					      u16 cmd_action)
@@ -1239,6 +1259,11 @@ int libertas_prepare_and_send_command(wlan_private * priv,
		ret = wlan_cmd_mac_multicast_adr(priv, cmdptr, cmd_action);
		break;

	case CMD_802_11_MONITOR_MODE:
		ret = wlan_cmd_802_11_monitor_mode(priv, cmdptr,
				          cmd_action, pdata_buf);
		break;

	case CMD_802_11_AD_HOC_JOIN:
		ret = libertas_cmd_80211_ad_hoc_join(priv, cmdptr, pdata_buf);
		break;
+4 −3
Original line number Diff line number Diff line
@@ -113,6 +113,8 @@ struct _wlan_private {

	struct net_device_stats stats;
	struct net_device *mesh_dev; /* Virtual device */
	struct net_device *rtap_net_dev;
	struct ieee80211_device *ieee;

	struct iw_statistics wstats;
	struct wlan_mesh_stats mstats;
@@ -362,8 +364,7 @@ struct _wlan_adapter {

	struct cmd_ds_802_11_get_log logmsg;

	u32 linkmode;
	u32 radiomode;
	u32 monitormode;
	u8 fw_ready;

	u8 last_scanned_channel;
+2 −0
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@

#define CMD_FWT_ACCESS                0x0095

#define CMD_802_11_MONITOR_MODE       0x0098

#define CMD_MESH_ACCESS               0x009b

/* For the IEEE Power Save */
+6 −0
Original line number Diff line number Diff line
@@ -405,6 +405,11 @@ struct cmd_ds_802_11_rf_antenna {

};

struct cmd_ds_802_11_monitor_mode {
	u16 action;
	u16 mode;
};

struct cmd_ds_802_11_ps_mode {
	__le16 action;
	__le16 nullpktinterval;
@@ -623,6 +628,7 @@ struct cmd_ds_command {
		struct cmd_ds_802_11_snmp_mib smib;
		struct cmd_ds_802_11_rf_tx_power txp;
		struct cmd_ds_802_11_rf_antenna rant;
		struct cmd_ds_802_11_monitor_mode monitor;
		struct cmd_ds_802_11_data_rate drate;
		struct cmd_ds_802_11_rate_adapt_rateset rateset;
		struct cmd_ds_mac_multicast_adr madr;
+2 −0
Original line number Diff line number Diff line
@@ -208,6 +208,8 @@ static int if_usb_probe(struct usb_interface *intf,
	if (!(priv = libertas_add_card(cardp, &udev->dev)))
		goto dealloc;

	udev->dev.driver_data = priv;

	if (libertas_add_mesh(priv, &udev->dev))
		goto err_add_mesh;

Loading