Skip to contentSkip to conversation

cfg80211: firmware and hardware version

PATCH In review Kalle Valo 11 participants 37 messages Sep 24, 2009 – Oct 1, 2009 4 messages not in the archive

Subsystems (5)
lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

cover cfg80211: firmware and hardware version

Here's my suggestion how to provide firmware and hardware version to user space. First I was thinking adding a new nl80211 command and it looked so ugly that I decided include the versions in struct wiphy instead.

Please comment.

---

Kalle Valo (2):
at76c50x-usb: set firmware and hardware version in wiphy
cfg80211: add firmware and hardware version to wiphy

 drivers/net/wireless/at76c50x-usb.c |   15 +++++++++++++++
 include/linux/nl80211.h             |    3 +++
 include/net/cfg80211.h              |    5 +++++
 net/wireless/nl80211.c              |   11 +++++++++++
 4 files changed, 34 insertions(+), 0 deletions(-)
author
#1 lore raw

PATCH 1/2 cfg80211: add firmware and hardware version to wiphy

From: Kalle Valo <[email protected]>

It's useful to provide firmware and hardware version to user space and have a generic interface to retrieve them. Users can provide the version information in bug reports etc.

Add fields for firmware and hardware version to struct wiphy and return them to user space in NL80211_CMD_GET_WIPHY reply.

---

 include/linux/nl80211.h |    3 +++
 include/net/cfg80211.h  |    5 +++++
 net/wireless/nl80211.c  |   11 +++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)
include/linux/nl80211.h +3 -0
index a8d71ed..6d6651f 100644
@@ -714,6 +714,9 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_PID,
 
+	NL80211_ATTR_FW_VERSION,
+	NL80211_ATTR_HW_VERSION,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +5 -0
index 3d874c6..de3da19 100644
@@ -1070,6 +1070,8 @@ struct cfg80211_ops {
  * and registration/helper functions
  */
 
+#define CFG80211_VERSION_LEN 32
+
 /**
  * struct wiphy - wireless hardware description
  * @idx: the wiphy index assigned to this item
@@ -1142,6 +1144,9 @@ struct wiphy {
 	u32 frag_threshold;
 	u32 rts_threshold;
 
+	char fw_version[CFG80211_VERSION_LEN];
+	char hw_version[CFG80211_VERSION_LEN];
+
 	/* If multiple wiphys are registered and you're handed e.g.
 	 * a regular netdev with assigned ieee80211_ptr, you won't
 	 * know whether it points to a wiphy your driver has registered
net/wireless/nl80211.c +11 -0
index eddab09..9e2214e 100644
@@ -138,6 +138,14 @@ static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = {
 	[NL80211_ATTR_CIPHER_SUITE_GROUP] = { .type = NLA_U32 },
 	[NL80211_ATTR_WPA_VERSIONS] = { .type = NLA_U32 },
 	[NL80211_ATTR_PID] = { .type = NLA_U32 },
+	[NL80211_ATTR_FW_VERSION] = {
+		.type = NLA_NUL_STRING,
+		.len = CFG80211_VERSION_LEN,
+	},
+	[NL80211_ATTR_HW_VERSION] = {
+		.type = NLA_NUL_STRING,
+		.len = CFG80211_VERSION_LEN,
+	},
 };
 
 /* policy for the attributes */
@@ -420,6 +428,9 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags,
 	NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_RTS_THRESHOLD,
 		    dev->wiphy.rts_threshold);
 
+	NLA_PUT_STRING(msg, NL80211_ATTR_FW_VERSION, dev->wiphy.fw_version);
+	NLA_PUT_STRING(msg, NL80211_ATTR_HW_VERSION, dev->wiphy.hw_version);
+
 	NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS,
 		   dev->wiphy.max_scan_ssids);
 	NLA_PUT_U16(msg, NL80211_ATTR_MAX_SCAN_IE_LEN,
#2 lore raw

Re: [PATCH 1/2] cfg80211: add firmware and hardware version to wiphy

Quoted 8 lines · Kalle Valo

From: Kalle Valo <[email protected]>

It's useful to provide firmware and hardware version to user space and have a generic interface to retrieve them. Users can provide the version information in bug reports etc.

Add fields for firmware and hardware version to struct wiphy and return them to user space in NL80211_CMD_GET_WIPHY reply.

Wow that was quick :)

Quoted 13 lines

---

 include/linux/nl80211.h |    3 +++
 include/net/cfg80211.h  |    5 +++++
 net/wireless/nl80211.c  |   11 +++++++++++

 3 files changed, 19 insertions(+), 0 deletions(-)
include/linux/nl80211.h +0 -0
index a8d71ed..6d6651f 100644

