diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-11-20 23:14:53 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-20 23:14:53 -0500 |
commit | 008298231abbeb91bc7be9e8b078607b816d1a4a (patch) | |
tree | 8cb0c17720086ef97c614b96241f06aa63ce8511 /drivers/net/bonding | |
parent | 6ab33d51713d6d60c7677c0d020910a8cb37e513 (diff) |
netdev: add more functions to netdevice ops
This patch moves neigh_setup and hard_start_xmit into the network device ops
structure. For bisection, fix all the previously converted drivers as well.
Bonding driver took the biggest hit on this.
Added a prefetch of the hard_start_xmit in the fast path to try and reduce
any impact this would have.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 614656c8187b..a339a8052737 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -1377,14 +1377,12 @@ done: | |||
1377 | return 0; | 1377 | return 0; |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | |||
1381 | static void bond_setup_by_slave(struct net_device *bond_dev, | 1380 | static void bond_setup_by_slave(struct net_device *bond_dev, |
1382 | struct net_device *slave_dev) | 1381 | struct net_device *slave_dev) |
1383 | { | 1382 | { |
1384 | struct bonding *bond = netdev_priv(bond_dev); | 1383 | struct bonding *bond = netdev_priv(bond_dev); |
1385 | 1384 | ||
1386 | bond_dev->neigh_setup = slave_dev->neigh_setup; | 1385 | bond_dev->header_ops = slave_dev->header_ops; |
1387 | bond_dev->header_ops = slave_dev->header_ops; | ||
1388 | 1386 | ||
1389 | bond_dev->type = slave_dev->type; | 1387 | bond_dev->type = slave_dev->type; |
1390 | bond_dev->hard_header_len = slave_dev->hard_header_len; | 1388 | bond_dev->hard_header_len = slave_dev->hard_header_len; |
@@ -4124,6 +4122,20 @@ static void bond_set_multicast_list(struct net_device *bond_dev) | |||
4124 | read_unlock(&bond->lock); | 4122 | read_unlock(&bond->lock); |
4125 | } | 4123 | } |
4126 | 4124 | ||
4125 | static int bond_neigh_setup(struct net_device *dev, struct neigh_parms *parms) | ||
4126 | { | ||
4127 | struct bonding *bond = netdev_priv(dev); | ||
4128 | struct slave *slave = bond->first_slave; | ||
4129 | |||
4130 | if (slave) { | ||
4131 | const struct net_device_ops *slave_ops | ||
4132 | = slave->dev->netdev_ops; | ||
4133 | if (slave_ops->ndo_neigh_setup) | ||
4134 | return slave_ops->ndo_neigh_setup(dev, parms); | ||
4135 | } | ||
4136 | return 0; | ||
4137 | } | ||
4138 | |||
4127 | /* | 4139 | /* |
4128 | * Change the MTU of all of a master's slaves to match the master | 4140 | * Change the MTU of all of a master's slaves to match the master |
4129 | */ | 4141 | */ |
@@ -4490,6 +4502,35 @@ static void bond_set_xmit_hash_policy(struct bonding *bond) | |||
4490 | } | 4502 | } |
4491 | } | 4503 | } |
4492 | 4504 | ||
4505 | static int bond_start_xmit(struct sk_buff *skb, struct net_device *dev) | ||
4506 | { | ||
4507 | const struct bonding *bond = netdev_priv(dev); | ||
4508 | |||
4509 | switch (bond->params.mode) { | ||
4510 | case BOND_MODE_ROUNDROBIN: | ||
4511 | return bond_xmit_roundrobin(skb, dev); | ||
4512 | case BOND_MODE_ACTIVEBACKUP: | ||
4513 | return bond_xmit_activebackup(skb, dev); | ||
4514 | case BOND_MODE_XOR: | ||
4515 | return bond_xmit_xor(skb, dev); | ||
4516 | case BOND_MODE_BROADCAST: | ||
4517 | return bond_xmit_broadcast(skb, dev); | ||
4518 | case BOND_MODE_8023AD: | ||
4519 | return bond_3ad_xmit_xor(skb, dev); | ||
4520 | case BOND_MODE_ALB: | ||
4521 | case BOND_MODE_TLB: | ||
4522 | return bond_alb_xmit(skb, dev); | ||
4523 | default: | ||
4524 | /* Should never happen, mode already checked */ | ||
4525 | printk(KERN_ERR DRV_NAME ": %s: Error: Unknown bonding mode %d\n", | ||
4526 | dev->name, bond->params.mode); | ||
4527 | WARN_ON_ONCE(1); | ||
4528 | dev_kfree_skb(skb); | ||
4529 | return NETDEV_TX_OK; | ||
4530 | } | ||
4531 | } | ||
4532 | |||
4533 | |||
4493 | /* | 4534 | /* |
4494 | * set bond mode specific net device operations | 4535 | * set bond mode specific net device operations |
4495 | */ | 4536 | */ |
@@ -4499,28 +4540,22 @@ void bond_set_mode_ops(struct bonding *bond, int mode) | |||
4499 | 4540 | ||
4500 | switch (mode) { | 4541 | switch (mode) { |
4501 | case BOND_MODE_ROUNDROBIN: | 4542 | case BOND_MODE_ROUNDROBIN: |
4502 | bond_dev->hard_start_xmit = bond_xmit_roundrobin; | ||
4503 | break; | 4543 | break; |
4504 | case BOND_MODE_ACTIVEBACKUP: | 4544 | case BOND_MODE_ACTIVEBACKUP: |
4505 | bond_dev->hard_start_xmit = bond_xmit_activebackup; | ||
4506 | break; | 4545 | break; |
4507 | case BOND_MODE_XOR: | 4546 | case BOND_MODE_XOR: |
4508 | bond_dev->hard_start_xmit = bond_xmit_xor; | ||
4509 | bond_set_xmit_hash_policy(bond); | 4547 | bond_set_xmit_hash_policy(bond); |
4510 | break; | 4548 | break; |
4511 | case BOND_MODE_BROADCAST: | 4549 | case BOND_MODE_BROADCAST: |
4512 | bond_dev->hard_start_xmit = bond_xmit_broadcast; | ||
4513 | break; | 4550 | break; |
4514 | case BOND_MODE_8023AD: | 4551 | case BOND_MODE_8023AD: |
4515 | bond_set_master_3ad_flags(bond); | 4552 | bond_set_master_3ad_flags(bond); |
4516 | bond_dev->hard_start_xmit = bond_3ad_xmit_xor; | ||
4517 | bond_set_xmit_hash_policy(bond); | 4553 | bond_set_xmit_hash_policy(bond); |
4518 | break; | 4554 | break; |
4519 | case BOND_MODE_ALB: | 4555 | case BOND_MODE_ALB: |
4520 | bond_set_master_alb_flags(bond); | 4556 | bond_set_master_alb_flags(bond); |
4521 | /* FALLTHRU */ | 4557 | /* FALLTHRU */ |
4522 | case BOND_MODE_TLB: | 4558 | case BOND_MODE_TLB: |
4523 | bond_dev->hard_start_xmit = bond_alb_xmit; | ||
4524 | break; | 4559 | break; |
4525 | default: | 4560 | default: |
4526 | /* Should never happen, mode already checked */ | 4561 | /* Should never happen, mode already checked */ |
@@ -4553,12 +4588,13 @@ static const struct ethtool_ops bond_ethtool_ops = { | |||
4553 | static const struct net_device_ops bond_netdev_ops = { | 4588 | static const struct net_device_ops bond_netdev_ops = { |
4554 | .ndo_open = bond_open, | 4589 | .ndo_open = bond_open, |
4555 | .ndo_stop = bond_close, | 4590 | .ndo_stop = bond_close, |
4591 | .ndo_start_xmit = bond_start_xmit, | ||
4556 | .ndo_get_stats = bond_get_stats, | 4592 | .ndo_get_stats = bond_get_stats, |
4557 | .ndo_do_ioctl = bond_do_ioctl, | 4593 | .ndo_do_ioctl = bond_do_ioctl, |
4558 | .ndo_set_multicast_list = bond_set_multicast_list, | 4594 | .ndo_set_multicast_list = bond_set_multicast_list, |
4559 | .ndo_change_mtu = bond_change_mtu, | 4595 | .ndo_change_mtu = bond_change_mtu, |
4560 | .ndo_validate_addr = NULL, | ||
4561 | .ndo_set_mac_address = bond_set_mac_address, | 4596 | .ndo_set_mac_address = bond_set_mac_address, |
4597 | .ndo_neigh_setup = bond_neigh_setup, | ||
4562 | .ndo_vlan_rx_register = bond_vlan_rx_register, | 4598 | .ndo_vlan_rx_register = bond_vlan_rx_register, |
4563 | .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid, | 4599 | .ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid, |
4564 | .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, | 4600 | .ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid, |