[Fwd: Re: [Fwd: Linksys and Dlink wireless access points]]

Marcelo Tosatti marcelo at kvack.org
Thu Feb 1 16:19:24 EST 2007


On Thu, Feb 01, 2007 at 10:50:55AM -0800, Lilian Walter wrote:
> Hi, Marcelo,
> 
> 1.  I can set MAC address with CMD_802_11_MAC_ADDRESS.  But I don't really
> have to because getting the MAC address with the said command returns a
> reasonable and unique value for each board that I have.
> 
> 2.  The issue is with CMD_GET_HW_SPEC.  Whenever I issue that command to the
> Marvel firmware, it returns 0s as mac address and it really zeroes out the
> reasonable mac address.
> 
> 3.  When my Dlink refuses to associate, that was because I issued the
> CMD_GET_HW_SPEC command.  And sniffing on the air confirms that the RA was
> 0.
> 
> 4.  Now that I don't do CMD_GET_HW_SPEC anymore, sniffing on the air
> confirms that the RA is the reasonable mac address.  AND, I can associate
> with the Dlink now.  Actually, I can send ethernet packets in and out of the
> Dlink AP (sniffed on the air and tcpdump on the wired side).
> 
> So, my main concern is CMD_GET_HW_SPEC.  I noticed that the linux driver
> issues one immediately after downloading the firmware and is expecting to
> get a valid mac address from the response.  That makes me rather nervous.
> That's all.

Hi Lilian, 

I've added some debugging code to the driver which: 

- reads the current MAC address with HostCmd_CMD_802_11_MAC_ADDRESS
- issues HostCmd_CMD_GET_HW_SPEC
- reads the current MAC address again

And it shows that the original MAC value is retained (ie. not zeroed as your testing 
shows).

Javier, Ronak, is there any reason why CMD_GET_HW_SPEC would zero the
MAC address?

I've attached the information discussed here in a Trac entry as a reminder:
http://dev.laptop.org/ticket/857

Here's the output from running the following code:

-bash-3.1# cat readmac
 0:17:c4: 0: 9:b5
issued HostCmd_CMD_GET_HW_SPEC
 0:17:c4: 0: 9:b5

diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 0e14ea2..c68aa38 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -1629,6 +1629,53 @@ out_unlock:
 	return res;
 }
 
+static ssize_t libertas_read_mac(struct file *file, char __user *userbuf,
+				  size_t count, loff_t *ppos)
+{
+	wlan_private *priv = file->private_data;
+	wlan_adapter *Adapter = priv->adapter;
+	char *buf = big_buffer;
+	ssize_t pos = 0;
+	ssize_t len = big_buffer_len;
+	int ret;
+
+	down(&big_buffer_sem);
+
+	ret = libertas_prepare_and_send_command(priv,
+				HostCmd_CMD_802_11_MAC_ADDRESS, HostCmd_ACT_GET,
+				HostCmd_OPTION_WAITFORRSP, 0, 0);
+
+	pos += snprintf(buf, len-pos, "%2x:%2x:%2x:%2x:%2x:%2x\n",
+               Adapter->CurrentAddr[0], Adapter->CurrentAddr[1],
+               Adapter->CurrentAddr[2], Adapter->CurrentAddr[3],
+               Adapter->CurrentAddr[4], Adapter->CurrentAddr[5]);
+
+	ret = libertas_prepare_and_send_command(priv, HostCmd_CMD_GET_HW_SPEC,
+				0, HostCmd_OPTION_WAITFORRSP, 0, NULL);
+
+	pos += snprintf(buf+pos, len-pos, "issued HostCmd_CMD_GET_HW_SPEC\n");
+
+	ret = libertas_prepare_and_send_command(priv,
+				HostCmd_CMD_802_11_MAC_ADDRESS, HostCmd_ACT_GET,
+				HostCmd_OPTION_WAITFORRSP, 0, 0);
+
+	pos += snprintf(buf+pos, len-pos, "%2x:%2x:%2x:%2x:%2x:%2x\n",
+               Adapter->CurrentAddr[0], Adapter->CurrentAddr[1],
+               Adapter->CurrentAddr[2], Adapter->CurrentAddr[3],
+               Adapter->CurrentAddr[4], Adapter->CurrentAddr[5]);
+
+	ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos);
+	up(&big_buffer_sem);
+	return ret;
+}
+
+static struct file_operations libertas_readmacaddr_fops = {
+	.owner = THIS_MODULE,
+	.open = open_file_generic,
+	.write = write_file_dummy,
+	.read = libertas_read_mac,
+};
+
 static struct file_operations libertas_devinfo_fops = { 
 	.owner = THIS_MODULE,
 	.open = open_file_generic,
@@ -1798,6 +1845,11 @@ void libertas_debugfs_init_one(wlan_priv
 						    priv,
 						    &libertas_setuserscan_fops);
 
+	priv->debugfs_readmac = debugfs_create_file("readmac", 0444,
+						    priv->debugfs_dir,
+						    priv,
+						    &libertas_readmacaddr_fops);
+
 	priv->events_dir = debugfs_create_dir("subscribed_events", priv->debugfs_dir);
 	if (!priv->events_dir)
 		goto exit;
@@ -1892,6 +1944,7 @@ #endif
 	debugfs_remove(priv->debugfs_sleepparams);
 	debugfs_remove(priv->debugfs_extscan);
 	debugfs_remove(priv->debugfs_setuserscan);
+	debugfs_remove(priv->debugfs_readmac);
 	debugfs_remove(priv->debugfs_dir);
 }
 
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index f43b137..488b645 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -146,6 +146,7 @@ struct _wlan_private {
 	struct dentry *debugfs_sleepparams;
 	struct dentry *debugfs_extscan;
 	struct dentry *debugfs_setuserscan;
+	struct dentry *debugfs_readmac;
 
 	struct dentry *events_dir;
 	struct dentry *low_rssi;



More information about the libertas-dev mailing list