diff options
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 395 |
1 files changed, 253 insertions, 142 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9d77b1d7dca8..41e1224651cf 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -43,6 +43,9 @@ | |||
43 | 43 | ||
44 | #include <net/net_namespace.h> | 44 | #include <net/net_namespace.h> |
45 | #include <net/dsa.h> | 45 | #include <net/dsa.h> |
46 | #ifdef CONFIG_DCB | ||
47 | #include <net/dcbnl.h> | ||
48 | #endif | ||
46 | 49 | ||
47 | struct vlan_group; | 50 | struct vlan_group; |
48 | struct ethtool_ops; | 51 | struct ethtool_ops; |
@@ -311,14 +314,16 @@ struct napi_struct { | |||
311 | spinlock_t poll_lock; | 314 | spinlock_t poll_lock; |
312 | int poll_owner; | 315 | int poll_owner; |
313 | struct net_device *dev; | 316 | struct net_device *dev; |
314 | struct list_head dev_list; | ||
315 | #endif | 317 | #endif |
318 | struct list_head dev_list; | ||
319 | struct sk_buff *gro_list; | ||
316 | }; | 320 | }; |
317 | 321 | ||
318 | enum | 322 | enum |
319 | { | 323 | { |
320 | NAPI_STATE_SCHED, /* Poll is scheduled */ | 324 | NAPI_STATE_SCHED, /* Poll is scheduled */ |
321 | NAPI_STATE_DISABLE, /* Disable pending */ | 325 | NAPI_STATE_DISABLE, /* Disable pending */ |
326 | NAPI_STATE_NPSVC, /* Netpoll - don't dequeue from poll_list */ | ||
322 | }; | 327 | }; |
323 | 328 | ||
324 | extern void __napi_schedule(struct napi_struct *n); | 329 | extern void __napi_schedule(struct napi_struct *n); |
@@ -372,22 +377,8 @@ static inline int napi_reschedule(struct napi_struct *napi) | |||
372 | * | 377 | * |
373 | * Mark NAPI processing as complete. | 378 | * Mark NAPI processing as complete. |
374 | */ | 379 | */ |
375 | static inline void __napi_complete(struct napi_struct *n) | 380 | extern void __napi_complete(struct napi_struct *n); |
376 | { | 381 | extern void napi_complete(struct napi_struct *n); |
377 | BUG_ON(!test_bit(NAPI_STATE_SCHED, &n->state)); | ||
378 | list_del(&n->poll_list); | ||
379 | smp_mb__before_clear_bit(); | ||
380 | clear_bit(NAPI_STATE_SCHED, &n->state); | ||
381 | } | ||
382 | |||
383 | static inline void napi_complete(struct napi_struct *n) | ||
384 | { | ||
385 | unsigned long flags; | ||
386 | |||
387 | local_irq_save(flags); | ||
388 | __napi_complete(n); | ||
389 | local_irq_restore(flags); | ||
390 | } | ||
391 | 382 | ||
392 | /** | 383 | /** |
393 | * napi_disable - prevent NAPI from scheduling | 384 | * napi_disable - prevent NAPI from scheduling |
@@ -451,6 +442,147 @@ struct netdev_queue { | |||
451 | struct Qdisc *qdisc_sleeping; | 442 | struct Qdisc *qdisc_sleeping; |
452 | } ____cacheline_aligned_in_smp; | 443 | } ____cacheline_aligned_in_smp; |
453 | 444 | ||
445 | |||
446 | /* | ||
447 | * This structure defines the management hooks for network devices. | ||
448 | * The following hooks can be defined; unless noted otherwise, they are | ||
449 | * optional and can be filled with a null pointer. | ||
450 | * | ||
451 | * int (*ndo_init)(struct net_device *dev); | ||
452 | * This function is called once when network device is registered. | ||
453 | * The network device can use this to any late stage initializaton | ||
454 | * or semantic validattion. It can fail with an error code which will | ||
455 | * be propogated back to register_netdev | ||
456 | * | ||
457 | * void (*ndo_uninit)(struct net_device *dev); | ||
458 | * This function is called when device is unregistered or when registration | ||
459 | * fails. It is not called if init fails. | ||
460 | * | ||
461 | * int (*ndo_open)(struct net_device *dev); | ||
462 | * This function is called when network device transistions to the up | ||
463 | * state. | ||
464 | * | ||
465 | * int (*ndo_stop)(struct net_device *dev); | ||
466 | * This function is called when network device transistions to the down | ||
467 | * state. | ||
468 | * | ||
469 | * int (*ndo_hard_start_xmit)(struct sk_buff *skb, struct net_device *dev); | ||
470 | * Called when a packet needs to be transmitted. | ||
471 | * Must return NETDEV_TX_OK , NETDEV_TX_BUSY, or NETDEV_TX_LOCKED, | ||
472 | * Required can not be NULL. | ||
473 | * | ||
474 | * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb); | ||
475 | * Called to decide which queue to when device supports multiple | ||
476 | * transmit queues. | ||
477 | * | ||
478 | * void (*ndo_change_rx_flags)(struct net_device *dev, int flags); | ||
479 | * This function is called to allow device receiver to make | ||
480 | * changes to configuration when multicast or promiscious is enabled. | ||
481 | * | ||
482 | * void (*ndo_set_rx_mode)(struct net_device *dev); | ||
483 | * This function is called device changes address list filtering. | ||
484 | * | ||
485 | * void (*ndo_set_multicast_list)(struct net_device *dev); | ||
486 | * This function is called when the multicast address list changes. | ||
487 | * | ||
488 | * int (*ndo_set_mac_address)(struct net_device *dev, void *addr); | ||
489 | * This function is called when the Media Access Control address | ||
490 | * needs to be changed. If not this interface is not defined, the | ||
491 | * mac address can not be changed. | ||
492 | * | ||
493 | * int (*ndo_validate_addr)(struct net_device *dev); | ||
494 | * Test if Media Access Control address is valid for the device. | ||
495 | * | ||
496 | * int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd); | ||
497 | * Called when a user request an ioctl which can't be handled by | ||
498 | * the generic interface code. If not defined ioctl's return | ||
499 | * not supported error code. | ||
500 | * | ||
501 | * int (*ndo_set_config)(struct net_device *dev, struct ifmap *map); | ||
502 | * Used to set network devices bus interface parameters. This interface | ||
503 | * is retained for legacy reason, new devices should use the bus | ||
504 | * interface (PCI) for low level management. | ||
505 | * | ||
506 | * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu); | ||
507 | * Called when a user wants to change the Maximum Transfer Unit | ||
508 | * of a device. If not defined, any request to change MTU will | ||
509 | * will return an error. | ||
510 | * | ||
511 | * void (*ndo_tx_timeout)(struct net_device *dev); | ||
512 | * Callback uses when the transmitter has not made any progress | ||
513 | * for dev->watchdog ticks. | ||
514 | * | ||
515 | * struct net_device_stats* (*get_stats)(struct net_device *dev); | ||
516 | * Called when a user wants to get the network device usage | ||
517 | * statistics. If not defined, the counters in dev->stats will | ||
518 | * be used. | ||
519 | * | ||
520 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); | ||
521 | * If device support VLAN receive accleration | ||
522 | * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called | ||
523 | * when vlan groups for the device changes. Note: grp is NULL | ||
524 | * if no vlan's groups are being used. | ||
525 | * | ||
526 | * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); | ||
527 | * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) | ||
528 | * this function is called when a VLAN id is registered. | ||
529 | * | ||
530 | * void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); | ||
531 | * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) | ||
532 | * this function is called when a VLAN id is unregistered. | ||
533 | * | ||
534 | * void (*ndo_poll_controller)(struct net_device *dev); | ||
535 | */ | ||
536 | #define HAVE_NET_DEVICE_OPS | ||
537 | struct net_device_ops { | ||
538 | int (*ndo_init)(struct net_device *dev); | ||
539 | void (*ndo_uninit)(struct net_device *dev); | ||
540 | int (*ndo_open)(struct net_device *dev); | ||
541 | int (*ndo_stop)(struct net_device *dev); | ||
542 | int (*ndo_start_xmit) (struct sk_buff *skb, | ||
543 | struct net_device *dev); | ||
544 | u16 (*ndo_select_queue)(struct net_device *dev, | ||
545 | struct sk_buff *skb); | ||
546 | #define HAVE_CHANGE_RX_FLAGS | ||
547 | void (*ndo_change_rx_flags)(struct net_device *dev, | ||
548 | int flags); | ||
549 | #define HAVE_SET_RX_MODE | ||
550 | void (*ndo_set_rx_mode)(struct net_device *dev); | ||
551 | #define HAVE_MULTICAST | ||
552 | void (*ndo_set_multicast_list)(struct net_device *dev); | ||
553 | #define HAVE_SET_MAC_ADDR | ||
554 | int (*ndo_set_mac_address)(struct net_device *dev, | ||
555 | void *addr); | ||
556 | #define HAVE_VALIDATE_ADDR | ||
557 | int (*ndo_validate_addr)(struct net_device *dev); | ||
558 | #define HAVE_PRIVATE_IOCTL | ||
559 | int (*ndo_do_ioctl)(struct net_device *dev, | ||
560 | struct ifreq *ifr, int cmd); | ||
561 | #define HAVE_SET_CONFIG | ||
562 | int (*ndo_set_config)(struct net_device *dev, | ||
563 | struct ifmap *map); | ||
564 | #define HAVE_CHANGE_MTU | ||
565 | int (*ndo_change_mtu)(struct net_device *dev, | ||
566 | int new_mtu); | ||
567 | int (*ndo_neigh_setup)(struct net_device *dev, | ||
568 | struct neigh_parms *); | ||
569 | #define HAVE_TX_TIMEOUT | ||
570 | void (*ndo_tx_timeout) (struct net_device *dev); | ||
571 | |||
572 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); | ||
573 | |||
574 | void (*ndo_vlan_rx_register)(struct net_device *dev, | ||
575 | struct vlan_group *grp); | ||
576 | void (*ndo_vlan_rx_add_vid)(struct net_device *dev, | ||
577 | unsigned short vid); | ||
578 | void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, | ||
579 | unsigned short vid); | ||
580 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
581 | #define HAVE_NETDEV_POLL | ||
582 | void (*ndo_poll_controller)(struct net_device *dev); | ||
583 | #endif | ||
584 | }; | ||
585 | |||
454 | /* | 586 | /* |
455 | * The DEVICE structure. | 587 | * The DEVICE structure. |
456 | * Actually, this whole structure is a big mistake. It mixes I/O | 588 | * Actually, this whole structure is a big mistake. It mixes I/O |
@@ -495,14 +627,7 @@ struct net_device | |||
495 | unsigned long state; | 627 | unsigned long state; |
496 | 628 | ||
497 | struct list_head dev_list; | 629 | struct list_head dev_list; |
498 | #ifdef CONFIG_NETPOLL | ||
499 | struct list_head napi_list; | 630 | struct list_head napi_list; |
500 | #endif | ||
501 | |||
502 | /* The device initialization function. Called only once. */ | ||
503 | int (*init)(struct net_device *dev); | ||
504 | |||
505 | /* ------- Fields preinitialized in Space.c finish here ------- */ | ||
506 | 631 | ||
507 | /* Net device features */ | 632 | /* Net device features */ |
508 | unsigned long features; | 633 | unsigned long features; |
@@ -521,6 +646,7 @@ struct net_device | |||
521 | #define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */ | 646 | #define NETIF_F_LLTX 4096 /* LockLess TX - deprecated. Please */ |
522 | /* do not use LLTX in new drivers */ | 647 | /* do not use LLTX in new drivers */ |
523 | #define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */ | 648 | #define NETIF_F_NETNS_LOCAL 8192 /* Does not change network namespaces */ |
649 | #define NETIF_F_GRO 16384 /* Generic receive offload */ | ||
524 | #define NETIF_F_LRO 32768 /* large receive offload */ | 650 | #define NETIF_F_LRO 32768 /* large receive offload */ |
525 | 651 | ||
526 | /* Segmentation offload features */ | 652 | /* Segmentation offload features */ |
@@ -546,15 +672,13 @@ struct net_device | |||
546 | * for all in netdev_increment_features. | 672 | * for all in netdev_increment_features. |
547 | */ | 673 | */ |
548 | #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ | 674 | #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ |
549 | NETIF_F_SG | NETIF_F_HIGHDMA | \ | 675 | NETIF_F_SG | NETIF_F_HIGHDMA | \ |
550 | NETIF_F_FRAGLIST) | 676 | NETIF_F_FRAGLIST) |
551 | 677 | ||
552 | /* Interface index. Unique device identifier */ | 678 | /* Interface index. Unique device identifier */ |
553 | int ifindex; | 679 | int ifindex; |
554 | int iflink; | 680 | int iflink; |
555 | 681 | ||
556 | |||
557 | struct net_device_stats* (*get_stats)(struct net_device *dev); | ||
558 | struct net_device_stats stats; | 682 | struct net_device_stats stats; |
559 | 683 | ||
560 | #ifdef CONFIG_WIRELESS_EXT | 684 | #ifdef CONFIG_WIRELESS_EXT |
@@ -564,18 +688,13 @@ struct net_device | |||
564 | /* Instance data managed by the core of Wireless Extensions. */ | 688 | /* Instance data managed by the core of Wireless Extensions. */ |
565 | struct iw_public_data * wireless_data; | 689 | struct iw_public_data * wireless_data; |
566 | #endif | 690 | #endif |
691 | /* Management operations */ | ||
692 | const struct net_device_ops *netdev_ops; | ||
567 | const struct ethtool_ops *ethtool_ops; | 693 | const struct ethtool_ops *ethtool_ops; |
568 | 694 | ||
569 | /* Hardware header description */ | 695 | /* Hardware header description */ |
570 | const struct header_ops *header_ops; | 696 | const struct header_ops *header_ops; |
571 | 697 | ||
572 | /* | ||
573 | * This marks the end of the "visible" part of the structure. All | ||
574 | * fields hereafter are internal to the system, and may change at | ||
575 | * will (read: may be cleaned up at will). | ||
576 | */ | ||
577 | |||
578 | |||
579 | unsigned int flags; /* interface flags (a la BSD) */ | 698 | unsigned int flags; /* interface flags (a la BSD) */ |
580 | unsigned short gflags; | 699 | unsigned short gflags; |
581 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ | 700 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ |
@@ -634,7 +753,7 @@ struct net_device | |||
634 | unsigned long last_rx; /* Time of last Rx */ | 753 | unsigned long last_rx; /* Time of last Rx */ |
635 | /* Interface address info used in eth_type_trans() */ | 754 | /* Interface address info used in eth_type_trans() */ |
636 | unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast | 755 | unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address, (before bcast |
637 | because most packets are unicast) */ | 756 | because most packets are unicast) */ |
638 | 757 | ||
639 | unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ | 758 | unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ |
640 | 759 | ||
@@ -653,18 +772,12 @@ struct net_device | |||
653 | /* | 772 | /* |
654 | * One part is mostly used on xmit path (device) | 773 | * One part is mostly used on xmit path (device) |
655 | */ | 774 | */ |
656 | void *priv; /* pointer to private data */ | ||
657 | int (*hard_start_xmit) (struct sk_buff *skb, | ||
658 | struct net_device *dev); | ||
659 | /* These may be needed for future network-power-down code. */ | 775 | /* These may be needed for future network-power-down code. */ |
660 | unsigned long trans_start; /* Time (in jiffies) of last Tx */ | 776 | unsigned long trans_start; /* Time (in jiffies) of last Tx */ |
661 | 777 | ||
662 | int watchdog_timeo; /* used by dev_watchdog() */ | 778 | int watchdog_timeo; /* used by dev_watchdog() */ |
663 | struct timer_list watchdog_timer; | 779 | struct timer_list watchdog_timer; |
664 | 780 | ||
665 | /* | ||
666 | * refcnt is a very hot point, so align it on SMP | ||
667 | */ | ||
668 | /* Number of references to this device */ | 781 | /* Number of references to this device */ |
669 | atomic_t refcnt ____cacheline_aligned_in_smp; | 782 | atomic_t refcnt ____cacheline_aligned_in_smp; |
670 | 783 | ||
@@ -683,56 +796,12 @@ struct net_device | |||
683 | NETREG_RELEASED, /* called free_netdev */ | 796 | NETREG_RELEASED, /* called free_netdev */ |
684 | } reg_state; | 797 | } reg_state; |
685 | 798 | ||
686 | /* Called after device is detached from network. */ | 799 | /* Called from unregister, can be used to call free_netdev */ |
687 | void (*uninit)(struct net_device *dev); | 800 | void (*destructor)(struct net_device *dev); |
688 | /* Called after last user reference disappears. */ | ||
689 | void (*destructor)(struct net_device *dev); | ||
690 | 801 | ||
691 | /* Pointers to interface service routines. */ | ||
692 | int (*open)(struct net_device *dev); | ||
693 | int (*stop)(struct net_device *dev); | ||
694 | #define HAVE_NETDEV_POLL | ||
695 | #define HAVE_CHANGE_RX_FLAGS | ||
696 | void (*change_rx_flags)(struct net_device *dev, | ||
697 | int flags); | ||
698 | #define HAVE_SET_RX_MODE | ||
699 | void (*set_rx_mode)(struct net_device *dev); | ||
700 | #define HAVE_MULTICAST | ||
701 | void (*set_multicast_list)(struct net_device *dev); | ||
702 | #define HAVE_SET_MAC_ADDR | ||
703 | int (*set_mac_address)(struct net_device *dev, | ||
704 | void *addr); | ||
705 | #define HAVE_VALIDATE_ADDR | ||
706 | int (*validate_addr)(struct net_device *dev); | ||
707 | #define HAVE_PRIVATE_IOCTL | ||
708 | int (*do_ioctl)(struct net_device *dev, | ||
709 | struct ifreq *ifr, int cmd); | ||
710 | #define HAVE_SET_CONFIG | ||
711 | int (*set_config)(struct net_device *dev, | ||
712 | struct ifmap *map); | ||
713 | #define HAVE_CHANGE_MTU | ||
714 | int (*change_mtu)(struct net_device *dev, int new_mtu); | ||
715 | |||
716 | #define HAVE_TX_TIMEOUT | ||
717 | void (*tx_timeout) (struct net_device *dev); | ||
718 | |||
719 | void (*vlan_rx_register)(struct net_device *dev, | ||
720 | struct vlan_group *grp); | ||
721 | void (*vlan_rx_add_vid)(struct net_device *dev, | ||
722 | unsigned short vid); | ||
723 | void (*vlan_rx_kill_vid)(struct net_device *dev, | ||
724 | unsigned short vid); | ||
725 | |||
726 | int (*neigh_setup)(struct net_device *dev, struct neigh_parms *); | ||
727 | #ifdef CONFIG_NETPOLL | 802 | #ifdef CONFIG_NETPOLL |
728 | struct netpoll_info *npinfo; | 803 | struct netpoll_info *npinfo; |
729 | #endif | 804 | #endif |
730 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
731 | void (*poll_controller)(struct net_device *dev); | ||
732 | #endif | ||
733 | |||
734 | u16 (*select_queue)(struct net_device *dev, | ||
735 | struct sk_buff *skb); | ||
736 | 805 | ||
737 | #ifdef CONFIG_NET_NS | 806 | #ifdef CONFIG_NET_NS |
738 | /* Network namespace this network device is inside */ | 807 | /* Network namespace this network device is inside */ |
@@ -763,6 +832,49 @@ struct net_device | |||
763 | /* for setting kernel sock attribute on TCP connection setup */ | 832 | /* for setting kernel sock attribute on TCP connection setup */ |
764 | #define GSO_MAX_SIZE 65536 | 833 | #define GSO_MAX_SIZE 65536 |
765 | unsigned int gso_max_size; | 834 | unsigned int gso_max_size; |
835 | |||
836 | #ifdef CONFIG_DCB | ||
837 | /* Data Center Bridging netlink ops */ | ||
838 | struct dcbnl_rtnl_ops *dcbnl_ops; | ||
839 | #endif | ||
840 | |||
841 | #ifdef CONFIG_COMPAT_NET_DEV_OPS | ||
842 | struct { | ||
843 | int (*init)(struct net_device *dev); | ||
844 | void (*uninit)(struct net_device *dev); | ||
845 | int (*open)(struct net_device *dev); | ||
846 | int (*stop)(struct net_device *dev); | ||
847 | int (*hard_start_xmit) (struct sk_buff *skb, | ||
848 | struct net_device *dev); | ||
849 | u16 (*select_queue)(struct net_device *dev, | ||
850 | struct sk_buff *skb); | ||
851 | void (*change_rx_flags)(struct net_device *dev, | ||
852 | int flags); | ||
853 | void (*set_rx_mode)(struct net_device *dev); | ||
854 | void (*set_multicast_list)(struct net_device *dev); | ||
855 | int (*set_mac_address)(struct net_device *dev, | ||
856 | void *addr); | ||
857 | int (*validate_addr)(struct net_device *dev); | ||
858 | int (*do_ioctl)(struct net_device *dev, | ||
859 | struct ifreq *ifr, int cmd); | ||
860 | int (*set_config)(struct net_device *dev, | ||
861 | struct ifmap *map); | ||
862 | int (*change_mtu)(struct net_device *dev, int new_mtu); | ||
863 | int (*neigh_setup)(struct net_device *dev, | ||
864 | struct neigh_parms *); | ||
865 | void (*tx_timeout) (struct net_device *dev); | ||
866 | struct net_device_stats* (*get_stats)(struct net_device *dev); | ||
867 | void (*vlan_rx_register)(struct net_device *dev, | ||
868 | struct vlan_group *grp); | ||
869 | void (*vlan_rx_add_vid)(struct net_device *dev, | ||
870 | unsigned short vid); | ||
871 | void (*vlan_rx_kill_vid)(struct net_device *dev, | ||
872 | unsigned short vid); | ||
873 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
874 | void (*poll_controller)(struct net_device *dev); | ||
875 | #endif | ||
876 | }; | ||
877 | #endif | ||
766 | }; | 878 | }; |
767 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 879 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
768 | 880 | ||
@@ -858,22 +970,8 @@ static inline void *netdev_priv(const struct net_device *dev) | |||
858 | * netif_napi_add() must be used to initialize a napi context prior to calling | 970 | * netif_napi_add() must be used to initialize a napi context prior to calling |
859 | * *any* of the other napi related functions. | 971 | * *any* of the other napi related functions. |
860 | */ | 972 | */ |
861 | static inline void netif_napi_add(struct net_device *dev, | 973 | void netif_napi_add(struct net_device *dev, struct napi_struct *napi, |
862 | struct napi_struct *napi, | 974 | int (*poll)(struct napi_struct *, int), int weight); |
863 | int (*poll)(struct napi_struct *, int), | ||
864 | int weight) | ||
865 | { | ||
866 | INIT_LIST_HEAD(&napi->poll_list); | ||
867 | napi->poll = poll; | ||
868 | napi->weight = weight; | ||
869 | #ifdef CONFIG_NETPOLL | ||
870 | napi->dev = dev; | ||
871 | list_add(&napi->dev_list, &dev->napi_list); | ||
872 | spin_lock_init(&napi->poll_lock); | ||
873 | napi->poll_owner = -1; | ||
874 | #endif | ||
875 | set_bit(NAPI_STATE_SCHED, &napi->state); | ||
876 | } | ||
877 | 975 | ||
878 | /** | 976 | /** |
879 | * netif_napi_del - remove a napi context | 977 | * netif_napi_del - remove a napi context |
@@ -881,12 +979,20 @@ static inline void netif_napi_add(struct net_device *dev, | |||
881 | * | 979 | * |
882 | * netif_napi_del() removes a napi context from the network device napi list | 980 | * netif_napi_del() removes a napi context from the network device napi list |
883 | */ | 981 | */ |
884 | static inline void netif_napi_del(struct napi_struct *napi) | 982 | void netif_napi_del(struct napi_struct *napi); |
885 | { | 983 | |
886 | #ifdef CONFIG_NETPOLL | 984 | struct napi_gro_cb { |
887 | list_del(&napi->dev_list); | 985 | /* This is non-zero if the packet may be of the same flow. */ |
888 | #endif | 986 | int same_flow; |
889 | } | 987 | |
988 | /* This is non-zero if the packet cannot be merged with the new skb. */ | ||
989 | int flush; | ||
990 | |||
991 | /* Number of segments aggregated. */ | ||
992 | int count; | ||
993 | }; | ||
994 | |||
995 | #define NAPI_GRO_CB(skb) ((struct napi_gro_cb *)(skb)->cb) | ||
890 | 996 | ||
891 | struct packet_type { | 997 | struct packet_type { |
892 | __be16 type; /* This is really htons(ether_type). */ | 998 | __be16 type; /* This is really htons(ether_type). */ |
@@ -898,6 +1004,9 @@ struct packet_type { | |||
898 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 1004 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
899 | int features); | 1005 | int features); |
900 | int (*gso_send_check)(struct sk_buff *skb); | 1006 | int (*gso_send_check)(struct sk_buff *skb); |
1007 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | ||
1008 | struct sk_buff *skb); | ||
1009 | int (*gro_complete)(struct sk_buff *skb); | ||
901 | void *af_packet_priv; | 1010 | void *af_packet_priv; |
902 | struct list_head list; | 1011 | struct list_head list; |
903 | }; | 1012 | }; |
@@ -1251,6 +1360,9 @@ extern int netif_rx(struct sk_buff *skb); | |||
1251 | extern int netif_rx_ni(struct sk_buff *skb); | 1360 | extern int netif_rx_ni(struct sk_buff *skb); |
1252 | #define HAVE_NETIF_RECEIVE_SKB 1 | 1361 | #define HAVE_NETIF_RECEIVE_SKB 1 |
1253 | extern int netif_receive_skb(struct sk_buff *skb); | 1362 | extern int netif_receive_skb(struct sk_buff *skb); |
1363 | extern void napi_gro_flush(struct napi_struct *napi); | ||
1364 | extern int napi_gro_receive(struct napi_struct *napi, | ||
1365 | struct sk_buff *skb); | ||
1254 | extern void netif_nit_deliver(struct sk_buff *skb); | 1366 | extern void netif_nit_deliver(struct sk_buff *skb); |
1255 | extern int dev_valid_name(const char *name); | 1367 | extern int dev_valid_name(const char *name); |
1256 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); | 1368 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); |
@@ -1443,8 +1555,7 @@ static inline u32 netif_msg_init(int debug_value, int default_msg_enable_bits) | |||
1443 | } | 1555 | } |
1444 | 1556 | ||
1445 | /* Test if receive needs to be scheduled but only if up */ | 1557 | /* Test if receive needs to be scheduled but only if up */ |
1446 | static inline int netif_rx_schedule_prep(struct net_device *dev, | 1558 | static inline int netif_rx_schedule_prep(struct napi_struct *napi) |
1447 | struct napi_struct *napi) | ||
1448 | { | 1559 | { |
1449 | return napi_schedule_prep(napi); | 1560 | return napi_schedule_prep(napi); |
1450 | } | 1561 | } |
@@ -1452,27 +1563,24 @@ static inline int netif_rx_schedule_prep(struct net_device *dev, | |||
1452 | /* Add interface to tail of rx poll list. This assumes that _prep has | 1563 | /* Add interface to tail of rx poll list. This assumes that _prep has |
1453 | * already been called and returned 1. | 1564 | * already been called and returned 1. |
1454 | */ | 1565 | */ |
1455 | static inline void __netif_rx_schedule(struct net_device *dev, | 1566 | static inline void __netif_rx_schedule(struct napi_struct *napi) |
1456 | struct napi_struct *napi) | ||
1457 | { | 1567 | { |
1458 | __napi_schedule(napi); | 1568 | __napi_schedule(napi); |
1459 | } | 1569 | } |
1460 | 1570 | ||
1461 | /* Try to reschedule poll. Called by irq handler. */ | 1571 | /* Try to reschedule poll. Called by irq handler. */ |
1462 | 1572 | ||
1463 | static inline void netif_rx_schedule(struct net_device *dev, | 1573 | static inline void netif_rx_schedule(struct napi_struct *napi) |
1464 | struct napi_struct *napi) | ||
1465 | { | 1574 | { |
1466 | if (netif_rx_schedule_prep(dev, napi)) | 1575 | if (netif_rx_schedule_prep(napi)) |
1467 | __netif_rx_schedule(dev, napi); | 1576 | __netif_rx_schedule(napi); |
1468 | } | 1577 | } |
1469 | 1578 | ||
1470 | /* Try to reschedule poll. Called by dev->poll() after netif_rx_complete(). */ | 1579 | /* Try to reschedule poll. Called by dev->poll() after netif_rx_complete(). */ |
1471 | static inline int netif_rx_reschedule(struct net_device *dev, | 1580 | static inline int netif_rx_reschedule(struct napi_struct *napi) |
1472 | struct napi_struct *napi) | ||
1473 | { | 1581 | { |
1474 | if (napi_schedule_prep(napi)) { | 1582 | if (napi_schedule_prep(napi)) { |
1475 | __netif_rx_schedule(dev, napi); | 1583 | __netif_rx_schedule(napi); |
1476 | return 1; | 1584 | return 1; |
1477 | } | 1585 | } |
1478 | return 0; | 1586 | return 0; |
@@ -1481,8 +1589,7 @@ static inline int netif_rx_reschedule(struct net_device *dev, | |||
1481 | /* same as netif_rx_complete, except that local_irq_save(flags) | 1589 | /* same as netif_rx_complete, except that local_irq_save(flags) |
1482 | * has already been issued | 1590 | * has already been issued |
1483 | */ | 1591 | */ |
1484 | static inline void __netif_rx_complete(struct net_device *dev, | 1592 | static inline void __netif_rx_complete(struct napi_struct *napi) |
1485 | struct napi_struct *napi) | ||
1486 | { | 1593 | { |
1487 | __napi_complete(napi); | 1594 | __napi_complete(napi); |
1488 | } | 1595 | } |
@@ -1492,14 +1599,9 @@ static inline void __netif_rx_complete(struct net_device *dev, | |||
1492 | * it completes the work. The device cannot be out of poll list at this | 1599 | * it completes the work. The device cannot be out of poll list at this |
1493 | * moment, it is BUG(). | 1600 | * moment, it is BUG(). |
1494 | */ | 1601 | */ |
1495 | static inline void netif_rx_complete(struct net_device *dev, | 1602 | static inline void netif_rx_complete(struct napi_struct *napi) |
1496 | struct napi_struct *napi) | ||
1497 | { | 1603 | { |
1498 | unsigned long flags; | 1604 | napi_complete(napi); |
1499 | |||
1500 | local_irq_save(flags); | ||
1501 | __netif_rx_complete(dev, napi); | ||
1502 | local_irq_restore(flags); | ||
1503 | } | 1605 | } |
1504 | 1606 | ||
1505 | static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu) | 1607 | static inline void __netif_tx_lock(struct netdev_queue *txq, int cpu) |
@@ -1676,6 +1778,8 @@ extern void netdev_features_change(struct net_device *dev); | |||
1676 | /* Load a device via the kmod */ | 1778 | /* Load a device via the kmod */ |
1677 | extern void dev_load(struct net *net, const char *name); | 1779 | extern void dev_load(struct net *net, const char *name); |
1678 | extern void dev_mcast_init(void); | 1780 | extern void dev_mcast_init(void); |
1781 | extern const struct net_device_stats *dev_get_stats(struct net_device *dev); | ||
1782 | |||
1679 | extern int netdev_max_backlog; | 1783 | extern int netdev_max_backlog; |
1680 | extern int weight_p; | 1784 | extern int weight_p; |
1681 | extern int netdev_set_master(struct net_device *dev, struct net_device *master); | 1785 | extern int netdev_set_master(struct net_device *dev, struct net_device *master); |
@@ -1724,6 +1828,8 @@ static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb) | |||
1724 | { | 1828 | { |
1725 | return skb_is_gso(skb) && | 1829 | return skb_is_gso(skb) && |
1726 | (!skb_gso_ok(skb, dev->features) || | 1830 | (!skb_gso_ok(skb, dev->features) || |
1831 | (skb_shinfo(skb)->frag_list && | ||
1832 | !(dev->features & NETIF_F_FRAGLIST)) || | ||
1727 | unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); | 1833 | unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); |
1728 | } | 1834 | } |
1729 | 1835 | ||
@@ -1742,26 +1848,31 @@ static inline int skb_bond_should_drop(struct sk_buff *skb) | |||
1742 | struct net_device *dev = skb->dev; | 1848 | struct net_device *dev = skb->dev; |
1743 | struct net_device *master = dev->master; | 1849 | struct net_device *master = dev->master; |
1744 | 1850 | ||
1745 | if (master && | 1851 | if (master) { |
1746 | (dev->priv_flags & IFF_SLAVE_INACTIVE)) { | 1852 | if (master->priv_flags & IFF_MASTER_ARPMON) |
1747 | if ((dev->priv_flags & IFF_SLAVE_NEEDARP) && | 1853 | dev->last_rx = jiffies; |
1748 | skb->protocol == __constant_htons(ETH_P_ARP)) | ||
1749 | return 0; | ||
1750 | 1854 | ||
1751 | if (master->priv_flags & IFF_MASTER_ALB) { | 1855 | if (dev->priv_flags & IFF_SLAVE_INACTIVE) { |
1752 | if (skb->pkt_type != PACKET_BROADCAST && | 1856 | if ((dev->priv_flags & IFF_SLAVE_NEEDARP) && |
1753 | skb->pkt_type != PACKET_MULTICAST) | 1857 | skb->protocol == __constant_htons(ETH_P_ARP)) |
1754 | return 0; | 1858 | return 0; |
1755 | } | ||
1756 | if (master->priv_flags & IFF_MASTER_8023AD && | ||
1757 | skb->protocol == __constant_htons(ETH_P_SLOW)) | ||
1758 | return 0; | ||
1759 | 1859 | ||
1760 | return 1; | 1860 | if (master->priv_flags & IFF_MASTER_ALB) { |
1861 | if (skb->pkt_type != PACKET_BROADCAST && | ||
1862 | skb->pkt_type != PACKET_MULTICAST) | ||
1863 | return 0; | ||
1864 | } | ||
1865 | if (master->priv_flags & IFF_MASTER_8023AD && | ||
1866 | skb->protocol == __constant_htons(ETH_P_SLOW)) | ||
1867 | return 0; | ||
1868 | |||
1869 | return 1; | ||
1870 | } | ||
1761 | } | 1871 | } |
1762 | return 0; | 1872 | return 0; |
1763 | } | 1873 | } |
1764 | 1874 | ||
1875 | extern struct pernet_operations __net_initdata loopback_net_ops; | ||
1765 | #endif /* __KERNEL__ */ | 1876 | #endif /* __KERNEL__ */ |
1766 | 1877 | ||
1767 | #endif /* _LINUX_DEV_H */ | 1878 | #endif /* _LINUX_DEV_H */ |