Skip to content

Commit 0082982

Browse files
Stephen Hemmingerdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6ab33d5 commit 0082982

36 files changed

+183
-93
lines changed

drivers/net/8139cp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,7 @@ static const struct net_device_ops cp_netdev_ops = {
18241824
.ndo_set_multicast_list = cp_set_rx_mode,
18251825
.ndo_get_stats = cp_get_stats,
18261826
.ndo_do_ioctl = cp_ioctl,
1827+
.ndo_start_xmit = cp_start_xmit,
18271828
.ndo_tx_timeout = cp_tx_timeout,
18281829
#if CP_VLAN_TAG_USED
18291830
.ndo_vlan_rx_register = cp_vlan_rx_register,
@@ -1949,7 +1950,6 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
19491950
memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
19501951

19511952
dev->netdev_ops = &cp_netdev_ops;
1952-
dev->hard_start_xmit = cp_start_xmit;
19531953
netif_napi_add(dev, &cp->napi, cp_rx_poll, 16);
19541954
dev->ethtool_ops = &cp_ethtool_ops;
19551955
dev->watchdog_timeo = TX_TIMEOUT;

drivers/net/8139too.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ static const struct net_device_ops rtl8139_netdev_ops = {
921921
.ndo_stop = rtl8139_close,
922922
.ndo_get_stats = rtl8139_get_stats,
923923
.ndo_validate_addr = eth_validate_addr,
924+
.ndo_start_xmit = rtl8139_start_xmit,
924925
.ndo_set_multicast_list = rtl8139_set_rx_mode,
925926
.ndo_do_ioctl = netdev_ioctl,
926927
.ndo_tx_timeout = rtl8139_tx_timeout,
@@ -992,7 +993,6 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
992993
dev->netdev_ops = &rtl8139_netdev_ops;
993994
dev->ethtool_ops = &rtl8139_ethtool_ops;
994995
dev->watchdog_timeo = TX_TIMEOUT;
995-
dev->hard_start_xmit = rtl8139_start_xmit;
996996
netif_napi_add(dev, &tp->napi, rtl8139_poll, 64);
997997

998998
/* note: the hardware is not capable of sg/csum/highdma, however

drivers/net/acenic.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,13 @@ static const struct net_device_ops ace_netdev_ops = {
455455
.ndo_stop = ace_close,
456456
.ndo_tx_timeout = ace_watchdog,
457457
.ndo_get_stats = ace_get_stats,
458+
.ndo_start_xmit = ace_start_xmit,
458459
.ndo_set_multicast_list = ace_set_multicast_list,
459460
.ndo_set_mac_address = ace_set_mac_addr,
460461
.ndo_change_mtu = ace_change_mtu,
462+
#if ACENIC_DO_VLAN
461463
.ndo_vlan_rx_register = ace_vlan_rx_register,
464+
#endif
462465
};
463466

464467
static int __devinit acenic_probe_one(struct pci_dev *pdev,
@@ -489,7 +492,6 @@ static int __devinit acenic_probe_one(struct pci_dev *pdev,
489492
dev->watchdog_timeo = 5*HZ;
490493

491494
dev->netdev_ops = &ace_netdev_ops;
492-
dev->hard_start_xmit = &ace_start_xmit;
493495
SET_ETHTOOL_OPS(dev, &ace_ethtool_ops);
494496

495497
/* we only display this string ONCE */

drivers/net/atl1e/atl1e_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2256,6 +2256,7 @@ static void atl1e_shutdown(struct pci_dev *pdev)
22562256
static const struct net_device_ops atl1e_netdev_ops = {
22572257
.ndo_open = atl1e_open,
22582258
.ndo_stop = atl1e_close,
2259+
.ndo_start_xmit = atl1e_xmit_frame,
22592260
.ndo_get_stats = atl1e_get_stats,
22602261
.ndo_set_multicast_list = atl1e_set_multi,
22612262
.ndo_validate_addr = eth_validate_addr,
@@ -2277,7 +2278,7 @@ static int atl1e_init_netdev(struct net_device *netdev, struct pci_dev *pdev)
22772278

22782279
netdev->irq = pdev->irq;
22792280
netdev->netdev_ops = &atl1e_netdev_ops;
2280-
netdev->hard_start_xmit = atl1e_xmit_frame,
2281+
22812282
netdev->watchdog_timeo = AT_TX_WATCHDOG;
22822283
atl1e_set_ethtool_ops(netdev);
22832284

drivers/net/atlx/atl1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,12 +2883,13 @@ static void atl1_poll_controller(struct net_device *netdev)
28832883
static const struct net_device_ops atl1_netdev_ops = {
28842884
.ndo_open = atl1_open,
28852885
.ndo_stop = atl1_close,
2886+
.ndo_start_xmit = atl1_xmit_frame,
28862887
.ndo_set_multicast_list = atlx_set_multi,
28872888
.ndo_validate_addr = eth_validate_addr,
28882889
.ndo_set_mac_address = atl1_set_mac,
28892890
.ndo_change_mtu = atl1_change_mtu,
28902891
.ndo_do_ioctl = atlx_ioctl,
2891-
.ndo_tx_timeout = atlx_tx_timeout,
2892+
.ndo_tx_timeout = atlx_tx_timeout,
28922893
.ndo_vlan_rx_register = atlx_vlan_rx_register,
28932894
#ifdef CONFIG_NET_POLL_CONTROLLER
28942895
.ndo_poll_controller = atl1_poll_controller,
@@ -2983,7 +2984,6 @@ static int __devinit atl1_probe(struct pci_dev *pdev,
29832984
adapter->mii.reg_num_mask = 0x1f;
29842985

29852986
netdev->netdev_ops = &atl1_netdev_ops;
2986-
netdev->hard_start_xmit = &atl1_xmit_frame;
29872987
netdev->watchdog_timeo = 5 * HZ;
29882988

29892989
netdev->ethtool_ops = &atl1_ethtool_ops;

drivers/net/atlx/atl2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,6 +1315,7 @@ static void atl2_poll_controller(struct net_device *netdev)
13151315
static const struct net_device_ops atl2_netdev_ops = {
13161316
.ndo_open = atl2_open,
13171317
.ndo_stop = atl2_close,
1318+
.ndo_start_xmit = atl2_xmit_frame,
13181319
.ndo_set_multicast_list = atl2_set_multi,
13191320
.ndo_validate_addr = eth_validate_addr,
13201321
.ndo_set_mac_address = atl2_set_mac,
@@ -1400,7 +1401,6 @@ static int __devinit atl2_probe(struct pci_dev *pdev,
14001401

14011402
atl2_setup_pcicmd(pdev);
14021403

1403-
netdev->hard_start_xmit = &atl2_xmit_frame;
14041404
netdev->netdev_ops = &atl2_netdev_ops;
14051405
atl2_set_ethtool_ops(netdev);
14061406
netdev->watchdog_timeo = 5 * HZ;

drivers/net/bonding/bond_main.c

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,14 +1377,12 @@ static int bond_compute_features(struct bonding *bond)
13771377
return 0;
13781378
}
13791379

1380-
13811380
static void bond_setup_by_slave(struct net_device *bond_dev,
13821381
struct net_device *slave_dev)
13831382
{
13841383
struct bonding *bond = netdev_priv(bond_dev);
13851384

1386-
bond_dev->neigh_setup = slave_dev->neigh_setup;
1387-
bond_dev->header_ops = slave_dev->header_ops;
1385+
bond_dev->header_ops = slave_dev->header_ops;
13881386

13891387
bond_dev->type = slave_dev->type;
13901388
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)
41244122
read_unlock(&bond->lock);
41254123
}
41264124

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+
41274139
/*
41284140
* Change the MTU of all of a master's slaves to match the master
41294141
*/
@@ -4490,6 +4502,35 @@ static void bond_set_xmit_hash_policy(struct bonding *bond)
44904502
}
44914503
}
44924504

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+
44934534
/*
44944535
* set bond mode specific net device operations
44954536
*/
@@ -4499,28 +4540,22 @@ void bond_set_mode_ops(struct bonding *bond, int mode)
44994540

45004541
switch (mode) {
45014542
case BOND_MODE_ROUNDROBIN:
4502-
bond_dev->hard_start_xmit = bond_xmit_roundrobin;
45034543
break;
45044544
case BOND_MODE_ACTIVEBACKUP:
4505-
bond_dev->hard_start_xmit = bond_xmit_activebackup;
45064545
break;
45074546
case BOND_MODE_XOR:
4508-
bond_dev->hard_start_xmit = bond_xmit_xor;
45094547
bond_set_xmit_hash_policy(bond);
45104548
break;
45114549
case BOND_MODE_BROADCAST:
4512-
bond_dev->hard_start_xmit = bond_xmit_broadcast;
45134550
break;
45144551
case BOND_MODE_8023AD:
45154552
bond_set_master_3ad_flags(bond);
4516-
bond_dev->hard_start_xmit = bond_3ad_xmit_xor;
45174553
bond_set_xmit_hash_policy(bond);
45184554
break;
45194555
case BOND_MODE_ALB:
45204556
bond_set_master_alb_flags(bond);
45214557
/* FALLTHRU */
45224558
case BOND_MODE_TLB:
4523-
bond_dev->hard_start_xmit = bond_alb_xmit;
45244559
break;
45254560
default:
45264561
/* Should never happen, mode already checked */
@@ -4553,12 +4588,13 @@ static const struct ethtool_ops bond_ethtool_ops = {
45534588
static const struct net_device_ops bond_netdev_ops = {
45544589
.ndo_open = bond_open,
45554590
.ndo_stop = bond_close,
4591+
.ndo_start_xmit = bond_start_xmit,
45564592
.ndo_get_stats = bond_get_stats,
45574593
.ndo_do_ioctl = bond_do_ioctl,
45584594
.ndo_set_multicast_list = bond_set_multicast_list,
45594595
.ndo_change_mtu = bond_change_mtu,
4560-
.ndo_validate_addr = NULL,
45614596
.ndo_set_mac_address = bond_set_mac_address,
4597+
.ndo_neigh_setup = bond_neigh_setup,
45624598
.ndo_vlan_rx_register = bond_vlan_rx_register,
45634599
.ndo_vlan_rx_add_vid = bond_vlan_rx_add_vid,
45644600
.ndo_vlan_rx_kill_vid = bond_vlan_rx_kill_vid,

drivers/net/chelsio/cxgb2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static int t1_set_mac_addr(struct net_device *dev, void *p)
915915
}
916916

917917
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
918-
static void vlan_rx_register(struct net_device *dev,
918+
static void t1_vlan_rx_register(struct net_device *dev,
919919
struct vlan_group *grp)
920920
{
921921
struct adapter *adapter = dev->ml_priv;
@@ -1013,14 +1013,15 @@ void t1_fatal_err(struct adapter *adapter)
10131013
static const struct net_device_ops cxgb_netdev_ops = {
10141014
.ndo_open = cxgb_open,
10151015
.ndo_stop = cxgb_close,
1016+
.ndo_start_xmit = t1_start_xmit,
10161017
.ndo_get_stats = t1_get_stats,
10171018
.ndo_validate_addr = eth_validate_addr,
10181019
.ndo_set_multicast_list = t1_set_rxmode,
10191020
.ndo_do_ioctl = t1_ioctl,
10201021
.ndo_change_mtu = t1_change_mtu,
10211022
.ndo_set_mac_address = t1_set_mac_addr,
10221023
#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
1023-
.ndo_vlan_rx_register = vlan_rx_register,
1024+
.ndo_vlan_rx_register = t1_vlan_rx_register,
10241025
#endif
10251026
#ifdef CONFIG_NET_POLL_CONTROLLER
10261027
.ndo_poll_controller = t1_netpoll,
@@ -1157,7 +1158,6 @@ static int __devinit init_one(struct pci_dev *pdev,
11571158
}
11581159

11591160
netdev->netdev_ops = &cxgb_netdev_ops;
1160-
netdev->hard_start_xmit = t1_start_xmit;
11611161
netdev->hard_header_len += (adapter->flags & TSO_CAPABLE) ?
11621162
sizeof(struct cpl_tx_pkt_lso) : sizeof(struct cpl_tx_pkt);
11631163

drivers/net/cxgb3/cxgb3_main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,6 @@ static int __devinit init_one(struct pci_dev *pdev,
29552955

29562956
netdev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
29572957
netdev->netdev_ops = &cxgb_netdev_ops;
2958-
netdev->hard_start_xmit = t3_eth_xmit;
29592958
SET_ETHTOOL_OPS(netdev, &cxgb_ethtool_ops);
29602959
}
29612960

drivers/net/e100.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2615,6 +2615,7 @@ static int e100_close(struct net_device *netdev)
26152615
static const struct net_device_ops e100_netdev_ops = {
26162616
.ndo_open = e100_open,
26172617
.ndo_stop = e100_close,
2618+
.ndo_start_xmit = e100_xmit_frame,
26182619
.ndo_validate_addr = eth_validate_addr,
26192620
.ndo_set_multicast_list = e100_set_multicast_list,
26202621
.ndo_set_mac_address = e100_set_mac_address,
@@ -2640,7 +2641,6 @@ static int __devinit e100_probe(struct pci_dev *pdev,
26402641
}
26412642

26422643
netdev->netdev_ops = &e100_netdev_ops;
2643-
netdev->hard_start_xmit = e100_xmit_frame;
26442644
SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops);
26452645
netdev->watchdog_timeo = E100_WATCHDOG_PERIOD;
26462646
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);

drivers/net/e1000/e1000_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ static int e1000_is_need_ioport(struct pci_dev *pdev)
891891
static const struct net_device_ops e1000_netdev_ops = {
892892
.ndo_open = e1000_open,
893893
.ndo_stop = e1000_close,
894+
.ndo_start_xmit = e1000_xmit_frame,
894895
.ndo_get_stats = e1000_get_stats,
895896
.ndo_set_rx_mode = e1000_set_rx_mode,
896897
.ndo_set_mac_address = e1000_set_mac,
@@ -1001,7 +1002,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
10011002
}
10021003

10031004
netdev->netdev_ops = &e1000_netdev_ops;
1004-
netdev->hard_start_xmit = &e1000_xmit_frame;
10051005
e1000_set_ethtool_ops(netdev);
10061006
netdev->watchdog_timeo = 5 * HZ;
10071007
netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);

drivers/net/e1000e/netdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4707,6 +4707,7 @@ static void e1000_eeprom_checks(struct e1000_adapter *adapter)
47074707
static const struct net_device_ops e1000e_netdev_ops = {
47084708
.ndo_open = e1000_open,
47094709
.ndo_stop = e1000_close,
4710+
.ndo_start_xmit = e1000_xmit_frame,
47104711
.ndo_get_stats = e1000_get_stats,
47114712
.ndo_set_multicast_list = e1000_set_multi,
47124713
.ndo_set_mac_address = e1000_set_mac,
@@ -4822,7 +4823,6 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
48224823

48234824
/* construct the net_device struct */
48244825
netdev->netdev_ops = &e1000e_netdev_ops;
4825-
netdev->hard_start_xmit = &e1000_xmit_frame;
48264826
e1000e_set_ethtool_ops(netdev);
48274827
netdev->watchdog_timeo = 5 * HZ;
48284828
netif_napi_add(netdev, &adapter->napi, e1000_clean, 64);

drivers/net/enic/enic_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,6 +1593,7 @@ static void enic_iounmap(struct enic *enic)
15931593
static const struct net_device_ops enic_netdev_ops = {
15941594
.ndo_open = enic_open,
15951595
.ndo_stop = enic_stop,
1596+
.ndo_start_xmit = enic_hard_start_xmit,
15961597
.ndo_get_stats = enic_get_stats,
15971598
.ndo_validate_addr = eth_validate_addr,
15981599
.ndo_set_multicast_list = enic_set_multicast_list,
@@ -1830,7 +1831,6 @@ static int __devinit enic_probe(struct pci_dev *pdev,
18301831
}
18311832

18321833
netdev->netdev_ops = &enic_netdev_ops;
1833-
netdev->hard_start_xmit = enic_hard_start_xmit;
18341834
netdev->watchdog_timeo = 2 * HZ;
18351835
netdev->ethtool_ops = &enic_ethtool_ops;
18361836

drivers/net/forcedeth.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5412,6 +5412,23 @@ static const struct net_device_ops nv_netdev_ops = {
54125412
.ndo_open = nv_open,
54135413
.ndo_stop = nv_close,
54145414
.ndo_get_stats = nv_get_stats,
5415+
.ndo_start_xmit = nv_start_xmit,
5416+
.ndo_tx_timeout = nv_tx_timeout,
5417+
.ndo_change_mtu = nv_change_mtu,
5418+
.ndo_validate_addr = eth_validate_addr,
5419+
.ndo_set_mac_address = nv_set_mac_address,
5420+
.ndo_set_multicast_list = nv_set_multicast,
5421+
.ndo_vlan_rx_register = nv_vlan_rx_register,
5422+
#ifdef CONFIG_NET_POLL_CONTROLLER
5423+
.ndo_poll_controller = nv_poll_controller,
5424+
#endif
5425+
};
5426+
5427+
static const struct net_device_ops nv_netdev_ops_optimized = {
5428+
.ndo_open = nv_open,
5429+
.ndo_stop = nv_close,
5430+
.ndo_get_stats = nv_get_stats,
5431+
.ndo_start_xmit = nv_start_xmit_optimized,
54155432
.ndo_tx_timeout = nv_tx_timeout,
54165433
.ndo_change_mtu = nv_change_mtu,
54175434
.ndo_validate_addr = eth_validate_addr,
@@ -5592,11 +5609,10 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
55925609
goto out_freering;
55935610

55945611
if (!nv_optimized(np))
5595-
dev->hard_start_xmit = nv_start_xmit;
5612+
dev->netdev_ops = &nv_netdev_ops;
55965613
else
5597-
dev->hard_start_xmit = nv_start_xmit_optimized;
5614+
dev->netdev_ops = &nv_netdev_ops_optimized;
55985615

5599-
dev->netdev_ops = &nv_netdev_ops;
56005616
#ifdef CONFIG_FORCEDETH_NAPI
56015617
netif_napi_add(dev, &np->napi, nv_napi_poll, RX_WORK_PER_LOOP);
56025618
#endif

drivers/net/ifb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ static void ri_tasklet(unsigned long dev)
138138
}
139139

140140
static const struct net_device_ops ifb_netdev_ops = {
141-
.ndo_validate_addr = eth_validate_addr,
142141
.ndo_open = ifb_open,
143142
.ndo_stop = ifb_close,
143+
.ndo_start_xmit = ifb_xmit,
144+
.ndo_validate_addr = eth_validate_addr,
144145
};
145146

146147
static void ifb_setup(struct net_device *dev)
147148
{
148149
/* Initialize the device structure. */
149-
dev->hard_start_xmit = ifb_xmit;
150150
dev->destructor = free_netdev;
151151
dev->netdev_ops = &ifb_netdev_ops;
152152

0 commit comments

Comments
 (0)