include/linux/nl80211.h enum nl80211_attrs { · line 719

Quoted 6 lines
include/linux/nl80211.h +3 -0
@@ -714,6 +714,9 @@ enum nl80211_attrs {
 
        NL80211_ATTR_PID,
 
+       NL80211_ATTR_FW_VERSION,
+       NL80211_ATTR_HW_VERSION,
+

Some kdoc on this would be nice.

include/net/cfg80211.h struct cfg80211_ops { · line 1073

Quoted 12 lines
include/linux/nl80211.h +0 -0
        /* add attributes here, update the policy in nl80211.c */
 
        __NL80211_ATTR_AFTER_LAST,
include/net/cfg80211.h +1 -0
index 3d874c6..de3da19 100644
@@ -1070,6 +1070,8 @@ struct cfg80211_ops {
  * and registration/helper functions
  */
 
+#define CFG80211_VERSION_LEN 32

Probably best to just remove this or at least make this not just CFG80211_VERSION_LEN, seems like this is related to cfg80211's version somehow.

Luis

author
#3 lore raw

Re: [PATCH 1/2] cfg80211: add firmware and hardware version to wiphy

Quoted 11 lines · Luis R. Rodriguez
Quoted 8 lines · Kalle Valo

From: Kalle Valo <[email protected]>

It's useful to provide firmware and hardware version to user space and have a generic interface to retrieve them. Users can provide the version information in bug reports etc.

Add fields for firmware and hardware version to struct wiphy and return them to user space in NL80211_CMD_GET_WIPHY reply.

Wow that was quick :)

Yeah, it's easy to hack here at Plumbers :D

Quoted 7 lines
Quoted 5 lines

       NL80211_ATTR_PID,

+       NL80211_ATTR_FW_VERSION,
+       NL80211_ATTR_HW_VERSION,
+

Some kdoc on this would be nice.

Definitely. I'll add it in v2 if the implementation is ok otherwise.

Quoted 11 lines
Quoted 11 lines

       /* add attributes here, update the policy in nl80211.c */

       __NL80211_ATTR_AFTER_LAST,

include/net/cfg80211.h +0 -0
index 3d874c6..de3da19 100644
@@ -1070,6 +1070,8 @@ struct cfg80211_ops {
  * and registration/helper functions
  */
 
Quoted 5 lines

include/net/cfg80211.h struct cfg80211_ops { · line 1073

Quoted 1 line
include/net/cfg80211.h +1 -0
+#define CFG80211_VERSION_LEN 32

Probably best to just remove this or at least make this not just CFG80211_VERSION_LEN, seems like this is related to cfg80211's version somehow.

The length is used four time so I would not want to remove it. Maybe rename to CFG80211_FWHW_VERSION_LEN?

Kalle

#4 lore raw

Re: [PATCH 1/2] cfg80211: add firmware and hardware version to wiphy

Quoted 2 lines · Kalle Valo

The length is used four time so I would not want to remove it. Maybe rename to CFG80211_FWHW_VERSION_LEN?

Sure.

Luis

author
#5 lore raw

PATCH 2/2 at76c50x-usb: set firmware and hardware version in wiphy

In reply to Kalle Valo

Set firmware and hardware version in wiphy so that user space can access it.

---

 drivers/net/wireless/at76c50x-usb.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/net/wireless/at76c50x-usb.c +15 -0
index 8e1a55d..b6de657 100644
@@ -2217,6 +2217,8 @@ static struct ieee80211_supported_band at76_supported_band = {
 static int at76_init_new_device(struct at76_priv *priv,
 				struct usb_interface *interface)
 {
+	struct wiphy *wiphy;
+	size_t len;
 	int ret;
 
 	/* set up the endpoint information */
@@ -2254,6 +2256,7 @@ static int at76_init_new_device(struct at76_priv *priv,
 	priv->device_unplugged = 0;
 
 	/* mac80211 initialisation */
+	wiphy = priv->hw->wiphy;
 	priv->hw->wiphy->max_scan_ssids = 1;
 	priv->hw->wiphy->max_scan_ie_len = 0;
 	priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
@@ -2265,6 +2268,18 @@ static int at76_init_new_device(struct at76_priv *priv,
 	SET_IEEE80211_DEV(priv->hw, &interface->dev);
 	SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
 
+	len = sizeof(wiphy->fw_version);
+	snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+		 priv->fw_version.major, priv->fw_version.minor,
+		 priv->fw_version.patch, priv->fw_version.build);
+
+	len = sizeof(wiphy->hw_version);
+	snprintf(wiphy->hw_version, len, "%d", priv->board_type);
+
+	/* null terminate the strings in case they were truncated */
+	wiphy->fw_version[len - 1] = '\0';
+	wiphy->hw_version[len - 1] = '\0';
+
 	ret = ieee80211_register_hw(priv->hw);
 	if (ret) {
 		printk(KERN_ERR "cannot register mac80211 hw (status %d)!\n",
#6 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 31 lines · Kalle Valo

Set firmware and hardware version in wiphy so that user space can access it.

---

 drivers/net/wireless/at76c50x-usb.c |   15 +++++++++++++++

 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/net/wireless/at76c50x-usb.c +3 -0
index 8e1a55d..b6de657 100644
@@ -2217,6 +2217,8 @@ static struct ieee80211_supported_band at76_supported_band = {
  static int at76_init_new_device(struct at76_priv *priv,
                                struct usb_interface *interface)
  {
+       struct wiphy *wiphy;
+       size_t len;
        int ret;
 
        /* set up the endpoint information */
@@ -2254,6 +2256,7 @@ static int at76_init_new_device(struct at76_priv *priv,
        priv->device_unplugged = 0;
 
        /* mac80211 initialisation */
+       wiphy = priv->hw->wiphy;
        priv->hw->wiphy->max_scan_ssids = 1;
        priv->hw->wiphy->max_scan_ie_len = 0;
        priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);

drivers/net/wireless/at76c50x-usb.c static int at76_init_new_device(struct at76_priv *priv, · line 2277

Quoted 10 lines
drivers/net/wireless/at76c50x-usb.c +7 -0
@@ -2265,6 +2268,18 @@ static int at76_init_new_device(struct at76_priv *priv,
        SET_IEEE80211_DEV(priv->hw, &interface->dev);
        SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
 
+       len = sizeof(wiphy->fw_version);
+       snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+                priv->fw_version.major, priv->fw_version.minor,
+                priv->fw_version.patch, priv->fw_version.build);
+
+       len = sizeof(wiphy->hw_version);
+       snprintf(wiphy->hw_version, len, "%d", priv->board_type);

So ath9k and ath5k keep their own strings for such things, to name the MAC/Baseband, and then the radio revision and subrevisions... What I'd like to see documented on the kdoc for hw_version is what exactly is expected to be put there.

The hw_version and fw_version seem to be helpful in providing more information to userspace which you would not typically see -- things you would only tend to see on a dmesg output so at least for that purpose I think its nice. For example lspci won't really tell you the exact hardware type on atheros chipsets, so this seems nice.

Anyway, getting some more clarification on the docs would be nice.

Luis

author
#7 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 10 lines · Luis R. Rodriguez

So ath9k and ath5k keep their own strings for such things, to name the MAC/Baseband, and then the radio revision and subrevisions... What I'd like to see documented on the kdoc for hw_version is what exactly is expected to be put there.

The hw_version and fw_version seem to be helpful in providing more information to userspace which you would not typically see -- things you would only tend to see on a dmesg output so at least for that purpose I think its nice. For example lspci won't really tell you the exact hardware type on atheros chipsets, so this seems nice.

Exactly, that's my idea here. And with this the information should be easy to show in UI.

Quoted 1 line

Anyway, getting some more clarification on the docs would be nice.

I will definitely add documentation. I meant to send these patches RFC for the implementation idea, but forgot to do it.

BTW, is there an easy way to get the module name for the interface? That's also helpful information for the user.

Kalle

#8 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 2 lines · Kalle Valo

BTW, is there an easy way to get the module name for the interface? That's also helpful information for the user.

If you can map the interface to PCI ID then I think its possible, lspci -k seems to do it. It would be a nice addition to iw output as well IMHO.

Luis

author
#9 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 7 lines · Luis R. Rodriguez
Quoted 2 lines · Kalle Valo

BTW, is there an easy way to get the module name for the interface? That's also helpful information for the user.

If you can map the interface to PCI ID then I think its possible, lspci -k seems to do it.

Not all drivers use PCI, we have USB, SDIO, SPI and so on.

Quoted 1 line

It would be a nice addition to iw output as well IMHO.

I agree. I'm not going to work on adding the driver name right now, but maybe in the future.

Kalle

#10 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 10 lines · Kalle Valo
Quoted 7 lines · Luis R. Rodriguez
Quoted 2 lines · Kalle Valo

BTW, is there an easy way to get the module name for the interface? That's also helpful information for the user.

If you can map the interface to PCI ID then I think its possible, lspci -k seems to do it.

Not all drivers use PCI, we have USB, SDIO, SPI and so on.

Sure, it was just an example of a transport where this does exist, I am hoping this doesn't use PCI specific stuff and based on a simple strace of "strace -o foo lspci -k -s 03:00.0" I see it actually ends up reading a /lib/modules/ file and am hoping this is what it uses to do the mapping. But you still first need the bus ID for the netdevice, not sure how to best to do that. I do see the sysfs ieee80211 class maps the phy%d to the bus:

mcgrof@tux ~ $ ls -ld /sys/class/ieee80211/phy0/device lrwxrwxrwx 1 root root 0 2009-09-25 12:25 /sys/class/ieee80211/phy0/device -> ../../../0000:03:00.0

If you can extract the bus from here and then the device:vendor id I think you can read the /lib/modules/ map file for the driver.

Check these files out:

ls /lib/modules/2.6.31-wl/modules.*map

Luis

maintainer
#11 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

In reply to Kalle Valo
Quoted 2 lines · Kalle Valo

I agree. I'm not going to work on adding the driver name right now, but maybe in the future.

$ readlink /sys/class/net/wlan0/phy80211/device/driver/module

johannes

author
#12 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 6 lines · Johannes Berg
Quoted 2 lines · Kalle Valo

I agree. I'm not going to work on adding the driver name right now, but maybe in the future.

$ readlink /sys/class/net/wlan0/phy80211/device/driver/module

Excellent, that shows the driver name easily enough. Thanks.

Kalle

#13 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

In reply to Kalle Valo

drivers/net/wireless/at76c50x-usb.c static int at76_init_new_device(struct at76_priv *priv, · line 2281

Quoted 11 lines · Kalle Valo
drivers/net/wireless/at76c50x-usb.c +11 -0
+	len = sizeof(wiphy->fw_version);
+	snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+		 priv->fw_version.major, priv->fw_version.minor,
+		 priv->fw_version.patch, priv->fw_version.build);
+
+	len = sizeof(wiphy->hw_version);
+	snprintf(wiphy->hw_version, len, "%d", priv->board_type);
+
+	/* null terminate the strings in case they were truncated */
+	wiphy->fw_version[len - 1] = '\0';
+	wiphy->hw_version[len - 1] = '\0';

This only works as long as sizeof(wiphy->fw_version) == sizeof(wiphy->hw_version) - which is currently the case. For sizeof(wiphy->fw_version) < sizeof(wiphy_hw_version) it overwrites memory behind wiphy->fw_version.

IMHO this is more robust against changes in the lengths of the char arrays:

+ wiphy->fw_version[sizeof(wiphy->fw_version) - 1] = '\0';
+ wiphy->hw_version[sizeof(wiphy->hw_version) - 1] = '\0';

Regards,
Jörg.

author
#14 lore raw

Re: [PATCH 2/2] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 16 lines · Joerg Albert

drivers/net/wireless/at76c50x-usb.c static int at76_init_new_device(struct at76_priv *priv, · line 2281

Quoted 11 lines · Kalle Valo

+     len = sizeof(wiphy->fw_version);
+     snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+              priv->fw_version.major, priv->fw_version.minor,
+              priv->fw_version.patch, priv->fw_version.build);

drivers/net/wireless/at76c50x-usb.c +7 -0
+
+     len = sizeof(wiphy->hw_version);
+     snprintf(wiphy->hw_version, len, "%d", priv->board_type);
+
+     /* null terminate the strings in case they were truncated */
+     wiphy->fw_version[len - 1] = '\0';
+     wiphy->hw_version[len - 1] = '\0';

This only works as long as sizeof(wiphy->fw_version) == sizeof(wiphy->hw_version) - which is currently the case. For sizeof(wiphy->fw_version) < sizeof(wiphy_hw_version) it overwrites memory behind wiphy->fw_version.

Good point, thanks for catching that.

Quoted 4 lines

IMHO this is more robust against changes in the lengths of the char arrays:

+       wiphy->fw_version[sizeof(wiphy->fw_version) - 1] = '\0';
+       wiphy->hw_version[sizeof(wiphy->hw_version) - 1] = '\0';

Actually Christian pointed out that snprintf() always null terminates the string and all this unnecessary. So I'll just remove this in v2.

Kalle

#15 lore raw

PATCH 1/2 iw: update nl80211.h from wireless-testing

In reply to Kalle Valo

---

 nl80211.h |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
nl80211.h +21 -5
index 962e223..a8d71ed 100644
@@ -262,6 +262,9 @@
  *	reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
  *	%NL80211_ATTR_REASON_CODE attributes are used.
  *
+ * @NL80211_CMD_SET_WIPHY_NETNS: Set a wiphy's netns. Note that all devices
+ *	associated with this wiphy must be down and will follow.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -336,6 +339,8 @@ enum nl80211_commands {
 	NL80211_CMD_ROAM,
 	NL80211_CMD_DISCONNECT,
 
+	NL80211_CMD_SET_WIPHY_NETNS,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -475,10 +480,6 @@ enum nl80211_commands {
  * @NL80211_ATTR_SCAN_FREQUENCIES: nested attribute with frequencies (in MHz)
  * @NL80211_ATTR_SCAN_SSIDS: nested attribute with SSIDs, leave out for passive
  *	scanning and include a zero-length SSID (wildcard) for wildcard scan
- * @NL80211_ATTR_SCAN_GENERATION: the scan generation increases whenever the
- *	scan result list changes (BSS expired or added) so that applications
- *	can verify that they got a single, consistent snapshot (when all dump
- *	messages carried the same generation number)
  * @NL80211_ATTR_BSS: scan result BSS
  *
  * @NL80211_ATTR_REG_INITIATOR: indicates who requested the regulatory domain
@@ -573,6 +574,16 @@ enum nl80211_commands {
  *	and join_ibss(), key information is in a nested attribute each
  *	with %NL80211_KEY_* sub-attributes
  *
+ * @NL80211_ATTR_PID: Process ID of a network namespace.
+ *
+ * @NL80211_ATTR_GENERATION: Used to indicate consistent snapshots for
+ *	dumps. This number increases whenever the object list being
+ *	dumped changes, and as such userspace can verify that it has
+ *	obtained a complete and consistent snapshot by verifying that
+ *	all dump messages contain the same generation number. If it
+ *	changed then the list changed and the dump should be repeated
+ *	completely from scratch.
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -644,7 +655,7 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_SCAN_FREQUENCIES,
 	NL80211_ATTR_SCAN_SSIDS,
-	NL80211_ATTR_SCAN_GENERATION,
+	NL80211_ATTR_GENERATION, /* replaces old SCAN_GENERATION */
 	NL80211_ATTR_BSS,
 
 	NL80211_ATTR_REG_INITIATOR,
@@ -701,12 +712,17 @@ enum nl80211_attrs {
 	NL80211_ATTR_KEY,
 	NL80211_ATTR_KEYS,
 
+	NL80211_ATTR_PID,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
 	NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
 };
 
+/* source-level API compatibility */
+#define NL80211_ATTR_SCAN_GENERATION NL80211_ATTR_GENERATION
+
 /*
  * Allow user space programs to use #ifdef on new attributes by defining them
  * here
#16 lore raw

PATCH 2/2 iw: print firmware and hardware version

In reply to Kalle Valo

struct wiphy now contains firmware and hardware version, print that information to the user.
---

 info.c    |   15 +++++++++++++++
 nl80211.h |    3 +++
 2 files changed, 18 insertions(+), 0 deletions(-)
info.c +15 -0
index 7bca69d..ae3ed54 100644
@@ -66,6 +66,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	struct nlattr *nl_freq;
 	struct nlattr *nl_rate;
 	struct nlattr *nl_mode;
+	const char *str;
 	int bandidx = 1;
 	int rem_band, rem_freq, rem_rate, rem_mode;
 	int open;
@@ -263,6 +264,20 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 			printf("\tRTS threshold: %d\n", rts);
 	}
 
+	if (tb_msg[NL80211_ATTR_FW_VERSION]) {
+		str = nla_get_string(tb_msg[NL80211_ATTR_FW_VERSION]);
+		if (strlen(str) == 0)
+			str = "<unknown>";
+		printf("\tFirmware version: %s\n", str);
+	}
+
+	if (tb_msg[NL80211_ATTR_HW_VERSION]) {
+		str = nla_get_string(tb_msg[NL80211_ATTR_HW_VERSION]);
+		if (strlen(str) == 0)
+			str = "<unknown>";
+		printf("\tHardware version: %s\n", str);
+	}
+
 	if (!tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES])
 		return NL_SKIP;
 
nl80211.h +3 -0
index a8d71ed..6d6651f 100644
@@ -714,6 +714,9 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_PID,
 
+	NL80211_ATTR_FW_VERSION,
+	NL80211_ATTR_HW_VERSION,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
#17 lore raw
In reply to Kalle Valo
Quoted 6 lines · Kalle Valo

Here's my suggestion how to provide firmware and hardware version to user space. First I was thinking adding a new nl80211 command and it looked so ugly that I decided include the versions in struct wiphy instead.

Please comment.

What was the conclusion on ethtool stuff again? I forgot.

Luis

#18 lore raw
Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines · Kalle Valo

Here's my suggestion how to provide firmware and hardware version to user space. First I was thinking adding a new nl80211 command and it looked so ugly that I decided include the versions in struct wiphy instead.

Please comment.

What was the conclusion on ethtool stuff again? I forgot.

IIRC, I suggested that the cfg80211 driver API (or just the wiphy data structure) could be extended for appropriate bits like this, then cfg80211 could catch ethtool operations in a way similar to how it catches wireless extensions now.

I was thinking to look at this after I get home, maybe next week. Others are welcome to beat me to it, of course. :-)

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
author
#19 lore raw
Quoted 7 lines · John W. Linville
Quoted 6 lines · Luis R. Rodriguez
Quoted 5 lines · Kalle Valo

Here's my suggestion how to provide firmware and hardware version to user space. First I was thinking adding a new nl80211 command and it looked so ugly that I decided include the versions in struct wiphy instead.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Please comment.

What was the conclusion on ethtool stuff again? I forgot.

IIRC, I suggested that the cfg80211 driver API (or just the wiphy data structure) could be extended for appropriate bits like this, then cfg80211 could catch ethtool operations in a way similar to how it catches wireless extensions now.

Oh, then I misunderstood our discussion at the summit, my understanding was that we will use nl80211 anyway. Sorry about that.

But we want to export two strings to user space (at least for now), is it really worth the effort to add ethtool support for such a minor feature? Also I have understood that ethtool is implemented only for ethernet drivers, I don't feel comfortable that we use ethernet driver interfaces with 802.11 device drivers. They are so much different that there isn't that much common functionality. That's why I prefer nl80211 over ethtool.

What do people think?

Kalle

#20 lore raw
Quoted 29 lines · Kalle Valo
Quoted 7 lines · John W. Linville
Quoted 6 lines · Luis R. Rodriguez
Quoted 5 lines · Kalle Valo

Here's my suggestion how to provide firmware and hardware version to user space. First I was thinking adding a new nl80211 command and it looked so ugly that I decided include the versions in struct wiphy instead.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Please comment.

What was the conclusion on ethtool stuff again? I forgot.

IIRC, I suggested that the cfg80211 driver API (or just the wiphy data structure) could be extended for appropriate bits like this, then cfg80211 could catch ethtool operations in a way similar to how it catches wireless extensions now.

Oh, then I misunderstood our discussion at the summit, my understanding was that we will use nl80211 anyway. Sorry about that.

But we want to export two strings to user space (at least for now), is it really worth the effort to add ethtool support for such a minor feature? Also I have understood that ethtool is implemented only for ethernet drivers, I don't feel comfortable that we use ethernet driver interfaces with 802.11 device drivers. They are so much different that there isn't that much common functionality. That's why I prefer nl80211 over ethtool.

Quoted 1 line

What do people think?

So for Wake-on-Wireless I ran into the same, ethtool just did not offer the same wake up events needed for wireless. I could have technically used ethtool and expanded it to support wireless but it just seemed dirty.

I agree that using ethtool seems overkill compared to the patches you posted.

Luis

#21 lore raw
Quoted 10 lines · Luis R. Rodriguez
Quoted 8 lines · Kalle Valo

But we want to export two strings to user space (at least for now), is it really worth the effort to add ethtool support for such a minor feature? Also I have understood that ethtool is implemented only for ethernet drivers, I don't feel comfortable that we use ethernet driver interfaces with 802.11 device drivers. They are so much different that there isn't that much common functionality. That's why I prefer nl80211 over ethtool.

Quoted 8 lines
Quoted 1 line

What do people think?

So for Wake-on-Wireless I ran into the same, ethtool just did not offer the same wake up events needed for wireless. I could have technically used ethtool and expanded it to support wireless but it just seemed dirty.

I agree that using ethtool seems overkill compared to the patches you posted.

I think you either overestimate the amount of trouble for implementing (minimal) ethtool support or you underestimate the amount of functionality available through that interface. That, or you just don't like using something named "eth"tool for wireless -- but hey, let's be honest about the frames we send/receive to/from the kernel... :-)

The ethtool interface provides functionality for viewing and modifying eeprom contents, dumping registers, trigger self-tests, basic driver info, getting and setting message reporting levels, external card identification (hey, _could_ be useful!), and some other bits like checksum offload that might(?) be useful in the future. I understand regarding the WoW vs. WoL issue but probably the answer is just to add a new method for WoW...?

I'll post a patch series based on what Kalle sent but using ethtool instead of nl80211...

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#23 lore raw

PATCH 1/3 wireless: implement basic ethtool support for cfg80211 devices

---
 net/wireless/Makefile  |    2 +-
 net/wireless/core.c    |    3 +++
 net/wireless/ethtool.c |   27 +++++++++++++++++++++++++++
 net/wireless/ethtool.h |   10 ++++++++++
 4 files changed, 41 insertions(+), 1 deletions(-)
 create mode 100644 net/wireless/ethtool.c
 create mode 100644 net/wireless/ethtool.h
net/wireless/Makefile +1 -1
index c814150..f07c8dc 100644
@@ -10,7 +10,7 @@ obj-$(CONFIG_WEXT_SPY) += wext-spy.o
 obj-$(CONFIG_WEXT_PRIV) += wext-priv.o
 
 cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o
-cfg80211-y += mlme.o ibss.o sme.o chan.o
+cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o
 cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o
 cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o
 
net/wireless/core.c +3 -0
index c761532..faada5c 100644
@@ -21,6 +21,7 @@
 #include "sysfs.h"
 #include "debugfs.h"
 #include "wext-compat.h"
+#include "ethtool.h"
 
 /* name for sysfs, %d is appended */
 #define PHY_NAME "phy"
@@ -683,6 +684,8 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
 				wdev->wext.ps = false;
 			}
 #endif
+		if (!dev->ethtool_ops)
+			dev->ethtool_ops = &cfg80211_ethtool_ops;
 		break;
 	case NETDEV_GOING_DOWN:
 		switch (wdev->iftype) {
net/wireless/ethtool.c new file +27 -0
new file mode 100644
index 0000000..94ca377
@@ -0,0 +1,27 @@
+#include <linux/utsrelease.h>
+#include <net/cfg80211.h>
+#include "ethtool.h"
+
+const struct ethtool_ops cfg80211_ethtool_ops = {
+	.get_drvinfo = cfg80211_get_drvinfo,
+	.get_link = ethtool_op_get_link,
+};
+
+void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+
+	strncpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
+		sizeof(info->driver));
+	info->driver[sizeof(info->driver) - 1] = '\0';
+
+	strncpy(info->version, UTS_RELEASE, sizeof(info->version));
+	info->version[sizeof(info->version) - 1] = '\0';
+
+	strncpy(info->fw_version, "N/A", sizeof(info->fw_version));
+	info->fw_version[sizeof(info->fw_version) - 1] = '\0';
+
+	strncpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
+		sizeof(info->bus_info));
+	info->bus_info[sizeof(info->bus_info) - 1] = '\0';
+}
net/wireless/ethtool.h new file +10 -0
new file mode 100644
index 0000000..a51b470
@@ -0,0 +1,10 @@
+#ifndef __CFG80211_ETHTOOL__
+#define __CFG80211_ETHTOOL__
+
+#include <linux/ethtool.h>
+
+extern void cfg80211_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
+
+extern const struct ethtool_ops cfg80211_ethtool_ops;
+
+#endif /* __CFG80211_ETHTOOL__ */
Signature · 6 lines
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#24 lore raw

PATCH 2/3 cfg80211: add firmware and hardware version to wiphy

From: Kalle Valo <[email protected]>

It's useful to provide firmware and hardware version to user space and have a generic interface to retrieve them. Users can provide the version information in bug reports etc.

Add fields for firmware and hardware version to struct wiphy.

(Dropped nl80211 bits for now and modified remaining bits in favor of ethtool. -- JWL)

---
 include/net/cfg80211.h |    3 +++
 net/wireless/ethtool.c |   23 ++++++++++++++++++++++-
 net/wireless/ethtool.h |    3 +++
 3 files changed, 28 insertions(+), 1 deletions(-)
include/net/cfg80211.h +3 -0
index 241ea14..6f4862b 100644
@@ -1142,6 +1142,9 @@ struct wiphy {
 	u32 frag_threshold;
 	u32 rts_threshold;
 
+	char fw_version[ETHTOOL_BUSINFO_LEN];
+	u32 hw_version;
+
 	/* If multiple wiphys are registered and you're handed e.g.
 	 * a regular netdev with assigned ieee80211_ptr, you won't
 	 * know whether it points to a wiphy your driver has registered
net/wireless/ethtool.c +22 -1
index 94ca377..3c59549 100644
@@ -4,6 +4,8 @@
 
 const struct ethtool_ops cfg80211_ethtool_ops = {
 	.get_drvinfo = cfg80211_get_drvinfo,
+	.get_regs_len = cfg80211_get_regs_len,
+	.get_regs = cfg80211_get_regs,
 	.get_link = ethtool_op_get_link,
 };
 
@@ -18,10 +20,29 @@ void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
 	strncpy(info->version, UTS_RELEASE, sizeof(info->version));
 	info->version[sizeof(info->version) - 1] = '\0';
 
-	strncpy(info->fw_version, "N/A", sizeof(info->fw_version));
+	if (wdev->wiphy->fw_version[0])
+		strncpy(info->fw_version, wdev->wiphy->fw_version,
+			sizeof(info->fw_version));
+	else
+		strncpy(info->fw_version, "N/A", sizeof(info->fw_version));
 	info->fw_version[sizeof(info->fw_version) - 1] = '\0';
 
 	strncpy(info->bus_info, dev_name(wiphy_dev(wdev->wiphy)),
 		sizeof(info->bus_info));
 	info->bus_info[sizeof(info->bus_info) - 1] = '\0';
 }
+
+int cfg80211_get_regs_len(struct net_device *dev)
+{
+	/* For now, return 0... */
+	return 0;
+}
+
+void cfg80211_get_regs(struct net_device *dev, struct ethtool_regs *regs,
+			void *data)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+
+	regs->version = wdev->wiphy->hw_version;
+	regs->len = 0;
+}
net/wireless/ethtool.h +3 -0
index a51b470..2d4602a 100644
@@ -4,6 +4,9 @@
 #include <linux/ethtool.h>
 
 extern void cfg80211_get_drvinfo(struct net_device *, struct ethtool_drvinfo *);
+extern int cfg80211_get_regs_len(struct net_device *);
+extern void cfg80211_get_regs(struct net_device *, struct ethtool_regs *,
+				void *);
 
 extern const struct ethtool_ops cfg80211_ethtool_ops;
 
Signature · 1 line
1.6.2.5

A message that is not in the archive (sent off-list or not yet received): 1254359942-3483-2-git-send-email-linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org

#26 lore raw

PATCH 3/3 at76c50x-usb: set firmware and hardware version in wiphy

From: Kalle Valo <[email protected]>

Set firmware and hardware version in wiphy so that user space can access it.

(Modification from original in favor of cfg80211 ethtool support. -- JWL)

---
 drivers/net/wireless/at76c50x-usb.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/net/wireless/at76c50x-usb.c +12 -0
index 8e1a55d..533954d 100644
@@ -2217,6 +2217,8 @@ static struct ieee80211_supported_band at76_supported_band = {
 static int at76_init_new_device(struct at76_priv *priv,
 				struct usb_interface *interface)
 {
+	struct wiphy *wiphy;
+	size_t len;
 	int ret;
 
 	/* set up the endpoint information */
@@ -2254,6 +2256,7 @@ static int at76_init_new_device(struct at76_priv *priv,
 	priv->device_unplugged = 0;
 
 	/* mac80211 initialisation */
+	wiphy = priv->hw->wiphy;
 	priv->hw->wiphy->max_scan_ssids = 1;
 	priv->hw->wiphy->max_scan_ie_len = 0;
 	priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
@@ -2265,6 +2268,15 @@ static int at76_init_new_device(struct at76_priv *priv,
 	SET_IEEE80211_DEV(priv->hw, &interface->dev);
 	SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr);
 
+	len = sizeof(wiphy->fw_version);
+	snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+		 priv->fw_version.major, priv->fw_version.minor,
+		 priv->fw_version.patch, priv->fw_version.build);
+	/* null terminate the strings in case they were truncated */
+	wiphy->fw_version[len - 1] = '\0';
+
+	wiphy->hw_version = priv->board_type;
+
 	ret = ieee80211_register_hw(priv->hw);
 	if (ret) {
 		printk(KERN_ERR "cannot register mac80211 hw (status %d)!\n",
Signature · 6 lines
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#27 lore raw

Re: [PATCH 3/3] at76c50x-usb: set firmware and hardware version in wiphy

On Wed, 2009-09-30 at 21:19 -0400, John W. Linville wrote:
[...]

drivers/net/wireless/at76c50x-usb.c static int at76_init_new_device(struct at76_priv *priv, · line 2276

Quoted 6 lines
drivers/net/wireless/at76c50x-usb.c +6 -0
+	len = sizeof(wiphy->fw_version);
+	snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+		 priv->fw_version.major, priv->fw_version.minor,
+		 priv->fw_version.patch, priv->fw_version.build);
+	/* null terminate the strings in case they were truncated */
+	wiphy->fw_version[len - 1] = '\0';

[...]

This last statement is unnecessary; snprintf() always null-terminates (unless the length is zero).

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
author
#28 lore raw

Re: [PATCH 3/3] at76c50x-usb: set firmware and hardware version in wiphy

Quoted 10 lines · Ben Hutchings

On Wed, 2009-09-30 at 21:19 -0400, John W. Linville wrote:
[...]

Quoted 6 lines
drivers/net/wireless/at76c50x-usb.c +6 -0
+	len = sizeof(wiphy->fw_version);
+	snprintf(wiphy->fw_version, len, "%d.%d.%d-%d",
+		 priv->fw_version.major, priv->fw_version.minor,
+		 priv->fw_version.patch, priv->fw_version.build);
+	/* null terminate the strings in case they were truncated */
+	wiphy->fw_version[len - 1] = '\0';

[...]

Quoted 2 lines

This last statement is unnecessary; snprintf() always null-terminates (unless the length is zero).

Yes, the extra null termination is unnecessary. This was my mistake in the first patchset I sent.

Signature · 1 line
Kalle Valo
#29 lore raw

Re: [PATCH 1/3] wireless: implement basic ethtool support for cfg80211 devices

In reply to John W. Linville

On Wed, 2009-09-30 at 21:19 -0400, John W. Linville wrote:
[...]

net/wireless/ethtool.c line 16

Quoted 7 lines
net/wireless/ethtool.c new file +7 -0
+void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+	struct wireless_dev *wdev = dev->ieee80211_ptr;
+
+	strncpy(info->driver, wiphy_dev(wdev->wiphy)->driver->name,
+		sizeof(info->driver));
+	info->driver[sizeof(info->driver) - 1] = '\0';

[...]

Use strlcpy() instead of these two statements.

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

A message that is not in the archive (sent off-list or not yet received): 1254359942-3483-1-git-send-email-linville-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org

#31 lore raw

Re: [PATCH 1/3] wireless: implement basic ethtool support for cfg80211 devices

net/wireless/core.c static int cfg80211_netdev_notifier_call(struct notifier_block * nb, · line 689

Quoted 3 lines · John W. Linville
net/wireless/core.c +2 -0
+		if (!dev->ethtool_ops)
+			dev->ethtool_ops = &cfg80211_ethtool_ops;
 		break;

I might go so far and do it unconditionally so we get consistent functionality across things. OTOH, full-mac drivers might be able to support more.

net/wireless/ethtool.c line 10

Quoted 6 lines
net/wireless/ethtool.c new file +6 -0
+const struct ethtool_ops cfg80211_ethtool_ops = {
+	.get_drvinfo = cfg80211_get_drvinfo,
+	.get_link = ethtool_op_get_link,
+};
+
+void cfg80211_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)

if you change the order, you can make the latter static

johannes

author
#32 lore raw
In reply to John W. Linville
Quoted 7 lines · John W. Linville
Quoted 5 lines · Luis R. Rodriguez

So for Wake-on-Wireless I ran into the same, ethtool just did not offer the same wake up events needed for wireless. I could have technically used ethtool and expanded it to support wireless but it just seemed dirty.

Quoted 6 lines
Quoted 2 lines

I agree that using ethtool seems overkill compared to the patches you posted.

I think you either overestimate the amount of trouble for implementing (minimal) ethtool support or you underestimate the amount of functionality available through that interface.

I'm not worried about the implementation complexity, and as your patches show it was easy. My concern is the overall design for wireless devices. Instead of using nl80211 for everything, with some features we would use nl80211/iw and with some ethtool. That's just confusing and I don't like that. I would prefer that nl80211 provides everything, it makes things so much easier.

Quoted 3 lines

That, or you just don't like using something named "eth"tool for wireless -- but hey, let's be honest about the frames we send/receive to/from the kernel... :-)

I don't have a problem with the name :) But ethernet is still so much different from 802.11 that there isn't that much to share and we in wireless will need different features.

One example is the hw version, ethtool only provides u32 to userspace and moves the burden of translating hw id to the user. For us a string is much better choise because when debuggin we need to often (or always?) know the chip version.

But this is not something I will start fighting about. If you still think that ethtool is the way to go, I'm perfectly fine with it.

Quoted 7 lines
Quoted 1 line

The ethtool interface provides functionality for viewing and modifying

eeprom contents, dumping registers, trigger self-tests, basic driver info, getting and setting message reporting levels, external card identification (hey, _could_ be useful!), and some other bits like checksum offload that might(?) be useful in the future. I understand regarding the WoW vs. WoL issue but probably the answer is just to add a new method for WoW...?

I took a look at ethtool help output from debian unstable and I think this is the set of features we can use in wireless:

ethtool -i|--driver DEVNAME Show driver information
ethtool -d|--register-dump DEVNAME Do a register dump
[ raw on|off ]
[ file FILENAME ]
ethtool -e|--eeprom-dump DEVNAME Do a EEPROM dump
[ raw on|off ]
[ offset N ]
[ length N ]
ethtool -E|--change-eeprom DEVNAME Change bytes in device
EEPROM
[ magic N ]
[ offset N ]
[ value N ]
ethtool -p|--identify DEVNAME Show visible port
identification (e.g. blinking)
[ TIME-IN-SECONDS ]
ethtool -t|--test DEVNAME Execute adapter self test
[ online | offline ]

But here are the features which I doubt we will ever use:

ethtool -s|--change DEVNAME Change generic options
[ speed %%d ]
[ duplex half|full ]
[ port tp|aui|bnc|mii|fibre ]
[ autoneg on|off ]
[ advertise %%x ]
[ phyad %%d ]
[ xcvr internal|external ]
[ wol p|u|m|b|a|g|s|d... ]
[ sopass %%x:%%x:%%x:%%x:%%x:%%x ]
[ msglvl %%d ]
ethtool -a|--show-pause DEVNAME Show pause options
ethtool -A|--pause DEVNAME Set pause options
[ autoneg on|off ]
[ rx on|off ]
[ tx on|off ]
ethtool -c|--show-coalesce DEVNAME Show coalesce options
ethtool -C|--coalesce DEVNAME Set coalesce options
[adaptive-rx on|off]
[adaptive-tx on|off]
[rx-usecs N]
[rx-frames N]
[rx-usecs-irq N]
[rx-frames-irq N]
[tx-usecs N]
[tx-frames N]
[tx-usecs-irq N]
[tx-frames-irq N]
[stats-block-usecs N]
[pkt-rate-low N]
[rx-usecs-low N]
[rx-frames-low N]
[tx-usecs-low N]
[tx-frames-low N]
[pkt-rate-high N]
[rx-usecs-high N]
[rx-frames-high N]
[tx-usecs-high N]
[tx-frames-high N]
[sample-interval N]
ethtool -g|--show-ring DEVNAME Query RX/TX ring parameters
ethtool -G|--set-ring DEVNAME Set RX/TX ring parameters
[ rx N ]
[ rx-mini N ]
[ rx-jumbo N ]
[ tx N ]
ethtool -k|--show-offload DEVNAME Get protocol offload
information
ethtool -K|--offload DEVNAME Set protocol offload
[ rx on|off ]
[ tx on|off ]
[ sg on|off ]
[ tso on|off ]
[ ufo on|off ]
[ gso on|off ]
[ gro on|off ]
[ lro on|off ]
ethtool -r|--negotiate DEVNAME Restart N-WAY negotation
ethtool -n|--show-nfc DEVNAME Show Rx network flow
classificationoptions
[ rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 ]
ethtool -N|--config-nfc DEVNAME Configure Rx network flow
classification options
[ rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 m|v|t|s|d|f|n|r... ]

Signature · 1 line
Kalle Valo
#33 lore raw
Quoted 16 lines · Kalle Valo
Quoted 7 lines · John W. Linville
Quoted 5 lines · Luis R. Rodriguez

So for Wake-on-Wireless I ran into the same, ethtool just did not offer the same wake up events needed for wireless. I could have technically used ethtool and expanded it to support wireless but it just seemed dirty.

Quoted 6 lines
Quoted 2 lines

I agree that using ethtool seems overkill compared to the patches you posted.

I think you either overestimate the amount of trouble for implementing (minimal) ethtool support or you underestimate the amount of functionality available through that interface.

Quoted 6 lines

I'm not worried about the implementation complexity, and as your patches show it was easy. My concern is the overall design for wireless devices. Instead of using nl80211 for everything, with some features we would use nl80211/iw and with some ethtool. That's just confusing and I don't like that. I would prefer that nl80211 provides everything, it makes things so much easier.

Well, if the hw/fw version numbers were the only thing then I'd probably say it's not a big deal. But having ethtool support is nice in that it makes a familiar tool work for us. Among other things, this probably helps with some distro scripts that don't work quite right without it. Plus, there is lots of debugging stuff that could be turned-on without having to write new tools.

I suppose I understand the 'one API' idea, but why duplicate functionality? Anyway, adding a couple of ioctl calls isn't a big deal. And don't forget, we are still network drivers too...

Quoted 4 lines
Quoted 3 lines

That, or you just don't like using something named "eth"tool for wireless -- but hey, let's be honest about the frames we send/receive to/from the kernel... :-)

Quoted 8 lines

I don't have a problem with the name :) But ethernet is still so much different from 802.11 that there isn't that much to share and we in wireless will need different features.

One example is the hw version, ethtool only provides u32 to userspace and moves the burden of translating hw id to the user. For us a string is much better choise because when debuggin we need to often (or always?) know the chip version.

Look at the way most drivers set the version (using each byte as a field). If you want prettier output, adding a parser to the userland ethtool is fairly trivial. It looks something like the patch below...

Quoted 24 lines

But this is not something I will start fighting about. If you still think that ethtool is the way to go, I'm perfectly fine with it.

Quoted 7 lines
Quoted 1 line

The ethtool interface provides functionality for viewing and modifying

eeprom contents, dumping registers, trigger self-tests, basic driver info, getting and setting message reporting levels, external card identification (hey, _could_ be useful!), and some other bits like checksum offload that might(?) be useful in the future. I understand regarding the WoW vs. WoL issue but probably the answer is just to add a new method for WoW...?

I took a look at ethtool help output from debian unstable and I think this is the set of features we can use in wireless:

ethtool -i|--driver DEVNAME Show driver information
ethtool -d|--register-dump DEVNAME Do a register dump
[ raw on|off ]
[ file FILENAME ]
ethtool -e|--eeprom-dump DEVNAME Do a EEPROM dump
[ raw on|off ]
[ offset N ]
[ length N ]
ethtool -E|--change-eeprom DEVNAME Change bytes in device
EEPROM

Quoted 8 lines

[ magic N ]
[ offset N ]
[ value N ]
ethtool -p|--identify DEVNAME Show visible port
identification (e.g. blinking)
[ TIME-IN-SECONDS ]
ethtool -t|--test DEVNAME Execute adapter self test
[ online | offline ]

I agree with the above.

Quoted 18 lines

But here are the features which I doubt we will ever use:

ethtool -s|--change DEVNAME Change generic options
[ speed %%d ]
[ duplex half|full ]
[ port tp|aui|bnc|mii|fibre ]
[ autoneg on|off ]
[ advertise %%x ]
[ phyad %%d ]
[ xcvr internal|external ]
[ wol p|u|m|b|a|g|s|d... ]
[ sopass %%x:%%x:%%x:%%x:%%x:%%x ] [ msglvl %%d ]
ethtool -a|--show-pause DEVNAME Show pause options
ethtool -A|--pause DEVNAME Set pause options
[ autoneg on|off ]
[ rx on|off ]
[ tx on|off ]

I agree that the above are ethernet-specific.

Quoted 16 lines

ethtool -c|--show-coalesce DEVNAME Show coalesce options
ethtool -C|--coalesce DEVNAME Set coalesce options
[adaptive-rx on|off]
[adaptive-tx on|off]
[rx-usecs N]
[rx-frames N]
[rx-usecs-irq N]
[rx-frames-irq N]
[tx-usecs N]
[tx-frames N]
[tx-usecs-irq N]
[tx-frames-irq N]
[stats-block-usecs N]
[pkt-rate-low N]
[rx-usecs-low N]
[rx-frames-low N]

Quoted 8 lines

[tx-usecs-low N]
[tx-frames-low N]
[pkt-rate-high N]
[rx-usecs-high N]
[rx-frames-high N]
[tx-usecs-high N]
[tx-frames-high N]
[sample-interval N]

These _could_ be useful if wireless becomes more
performance-oriented...

Quoted 6 lines
        ethtool -g|--show-ring DEVNAME  Query RX/TX ring parameters
        ethtool -G|--set-ring DEVNAME   Set RX/TX ring parameters

[ rx N ]
[ rx-mini N ]
[ rx-jumbo N ]
[ tx N ]

Wireless devices have ring buffers, no?

Quoted 11 lines

ethtool -k|--show-offload DEVNAME Get protocol offload
information
ethtool -K|--offload DEVNAME Set protocol offload
[ rx on|off ]
[ tx on|off ]
[ sg on|off ]
[ tso on|off ]
[ ufo on|off ]
[ gso on|off ]
[ gro on|off ]
[ lro on|off ]

Again, if wireless devices become performance-oriented...

Quoted 1 line

ethtool -r|--negotiate DEVNAME Restart N-WAY negotation

Ethernet-specific...might could be overloaded for wireless to trigger reassoc...?

Quoted 8 lines
        ethtool -n|--show-nfc DEVNAME   Show Rx network flow
                classificationoptions
                [ rx-flow-hash
                tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6 ]
        ethtool -N|--config-nfc DEVNAME Configure Rx network flow
                classification options
                [ rx-flow-hash tcp4|udp4|ah4|sctp4|tcp6|udp6|ah6|sctp6
                m|v|t|s|d|f|n|r... ]

Long-shot, but no reason it couldn't be used in wireless... :-)

Anyway, it doesn't really matter if we don't use the whole API -- many older ethernet devices don't support all these features. The point is that the API exists and has some overlap with our needs. It is a driver-oriented API, with nitty-gritty stuff that need not clutter a configuraiton API like cfg80211. There is even the potential of us adding our own extensions (e.g. WoW) that are also device-oriented.

Anyway, between the link detection and making distro scripts work plus enabling a familiar tool for basic driver info I think this is a win. So much the better if some drivers move to ethtool for register dumping, setting message verbosity, querying/changing eeprom values, etc, etc...

John

P.S. The aforementioned path for userland ethtool...(theorhetical, not even compiled...)

Quoted 1 line

From aa92d32ac1cca57bdd3439013b0c7777bdf1217c Mon Sep 17 00:00:00 2001

From: John W. Linville <[email protected]>
Date: Thu, 1 Oct 2009 11:01:32 -0400
Subject: [PATCH] add support for at76c50x-usb driver.

---
 Makefile.am    |    2 +-
 at76c50x-usb.c |   32 ++++++++++++++++++++++++++++++++
 ethtool.c      |    1 +
 3 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 at76c50x-usb.c
Makefile.am +1 -1
index eac65fe..a384949 100644
@@ -8,7 +8,7 @@ ethtool_SOURCES = ethtool.c ethtool-copy.h ethtool-util.h	\
 		  amd8111e.c de2104x.c e100.c e1000.c igb.c	\
 		  fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c	\
 		  pcnet32.c realtek.c tg3.c marvell.c vioc.c	\
-		  smsc911x.c
+		  smsc911x.c at76c50x-usb.c
 
 dist-hook:
 	cp $(top_srcdir)/ethtool.spec $(distdir)
at76c50x-usb.c new file +32 -0
new file mode 100644
index 0000000..295d1cb
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include "ethtool-util.h"
+
+static char hw_versions[] = {
+        "503_ISL3861",
+        "503_ISL3863",
+        "        503",
+        "    503_ACC",
+        "        505",
+        "   505_2958",
+        "       505A",
+        "     505AMX",
+};
+
+int
+at76c50x_usb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
+{
+	u8 version = (u8)(regs->version >> 24);
+	u8 rev_id = (u8)(regs->version);
+	char *ver_string;
+
+	if(version != 0)
+		return -1;
+
+	ver_string = hw_versions[rev_id];
+	fprintf(stdout,
+		"Hardware Version                    %s\n",
+		ver_string);
+
+	return 0;
+}
+
ethtool.c +1 -0
index 0110682..7608750 100644
@@ -1189,6 +1189,7 @@ static struct {
 	{ "sky2", sky2_dump_regs },
         { "vioc", vioc_dump_regs },
         { "smsc911x", smsc911x_dump_regs },
+        { "at76c50x-usb", at76c50x_usb_dump_regs },
 };
 
 static int dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
Signature · 4 lines
1.6.2.5
-- 
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#34 lore raw

On Thu, 2009-10-01 at 11:18 -0400, John W. Linville wrote:
[...]

Quoted 19 lines
Quoted 18 lines

But here are the features which I doubt we will ever use:

ethtool -s|--change DEVNAME Change generic options
[ speed %%d ]
[ duplex half|full ]
[ port tp|aui|bnc|mii|fibre ]
[ autoneg on|off ]
[ advertise %%x ]
[ phyad %%d ]
[ xcvr internal|external ]
[ wol p|u|m|b|a|g|s|d... ]
[ sopass %%x:%%x:%%x:%%x:%%x:%%x ] [ msglvl %%d ]
ethtool -a|--show-pause DEVNAME Show pause options
ethtool -A|--pause DEVNAME Set pause options
[ autoneg on|off ]
[ rx on|off ]
[ tx on|off ]

Quoted 1 line

I agree that the above are ethernet-specific.

[...]

Message level isn't and WoL arguably isn't. It's a shame that these original ethtool settings are still bundled together...

Ben.

Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#35 lore raw
Quoted 21 lines · Ben Hutchings

On Thu, 2009-10-01 at 11:18 -0400, John W. Linville wrote:
[...]

Quoted 19 lines
Quoted 18 lines

But here are the features which I doubt we will ever use:

ethtool -s|--change DEVNAME Change generic options
[ speed %%d ]
[ duplex half|full ]
[ port tp|aui|bnc|mii|fibre ]
[ autoneg on|off ]
[ advertise %%x ]
[ phyad %%d ]
[ xcvr internal|external ]
[ wol p|u|m|b|a|g|s|d... ]
[ sopass %%x:%%x:%%x:%%x:%%x:%%x ] [ msglvl %%d ]
ethtool -a|--show-pause DEVNAME Show pause options
ethtool -A|--pause DEVNAME Set pause options
[ autoneg on|off ]
[ rx on|off ]
[ tx on|off ]

Quoted 5 lines
Quoted 1 line

I agree that the above are ethernet-specific.

[...]

Message level isn't and WoL arguably isn't. It's a shame that these original ethtool settings are still bundled together...

Oh, yes! Missed those in the noise...

John

Signature · 6 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#36 lore raw
In reply to John W. Linville
Quoted 9 lines · John W. Linville
Quoted 7 lines · Kalle Valo

I'm not worried about the implementation complexity, and as your patches show it was easy. My concern is the overall design for wireless devices. Instead of using nl80211 for everything, with some features we would use nl80211/iw and with some ethtool. That's just confusing and I don't like that. I would prefer that nl80211 provides everything, it makes things so much easier.

Quoted 6 lines

Well, if the hw/fw version numbers were the only thing then I'd probably say it's not a big deal. But having ethtool support is nice in that it makes a familiar tool work for us. Among other things, this probably helps with some distro scripts that don't work quite right without it. Plus, there is lots of debugging stuff that could be turned-on without having to write new tools.

Agreed, maybe expect the distro scripts part. To me that just sounds as a bug in the scripts.

Quoted 2 lines

I suppose I understand the 'one API' idea, but why duplicate functionality?

Just because the common functionality in this case isn't high enough. I'm worried that we will use 10% of the functionality in nl80211 and the rest 90% will be something we can't use and have to reimplement in nl80211.

Quoted 1 line

Anyway, adding a couple of ioctl calls isn't a big deal.

Sure, but we need to support this forever. If, say after two years, we decide that ethtool is not the way to go, it's very difficult to remove it. The less interfaces we have, the easier it is to maintain them.

Quoted 1 line

And don't forget, we are still network drivers too...

I hope ethtool isn't a strict requirement for a network driver, at least I haven't heard about that.

Quoted 7 lines
Quoted 4 lines

One example is the hw version, ethtool only provides u32 to userspace and moves the burden of translating hw id to the user. For us a string is much better choise because when debuggin we need to often (or always?) know the chip version.

Look at the way most drivers set the version (using each byte as a field).

Yes, that's how it is also with wl1251. A number like '0x7030101' is just not that user friendly.

Quoted 2 lines

If you want prettier output, adding a parser to the userland ethtool is fairly trivial. It looks something like the patch below...

Oh wow, that's cool and a truly useful feature. One complaint less from me :)

Quoted 25 lines
Quoted 16 lines

ethtool -c|--show-coalesce DEVNAME Show coalesce options
ethtool -C|--coalesce DEVNAME Set coalesce options
[adaptive-rx on|off]
[adaptive-tx on|off]
[rx-usecs N]
[rx-frames N]
[rx-usecs-irq N]
[rx-frames-irq N]
[tx-usecs N]
[tx-frames N]
[tx-usecs-irq N]
[tx-frames-irq N]
[stats-block-usecs N]
[pkt-rate-low N]
[rx-usecs-low N]
[rx-frames-low N]

Quoted 8 lines

[tx-usecs-low N]
[tx-frames-low N]
[pkt-rate-high N]
[rx-usecs-high N]
[rx-frames-high N]
[tx-usecs-high N]
[tx-frames-high N]
[sample-interval N]

Quoted 2 lines

These _could_ be useful if wireless becomes more
performance-oriented...

Maybe, or maybe not. We will only find out within the next few years.

And what will we do if the parameters are actually a bit different? Is it ok to extend ethtool for supporting wireless or do we later on have to add separate support to nl80211? The latter would suck big time.

Quoted 8 lines
Quoted 6 lines
        ethtool -g|--show-ring DEVNAME  Query RX/TX ring parameters
        ethtool -G|--set-ring DEVNAME   Set RX/TX ring parameters

[ rx N ]
[ rx-mini N ]
[ rx-jumbo N ]
[ tx N ]

Wireless devices have ring buffers, no?

Yes, there is hardware which have them but again the question is this relevant for wireless devices. In ethernet the hardware is the bottleneck but in 802.11 the wireless medium is the bottleneck, so the parameters we need to configure are usually different.

Quoted 4 lines
Quoted 1 line

ethtool -r|--negotiate DEVNAME Restart N-WAY negotation

Ethernet-specific...might could be overloaded for wireless to trigger reassoc...?

Please no, I don't want to see any reassociation or anything else 802.11 state related in ethtool, nl80211 was created for this. This is something I would object loudly :)

Quoted 7 lines

Anyway, it doesn't really matter if we don't use the whole API -- many older ethernet devices don't support all these features. The point is that the API exists and has some overlap with our needs. It is a driver-oriented API, with nitty-gritty stuff that need not clutter a configuraiton API like cfg80211. There is even the potential of us adding our own extensions (e.g. WoW) that are also device-oriented.

Quoted 5 lines

Anyway, between the link detection and making distro scripts work plus enabling a familiar tool for basic driver info I think this is a win. So much the better if some drivers move to ethtool for register dumping, setting message verbosity, querying/changing eeprom values, etc, etc...

Sounds good enough. As I said in my earlier email, I'm not going argue about this for too long. You know this better than I do. So let's go forward with ethtool.

Thanks for listening to my concerns.

Signature · 1 line
Kalle Valo
#37 lore raw
Quoted 10 lines · Kalle Valo
Quoted 3 lines · John W. Linville

On Thu, Oct 01, 2009 at 05:18:33PM +0300, Kalle Valo wrote:

Anyway, adding a couple of ioctl calls isn't a big deal.

Sure, but we need to support this forever. If, say after two years, we decide that ethtool is not the way to go, it's very difficult to remove it. The less interfaces we have, the easier it is to maintain them.

Just to be clear, I was taling about adding ioctl calls to a userland application (if you didn't want to use the ethtool utility). The required ioctls are already defined for ethtool in the kernel.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

ethtool -r|--negotiate DEVNAME Restart N-WAY negotation

Ethernet-specific...might could be overloaded for wireless to trigger reassoc...?

Please no, I don't want to see any reassociation or anything else 802.11 state related in ethtool, nl80211 was created for this. This is something I would object loudly :)

Well, it was just a thought... :-)

Quoted 11 lines
Quoted 5 lines

Anyway, between the link detection and making distro scripts work plus enabling a familiar tool for basic driver info I think this is a win. So much the better if some drivers move to ethtool for register dumping, setting message verbosity, querying/changing eeprom values, etc, etc...

Sounds good enough. As I said in my earlier email, I'm not going argue about this for too long. You know this better than I do. So let's go forward with ethtool.

Thanks for listening to my concerns.

Sure, np. And FWIW, I don't predict a huge problem if there are valid extensions required for use by wireless drivers in the future. But for now, I'd like to see us make use of some of the debugging facilities available in the ethtool API -- hopefully the iwlwifi guys are listening... ;-)

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#39 lore raw
Quoted 5 lines · John W. Linville

I don't predict a huge problem if there are
valid extensions required for use by wireless drivers in the future. But for now, I'd like to see us make use of some of the debugging facilities available in the ethtool API -- hopefully the iwlwifi guys are listening... ;-)

Does the same apply to wimax then? Ethtool for 802.11 and wimax? Eh.

Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#40 lore raw
Quoted 9 lines · Luis R. Rodriguez
Quoted 5 lines · John W. Linville

I don't predict a huge problem if there are
valid extensions required for use by wireless drivers in the future. But for now, I'd like to see us make use of some of the debugging facilities available in the ethtool API -- hopefully the iwlwifi guys are listening... ;-)

Does the same apply to wimax then? Ethtool for 802.11 and wimax? Eh.

Not really -- WiMAX is not eth-frame based, but IP based.

The WiMAX stack doesn't require any type of framing/network device typing requirement. That is left up to the device driver writer (although yes, emulating eth is easier).

Signature · 1 line
-- Inaky