vlan: convert to net_device_ops
authorStephen Hemminger <shemminger@vyatta.com>
Thu, 20 Nov 2008 05:53:47 +0000 (21:53 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Nov 2008 06:42:41 +0000 (22:42 -0800)
Convert vlan devices and function pointers to net_device_ops.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/8021q/vlan.c
net/8021q/vlan_dev.c

index 72326b9c759c7cfbdacc5d27ac7adcbe1a00a9fc..41e8f65bd3f0f6ea0a121ad4bc48f68ffd569a61 100644 (file)
@@ -144,6 +144,7 @@ void unregister_vlan_dev(struct net_device *dev)
 {
        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_device *dev)
         * 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->ndo_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_device *dev)
                vlan_gvrp_uninit_applicant(real_dev);
 
                if (real_dev->features & NETIF_F_HW_VLAN_RX)
-                       real_dev->vlan_rx_register(real_dev, NULL);
+                       ops->ndo_vlan_rx_register(real_dev, NULL);
 
                hlist_del_rcu(&grp->hlist);
 
@@ -205,21 +206,21 @@ static void vlan_transfer_operstate(const struct net_device *dev,
 
 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->ndo_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->ndo_vlan_rx_add_vid || !ops->ndo_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 *dev)
 {
        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 *dev)
        grp->nr_vlans++;
 
        if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
-               real_dev->vlan_rx_register(real_dev, ngrp);
+               ops->ndo_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->ndo_vlan_rx_add_vid(real_dev, vlan_id);
 
        return 0;
 
index e4bf39f87032af3eea40659a1075b74e4017585f..71193a6b10e6bb8ec67d3d1bb09bd1fd9be6bf31 100644 (file)
@@ -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_device *dev, struct ifreq *ifr, int cmd)
        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->ndo_do_ioctl)
+                       err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd);
                break;
        }
 
@@ -697,6 +698,20 @@ static const struct ethtool_ops vlan_ethtool_ops = {
        .get_flags              = vlan_ethtool_get_flags,
 };
 
+static const struct net_device_ops vlan_netdev_ops = {
+       .ndo_change_mtu         = vlan_dev_change_mtu,
+       .ndo_init               = vlan_dev_init,
+       .ndo_uninit             = vlan_dev_uninit,
+       .ndo_open               = vlan_dev_open,
+       .ndo_stop               = vlan_dev_stop,
+       .ndo_validate_addr      = eth_validate_addr,
+       .ndo_set_mac_address    = vlan_dev_set_mac_address,
+       .ndo_set_rx_mode        = vlan_dev_set_rx_mode,
+       .ndo_set_multicast_list = vlan_dev_set_rx_mode,
+       .ndo_change_rx_flags    = vlan_dev_change_rx_flags,
+       .ndo_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;