[PATCH] Minimal ethtool support

Pavel Roskin proski
Wed Dec 10 14:25:57 PST 2003


Hello!

The attached patch against CVS HEAD adds minimal support for ethtool.
Without this patch hostap writes following to the kernel log:

wlan0 unsupported ioctl(0x8946)

Fedora Core 1 is configured in such way that ethtool is run from
/sbin/ifup, which is run by hotplug.  This means that the message about
"unsupported ioctl" appears every time a hostap network interface is
registered, e.g. immediately after running "modprobe hostap_plx".

Many drivers in the latest Linux 2.6 kernels have minimal support
for "driver info" command.  For example, wavelan_cs.c only returns the
driver name.

My patch also returns version of the driver and the firmware version.
The version of the secondary firmware is used as "the firmware version".

Bus ID is not returned.  The driver doesn't have the necessary code to
distinguish e.g. PLX and native PCI cards in the generic code.  I don't
think such significant changes are worth the trouble.

That's what ethtool prints after applying the patch:

# ethtool -i wlan0
driver: hostap
version: CVS
firmware-version: 1.7.1
bus-info:

-- 
Regards,
Pavel Roskin
-------------- next part --------------
--- driver/modules/hostap_ioctl.c
+++ driver/modules/hostap_ioctl.c
@@ -4,6 +4,7 @@
 /* Get kernel_locked() for in_atomic() */
 #include <linux/smp_lock.h>
 #endif
+#include <linux/ethtool.h>
 
 
 static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
@@ -3338,6 +3339,32 @@ static int prism2_ioctl_priv_hostapd(loc
 }
 
 
+static int prism2_ioctl_ethtool(local_info_t *local, void *useraddr)
+{
+	u32 ethcmd;
+	struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
+
+	if (copy_from_user(&ethcmd, useraddr, sizeof(ethcmd)))
+		return -EFAULT;
+
+	switch (ethcmd) {
+	case ETHTOOL_GDRVINFO:
+		strncpy(info.driver, "hostap", sizeof(info.driver) - 1);
+		strncpy(info.version, PRISM2_VERSION,
+			sizeof(info.version) - 1);
+		snprintf(info.fw_version, sizeof(info.fw_version) - 1,
+			 "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
+			 (local->sta_fw_ver >> 8) & 0xff,
+			 local->sta_fw_ver & 0xff);
+		if (copy_to_user(useraddr, &info, sizeof(info)))
+			return -EFAULT;
+		return 0;
+	}
+
+	return -EOPNOTSUPP;
+}
+
+
 /* Structures to export the Wireless Handlers */
 
 static const iw_handler prism2_handler[] =
@@ -3564,6 +3591,10 @@ int hostap_ioctl(struct net_device *dev,
 		else ret = prism2_ioctl_priv_hostapd(local, &wrq->u.data);
 		break;
 
+	case SIOCETHTOOL:
+		ret = prism2_ioctl_ethtool(local, (void *) ifr->ifr_data);
+		break;
+
 	default:
 		if (cmd >= SIOCSIWCOMMIT && cmd <= SIOCGIWPOWER) {
 			/* unsupport wireless extensions get through here - do



More information about the Hostap mailing list