From: Pavel Emelyanov <xemul@openvz.org>
To: Linux Netdev List <netdev@vger.kernel.org>
Subject: [RFC][PATCH 1/3] Introduce the net_device_ops structure.
Date: Fri, 04 Apr 2008 18:10:52 +0400 [thread overview]
Message-ID: <47F636EC.5070506@openvz.org> (raw)
In-Reply-To: <47F63681.1030603@openvz.org>
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@openvz.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
next prev parent reply other threads:[~2008-04-04 13:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-04 14:09 [RFC][PATCH 0/3] Make loopback device weight twice as little Pavel Emelyanov
2008-04-04 14:10 ` Pavel Emelyanov [this message]
2008-04-04 15:14 ` [RFC][PATCH 1/3] Introduce the net_device_ops structure Stephen Hemminger
2008-04-04 15:54 ` Patrick McHardy
2008-04-14 4:20 ` David Miller
2008-04-04 14:12 ` [RFC][PATCH 2/3] Move net_device->init callback on net_device_ops Pavel Emelyanov
2008-04-04 14:14 ` [RFC][PATCH 3/3] Move net_device->uninit " Pavel Emelyanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47F636EC.5070506@openvz.org \
--to=xemul@openvz.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).