[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 04 Apr 2008 18:10:52 +0400
From: Pavel Emelyanov <xemul@...nvz.org>
To: Linux Netdev List <netdev@...r.kernel.org>
Subject: [RFC][PATCH 1/3] Introduce the net_device_ops structure.
And fill it with copied from net_device.
Also make newly created devices be assigned to the
(currently empty) nd_default_ops.
Signed-off-by: Pavel Emelyanov <xemul@...nvz.org>
---
include/linux/netdevice.h | 39 +++++++++++++++++++++++++++++++++++++++
net/core/dev.c | 9 +++++++++
2 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 8b17ed4..33f00ff 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -447,6 +447,43 @@ static inline void napi_synchronize(const struct napi_struct *n)
* moves out.
*/
+struct net_device_ops {
+ int (*init)(struct net_device *dev);
+ struct net_device_stats* (*get_stats)(struct net_device *dev);
+ int (*hard_start_xmit) (struct sk_buff *skb,
+ struct net_device *dev);
+ void (*uninit)(struct net_device *dev);
+ void (*destructor)(struct net_device *dev);
+ int (*open)(struct net_device *dev);
+ int (*stop)(struct net_device *dev);
+ void (*change_rx_flags)(struct net_device *dev,
+ int flags);
+ void (*set_rx_mode)(struct net_device *dev);
+ void (*set_multicast_list)(struct net_device *dev);
+ int (*set_mac_address)(struct net_device *dev,
+ void *addr);
+ int (*validate_addr)(struct net_device *dev);
+ int (*do_ioctl)(struct net_device *dev,
+ struct ifreq *ifr, int cmd);
+ int (*set_config)(struct net_device *dev,
+ struct ifmap *map);
+ int (*change_mtu)(struct net_device *dev,
+ int new_mtu);
+ void (*tx_timeout) (struct net_device *dev);
+
+ void (*vlan_rx_register)(struct net_device *dev,
+ struct vlan_group *grp);
+ void (*vlan_rx_add_vid)(struct net_device *dev,
+ unsigned short vid);
+ void (*vlan_rx_kill_vid)(struct net_device *dev,
+ unsigned short vid);
+ int (*neigh_setup)(struct net_device *dev,
+ struct neigh_parms *);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ void (*poll_controller)(struct net_device *dev);
+#endif
+};
+
struct net_device
{
@@ -662,6 +699,8 @@ struct net_device
NETREG_RELEASED, /* called free_netdev */
} reg_state;
+ struct net_device_ops *nd_ops;
+
/* Called after device is detached from network. */
void (*uninit)(struct net_device *dev);
/* Called after last user reference disappears. */
diff --git a/net/core/dev.c b/net/core/dev.c
index 7aa0112..5e7bf79 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3976,6 +3976,13 @@ static struct net_device_stats *internal_stats(struct net_device *dev)
return &dev->stats;
}
+/*
+ * temporary devices operations - to be removed very soon
+ */
+
+static struct net_device_ops nd_default_ops = {
+};
+
/**
* alloc_netdev_mq - allocate network device
* @sizeof_priv: size of private data to allocate space for
@@ -4027,6 +4034,8 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
dev->get_stats = internal_stats;
netpoll_netdev_init(dev);
setup(dev);
+ if (dev->nd_ops == NULL)
+ dev->nd_ops = &nd_default_ops;
strcpy(dev->name, name);
return dev;
}
--
1.5.3.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists