提交 656299f7 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

vlan: convert to net_device_ops

Convert vlan devices and function pointers to net_device_ops.
Signed-off-by: NStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5bc3eb7e
...@@ -144,6 +144,7 @@ void unregister_vlan_dev(struct net_device *dev) ...@@ -144,6 +144,7 @@ void unregister_vlan_dev(struct net_device *dev)
{ {
struct vlan_dev_info *vlan = vlan_dev_info(dev); struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_dev; struct net_device *real_dev = vlan->real_dev;
const struct net_device_ops *ops = real_dev->netdev_ops;
struct vlan_group *grp; struct vlan_group *grp;
u16 vlan_id = vlan->vlan_id; u16 vlan_id = vlan->vlan_id;
...@@ -156,7 +157,7 @@ void unregister_vlan_dev(struct net_device *dev) ...@@ -156,7 +157,7 @@ void unregister_vlan_dev(struct net_device *dev)
* HW accelerating devices or SW vlan input packet processing. * HW accelerating devices or SW vlan input packet processing.
*/ */
if (real_dev->features & NETIF_F_HW_VLAN_FILTER) 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); vlan_group_set_device(grp, vlan_id, NULL);
grp->nr_vlans--; grp->nr_vlans--;
...@@ -170,7 +171,7 @@ void unregister_vlan_dev(struct net_device *dev) ...@@ -170,7 +171,7 @@ void unregister_vlan_dev(struct net_device *dev)
vlan_gvrp_uninit_applicant(real_dev); vlan_gvrp_uninit_applicant(real_dev);
if (real_dev->features & NETIF_F_HW_VLAN_RX) 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); hlist_del_rcu(&grp->hlist);
...@@ -205,21 +206,21 @@ static void vlan_transfer_operstate(const struct net_device *dev, ...@@ -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) 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) { if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
pr_info("8021q: VLANs not supported on %s\n", name); pr_info("8021q: VLANs not supported on %s\n", name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if ((real_dev->features & NETIF_F_HW_VLAN_RX) && if ((real_dev->features & NETIF_F_HW_VLAN_RX) && !ops->ndo_vlan_rx_register) {
!real_dev->vlan_rx_register) {
pr_info("8021q: device %s has buggy VLAN hw accel\n", name); pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && 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); pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -240,6 +241,7 @@ int register_vlan_dev(struct net_device *dev) ...@@ -240,6 +241,7 @@ int register_vlan_dev(struct net_device *dev)
{ {
struct vlan_dev_info *vlan = vlan_dev_info(dev); struct vlan_dev_info *vlan = vlan_dev_info(dev);
struct net_device *real_dev = vlan->real_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; u16 vlan_id = vlan->vlan_id;
struct vlan_group *grp, *ngrp = NULL; struct vlan_group *grp, *ngrp = NULL;
int err; int err;
...@@ -275,9 +277,9 @@ int register_vlan_dev(struct net_device *dev) ...@@ -275,9 +277,9 @@ int register_vlan_dev(struct net_device *dev)
grp->nr_vlans++; grp->nr_vlans++;
if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX) 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) 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; return 0;
......
...@@ -524,6 +524,7 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p) ...@@ -524,6 +524,7 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 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; struct net_device *real_dev = vlan_dev_info(dev)->real_dev;
const struct net_device_ops *ops = real_dev->netdev_ops;
struct ifreq ifrr; struct ifreq ifrr;
int err = -EOPNOTSUPP; int err = -EOPNOTSUPP;
...@@ -534,8 +535,8 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -534,8 +535,8 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case SIOCGMIIPHY: case SIOCGMIIPHY:
case SIOCGMIIREG: case SIOCGMIIREG:
case SIOCSMIIREG: case SIOCSMIIREG:
if (real_dev->do_ioctl && netif_device_present(real_dev)) if (netif_device_present(real_dev) && ops->ndo_do_ioctl)
err = real_dev->do_ioctl(real_dev, &ifrr, cmd); err = ops->ndo_do_ioctl(real_dev, &ifrr, cmd);
break; break;
} }
...@@ -697,6 +698,20 @@ static const struct ethtool_ops vlan_ethtool_ops = { ...@@ -697,6 +698,20 @@ static const struct ethtool_ops vlan_ethtool_ops = {
.get_flags = vlan_ethtool_get_flags, .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) void vlan_setup(struct net_device *dev)
{ {
ether_setup(dev); ether_setup(dev);
...@@ -704,16 +719,7 @@ void vlan_setup(struct net_device *dev) ...@@ -704,16 +719,7 @@ void vlan_setup(struct net_device *dev)
dev->priv_flags |= IFF_802_1Q_VLAN; dev->priv_flags |= IFF_802_1Q_VLAN;
dev->tx_queue_len = 0; dev->tx_queue_len = 0;
dev->change_mtu = vlan_dev_change_mtu; dev->netdev_ops = &vlan_netdev_ops;
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->destructor = free_netdev; dev->destructor = free_netdev;
dev->ethtool_ops = &vlan_ethtool_ops; dev->ethtool_ops = &vlan_ethtool_ops;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册