Skip to contentSkip to conversation

More device type integration

PATCH In review Marcel Holtmann 2 participants 6 messages Oct 2, 2009 – Oct 5, 2009

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

cover More device type integration

Hi Dave,

I followed the work from Johannes and made sure we can register the device type for wireless devices via the netdev notifier callback for all cfg80211 based devices. This way we don't have to touch any of the drivers.

For the mobile broadband cards from Ericsson, the device type is now set to "wwan" and it also uses "wwan%d" for the default interface name.

Regards

Marcel

Johannes Berg (1):
net: introduce NETDEV_POST_INIT notifier

Marcel Holtmann (3):
usbnet: Use wwan%d interface name for mobile broadband devices
usbnet: Set device type for wlan and wwan devices
cfg80211: assign device type in netdev notifier callback

 drivers/net/usb/cdc_ether.c |   20 ++++++++++++++------
 drivers/net/usb/usbnet.c    |   17 +++++++++++++++++
 include/linux/notifier.h    |    1 +
 include/linux/usb/usbnet.h  |    1 +
 net/core/dev.c              |    6 ++++++
 net/mac80211/iface.c        |    5 -----
 net/wireless/core.c         |    7 +++++++
 7 files changed, 46 insertions(+), 11 deletions(-)
#1 lore raw

PATCH 1/4 usbnet: Use wwan%d interface name for mobile broadband devices

Add support for usbnet based devices like CDC-Ether to indicate that they are actually mobile broadband devices. In that case use wwan%d as default interface name.

---
 drivers/net/usb/cdc_ether.c |   20 ++++++++++++++------
 drivers/net/usb/usbnet.c    |    3 +++
 include/linux/usb/usbnet.h  |    1 +
 3 files changed, 18 insertions(+), 6 deletions(-)
drivers/net/usb/cdc_ether.c +14 -6
index 4a6aff5..71e65fc 100644
@@ -420,6 +420,14 @@ static const struct driver_info	cdc_info = {
 	.status =	cdc_status,
 };
 
+static const struct driver_info mbm_info = {
+	.description =	"Mobile Broadband Network Device",
+	.flags =	FLAG_WWAN,
+	.bind = 	cdc_bind,
+	.unbind =	usbnet_cdc_unbind,
+	.status =	cdc_status,
+};
+
 /*-------------------------------------------------------------------------*/
 
 
