Subject: Re: [RFC] network device ops phase 1

From: Stephen Hemminger <[email-masked]>
Date: Mon, 10 Nov 2008 17:21:07 -0800

On Mon, 10 Nov 2008 17:02:11 -0800 (PST)
David Miller <[email-masked]> wrote:

> From: Stephen Hemminger <[email-masked]>
> Date: Fri, 7 Nov 2008 15:50:23 -0800
> 
> > This early work on a series of patches to separate the management portions
> > of the network device (immutable function pointers) from the data
> > structure part of the network device.
>  ...
> 
> I think this is a good way to attack this kind of transition.
> 
> Fix the build errors, do some testing, and please resubmit:
> 
> net/core/dev.c: In function ‘register_netdevice’:
> net/core/dev.c:4075: error: ‘struct net_device_ops’ has no member named ‘poll_controller’
> net/core/dev.c:4075: error: ‘struct net_device’ has no member named ‘poll_controller’
> make[2]: *** [net/core/dev.o] Error 1
> make[1]: *** [net/core] Error 2
> make: *** [net] Error 2
> make: *** Waiting for unfinished jobs....
> 
> Thanks.

This is one case where I wish GCC had more C++ style anonymous structures
so the following would work, and avoid the copying and allocation.

struct net_device_ops {
   int (*init)(struct net_device *);
...
};

struct net_device {
...
#ifdef CONFIG_COMPAT_XXX
   struct net_device_ops;
#endif
   struct net_device_ops *ops;
};

void register_netdevice(struct net_device *dev)
{
...

#ifdef CONFIG_COMPAT_XXX
      if (ops == NULL) {
         printk("loser device %s", dev->name);
         dev->ops = (struct net_device_ops *) dev->init;
      }
#endif

}