* [PATCH 01/33] netdev: network device operations infrastructure
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:26 ` David Miller
2008-11-17 23:42 ` [PATCH 02/33] netdev: introduce dev_get_stats() Stephen Hemminger
` (33 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: netdevice-ops.patch --]
[-- Type: text/plain, Size: 23964 bytes --]
This patch changes the network device internal API to move adminstrative
operations out of the network device structure and into a separate structure.
This patch involves some hackery to maintain compatablity between the
new and old model, so all 300+ drivers don't have to be changed at once.
For drivers that aren't converted yet, the netdevice_ops virt function list
still resides in the net_device structure. For old protocols, the new
net_device_ops are copied out to the old net_device pointers.
After the transistion is completed the nag message can be changed to
an WARN_ON, and the compatiablity code can be made configurable.
Some function pointers aren't moved:
* destructor can't be in net_device_ops because
it may need to be referenced after the module is unloaded.
* neighbor setup is manipulated in a couple of places that need special
consideration
* hard_start_xmit is in the fast path for transmit.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
---
include/linux/netdevice.h | 232 +++++++++++++++++++++++++++++++++-------------
net/Kconfig | 3
net/core/dev.c | 107 ++++++++++++++-------
net/core/netpoll.c | 7 -
net/core/rtnetlink.c | 9 -
net/sched/sch_generic.c | 4
6 files changed, 257 insertions(+), 105 deletions(-)
--- a/include/linux/netdevice.h 2008-11-17 14:53:09.000000000 -0800
+++ b/include/linux/netdevice.h 2008-11-17 15:15:40.000000000 -0800
@@ -451,6 +451,131 @@ struct netdev_queue {
struct Qdisc *qdisc_sleeping;
} ____cacheline_aligned_in_smp;
+
+/*
+ * This structure defines the management hooks for network devices.
+ * The following hooks can bed defined and are optonal (can be null)
+ * unless otherwise noted.
+ *
+ * int (*init)(struct net_device *dev);
+ * This function is called once when network device is registered.
+ * The network device can use this to any late stage initializaton
+ * or semantic validattion. It can fail with an error code which will
+ * be propogated back to register_netdev
+ *
+ * void (*uninit)(struct net_device *dev);
+ * This function is called when device is unregistered or when registration
+ * fails. It is not called if init fails.
+ *
+ * int (*open)(struct net_device *dev);
+ * This function is called when network device transistions to the up
+ * state.
+ *
+ * int (*stop)(struct net_device *dev);
+ * This function is called when network device transistions to the down
+ * state.
+ *
+ * void (*change_rx_flags)(struct net_device *dev, int flags);
+ * This function is called to allow device receiver to make
+ * changes to configuration when multicast or promiscious is enabled.
+ *
+ * void (*set_rx_mode)(struct net_device *dev);
+ * This function is called device changes address list filtering.
+ *
+ * void (*set_multicast_list)(struct net_device *dev);
+ * This function is called when the multicast address list changes.
+ *
+ * int (*set_mac_address)(struct net_device *dev, void *addr);
+ * This function is called when the Media Access Control address
+ * needs to be changed. If not this interface is not defined, the
+ * mac address can not be changed.
+ *
+ * int (*validate_addr)(struct net_device *dev);
+ * Test if Media Access Control address is valid for the device.
+ *
+ * int (*do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd);
+ * Called when a user request an ioctl which can't be handled by
+ * the generic interface code. If not defined ioctl's return
+ * not supported error code.
+ *
+ * int (*set_config)(struct net_device *dev, struct ifmap *map);
+ * Used to set network devices bus interface parameters. This interface
+ * is retained for legacy reason, new devices should use the bus
+ * interface (PCI) for low level management.
+ *
+ * int (*change_mtu)(struct net_device *dev, int new_mtu);
+ * Called when a user wants to change the Maximum Transfer Unit
+ * of a device. If not defined, any request to change MTU will
+ * will return an error.
+ *
+ * void (*tx_timeout) (struct net_device *dev);
+ * Callback uses when the transmitter has not made any progress
+ * for dev->watchdog ticks.
+ *
+ * struct net_device_stats* (*get_stats)(struct net_device *dev);
+ * Called when a user wants to get the network device usage
+ * statistics. If not defined, the counters in dev->stats will
+ * be used.
+ *
+ * void (*vlan_rx_register)(struct net_device *dev, struct vlan_group *grp);
+ * If device support VLAN receive accleration
+ * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called
+ * when vlan groups for the device changes. Note: grp is NULL
+ * if no vlan's groups are being used.
+ *
+ * void (*vlan_rx_add_vid)(struct net_device *dev, unsigned short vid);
+ * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
+ * this function is called when a VLAN id is registered.
+ *
+ * void (*vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid);
+ * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER)
+ * this function is called when a VLAN id is unregistered.
+ *
+ * void (*poll_controller)(struct net_device *dev);
+ */
+struct net_device_ops {
+ int (*init)(struct net_device *dev);
+ void (*uninit)(struct net_device *dev);
+ int (*open)(struct net_device *dev);
+ int (*stop)(struct net_device *dev);
+#define HAVE_CHANGE_RX_FLAGS
+ void (*change_rx_flags)(struct net_device *dev,
+ int flags);
+#define HAVE_SET_RX_MODE
+ void (*set_rx_mode)(struct net_device *dev);
+#define HAVE_MULTICAST
+ void (*set_multicast_list)(struct net_device *dev);
+#define HAVE_SET_MAC_ADDR
+ int (*set_mac_address)(struct net_device *dev,
+ void *addr);
+#define HAVE_VALIDATE_ADDR
+ int (*validate_addr)(struct net_device *dev);
+#define HAVE_PRIVATE_IOCTL
+ int (*do_ioctl)(struct net_device *dev,
+ struct ifreq *ifr, int cmd);
+#define HAVE_SET_CONFIG
+ int (*set_config)(struct net_device *dev,
+ struct ifmap *map);
+#define HAVE_CHANGE_MTU
+ int (*change_mtu)(struct net_device *dev, int new_mtu);
+
+#define HAVE_TX_TIMEOUT
+ void (*tx_timeout) (struct net_device *dev);
+
+ struct net_device_stats* (*get_stats)(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);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+#define HAVE_NETDEV_POLL
+ void (*poll_controller)(struct net_device *dev);
+#endif
+};
+
/*
* The DEVICE structure.
* Actually, this whole structure is a big mistake. It mixes I/O
@@ -498,11 +623,6 @@ struct net_device
#ifdef CONFIG_NETPOLL
struct list_head napi_list;
#endif
-
- /* The device initialization function. Called only once. */
- int (*init)(struct net_device *dev);
-
- /* ------- Fields preinitialized in Space.c finish here ------- */
/* Net device features */
unsigned long features;
@@ -546,15 +666,13 @@ struct net_device
* for all in netdev_increment_features.
*/
#define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \
- NETIF_F_SG | NETIF_F_HIGHDMA | \
+ NETIF_F_SG | NETIF_F_HIGHDMA | \
NETIF_F_FRAGLIST)
/* Interface index. Unique device identifier */
int ifindex;
int iflink;
-
- struct net_device_stats* (*get_stats)(struct net_device *dev);
struct net_device_stats stats;
#ifdef CONFIG_WIRELESS_EXT
@@ -564,18 +682,13 @@ struct net_device
/* Instance data managed by the core of Wireless Extensions. */
struct iw_public_data * wireless_data;
#endif
+ /* Management operations */
+ const struct net_device_ops *netdev_ops;
const struct ethtool_ops *ethtool_ops;
/* Hardware header description */
const struct header_ops *header_ops;
- /*
- * This marks the end of the "visible" part of the structure. All
- * fields hereafter are internal to the system, and may change at
- * will (read: may be cleaned up at will).
- */
-
-
unsigned int flags; /* interface flags (a la BSD) */
unsigned short gflags;
unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */
@@ -634,7 +747,7 @@ struct net_device
unsigned long last_rx; /* Time of last Rx */
/* Interface address info used in eth_type_trans() */
unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast
- because most packets are unicast) */
+ because most packets are unicast) */
unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */
@@ -648,6 +761,10 @@ struct net_device
/* Number of TX queues currently active in device */
unsigned int real_num_tx_queues;
+ /* Map buffer to appropriate transmit queue */
+ u16 (*select_queue)(struct net_device *dev,
+ struct sk_buff *skb);
+
unsigned long tx_queue_len; /* Max frames per queue allowed */
spinlock_t tx_global_lock;
/*
@@ -662,9 +779,6 @@ struct net_device
int watchdog_timeo; /* used by dev_watchdog() */
struct timer_list watchdog_timer;
-/*
- * refcnt is a very hot point, so align it on SMP
- */
/* Number of references to this device */
atomic_t refcnt ____cacheline_aligned_in_smp;
@@ -683,56 +797,14 @@ struct net_device
NETREG_RELEASED, /* called free_netdev */
} reg_state;
- /* Called after device is detached from network. */
- void (*uninit)(struct net_device *dev);
- /* Called after last user reference disappears. */
- void (*destructor)(struct net_device *dev);
-
- /* Pointers to interface service routines. */
- int (*open)(struct net_device *dev);
- int (*stop)(struct net_device *dev);
-#define HAVE_NETDEV_POLL
-#define HAVE_CHANGE_RX_FLAGS
- void (*change_rx_flags)(struct net_device *dev,
- int flags);
-#define HAVE_SET_RX_MODE
- void (*set_rx_mode)(struct net_device *dev);
-#define HAVE_MULTICAST
- void (*set_multicast_list)(struct net_device *dev);
-#define HAVE_SET_MAC_ADDR
- int (*set_mac_address)(struct net_device *dev,
- void *addr);
-#define HAVE_VALIDATE_ADDR
- int (*validate_addr)(struct net_device *dev);
-#define HAVE_PRIVATE_IOCTL
- int (*do_ioctl)(struct net_device *dev,
- struct ifreq *ifr, int cmd);
-#define HAVE_SET_CONFIG
- int (*set_config)(struct net_device *dev,
- struct ifmap *map);
-#define HAVE_CHANGE_MTU
- int (*change_mtu)(struct net_device *dev, int new_mtu);
-
-#define HAVE_TX_TIMEOUT
- void (*tx_timeout) (struct net_device *dev);
+ /* Called from unregister, can be used to call free_netdev */
+ void (*destructor)(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 *);
- int (*neigh_setup)(struct net_device *dev, struct neigh_parms *);
#ifdef CONFIG_NETPOLL
struct netpoll_info *npinfo;
#endif
-#ifdef CONFIG_NET_POLL_CONTROLLER
- void (*poll_controller)(struct net_device *dev);
-#endif
-
- u16 (*select_queue)(struct net_device *dev,
- struct sk_buff *skb);
#ifdef CONFIG_NET_NS
/* Network namespace this network device is inside */
@@ -763,6 +835,38 @@ struct net_device
/* for setting kernel sock attribute on TCP connection setup */
#define GSO_MAX_SIZE 65536
unsigned int gso_max_size;
+
+#ifdef CONFIG_COMPAT_NET_DEV_OPS
+ struct {
+ int (*init)(struct net_device *dev);
+ void (*uninit)(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);
+ struct net_device_stats* (*get_stats)(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);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ void (*poll_controller)(struct net_device *dev);
+#endif
+#endif
+ };
};
#define to_net_dev(d) container_of(d, struct net_device, dev)
--- a/net/Kconfig 2008-11-17 14:53:09.000000000 -0800
+++ b/net/Kconfig 2008-11-17 14:53:24.000000000 -0800
@@ -32,6 +32,9 @@ config NET_NS
Allow user space to create what appear to be multiple instances
of the network stack.
+config COMPAT_NET_DEV_OPS
+ def_bool y
+
source "net/packet/Kconfig"
source "net/unix/Kconfig"
source "net/xfrm/Kconfig"
--- a/net/core/dev.c 2008-11-17 14:53:09.000000000 -0800
+++ b/net/core/dev.c 2008-11-17 15:15:40.000000000 -0800
@@ -1059,6 +1059,7 @@ void dev_load(struct net *net, const cha
*/
int dev_open(struct net_device *dev)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
int ret = 0;
ASSERT_RTNL();
@@ -1081,11 +1082,11 @@ int dev_open(struct net_device *dev)
*/
set_bit(__LINK_STATE_START, &dev->state);
- if (dev->validate_addr)
- ret = dev->validate_addr(dev);
+ if (ops->validate_addr)
+ ret = ops->validate_addr(dev);
- if (!ret && dev->open)
- ret = dev->open(dev);
+ if (!ret && ops->open)
+ ret = ops->open(dev);
/*
* If it went open OK then:
@@ -1129,6 +1130,7 @@ int dev_open(struct net_device *dev)
*/
int dev_close(struct net_device *dev)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
ASSERT_RTNL();
might_sleep();
@@ -1161,8 +1163,8 @@ int dev_close(struct net_device *dev)
* We allow it to be called even after a DETACH hot-plug
* event.
*/
- if (dev->stop)
- dev->stop(dev);
+ if (ops->stop)
+ ops->stop(dev);
/*
* Device is now down.
@@ -2930,8 +2932,10 @@ int netdev_set_master(struct net_device
static void dev_change_rx_flags(struct net_device *dev, int flags)
{
- if (dev->flags & IFF_UP && dev->change_rx_flags)
- dev->change_rx_flags(dev, flags);
+ const struct net_device_ops *ops = dev->netdev_ops;
+
+ if ((dev->flags & IFF_UP) && ops->change_rx_flags)
+ ops->change_rx_flags(dev, flags);
}
static int __dev_set_promiscuity(struct net_device *dev, int inc)
@@ -3051,6 +3055,8 @@ int dev_set_allmulti(struct net_device *
*/
void __dev_set_rx_mode(struct net_device *dev)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
+
/* dev_open will call this function so the list will stay sane. */
if (!(dev->flags&IFF_UP))
return;
@@ -3058,8 +3064,8 @@ void __dev_set_rx_mode(struct net_device
if (!netif_device_present(dev))
return;
- if (dev->set_rx_mode)
- dev->set_rx_mode(dev);
+ if (ops->set_rx_mode)
+ ops->set_rx_mode(dev);
else {
/* Unicast addresses changes may only happen under the rtnl,
* therefore calling __dev_set_promiscuity here is safe.
@@ -3072,8 +3078,8 @@ void __dev_set_rx_mode(struct net_device
dev->uc_promisc = 0;
}
- if (dev->set_multicast_list)
- dev->set_multicast_list(dev);
+ if (ops->set_multicast_list)
+ ops->set_multicast_list(dev);
}
}
@@ -3432,6 +3438,7 @@ int dev_change_flags(struct net_device *
*/
int dev_set_mtu(struct net_device *dev, int new_mtu)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
int err;
if (new_mtu == dev->mtu)
@@ -3445,10 +3452,11 @@ int dev_set_mtu(struct net_device *dev,
return -ENODEV;
err = 0;
- if (dev->change_mtu)
- err = dev->change_mtu(dev, new_mtu);
+ if (ops->change_mtu)
+ err = ops->change_mtu(dev, new_mtu);
else
dev->mtu = new_mtu;
+
if (!err && dev->flags & IFF_UP)
call_netdevice_notifiers(NETDEV_CHANGEMTU, dev);
return err;
@@ -3463,15 +3471,16 @@ int dev_set_mtu(struct net_device *dev,
*/
int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
int err;
- if (!dev->set_mac_address)
+ if (!ops->set_mac_address)
return -EOPNOTSUPP;
if (sa->sa_family != dev->type)
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
- err = dev->set_mac_address(dev, sa);
+ err = ops->set_mac_address(dev, sa);
if (!err)
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
return err;
@@ -3551,6 +3560,7 @@ static int dev_ifsioc(struct net *net, s
{
int err;
struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name);
+ const struct net_device_ops *ops = dev->netdev_ops;
if (!dev)
return -ENODEV;
@@ -3578,15 +3588,15 @@ static int dev_ifsioc(struct net *net, s
return 0;
case SIOCSIFMAP:
- if (dev->set_config) {
+ if (ops->set_config) {
if (!netif_device_present(dev))
return -ENODEV;
- return dev->set_config(dev, &ifr->ifr_map);
+ return ops->set_config(dev, &ifr->ifr_map);
}
return -EOPNOTSUPP;
case SIOCADDMULTI:
- if ((!dev->set_multicast_list && !dev->set_rx_mode) ||
+ if ((!ops->set_multicast_list && !ops->set_rx_mode) ||
ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
return -EINVAL;
if (!netif_device_present(dev))
@@ -3595,7 +3605,7 @@ static int dev_ifsioc(struct net *net, s
dev->addr_len, 1);
case SIOCDELMULTI:
- if ((!dev->set_multicast_list && !dev->set_rx_mode) ||
+ if ((!ops->set_multicast_list && !ops->set_rx_mode) ||
ifr->ifr_hwaddr.sa_family != AF_UNSPEC)
return -EINVAL;
if (!netif_device_present(dev))
@@ -3633,10 +3643,9 @@ static int dev_ifsioc(struct net *net, s
cmd == SIOCBRDELIF ||
cmd == SIOCWANDEV) {
err = -EOPNOTSUPP;
- if (dev->do_ioctl) {
+ if (ops->do_ioctl) {
if (netif_device_present(dev))
- err = dev->do_ioctl(dev, ifr,
- cmd);
+ err = ops->do_ioctl(dev, ifr, cmd);
else
err = -ENODEV;
}
@@ -3897,8 +3906,8 @@ static void rollback_registered(struct n
*/
dev_addr_discard(dev);
- if (dev->uninit)
- dev->uninit(dev);
+ if (dev->netdev_ops->uninit)
+ dev->netdev_ops->uninit(dev);
/* Notifier chain MUST detach us from master device. */
WARN_ON(dev->master);
@@ -3988,7 +3997,7 @@ int register_netdevice(struct net_device
struct hlist_head *head;
struct hlist_node *p;
int ret;
- struct net *net;
+ struct net *net = dev_net(dev);
BUG_ON(dev_boot_phase);
ASSERT_RTNL();
@@ -3997,8 +4006,7 @@ int register_netdevice(struct net_device
/* When net_device's are persistent, this will be fatal. */
BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
- BUG_ON(!dev_net(dev));
- net = dev_net(dev);
+ BUG_ON(!net);
spin_lock_init(&dev->addr_list_lock);
netdev_set_addr_lockdep_class(dev);
@@ -4006,9 +4014,44 @@ int register_netdevice(struct net_device
dev->iflink = -1;
+#ifdef CONFIG_COMPAT_NET_DEV_OPS
+ /* Netdevice_ops API compatiability support.
+ * This is temporary until all network devices are converted.
+ */
+ if (dev->netdev_ops) {
+ const struct net_device_ops *ops = dev->netdev_ops;
+
+ dev->init = ops->init;
+ dev->uninit = ops->uninit;
+ dev->open = ops->open;
+ dev->change_rx_flags = ops->change_rx_flags;
+ dev->set_rx_mode = ops->set_rx_mode;
+ dev->set_multicast_list = ops->set_multicast_list;
+ dev->set_mac_address = ops->set_mac_address;
+ dev->validate_addr = ops->validate_addr;
+ dev->do_ioctl = ops->do_ioctl;
+ dev->set_config = ops->set_config;
+ dev->change_mtu = ops->change_mtu;
+ dev->tx_timeout = ops->tx_timeout;
+ dev->get_stats = ops->get_stats;
+ dev->vlan_rx_register = ops->vlan_rx_register;
+ dev->vlan_rx_add_vid = ops->vlan_rx_add_vid;
+ dev->vlan_rx_kill_vid = ops->vlan_rx_kill_vid;
+ dev->poll_controller = ops->poll_controller;
+ } else {
+ char drivername[64];
+ pr_info("%s (%s): not using net_device_ops yet\n",
+ dev->name, netdev_drivername(dev, drivername, 64));
+
+ /* This works only because net_device_ops and the
+ compatiablity structure are the same. */
+ dev->netdev_ops = (void *) &(dev->init);
+ }
+#endif
+
/* Init, if this function is available */
- if (dev->init) {
- ret = dev->init(dev);
+ if (dev->netdev_ops->init) {
+ ret = dev->netdev_ops->init(dev);
if (ret) {
if (ret > 0)
ret = -EIO;
@@ -4086,8 +4129,8 @@ out:
return ret;
err_uninit:
- if (dev->uninit)
- dev->uninit(dev);
+ if (dev->netdev_ops->uninit)
+ dev->netdev_ops->uninit(dev);
goto out;
}
--- a/net/core/netpoll.c 2008-11-17 14:53:09.000000000 -0800
+++ b/net/core/netpoll.c 2008-11-17 14:53:24.000000000 -0800
@@ -172,12 +172,13 @@ static void service_arp_queue(struct net
void netpoll_poll(struct netpoll *np)
{
struct net_device *dev = np->dev;
+ const struct net_device_ops *ops = dev->netdev_ops;
- if (!dev || !netif_running(dev) || !dev->poll_controller)
+ if (!dev || !netif_running(dev) || !ops->poll_controller)
return;
/* Process pending work on NIC */
- dev->poll_controller(dev);
+ ops->poll_controller(dev);
poll_napi(dev);
@@ -694,7 +695,7 @@ int netpoll_setup(struct netpoll *np)
atomic_inc(&npinfo->refcnt);
}
- if (!ndev->poll_controller) {
+ if (!ndev->netdev_ops->poll_controller) {
printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
np->name, np->dev_name);
err = -ENOTSUPP;
--- a/net/sched/sch_generic.c 2008-11-17 14:53:09.000000000 -0800
+++ b/net/sched/sch_generic.c 2008-11-17 14:53:24.000000000 -0800
@@ -224,7 +224,7 @@ static void dev_watchdog(unsigned long a
char drivername[64];
WARN_ONCE(1, KERN_INFO "NETDEV WATCHDOG: %s (%s): transmit timed out\n",
dev->name, netdev_drivername(dev, drivername, 64));
- dev->tx_timeout(dev);
+ dev->netdev_ops->tx_timeout(dev);
}
if (!mod_timer(&dev->watchdog_timer,
round_jiffies(jiffies +
@@ -239,7 +239,7 @@ static void dev_watchdog(unsigned long a
void __netdev_watchdog_up(struct net_device *dev)
{
- if (dev->tx_timeout) {
+ if (dev->netdev_ops->tx_timeout) {
if (dev->watchdog_timeo <= 0)
dev->watchdog_timeo = 5*HZ;
if (!mod_timer(&dev->watchdog_timer,
--- a/net/core/rtnetlink.c 2008-11-17 14:53:09.000000000 -0800
+++ b/net/core/rtnetlink.c 2008-11-17 15:15:40.000000000 -0800
@@ -762,6 +762,7 @@ static int validate_linkmsg(struct net_d
static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
int send_addr_notify = 0;
int err;
@@ -783,7 +784,7 @@ static int do_setlink(struct net_device
struct rtnl_link_ifmap *u_map;
struct ifmap k_map;
- if (!dev->set_config) {
+ if (!ops->set_config) {
err = -EOPNOTSUPP;
goto errout;
}
@@ -801,7 +802,7 @@ static int do_setlink(struct net_device
k_map.dma = (unsigned char) u_map->dma;
k_map.port = (unsigned char) u_map->port;
- err = dev->set_config(dev, &k_map);
+ err = ops->set_config(dev, &k_map);
if (err < 0)
goto errout;
@@ -812,7 +813,7 @@ static int do_setlink(struct net_device
struct sockaddr *sa;
int len;
- if (!dev->set_mac_address) {
+ if (!ops->set_mac_address) {
err = -EOPNOTSUPP;
goto errout;
}
@@ -831,7 +832,7 @@ static int do_setlink(struct net_device
sa->sa_family = dev->type;
memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]),
dev->addr_len);
- err = dev->set_mac_address(dev, sa);
+ err = ops->set_mac_address(dev, sa);
kfree(sa);
if (err)
goto errout;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 01/33] netdev: network device operations infrastructure
2008-11-17 23:42 ` [PATCH 01/33] netdev: network device operations infrastructure Stephen Hemminger
@ 2008-11-20 5:26 ` David Miller
2008-11-20 5:27 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: David Miller @ 2008-11-20 5:26 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 15:42:08 -0800
> This patch changes the network device internal API to move adminstrative
> operations out of the network device structure and into a separate structure.
>
> This patch involves some hackery to maintain compatablity between the
> new and old model, so all 300+ drivers don't have to be changed at once.
> For drivers that aren't converted yet, the netdevice_ops virt function list
> still resides in the net_device structure. For old protocols, the new
> net_device_ops are copied out to the old net_device pointers.
>
> After the transistion is completed the nag message can be changed to
> an WARN_ON, and the compatiablity code can be made configurable.
>
> Some function pointers aren't moved:
> * destructor can't be in net_device_ops because
> it may need to be referenced after the module is unloaded.
> * neighbor setup is manipulated in a couple of places that need special
> consideration
> * hard_start_xmit is in the fast path for transmit.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Ok, I'm applying this but it needs the following interdiff to cure some
build failures.
And I'm also going to add the "ndo_*" prefix to the netdev_ops member
names as suggested by Eric.
I'll fix up the remaining patches as needed, so don't worry about that.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 01/33] netdev: network device operations infrastructure
2008-11-20 5:26 ` David Miller
@ 2008-11-20 5:27 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 5:27 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: David Miller <davem@davemloft.net>
Date: Wed, 19 Nov 2008 21:26:50 -0800 (PST)
> Ok, I'm applying this but it needs the following interdiff to cure some
> build failures.
Durrr! And here is that interdiff!
--- net/core/dev.c~ 2008-11-19 17:36:28.000000000 -0800
+++ net/core/dev.c 2008-11-19 17:36:56.000000000 -0800
@@ -4037,7 +4037,9 @@ int register_netdevice(struct net_device
dev->vlan_rx_register = ops->vlan_rx_register;
dev->vlan_rx_add_vid = ops->vlan_rx_add_vid;
dev->vlan_rx_kill_vid = ops->vlan_rx_kill_vid;
+#ifdef CONFIG_NET_POLL_CONTROLLER
dev->poll_controller = ops->poll_controller;
+#endif
} else {
char drivername[64];
pr_info("%s (%s): not using net_device_ops yet\n",
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 02/33] netdev: introduce dev_get_stats()
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
2008-11-17 23:42 ` [PATCH 01/33] netdev: network device operations infrastructure Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:40 ` David Miller
2008-11-17 23:42 ` [PATCH 03/33] netdev: expose ethernet address primitives Stephen Hemminger
` (32 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: netdev-ops_stats.patch --]
[-- Type: text/plain, Size: 7621 bytes --]
In order for the network device ops get_stats call to be immutable, the handling
of the default internal network device stats block has to be changed. Add a new
helper function which replaces the old use of internal_get_stats.
Note: change return code to make it clear that the caller should not
go changing the returned statistics.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
arch/s390/appldata/appldata_net_sum.c | 4 ++--
drivers/net/bonding/bond_main.c | 5 +++--
drivers/net/sfc/ethtool.c | 2 +-
drivers/parisc/led.c | 4 ++--
include/linux/netdevice.h | 4 +++-
net/core/dev.c | 23 ++++++++++++++++++-----
net/core/net-sysfs.c | 3 +--
net/core/rtnetlink.c | 6 +++---
8 files changed, 33 insertions(+), 18 deletions(-)
--- a/arch/s390/appldata/appldata_net_sum.c 2008-11-17 14:53:08.000000000 -0800
+++ b/arch/s390/appldata/appldata_net_sum.c 2008-11-17 15:06:14.000000000 -0800
@@ -67,7 +67,6 @@ static void appldata_get_net_sum_data(vo
int i;
struct appldata_net_sum_data *net_data;
struct net_device *dev;
- struct net_device_stats *stats;
unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes, rx_errors,
tx_errors, rx_dropped, tx_dropped, collisions;
@@ -86,7 +85,8 @@ static void appldata_get_net_sum_data(vo
collisions = 0;
read_lock(&dev_base_lock);
for_each_netdev(&init_net, dev) {
- stats = dev->get_stats(dev);
+ const struct net_device_stats *stats = dev_get_stats(dev);
+
rx_packets += stats->rx_packets;
tx_packets += stats->tx_packets;
rx_bytes += stats->rx_bytes;
--- a/drivers/net/bonding/bond_main.c 2008-11-17 14:53:08.000000000 -0800
+++ b/drivers/net/bonding/bond_main.c 2008-11-17 15:06:14.000000000 -0800
@@ -3899,7 +3899,7 @@ static int bond_close(struct net_device
static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
- struct net_device_stats *stats = &(bond->stats), *sstats;
+ struct net_device_stats *stats = &bond->stats;
struct net_device_stats local_stats;
struct slave *slave;
int i;
@@ -3909,7 +3909,8 @@ static struct net_device_stats *bond_get
read_lock_bh(&bond->lock);
bond_for_each_slave(bond, slave, i) {
- sstats = slave->dev->get_stats(slave->dev);
+ const struct net_device_stats *sstats = dev_get_stats(slave->dev);
+
local_stats.rx_packets += sstats->rx_packets;
local_stats.rx_bytes += sstats->rx_bytes;
local_stats.rx_errors += sstats->rx_errors;
--- a/drivers/net/sfc/ethtool.c 2008-11-17 14:53:09.000000000 -0800
+++ b/drivers/net/sfc/ethtool.c 2008-11-17 15:06:14.000000000 -0800
@@ -426,7 +426,7 @@ static void efx_ethtool_get_stats(struct
EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);
/* Update MAC and NIC statistics */
- net_dev->get_stats(net_dev);
+ dev_get_stats(net_dev);
/* Fill detailed statistics buffer */
for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
--- a/drivers/parisc/led.c 2008-11-17 14:53:09.000000000 -0800
+++ b/drivers/parisc/led.c 2008-11-17 15:06:14.000000000 -0800
@@ -360,13 +360,13 @@ static __inline__ int led_get_net_activi
read_lock(&dev_base_lock);
rcu_read_lock();
for_each_netdev(&init_net, dev) {
- struct net_device_stats *stats;
+ const struct net_device_stats *stats;
struct in_device *in_dev = __in_dev_get_rcu(dev);
if (!in_dev || !in_dev->ifa_list)
continue;
if (ipv4_is_loopback(in_dev->ifa_list->ifa_local))
continue;
- stats = dev->get_stats(dev);
+ stats = dev_get_stats(dev);
rx_total += stats->rx_packets;
tx_total += stats->tx_packets;
}
--- a/include/linux/netdevice.h 2008-11-17 15:05:16.000000000 -0800
+++ b/include/linux/netdevice.h 2008-11-17 15:06:14.000000000 -0800
@@ -865,8 +865,8 @@ struct net_device
#ifdef CONFIG_NET_POLL_CONTROLLER
void (*poll_controller)(struct net_device *dev);
#endif
-#endif
};
+#endif
};
#define to_net_dev(d) container_of(d, struct net_device, dev)
@@ -1780,6 +1780,8 @@ extern void netdev_features_change(stru
/* Load a device via the kmod */
extern void dev_load(struct net *net, const char *name);
extern void dev_mcast_init(void);
+extern const struct net_device_stats *dev_get_stats(struct net_device *dev);
+
extern int netdev_max_backlog;
extern int weight_p;
extern int netdev_set_master(struct net_device *dev, struct net_device *master);
--- a/net/core/dev.c 2008-11-17 14:53:24.000000000 -0800
+++ b/net/core/dev.c 2008-11-17 15:06:14.000000000 -0800
@@ -2620,7 +2620,7 @@ void dev_seq_stop(struct seq_file *seq,
static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
{
- struct net_device_stats *stats = dev->get_stats(dev);
+ const struct net_device_stats *stats = dev_get_stats(dev);
seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
"%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
@@ -4286,10 +4286,24 @@ void netdev_run_todo(void)
}
}
-static struct net_device_stats *internal_stats(struct net_device *dev)
-{
- return &dev->stats;
+/**
+ * dev_get_stats - get network device statistics
+ * @dev: device to get statistics from
+ *
+ * Get network statistics from device. The device driver may provide
+ * its own method by setting dev->netdev_ops->get_stats; otherwise
+ * the internal statistics structure is used.
+ */
+const struct net_device_stats *dev_get_stats(struct net_device *dev)
+ {
+ const struct net_device_ops *ops = dev->netdev_ops;
+
+ if (ops->get_stats)
+ return ops->get_stats(dev);
+ else
+ return &dev->stats;
}
+EXPORT_SYMBOL(dev_get_stats);
static void netdev_init_one_queue(struct net_device *dev,
struct netdev_queue *queue,
@@ -4368,7 +4382,6 @@ struct net_device *alloc_netdev_mq(int s
netdev_init_queues(dev);
- dev->get_stats = internal_stats;
netpoll_netdev_init(dev);
setup(dev);
strcpy(dev->name, name);
--- a/net/core/net-sysfs.c 2008-11-17 14:53:08.000000000 -0800
+++ b/net/core/net-sysfs.c 2008-11-17 15:06:14.000000000 -0800
@@ -270,7 +270,6 @@ static ssize_t netstat_show(const struct
unsigned long offset)
{
struct net_device *dev = to_net_dev(d);
- struct net_device_stats *stats;
ssize_t ret = -EINVAL;
WARN_ON(offset > sizeof(struct net_device_stats) ||
@@ -278,7 +277,7 @@ static ssize_t netstat_show(const struct
read_lock(&dev_base_lock);
if (dev_isalive(dev)) {
- stats = dev->get_stats(dev);
+ const struct net_device_stats *stats = dev_get_stats(dev);
ret = sprintf(buf, fmt_ulong,
*(unsigned long *)(((u8 *) stats) + offset));
}
--- a/net/core/rtnetlink.c 2008-11-17 14:53:24.000000000 -0800
+++ b/net/core/rtnetlink.c 2008-11-17 15:06:14.000000000 -0800
@@ -551,7 +551,7 @@ static void set_operstate(struct net_dev
}
static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
- struct net_device_stats *b)
+ const struct net_device_stats *b)
{
a->rx_packets = b->rx_packets;
a->tx_packets = b->tx_packets;
@@ -609,7 +609,7 @@ static int rtnl_fill_ifinfo(struct sk_bu
struct netdev_queue *txq;
struct ifinfomsg *ifm;
struct nlmsghdr *nlh;
- struct net_device_stats *stats;
+ const struct net_device_stats *stats;
struct nlattr *attr;
nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
@@ -666,7 +666,7 @@ static int rtnl_fill_ifinfo(struct sk_bu
if (attr == NULL)
goto nla_put_failure;
- stats = dev->get_stats(dev);
+ stats = dev_get_stats(dev);
copy_rtnl_link_stats(nla_data(attr), stats);
if (dev->rtnl_link_ops) {
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 02/33] netdev: introduce dev_get_stats()
2008-11-17 23:42 ` [PATCH 02/33] netdev: introduce dev_get_stats() Stephen Hemminger
@ 2008-11-20 5:40 ` David Miller
2008-11-20 9:17 ` Eric Dumazet
0 siblings, 1 reply; 93+ messages in thread
From: David Miller @ 2008-11-20 5:40 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 15:42:09 -0800
> In order for the network device ops get_stats call to be immutable, the handling
> of the default internal network device stats block has to be changed. Add a new
> helper function which replaces the old use of internal_get_stats.
>
> Note: change return code to make it clear that the caller should not
> go changing the returned statistics.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Applied.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 02/33] netdev: introduce dev_get_stats()
2008-11-20 5:40 ` David Miller
@ 2008-11-20 9:17 ` Eric Dumazet
2008-11-20 12:27 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Eric Dumazet @ 2008-11-20 9:17 UTC (permalink / raw)
To: David Miller; +Cc: shemminger, netdev
David Miller a écrit :
> From: Stephen Hemminger <shemminger@vyatta.com>
> Date: Mon, 17 Nov 2008 15:42:09 -0800
>
>> In order for the network device ops get_stats call to be immutable, the handling
>> of the default internal network device stats block has to be changed. Add a new
>> helper function which replaces the old use of internal_get_stats.
>>
>> Note: change return code to make it clear that the caller should not
>> go changing the returned statistics.
>>
>> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> Applied.
I have one comment about netdev stats
on 32bit arches, SMP :
struct net_device = 0x480
offsetof(struct net_device, features)=0x44
offsetof(struct net_device, stats)=0x50
offsetof(struct net_device, stats.rx_packets)=0x50
So we trash features field, thats a problem...
I wonder if we could zap stats from netdev structure.
Some drivers already use external stats handling (like loopback)
get_dev_stats() would accept a second parameter : a pointer to a struct net_device_stats
provided by the reader, that the driver could use as a working zone, or not.
static struct net_device_stats *bond_get_stats(struct net_device *bond_dev,
struct net_device_stats *temp)
{
struct bonding *bond = netdev_priv(bond_dev);
struct net_device_stats wrk;
struct slave *slave;
int i;
/* use the caller provided zone */
memset(temp, 0, sizeof(struct net_device_stats));
read_lock_bh(&bond->lock);
bond_for_each_slave(bond, slave, i) {
const struct net_device_stats *sstats = dev_get_stats(slave->dev, &wrk);
temp->rx_packets += sstats->rx_packets;
temp->rx_bytes += sstats->rx_bytes;
temp->rx_errors += sstats->rx_errors;
...
}
read_unlock_bh(&bond->lock);
return temp;
}
....
static struct net_device_stats *loopback_get_stats(struct net_device *dev,
struct net_device_stats *temp)
{
const struct pcpu_lstats *pcpu_lstats;
unsigned long bytes = 0;
unsigned long packets = 0;
int i;
memset(temp, 0, sizeof(*temp);
pcpu_lstats = dev->ml_priv;
for_each_possible_cpu(i) {
const struct pcpu_lstats *lb_stats;
lb_stats = per_cpu_ptr(pcpu_lstats, i);
bytes += lb_stats->bytes;
packets += lb_stats->packets;
}
temp->rx_packets = packets;
temp->tx_packets = packets;
temp->rx_bytes = bytes;
temp->tx_bytes = bytes;
return temp;
}
...
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 02/33] netdev: introduce dev_get_stats()
2008-11-20 9:17 ` Eric Dumazet
@ 2008-11-20 12:27 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 12:27 UTC (permalink / raw)
To: dada1; +Cc: shemminger, netdev
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Thu, 20 Nov 2008 10:17:02 +0100
> I have one comment about netdev stats
>
> on 32bit arches, SMP :
>
> struct net_device = 0x480
> offsetof(struct net_device, features)=0x44
> offsetof(struct net_device, stats)=0x50
> offsetof(struct net_device, stats.rx_packets)=0x50
>
> So we trash features field, thats a problem...
>
> I wonder if we could zap stats from netdev structure.
> Some drivers already use external stats handling (like loopback)
Some... but most just want a single stats structure, and that's
what this is for.
Let's just put the appropriate alignment tags in struct net_device
after all of this dust settles, ok?
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 03/33] netdev: expose ethernet address primitives
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
2008-11-17 23:42 ` [PATCH 01/33] netdev: network device operations infrastructure Stephen Hemminger
2008-11-17 23:42 ` [PATCH 02/33] netdev: introduce dev_get_stats() Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:45 ` David Miller
2008-11-17 23:42 ` [PATCH 04/33] netdev: convert loopback to net_device_ops Stephen Hemminger
` (31 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: eth-netdev-ops.patch --]
[-- Type: text/plain, Size: 2708 bytes --]
When ethernet devices are converted, the function pointer setup
by eth_setup() need to be done during intialization.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
include/linux/etherdevice.h | 4 ++++
net/ethernet/eth.c | 13 ++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
--- a/include/linux/etherdevice.h 2008-11-17 14:53:08.000000000 -0800
+++ b/include/linux/etherdevice.h 2008-11-17 15:06:23.000000000 -0800
@@ -41,6 +41,10 @@ extern int eth_header_cache(const struct
extern void eth_header_cache_update(struct hh_cache *hh,
const struct net_device *dev,
const unsigned char *haddr);
+extern int eth_mac_addr(struct net_device *dev, void *p);
+extern int eth_change_mtu(struct net_device *dev, int new_mtu);
+extern int eth_validate_addr(struct net_device *dev);
+
extern struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count);
--- a/net/ethernet/eth.c 2008-11-17 14:53:08.000000000 -0800
+++ b/net/ethernet/eth.c 2008-11-17 15:06:23.000000000 -0800
@@ -282,7 +282,7 @@ EXPORT_SYMBOL(eth_header_cache_update);
* This doesn't change hardware matching, so needs to be overridden
* for most real devices.
*/
-static int eth_mac_addr(struct net_device *dev, void *p)
+int eth_mac_addr(struct net_device *dev, void *p)
{
struct sockaddr *addr = p;
@@ -293,6 +293,7 @@ static int eth_mac_addr(struct net_devic
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
return 0;
}
+EXPORT_SYMBOL(eth_mac_addr);
/**
* eth_change_mtu - set new MTU size
@@ -302,21 +303,23 @@ static int eth_mac_addr(struct net_devic
* Allow changing MTU size. Needs to be overridden for devices
* supporting jumbo frames.
*/
-static int eth_change_mtu(struct net_device *dev, int new_mtu)
+int eth_change_mtu(struct net_device *dev, int new_mtu)
{
if (new_mtu < 68 || new_mtu > ETH_DATA_LEN)
return -EINVAL;
dev->mtu = new_mtu;
return 0;
}
+EXPORT_SYMBOL(eth_change_mtu);
-static int eth_validate_addr(struct net_device *dev)
+int eth_validate_addr(struct net_device *dev)
{
if (!is_valid_ether_addr(dev->dev_addr))
return -EADDRNOTAVAIL;
return 0;
}
+EXPORT_SYMBOL(eth_validate_addr);
const struct header_ops eth_header_ops ____cacheline_aligned = {
.create = eth_header,
@@ -334,11 +337,11 @@ const struct header_ops eth_header_ops _
void ether_setup(struct net_device *dev)
{
dev->header_ops = ð_header_ops;
-
+#ifdef CONFIG_COMPAT_NET_DEV_OPS
dev->change_mtu = eth_change_mtu;
dev->set_mac_address = eth_mac_addr;
dev->validate_addr = eth_validate_addr;
-
+#endif
dev->type = ARPHRD_ETHER;
dev->hard_header_len = ETH_HLEN;
dev->mtu = ETH_DATA_LEN;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 03/33] netdev: expose ethernet address primitives
2008-11-17 23:42 ` [PATCH 03/33] netdev: expose ethernet address primitives Stephen Hemminger
@ 2008-11-20 5:45 ` David Miller
2008-11-20 6:40 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: David Miller @ 2008-11-20 5:45 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 15:42:10 -0800
> When ethernet devices are converted, the function pointer setup
> by eth_setup() need to be done during intialization.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Applied.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 03/33] netdev: expose ethernet address primitives
2008-11-20 5:45 ` David Miller
@ 2008-11-20 6:40 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 6:40 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: David Miller <davem@davemloft.net>
Date: Wed, 19 Nov 2008 21:45:25 -0800 (PST)
> From: Stephen Hemminger <shemminger@vyatta.com>
> Date: Mon, 17 Nov 2008 15:42:10 -0800
>
> > When ethernet devices are converted, the function pointer setup
> > by eth_setup() need to be done during intialization.
> >
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> Applied.
Ok, I have to make a slight modification to this change.
Build testing showed that drivers/usb/gadget/u_ether.c has static
functions with the same name, in particular eth_change_mtu().
I'll rename the function in the usb driver and respin everything
before pushing out.
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 04/33] netdev: convert loopback to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (2 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 03/33] netdev: expose ethernet address primitives Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:46 ` David Miller
2008-11-17 23:42 ` [PATCH 05/33] ifb: convert " Stephen Hemminger
` (30 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: loopback-netdev-ops.patch --]
[-- Type: text/plain, Size: 1456 bytes --]
First device to convert over is the loopback device.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/loopback.c 2008-11-17 12:21:00.000000000 -0800
+++ b/drivers/net/loopback.c 2008-11-17 12:28:45.000000000 -0800
@@ -87,7 +87,7 @@ static int loopback_xmit(struct sk_buff
return 0;
}
-static struct net_device_stats *get_stats(struct net_device *dev)
+static struct net_device_stats *loopback_get_stats(struct net_device *dev)
{
const struct pcpu_lstats *pcpu_lstats;
struct net_device_stats *stats = &dev->stats;
@@ -143,13 +143,17 @@ static void loopback_dev_free(struct net
free_netdev(dev);
}
+static const struct net_device_ops loopback_ops = {
+ .init = loopback_dev_init,
+ .get_stats = loopback_get_stats,
+};
+
/*
* The loopback device is special. There is only one instance
* per network namespace.
*/
static void loopback_setup(struct net_device *dev)
{
- dev->get_stats = &get_stats;
dev->mtu = (16 * 1024) + 20 + 20 + 12;
dev->hard_start_xmit = loopback_xmit;
dev->hard_header_len = ETH_HLEN; /* 14 */
@@ -165,8 +169,8 @@ static void loopback_setup(struct net_de
| NETIF_F_NETNS_LOCAL;
dev->ethtool_ops = &loopback_ethtool_ops;
dev->header_ops = ð_header_ops;
- dev->init = loopback_dev_init;
- dev->destructor = loopback_dev_free;
+ dev->netdev_ops = &loopback_ops;
+ dev->destructor = loopback_dev_free;
}
/* Setup and register the loopback device. */
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 05/33] ifb: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (3 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 04/33] netdev: convert loopback to net_device_ops Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:47 ` David Miller
2008-11-17 23:42 ` [PATCH 06/33] dummy: " Stephen Hemminger
` (29 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: ifb-netdev_ops.patch --]
[-- Type: text/plain, Size: 897 bytes --]
Convert to new network device ops interface.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/ifb.c 2008-11-02 09:43:24.000000000 -0800
+++ b/drivers/net/ifb.c 2008-11-02 10:06:17.000000000 -0800
@@ -137,18 +137,23 @@ resched:
}
+static const struct net_device_ops ifb_netdev_ops = {
+ .validate_addr = eth_validate_addr,
+ .open = ifb_open,
+ .stop = ifb_close,
+};
+
static void ifb_setup(struct net_device *dev)
{
/* Initialize the device structure. */
dev->hard_start_xmit = ifb_xmit;
- dev->open = &ifb_open;
- dev->stop = &ifb_close;
dev->destructor = free_netdev;
+ dev->netdev_ops = &ifb_netdev_ops;
/* Fill in device structure with ethernet-generic values. */
ether_setup(dev);
dev->tx_queue_len = TX_Q_LIMIT;
- dev->change_mtu = NULL;
+
dev->flags |= IFF_NOARP;
dev->flags &= ~IFF_MULTICAST;
random_ether_addr(dev->dev_addr);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 06/33] dummy: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (4 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 05/33] ifb: convert " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:48 ` David Miller
2008-11-17 23:42 ` [PATCH 07/33] bridge: " Stephen Hemminger
` (28 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: dummy-netdev_ops.patch --]
[-- Type: text/plain, Size: 1035 bytes --]
Convert to new network device ops interface.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/dummy.c 2008-11-02 09:43:24.000000000 -0800
+++ b/drivers/net/dummy.c 2008-11-02 10:06:15.000000000 -0800
@@ -57,18 +57,23 @@ static void set_multicast_list(struct ne
{
}
+static const struct net_device_ops dummy_netdev_ops = {
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = set_multicast_list,
+ .set_mac_address = dummy_set_address,
+};
+
static void dummy_setup(struct net_device *dev)
{
+ ether_setup(dev);
+
/* Initialize the device structure. */
+ dev->netdev_ops = &dummy_netdev_ops;
dev->hard_start_xmit = dummy_xmit;
- dev->set_multicast_list = set_multicast_list;
- dev->set_mac_address = dummy_set_address;
dev->destructor = free_netdev;
/* Fill in device structure with ethernet-generic values. */
- ether_setup(dev);
dev->tx_queue_len = 0;
- dev->change_mtu = NULL;
dev->flags |= IFF_NOARP;
dev->flags &= ~IFF_MULTICAST;
random_ether_addr(dev->dev_addr);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 07/33] bridge: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (5 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 06/33] dummy: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:49 ` David Miller
2008-11-17 23:42 ` [PATCH 08/33] veth: " Stephen Hemminger
` (27 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: bridge-netdev_ops.patch --]
[-- Type: text/plain, Size: 1491 bytes --]
Convert to net_device_ops function table.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/bridge/br_device.c 2008-11-17 10:23:18.000000000 -0800
+++ b/net/bridge/br_device.c 2008-11-17 10:25:05.000000000 -0800
@@ -147,7 +147,7 @@ static int br_set_tx_csum(struct net_dev
return 0;
}
-static struct ethtool_ops br_ethtool_ops = {
+static const struct ethtool_ops br_ethtool_ops = {
.get_drvinfo = br_getinfo,
.get_link = ethtool_op_get_link,
.get_tx_csum = ethtool_op_get_tx_csum,
@@ -160,21 +160,25 @@ static struct ethtool_ops br_ethtool_ops
.get_flags = ethtool_op_get_flags,
};
+static const struct net_device_ops br_netdev_ops = {
+ .open = br_dev_open,
+ .stop = br_dev_stop,
+ .set_mac_address = br_set_mac_address,
+ .set_multicast_list = br_dev_set_multicast_list,
+ .change_mtu = br_change_mtu,
+ .do_ioctl = br_dev_ioctl,
+};
+
void br_dev_setup(struct net_device *dev)
{
random_ether_addr(dev->dev_addr);
ether_setup(dev);
- dev->do_ioctl = br_dev_ioctl;
+ dev->netdev_ops = &br_netdev_ops;
dev->hard_start_xmit = br_dev_xmit;
- dev->open = br_dev_open;
- dev->set_multicast_list = br_dev_set_multicast_list;
- dev->change_mtu = br_change_mtu;
dev->destructor = free_netdev;
SET_ETHTOOL_OPS(dev, &br_ethtool_ops);
- dev->stop = br_dev_stop;
dev->tx_queue_len = 0;
- dev->set_mac_address = br_set_mac_address;
dev->priv_flags = IFF_EBRIDGE;
dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 08/33] veth: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (6 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 07/33] bridge: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:50 ` David Miller
2008-11-17 23:42 ` [PATCH 09/33] macvlan: " Stephen Hemminger
` (26 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: veth-netdev_ops.patch --]
[-- Type: text/plain, Size: 1016 bytes --]
Convert to net_device_ops function tabl.e
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/veth.c 2008-11-17 10:27:34.000000000 -0800
+++ b/drivers/net/veth.c 2008-11-17 10:28:30.000000000 -0800
@@ -262,16 +262,20 @@ static void veth_dev_free(struct net_dev
free_netdev(dev);
}
+static const struct net_device_ops veth_netdev_ops = {
+ .init = veth_dev_init,
+ .open = veth_open,
+ .get_stats = veth_get_stats,
+};
+
static void veth_setup(struct net_device *dev)
{
ether_setup(dev);
+ dev->netdev_ops = &veth_netdev_ops;
dev->hard_start_xmit = veth_xmit;
- dev->get_stats = veth_get_stats;
- dev->open = veth_open;
dev->ethtool_ops = &veth_ethtool_ops;
dev->features |= NETIF_F_LLTX;
- dev->init = veth_dev_init;
dev->destructor = veth_dev_free;
}
@@ -297,7 +301,7 @@ static int veth_device_event(struct noti
{
struct net_device *dev = ptr;
- if (dev->open != veth_open)
+ if (dev->netdev_ops->open != veth_open)
goto out;
switch (event) {
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 09/33] macvlan: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (7 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 08/33] veth: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:51 ` David Miller
2008-11-17 23:42 ` [PATCH 10/33] ip: convert to net_device_ops for ioctl Stephen Hemminger
` (25 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: macvlan-netdev_ops.patch --]
[-- Type: text/plain, Size: 1236 bytes --]
Convert to net_device_ops function table.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/macvlan.c 2008-11-04 13:58:06.000000000 -0800
+++ b/drivers/net/macvlan.c 2008-11-17 10:25:18.000000000 -0800
@@ -361,17 +361,22 @@ static const struct ethtool_ops macvlan_
.get_flags = macvlan_ethtool_get_flags,
};
+static const struct net_device_ops macvlan_netdev_ops = {
+ .init = macvlan_init,
+ .open = macvlan_open,
+ .stop = macvlan_stop,
+ .change_mtu = macvlan_change_mtu,
+ .change_rx_flags= macvlan_change_rx_flags,
+ .set_mac_address= macvlan_set_mac_address,
+ .set_multicast_list= macvlan_set_multicast_list,
+ .validate_addr = eth_validate_addr,
+};
+
static void macvlan_setup(struct net_device *dev)
{
ether_setup(dev);
- dev->init = macvlan_init;
- dev->open = macvlan_open;
- dev->stop = macvlan_stop;
- dev->change_mtu = macvlan_change_mtu;
- dev->change_rx_flags = macvlan_change_rx_flags;
- dev->set_mac_address = macvlan_set_mac_address;
- dev->set_multicast_list = macvlan_set_multicast_list;
+ dev->netdev_ops = &macvlan_netdev_ops;
dev->hard_start_xmit = macvlan_hard_start_xmit;
dev->destructor = free_netdev;
dev->header_ops = &macvlan_hard_header_ops,
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 10/33] ip: convert to net_device_ops for ioctl
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (8 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 09/33] macvlan: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:52 ` David Miller
2008-11-17 23:42 ` [PATCH 11/33] vlan: convert to net_device_ops Stephen Hemminger
` (24 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: ip-ioctl.patch --]
[-- Type: text/plain, Size: 2639 bytes --]
Convert to net_device_ops function table pointer for ioctl.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/ipv4/ipmr.c 2008-11-17 12:37:11.000000000 -0800
+++ b/net/ipv4/ipmr.c 2008-11-17 12:38:54.000000000 -0800
@@ -124,8 +124,8 @@ static void ipmr_del_tunnel(struct net_d
dev = __dev_get_by_name(&init_net, "tunl0");
if (dev) {
+ const struct net_device_ops *ops = dev->netdev_ops;
struct ifreq ifr;
- mm_segment_t oldfs;
struct ip_tunnel_parm p;
memset(&p, 0, sizeof(p));
@@ -137,9 +137,13 @@ static void ipmr_del_tunnel(struct net_d
sprintf(p.name, "dvmrp%d", v->vifc_vifi);
ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
- oldfs = get_fs(); set_fs(KERNEL_DS);
- dev->do_ioctl(dev, &ifr, SIOCDELTUNNEL);
- set_fs(oldfs);
+ if (ops->do_ioctl) {
+ mm_segment_t oldfs = get_fs();
+
+ set_fs(KERNEL_DS);
+ ops->do_ioctl(dev, &ifr, SIOCDELTUNNEL);
+ set_fs(oldfs);
+ }
}
}
@@ -151,9 +155,9 @@ struct net_device *ipmr_new_tunnel(struc
dev = __dev_get_by_name(&init_net, "tunl0");
if (dev) {
+ const struct net_device_ops *ops = dev->netdev_ops;
int err;
struct ifreq ifr;
- mm_segment_t oldfs;
struct ip_tunnel_parm p;
struct in_device *in_dev;
@@ -166,9 +170,14 @@ struct net_device *ipmr_new_tunnel(struc
sprintf(p.name, "dvmrp%d", v->vifc_vifi);
ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
- oldfs = get_fs(); set_fs(KERNEL_DS);
- err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
- set_fs(oldfs);
+ if (ops->do_ioctl) {
+ mm_segment_t oldfs = get_fs();
+
+ set_fs(KERNEL_DS);
+ err = ops->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
+ set_fs(oldfs);
+ } else
+ err = -EOPNOTSUPP;
dev = NULL;
--- a/net/ipv6/addrconf.c 2008-11-17 12:37:26.000000000 -0800
+++ b/net/ipv6/addrconf.c 2008-11-17 12:38:39.000000000 -0800
@@ -2031,8 +2031,8 @@ int addrconf_set_dstaddr(struct net *net
#if defined(CONFIG_IPV6_SIT) || defined(CONFIG_IPV6_SIT_MODULE)
if (dev->type == ARPHRD_SIT) {
+ const struct net_device_ops *ops = dev->netdev_ops;
struct ifreq ifr;
- mm_segment_t oldfs;
struct ip_tunnel_parm p;
err = -EADDRNOTAVAIL;
@@ -2048,9 +2048,14 @@ int addrconf_set_dstaddr(struct net *net
p.iph.ttl = 64;
ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
- oldfs = get_fs(); set_fs(KERNEL_DS);
- err = dev->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
- set_fs(oldfs);
+ if (ops->do_ioctl) {
+ mm_segment_t oldfs = get_fs();
+
+ set_fs(KERNEL_DS);
+ err = ops->do_ioctl(dev, &ifr, SIOCADDTUNNEL);
+ set_fs(oldfs);
+ } else
+ err = -EOPNOTSUPP;
if (err == 0) {
err = -ENOBUFS;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 11/33] vlan: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (9 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 10/33] ip: convert to net_device_ops for ioctl Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:54 ` David Miller
2008-11-17 23:42 ` [PATCH 12/33] bonding: " Stephen Hemminger
` (23 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: vlan-netdev_ops.patch --]
[-- Type: text/plain, Size: 4801 bytes --]
Convert vlan devices and function pointers to net_device_ops.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/net/8021q/vlan.c 2008-11-17 11:45:49.000000000 -0800
+++ b/net/8021q/vlan.c 2008-11-17 11:46:37.000000000 -0800
@@ -144,6 +144,7 @@ void unregister_vlan_dev(struct net_devi
{
struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_dev;
+ const struct net_device_ops *ops = real_dev->netdev_ops;
struct vlan_group *grp;
u16 vlan_id = vlan->vlan_id;
@@ -156,7 +157,7 @@ void unregister_vlan_dev(struct net_devi
* HW accelerating devices or SW vlan input packet processing.
*/
if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
- real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
+ ops->vlan_rx_kill_vid(real_dev, vlan_id);
vlan_group_set_device(grp, vlan_id, NULL);
grp->nr_vlans--;
@@ -170,7 +171,7 @@ void unregister_vlan_dev(struct net_devi
vlan_gvrp_uninit_applicant(real_dev);
if (real_dev->features & NETIF_F_HW_VLAN_RX)
- real_dev->vlan_rx_register(real_dev, NULL);
+ ops->vlan_rx_register(real_dev, NULL);
hlist_del_rcu(&grp->hlist);
@@ -205,21 +206,21 @@ static void vlan_transfer_operstate(cons
int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id)
{
- char *name = real_dev->name;
+ const char *name = real_dev->name;
+ const struct net_device_ops *ops = real_dev->netdev_ops;
if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
pr_info("8021q: VLANs not supported on %s\n", name);
return -EOPNOTSUPP;
}
- if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
- !real_dev->vlan_rx_register) {
+ if ((real_dev->features & NETIF_F_HW_VLAN_RX) && !ops->vlan_rx_register) {
pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
return -EOPNOTSUPP;
}
if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
- (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
+ (!ops->vlan_rx_add_vid || !ops->vlan_rx_kill_vid)) {
pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
return -EOPNOTSUPP;
}
@@ -240,6 +241,7 @@ int register_vlan_dev(struct net_device
{
struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_dev;
+ const struct net_device_ops *ops = real_dev->netdev_ops;
u16 vlan_id = vlan->vlan_id;
struct vlan_group *grp, *ngrp = NULL;
int err;
@@ -275,9 +277,9 @@ int register_vlan_dev(struct net_device
grp->nr_vlans++;
if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
- real_dev->vlan_rx_register(real_dev, ngrp);
+ ops->vlan_rx_register(real_dev, ngrp);
if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
- real_dev->vlan_rx_add_vid(real_dev, vlan_id);
+ ops->vlan_rx_add_vid(real_dev, vlan_id);
return 0;
--- a/net/8021q/vlan_dev.c 2008-11-17 11:45:49.000000000 -0800
+++ b/net/8021q/vlan_dev.c 2008-11-17 11:46:37.000000000 -0800
@@ -524,6 +524,7 @@ out:
static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
+ const struct net_device_ops *ops = real_dev->netdev_ops;
struct ifreq ifrr;
int err = -EOPNOTSUPP;
@@ -534,8 +535,8 @@ static int vlan_dev_ioctl(struct net_dev
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
- if (real_dev->do_ioctl && netif_device_present(real_dev))
- err = real_dev->do_ioctl(real_dev, &ifrr, cmd);
+ if (netif_device_present(real_dev) && ops->do_ioctl)
+ err = ops->do_ioctl(real_dev, &ifrr, cmd);
break;
}
@@ -697,6 +698,20 @@ static const struct ethtool_ops vlan_eth
.get_flags = vlan_ethtool_get_flags,
};
+static const struct net_device_ops vlan_netdev_ops = {
+ .change_mtu = vlan_dev_change_mtu,
+ .init = vlan_dev_init,
+ .uninit = vlan_dev_uninit,
+ .open = vlan_dev_open,
+ .stop = vlan_dev_stop,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = vlan_dev_set_mac_address,
+ .set_rx_mode = vlan_dev_set_rx_mode,
+ .set_multicast_list = vlan_dev_set_rx_mode,
+ .change_rx_flags = vlan_dev_change_rx_flags,
+ .do_ioctl = vlan_dev_ioctl,
+};
+
void vlan_setup(struct net_device *dev)
{
ether_setup(dev);
@@ -704,16 +719,7 @@ void vlan_setup(struct net_device *dev)
dev->priv_flags |= IFF_802_1Q_VLAN;
dev->tx_queue_len = 0;
- dev->change_mtu = vlan_dev_change_mtu;
- dev->init = vlan_dev_init;
- dev->uninit = vlan_dev_uninit;
- dev->open = vlan_dev_open;
- dev->stop = vlan_dev_stop;
- dev->set_mac_address = vlan_dev_set_mac_address;
- dev->set_rx_mode = vlan_dev_set_rx_mode;
- dev->set_multicast_list = vlan_dev_set_rx_mode;
- dev->change_rx_flags = vlan_dev_change_rx_flags;
- dev->do_ioctl = vlan_dev_ioctl;
+ dev->netdev_ops = &vlan_netdev_ops;
dev->destructor = free_netdev;
dev->ethtool_ops = &vlan_ethtool_ops;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 12/33] bonding: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (10 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 11/33] vlan: convert to net_device_ops Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:56 ` David Miller
2008-11-17 23:42 ` [PATCH 13/33] e1000e: " Stephen Hemminger
` (22 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: bonding-netdev_ops.patch --]
[-- Type: text/plain, Size: 10460 bytes --]
Convert to net_device_ops table.
Note: for some operations move error checking into generic networking
layer (rather than looking at pointers in bonding).
A couple of gratituous style cleanups to get rid of extra {}
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/bonding/bond_alb.c 2008-11-17 13:02:53.000000000 -0800
+++ b/drivers/net/bonding/bond_alb.c 2008-11-17 13:02:59.000000000 -0800
@@ -1218,11 +1218,6 @@ static int alb_set_mac_address(struct bo
}
bond_for_each_slave(bond, slave, i) {
- if (slave->dev->set_mac_address == NULL) {
- res = -EOPNOTSUPP;
- goto unwind;
- }
-
/* save net_device's current hw address */
memcpy(tmp_addr, slave->dev->dev_addr, ETH_ALEN);
@@ -1231,9 +1226,8 @@ static int alb_set_mac_address(struct bo
/* restore net_device's hw address */
memcpy(slave->dev->dev_addr, tmp_addr, ETH_ALEN);
- if (res) {
+ if (res)
goto unwind;
- }
}
return 0;
--- a/drivers/net/bonding/bond_main.c 2008-11-17 13:02:53.000000000 -0800
+++ b/drivers/net/bonding/bond_main.c 2008-11-17 13:02:59.000000000 -0800
@@ -462,10 +462,11 @@ static void bond_vlan_rx_register(struct
bond_for_each_slave(bond, slave, i) {
struct net_device *slave_dev = slave->dev;
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
if ((slave_dev->features & NETIF_F_HW_VLAN_RX) &&
- slave_dev->vlan_rx_register) {
- slave_dev->vlan_rx_register(slave_dev, grp);
+ slave_ops->vlan_rx_register) {
+ slave_ops->vlan_rx_register(slave_dev, grp);
}
}
}
@@ -483,10 +484,11 @@ static void bond_vlan_rx_add_vid(struct
bond_for_each_slave(bond, slave, i) {
struct net_device *slave_dev = slave->dev;
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
if ((slave_dev->features & NETIF_F_HW_VLAN_FILTER) &&
- slave_dev->vlan_rx_add_vid) {
- slave_dev->vlan_rx_add_vid(slave_dev, vid);
+ slave_ops->vlan_rx_add_vid) {
+ slave_ops->vlan_rx_add_vid(slave_dev, vid);
}
}
@@ -512,14 +514,15 @@ static void bond_vlan_rx_kill_vid(struct
bond_for_each_slave(bond, slave, i) {
struct net_device *slave_dev = slave->dev;
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
if ((slave_dev->features & NETIF_F_HW_VLAN_FILTER) &&
- slave_dev->vlan_rx_kill_vid) {
+ slave_ops->vlan_rx_kill_vid) {
/* Save and then restore vlan_dev in the grp array,
* since the slave's driver might clear it.
*/
vlan_dev = vlan_group_get_device(bond->vlgrp, vid);
- slave_dev->vlan_rx_kill_vid(slave_dev, vid);
+ slave_ops->vlan_rx_kill_vid(slave_dev, vid);
vlan_group_set_device(bond->vlgrp, vid, vlan_dev);
}
}
@@ -535,26 +538,23 @@ static void bond_vlan_rx_kill_vid(struct
static void bond_add_vlans_on_slave(struct bonding *bond, struct net_device *slave_dev)
{
struct vlan_entry *vlan;
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
write_lock_bh(&bond->lock);
- if (list_empty(&bond->vlan_list)) {
+ if (list_empty(&bond->vlan_list))
goto out;
- }
if ((slave_dev->features & NETIF_F_HW_VLAN_RX) &&
- slave_dev->vlan_rx_register) {
- slave_dev->vlan_rx_register(slave_dev, bond->vlgrp);
- }
+ slave_ops->vlan_rx_register)
+ slave_ops->vlan_rx_register(slave_dev, bond->vlgrp);
if (!(slave_dev->features & NETIF_F_HW_VLAN_FILTER) ||
- !(slave_dev->vlan_rx_add_vid)) {
+ !(slave_ops->vlan_rx_add_vid))
goto out;
- }
- list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
- slave_dev->vlan_rx_add_vid(slave_dev, vlan->vlan_id);
- }
+ list_for_each_entry(vlan, &bond->vlan_list, vlan_list)
+ slave_ops->vlan_rx_add_vid(slave_dev, vlan->vlan_id);
out:
write_unlock_bh(&bond->lock);
@@ -562,34 +562,32 @@ out:
static void bond_del_vlans_from_slave(struct bonding *bond, struct net_device *slave_dev)
{
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
struct vlan_entry *vlan;
struct net_device *vlan_dev;
write_lock_bh(&bond->lock);
- if (list_empty(&bond->vlan_list)) {
+ if (list_empty(&bond->vlan_list))
goto out;
- }
if (!(slave_dev->features & NETIF_F_HW_VLAN_FILTER) ||
- !(slave_dev->vlan_rx_kill_vid)) {
+ !(slave_ops->vlan_rx_kill_vid))
goto unreg;
- }
list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
/* Save and then restore vlan_dev in the grp array,
* since the slave's driver might clear it.
*/
vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
- slave_dev->vlan_rx_kill_vid(slave_dev, vlan->vlan_id);
+ slave_ops->vlan_rx_kill_vid(slave_dev, vlan->vlan_id);
vlan_group_set_device(bond->vlgrp, vlan->vlan_id, vlan_dev);
}
unreg:
if ((slave_dev->features & NETIF_F_HW_VLAN_RX) &&
- slave_dev->vlan_rx_register) {
- slave_dev->vlan_rx_register(slave_dev, NULL);
- }
+ slave_ops->vlan_rx_register)
+ slave_ops->vlan_rx_register(slave_dev, NULL);
out:
write_unlock_bh(&bond->lock);
@@ -698,15 +696,15 @@ static int bond_update_speed_duplex(stru
*/
static int bond_check_dev_link(struct bonding *bond, struct net_device *slave_dev, int reporting)
{
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
static int (* ioctl)(struct net_device *, struct ifreq *, int);
struct ifreq ifr;
struct mii_ioctl_data *mii;
- if (bond->params.use_carrier) {
+ if (bond->params.use_carrier)
return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0;
- }
- ioctl = slave_dev->do_ioctl;
+ ioctl = slave_ops->do_ioctl;
if (ioctl) {
/* TODO: set pointer to correct ioctl on a per team member */
/* bases to make this more efficient. that is, once */
@@ -1401,6 +1398,7 @@ static void bond_setup_by_slave(struct n
int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
+ const struct net_device_ops *slave_ops = slave_dev->netdev_ops;
struct slave *new_slave = NULL;
struct dev_mc_list *dmi;
struct sockaddr addr;
@@ -1409,7 +1407,7 @@ int bond_enslave(struct net_device *bond
int res = 0;
if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL &&
- slave_dev->do_ioctl == NULL) {
+ slave_ops->do_ioctl == NULL) {
printk(KERN_WARNING DRV_NAME
": %s: Warning: no link monitoring support for %s\n",
bond_dev->name, slave_dev->name);
@@ -1491,7 +1489,7 @@ int bond_enslave(struct net_device *bond
goto err_undo_flags;
}
- if (slave_dev->set_mac_address == NULL) {
+ if (slave_ops->set_mac_address == NULL) {
if (bond->slave_cnt == 0) {
printk(KERN_WARNING DRV_NAME
": %s: Warning: The first slave device "
@@ -4208,6 +4206,10 @@ static int bond_set_mac_address(struct n
int res = 0;
int i;
+ if (bond->params.mode == BOND_MODE_ALB)
+ return bond_alb_set_mac_address(bond_dev, addr);
+
+
dprintk("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None"));
/*
@@ -4237,9 +4239,10 @@ static int bond_set_mac_address(struct n
*/
bond_for_each_slave(bond, slave, i) {
+ const struct net_device_ops *slave_ops = slave->dev->netdev_ops;
dprintk("slave %p %s\n", slave, slave->dev->name);
- if (slave->dev->set_mac_address == NULL) {
+ if (slave_ops->set_mac_address == NULL) {
res = -EOPNOTSUPP;
dprintk("EOPNOTSUPP %s\n", slave->dev->name);
goto unwind;
@@ -4517,7 +4520,6 @@ void bond_set_mode_ops(struct bonding *b
/* FALLTHRU */
case BOND_MODE_TLB:
bond_dev->hard_start_xmit = bond_alb_xmit;
- bond_dev->set_mac_address = bond_alb_set_mac_address;
break;
default:
/* Should never happen, mode already checked */
@@ -4547,6 +4549,20 @@ static const struct ethtool_ops bond_eth
.get_flags = ethtool_op_get_flags,
};
+static const struct net_device_ops bond_netdev_ops = {
+ .open = bond_open,
+ .stop = bond_close,
+ .get_stats = bond_get_stats,
+ .do_ioctl = bond_do_ioctl,
+ .set_multicast_list = bond_set_multicast_list,
+ .change_mtu = bond_change_mtu,
+ .validate_addr = NULL,
+ .set_mac_address = bond_set_mac_address,
+ .vlan_rx_register = bond_vlan_rx_register,
+ .vlan_rx_add_vid = bond_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = bond_vlan_rx_kill_vid,
+};
+
/*
* Does not allocate but creates a /proc entry.
* Allowed to fail.
@@ -4579,16 +4595,8 @@ static int bond_init(struct net_device *
INIT_LIST_HEAD(&bond->vlan_list);
/* Initialize the device entry points */
- bond_dev->open = bond_open;
- bond_dev->stop = bond_close;
- bond_dev->get_stats = bond_get_stats;
- bond_dev->do_ioctl = bond_do_ioctl;
+ bond_dev->netdev_ops = &bond_netdev_ops;
bond_dev->ethtool_ops = &bond_ethtool_ops;
- bond_dev->set_multicast_list = bond_set_multicast_list;
- bond_dev->change_mtu = bond_change_mtu;
- bond_dev->set_mac_address = bond_set_mac_address;
- bond_dev->validate_addr = NULL;
-
bond_set_mode_ops(bond, bond->params.mode);
bond_dev->destructor = bond_destructor;
@@ -4617,9 +4625,6 @@ static int bond_init(struct net_device *
* when there are slaves that are not hw accel
* capable
*/
- bond_dev->vlan_rx_register = bond_vlan_rx_register;
- bond_dev->vlan_rx_add_vid = bond_vlan_rx_add_vid;
- bond_dev->vlan_rx_kill_vid = bond_vlan_rx_kill_vid;
bond_dev->features |= (NETIF_F_HW_VLAN_TX |
NETIF_F_HW_VLAN_RX |
NETIF_F_HW_VLAN_FILTER);
--- a/drivers/net/bonding/bond_sysfs.c 2008-11-17 13:02:53.000000000 -0800
+++ b/drivers/net/bonding/bond_sysfs.c 2008-11-17 13:04:05.000000000 -0800
@@ -317,18 +317,12 @@ static ssize_t bonding_store_slaves(stru
/* Set the slave's MTU to match the bond */
original_mtu = dev->mtu;
- if (dev->mtu != bond->dev->mtu) {
- if (dev->change_mtu) {
- res = dev->change_mtu(dev,
- bond->dev->mtu);
- if (res) {
- ret = res;
- goto out;
- }
- } else {
- dev->mtu = bond->dev->mtu;
- }
+ res = dev_set_mtu(dev, bond->dev->mtu);
+ if (res) {
+ ret = res;
+ goto out;
}
+
res = bond_enslave(bond->dev, dev);
bond_for_each_slave(bond, slave, i)
if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0)
@@ -357,11 +351,7 @@ static ssize_t bonding_store_slaves(stru
goto out;
}
/* set the slave MTU to the default */
- if (dev->change_mtu) {
- dev->change_mtu(dev, original_mtu);
- } else {
- dev->mtu = original_mtu;
- }
+ dev_set_mtu(dev, original_mtu);
}
else {
printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n",
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 12/33] bonding: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 12/33] bonding: " Stephen Hemminger
@ 2008-11-20 5:56 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 5:56 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 15:42:19 -0800
> Convert to net_device_ops table.
> Note: for some operations move error checking into generic networking
> layer (rather than looking at pointers in bonding).
>
> A couple of gratituous style cleanups to get rid of extra {}
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Applied.
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 13/33] e1000e: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (11 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 12/33] bonding: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 5:58 ` David Miller
2008-11-17 23:42 ` [PATCH 14/33] sky2: " Stephen Hemminger
` (21 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: e1000e-netdev_ops.patch --]
[-- Type: text/plain, Size: 1989 bytes --]
Convert e1000e to network device ops.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/e1000e/netdev.c 2008-11-17 07:57:18.000000000 -0800
+++ b/drivers/net/e1000e/netdev.c 2008-11-17 10:25:30.000000000 -0800
@@ -4686,6 +4686,25 @@ static void e1000_eeprom_checks(struct e
}
}
+static const struct net_device_ops e1000e_netdev_ops = {
+ .open = e1000_open,
+ .stop = e1000_close,
+ .get_stats = e1000_get_stats,
+ .set_multicast_list = e1000_set_multi,
+ .set_mac_address = e1000_set_mac,
+ .change_mtu = e1000_change_mtu,
+ .do_ioctl = e1000_ioctl,
+ .tx_timeout = e1000_tx_timeout,
+ .validate_addr = eth_validate_addr,
+
+ .vlan_rx_register = e1000_vlan_rx_register,
+ .vlan_rx_add_vid = e1000_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = e1000_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = e1000_netpoll,
+#endif
+};
+
/**
* e1000_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -4783,24 +4802,11 @@ static int __devinit e1000_probe(struct
}
/* construct the net_device struct */
- netdev->open = &e1000_open;
- netdev->stop = &e1000_close;
+ netdev->netdev_ops = &e1000e_netdev_ops;
netdev->hard_start_xmit = &e1000_xmit_frame;
- netdev->get_stats = &e1000_get_stats;
- netdev->set_multicast_list = &e1000_set_multi;
- netdev->set_mac_address = &e1000_set_mac;
- netdev->change_mtu = &e1000_change_mtu;
- netdev->do_ioctl = &e1000_ioctl;
e1000e_set_ethtool_ops(netdev);
- netdev->tx_timeout = &e1000_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
- netdev->vlan_rx_register = e1000_vlan_rx_register;
- netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = e1000_netpoll;
-#endif
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
netdev->mem_start = mmio_start;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 14/33] sky2: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (12 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 13/33] e1000e: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-18 1:37 ` Stephen Hemminger
2008-11-17 23:42 ` [PATCH 15/33] skge: " Stephen Hemminger
` (20 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: sky2-netdev_ops.patch --]
[-- Type: text/plain, Size: 2735 bytes --]
Convert to new network device ops interface. Slight additional complexity
here because the second port does not allow netpoll and therefore has
different virtual function table.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/sky2.c 2008-11-02 09:48:53.000000000 -0800
+++ b/drivers/net/sky2.c 2008-11-02 10:06:05.000000000 -0800
@@ -3979,7 +3979,7 @@ static int sky2_device_event(struct noti
struct net_device *dev = ptr;
struct sky2_port *sky2 = netdev_priv(dev);
- if (dev->open != sky2_up || !sky2_debug)
+ if (dev->netdev_ops->open != sky2_up || !sky2_debug)
return NOTIFY_DONE;
switch(event) {
@@ -4041,6 +4041,35 @@ static __exit void sky2_debug_cleanup(vo
#define sky2_debug_cleanup()
#endif
+/* Two copies of network device operations to handle special case of
+ not allowing netpoll on second port */
+static const struct net_device_ops sky2_netdev_ops[2] = {
+ {
+ .open = sky2_up,
+ .stop = sky2_down,
+ .do_ioctl = sky2_ioctl,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = sky2_set_mac_address,
+ .set_multicast_list = sky2_set_multicast,
+ .change_mtu = sky2_change_mtu,
+ .tx_timeout = sky2_tx_timeout,
+ .vlan_rx_register = sky2_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = sky2_netpoll,
+#endif
+ },
+ {
+ .open = sky2_up,
+ .stop = sky2_down,
+ .do_ioctl = sky2_ioctl,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = sky2_set_mac_address,
+ .set_multicast_list = sky2_set_multicast,
+ .change_mtu = sky2_change_mtu,
+ .tx_timeout = sky2_tx_timeout,
+ .vlan_rx_register = sky2_vlan_rx_register,
+ },
+};
/* Initialize network device */
static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
@@ -4057,20 +4086,10 @@ static __devinit struct net_device *sky2
SET_NETDEV_DEV(dev, &hw->pdev->dev);
dev->irq = hw->pdev->irq;
- dev->open = sky2_up;
- dev->stop = sky2_down;
- dev->do_ioctl = sky2_ioctl;
dev->hard_start_xmit = sky2_xmit_frame;
- dev->set_multicast_list = sky2_set_multicast;
- dev->set_mac_address = sky2_set_mac_address;
- dev->change_mtu = sky2_change_mtu;
SET_ETHTOOL_OPS(dev, &sky2_ethtool_ops);
- dev->tx_timeout = sky2_tx_timeout;
dev->watchdog_timeo = TX_WATCHDOG;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- if (port == 0)
- dev->poll_controller = sky2_netpoll;
-#endif
+ dev->netdev_ops = &sky2_netdev_ops[port];
sky2 = netdev_priv(dev);
sky2->netdev = dev;
@@ -4104,7 +4123,6 @@ static __devinit struct net_device *sky2
if (!(sky2->hw->chip_id == CHIP_ID_YUKON_FE_P &&
sky2->hw->chip_rev == CHIP_REV_YU_FE2_A0)) {
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = sky2_vlan_rx_register;
}
#endif
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 14/33] sky2: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 14/33] sky2: " Stephen Hemminger
@ 2008-11-18 1:37 ` Stephen Hemminger
2008-11-20 6:00 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-18 1:37 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Convert to new network device ops interface. Slight additional complexity
here because the second port does not allow netpoll and therefore has
different virtual function table.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Handle non-vlan build.
--- a/drivers/net/sky2.c 2008-11-17 17:21:59.000000000 -0800
+++ b/drivers/net/sky2.c 2008-11-17 17:23:33.000000000 -0800
@@ -3979,7 +3979,7 @@ static int sky2_device_event(struct noti
struct net_device *dev = ptr;
struct sky2_port *sky2 = netdev_priv(dev);
- if (dev->open != sky2_up || !sky2_debug)
+ if (dev->netdev_ops->open != sky2_up || !sky2_debug)
return NOTIFY_DONE;
switch(event) {
@@ -4041,6 +4041,39 @@ static __exit void sky2_debug_cleanup(vo
#define sky2_debug_cleanup()
#endif
+/* Two copies of network device operations to handle special case of
+ not allowing netpoll on second port */
+static const struct net_device_ops sky2_netdev_ops[2] = {
+ {
+ .open = sky2_up,
+ .stop = sky2_down,
+ .do_ioctl = sky2_ioctl,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = sky2_set_mac_address,
+ .set_multicast_list = sky2_set_multicast,
+ .change_mtu = sky2_change_mtu,
+ .tx_timeout = sky2_tx_timeout,
+#ifdef SKY2_VLAN_TAG_USED
+ .vlan_rx_register = sky2_vlan_rx_register,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = sky2_netpoll,
+#endif
+ },
+ {
+ .open = sky2_up,
+ .stop = sky2_down,
+ .do_ioctl = sky2_ioctl,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = sky2_set_mac_address,
+ .set_multicast_list = sky2_set_multicast,
+ .change_mtu = sky2_change_mtu,
+ .tx_timeout = sky2_tx_timeout,
+#ifdef SKY2_VLAN_TAG_USED
+ .vlan_rx_register = sky2_vlan_rx_register,
+#endif
+ },
+};
/* Initialize network device */
static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
@@ -4057,20 +4090,10 @@ static __devinit struct net_device *sky2
SET_NETDEV_DEV(dev, &hw->pdev->dev);
dev->irq = hw->pdev->irq;
- dev->open = sky2_up;
- dev->stop = sky2_down;
- dev->do_ioctl = sky2_ioctl;
dev->hard_start_xmit = sky2_xmit_frame;
- dev->set_multicast_list = sky2_set_multicast;
- dev->set_mac_address = sky2_set_mac_address;
- dev->change_mtu = sky2_change_mtu;
SET_ETHTOOL_OPS(dev, &sky2_ethtool_ops);
- dev->tx_timeout = sky2_tx_timeout;
dev->watchdog_timeo = TX_WATCHDOG;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- if (port == 0)
- dev->poll_controller = sky2_netpoll;
-#endif
+ dev->netdev_ops = &sky2_netdev_ops[port];
sky2 = netdev_priv(dev);
sky2->netdev = dev;
@@ -4104,7 +4127,6 @@ static __devinit struct net_device *sky2
if (!(sky2->hw->chip_id == CHIP_ID_YUKON_FE_P &&
sky2->hw->chip_rev == CHIP_REV_YU_FE2_A0)) {
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = sky2_vlan_rx_register;
}
#endif
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 14/33] sky2: convert to net_device_ops
2008-11-18 1:37 ` Stephen Hemminger
@ 2008-11-20 6:00 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 6:00 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 17:37:52 -0800
> Convert to new network device ops interface. Slight additional complexity
> here because the second port does not allow netpoll and therefore has
> different virtual function table.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> ---
> Handle non-vlan build.
Applied.
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 15/33] skge: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (13 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 14/33] sky2: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:01 ` David Miller
2008-11-17 23:42 ` [PATCH 16/33] r8169: " Stephen Hemminger
` (19 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: skge-netdev_ops.patch --]
[-- Type: text/plain, Size: 2997 bytes --]
Convert to new network device ops interface.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/skge.c 2008-11-04 13:58:06.000000000 -0800
+++ b/drivers/net/skge.c 2008-11-17 10:30:05.000000000 -0800
@@ -104,6 +104,7 @@ static void yukon_get_stats(struct skge_
static void yukon_init(struct skge_hw *hw, int port);
static void genesis_mac_init(struct skge_hw *hw, int port);
static void genesis_link_up(struct skge_port *skge);
+static void skge_set_multicast(struct net_device *dev);
/* Avoid conditionals by using array */
static const int txqaddr[] = { Q_XA1, Q_XA2 };
@@ -2463,7 +2464,7 @@ static void skge_phy_reset(struct skge_p
}
spin_unlock_bh(&hw->phy_lock);
- dev->set_multicast_list(dev);
+ skge_set_multicast(dev);
}
/* Basic MII support */
@@ -3031,6 +3032,18 @@ static inline int bad_phy_status(const s
(status & GMR_FS_RX_OK) == 0;
}
+static void skge_set_multicast(struct net_device *dev)
+{
+ struct skge_port *skge = netdev_priv(dev);
+ struct skge_hw *hw = skge->hw;
+
+ if (hw->chip_id == CHIP_ID_GENESIS)
+ genesis_set_multicast(dev);
+ else
+ yukon_set_multicast(dev);
+
+}
+
/* Get receive buffer from descriptor.
* Handles copy of small buffers and reallocation failures
@@ -3715,7 +3728,7 @@ static int skge_device_event(struct noti
struct skge_port *skge;
struct dentry *d;
- if (dev->open != &skge_up || !skge_debug)
+ if (dev->netdev_ops->open != &skge_up || !skge_debug)
goto done;
skge = netdev_priv(dev);
@@ -3789,6 +3802,22 @@ static __exit void skge_debug_cleanup(vo
#define skge_debug_cleanup()
#endif
+static const struct net_device_ops skge_netdev_ops = {
+ .open = skge_up,
+ .stop = skge_down,
+ .do_ioctl = skge_ioctl,
+ .get_stats = skge_get_stats,
+ .tx_timeout = skge_tx_timeout,
+ .change_mtu = skge_change_mtu,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = skge_set_multicast,
+ .set_mac_address = skge_set_mac_address,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = skge_netpoll,
+#endif
+};
+
+
/* Initialize network device */
static struct net_device *skge_devinit(struct skge_hw *hw, int port,
int highmem)
@@ -3802,24 +3831,10 @@ static struct net_device *skge_devinit(s
}
SET_NETDEV_DEV(dev, &hw->pdev->dev);
- dev->open = skge_up;
- dev->stop = skge_down;
- dev->do_ioctl = skge_ioctl;
dev->hard_start_xmit = skge_xmit_frame;
- dev->get_stats = skge_get_stats;
- if (hw->chip_id == CHIP_ID_GENESIS)
- dev->set_multicast_list = genesis_set_multicast;
- else
- dev->set_multicast_list = yukon_set_multicast;
-
- dev->set_mac_address = skge_set_mac_address;
- dev->change_mtu = skge_change_mtu;
- SET_ETHTOOL_OPS(dev, &skge_ethtool_ops);
- dev->tx_timeout = skge_tx_timeout;
+ dev->netdev_ops = &skge_netdev_ops;
+ dev->ethtool_ops = &skge_ethtool_ops;
dev->watchdog_timeo = TX_WATCHDOG;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = skge_netpoll;
-#endif
dev->irq = hw->pdev->irq;
if (highmem)
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 16/33] r8169: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (14 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 15/33] skge: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-18 1:38 ` Stephen Hemminger
2008-11-17 23:42 ` [PATCH 17/33] 8139: " Stephen Hemminger
` (18 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: r8169-netdev_ops.patch --]
[-- Type: text/plain, Size: 2725 bytes --]
Convert to new network device ops interface. In this case needed
to match behaviour of old code which only allowed ioctl on some
device types.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/r8169.c 2008-11-17 11:34:07.000000000 -0800
+++ b/drivers/net/r8169.c 2008-11-17 11:46:31.000000000 -0800
@@ -1832,6 +1832,9 @@ static int rtl8169_ioctl(struct net_devi
if (!netif_running(dev))
return -ENODEV;
+ if (tp->get_settings != rtl8169_gset_xmii)
+ return -EOPNOTSUPP;
+
switch (cmd) {
case SIOCGMIIPHY:
data->phy_id = 32; /* Internal PHY */
@@ -1915,6 +1918,23 @@ static void rtl_disable_msi(struct pci_d
}
}
+static const struct net_device_ops rtl8169_netdev_ops = {
+ .open = rtl8169_open,
+ .stop = rtl8169_close,
+ .get_stats = rtl8169_get_stats,
+ .tx_timeout = rtl8169_tx_timeout,
+ .validate_addr = eth_validate_addr,
+ .change_mtu = rtl8169_change_mtu,
+ .set_mac_address = rtl_set_mac_address,
+ .do_ioctl = rtl8169_ioctl,
+ .set_multicast_list = rtl_set_rx_mode,
+ .vlan_rx_register = rtl8169_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = rtl8169_netpoll,
+#endif
+
+};
+
static int __devinit
rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
@@ -1941,6 +1961,7 @@ rtl8169_init_one(struct pci_dev *pdev, c
}
SET_NETDEV_DEV(dev, &pdev->dev);
+ dev->netdev_ops = &rtl8169_netdev_ops;
tp = netdev_priv(dev);
tp->dev = dev;
tp->pci_dev = pdev;
@@ -2084,8 +2105,6 @@ rtl8169_init_one(struct pci_dev *pdev, c
tp->phy_reset_enable = rtl8169_xmii_reset_enable;
tp->phy_reset_pending = rtl8169_xmii_reset_pending;
tp->link_ok = rtl8169_xmii_link_ok;
-
- dev->do_ioctl = rtl8169_ioctl;
}
spin_lock_init(&tp->lock);
@@ -2097,28 +2116,16 @@ rtl8169_init_one(struct pci_dev *pdev, c
dev->dev_addr[i] = RTL_R8(MAC0 + i);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
- dev->open = rtl8169_open;
dev->hard_start_xmit = rtl8169_start_xmit;
- dev->get_stats = rtl8169_get_stats;
SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
- dev->stop = rtl8169_close;
- dev->tx_timeout = rtl8169_tx_timeout;
- dev->set_multicast_list = rtl_set_rx_mode;
dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
dev->irq = pdev->irq;
dev->base_addr = (unsigned long) ioaddr;
- dev->change_mtu = rtl8169_change_mtu;
- dev->set_mac_address = rtl_set_mac_address;
netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT);
#ifdef CONFIG_R8169_VLAN
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = rtl8169_vlan_rx_register;
-#endif
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = rtl8169_netpoll;
#endif
tp->intr_mask = 0xffff;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 16/33] r8169: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 16/33] r8169: " Stephen Hemminger
@ 2008-11-18 1:38 ` Stephen Hemminger
2008-11-18 21:18 ` Francois Romieu
0 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-18 1:38 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Convert to new network device ops interface. In this case needed
to match behaviour of old code which only allowed ioctl on some
device types.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Handle no vlan case as well.
--- a/drivers/net/r8169.c 2008-11-17 17:21:59.000000000 -0800
+++ b/drivers/net/r8169.c 2008-11-17 17:24:25.000000000 -0800
@@ -1832,6 +1832,9 @@ static int rtl8169_ioctl(struct net_devi
if (!netif_running(dev))
return -ENODEV;
+ if (tp->get_settings != rtl8169_gset_xmii)
+ return -EOPNOTSUPP;
+
switch (cmd) {
case SIOCGMIIPHY:
data->phy_id = 32; /* Internal PHY */
@@ -1915,6 +1918,25 @@ static void rtl_disable_msi(struct pci_d
}
}
+static const struct net_device_ops rtl8169_netdev_ops = {
+ .open = rtl8169_open,
+ .stop = rtl8169_close,
+ .get_stats = rtl8169_get_stats,
+ .tx_timeout = rtl8169_tx_timeout,
+ .validate_addr = eth_validate_addr,
+ .change_mtu = rtl8169_change_mtu,
+ .set_mac_address = rtl_set_mac_address,
+ .do_ioctl = rtl8169_ioctl,
+ .set_multicast_list = rtl_set_rx_mode,
+#ifdef CONFIG_R8169_VLAN
+ .vlan_rx_register = rtl8169_vlan_rx_register,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = rtl8169_netpoll,
+#endif
+
+};
+
static int __devinit
rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
@@ -1941,6 +1963,7 @@ rtl8169_init_one(struct pci_dev *pdev, c
}
SET_NETDEV_DEV(dev, &pdev->dev);
+ dev->netdev_ops = &rtl8169_netdev_ops;
tp = netdev_priv(dev);
tp->dev = dev;
tp->pci_dev = pdev;
@@ -2084,8 +2107,6 @@ rtl8169_init_one(struct pci_dev *pdev, c
tp->phy_reset_enable = rtl8169_xmii_reset_enable;
tp->phy_reset_pending = rtl8169_xmii_reset_pending;
tp->link_ok = rtl8169_xmii_link_ok;
-
- dev->do_ioctl = rtl8169_ioctl;
}
spin_lock_init(&tp->lock);
@@ -2097,28 +2118,16 @@ rtl8169_init_one(struct pci_dev *pdev, c
dev->dev_addr[i] = RTL_R8(MAC0 + i);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
- dev->open = rtl8169_open;
dev->hard_start_xmit = rtl8169_start_xmit;
- dev->get_stats = rtl8169_get_stats;
SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
- dev->stop = rtl8169_close;
- dev->tx_timeout = rtl8169_tx_timeout;
- dev->set_multicast_list = rtl_set_rx_mode;
dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
dev->irq = pdev->irq;
dev->base_addr = (unsigned long) ioaddr;
- dev->change_mtu = rtl8169_change_mtu;
- dev->set_mac_address = rtl_set_mac_address;
netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT);
#ifdef CONFIG_R8169_VLAN
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = rtl8169_vlan_rx_register;
-#endif
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = rtl8169_netpoll;
#endif
tp->intr_mask = 0xffff;
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 16/33] r8169: convert to net_device_ops
2008-11-18 1:38 ` Stephen Hemminger
@ 2008-11-18 21:18 ` Francois Romieu
2008-11-20 6:07 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Francois Romieu @ 2008-11-18 21:18 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Stephen Hemminger <shemminger@vyatta.com> :
> Convert to new network device ops interface. In this case needed
> to match behaviour of old code which only allowed ioctl on some
> device types.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> ---
> Handle no vlan case as well.
>
> --- a/drivers/net/r8169.c 2008-11-17 17:21:59.000000000 -0800
> +++ b/drivers/net/r8169.c 2008-11-17 17:24:25.000000000 -0800
> @@ -1832,6 +1832,9 @@ static int rtl8169_ioctl(struct net_devi
> if (!netif_running(dev))
> return -ENODEV;
>
> + if (tp->get_settings != rtl8169_gset_xmii)
> + return -EOPNOTSUPP;
> +
It's a bit hackish. Would you raise an objection against the code
below ?
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 4b7cb38..983ec8b 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -474,6 +474,7 @@ struct rtl8169_private {
void (*hw_start)(struct net_device *);
unsigned int (*phy_reset_pending)(void __iomem *);
unsigned int (*link_ok)(void __iomem *);
+ int do_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data);
int pcie_cap;
struct delayed_work task;
unsigned features;
@@ -1829,9 +1830,11 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
struct rtl8169_private *tp = netdev_priv(dev);
struct mii_ioctl_data *data = if_mii(ifr);
- if (!netif_running(dev))
- return -ENODEV;
+ return netif_running(dev) ? tp->do_ioctl(tp, data) : -ENODEV;
+}
+static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data)
+{
switch (cmd) {
case SIOCGMIIPHY:
data->phy_id = 32; /* Internal PHY */
@@ -1850,6 +1853,11 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return -EOPNOTSUPP;
}
+static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data)
+{
+ return -EOPNOTSUPP;
+}
+
static const struct rtl_cfg_info {
void (*hw_start)(struct net_device *);
unsigned int region;
@@ -1915,6 +1923,25 @@ static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp)
}
}
+static const struct net_device_ops rtl8169_netdev_ops = {
+ .open = rtl8169_open,
+ .stop = rtl8169_close,
+ .get_stats = rtl8169_get_stats,
+ .tx_timeout = rtl8169_tx_timeout,
+ .validate_addr = eth_validate_addr,
+ .change_mtu = rtl8169_change_mtu,
+ .set_mac_address = rtl_set_mac_address,
+ .do_ioctl = rtl8169_ioctl,
+ .set_multicast_list = rtl_set_rx_mode,
+#ifdef CONFIG_R8169_VLAN
+ .vlan_rx_register = rtl8169_vlan_rx_register,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = rtl8169_netpoll,
+#endif
+
+};
+
static int __devinit
rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
@@ -1941,6 +1968,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
SET_NETDEV_DEV(dev, &pdev->dev);
+ dev->netdev_ops = &rtl8169_netdev_ops;
tp = netdev_priv(dev);
tp->dev = dev;
tp->pci_dev = pdev;
@@ -2076,6 +2104,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->phy_reset_enable = rtl8169_tbi_reset_enable;
tp->phy_reset_pending = rtl8169_tbi_reset_pending;
tp->link_ok = rtl8169_tbi_link_ok;
+ tp->do_ioctl = rtl_tbi_ioctl;
tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */
} else {
@@ -2084,8 +2113,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->phy_reset_enable = rtl8169_xmii_reset_enable;
tp->phy_reset_pending = rtl8169_xmii_reset_pending;
tp->link_ok = rtl8169_xmii_link_ok;
-
- dev->do_ioctl = rtl8169_ioctl;
+ tp->do_ioctl = rtl_xmii_ioctl;
}
spin_lock_init(&tp->lock);
@@ -2097,28 +2125,16 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->dev_addr[i] = RTL_R8(MAC0 + i);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
- dev->open = rtl8169_open;
dev->hard_start_xmit = rtl8169_start_xmit;
- dev->get_stats = rtl8169_get_stats;
SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
- dev->stop = rtl8169_close;
- dev->tx_timeout = rtl8169_tx_timeout;
- dev->set_multicast_list = rtl_set_rx_mode;
dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
dev->irq = pdev->irq;
dev->base_addr = (unsigned long) ioaddr;
- dev->change_mtu = rtl8169_change_mtu;
- dev->set_mac_address = rtl_set_mac_address;
netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT);
#ifdef CONFIG_R8169_VLAN
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = rtl8169_vlan_rx_register;
-#endif
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = rtl8169_netpoll;
#endif
tp->intr_mask = 0xffff;
--
Ueimor
^ permalink raw reply related [flat|nested] 93+ messages in thread* Re: [PATCH 16/33] r8169: convert to net_device_ops
2008-11-18 21:18 ` Francois Romieu
@ 2008-11-20 6:07 ` David Miller
2008-11-20 19:55 ` Francois Romieu
0 siblings, 1 reply; 93+ messages in thread
From: David Miller @ 2008-11-20 6:07 UTC (permalink / raw)
To: romieu; +Cc: shemminger, netdev
From: Francois Romieu <romieu@fr.zoreil.com>
Date: Tue, 18 Nov 2008 22:18:58 +0100
> Stephen Hemminger <shemminger@vyatta.com> :
> > Convert to new network device ops interface. In this case needed
> > to match behaviour of old code which only allowed ioctl on some
> > device types.
> >
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> > ---
> > Handle no vlan case as well.
> >
> > --- a/drivers/net/r8169.c 2008-11-17 17:21:59.000000000 -0800
> > +++ b/drivers/net/r8169.c 2008-11-17 17:24:25.000000000 -0800
> > @@ -1832,6 +1832,9 @@ static int rtl8169_ioctl(struct net_devi
> > if (!netif_running(dev))
> > return -ENODEV;
> >
> > + if (tp->get_settings != rtl8169_gset_xmii)
> > + return -EOPNOTSUPP;
> > +
>
> It's a bit hackish. Would you raise an objection against the code
> below ?
I applied this (actually build tested, sigh) version of your patch.
Please, if you are going to propose a real patch, at least do a
minimal build test on it.
If you cannot be bothered to do that, either be happy with the
original submission or make your suggestion using pseudo-code or plain
english.
Otherwise what you post looks like something I can expect to apply
and use.
r8169: convert to net_device_ops
From: Francois Romieu <romieu@fr.zoreil.com>
Based upon a patch by Stephen Hemminger.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/r8169.c | 48 ++++++++++++++++++++++++++++++++----------------
1 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index cb5042e..bac58ca 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -474,6 +474,7 @@ struct rtl8169_private {
void (*hw_start)(struct net_device *);
unsigned int (*phy_reset_pending)(void __iomem *);
unsigned int (*link_ok)(void __iomem *);
+ int (*do_ioctl)(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd);
int pcie_cap;
struct delayed_work task;
unsigned features;
@@ -1829,9 +1830,11 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
struct rtl8169_private *tp = netdev_priv(dev);
struct mii_ioctl_data *data = if_mii(ifr);
- if (!netif_running(dev))
- return -ENODEV;
+ return netif_running(dev) ? tp->do_ioctl(tp, data, cmd) : -ENODEV;
+}
+static int rtl_xmii_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd)
+{
switch (cmd) {
case SIOCGMIIPHY:
data->phy_id = 32; /* Internal PHY */
@@ -1850,6 +1853,11 @@ static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
return -EOPNOTSUPP;
}
+static int rtl_tbi_ioctl(struct rtl8169_private *tp, struct mii_ioctl_data *data, int cmd)
+{
+ return -EOPNOTSUPP;
+}
+
static const struct rtl_cfg_info {
void (*hw_start)(struct net_device *);
unsigned int region;
@@ -1915,6 +1923,25 @@ static void rtl_disable_msi(struct pci_dev *pdev, struct rtl8169_private *tp)
}
}
+static const struct net_device_ops rtl8169_netdev_ops = {
+ .ndo_open = rtl8169_open,
+ .ndo_stop = rtl8169_close,
+ .ndo_get_stats = rtl8169_get_stats,
+ .ndo_tx_timeout = rtl8169_tx_timeout,
+ .ndo_validate_addr = eth_validate_addr,
+ .ndo_change_mtu = rtl8169_change_mtu,
+ .ndo_set_mac_address = rtl_set_mac_address,
+ .ndo_do_ioctl = rtl8169_ioctl,
+ .ndo_set_multicast_list = rtl_set_rx_mode,
+#ifdef CONFIG_R8169_VLAN
+ .ndo_vlan_rx_register = rtl8169_vlan_rx_register,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = rtl8169_netpoll,
+#endif
+
+};
+
static int __devinit
rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
@@ -1941,6 +1968,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
}
SET_NETDEV_DEV(dev, &pdev->dev);
+ dev->netdev_ops = &rtl8169_netdev_ops;
tp = netdev_priv(dev);
tp->dev = dev;
tp->pci_dev = pdev;
@@ -2076,6 +2104,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->phy_reset_enable = rtl8169_tbi_reset_enable;
tp->phy_reset_pending = rtl8169_tbi_reset_pending;
tp->link_ok = rtl8169_tbi_link_ok;
+ tp->do_ioctl = rtl_tbi_ioctl;
tp->phy_1000_ctrl_reg = ADVERTISE_1000FULL; /* Implied by TBI */
} else {
@@ -2084,8 +2113,7 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp->phy_reset_enable = rtl8169_xmii_reset_enable;
tp->phy_reset_pending = rtl8169_xmii_reset_pending;
tp->link_ok = rtl8169_xmii_link_ok;
-
- dev->do_ioctl = rtl8169_ioctl;
+ tp->do_ioctl = rtl_xmii_ioctl;
}
spin_lock_init(&tp->lock);
@@ -2097,28 +2125,16 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->dev_addr[i] = RTL_R8(MAC0 + i);
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
- dev->open = rtl8169_open;
dev->hard_start_xmit = rtl8169_start_xmit;
- dev->get_stats = rtl8169_get_stats;
SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
- dev->stop = rtl8169_close;
- dev->tx_timeout = rtl8169_tx_timeout;
- dev->set_multicast_list = rtl_set_rx_mode;
dev->watchdog_timeo = RTL8169_TX_TIMEOUT;
dev->irq = pdev->irq;
dev->base_addr = (unsigned long) ioaddr;
- dev->change_mtu = rtl8169_change_mtu;
- dev->set_mac_address = rtl_set_mac_address;
netif_napi_add(dev, &tp->napi, rtl8169_poll, R8169_NAPI_WEIGHT);
#ifdef CONFIG_R8169_VLAN
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = rtl8169_vlan_rx_register;
-#endif
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = rtl8169_netpoll;
#endif
tp->intr_mask = 0xffff;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 93+ messages in thread
* [PATCH 17/33] 8139: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (15 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 16/33] r8169: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-18 1:39 ` Stephen Hemminger
2008-11-17 23:42 ` [PATCH 18/33] tun: " Stephen Hemminger
` (17 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: 8139-netdev_ops.patch --]
[-- Type: text/plain, Size: 3577 bytes --]
Convert to new network device ops interface.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
drivers/net/8139cp.c | 31 ++++++++++++++++++-------------
drivers/net/8139too.c | 27 ++++++++++++++++-----------
2 files changed, 34 insertions(+), 24 deletions(-)
--- a/drivers/net/8139cp.c 2008-11-04 13:58:05.000000000 -0800
+++ b/drivers/net/8139cp.c 2008-11-17 11:53:01.000000000 -0800
@@ -1817,6 +1817,23 @@ static void cp_set_d3_state (struct cp_p
pci_set_power_state (cp->pdev, PCI_D3hot);
}
+static const struct net_device_ops cp_netdev_ops = {
+ .open = cp_open,
+ .stop = cp_close,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = cp_set_rx_mode,
+ .get_stats = cp_get_stats,
+ .do_ioctl = cp_ioctl,
+ .tx_timeout = cp_tx_timeout,
+ .vlan_rx_register = cp_vlan_rx_register,
+#ifdef BROKEN
+ .change_mtu = cp_change_mtu,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = cp_poll_controller,
+#endif
+};
+
static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
@@ -1929,26 +1946,14 @@ static int cp_init_one (struct pci_dev *
cpu_to_le16(read_eeprom (regs, i + 7, addr_len));
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
- dev->open = cp_open;
- dev->stop = cp_close;
- dev->set_multicast_list = cp_set_rx_mode;
+ dev->netdev_ops = &cp_netdev_ops;
dev->hard_start_xmit = cp_start_xmit;
- dev->get_stats = cp_get_stats;
- dev->do_ioctl = cp_ioctl;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = cp_poll_controller;
-#endif
netif_napi_add(dev, &cp->napi, cp_rx_poll, 16);
-#ifdef BROKEN
- dev->change_mtu = cp_change_mtu;
-#endif
dev->ethtool_ops = &cp_ethtool_ops;
- dev->tx_timeout = cp_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#if CP_VLAN_TAG_USED
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = cp_vlan_rx_register;
#endif
if (pci_using_dac)
--- a/drivers/net/8139too.c 2008-11-04 13:58:05.000000000 -0800
+++ b/drivers/net/8139too.c 2008-11-17 11:53:01.000000000 -0800
@@ -916,6 +916,19 @@ err_out:
return rc;
}
+static const struct net_device_ops rtl8139_netdev_ops = {
+ .open = rtl8139_open,
+ .stop = rtl8139_close,
+ .get_stats = rtl8139_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = rtl8139_set_rx_mode,
+ .do_ioctl = netdev_ioctl,
+ .tx_timeout = rtl8139_tx_timeout,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = rtl8139_poll_controller,
+#endif
+
+};
static int __devinit rtl8139_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent)
@@ -976,19 +989,11 @@ static int __devinit rtl8139_init_one (s
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
/* The Rtl8139-specific entries in the device structure. */
- dev->open = rtl8139_open;
- dev->hard_start_xmit = rtl8139_start_xmit;
- netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
- dev->stop = rtl8139_close;
- dev->get_stats = rtl8139_get_stats;
- dev->set_multicast_list = rtl8139_set_rx_mode;
- dev->do_ioctl = netdev_ioctl;
+ dev->netdev_ops = &rtl8139_netdev_ops;
dev->ethtool_ops = &rtl8139_ethtool_ops;
- dev->tx_timeout = rtl8139_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = rtl8139_poll_controller;
-#endif
+ dev->hard_start_xmit = rtl8139_start_xmit;
+ netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
/* note: the hardware is not capable of sg/csum/highdma, however
* through the use of skb_copy_and_csum_dev we enable these
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 17/33] 8139: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 17/33] 8139: " Stephen Hemminger
@ 2008-11-18 1:39 ` Stephen Hemminger
2008-11-20 6:09 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-18 1:39 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Convert to new network device ops interface.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Handle non-vlan tag support as well
drivers/net/8139cp.c | 31 ++++++++++++++++++-------------
drivers/net/8139too.c | 27 ++++++++++++++++-----------
2 files changed, 34 insertions(+), 24 deletions(-)
--- a/drivers/net/8139cp.c 2008-11-17 17:21:59.000000000 -0800
+++ b/drivers/net/8139cp.c 2008-11-17 17:24:58.000000000 -0800
@@ -1817,6 +1817,25 @@ static void cp_set_d3_state (struct cp_p
pci_set_power_state (cp->pdev, PCI_D3hot);
}
+static const struct net_device_ops cp_netdev_ops = {
+ .open = cp_open,
+ .stop = cp_close,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = cp_set_rx_mode,
+ .get_stats = cp_get_stats,
+ .do_ioctl = cp_ioctl,
+ .tx_timeout = cp_tx_timeout,
+#if CP_VLAN_TAG_USED
+ .vlan_rx_register = cp_vlan_rx_register,
+#endif
+#ifdef BROKEN
+ .change_mtu = cp_change_mtu,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = cp_poll_controller,
+#endif
+};
+
static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
@@ -1929,26 +1948,14 @@ static int cp_init_one (struct pci_dev *
cpu_to_le16(read_eeprom (regs, i + 7, addr_len));
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
- dev->open = cp_open;
- dev->stop = cp_close;
- dev->set_multicast_list = cp_set_rx_mode;
+ dev->netdev_ops = &cp_netdev_ops;
dev->hard_start_xmit = cp_start_xmit;
- dev->get_stats = cp_get_stats;
- dev->do_ioctl = cp_ioctl;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = cp_poll_controller;
-#endif
netif_napi_add(dev, &cp->napi, cp_rx_poll, 16);
-#ifdef BROKEN
- dev->change_mtu = cp_change_mtu;
-#endif
dev->ethtool_ops = &cp_ethtool_ops;
- dev->tx_timeout = cp_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
#if CP_VLAN_TAG_USED
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = cp_vlan_rx_register;
#endif
if (pci_using_dac)
--- a/drivers/net/8139too.c 2008-11-17 17:21:59.000000000 -0800
+++ b/drivers/net/8139too.c 2008-11-17 17:24:37.000000000 -0800
@@ -916,6 +916,19 @@ err_out:
return rc;
}
+static const struct net_device_ops rtl8139_netdev_ops = {
+ .open = rtl8139_open,
+ .stop = rtl8139_close,
+ .get_stats = rtl8139_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = rtl8139_set_rx_mode,
+ .do_ioctl = netdev_ioctl,
+ .tx_timeout = rtl8139_tx_timeout,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = rtl8139_poll_controller,
+#endif
+
+};
static int __devinit rtl8139_init_one (struct pci_dev *pdev,
const struct pci_device_id *ent)
@@ -976,19 +989,11 @@ static int __devinit rtl8139_init_one (s
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
/* The Rtl8139-specific entries in the device structure. */
- dev->open = rtl8139_open;
- dev->hard_start_xmit = rtl8139_start_xmit;
- netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
- dev->stop = rtl8139_close;
- dev->get_stats = rtl8139_get_stats;
- dev->set_multicast_list = rtl8139_set_rx_mode;
- dev->do_ioctl = netdev_ioctl;
+ dev->netdev_ops = &rtl8139_netdev_ops;
dev->ethtool_ops = &rtl8139_ethtool_ops;
- dev->tx_timeout = rtl8139_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = rtl8139_poll_controller;
-#endif
+ dev->hard_start_xmit = rtl8139_start_xmit;
+ netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
/* note: the hardware is not capable of sg/csum/highdma, however
* through the use of skb_copy_and_csum_dev we enable these
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 18/33] tun: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (16 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 17/33] 8139: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:10 ` David Miller
2008-11-17 23:42 ` [PATCH 19/33] atl1e: " Stephen Hemminger
` (16 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: tun-netdev_ops.patch --]
[-- Type: text/plain, Size: 2080 bytes --]
Convert the TUN/TAP tunnel driver to net_device_ops.
Split the ops in two, and retain compatability.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/tun.c 2008-11-17 14:03:49.000000000 -0800
+++ b/drivers/net/tun.c 2008-11-17 14:43:57.000000000 -0800
@@ -305,6 +305,22 @@ tun_net_change_mtu(struct net_device *de
return 0;
}
+static const struct net_device_ops tun_netdev_ops = {
+ .open = tun_net_open,
+ .stop = tun_net_close,
+ .change_mtu = tun_net_change_mtu,
+
+};
+
+static const struct net_device_ops tap_netdev_ops = {
+ .open = tun_net_open,
+ .stop = tun_net_close,
+ .change_mtu = tun_net_change_mtu,
+ .set_multicast_list = tun_net_mclist,
+ .set_mac_address = eth_mac_addr,
+ .validate_addr = eth_validate_addr,
+};
+
/* Initialize net device. */
static void tun_net_init(struct net_device *dev)
{
@@ -312,11 +328,12 @@ static void tun_net_init(struct net_devi
switch (tun->flags & TUN_TYPE_MASK) {
case TUN_TUN_DEV:
+ dev->netdev_ops = &tun_netdev_ops;
+
/* Point-to-Point TUN Device */
dev->hard_header_len = 0;
dev->addr_len = 0;
dev->mtu = 1500;
- dev->change_mtu = tun_net_change_mtu;
/* Zero header length */
dev->type = ARPHRD_NONE;
@@ -325,10 +342,9 @@ static void tun_net_init(struct net_devi
break;
case TUN_TAP_DEV:
+ dev->netdev_ops = &tun_netdev_ops;
/* Ethernet TAP Device */
ether_setup(dev);
- dev->change_mtu = tun_net_change_mtu;
- dev->set_multicast_list = tun_net_mclist;
random_ether_addr(dev->dev_addr);
@@ -675,9 +691,7 @@ static void tun_setup(struct net_device
tun->owner = -1;
tun->group = -1;
- dev->open = tun_net_open;
dev->hard_start_xmit = tun_net_xmit;
- dev->stop = tun_net_close;
dev->ethtool_ops = &tun_ethtool_ops;
dev->destructor = free_netdev;
dev->features |= NETIF_F_NETNS_LOCAL;
@@ -749,6 +763,7 @@ static int tun_set_iff(struct net *net,
return -ENOMEM;
dev_net_set(dev, net);
+
tun = netdev_priv(dev);
tun->dev = dev;
tun->flags = flags;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 19/33] atl1e: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (17 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 18/33] tun: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:12 ` David Miller
2008-11-17 23:42 ` [PATCH 20/33] atlx: " Stephen Hemminger
` (15 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: atl1e-netdev_ops.patch --]
[-- Type: text/plain, Size: 1815 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/atl1e/atl1e_main.c 2008-11-17 11:59:32.000000000 -0800
+++ b/drivers/net/atl1e/atl1e_main.c 2008-11-17 12:05:05.000000000 -0800
@@ -2253,26 +2253,32 @@ static void atl1e_shutdown(struct pci_de
atl1e_suspend(pdev, PMSG_SUSPEND);
}
+static const struct net_device_ops atl1e_netdev_ops = {
+ .open = atl1e_open,
+ .stop = atl1e_close,
+ .get_stats = atl1e_get_stats,
+ .set_multicast_list = atl1e_set_multi,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = atl1e_set_mac_addr,
+ .change_mtu = atl1e_change_mtu,
+ .do_ioctl = atl1e_ioctl,
+ .tx_timeout = atl1e_tx_timeout,
+ .vlan_rx_register = atl1e_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = atl1e_netpoll,
+#endif
+
+};
+
static int atl1e_init_netdev(struct net_device *netdev, struct pci_dev *pdev)
{
SET_NETDEV_DEV(netdev, &pdev->dev);
pci_set_drvdata(pdev, netdev);
netdev->irq = pdev->irq;
- netdev->open = &atl1e_open;
- netdev->stop = &atl1e_close;
- netdev->hard_start_xmit = &atl1e_xmit_frame;
- netdev->get_stats = &atl1e_get_stats;
- netdev->set_multicast_list = &atl1e_set_multi;
- netdev->set_mac_address = &atl1e_set_mac_addr;
- netdev->change_mtu = &atl1e_change_mtu;
- netdev->do_ioctl = &atl1e_ioctl;
- netdev->tx_timeout = &atl1e_tx_timeout;
+ netdev->netdev_ops = &atl1e_netdev_ops;
+ netdev->hard_start_xmit = atl1e_xmit_frame,
netdev->watchdog_timeo = AT_TX_WATCHDOG;
- netdev->vlan_rx_register = atl1e_vlan_rx_register;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = atl1e_netpoll;
-#endif
atl1e_set_ethtool_ops(netdev);
netdev->features = NETIF_F_SG | NETIF_F_HW_CSUM |
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 20/33] atlx: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (18 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 19/33] atl1e: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:14 ` David Miller
2008-11-17 23:42 ` [PATCH 21/33] cxgb3: " Stephen Hemminger
` (14 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: atlx-netdev_ops.patch --]
[-- Type: text/plain, Size: 3269 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/atlx/atl1.c 2008-11-17 13:02:49.000000000 -0800
+++ b/drivers/net/atlx/atl1.c 2008-11-17 13:04:16.000000000 -0800
@@ -2880,6 +2880,21 @@ static void atl1_poll_controller(struct
}
#endif
+static const struct net_device_ops atl1_netdev_ops = {
+ .open = atl1_open,
+ .stop = atl1_close,
+ .set_multicast_list = atlx_set_multi,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = atl1_set_mac,
+ .change_mtu = atl1_change_mtu,
+ .do_ioctl = atlx_ioctl,
+ .tx_timeout = atlx_tx_timeout,
+ .vlan_rx_register = atlx_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = atl1_poll_controller,
+#endif
+};
+
/*
* atl1_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -2967,20 +2982,9 @@ static int __devinit atl1_probe(struct p
adapter->mii.phy_id_mask = 0x1f;
adapter->mii.reg_num_mask = 0x1f;
- netdev->open = &atl1_open;
- netdev->stop = &atl1_close;
+ netdev->netdev_ops = &atl1_netdev_ops;
netdev->hard_start_xmit = &atl1_xmit_frame;
-
- netdev->set_multicast_list = &atlx_set_multi;
- netdev->set_mac_address = &atl1_set_mac;
- netdev->change_mtu = &atl1_change_mtu;
- netdev->do_ioctl = &atlx_ioctl;
- netdev->tx_timeout = &atlx_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = atl1_poll_controller;
-#endif
- netdev->vlan_rx_register = atlx_vlan_rx_register;
netdev->ethtool_ops = &atl1_ethtool_ops;
adapter->bd_number = cards_found;
--- a/drivers/net/atlx/atl2.c 2008-11-17 13:02:49.000000000 -0800
+++ b/drivers/net/atlx/atl2.c 2008-11-17 14:48:20.000000000 -0800
@@ -1311,6 +1311,22 @@ static void atl2_poll_controller(struct
}
#endif
+
+static const struct net_device_ops atl2_netdev_ops = {
+ .open = atl2_open,
+ .stop = atl2_close,
+ .set_multicast_list = atl2_set_multi,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = atl2_set_mac,
+ .change_mtu = atl2_change_mtu,
+ .do_ioctl = atl2_ioctl,
+ .tx_timeout = atl2_tx_timeout,
+ .vlan_rx_register = atl2_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = atl2_poll_controller,
+#endif
+};
+
/*
* atl2_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -1384,25 +1400,10 @@ static int __devinit atl2_probe(struct p
atl2_setup_pcicmd(pdev);
- netdev->open = &atl2_open;
- netdev->stop = &atl2_close;
netdev->hard_start_xmit = &atl2_xmit_frame;
- netdev->set_multicast_list = &atl2_set_multi;
- netdev->set_mac_address = &atl2_set_mac;
- netdev->change_mtu = &atl2_change_mtu;
- netdev->do_ioctl = &atl2_ioctl;
+ netdev->netdev_ops = &atl2_netdev_ops;
atl2_set_ethtool_ops(netdev);
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = atl2_poll_controller;
-#endif
-#ifdef HAVE_TX_TIMEOUT
- netdev->tx_timeout = &atl2_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
-#endif
-#ifdef NETIF_F_HW_VLAN_TX
- netdev->vlan_rx_register = atl2_vlan_rx_register;
-#endif
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
netdev->mem_start = mmio_start;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 21/33] cxgb3: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (19 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 20/33] atlx: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:15 ` David Miller
2008-11-17 23:42 ` [PATCH 22/33] cxgb2: " Stephen Hemminger
` (13 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: cxgb3-netdev.patch --]
[-- Type: text/plain, Size: 1595 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/cxgb3/cxgb3_main.c 2008-11-17 13:56:57.000000000 -0800
+++ b/drivers/net/cxgb3/cxgb3_main.c 2008-11-17 13:58:49.000000000 -0800
@@ -2826,6 +2826,21 @@ static void __devinit print_port_info(st
}
}
+static const struct net_device_ops cxgb_netdev_ops = {
+ .open = cxgb_open,
+ .stop = cxgb_close,
+ .get_stats = cxgb_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = cxgb_set_rxmode,
+ .do_ioctl = cxgb_ioctl,
+ .change_mtu = cxgb_change_mtu,
+ .set_mac_address = cxgb_set_mac_addr,
+ .vlan_rx_register = vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = cxgb_netpoll,
+#endif
+};
+
static int __devinit init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -2937,20 +2952,8 @@ static int __devinit init_one(struct pci
netdev->features |= NETIF_F_HIGHDMA;
netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- netdev->vlan_rx_register = vlan_rx_register;
-
- netdev->open = cxgb_open;
- netdev->stop = cxgb_close;
+ netdev->netdev_ops = &cxgb_netdev_ops;
netdev->hard_start_xmit = t3_eth_xmit;
- netdev->get_stats = cxgb_get_stats;
- netdev->set_multicast_list = cxgb_set_rxmode;
- netdev->do_ioctl = cxgb_ioctl;
- netdev->change_mtu = cxgb_change_mtu;
- netdev->set_mac_address = cxgb_set_mac_addr;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = cxgb_netpoll;
-#endif
-
SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops);
}
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 22/33] cxgb2: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (20 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 21/33] cxgb3: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-18 1:40 ` Stephen Hemminger
2008-11-17 23:42 ` [PATCH 23/33] e1000: " Stephen Hemminger
` (12 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: cxgb2-netdev.patch --]
[-- Type: text/plain, Size: 1878 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/chelsio/cxgb2.c 2008-11-17 13:56:56.000000000 -0800
+++ b/drivers/net/chelsio/cxgb2.c 2008-11-17 14:46:24.000000000 -0800
@@ -1010,6 +1010,21 @@ void t1_fatal_err(struct adapter *adapte
adapter->name);
}
+static const struct net_device_ops cxgb_netdev_ops = {
+ .open = cxgb_open,
+ .stop = cxgb_close,
+ .get_stats = t1_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = t1_set_rxmode,
+ .do_ioctl = t1_ioctl,
+ .change_mtu = t1_change_mtu,
+ .set_mac_address = t1_set_mac_addr,
+ .vlan_rx_register = vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = t1_netpoll,
+#endif
+};
+
static int __devinit init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -1130,7 +1145,6 @@ static int __devinit init_one(struct pci
adapter->flags |= VLAN_ACCEL_CAPABLE;
netdev->features |=
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- netdev->vlan_rx_register = vlan_rx_register;
#endif
/* T204: disable TSO */
@@ -1140,19 +1154,11 @@ static int __devinit init_one(struct pci
}
}
- netdev->open = cxgb_open;
- netdev->stop = cxgb_close;
+ netdev->netdev_ops = &cxgb_netdev_ops;
netdev->hard_start_xmit = t1_start_xmit;
netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ?
sizeof(struct cpl_tx_pkt_lso) : sizeof(struct cpl_tx_pkt);
- netdev->get_stats = t1_get_stats;
- netdev->set_multicast_list = t1_set_rxmode;
- netdev->do_ioctl = t1_ioctl;
- netdev->change_mtu = t1_change_mtu;
- netdev->set_mac_address = t1_set_mac_addr;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = t1_netpoll;
-#endif
+
netif_napi_add(netdev, &adapter->napi, t1_poll, 64);
SET_ETHTOOL_OPS(netdev, &t1_ethtool_ops);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 22/33] cxgb2: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 22/33] cxgb2: " Stephen Hemminger
@ 2008-11-18 1:40 ` Stephen Hemminger
2008-11-20 6:17 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-18 1:40 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Convert this driver to network device ops. Compile teseted only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Need to handle non-vlan cas as well.
--- a/drivers/net/chelsio/cxgb2.c 2008-11-17 17:21:58.000000000 -0800
+++ b/drivers/net/chelsio/cxgb2.c 2008-11-17 17:26:09.000000000 -0800
@@ -1010,6 +1010,23 @@ void t1_fatal_err(struct adapter *adapte
adapter->name);
}
+static const struct net_device_ops cxgb_netdev_ops = {
+ .open = cxgb_open,
+ .stop = cxgb_close,
+ .get_stats = t1_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = t1_set_rxmode,
+ .do_ioctl = t1_ioctl,
+ .change_mtu = t1_change_mtu,
+ .set_mac_address = t1_set_mac_addr,
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+ .vlan_rx_register = vlan_rx_register,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = t1_netpoll,
+#endif
+};
+
static int __devinit init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -1130,7 +1147,6 @@ static int __devinit init_one(struct pci
adapter->flags |= VLAN_ACCEL_CAPABLE;
netdev->features |=
NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- netdev->vlan_rx_register = vlan_rx_register;
#endif
/* T204: disable TSO */
@@ -1140,19 +1156,11 @@ static int __devinit init_one(struct pci
}
}
- netdev->open = cxgb_open;
- netdev->stop = cxgb_close;
+ netdev->netdev_ops = &cxgb_netdev_ops;
netdev->hard_start_xmit = t1_start_xmit;
netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ?
sizeof(struct cpl_tx_pkt_lso) : sizeof(struct cpl_tx_pkt);
- netdev->get_stats = t1_get_stats;
- netdev->set_multicast_list = t1_set_rxmode;
- netdev->do_ioctl = t1_ioctl;
- netdev->change_mtu = t1_change_mtu;
- netdev->set_mac_address = t1_set_mac_addr;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = t1_netpoll;
-#endif
+
netif_napi_add(netdev, &adapter->napi, t1_poll, 64);
SET_ETHTOOL_OPS(netdev, &t1_ethtool_ops);
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 23/33] e1000: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (21 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 22/33] cxgb2: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:18 ` David Miller
2008-11-17 23:42 ` [PATCH 24/33] via-velocity: " Stephen Hemminger
` (11 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: e1000-netdev_ops.patch --]
[-- Type: text/plain, Size: 1936 bytes --]
Convert to new network device ops interface.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/e1000/e1000_main.c 2008-11-17 07:57:18.000000000 -0800
+++ b/drivers/net/e1000/e1000_main.c 2008-11-17 12:55:04.000000000 -0800
@@ -888,6 +888,25 @@ static int e1000_is_need_ioport(struct p
}
}
+static const struct net_device_ops e1000_netdev_ops = {
+ .open = e1000_open,
+ .stop = e1000_close,
+ .get_stats = e1000_get_stats,
+ .set_rx_mode = e1000_set_rx_mode,
+ .set_mac_address = e1000_set_mac,
+ .tx_timeout = e1000_tx_timeout,
+ .change_mtu = e1000_change_mtu,
+ .do_ioctl = e1000_ioctl,
+ .validate_addr = eth_validate_addr,
+
+ .vlan_rx_register = e1000_vlan_rx_register,
+ .vlan_rx_add_vid = e1000_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = e1000_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = e1000_netpoll,
+#endif
+};
+
/**
* e1000_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -981,24 +1000,12 @@ static int __devinit e1000_probe(struct
}
}
- netdev->open = &e1000_open;
- netdev->stop = &e1000_close;
+ netdev->netdev_ops = &e1000_netdev_ops;
netdev->hard_start_xmit = &e1000_xmit_frame;
- netdev->get_stats = &e1000_get_stats;
- netdev->set_rx_mode = &e1000_set_rx_mode;
- netdev->set_mac_address = &e1000_set_mac;
- netdev->change_mtu = &e1000_change_mtu;
- netdev->do_ioctl = &e1000_ioctl;
e1000_set_ethtool_ops(netdev);
- netdev->tx_timeout = &e1000_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);
- netdev->vlan_rx_register = e1000_vlan_rx_register;
- netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = e1000_netpoll;
-#endif
+
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
adapter->bd_number = cards_found;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 24/33] via-velocity: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (22 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 23/33] e1000: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:19 ` David Miller
2008-11-17 23:42 ` [PATCH 25/33] igb: " Stephen Hemminger
` (10 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: via-netdev_ops.patch --]
[-- Type: text/plain, Size: 1586 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/via-velocity.c 2008-11-17 12:56:02.000000000 -0800
+++ b/drivers/net/via-velocity.c 2008-11-17 12:58:13.000000000 -0800
@@ -849,6 +849,19 @@ static int velocity_soft_reset(struct ve
return 0;
}
+static const struct net_device_ops velocity_netdev_ops = {
+ .open = velocity_open,
+ .stop = velocity_close,
+ .get_stats = velocity_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = velocity_set_multi,
+ .change_mtu = velocity_change_mtu,
+ .do_ioctl = velocity_ioctl,
+ .vlan_rx_add_vid = velocity_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = velocity_vlan_rx_kill_vid,
+ .vlan_rx_register = velocity_vlan_rx_register,
+};
+
/**
* velocity_found1 - set up discovered velocity card
* @pdev: PCI device
@@ -958,18 +971,9 @@ static int __devinit velocity_found1(str
vptr->phy_id = MII_GET_PHY_ID(vptr->mac_regs);
dev->irq = pdev->irq;
- dev->open = velocity_open;
dev->hard_start_xmit = velocity_xmit;
- dev->stop = velocity_close;
- dev->get_stats = velocity_get_stats;
- dev->set_multicast_list = velocity_set_multi;
- dev->do_ioctl = velocity_ioctl;
+ dev->netdev_ops = &velocity_netdev_ops;
dev->ethtool_ops = &velocity_ethtool_ops;
- dev->change_mtu = velocity_change_mtu;
-
- dev->vlan_rx_add_vid = velocity_vlan_rx_add_vid;
- dev->vlan_rx_kill_vid = velocity_vlan_rx_kill_vid;
- dev->vlan_rx_register = velocity_vlan_rx_register;
#ifdef VELOCITY_ZERO_COPY_SUPPORT
dev->features |= NETIF_F_SG;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 25/33] igb: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (23 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 24/33] via-velocity: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:21 ` David Miller
2008-11-17 23:42 ` [PATCH 26/33] e100: " Stephen Hemminger
` (9 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: igb-netdev_ops.patch --]
[-- Type: text/plain, Size: 1845 bytes --]
Convert to new network device ops interface. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/igb/igb_main.c 2008-11-02 09:48:53.000000000 -0800
+++ b/drivers/net/igb/igb_main.c 2008-11-02 10:06:09.000000000 -0800
@@ -950,6 +950,24 @@ static int igb_is_need_ioport(struct pci
}
}
+static const struct net_device_ops igb_netdev_ops = {
+ .open = igb_open,
+ .stop = igb_close,
+ .get_stats = igb_get_stats,
+ .set_multicast_list = igb_set_multi,
+ .set_mac_address = igb_set_mac,
+ .change_mtu = igb_change_mtu,
+ .do_ioctl = igb_ioctl,
+ .tx_timeout = igb_tx_timeout,
+ .validate_addr = eth_validate_addr,
+ .vlan_rx_register = igb_vlan_rx_register,
+ .vlan_rx_add_vid = igb_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = igb_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = igb_netpoll,
+#endif
+};
+
/**
* igb_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -1060,22 +1078,9 @@ static int __devinit igb_probe(struct pc
if (!adapter->hw.hw_addr)
goto err_ioremap;
- netdev->open = &igb_open;
- netdev->stop = &igb_close;
- netdev->get_stats = &igb_get_stats;
- netdev->set_multicast_list = &igb_set_multi;
- netdev->set_mac_address = &igb_set_mac;
- netdev->change_mtu = &igb_change_mtu;
- netdev->do_ioctl = &igb_ioctl;
+ netdev->netdev_ops = &igb_netdev_ops;
igb_set_ethtool_ops(netdev);
- netdev->tx_timeout = &igb_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
- netdev->vlan_rx_register = igb_vlan_rx_register;
- netdev->vlan_rx_add_vid = igb_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = igb_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = igb_netpoll;
-#endif
netdev->hard_start_xmit = &igb_xmit_frame_adv;
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 26/33] e100: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (24 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 25/33] igb: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:22 ` David Miller
2008-11-17 23:42 ` [PATCH 27/33] ppp: " Stephen Hemminger
` (8 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: e100-netdev.patch --]
[-- Type: text/plain, Size: 1887 bytes --]
Convert to new network device ops interface. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/e100.c 2008-11-17 13:56:53.000000000 -0800
+++ b/drivers/net/e100.c 2008-11-17 14:07:06.000000000 -0800
@@ -2612,6 +2612,20 @@ static int e100_close(struct net_device
return 0;
}
+static const struct net_device_ops e100_netdev_ops = {
+ .open = e100_open,
+ .stop = e100_close,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = e100_set_multicast_list,
+ .set_mac_address = e100_set_mac_address,
+ .change_mtu = e100_change_mtu,
+ .do_ioctl = e100_do_ioctl,
+ .tx_timeout = e100_tx_timeout,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = e100_netpoll,
+#endif
+};
+
static int __devinit e100_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -2625,19 +2639,10 @@ static int __devinit e100_probe(struct p
return -ENOMEM;
}
- netdev->open = e100_open;
- netdev->stop = e100_close;
+ netdev->netdev_ops = &e100_netdev_ops;
netdev->hard_start_xmit = e100_xmit_frame;
- netdev->set_multicast_list = e100_set_multicast_list;
- netdev->set_mac_address = e100_set_mac_address;
- netdev->change_mtu = e100_change_mtu;
- netdev->do_ioctl = e100_do_ioctl;
SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops);
- netdev->tx_timeout = e100_tx_timeout;
netdev->watchdog_timeo = E100_WATCHDOG_PERIOD;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = e100_netpoll;
-#endif
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
nic = netdev_priv(netdev);
@@ -2845,7 +2850,7 @@ static pci_ers_result_t e100_io_error_de
struct nic *nic = netdev_priv(netdev);
/* Similar to calling e100_down(), but avoids adapter I/O. */
- netdev->stop(netdev);
+ e100_close(netdev);
/* Detach; put netif into a state similar to hotplug unplug. */
napi_enable(&nic->napi);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 27/33] ppp: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (25 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 26/33] e100: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:22 ` David Miller
2008-11-17 23:42 ` [PATCH 28/33] enic: " Stephen Hemminger
` (7 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: ppp-netdev_ops.patch --]
[-- Type: text/plain, Size: 811 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/ppp_generic.c 2008-11-04 13:58:06.000000000 -0800
+++ b/drivers/net/ppp_generic.c 2008-11-17 13:22:34.000000000 -0800
@@ -971,8 +971,13 @@ ppp_net_ioctl(struct net_device *dev, st
return err;
}
+static const struct net_device_ops ppp_netdev_ops = {
+ .do_ioctl = ppp_net_ioctl,
+};
+
static void ppp_setup(struct net_device *dev)
{
+ dev->netdev_ops = &ppp_netdev_ops;
dev->hard_header_len = PPP_HDRLEN;
dev->mtu = PPP_MTU;
dev->addr_len = 0;
@@ -2436,7 +2441,6 @@ ppp_create_interface(int unit, int *retp
dev->priv = ppp;
dev->hard_start_xmit = ppp_start_xmit;
- dev->do_ioctl = ppp_net_ioctl;
ret = -EEXIST;
mutex_lock(&all_ppp_mutex);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 28/33] enic: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (26 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 27/33] ppp: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:23 ` David Miller
2008-11-17 23:42 ` [PATCH 29/33] ixgb: " Stephen Hemminger
` (6 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: enic-netdev_ops.patch --]
[-- Type: text/plain, Size: 1785 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/enic/enic_main.c 2008-11-17 13:23:10.000000000 -0800
+++ b/drivers/net/enic/enic_main.c 2008-11-17 13:26:25.000000000 -0800
@@ -1590,6 +1590,22 @@ static void enic_iounmap(struct enic *en
iounmap(enic->bar0.vaddr);
}
+static const struct net_device_ops enic_netdev_ops = {
+ .open = enic_open,
+ .stop = enic_stop,
+ .get_stats = enic_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = enic_set_multicast_list,
+ .change_mtu = enic_change_mtu,
+ .vlan_rx_register = enic_vlan_rx_register,
+ .vlan_rx_add_vid = enic_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = enic_vlan_rx_kill_vid,
+ .tx_timeout = enic_tx_timeout,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = enic_poll_controller,
+#endif
+};
+
static int __devinit enic_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -1813,21 +1829,10 @@ static int __devinit enic_probe(struct p
goto err_out_free_vnic_resources;
}
- netdev->open = enic_open;
- netdev->stop = enic_stop;
+ netdev->netdev_ops = &enic_netdev_ops;
netdev->hard_start_xmit = enic_hard_start_xmit;
- netdev->get_stats = enic_get_stats;
- netdev->set_multicast_list = enic_set_multicast_list;
- netdev->change_mtu = enic_change_mtu;
- netdev->vlan_rx_register = enic_vlan_rx_register;
- netdev->vlan_rx_add_vid = enic_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = enic_vlan_rx_kill_vid;
- netdev->tx_timeout = enic_tx_timeout;
netdev->watchdog_timeo = 2 * HZ;
netdev->ethtool_ops = &enic_ethtool_ops;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = enic_poll_controller;
-#endif
switch (vnic_dev_get_intr_mode(enic->vdev)) {
default:
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 29/33] ixgb: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (27 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 28/33] enic: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:24 ` David Miller
2008-11-17 23:42 ` [PATCH 30/33] tg3: " Stephen Hemminger
` (5 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: ixgb-netdev_ops.patch --]
[-- Type: text/plain, Size: 3647 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/ixgb/ixgb_main.c 2008-11-17 14:03:54.000000000 -0800
+++ b/drivers/net/ixgb/ixgb_main.c 2008-11-17 14:03:57.000000000 -0800
@@ -321,6 +321,23 @@ ixgb_reset(struct ixgb_adapter *adapter)
}
}
+static const struct net_device_ops ixgb_netdev_ops = {
+ .open = ixgb_open,
+ .stop = ixgb_close,
+ .get_stats = ixgb_get_stats,
+ .set_multicast_list = ixgb_set_multi,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = ixgb_set_mac,
+ .change_mtu = ixgb_change_mtu,
+ .tx_timeout = ixgb_tx_timeout,
+ .vlan_rx_register = ixgb_vlan_rx_register,
+ .vlan_rx_add_vid = ixgb_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = ixgb_netpoll,
+#endif
+};
+
/**
* ixgb_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -396,23 +413,11 @@ ixgb_probe(struct pci_dev *pdev, const s
}
}
- netdev->open = &ixgb_open;
- netdev->stop = &ixgb_close;
+ netdev->netdev_ops = &ixgb_netdev_ops;
netdev->hard_start_xmit = &ixgb_xmit_frame;
- netdev->get_stats = &ixgb_get_stats;
- netdev->set_multicast_list = &ixgb_set_multi;
- netdev->set_mac_address = &ixgb_set_mac;
- netdev->change_mtu = &ixgb_change_mtu;
ixgb_set_ethtool_ops(netdev);
- netdev->tx_timeout = &ixgb_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
netif_napi_add(netdev, &adapter->napi, ixgb_clean, 64);
- netdev->vlan_rx_register = ixgb_vlan_rx_register;
- netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = ixgb_netpoll;
-#endif
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
--- a/drivers/net/ixgbe/ixgbe_main.c 2008-11-17 14:03:54.000000000 -0800
+++ b/drivers/net/ixgbe/ixgbe_main.c 2008-11-17 14:05:29.000000000 -0800
@@ -3727,6 +3727,23 @@ static int ixgbe_link_config(struct ixgb
return hw->mac.ops.setup_link_speed(hw, autoneg, true, true);
}
+static const struct net_device_ops ixgbe_netdev_ops = {
+ .open = ixgbe_open,
+ .stop = ixgbe_close,
+ .get_stats = ixgbe_get_stats,
+ .set_multicast_list = ixgbe_set_rx_mode,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = ixgbe_set_mac,
+ .change_mtu = ixgbe_change_mtu,
+ .tx_timeout = ixgbe_tx_timeout,
+ .vlan_rx_register = ixgbe_vlan_rx_register,
+ .vlan_rx_add_vid = ixgbe_vlan_rx_add_vid,
+ .vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = ixgbe_netpoll,
+#endif
+};
+
/**
* ixgbe_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -3808,23 +3825,10 @@ static int __devinit ixgbe_probe(struct
continue;
}
- netdev->open = &ixgbe_open;
- netdev->stop = &ixgbe_close;
+ netdev->netdev_ops = &ixgbe_netdev_ops;
netdev->hard_start_xmit = &ixgbe_xmit_frame;
- netdev->get_stats = &ixgbe_get_stats;
- netdev->set_rx_mode = &ixgbe_set_rx_mode;
- netdev->set_multicast_list = &ixgbe_set_rx_mode;
- netdev->set_mac_address = &ixgbe_set_mac;
- netdev->change_mtu = &ixgbe_change_mtu;
ixgbe_set_ethtool_ops(netdev);
- netdev->tx_timeout = &ixgbe_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
- netdev->vlan_rx_register = ixgbe_vlan_rx_register;
- netdev->vlan_rx_add_vid = ixgbe_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = ixgbe_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = ixgbe_netpoll;
-#endif
strcpy(netdev->name, pci_name(pdev));
adapter->bd_number = cards_found;
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 30/33] tg3: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (28 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 29/33] ixgb: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-18 0:42 ` Matt Carlson
2008-11-18 1:37 ` Stephen Hemminger
2008-11-17 23:42 ` [PATCH 31/33] forcedeth: " Stephen Hemminger
` (4 subsequent siblings)
34 siblings, 2 replies; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: tg3-netdev_ops.patch --]
[-- Type: text/plain, Size: 1878 bytes --]
Convert this driver to network device ops.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/tg3.c 2008-11-17 14:03:52.000000000 -0800
+++ b/drivers/net/tg3.c 2008-11-17 14:45:38.000000000 -0800
@@ -13343,6 +13343,22 @@ static void __devinit tg3_init_coal(stru
}
}
+static const struct net_device_ops tg3_netdev_ops = {
+ .open = tg3_open,
+ .stop = tg3_close,
+ .get_stats = tg3_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = tg3_set_rx_mode,
+ .set_mac_address = tg3_set_mac_addr,
+ .do_ioctl = tg3_ioctl,
+ .tx_timeout = tg3_tx_timeout,
+ .change_mtu = tg3_change_mtu,
+ .vlan_rx_register = tg3_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = tg3_poll_controller,
+#endif
+};
+
static int __devinit tg3_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -13400,7 +13416,6 @@ static int __devinit tg3_init_one(struct
#if TG3_VLAN_TAG_USED
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = tg3_vlan_rx_register;
#endif
tp = netdev_priv(dev);
@@ -13458,21 +13473,11 @@ static int __devinit tg3_init_one(struct
tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING;
tp->tx_pending = TG3_DEF_TX_RING_PENDING;
- dev->open = tg3_open;
- dev->stop = tg3_close;
- dev->get_stats = tg3_get_stats;
- dev->set_multicast_list = tg3_set_rx_mode;
- dev->set_mac_address = tg3_set_mac_addr;
- dev->do_ioctl = tg3_ioctl;
- dev->tx_timeout = tg3_tx_timeout;
+ dev->netdev_ops = &tg3_netdev_ops;
netif_napi_add(dev, &tp->napi, tg3_poll, 64);
dev->ethtool_ops = &tg3_ethtool_ops;
dev->watchdog_timeo = TG3_TX_TIMEOUT;
- dev->change_mtu = tg3_change_mtu;
dev->irq = pdev->irq;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = tg3_poll_controller;
-#endif
err = tg3_get_invariants(tp);
if (err) {
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 30/33] tg3: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 30/33] tg3: " Stephen Hemminger
@ 2008-11-18 0:42 ` Matt Carlson
2008-11-18 1:37 ` Stephen Hemminger
1 sibling, 0 replies; 93+ messages in thread
From: Matt Carlson @ 2008-11-18 0:42 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev@vger.kernel.org
On Mon, Nov 17, 2008 at 03:42:37PM -0800, Stephen Hemminger wrote:
> Convert this driver to network device ops.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> --- a/drivers/net/tg3.c 2008-11-17 14:03:52.000000000 -0800
> +++ b/drivers/net/tg3.c 2008-11-17 14:45:38.000000000 -0800
> @@ -13343,6 +13343,22 @@ static void __devinit tg3_init_coal(stru
> }
> }
>
> +static const struct net_device_ops tg3_netdev_ops = {
> + .open = tg3_open,
> + .stop = tg3_close,
> + .get_stats = tg3_get_stats,
> + .validate_addr = eth_validate_addr,
> + .set_multicast_list = tg3_set_rx_mode,
> + .set_mac_address = tg3_set_mac_addr,
> + .do_ioctl = tg3_ioctl,
> + .tx_timeout = tg3_tx_timeout,
> + .change_mtu = tg3_change_mtu,
> + .vlan_rx_register = tg3_vlan_rx_register,
> +#ifdef CONFIG_NET_POLL_CONTROLLER
> + .poll_controller = tg3_poll_controller,
> +#endif
> +};
> +
> static int __devinit tg3_init_one(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> {
> @@ -13400,7 +13416,6 @@ static int __devinit tg3_init_one(struct
>
> #if TG3_VLAN_TAG_USED
> dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
> - dev->vlan_rx_register = tg3_vlan_rx_register;
> #endif
The tg3_vlan_rx_register() function is only defined if
CONFIG_VLAN_8021Q or CONFIG_VLAN_8021Q_MODULE is defined. You will need to
either surround the .vlan_rx_register declaration with TG3_VLAN_TAG_USED or
move the TG3_VLAN_TAG_USED preprocessor guards inside the body of
tg3_vlan_rx_register().
> tp = netdev_priv(dev);
> @@ -13458,21 +13473,11 @@ static int __devinit tg3_init_one(struct
> tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING;
> tp->tx_pending = TG3_DEF_TX_RING_PENDING;
>
> - dev->open = tg3_open;
> - dev->stop = tg3_close;
> - dev->get_stats = tg3_get_stats;
> - dev->set_multicast_list = tg3_set_rx_mode;
> - dev->set_mac_address = tg3_set_mac_addr;
> - dev->do_ioctl = tg3_ioctl;
> - dev->tx_timeout = tg3_tx_timeout;
> + dev->netdev_ops = &tg3_netdev_ops;
> netif_napi_add(dev, &tp->napi, tg3_poll, 64);
> dev->ethtool_ops = &tg3_ethtool_ops;
> dev->watchdog_timeo = TG3_TX_TIMEOUT;
> - dev->change_mtu = tg3_change_mtu;
> dev->irq = pdev->irq;
> -#ifdef CONFIG_NET_POLL_CONTROLLER
> - dev->poll_controller = tg3_poll_controller;
> -#endif
>
> err = tg3_get_invariants(tp);
> if (err) {
>
> --
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 30/33] tg3: convert to net_device_ops
2008-11-17 23:42 ` [PATCH 30/33] tg3: " Stephen Hemminger
2008-11-18 0:42 ` Matt Carlson
@ 2008-11-18 1:37 ` Stephen Hemminger
2008-11-19 21:04 ` Matt Carlson
2008-11-20 6:25 ` David Miller
1 sibling, 2 replies; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-18 1:37 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Convert this driver to network device ops.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
---
Handle non-vlan build.
--- a/drivers/net/tg3.c 2008-11-17 17:21:58.000000000 -0800
+++ b/drivers/net/tg3.c 2008-11-17 17:26:45.000000000 -0800
@@ -13343,6 +13343,24 @@ static void __devinit tg3_init_coal(stru
}
}
+static const struct net_device_ops tg3_netdev_ops = {
+ .open = tg3_open,
+ .stop = tg3_close,
+ .get_stats = tg3_get_stats,
+ .validate_addr = eth_validate_addr,
+ .set_multicast_list = tg3_set_rx_mode,
+ .set_mac_address = tg3_set_mac_addr,
+ .do_ioctl = tg3_ioctl,
+ .tx_timeout = tg3_tx_timeout,
+ .change_mtu = tg3_change_mtu,
+#if TG3_VLAN_TAG_USED
+ .vlan_rx_register = tg3_vlan_rx_register,
+#endif
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = tg3_poll_controller,
+#endif
+};
+
static int __devinit tg3_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
@@ -13400,7 +13418,6 @@ static int __devinit tg3_init_one(struct
#if TG3_VLAN_TAG_USED
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = tg3_vlan_rx_register;
#endif
tp = netdev_priv(dev);
@@ -13458,21 +13475,11 @@ static int __devinit tg3_init_one(struct
tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING;
tp->tx_pending = TG3_DEF_TX_RING_PENDING;
- dev->open = tg3_open;
- dev->stop = tg3_close;
- dev->get_stats = tg3_get_stats;
- dev->set_multicast_list = tg3_set_rx_mode;
- dev->set_mac_address = tg3_set_mac_addr;
- dev->do_ioctl = tg3_ioctl;
- dev->tx_timeout = tg3_tx_timeout;
+ dev->netdev_ops = &tg3_netdev_ops;
netif_napi_add(dev, &tp->napi, tg3_poll, 64);
dev->ethtool_ops = &tg3_ethtool_ops;
dev->watchdog_timeo = TG3_TX_TIMEOUT;
- dev->change_mtu = tg3_change_mtu;
dev->irq = pdev->irq;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = tg3_poll_controller;
-#endif
err = tg3_get_invariants(tp);
if (err) {
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 30/33] tg3: convert to net_device_ops
2008-11-18 1:37 ` Stephen Hemminger
@ 2008-11-19 21:04 ` Matt Carlson
2008-11-19 21:07 ` Stephen Hemminger
2008-11-20 6:25 ` David Miller
1 sibling, 1 reply; 93+ messages in thread
From: Matt Carlson @ 2008-11-19 21:04 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev@vger.kernel.org
On Mon, Nov 17, 2008 at 05:37:06PM -0800, Stephen Hemminger wrote:
> Convert this driver to network device ops.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> ---
> Handle non-vlan build.
>
> --- a/drivers/net/tg3.c 2008-11-17 17:21:58.000000000 -0800
> +++ b/drivers/net/tg3.c 2008-11-17 17:26:45.000000000 -0800
> @@ -13343,6 +13343,24 @@ static void __devinit tg3_init_coal(stru
> }
> }
>
> +static const struct net_device_ops tg3_netdev_ops = {
> + .open = tg3_open,
> + .stop = tg3_close,
One more completely trivial nit. Is there a reason why you chose
the verbs to be "open" and "stop" rather than "open" and "close" or
"start" and "stop"?
> + .get_stats = tg3_get_stats,
> + .validate_addr = eth_validate_addr,
> + .set_multicast_list = tg3_set_rx_mode,
> + .set_mac_address = tg3_set_mac_addr,
> + .do_ioctl = tg3_ioctl,
> + .tx_timeout = tg3_tx_timeout,
> + .change_mtu = tg3_change_mtu,
> +#if TG3_VLAN_TAG_USED
> + .vlan_rx_register = tg3_vlan_rx_register,
> +#endif
> +#ifdef CONFIG_NET_POLL_CONTROLLER
> + .poll_controller = tg3_poll_controller,
> +#endif
> +};
> +
> static int __devinit tg3_init_one(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> {
> @@ -13400,7 +13418,6 @@ static int __devinit tg3_init_one(struct
>
> #if TG3_VLAN_TAG_USED
> dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
> - dev->vlan_rx_register = tg3_vlan_rx_register;
> #endif
>
> tp = netdev_priv(dev);
> @@ -13458,21 +13475,11 @@ static int __devinit tg3_init_one(struct
> tp->rx_jumbo_pending = TG3_DEF_RX_JUMBO_RING_PENDING;
> tp->tx_pending = TG3_DEF_TX_RING_PENDING;
>
> - dev->open = tg3_open;
> - dev->stop = tg3_close;
> - dev->get_stats = tg3_get_stats;
> - dev->set_multicast_list = tg3_set_rx_mode;
> - dev->set_mac_address = tg3_set_mac_addr;
> - dev->do_ioctl = tg3_ioctl;
> - dev->tx_timeout = tg3_tx_timeout;
> + dev->netdev_ops = &tg3_netdev_ops;
> netif_napi_add(dev, &tp->napi, tg3_poll, 64);
> dev->ethtool_ops = &tg3_ethtool_ops;
> dev->watchdog_timeo = TG3_TX_TIMEOUT;
> - dev->change_mtu = tg3_change_mtu;
> dev->irq = pdev->irq;
> -#ifdef CONFIG_NET_POLL_CONTROLLER
> - dev->poll_controller = tg3_poll_controller;
> -#endif
>
> err = tg3_get_invariants(tp);
> if (err) {
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 30/33] tg3: convert to net_device_ops
2008-11-19 21:04 ` Matt Carlson
@ 2008-11-19 21:07 ` Stephen Hemminger
2008-11-20 1:21 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-19 21:07 UTC (permalink / raw)
To: Matt Carlson; +Cc: David Miller, netdev@vger.kernel.org
On Wed, 19 Nov 2008 13:04:47 -0800
"Matt Carlson" <mcarlson@broadcom.com> wrote:
> On Mon, Nov 17, 2008 at 05:37:06PM -0800, Stephen Hemminger wrote:
> > Convert this driver to network device ops.
> >
> > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> >
> > ---
> > Handle non-vlan build.
> >
> > --- a/drivers/net/tg3.c 2008-11-17 17:21:58.000000000 -0800
> > +++ b/drivers/net/tg3.c 2008-11-17 17:26:45.000000000 -0800
> > @@ -13343,6 +13343,24 @@ static void __devinit tg3_init_coal(stru
> > }
> > }
> >
> > +static const struct net_device_ops tg3_netdev_ops = {
> > + .open = tg3_open,
> > + .stop = tg3_close,
>
> One more completely trivial nit. Is there a reason why you chose
> the verbs to be "open" and "stop" rather than "open" and "close" or
> "start" and "stop"?
Because that is what they were before (but in a different place).
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 30/33] tg3: convert to net_device_ops
2008-11-19 21:07 ` Stephen Hemminger
@ 2008-11-20 1:21 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 1:21 UTC (permalink / raw)
To: shemminger; +Cc: mcarlson, netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Wed, 19 Nov 2008 13:07:27 -0800
> On Wed, 19 Nov 2008 13:04:47 -0800
> "Matt Carlson" <mcarlson@broadcom.com> wrote:
>
> > On Mon, Nov 17, 2008 at 05:37:06PM -0800, Stephen Hemminger wrote:
> > > Convert this driver to network device ops.
> > >
> > > Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> > >
> > > ---
> > > Handle non-vlan build.
> > >
> > > --- a/drivers/net/tg3.c 2008-11-17 17:21:58.000000000 -0800
> > > +++ b/drivers/net/tg3.c 2008-11-17 17:26:45.000000000 -0800
> > > @@ -13343,6 +13343,24 @@ static void __devinit tg3_init_coal(stru
> > > }
> > > }
> > >
> > > +static const struct net_device_ops tg3_netdev_ops = {
> > > + .open = tg3_open,
> > > + .stop = tg3_close,
> >
> > One more completely trivial nit. Is there a reason why you chose
> > the verbs to be "open" and "stop" rather than "open" and "close" or
> > "start" and "stop"?
>
> Because that is what they were before (but in a different place).
Right.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 30/33] tg3: convert to net_device_ops
2008-11-18 1:37 ` Stephen Hemminger
2008-11-19 21:04 ` Matt Carlson
@ 2008-11-20 6:25 ` David Miller
1 sibling, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 6:25 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 17:37:06 -0800
> Convert this driver to network device ops.
>
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
>
> ---
> Handle non-vlan build.
Applied.
^ permalink raw reply [flat|nested] 93+ messages in thread
* [PATCH 31/33] forcedeth: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (29 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 30/33] tg3: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:27 ` David Miller
2008-11-17 23:42 ` [PATCH 32/33] niu: " Stephen Hemminger
` (3 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: forcedeth-netdev_ops.patch --]
[-- Type: text/plain, Size: 2011 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/forcedeth.c 2008-11-17 14:03:51.000000000 -0800
+++ b/drivers/net/forcedeth.c 2008-11-17 14:44:45.000000000 -0800
@@ -5408,6 +5408,21 @@ static int nv_close(struct net_device *d
return 0;
}
+static const struct net_device_ops nv_netdev_ops = {
+ .open = nv_open,
+ .stop = nv_close,
+ .get_stats = nv_get_stats,
+ .tx_timeout = nv_tx_timeout,
+ .change_mtu = nv_change_mtu,
+ .validate_addr= eth_validate_addr,
+ .set_mac_address = nv_set_mac_address,
+ .set_multicast_list = nv_set_multicast,
+ .vlan_rx_register = nv_vlan_rx_register,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .poll_controller = nv_poll_controller,
+#endif
+};
+
static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
{
struct net_device *dev;
@@ -5527,7 +5542,6 @@ static int __devinit nv_probe(struct pci
if (id->driver_data & DEV_HAS_VLAN) {
np->vlanctl_bits = NVREG_VLANCONTROL_ENABLE;
dev->features |= NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX;
- dev->vlan_rx_register = nv_vlan_rx_register;
}
np->msi_flags = 0;
@@ -5577,25 +5591,16 @@ static int __devinit nv_probe(struct pci
if (!np->rx_skb || !np->tx_skb)
goto out_freering;
- dev->open = nv_open;
- dev->stop = nv_close;
-
if (!nv_optimized(np))
dev->hard_start_xmit = nv_start_xmit;
else
dev->hard_start_xmit = nv_start_xmit_optimized;
- dev->get_stats = nv_get_stats;
- dev->change_mtu = nv_change_mtu;
- dev->set_mac_address = nv_set_mac_address;
- dev->set_multicast_list = nv_set_multicast;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- dev->poll_controller = nv_poll_controller;
-#endif
+
+ dev->netdev_ops = &nv_netdev_ops;
#ifdef CONFIG_FORCEDETH_NAPI
netif_napi_add(dev, &np->napi, nv_napi_poll, RX_WORK_PER_LOOP);
#endif
SET_ETHTOOL_OPS(dev, &ops);
- dev->tx_timeout = nv_tx_timeout;
dev->watchdog_timeo = NV_WATCHDOG_TIMEO;
pci_set_drvdata(pci_dev, dev);
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 32/33] niu: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (30 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 31/33] forcedeth: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:28 ` David Miller
2008-11-17 23:42 ` [PATCH 33/33] acenic: " Stephen Hemminger
` (2 subsequent siblings)
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: niu-netdev_ops.patch --]
[-- Type: text/plain, Size: 1259 bytes --]
Convert this driver to network device ops. Compile tested only (give me hw!)
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/niu.c 2008-11-17 13:45:41.000000000 -0800
+++ b/drivers/net/niu.c 2008-11-17 13:48:46.000000000 -0800
@@ -8618,19 +8618,24 @@ static struct net_device * __devinit niu
return dev;
}
+static const struct net_device_ops niu_netdev_ops = {
+ .open = niu_open,
+ .stop = niu_close,
+ .get_stats = niu_get_stats,
+ .set_multicast_list = niu_set_rx_mode,
+ .validate_addr = eth_validate_addr,
+ .set_mac_address = niu_set_mac_addr,
+ .do_ioctl = niu_ioctl,
+ .tx_timeout = niu_tx_timeout,
+ .change_mtu = niu_change_mtu,
+};
+
static void __devinit niu_assign_netdev_ops(struct net_device *dev)
{
- dev->open = niu_open;
- dev->stop = niu_close;
- dev->get_stats = niu_get_stats;
- dev->set_multicast_list = niu_set_rx_mode;
- dev->set_mac_address = niu_set_mac_addr;
- dev->do_ioctl = niu_ioctl;
- dev->tx_timeout = niu_tx_timeout;
+ dev->netdev_ops = &niu_netdev_ops;
dev->hard_start_xmit = niu_start_xmit;
dev->ethtool_ops = &niu_ethtool_ops;
dev->watchdog_timeo = NIU_TX_TIMEOUT;
- dev->change_mtu = niu_change_mtu;
}
static void __devinit niu_device_announce(struct niu *np)
--
^ permalink raw reply [flat|nested] 93+ messages in thread* [PATCH 33/33] acenic: convert to net_device_ops
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (31 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 32/33] niu: " Stephen Hemminger
@ 2008-11-17 23:42 ` Stephen Hemminger
2008-11-20 6:29 ` David Miller
2008-11-18 1:27 ` [PATCH 00/33] Network Devices Ops (v0.3) Jeff Kirsher
2008-11-20 1:33 ` David Miller
34 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-17 23:42 UTC (permalink / raw)
To: David Miller; +Cc: netdev
[-- Attachment #1: acenic-netdev_ops.patch --]
[-- Type: text/plain, Size: 1518 bytes --]
Convert this driver to network device ops. Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/acenic.c 2008-11-17 14:16:13.000000000 -0800
+++ b/drivers/net/acenic.c 2008-11-17 14:18:52.000000000 -0800
@@ -450,6 +450,17 @@ static const struct ethtool_ops ace_etht
static void ace_watchdog(struct net_device *dev);
+static const struct net_device_ops ace_netdev_ops = {
+ .open = ace_open,
+ .stop = ace_close,
+ .tx_timeout = ace_watchdog,
+ .get_stats = ace_get_stats,
+ .set_multicast_list = ace_set_multicast_list,
+ .set_mac_address = ace_set_mac_addr,
+ .change_mtu = ace_change_mtu,
+ .vlan_rx_register = ace_vlan_rx_register,
+};
+
static int __devinit acenic_probe_one(struct pci_dev *pdev,
const struct pci_device_id *id)
{
@@ -473,20 +484,13 @@ static int __devinit acenic_probe_one(st
dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
#if ACENIC_DO_VLAN
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
- dev->vlan_rx_register = ace_vlan_rx_register;
#endif
- dev->tx_timeout = &ace_watchdog;
dev->watchdog_timeo = 5*HZ;
- dev->open = &ace_open;
- dev->stop = &ace_close;
+ dev->netdev_ops = &ace_netdev_ops;
dev->hard_start_xmit = &ace_start_xmit;
- dev->get_stats = &ace_get_stats;
- dev->set_multicast_list = &ace_set_multicast_list;
SET_ETHTOOL_OPS(dev, &ace_ethtool_ops);
- dev->set_mac_address = &ace_set_mac_addr;
- dev->change_mtu = &ace_change_mtu;
/* we only display this string ONCE */
if (!boards_found)
--
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (32 preceding siblings ...)
2008-11-17 23:42 ` [PATCH 33/33] acenic: " Stephen Hemminger
@ 2008-11-18 1:27 ` Jeff Kirsher
2008-11-18 1:35 ` Stephen Hemminger
2008-11-20 1:33 ` David Miller
34 siblings, 1 reply; 93+ messages in thread
From: Jeff Kirsher @ 2008-11-18 1:27 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On Mon, Nov 17, 2008 at 3:42 PM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> This sequence of patches breaks the network device adminstration
> function table away from the network device data structure. It is
> a transitional API change (both keep working), and this set of patches
> hits a range of commonly used drivers. This should be enough to make sure
> both old and new interfaces get used and tested.
>
> --
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Did I miss a patch, or did you intentionally not convert ixgbe?
The following patches look find...
Patch 13/33 - e1000e
Patch 23/33 - e1000
Patch 25/33 - igb
Patch 26/33 - e100
Patch 29/33 - ixgb
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
--
Cheers,
Jeff
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-18 1:27 ` [PATCH 00/33] Network Devices Ops (v0.3) Jeff Kirsher
@ 2008-11-18 1:35 ` Stephen Hemminger
2008-11-18 1:43 ` Jeff Kirsher
2008-11-19 21:55 ` Jeff Kirsher
0 siblings, 2 replies; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-18 1:35 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: David Miller, netdev
On Mon, 17 Nov 2008 17:27:05 -0800
"Jeff Kirsher" <jeffrey.t.kirsher@intel.com> wrote:
> On Mon, Nov 17, 2008 at 3:42 PM, Stephen Hemminger
> <shemminger@vyatta.com> wrote:
> > This sequence of patches breaks the network device adminstration
> > function table away from the network device data structure. It is
> > a transitional API change (both keep working), and this set of patches
> > hits a range of commonly used drivers. This should be enough to make sure
> > both old and new interfaces get used and tested.
> >
> > --
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe netdev" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
> Did I miss a patch, or did you intentionally not convert ixgbe?
Since it was so similar to ixgb, both files are patched in same patch bundle.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-18 1:35 ` Stephen Hemminger
@ 2008-11-18 1:43 ` Jeff Kirsher
2008-11-19 21:55 ` Jeff Kirsher
1 sibling, 0 replies; 93+ messages in thread
From: Jeff Kirsher @ 2008-11-18 1:43 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On Mon, Nov 17, 2008 at 5:35 PM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> On Mon, 17 Nov 2008 17:27:05 -0800
> "Jeff Kirsher" <jeffrey.t.kirsher@intel.com> wrote:
>
>> On Mon, Nov 17, 2008 at 3:42 PM, Stephen Hemminger
>> <shemminger@vyatta.com> wrote:
>> > This sequence of patches breaks the network device adminstration
>> > function table away from the network device data structure. It is
>> > a transitional API change (both keep working), and this set of patches
>> > hits a range of commonly used drivers. This should be enough to make sure
>> > both old and new interfaces get used and tested.
>> >
>> > --
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe netdev" in
>> > the body of a message to majordomo@vger.kernel.org
>> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>> >
>>
>> Did I miss a patch, or did you intentionally not convert ixgbe?
>
> Since it was so similar to ixgb, both files are patched in same patch bundle.
Got it, thanks.
--
Cheers,
Jeff
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-18 1:35 ` Stephen Hemminger
2008-11-18 1:43 ` Jeff Kirsher
@ 2008-11-19 21:55 ` Jeff Kirsher
2008-11-19 22:04 ` David Miller
1 sibling, 1 reply; 93+ messages in thread
From: Jeff Kirsher @ 2008-11-19 21:55 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
On Mon, Nov 17, 2008 at 5:35 PM, Stephen Hemminger
<shemminger@vyatta.com> wrote:
> On Mon, 17 Nov 2008 17:27:05 -0800
> "Jeff Kirsher" <jeffrey.t.kirsher@intel.com> wrote:
>
>> On Mon, Nov 17, 2008 at 3:42 PM, Stephen Hemminger
>> <shemminger@vyatta.com> wrote:
>> > This sequence of patches breaks the network device adminstration
>> > function table away from the network device data structure. It is
>> > a transitional API change (both keep working), and this set of patches
>> > hits a range of commonly used drivers. This should be enough to make sure
>> > both old and new interfaces get used and tested.
>> >
>> >
>>
>> Did I miss a patch, or did you intentionally not convert ixgbe?
>
> Since it was so similar to ixgb, both files are patched in same patch bundle.
> --
>
Looking at this further, what is the benefit of this change? For this
massive of a change, I would expect some sort of significant benefit.
What is the driving force behind this change?
--
Cheers,
Jeff
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-19 21:55 ` Jeff Kirsher
@ 2008-11-19 22:04 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-19 22:04 UTC (permalink / raw)
To: jeffrey.t.kirsher; +Cc: shemminger, netdev
From: "Jeff Kirsher" <jeffrey.t.kirsher@intel.com>
Date: Wed, 19 Nov 2008 13:55:12 -0800
> On Mon, Nov 17, 2008 at 5:35 PM, Stephen Hemminger
> <shemminger@vyatta.com> wrote:
> > On Mon, 17 Nov 2008 17:27:05 -0800
> > "Jeff Kirsher" <jeffrey.t.kirsher@intel.com> wrote:
> >
> >> On Mon, Nov 17, 2008 at 3:42 PM, Stephen Hemminger
> >> <shemminger@vyatta.com> wrote:
> >> > This sequence of patches breaks the network device adminstration
> >> > function table away from the network device data structure. It is
> >> > a transitional API change (both keep working), and this set of patches
> >> > hits a range of commonly used drivers. This should be enough to make sure
> >> > both old and new interfaces get used and tested.
> >> >
> >> >
> >>
> >> Did I miss a patch, or did you intentionally not convert ixgbe?
> >
> > Since it was so similar to ixgb, both files are patched in same patch bundle.
> > --
> >
>
> Looking at this further, what is the benefit of this change? For this
> massive of a change, I would expect some sort of significant benefit.
>
> What is the driving force behind this change?
If you have 1,000 virtual MAC vlan devices, you have 1,000 copies of
these ops pointers being accessed by the CPU, that's stupid.
It's just one of many examples.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-17 23:42 [PATCH 00/33] Network Devices Ops (v0.3) Stephen Hemminger
` (33 preceding siblings ...)
2008-11-18 1:27 ` [PATCH 00/33] Network Devices Ops (v0.3) Jeff Kirsher
@ 2008-11-20 1:33 ` David Miller
2008-11-20 3:02 ` Stephen Hemminger
34 siblings, 1 reply; 93+ messages in thread
From: David Miller @ 2008-11-20 1:33 UTC (permalink / raw)
To: shemminger; +Cc: netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 17 Nov 2008 15:42:07 -0800
> This sequence of patches breaks the network device adminstration
> function table away from the network device data structure. It is
> a transitional API change (both keep working), and this set of patches
> hits a range of commonly used drivers. This should be enough to make sure
> both old and new interfaces get used and tested.
I'm starting to apply these patches, thanks Stephen.
I really think we should move even fast-path function pointers
here. When we have tons of virtual devices configured, it
doesn't make sense for us to touch tons of ->hard_start_xmit
pointer values which all evaluate to the same thing.
ops are ops
^ permalink raw reply [flat|nested] 93+ messages in thread* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-20 1:33 ` David Miller
@ 2008-11-20 3:02 ` Stephen Hemminger
2008-11-20 5:21 ` Eric Dumazet
0 siblings, 1 reply; 93+ messages in thread
From: Stephen Hemminger @ 2008-11-20 3:02 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On Wed, 19 Nov 2008 17:33:53 -0800 (PST)
David Miller <davem@davemloft.net> wrote:
> From: Stephen Hemminger <shemminger@vyatta.com>
> Date: Mon, 17 Nov 2008 15:42:07 -0800
>
> > This sequence of patches breaks the network device adminstration
> > function table away from the network device data structure. It is
> > a transitional API change (both keep working), and this set of patches
> > hits a range of commonly used drivers. This should be enough to make sure
> > both old and new interfaces get used and tested.
>
> I'm starting to apply these patches, thanks Stephen.
>
> I really think we should move even fast-path function pointers
> here. When we have tons of virtual devices configured, it
> doesn't make sense for us to touch tons of ->hard_start_xmit
> pointer values which all evaluate to the same thing.
>
> ops are ops
I have some more pending. I'll add neigh_setup and xmit stuff.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-20 3:02 ` Stephen Hemminger
@ 2008-11-20 5:21 ` Eric Dumazet
2008-11-20 5:25 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Eric Dumazet @ 2008-11-20 5:21 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
Stephen Hemminger a écrit :
> On Wed, 19 Nov 2008 17:33:53 -0800 (PST)
> David Miller <davem@davemloft.net> wrote:
>
>> From: Stephen Hemminger <shemminger@vyatta.com>
>> Date: Mon, 17 Nov 2008 15:42:07 -0800
>>
>>> This sequence of patches breaks the network device adminstration
>>> function table away from the network device data structure. It is
>>> a transitional API change (both keep working), and this set of patches
>>> hits a range of commonly used drivers. This should be enough to make sure
>>> both old and new interfaces get used and tested.
>> I'm starting to apply these patches, thanks Stephen.
>>
>> I really think we should move even fast-path function pointers
>> here. When we have tons of virtual devices configured, it
>> doesn't make sense for us to touch tons of ->hard_start_xmit
>> pointer values which all evaluate to the same thing.
>>
>> ops are ops
>
> I have some more pending. I'll add neigh_setup and xmit stuff.
So if you plan to release a new release of Network Device Ops...
I would have one suggestion about these ops, that would be to prefix
method names (open, close, ...) by a ndo_ or something that ease greping...
Thanks
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-20 5:21 ` Eric Dumazet
@ 2008-11-20 5:25 ` David Miller
2008-11-20 6:15 ` Alexey Dobriyan
0 siblings, 1 reply; 93+ messages in thread
From: David Miller @ 2008-11-20 5:25 UTC (permalink / raw)
To: dada1; +Cc: shemminger, netdev
From: Eric Dumazet <dada1@cosmosbay.com>
Date: Thu, 20 Nov 2008 06:21:29 +0100
> So if you plan to release a new release of Network Device Ops...
>
> I would have one suggestion about these ops, that would be to prefix
> method names (open, close, ...) by a ndo_ or something that ease greping...
Since I'm in the process of integrating this work, I'll take care
of doing this. It definitely sounds like a good idea to me.
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-20 5:25 ` David Miller
@ 2008-11-20 6:15 ` Alexey Dobriyan
2008-11-20 6:37 ` David Miller
0 siblings, 1 reply; 93+ messages in thread
From: Alexey Dobriyan @ 2008-11-20 6:15 UTC (permalink / raw)
To: David Miller; +Cc: dada1, shemminger, netdev
On Wed, Nov 19, 2008 at 09:25:02PM -0800, David Miller wrote:
> From: Eric Dumazet <dada1@cosmosbay.com>
> Date: Thu, 20 Nov 2008 06:21:29 +0100
>
> > So if you plan to release a new release of Network Device Ops...
> >
> > I would have one suggestion about these ops, that would be to prefix
> > method names (open, close, ...) by a ndo_ or something that ease greping...
>
> Since I'm in the process of integrating this work, I'll take care
> of doing this. It definitely sounds like a good idea to me.
Can use just "nd_".
^ permalink raw reply [flat|nested] 93+ messages in thread
* Re: [PATCH 00/33] Network Devices Ops (v0.3)
2008-11-20 6:15 ` Alexey Dobriyan
@ 2008-11-20 6:37 ` David Miller
0 siblings, 0 replies; 93+ messages in thread
From: David Miller @ 2008-11-20 6:37 UTC (permalink / raw)
To: adobriyan; +Cc: dada1, shemminger, netdev
From: Alexey Dobriyan <adobriyan@gmail.com>
Date: Thu, 20 Nov 2008 09:15:40 +0300
> On Wed, Nov 19, 2008 at 09:25:02PM -0800, David Miller wrote:
> > From: Eric Dumazet <dada1@cosmosbay.com>
> > Date: Thu, 20 Nov 2008 06:21:29 +0100
> >
> > > So if you plan to release a new release of Network Device Ops...
> > >
> > > I would have one suggestion about these ops, that would be to prefix
> > > method names (open, close, ...) by a ndo_ or something that ease greping...
> >
> > Since I'm in the process of integrating this work, I'll take care
> > of doing this. It definitely sounds like a good idea to me.
>
> Can use just "nd_".
Already used by ocfs and others.
^ permalink raw reply [flat|nested] 93+ messages in thread