Thread (12 messages) flat view 12 messages, 3 authors, 2013-08-20
STALE4775d

[PATCH 1/3] net: add a new NETDEV_CHANGEROOM event type

From: "Florian Fainelli" <f.fainelli@gmail.com>
Date: 2013-08-20 12:46:13
Subsystem: networking drivers, networking [general], the rest · Maintainers: Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

The event NETDEV_CHANGEROOM event can be used by devices/subsystems
which need to adjust their needed_headroom and/or needed_tailroom
requirements dynamically. Two helper functions are introduced:

- dev_set_headroom(dev, new_headroom)
- dev_set_taioroom(dev, new_tailroom)

which will notify listeners of such a change.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 include/linux/netdevice.h |  3 +++
 net/core/dev.c            | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 077363d..2b3e56c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1652,6 +1652,7 @@ struct packet_offload {
 #define NETDEV_JOIN		0x0014
 #define NETDEV_CHANGEUPPER	0x0015
 #define NETDEV_RESEND_IGMP	0x0016
+#define NETDEV_CHANGEROOM	0x0017 /* needed_headroom/tailroom change */
 
 extern int register_netdevice_notifier(struct notifier_block *nb);
 extern int unregister_netdevice_notifier(struct notifier_block *nb);
@@ -2329,6 +2330,8 @@ extern int		dev_change_net_namespace(struct net_device *,
 						 struct net *, const char *);
 extern int		dev_set_mtu(struct net_device *, int);
 extern void		dev_set_group(struct net_device *, int);
+extern int		dev_set_headroom(struct net_device *, unsigned short);
+extern int		dev_set_tailroom(struct net_device *, unsigned short);
 extern int		dev_set_mac_address(struct net_device *,
 					    struct sockaddr *);
 extern int		dev_change_carrier(struct net_device *,
diff --git a/net/core/dev.c b/net/core/dev.c
index 1ed2b66..be712be 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4931,6 +4931,52 @@ int dev_set_mtu(struct net_device *dev, int new_mtu)
 EXPORT_SYMBOL(dev_set_mtu);
 
 /**
+ *	dev_set_headroom - Change device needed headroom
+ *	@dev: device
+ *	@new_headroom: new headroom size
+ *
+ * 	Change the network device headroom space.
+ */
+int dev_set_headroom(struct net_device *dev, unsigned short new_headroom)
+{
+	if (dev->needed_headroom == new_headroom)
+		return 0;
+
+	if (!netif_device_present(dev))
+		return -ENODEV;
+
+	dev->needed_headroom = new_headroom;
+
+	call_netdevice_notifiers(NETDEV_CHANGEROOM, dev);
+
+	return 0;
+}
+EXPORT_SYMBOL(dev_set_headroom);
+
+/**
+ *	dev_set_tailroom - Change device needed tailroom
+ *	@dev: device
+ *	@new_tailroom: new tailroom size
+ *
+ * 	Change the network device tailroom space.
+ */
+int dev_set_tailroom(struct net_device *dev, unsigned short new_tailroom)
+{
+	if (dev->needed_tailroom == new_tailroom)
+		return 0;
+
+	if (!netif_device_present(dev))
+		return -ENODEV;
+
+	dev->needed_tailroom = new_tailroom;
+
+	call_netdevice_notifiers(NETDEV_CHANGEROOM, dev);
+
+	return 0;
+}
+EXPORT_SYMBOL(dev_set_tailroom);
+
+/**
  *	dev_set_group - Change group this device belongs to
  *	@dev: device
  *	@new_group: group this device should belong to
-- 
1.8.1.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help