diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-11-20 00:53:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-20 01:42:41 -0500 |
commit | 656299f706e52e0409733d704c2761f1b12d6954 (patch) | |
tree | fcf2013d86e552eda9e9576acc58a32912c616f4 /net/8021q | |
parent | 5bc3eb7e2f0026f246d939851109df99e8e9f64a (diff) |
vlan: convert to net_device_ops
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>
Diffstat (limited to 'net/8021q')
-rw-r--r-- | net/8021q/vlan.c | 18 | ||||
-rw-r--r-- | net/8021q/vlan_dev.c | 30 |
2 files changed, 28 insertions, 20 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 72326b9c759c..41e8f65bd3f0 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -144,6 +144,7 @@ void unregister_vlan_dev(struct net_device *dev) | |||
144 | { | 144 | { |
145 | struct vlan_dev_info *vlan = vlan_dev_info(dev); | 145 | struct vlan_dev_info *vlan = vlan_dev_info(dev); |
146 | struct net_device *real_dev = vlan->real_dev; | 146 | struct net_device *real_dev = vlan->real_dev; |
147 | const struct net_device_ops *ops = real_dev->netdev_ops; | ||
147 | struct vlan_group *grp; | 148 | struct vlan_group *grp; |
148 | u16 vlan_id = vlan->vlan_id; | 149 | u16 vlan_id = vlan->vlan_id; |
149 | 150 | ||
@@ -156,7 +157,7 @@ void unregister_vlan_dev(struct net_device *dev) | |||
156 | * HW accelerating devices or SW vlan input packet processing. | 157 | * HW accelerating devices or SW vlan input packet processing. |
157 | */ | 158 | */ |
158 | if (real_dev->features & NETIF_F_HW_VLAN_FILTER) | 159 | if (real_dev->features & NETIF_F_HW_VLAN_FILTER) |
159 | real_dev->vlan_rx_kill_vid(real_dev, vlan_id); | 160 | ops->ndo_vlan_rx_kill_vid(real_dev, vlan_id); |
160 | 161 | ||
161 | vlan_group_set_device(grp, vlan_id, NULL); | 162 | vlan_group_set_device(grp, vlan_id, NULL); |
162 | grp->nr_vlans--; | 163 | grp->nr_vlans--; |
@@ -170,7 +171,7 @@ void unregister_vlan_dev(struct net_device *dev) | |||
170 | vlan_gvrp_uninit_applicant(real_dev); | 171 | vlan_gvrp_uninit_applicant(real_dev); |
171 | 172 | ||
172 | if (real_dev->features & NETIF_F_HW_VLAN_RX) | 173 | if (real_dev->features & NETIF_F_HW_VLAN_RX) |
173 | real_dev->vlan_rx_register(real_dev, NULL); | 174 | ops->ndo_vlan_rx_register(real_dev, NULL); |
174 | 175 | ||
175 | hlist_del_rcu(&grp->hlist); | 176 | hlist_del_rcu(&grp->hlist); |
176 | 177 | ||
@@ -205,21 +206,21 @@ static void vlan_transfer_operstate(const struct net_device *dev, | |||
205 | 206 | ||
206 | int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id) | 207 | int vlan_check_real_dev(struct net_device *real_dev, u16 vlan_id) |
207 | { | 208 | { |
208 | char *name = real_dev->name; | 209 | const char *name = real_dev->name; |
210 | const struct net_device_ops *ops = real_dev->netdev_ops; | ||
209 | 211 | ||
210 | if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { | 212 | if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { |
211 | pr_info("8021q: VLANs not supported on %s\n", name); | 213 | pr_info("8021q: VLANs not supported on %s\n", name); |
212 | return -EOPNOTSUPP; | 214 | return -EOPNOTSUPP; |
213 | } | 215 | } |
214 | 216 | ||
215 | if ((real_dev->features & NETIF_F_HW_VLAN_RX) && | 217 | if ((real_dev->features & NETIF_F_HW_VLAN_RX) && !ops->ndo_vlan_rx_register) { |
216 | !real_dev->vlan_rx_register) { | ||
217 | pr_info("8021q: device %s has buggy VLAN hw accel\n", name); | 218 | pr_info("8021q: device %s has buggy VLAN hw accel\n", name); |
218 | return -EOPNOTSUPP; | 219 | return -EOPNOTSUPP; |
219 | } | 220 | } |
220 | 221 | ||
221 | if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && | 222 | if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && |
222 | (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) { | 223 | (!ops->ndo_vlan_rx_add_vid || !ops->ndo_vlan_rx_kill_vid)) { |
223 | pr_info("8021q: Device %s has buggy VLAN hw accel\n", name); | 224 | pr_info("8021q: Device %s has buggy VLAN hw accel\n", name); |
224 | return -EOPNOTSUPP; | 225 | return -EOPNOTSUPP; |
225 | } | 226 | } |
@@ -240,6 +241,7 @@ int register_vlan_dev(struct net_device *dev) | |||
240 | { | 241 | { |
241 | struct vlan_dev_info *vlan = vlan_dev_info(dev); | 242 | struct vlan_dev_info *vlan = vlan_dev_info(dev); |
242 | struct net_device *real_dev = vlan->real_dev; | 243 | struct net_device *real_dev = vlan->real_dev; |
244 | const struct net_device_ops *ops = real_dev->netdev_ops; | ||
243 | u16 vlan_id = vlan->vlan_id; | 245 | u16 vlan_id = vlan->vlan_id; |
244 | struct vlan_group *grp, *ngrp = NULL; | 246 | struct vlan_group *grp, *ngrp = NULL; |
245 | int err; | 247 | int err; |
@@ -275,9 +277,9 @@ int register_vlan_dev(struct net_device *dev) | |||
275 | grp->nr_vlans++; | 277 | grp->nr_vlans++; |
276 | 278 | ||
277 | if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX) | 279 | if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX) |
278 | real_dev->vlan_rx_register(real_dev, ngrp); | 280 | ops->ndo_vlan_rx_register(real_dev, ngrp); |
279 | if (real_dev->features & NETIF_F_HW_VLAN_FILTER) | 281 | if (real_dev->features & NETIF_F_HW_VLAN_FILTER) |
280 | real_dev->vlan_rx_add_vid(real_dev, vlan_id); | 282 | ops->ndo_vlan_rx_add_vid(real_dev, vlan_id); |
281 | 283 | ||
282 | return 0; | 284 | return 0; |
283 | 285 | ||
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index e4bf39f87032..71193a6b10e6 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
@@ -524,6 +524,7 @@ out: | |||
524 | static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | 524 | static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
525 | { | 525 | { |
526 | struct net_device *real_dev = vlan_dev_info(dev)->real_dev; | 526 | struct net_device *real_dev = vlan_dev_info(dev)->real_dev; |
527 | const struct net_device_ops *ops = real_dev->netdev_ops; | ||
527 | struct ifreq ifrr; | 528 | struct ifreq ifrr; |
528 | int err = -EOPNOTSUPP; | 529 | int err = -EOPNOTSUPP; |
529 | 530 | ||
@@ -534,8 +535,8 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
534 | case SIOCGMIIPHY: | 535 | case SIOCGMIIPHY: |
535 | case SIOCGMIIREG: | 536 | case SIOCGMIIREG: |
536 | case SIOCSMIIREG: | 537 | case SIOCSMIIREG: |
537 | if (real_dev->do_ioctl && netif_device_present(real_dev)) | 538 | if (netif_device_present(real_dev) && ops->ndo_do_ioctl) |
538 | err = real_dev->do_ioctl(real_dev, &ifrr, cmd); | 539 | err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd); |
539 | break; | 540 | break; |
540 | } | 541 | } |
541 | 542 | ||
@@ -697,6 +698,20 @@ static const struct ethtool_ops vlan_ethtool_ops = { | |||
697 | .get_flags = vlan_ethtool_get_flags, | 698 | .get_flags = vlan_ethtool_get_flags, |
698 | }; | 699 | }; |
699 | 700 | ||
701 | static const struct net_device_ops vlan_netdev_ops = { | ||
702 | .ndo_change_mtu = vlan_dev_change_mtu, | ||
703 | .ndo_init = vlan_dev_init, | ||
704 | .ndo_uninit = vlan_dev_uninit, | ||
705 | .ndo_open = vlan_dev_open, | ||
706 | .ndo_stop = vlan_dev_stop, | ||
707 | .ndo_validate_addr = eth_validate_addr, | ||
708 | .ndo_set_mac_address = vlan_dev_set_mac_address, | ||
709 | .ndo_set_rx_mode = vlan_dev_set_rx_mode, | ||
710 | .ndo_set_multicast_list = vlan_dev_set_rx_mode, | ||
711 | .ndo_change_rx_flags = vlan_dev_change_rx_flags, | ||
712 | .ndo_do_ioctl = vlan_dev_ioctl, | ||
713 | }; | ||
714 | |||
700 | void vlan_setup(struct net_device *dev) | 715 | void vlan_setup(struct net_device *dev) |
701 | { | 716 | { |
702 | ether_setup(dev); | 717 | ether_setup(dev); |
@@ -704,16 +719,7 @@ void vlan_setup(struct net_device *dev) | |||
704 | dev->priv_flags |= IFF_802_1Q_VLAN; | 719 | dev->priv_flags |= IFF_802_1Q_VLAN; |
705 | dev->tx_queue_len = 0; | 720 | dev->tx_queue_len = 0; |
706 | 721 | ||
707 | dev->change_mtu = vlan_dev_change_mtu; | 722 | dev->netdev_ops = &vlan_netdev_ops; |
708 | dev->init = vlan_dev_init; | ||
709 | dev->uninit = vlan_dev_uninit; | ||
710 | dev->open = vlan_dev_open; | ||
711 | dev->stop = vlan_dev_stop; | ||
712 | dev->set_mac_address = vlan_dev_set_mac_address; | ||
713 | dev->set_rx_mode = vlan_dev_set_rx_mode; | ||
714 | dev->set_multicast_list = vlan_dev_set_rx_mode; | ||
715 | dev->change_rx_flags = vlan_dev_change_rx_flags; | ||
716 | dev->do_ioctl = vlan_dev_ioctl; | ||
717 | dev->destructor = free_netdev; | 723 | dev->destructor = free_netdev; |
718 | dev->ethtool_ops = &vlan_ethtool_ops; | 724 | dev->ethtool_ops = &vlan_ethtool_ops; |
719 | 725 | ||