@@ -532,32 +540,32 @@ static const struct usb_device_id	products [] = {
 	/* Ericsson F3507g */
 	USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1900, USB_CLASS_COMM,
 			USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
-	.driver_info = (unsigned long) &cdc_info,
+	.driver_info = (unsigned long) &mbm_info,
 }, {
 	/* Ericsson F3507g ver. 2 */
 	USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1902, USB_CLASS_COMM,
 			USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
-	.driver_info = (unsigned long) &cdc_info,
+	.driver_info = (unsigned long) &mbm_info,
 }, {
 	/* Ericsson F3607gw */
 	USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1904, USB_CLASS_COMM,
 			USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
-	.driver_info = (unsigned long) &cdc_info,
+	.driver_info = (unsigned long) &mbm_info,
 }, {
 	/* Ericsson F3307 */
 	USB_DEVICE_AND_INTERFACE_INFO(0x0bdb, 0x1906, USB_CLASS_COMM,
 			USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
-	.driver_info = (unsigned long) &cdc_info,
+	.driver_info = (unsigned long) &mbm_info,
 }, {
 	/* Toshiba F3507g */
 	USB_DEVICE_AND_INTERFACE_INFO(0x0930, 0x130b, USB_CLASS_COMM,
 			USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
-	.driver_info = (unsigned long) &cdc_info,
+	.driver_info = (unsigned long) &mbm_info,
 }, {
 	/* Dell F3507g */
 	USB_DEVICE_AND_INTERFACE_INFO(0x413c, 0x8147, USB_CLASS_COMM,
 			USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE),
-	.driver_info = (unsigned long) &cdc_info,
+	.driver_info = (unsigned long) &mbm_info,
 },
 	{ },		// END
 };
drivers/net/usb/usbnet.c +3 -0
index ca5ca5a..8124cf1 100644
@@ -1295,6 +1295,9 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 		/* WLAN devices should always be named "wlan%d" */
 		if ((dev->driver_info->flags & FLAG_WLAN) != 0)
 			strcpy(net->name, "wlan%d");
+		/* WWAN devices should always be named "wwan%d" */
+		if ((dev->driver_info->flags & FLAG_WWAN) != 0)
+			strcpy(net->name, "wwan%d");
 
 		/* maybe the remote can't receive an Ethernet MTU */
 		if (net->mtu > (dev->hard_mtu - net->hard_header_len))
include/linux/usb/usbnet.h +1 -0
index f814730..86c31b7 100644
@@ -90,6 +90,7 @@ struct driver_info {
 #define FLAG_WLAN	0x0080		/* use "wlan%d" names */
 #define FLAG_AVOID_UNLINK_URBS 0x0100	/* don't unlink urbs at usbnet_stop() */
 #define FLAG_SEND_ZLP	0x0200		/* hw requires ZLPs are sent */
+#define FLAG_WWAN	0x0400		/* use "wwan%d" names */
 
 
 	/* init device ... can sleep, or cause probe() failure */
Signature · 1 line
1.6.2.5
#2 lore raw

PATCH 2/4 usbnet: Set device type for wlan and wwan devices

For usbnet devices with FLAG_WLAN and FLAG_WWAN set the proper device type so that uevent contains the correct value. This then allows an easy identification of the actual underlying technology of the Ethernet device.

---
 drivers/net/usb/usbnet.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/net/usb/usbnet.c +14 -0
index 8124cf1..378da8c 100644
@@ -1210,6 +1210,14 @@ static const struct net_device_ops usbnet_netdev_ops = {
 
 // precondition: never called in_interrupt
 
+static struct device_type wlan_type = {
+	.name	= "wlan",
+};
+
+static struct device_type wwan_type = {
+	.name	= "wwan",
+};
+
 int
 usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 {
@@ -1325,6 +1333,12 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod)
 	dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1);
 
 	SET_NETDEV_DEV(net, &udev->dev);
+
+	if ((dev->driver_info->flags & FLAG_WLAN) != 0)
+		SET_NETDEV_DEVTYPE(net, &wlan_type);
+	if ((dev->driver_info->flags & FLAG_WWAN) != 0)
+		SET_NETDEV_DEVTYPE(net, &wwan_type);
+
 	status = register_netdev (net);
 	if (status)
 		goto out3;
Signature · 1 line
1.6.2.5
#3 lore raw

PATCH 3/4 net: introduce NETDEV_POST_INIT notifier

From: Johannes Berg <[email protected]>

For various purposes including a wireless extensions bugfix, we need to hook into the netdev creation before before netdev_register_kobject(). This will also ease doing the dev type assignment that Marcel was working on for cfg80211 drivers w/o touching them all.

---
 include/linux/notifier.h |    1 +
 net/core/dev.c           |    6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)
include/linux/notifier.h +1 -0
index 44428d2..29714b8 100644
@@ -201,6 +201,7 @@ static inline int notifier_to_errno(int ret)
 #define NETDEV_PRE_UP		0x000D
 #define NETDEV_BONDING_OLDTYPE  0x000E
 #define NETDEV_BONDING_NEWTYPE  0x000F
+#define NETDEV_POST_INIT	0x0010
 
 #define SYS_DOWN	0x0001	/* Notify of system down */
 #define SYS_RESTART	SYS_DOWN
net/core/dev.c +6 -0
index b8f74cf..a74c8fd 100644
@@ -4836,6 +4836,12 @@ int register_netdevice(struct net_device *dev)
 		dev->features |= NETIF_F_GSO;
 
 	netdev_initialize_kobject(dev);
+
+	ret = call_netdevice_notifiers(NETDEV_POST_INIT, dev);
+	ret = notifier_to_errno(ret);
+	if (ret)
+		goto err_uninit;
+
 	ret = netdev_register_kobject(dev);
 	if (ret)
 		goto err_uninit;
Signature · 1 line
1.6.2.5
#4 lore raw

PATCH 4/4 cfg80211: assign device type in netdev notifier callback

Instead of having to modify every non-mac80211 for device type assignment, do this inside the netdev notifier callback of cfg80211. So all drivers that integrate with cfg80211 will export a proper device type.

---
 net/mac80211/iface.c |    5 -----
 net/wireless/core.c  |    7 +++++++
 2 files changed, 7 insertions(+), 5 deletions(-)
net/mac80211/iface.c +0 -5
index b8295cb..f6005ad 100644
@@ -754,10 +754,6 @@ int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
 	return 0;
 }
 
-static struct device_type wiphy_type = {
-	.name	= "wlan",
-};
-
 int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 		     struct net_device **new_dev, enum nl80211_iftype type,
 		     struct vif_params *params)
@@ -789,7 +785,6 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 
 	memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
 	SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
-	SET_NETDEV_DEVTYPE(ndev, &wiphy_type);
 
 	/* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */
 	sdata = netdev_priv(ndev);
net/wireless/core.c +7 -0
index 45b2be3..e6f02e9 100644
@@ -625,6 +625,10 @@ static void wdev_cleanup_work(struct work_struct *work)
 	dev_put(wdev->netdev);
 }
 
+static struct device_type wiphy_type = {
+	.name	= "wlan",
+};
+
 static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
 					 unsigned long state,
 					 void *ndev)
@@ -641,6 +645,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
 	WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED);
 
 	switch (state) {
+	case NETDEV_POST_INIT:
+		SET_NETDEV_DEVTYPE(dev, &wiphy_type);
+		break;
 	case NETDEV_REGISTER:
 		/*
 		 * NB: cannot take rdev->mtx here because this may be
Signature · 1 line
1.6.2.5
maintainer
#5 lore raw
In reply to Marcel Holtmann

From: Marcel Holtmann <[email protected]>
Date: Fri, 2 Oct 2009 17:15:24 +0200

Quoted 7 lines

I followed the work from Johannes and made sure we can register the device type for wireless devices via the netdev notifier callback for all cfg80211 based devices. This way we don't have to touch any of the drivers.

For the mobile broadband cards from Ericsson, the device type is now set to "wwan" and it also uses "wwan%d" for the default interface name.

Looks good, all applied to net-next-2.6

Thanks!