diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /include/linux/netdevice.h | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 561 |
1 files changed, 470 insertions, 91 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 46c36ffe20ee..9e19477991ad 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -138,6 +138,9 @@ static inline bool dev_xmit_complete(int rc) | |||
138 | 138 | ||
139 | #define MAX_ADDR_LEN 32 /* Largest hardware address length */ | 139 | #define MAX_ADDR_LEN 32 /* Largest hardware address length */ |
140 | 140 | ||
141 | /* Initial net device group. All devices belong to group 0 by default. */ | ||
142 | #define INIT_NETDEV_GROUP 0 | ||
143 | |||
141 | #ifdef __KERNEL__ | 144 | #ifdef __KERNEL__ |
142 | /* | 145 | /* |
143 | * Compute the worst case header length according to the protocols | 146 | * Compute the worst case header length according to the protocols |
@@ -228,9 +231,9 @@ struct netdev_hw_addr { | |||
228 | #define NETDEV_HW_ADDR_T_SLAVE 3 | 231 | #define NETDEV_HW_ADDR_T_SLAVE 3 |
229 | #define NETDEV_HW_ADDR_T_UNICAST 4 | 232 | #define NETDEV_HW_ADDR_T_UNICAST 4 |
230 | #define NETDEV_HW_ADDR_T_MULTICAST 5 | 233 | #define NETDEV_HW_ADDR_T_MULTICAST 5 |
231 | int refcount; | ||
232 | bool synced; | 234 | bool synced; |
233 | bool global_use; | 235 | bool global_use; |
236 | int refcount; | ||
234 | struct rcu_head rcu_head; | 237 | struct rcu_head rcu_head; |
235 | }; | 238 | }; |
236 | 239 | ||
@@ -281,6 +284,12 @@ struct hh_cache { | |||
281 | unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; | 284 | unsigned long hh_data[HH_DATA_ALIGN(LL_MAX_HEADER) / sizeof(long)]; |
282 | }; | 285 | }; |
283 | 286 | ||
287 | static inline void hh_cache_put(struct hh_cache *hh) | ||
288 | { | ||
289 | if (atomic_dec_and_test(&hh->hh_refcnt)) | ||
290 | kfree(hh); | ||
291 | } | ||
292 | |||
284 | /* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much. | 293 | /* Reserve HH_DATA_MOD byte aligned hard_header_len, but at least that much. |
285 | * Alternative is: | 294 | * Alternative is: |
286 | * dev->hard_header_len ? (dev->hard_header_len + | 295 | * dev->hard_header_len ? (dev->hard_header_len + |
@@ -381,7 +390,55 @@ enum gro_result { | |||
381 | }; | 390 | }; |
382 | typedef enum gro_result gro_result_t; | 391 | typedef enum gro_result gro_result_t; |
383 | 392 | ||
384 | typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); | 393 | /* |
394 | * enum rx_handler_result - Possible return values for rx_handlers. | ||
395 | * @RX_HANDLER_CONSUMED: skb was consumed by rx_handler, do not process it | ||
396 | * further. | ||
397 | * @RX_HANDLER_ANOTHER: Do another round in receive path. This is indicated in | ||
398 | * case skb->dev was changed by rx_handler. | ||
399 | * @RX_HANDLER_EXACT: Force exact delivery, no wildcard. | ||
400 | * @RX_HANDLER_PASS: Do nothing, passe the skb as if no rx_handler was called. | ||
401 | * | ||
402 | * rx_handlers are functions called from inside __netif_receive_skb(), to do | ||
403 | * special processing of the skb, prior to delivery to protocol handlers. | ||
404 | * | ||
405 | * Currently, a net_device can only have a single rx_handler registered. Trying | ||
406 | * to register a second rx_handler will return -EBUSY. | ||
407 | * | ||
408 | * To register a rx_handler on a net_device, use netdev_rx_handler_register(). | ||
409 | * To unregister a rx_handler on a net_device, use | ||
410 | * netdev_rx_handler_unregister(). | ||
411 | * | ||
412 | * Upon return, rx_handler is expected to tell __netif_receive_skb() what to | ||
413 | * do with the skb. | ||
414 | * | ||
415 | * If the rx_handler consumed to skb in some way, it should return | ||
416 | * RX_HANDLER_CONSUMED. This is appropriate when the rx_handler arranged for | ||
417 | * the skb to be delivered in some other ways. | ||
418 | * | ||
419 | * If the rx_handler changed skb->dev, to divert the skb to another | ||
420 | * net_device, it should return RX_HANDLER_ANOTHER. The rx_handler for the | ||
421 | * new device will be called if it exists. | ||
422 | * | ||
423 | * If the rx_handler consider the skb should be ignored, it should return | ||
424 | * RX_HANDLER_EXACT. The skb will only be delivered to protocol handlers that | ||
425 | * are registred on exact device (ptype->dev == skb->dev). | ||
426 | * | ||
427 | * If the rx_handler didn't changed skb->dev, but want the skb to be normally | ||
428 | * delivered, it should return RX_HANDLER_PASS. | ||
429 | * | ||
430 | * A device without a registered rx_handler will behave as if rx_handler | ||
431 | * returned RX_HANDLER_PASS. | ||
432 | */ | ||
433 | |||
434 | enum rx_handler_result { | ||
435 | RX_HANDLER_CONSUMED, | ||
436 | RX_HANDLER_ANOTHER, | ||
437 | RX_HANDLER_EXACT, | ||
438 | RX_HANDLER_PASS, | ||
439 | }; | ||
440 | typedef enum rx_handler_result rx_handler_result_t; | ||
441 | typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb); | ||
385 | 442 | ||
386 | extern void __napi_schedule(struct napi_struct *n); | 443 | extern void __napi_schedule(struct napi_struct *n); |
387 | 444 | ||
@@ -487,6 +544,8 @@ static inline void napi_synchronize(const struct napi_struct *n) | |||
487 | enum netdev_queue_state_t { | 544 | enum netdev_queue_state_t { |
488 | __QUEUE_STATE_XOFF, | 545 | __QUEUE_STATE_XOFF, |
489 | __QUEUE_STATE_FROZEN, | 546 | __QUEUE_STATE_FROZEN, |
547 | #define QUEUE_STATE_XOFF_OR_FROZEN ((1 << __QUEUE_STATE_XOFF) | \ | ||
548 | (1 << __QUEUE_STATE_FROZEN)) | ||
490 | }; | 549 | }; |
491 | 550 | ||
492 | struct netdev_queue { | 551 | struct netdev_queue { |
@@ -497,6 +556,12 @@ struct netdev_queue { | |||
497 | struct Qdisc *qdisc; | 556 | struct Qdisc *qdisc; |
498 | unsigned long state; | 557 | unsigned long state; |
499 | struct Qdisc *qdisc_sleeping; | 558 | struct Qdisc *qdisc_sleeping; |
559 | #ifdef CONFIG_RPS | ||
560 | struct kobject kobj; | ||
561 | #endif | ||
562 | #if defined(CONFIG_XPS) && defined(CONFIG_NUMA) | ||
563 | int numa_node; | ||
564 | #endif | ||
500 | /* | 565 | /* |
501 | * write mostly part | 566 | * write mostly part |
502 | */ | 567 | */ |
@@ -506,11 +571,24 @@ struct netdev_queue { | |||
506 | * please use this field instead of dev->trans_start | 571 | * please use this field instead of dev->trans_start |
507 | */ | 572 | */ |
508 | unsigned long trans_start; | 573 | unsigned long trans_start; |
509 | u64 tx_bytes; | ||
510 | u64 tx_packets; | ||
511 | u64 tx_dropped; | ||
512 | } ____cacheline_aligned_in_smp; | 574 | } ____cacheline_aligned_in_smp; |
513 | 575 | ||
576 | static inline int netdev_queue_numa_node_read(const struct netdev_queue *q) | ||
577 | { | ||
578 | #if defined(CONFIG_XPS) && defined(CONFIG_NUMA) | ||
579 | return q->numa_node; | ||
580 | #else | ||
581 | return NUMA_NO_NODE; | ||
582 | #endif | ||
583 | } | ||
584 | |||
585 | static inline void netdev_queue_numa_node_write(struct netdev_queue *q, int node) | ||
586 | { | ||
587 | #if defined(CONFIG_XPS) && defined(CONFIG_NUMA) | ||
588 | q->numa_node = node; | ||
589 | #endif | ||
590 | } | ||
591 | |||
514 | #ifdef CONFIG_RPS | 592 | #ifdef CONFIG_RPS |
515 | /* | 593 | /* |
516 | * This structure holds an RPS map which can be of variable length. The | 594 | * This structure holds an RPS map which can be of variable length. The |
@@ -524,14 +602,16 @@ struct rps_map { | |||
524 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) | 602 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) |
525 | 603 | ||
526 | /* | 604 | /* |
527 | * The rps_dev_flow structure contains the mapping of a flow to a CPU and the | 605 | * The rps_dev_flow structure contains the mapping of a flow to a CPU, the |
528 | * tail pointer for that CPU's input queue at the time of last enqueue. | 606 | * tail pointer for that CPU's input queue at the time of last enqueue, and |
607 | * a hardware filter index. | ||
529 | */ | 608 | */ |
530 | struct rps_dev_flow { | 609 | struct rps_dev_flow { |
531 | u16 cpu; | 610 | u16 cpu; |
532 | u16 fill; | 611 | u16 filter; |
533 | unsigned int last_qtail; | 612 | unsigned int last_qtail; |
534 | }; | 613 | }; |
614 | #define RPS_NO_FILTER 0xffff | ||
535 | 615 | ||
536 | /* | 616 | /* |
537 | * The rps_dev_flow_table structure contains a table of flow mappings. | 617 | * The rps_dev_flow_table structure contains a table of flow mappings. |
@@ -579,18 +659,56 @@ static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table, | |||
579 | table->ents[hash & table->mask] = RPS_NO_CPU; | 659 | table->ents[hash & table->mask] = RPS_NO_CPU; |
580 | } | 660 | } |
581 | 661 | ||
582 | extern struct rps_sock_flow_table *rps_sock_flow_table; | 662 | extern struct rps_sock_flow_table __rcu *rps_sock_flow_table; |
663 | |||
664 | #ifdef CONFIG_RFS_ACCEL | ||
665 | extern bool rps_may_expire_flow(struct net_device *dev, u16 rxq_index, | ||
666 | u32 flow_id, u16 filter_id); | ||
667 | #endif | ||
583 | 668 | ||
584 | /* This structure contains an instance of an RX queue. */ | 669 | /* This structure contains an instance of an RX queue. */ |
585 | struct netdev_rx_queue { | 670 | struct netdev_rx_queue { |
586 | struct rps_map *rps_map; | 671 | struct rps_map __rcu *rps_map; |
587 | struct rps_dev_flow_table *rps_flow_table; | 672 | struct rps_dev_flow_table __rcu *rps_flow_table; |
588 | struct kobject kobj; | 673 | struct kobject kobj; |
589 | struct netdev_rx_queue *first; | 674 | struct net_device *dev; |
590 | atomic_t count; | ||
591 | } ____cacheline_aligned_in_smp; | 675 | } ____cacheline_aligned_in_smp; |
592 | #endif /* CONFIG_RPS */ | 676 | #endif /* CONFIG_RPS */ |
593 | 677 | ||
678 | #ifdef CONFIG_XPS | ||
679 | /* | ||
680 | * This structure holds an XPS map which can be of variable length. The | ||
681 | * map is an array of queues. | ||
682 | */ | ||
683 | struct xps_map { | ||
684 | unsigned int len; | ||
685 | unsigned int alloc_len; | ||
686 | struct rcu_head rcu; | ||
687 | u16 queues[0]; | ||
688 | }; | ||
689 | #define XPS_MAP_SIZE(_num) (sizeof(struct xps_map) + (_num * sizeof(u16))) | ||
690 | #define XPS_MIN_MAP_ALLOC ((L1_CACHE_BYTES - sizeof(struct xps_map)) \ | ||
691 | / sizeof(u16)) | ||
692 | |||
693 | /* | ||
694 | * This structure holds all XPS maps for device. Maps are indexed by CPU. | ||
695 | */ | ||
696 | struct xps_dev_maps { | ||
697 | struct rcu_head rcu; | ||
698 | struct xps_map __rcu *cpu_map[0]; | ||
699 | }; | ||
700 | #define XPS_DEV_MAPS_SIZE (sizeof(struct xps_dev_maps) + \ | ||
701 | (nr_cpu_ids * sizeof(struct xps_map *))) | ||
702 | #endif /* CONFIG_XPS */ | ||
703 | |||
704 | #define TC_MAX_QUEUE 16 | ||
705 | #define TC_BITMASK 15 | ||
706 | /* HW offloaded queuing disciplines txq count and offset maps */ | ||
707 | struct netdev_tc_txq { | ||
708 | u16 count; | ||
709 | u16 offset; | ||
710 | }; | ||
711 | |||
594 | /* | 712 | /* |
595 | * This structure defines the management hooks for network devices. | 713 | * This structure defines the management hooks for network devices. |
596 | * The following hooks can be defined; unless noted otherwise, they are | 714 | * The following hooks can be defined; unless noted otherwise, they are |
@@ -677,7 +795,7 @@ struct netdev_rx_queue { | |||
677 | * neither operation. | 795 | * neither operation. |
678 | * | 796 | * |
679 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); | 797 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); |
680 | * If device support VLAN receive accleration | 798 | * If device support VLAN receive acceleration |
681 | * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called | 799 | * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called |
682 | * when vlan groups for the device changes. Note: grp is NULL | 800 | * when vlan groups for the device changes. Note: grp is NULL |
683 | * if no vlan's groups are being used. | 801 | * if no vlan's groups are being used. |
@@ -701,6 +819,74 @@ struct netdev_rx_queue { | |||
701 | * int (*ndo_set_vf_port)(struct net_device *dev, int vf, | 819 | * int (*ndo_set_vf_port)(struct net_device *dev, int vf, |
702 | * struct nlattr *port[]); | 820 | * struct nlattr *port[]); |
703 | * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); | 821 | * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); |
822 | * int (*ndo_setup_tc)(struct net_device *dev, u8 tc) | ||
823 | * Called to setup 'tc' number of traffic classes in the net device. This | ||
824 | * is always called from the stack with the rtnl lock held and netif tx | ||
825 | * queues stopped. This allows the netdevice to perform queue management | ||
826 | * safely. | ||
827 | * | ||
828 | * Fiber Channel over Ethernet (FCoE) offload functions. | ||
829 | * int (*ndo_fcoe_enable)(struct net_device *dev); | ||
830 | * Called when the FCoE protocol stack wants to start using LLD for FCoE | ||
831 | * so the underlying device can perform whatever needed configuration or | ||
832 | * initialization to support acceleration of FCoE traffic. | ||
833 | * | ||
834 | * int (*ndo_fcoe_disable)(struct net_device *dev); | ||
835 | * Called when the FCoE protocol stack wants to stop using LLD for FCoE | ||
836 | * so the underlying device can perform whatever needed clean-ups to | ||
837 | * stop supporting acceleration of FCoE traffic. | ||
838 | * | ||
839 | * int (*ndo_fcoe_ddp_setup)(struct net_device *dev, u16 xid, | ||
840 | * struct scatterlist *sgl, unsigned int sgc); | ||
841 | * Called when the FCoE Initiator wants to initialize an I/O that | ||
842 | * is a possible candidate for Direct Data Placement (DDP). The LLD can | ||
843 | * perform necessary setup and returns 1 to indicate the device is set up | ||
844 | * successfully to perform DDP on this I/O, otherwise this returns 0. | ||
845 | * | ||
846 | * int (*ndo_fcoe_ddp_done)(struct net_device *dev, u16 xid); | ||
847 | * Called when the FCoE Initiator/Target is done with the DDPed I/O as | ||
848 | * indicated by the FC exchange id 'xid', so the underlying device can | ||
849 | * clean up and reuse resources for later DDP requests. | ||
850 | * | ||
851 | * int (*ndo_fcoe_ddp_target)(struct net_device *dev, u16 xid, | ||
852 | * struct scatterlist *sgl, unsigned int sgc); | ||
853 | * Called when the FCoE Target wants to initialize an I/O that | ||
854 | * is a possible candidate for Direct Data Placement (DDP). The LLD can | ||
855 | * perform necessary setup and returns 1 to indicate the device is set up | ||
856 | * successfully to perform DDP on this I/O, otherwise this returns 0. | ||
857 | * | ||
858 | * int (*ndo_fcoe_get_wwn)(struct net_device *dev, u64 *wwn, int type); | ||
859 | * Called when the underlying device wants to override default World Wide | ||
860 | * Name (WWN) generation mechanism in FCoE protocol stack to pass its own | ||
861 | * World Wide Port Name (WWPN) or World Wide Node Name (WWNN) to the FCoE | ||
862 | * protocol stack to use. | ||
863 | * | ||
864 | * RFS acceleration. | ||
865 | * int (*ndo_rx_flow_steer)(struct net_device *dev, const struct sk_buff *skb, | ||
866 | * u16 rxq_index, u32 flow_id); | ||
867 | * Set hardware filter for RFS. rxq_index is the target queue index; | ||
868 | * flow_id is a flow ID to be passed to rps_may_expire_flow() later. | ||
869 | * Return the filter ID on success, or a negative error code. | ||
870 | * | ||
871 | * Slave management functions (for bridge, bonding, etc). User should | ||
872 | * call netdev_set_master() to set dev->master properly. | ||
873 | * int (*ndo_add_slave)(struct net_device *dev, struct net_device *slave_dev); | ||
874 | * Called to make another netdev an underling. | ||
875 | * | ||
876 | * int (*ndo_del_slave)(struct net_device *dev, struct net_device *slave_dev); | ||
877 | * Called to release previously enslaved netdev. | ||
878 | * | ||
879 | * Feature/offload setting functions. | ||
880 | * u32 (*ndo_fix_features)(struct net_device *dev, u32 features); | ||
881 | * Adjusts the requested feature flags according to device-specific | ||
882 | * constraints, and returns the resulting flags. Must not modify | ||
883 | * the device state. | ||
884 | * | ||
885 | * int (*ndo_set_features)(struct net_device *dev, u32 features); | ||
886 | * Called to update device configuration to new features. Passed | ||
887 | * feature set might be less than what was returned by ndo_fix_features()). | ||
888 | * Must return >0 or -errno if it changed dev->features itself. | ||
889 | * | ||
704 | */ | 890 | */ |
705 | #define HAVE_NET_DEVICE_OPS | 891 | #define HAVE_NET_DEVICE_OPS |
706 | struct net_device_ops { | 892 | struct net_device_ops { |
@@ -759,6 +945,7 @@ struct net_device_ops { | |||
759 | struct nlattr *port[]); | 945 | struct nlattr *port[]); |
760 | int (*ndo_get_vf_port)(struct net_device *dev, | 946 | int (*ndo_get_vf_port)(struct net_device *dev, |
761 | int vf, struct sk_buff *skb); | 947 | int vf, struct sk_buff *skb); |
948 | int (*ndo_setup_tc)(struct net_device *dev, u8 tc); | ||
762 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 949 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
763 | int (*ndo_fcoe_enable)(struct net_device *dev); | 950 | int (*ndo_fcoe_enable)(struct net_device *dev); |
764 | int (*ndo_fcoe_disable)(struct net_device *dev); | 951 | int (*ndo_fcoe_disable)(struct net_device *dev); |
@@ -768,11 +955,29 @@ struct net_device_ops { | |||
768 | unsigned int sgc); | 955 | unsigned int sgc); |
769 | int (*ndo_fcoe_ddp_done)(struct net_device *dev, | 956 | int (*ndo_fcoe_ddp_done)(struct net_device *dev, |
770 | u16 xid); | 957 | u16 xid); |
958 | int (*ndo_fcoe_ddp_target)(struct net_device *dev, | ||
959 | u16 xid, | ||
960 | struct scatterlist *sgl, | ||
961 | unsigned int sgc); | ||
771 | #define NETDEV_FCOE_WWNN 0 | 962 | #define NETDEV_FCOE_WWNN 0 |
772 | #define NETDEV_FCOE_WWPN 1 | 963 | #define NETDEV_FCOE_WWPN 1 |
773 | int (*ndo_fcoe_get_wwn)(struct net_device *dev, | 964 | int (*ndo_fcoe_get_wwn)(struct net_device *dev, |
774 | u64 *wwn, int type); | 965 | u64 *wwn, int type); |
775 | #endif | 966 | #endif |
967 | #ifdef CONFIG_RFS_ACCEL | ||
968 | int (*ndo_rx_flow_steer)(struct net_device *dev, | ||
969 | const struct sk_buff *skb, | ||
970 | u16 rxq_index, | ||
971 | u32 flow_id); | ||
972 | #endif | ||
973 | int (*ndo_add_slave)(struct net_device *dev, | ||
974 | struct net_device *slave_dev); | ||
975 | int (*ndo_del_slave)(struct net_device *dev, | ||
976 | struct net_device *slave_dev); | ||
977 | u32 (*ndo_fix_features)(struct net_device *dev, | ||
978 | u32 features); | ||
979 | int (*ndo_set_features)(struct net_device *dev, | ||
980 | u32 features); | ||
776 | }; | 981 | }; |
777 | 982 | ||
778 | /* | 983 | /* |
@@ -815,17 +1020,24 @@ struct net_device { | |||
815 | * part of the usual set specified in Space.c. | 1020 | * part of the usual set specified in Space.c. |
816 | */ | 1021 | */ |
817 | 1022 | ||
818 | unsigned char if_port; /* Selectable AUI, TP,..*/ | ||
819 | unsigned char dma; /* DMA channel */ | ||
820 | |||
821 | unsigned long state; | 1023 | unsigned long state; |
822 | 1024 | ||
823 | struct list_head dev_list; | 1025 | struct list_head dev_list; |
824 | struct list_head napi_list; | 1026 | struct list_head napi_list; |
825 | struct list_head unreg_list; | 1027 | struct list_head unreg_list; |
826 | 1028 | ||
827 | /* Net device features */ | 1029 | /* currently active device features */ |
828 | unsigned long features; | 1030 | u32 features; |
1031 | /* user-changeable features */ | ||
1032 | u32 hw_features; | ||
1033 | /* user-requested features */ | ||
1034 | u32 wanted_features; | ||
1035 | /* mask of features inheritable by VLAN devices */ | ||
1036 | u32 vlan_features; | ||
1037 | |||
1038 | /* Net device feature bits; if you change something, | ||
1039 | * also update netdev_features_strings[] in ethtool.c */ | ||
1040 | |||
829 | #define NETIF_F_SG 1 /* Scatter/gather IO. */ | 1041 | #define NETIF_F_SG 1 /* Scatter/gather IO. */ |
830 | #define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */ | 1042 | #define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */ |
831 | #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ | 1043 | #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ |
@@ -850,6 +1062,9 @@ struct net_device { | |||
850 | #define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ | 1062 | #define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ |
851 | #define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */ | 1063 | #define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */ |
852 | #define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */ | 1064 | #define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */ |
1065 | #define NETIF_F_RXCSUM (1 << 29) /* Receive checksumming offload */ | ||
1066 | #define NETIF_F_NOCACHE_COPY (1 << 30) /* Use no-cache copyfromuser */ | ||
1067 | #define NETIF_F_LOOPBACK (1 << 31) /* Enable loopback */ | ||
853 | 1068 | ||
854 | /* Segmentation offload features */ | 1069 | /* Segmentation offload features */ |
855 | #define NETIF_F_GSO_SHIFT 16 | 1070 | #define NETIF_F_GSO_SHIFT 16 |
@@ -861,6 +1076,12 @@ struct net_device { | |||
861 | #define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) | 1076 | #define NETIF_F_TSO6 (SKB_GSO_TCPV6 << NETIF_F_GSO_SHIFT) |
862 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) | 1077 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) |
863 | 1078 | ||
1079 | /* Features valid for ethtool to change */ | ||
1080 | /* = all defined minus driver/device-class-related */ | ||
1081 | #define NETIF_F_NEVER_CHANGE (NETIF_F_VLAN_CHALLENGED | \ | ||
1082 | NETIF_F_LLTX | NETIF_F_NETNS_LOCAL) | ||
1083 | #define NETIF_F_ETHTOOL_BITS (0xff3fffff & ~NETIF_F_NEVER_CHANGE) | ||
1084 | |||
864 | /* List of features with software fallbacks. */ | 1085 | /* List of features with software fallbacks. */ |
865 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ | 1086 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ |
866 | NETIF_F_TSO6 | NETIF_F_UFO) | 1087 | NETIF_F_TSO6 | NETIF_F_UFO) |
@@ -871,19 +1092,35 @@ struct net_device { | |||
871 | #define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) | 1092 | #define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) |
872 | #define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) | 1093 | #define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) |
873 | 1094 | ||
1095 | #define NETIF_F_ALL_TSO (NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_TSO_ECN) | ||
1096 | |||
1097 | #define NETIF_F_ALL_FCOE (NETIF_F_FCOE_CRC | NETIF_F_FCOE_MTU | \ | ||
1098 | NETIF_F_FSO) | ||
1099 | |||
874 | /* | 1100 | /* |
875 | * If one device supports one of these features, then enable them | 1101 | * If one device supports one of these features, then enable them |
876 | * for all in netdev_increment_features. | 1102 | * for all in netdev_increment_features. |
877 | */ | 1103 | */ |
878 | #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ | 1104 | #define NETIF_F_ONE_FOR_ALL (NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ROBUST | \ |
879 | NETIF_F_SG | NETIF_F_HIGHDMA | \ | 1105 | NETIF_F_SG | NETIF_F_HIGHDMA | \ |
880 | NETIF_F_FRAGLIST) | 1106 | NETIF_F_FRAGLIST | NETIF_F_VLAN_CHALLENGED) |
1107 | /* | ||
1108 | * If one device doesn't support one of these features, then disable it | ||
1109 | * for all in netdev_increment_features. | ||
1110 | */ | ||
1111 | #define NETIF_F_ALL_FOR_ALL (NETIF_F_NOCACHE_COPY | NETIF_F_FSO) | ||
1112 | |||
1113 | /* changeable features with no special hardware requirements */ | ||
1114 | #define NETIF_F_SOFT_FEATURES (NETIF_F_GSO | NETIF_F_GRO) | ||
881 | 1115 | ||
882 | /* Interface index. Unique device identifier */ | 1116 | /* Interface index. Unique device identifier */ |
883 | int ifindex; | 1117 | int ifindex; |
884 | int iflink; | 1118 | int iflink; |
885 | 1119 | ||
886 | struct net_device_stats stats; | 1120 | struct net_device_stats stats; |
1121 | atomic_long_t rx_dropped; /* dropped packets by core network | ||
1122 | * Do not use this in drivers. | ||
1123 | */ | ||
887 | 1124 | ||
888 | #ifdef CONFIG_WIRELESS_EXT | 1125 | #ifdef CONFIG_WIRELESS_EXT |
889 | /* List of functions to handle Wireless Extensions (instead of ioctl). | 1126 | /* List of functions to handle Wireless Extensions (instead of ioctl). |
@@ -900,13 +1137,16 @@ struct net_device { | |||
900 | const struct header_ops *header_ops; | 1137 | const struct header_ops *header_ops; |
901 | 1138 | ||
902 | unsigned int flags; /* interface flags (a la BSD) */ | 1139 | unsigned int flags; /* interface flags (a la BSD) */ |
1140 | unsigned int priv_flags; /* Like 'flags' but invisible to userspace. */ | ||
903 | unsigned short gflags; | 1141 | unsigned short gflags; |
904 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ | ||
905 | unsigned short padded; /* How much padding added by alloc_netdev() */ | 1142 | unsigned short padded; /* How much padding added by alloc_netdev() */ |
906 | 1143 | ||
907 | unsigned char operstate; /* RFC2863 operstate */ | 1144 | unsigned char operstate; /* RFC2863 operstate */ |
908 | unsigned char link_mode; /* mapping policy to operstate */ | 1145 | unsigned char link_mode; /* mapping policy to operstate */ |
909 | 1146 | ||
1147 | unsigned char if_port; /* Selectable AUI, TP,..*/ | ||
1148 | unsigned char dma; /* DMA channel */ | ||
1149 | |||
910 | unsigned int mtu; /* interface MTU value */ | 1150 | unsigned int mtu; /* interface MTU value */ |
911 | unsigned short type; /* interface hardware type */ | 1151 | unsigned short type; /* interface hardware type */ |
912 | unsigned short hard_header_len; /* hardware hdr length */ | 1152 | unsigned short hard_header_len; /* hardware hdr length */ |
@@ -918,10 +1158,6 @@ struct net_device { | |||
918 | unsigned short needed_headroom; | 1158 | unsigned short needed_headroom; |
919 | unsigned short needed_tailroom; | 1159 | unsigned short needed_tailroom; |
920 | 1160 | ||
921 | struct net_device *master; /* Pointer to master device of a group, | ||
922 | * which this device is member of. | ||
923 | */ | ||
924 | |||
925 | /* Interface address info. */ | 1161 | /* Interface address info. */ |
926 | unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ | 1162 | unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ |
927 | unsigned char addr_assign_type; /* hw address assignment type */ | 1163 | unsigned char addr_assign_type; /* hw address assignment type */ |
@@ -937,23 +1173,37 @@ struct net_device { | |||
937 | 1173 | ||
938 | 1174 | ||
939 | /* Protocol specific pointers */ | 1175 | /* Protocol specific pointers */ |
940 | 1176 | ||
1177 | #if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) | ||
1178 | struct vlan_group __rcu *vlgrp; /* VLAN group */ | ||
1179 | #endif | ||
941 | #ifdef CONFIG_NET_DSA | 1180 | #ifdef CONFIG_NET_DSA |
942 | void *dsa_ptr; /* dsa specific data */ | 1181 | void *dsa_ptr; /* dsa specific data */ |
943 | #endif | 1182 | #endif |
944 | void *atalk_ptr; /* AppleTalk link */ | 1183 | void *atalk_ptr; /* AppleTalk link */ |
945 | void *ip_ptr; /* IPv4 specific data */ | 1184 | struct in_device __rcu *ip_ptr; /* IPv4 specific data */ |
946 | void *dn_ptr; /* DECnet specific data */ | 1185 | struct dn_dev __rcu *dn_ptr; /* DECnet specific data */ |
947 | void *ip6_ptr; /* IPv6 specific data */ | 1186 | struct inet6_dev __rcu *ip6_ptr; /* IPv6 specific data */ |
948 | void *ec_ptr; /* Econet specific data */ | 1187 | void *ec_ptr; /* Econet specific data */ |
949 | void *ax25_ptr; /* AX.25 specific data */ | 1188 | void *ax25_ptr; /* AX.25 specific data */ |
950 | struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data, | 1189 | struct wireless_dev *ieee80211_ptr; /* IEEE 802.11 specific data, |
951 | assign before registering */ | 1190 | assign before registering */ |
952 | 1191 | ||
953 | /* | 1192 | /* |
954 | * Cache line mostly used on receive path (including eth_type_trans()) | 1193 | * Cache lines mostly used on receive path (including eth_type_trans()) |
955 | */ | 1194 | */ |
956 | unsigned long last_rx; /* Time of last Rx */ | 1195 | unsigned long last_rx; /* Time of last Rx |
1196 | * This should not be set in | ||
1197 | * drivers, unless really needed, | ||
1198 | * because network stack (bonding) | ||
1199 | * use it if/when necessary, to | ||
1200 | * avoid dirtying this cache line. | ||
1201 | */ | ||
1202 | |||
1203 | struct net_device *master; /* Pointer to master device of a group, | ||
1204 | * which this device is member of. | ||
1205 | */ | ||
1206 | |||
957 | /* Interface address info used in eth_type_trans() */ | 1207 | /* Interface address info used in eth_type_trans() */ |
958 | unsigned char *dev_addr; /* hw address, (before bcast | 1208 | unsigned char *dev_addr; /* hw address, (before bcast |
959 | because most packets are | 1209 | because most packets are |
@@ -969,14 +1219,28 @@ struct net_device { | |||
969 | 1219 | ||
970 | struct netdev_rx_queue *_rx; | 1220 | struct netdev_rx_queue *_rx; |
971 | 1221 | ||
972 | /* Number of RX queues allocated at alloc_netdev_mq() time */ | 1222 | /* Number of RX queues allocated at register_netdev() time */ |
973 | unsigned int num_rx_queues; | 1223 | unsigned int num_rx_queues; |
1224 | |||
1225 | /* Number of RX queues currently active in device */ | ||
1226 | unsigned int real_num_rx_queues; | ||
1227 | |||
1228 | #ifdef CONFIG_RFS_ACCEL | ||
1229 | /* CPU reverse-mapping for RX completion interrupts, indexed | ||
1230 | * by RX queue number. Assigned by driver. This must only be | ||
1231 | * set if the ndo_rx_flow_steer operation is defined. */ | ||
1232 | struct cpu_rmap *rx_cpu_rmap; | ||
1233 | #endif | ||
974 | #endif | 1234 | #endif |
975 | 1235 | ||
976 | struct netdev_queue rx_queue; | 1236 | rx_handler_func_t __rcu *rx_handler; |
977 | rx_handler_func_t *rx_handler; | 1237 | void __rcu *rx_handler_data; |
978 | void *rx_handler_data; | 1238 | |
1239 | struct netdev_queue __rcu *ingress_queue; | ||
979 | 1240 | ||
1241 | /* | ||
1242 | * Cache lines mostly used on transmit path | ||
1243 | */ | ||
980 | struct netdev_queue *_tx ____cacheline_aligned_in_smp; | 1244 | struct netdev_queue *_tx ____cacheline_aligned_in_smp; |
981 | 1245 | ||
982 | /* Number of TX queues allocated at alloc_netdev_mq() time */ | 1246 | /* Number of TX queues allocated at alloc_netdev_mq() time */ |
@@ -990,9 +1254,11 @@ struct net_device { | |||
990 | 1254 | ||
991 | unsigned long tx_queue_len; /* Max frames per queue allowed */ | 1255 | unsigned long tx_queue_len; /* Max frames per queue allowed */ |
992 | spinlock_t tx_global_lock; | 1256 | spinlock_t tx_global_lock; |
993 | /* | 1257 | |
994 | * One part is mostly used on xmit path (device) | 1258 | #ifdef CONFIG_XPS |
995 | */ | 1259 | struct xps_dev_maps __rcu *xps_maps; |
1260 | #endif | ||
1261 | |||
996 | /* These may be needed for future network-power-down code. */ | 1262 | /* These may be needed for future network-power-down code. */ |
997 | 1263 | ||
998 | /* | 1264 | /* |
@@ -1005,7 +1271,7 @@ struct net_device { | |||
1005 | struct timer_list watchdog_timer; | 1271 | struct timer_list watchdog_timer; |
1006 | 1272 | ||
1007 | /* Number of references to this device */ | 1273 | /* Number of references to this device */ |
1008 | atomic_t refcnt ____cacheline_aligned_in_smp; | 1274 | int __percpu *pcpu_refcnt; |
1009 | 1275 | ||
1010 | /* delayed register/unregister */ | 1276 | /* delayed register/unregister */ |
1011 | struct list_head todo_list; | 1277 | struct list_head todo_list; |
@@ -1021,7 +1287,9 @@ struct net_device { | |||
1021 | NETREG_UNREGISTERED, /* completed unregister todo */ | 1287 | NETREG_UNREGISTERED, /* completed unregister todo */ |
1022 | NETREG_RELEASED, /* called free_netdev */ | 1288 | NETREG_RELEASED, /* called free_netdev */ |
1023 | NETREG_DUMMY, /* dummy device for NAPI poll */ | 1289 | NETREG_DUMMY, /* dummy device for NAPI poll */ |
1024 | } reg_state:16; | 1290 | } reg_state:8; |
1291 | |||
1292 | bool dismantle; /* device is going do be freed */ | ||
1025 | 1293 | ||
1026 | enum { | 1294 | enum { |
1027 | RTNL_LINK_INITIALIZED, | 1295 | RTNL_LINK_INITIALIZED, |
@@ -1041,10 +1309,14 @@ struct net_device { | |||
1041 | #endif | 1309 | #endif |
1042 | 1310 | ||
1043 | /* mid-layer private */ | 1311 | /* mid-layer private */ |
1044 | void *ml_priv; | 1312 | union { |
1045 | 1313 | void *ml_priv; | |
1314 | struct pcpu_lstats __percpu *lstats; /* loopback stats */ | ||
1315 | struct pcpu_tstats __percpu *tstats; /* tunnel stats */ | ||
1316 | struct pcpu_dstats __percpu *dstats; /* dummy stats */ | ||
1317 | }; | ||
1046 | /* GARP */ | 1318 | /* GARP */ |
1047 | struct garp_port *garp_port; | 1319 | struct garp_port __rcu *garp_port; |
1048 | 1320 | ||
1049 | /* class/net/name entry */ | 1321 | /* class/net/name entry */ |
1050 | struct device dev; | 1322 | struct device dev; |
@@ -1054,9 +1326,6 @@ struct net_device { | |||
1054 | /* rtnetlink link ops */ | 1326 | /* rtnetlink link ops */ |
1055 | const struct rtnl_link_ops *rtnl_link_ops; | 1327 | const struct rtnl_link_ops *rtnl_link_ops; |
1056 | 1328 | ||
1057 | /* VLAN feature mask */ | ||
1058 | unsigned long vlan_features; | ||
1059 | |||
1060 | /* for setting kernel sock attribute on TCP connection setup */ | 1329 | /* for setting kernel sock attribute on TCP connection setup */ |
1061 | #define GSO_MAX_SIZE 65536 | 1330 | #define GSO_MAX_SIZE 65536 |
1062 | unsigned int gso_max_size; | 1331 | unsigned int gso_max_size; |
@@ -1065,6 +1334,9 @@ struct net_device { | |||
1065 | /* Data Center Bridging netlink ops */ | 1334 | /* Data Center Bridging netlink ops */ |
1066 | const struct dcbnl_rtnl_ops *dcbnl_ops; | 1335 | const struct dcbnl_rtnl_ops *dcbnl_ops; |
1067 | #endif | 1336 | #endif |
1337 | u8 num_tc; | ||
1338 | struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE]; | ||
1339 | u8 prio_tc_map[TC_BITMASK + 1]; | ||
1068 | 1340 | ||
1069 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 1341 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
1070 | /* max exchange id for FCoE LRO by ddp */ | 1342 | /* max exchange id for FCoE LRO by ddp */ |
@@ -1075,12 +1347,66 @@ struct net_device { | |||
1075 | 1347 | ||
1076 | /* phy device may attach itself for hardware timestamping */ | 1348 | /* phy device may attach itself for hardware timestamping */ |
1077 | struct phy_device *phydev; | 1349 | struct phy_device *phydev; |
1350 | |||
1351 | /* group the device belongs to */ | ||
1352 | int group; | ||
1078 | }; | 1353 | }; |
1079 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 1354 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
1080 | 1355 | ||
1081 | #define NETDEV_ALIGN 32 | 1356 | #define NETDEV_ALIGN 32 |
1082 | 1357 | ||
1083 | static inline | 1358 | static inline |
1359 | int netdev_get_prio_tc_map(const struct net_device *dev, u32 prio) | ||
1360 | { | ||
1361 | return dev->prio_tc_map[prio & TC_BITMASK]; | ||
1362 | } | ||
1363 | |||
1364 | static inline | ||
1365 | int netdev_set_prio_tc_map(struct net_device *dev, u8 prio, u8 tc) | ||
1366 | { | ||
1367 | if (tc >= dev->num_tc) | ||
1368 | return -EINVAL; | ||
1369 | |||
1370 | dev->prio_tc_map[prio & TC_BITMASK] = tc & TC_BITMASK; | ||
1371 | return 0; | ||
1372 | } | ||
1373 | |||
1374 | static inline | ||
1375 | void netdev_reset_tc(struct net_device *dev) | ||
1376 | { | ||
1377 | dev->num_tc = 0; | ||
1378 | memset(dev->tc_to_txq, 0, sizeof(dev->tc_to_txq)); | ||
1379 | memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map)); | ||
1380 | } | ||
1381 | |||
1382 | static inline | ||
1383 | int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset) | ||
1384 | { | ||
1385 | if (tc >= dev->num_tc) | ||
1386 | return -EINVAL; | ||
1387 | |||
1388 | dev->tc_to_txq[tc].count = count; | ||
1389 | dev->tc_to_txq[tc].offset = offset; | ||
1390 | return 0; | ||
1391 | } | ||
1392 | |||
1393 | static inline | ||
1394 | int netdev_set_num_tc(struct net_device *dev, u8 num_tc) | ||
1395 | { | ||
1396 | if (num_tc > TC_MAX_QUEUE) | ||
1397 | return -EINVAL; | ||
1398 | |||
1399 | dev->num_tc = num_tc; | ||
1400 | return 0; | ||
1401 | } | ||
1402 | |||
1403 | static inline | ||
1404 | int netdev_get_num_tc(struct net_device *dev) | ||
1405 | { | ||
1406 | return dev->num_tc; | ||
1407 | } | ||
1408 | |||
1409 | static inline | ||
1084 | struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, | 1410 | struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, |
1085 | unsigned int index) | 1411 | unsigned int index) |
1086 | { | 1412 | { |
@@ -1222,7 +1548,7 @@ struct packet_type { | |||
1222 | struct packet_type *, | 1548 | struct packet_type *, |
1223 | struct net_device *); | 1549 | struct net_device *); |
1224 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 1550 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
1225 | int features); | 1551 | u32 features); |
1226 | int (*gso_send_check)(struct sk_buff *skb); | 1552 | int (*gso_send_check)(struct sk_buff *skb); |
1227 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 1553 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
1228 | struct sk_buff *skb); | 1554 | struct sk_buff *skb); |
@@ -1267,7 +1593,7 @@ static inline struct net_device *next_net_device_rcu(struct net_device *dev) | |||
1267 | struct net *net; | 1593 | struct net *net; |
1268 | 1594 | ||
1269 | net = dev_net(dev); | 1595 | net = dev_net(dev); |
1270 | lh = rcu_dereference(dev->dev_list.next); | 1596 | lh = rcu_dereference(list_next_rcu(&dev->dev_list)); |
1271 | return lh == &net->dev_base_head ? NULL : net_device_entry(lh); | 1597 | return lh == &net->dev_base_head ? NULL : net_device_entry(lh); |
1272 | } | 1598 | } |
1273 | 1599 | ||
@@ -1277,9 +1603,17 @@ static inline struct net_device *first_net_device(struct net *net) | |||
1277 | net_device_entry(net->dev_base_head.next); | 1603 | net_device_entry(net->dev_base_head.next); |
1278 | } | 1604 | } |
1279 | 1605 | ||
1606 | static inline struct net_device *first_net_device_rcu(struct net *net) | ||
1607 | { | ||
1608 | struct list_head *lh = rcu_dereference(list_next_rcu(&net->dev_base_head)); | ||
1609 | |||
1610 | return lh == &net->dev_base_head ? NULL : net_device_entry(lh); | ||
1611 | } | ||
1612 | |||
1280 | extern int netdev_boot_setup_check(struct net_device *dev); | 1613 | extern int netdev_boot_setup_check(struct net_device *dev); |
1281 | extern unsigned long netdev_boot_base(const char *prefix, int unit); | 1614 | extern unsigned long netdev_boot_base(const char *prefix, int unit); |
1282 | extern struct net_device *dev_getbyhwaddr(struct net *net, unsigned short type, char *hwaddr); | 1615 | extern struct net_device *dev_getbyhwaddr_rcu(struct net *net, unsigned short type, |
1616 | const char *hwaddr); | ||
1283 | extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type); | 1617 | extern struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type); |
1284 | extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type); | 1618 | extern struct net_device *__dev_getfirstbyhwtype(struct net *net, unsigned short type); |
1285 | extern void dev_add_pack(struct packet_type *pt); | 1619 | extern void dev_add_pack(struct packet_type *pt); |
@@ -1305,6 +1639,7 @@ static inline void unregister_netdevice(struct net_device *dev) | |||
1305 | unregister_netdevice_queue(dev, NULL); | 1639 | unregister_netdevice_queue(dev, NULL); |
1306 | } | 1640 | } |
1307 | 1641 | ||
1642 | extern int netdev_refcnt_read(const struct net_device *dev); | ||
1308 | extern void free_netdev(struct net_device *dev); | 1643 | extern void free_netdev(struct net_device *dev); |
1309 | extern void synchronize_net(void); | 1644 | extern void synchronize_net(void); |
1310 | extern int register_netdevice_notifier(struct notifier_block *nb); | 1645 | extern int register_netdevice_notifier(struct notifier_block *nb); |
@@ -1525,6 +1860,10 @@ static inline void netif_tx_wake_all_queues(struct net_device *dev) | |||
1525 | 1860 | ||
1526 | static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) | 1861 | static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) |
1527 | { | 1862 | { |
1863 | if (WARN_ON(!dev_queue)) { | ||
1864 | pr_info("netif_stop_queue() cannot be called before register_netdev()\n"); | ||
1865 | return; | ||
1866 | } | ||
1528 | set_bit(__QUEUE_STATE_XOFF, &dev_queue->state); | 1867 | set_bit(__QUEUE_STATE_XOFF, &dev_queue->state); |
1529 | } | 1868 | } |
1530 | 1869 | ||
@@ -1566,9 +1905,9 @@ static inline int netif_queue_stopped(const struct net_device *dev) | |||
1566 | return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); | 1905 | return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); |
1567 | } | 1906 | } |
1568 | 1907 | ||
1569 | static inline int netif_tx_queue_frozen(const struct netdev_queue *dev_queue) | 1908 | static inline int netif_tx_queue_frozen_or_stopped(const struct netdev_queue *dev_queue) |
1570 | { | 1909 | { |
1571 | return test_bit(__QUEUE_STATE_FROZEN, &dev_queue->state); | 1910 | return dev_queue->state & QUEUE_STATE_XOFF_OR_FROZEN; |
1572 | } | 1911 | } |
1573 | 1912 | ||
1574 | /** | 1913 | /** |
@@ -1659,6 +1998,16 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) | |||
1659 | __netif_schedule(txq->qdisc); | 1998 | __netif_schedule(txq->qdisc); |
1660 | } | 1999 | } |
1661 | 2000 | ||
2001 | /* | ||
2002 | * Returns a Tx hash for the given packet when dev->real_num_tx_queues is used | ||
2003 | * as a distribution range limit for the returned value. | ||
2004 | */ | ||
2005 | static inline u16 skb_tx_hash(const struct net_device *dev, | ||
2006 | const struct sk_buff *skb) | ||
2007 | { | ||
2008 | return __skb_tx_hash(dev, skb, dev->real_num_tx_queues); | ||
2009 | } | ||
2010 | |||
1662 | /** | 2011 | /** |
1663 | * netif_is_multiqueue - test if device has multiple transmit queues | 2012 | * netif_is_multiqueue - test if device has multiple transmit queues |
1664 | * @dev: network device | 2013 | * @dev: network device |
@@ -1667,11 +2016,34 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) | |||
1667 | */ | 2016 | */ |
1668 | static inline int netif_is_multiqueue(const struct net_device *dev) | 2017 | static inline int netif_is_multiqueue(const struct net_device *dev) |
1669 | { | 2018 | { |
1670 | return (dev->num_tx_queues > 1); | 2019 | return dev->num_tx_queues > 1; |
2020 | } | ||
2021 | |||
2022 | extern int netif_set_real_num_tx_queues(struct net_device *dev, | ||
2023 | unsigned int txq); | ||
2024 | |||
2025 | #ifdef CONFIG_RPS | ||
2026 | extern int netif_set_real_num_rx_queues(struct net_device *dev, | ||
2027 | unsigned int rxq); | ||
2028 | #else | ||
2029 | static inline int netif_set_real_num_rx_queues(struct net_device *dev, | ||
2030 | unsigned int rxq) | ||
2031 | { | ||
2032 | return 0; | ||
1671 | } | 2033 | } |
2034 | #endif | ||
1672 | 2035 | ||
1673 | extern void netif_set_real_num_tx_queues(struct net_device *dev, | 2036 | static inline int netif_copy_real_num_queues(struct net_device *to_dev, |
1674 | unsigned int txq); | 2037 | const struct net_device *from_dev) |
2038 | { | ||
2039 | netif_set_real_num_tx_queues(to_dev, from_dev->real_num_tx_queues); | ||
2040 | #ifdef CONFIG_RPS | ||
2041 | return netif_set_real_num_rx_queues(to_dev, | ||
2042 | from_dev->real_num_rx_queues); | ||
2043 | #else | ||
2044 | return 0; | ||
2045 | #endif | ||
2046 | } | ||
1675 | 2047 | ||
1676 | /* Use this variant when it is known for sure that it | 2048 | /* Use this variant when it is known for sure that it |
1677 | * is executing from hardware interrupt context or with hardware interrupts | 2049 | * is executing from hardware interrupt context or with hardware interrupts |
@@ -1695,8 +2067,7 @@ extern gro_result_t dev_gro_receive(struct napi_struct *napi, | |||
1695 | extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); | 2067 | extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); |
1696 | extern gro_result_t napi_gro_receive(struct napi_struct *napi, | 2068 | extern gro_result_t napi_gro_receive(struct napi_struct *napi, |
1697 | struct sk_buff *skb); | 2069 | struct sk_buff *skb); |
1698 | extern void napi_reuse_skb(struct napi_struct *napi, | 2070 | extern void napi_gro_flush(struct napi_struct *napi); |
1699 | struct sk_buff *skb); | ||
1700 | extern struct sk_buff * napi_get_frags(struct napi_struct *napi); | 2071 | extern struct sk_buff * napi_get_frags(struct napi_struct *napi); |
1701 | extern gro_result_t napi_frags_finish(struct napi_struct *napi, | 2072 | extern gro_result_t napi_frags_finish(struct napi_struct *napi, |
1702 | struct sk_buff *skb, | 2073 | struct sk_buff *skb, |
@@ -1715,7 +2086,6 @@ extern int netdev_rx_handler_register(struct net_device *dev, | |||
1715 | void *rx_handler_data); | 2086 | void *rx_handler_data); |
1716 | extern void netdev_rx_handler_unregister(struct net_device *dev); | 2087 | extern void netdev_rx_handler_unregister(struct net_device *dev); |
1717 | 2088 | ||
1718 | extern void netif_nit_deliver(struct sk_buff *skb); | ||
1719 | extern int dev_valid_name(const char *name); | 2089 | extern int dev_valid_name(const char *name); |
1720 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); | 2090 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); |
1721 | extern int dev_ethtool(struct net *net, struct ifreq *); | 2091 | extern int dev_ethtool(struct net *net, struct ifreq *); |
@@ -1728,6 +2098,7 @@ extern int dev_set_alias(struct net_device *, const char *, size_t); | |||
1728 | extern int dev_change_net_namespace(struct net_device *, | 2098 | extern int dev_change_net_namespace(struct net_device *, |
1729 | struct net *, const char *); | 2099 | struct net *, const char *); |
1730 | extern int dev_set_mtu(struct net_device *, int); | 2100 | extern int dev_set_mtu(struct net_device *, int); |
2101 | extern void dev_set_group(struct net_device *, int); | ||
1731 | extern int dev_set_mac_address(struct net_device *, | 2102 | extern int dev_set_mac_address(struct net_device *, |
1732 | struct sockaddr *); | 2103 | struct sockaddr *); |
1733 | extern int dev_hard_start_xmit(struct sk_buff *skb, | 2104 | extern int dev_hard_start_xmit(struct sk_buff *skb, |
@@ -1749,7 +2120,7 @@ extern void netdev_run_todo(void); | |||
1749 | */ | 2120 | */ |
1750 | static inline void dev_put(struct net_device *dev) | 2121 | static inline void dev_put(struct net_device *dev) |
1751 | { | 2122 | { |
1752 | atomic_dec(&dev->refcnt); | 2123 | irqsafe_cpu_dec(*dev->pcpu_refcnt); |
1753 | } | 2124 | } |
1754 | 2125 | ||
1755 | /** | 2126 | /** |
@@ -1760,7 +2131,7 @@ static inline void dev_put(struct net_device *dev) | |||
1760 | */ | 2131 | */ |
1761 | static inline void dev_hold(struct net_device *dev) | 2132 | static inline void dev_hold(struct net_device *dev) |
1762 | { | 2133 | { |
1763 | atomic_inc(&dev->refcnt); | 2134 | irqsafe_cpu_inc(*dev->pcpu_refcnt); |
1764 | } | 2135 | } |
1765 | 2136 | ||
1766 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on | 2137 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on |
@@ -2072,11 +2443,15 @@ static inline void netif_addr_unlock_bh(struct net_device *dev) | |||
2072 | extern void ether_setup(struct net_device *dev); | 2443 | extern void ether_setup(struct net_device *dev); |
2073 | 2444 | ||
2074 | /* Support for loadable net-drivers */ | 2445 | /* Support for loadable net-drivers */ |
2075 | extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | 2446 | extern struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, |
2076 | void (*setup)(struct net_device *), | 2447 | void (*setup)(struct net_device *), |
2077 | unsigned int queue_count); | 2448 | unsigned int txqs, unsigned int rxqs); |
2078 | #define alloc_netdev(sizeof_priv, name, setup) \ | 2449 | #define alloc_netdev(sizeof_priv, name, setup) \ |
2079 | alloc_netdev_mq(sizeof_priv, name, setup, 1) | 2450 | alloc_netdev_mqs(sizeof_priv, name, setup, 1, 1) |
2451 | |||
2452 | #define alloc_netdev_mq(sizeof_priv, name, setup, count) \ | ||
2453 | alloc_netdev_mqs(sizeof_priv, name, setup, count, count) | ||
2454 | |||
2080 | extern int register_netdev(struct net_device *dev); | 2455 | extern int register_netdev(struct net_device *dev); |
2081 | extern void unregister_netdev(struct net_device *dev); | 2456 | extern void unregister_netdev(struct net_device *dev); |
2082 | 2457 | ||
@@ -2142,15 +2517,16 @@ extern void dev_load(struct net *net, const char *name); | |||
2142 | extern void dev_mcast_init(void); | 2517 | extern void dev_mcast_init(void); |
2143 | extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, | 2518 | extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, |
2144 | struct rtnl_link_stats64 *storage); | 2519 | struct rtnl_link_stats64 *storage); |
2145 | extern void dev_txq_stats_fold(const struct net_device *dev, | ||
2146 | struct rtnl_link_stats64 *stats); | ||
2147 | 2520 | ||
2148 | extern int netdev_max_backlog; | 2521 | extern int netdev_max_backlog; |
2149 | extern int netdev_tstamp_prequeue; | 2522 | extern int netdev_tstamp_prequeue; |
2150 | extern int weight_p; | 2523 | extern int weight_p; |
2524 | extern int bpf_jit_enable; | ||
2151 | extern int netdev_set_master(struct net_device *dev, struct net_device *master); | 2525 | extern int netdev_set_master(struct net_device *dev, struct net_device *master); |
2526 | extern int netdev_set_bond_master(struct net_device *dev, | ||
2527 | struct net_device *master); | ||
2152 | extern int skb_checksum_help(struct sk_buff *skb); | 2528 | extern int skb_checksum_help(struct sk_buff *skb); |
2153 | extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features); | 2529 | extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, u32 features); |
2154 | #ifdef CONFIG_BUG | 2530 | #ifdef CONFIG_BUG |
2155 | extern void netdev_rx_csum_fault(struct net_device *dev); | 2531 | extern void netdev_rx_csum_fault(struct net_device *dev); |
2156 | #else | 2532 | #else |
@@ -2171,33 +2547,42 @@ extern void dev_seq_stop(struct seq_file *seq, void *v); | |||
2171 | extern int netdev_class_create_file(struct class_attribute *class_attr); | 2547 | extern int netdev_class_create_file(struct class_attribute *class_attr); |
2172 | extern void netdev_class_remove_file(struct class_attribute *class_attr); | 2548 | extern void netdev_class_remove_file(struct class_attribute *class_attr); |
2173 | 2549 | ||
2174 | extern char *netdev_drivername(const struct net_device *dev, char *buffer, int len); | 2550 | extern struct kobj_ns_type_operations net_ns_type_operations; |
2551 | |||
2552 | extern const char *netdev_drivername(const struct net_device *dev); | ||
2175 | 2553 | ||
2176 | extern void linkwatch_run_queue(void); | 2554 | extern void linkwatch_run_queue(void); |
2177 | 2555 | ||
2178 | unsigned long netdev_increment_features(unsigned long all, unsigned long one, | 2556 | static inline u32 netdev_get_wanted_features(struct net_device *dev) |
2179 | unsigned long mask); | 2557 | { |
2180 | unsigned long netdev_fix_features(unsigned long features, const char *name); | 2558 | return (dev->features & ~dev->hw_features) | dev->wanted_features; |
2559 | } | ||
2560 | u32 netdev_increment_features(u32 all, u32 one, u32 mask); | ||
2561 | u32 netdev_fix_features(struct net_device *dev, u32 features); | ||
2562 | int __netdev_update_features(struct net_device *dev); | ||
2563 | void netdev_update_features(struct net_device *dev); | ||
2564 | void netdev_change_features(struct net_device *dev); | ||
2181 | 2565 | ||
2182 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, | 2566 | void netif_stacked_transfer_operstate(const struct net_device *rootdev, |
2183 | struct net_device *dev); | 2567 | struct net_device *dev); |
2184 | 2568 | ||
2185 | static inline int net_gso_ok(int features, int gso_type) | 2569 | u32 netif_skb_features(struct sk_buff *skb); |
2570 | |||
2571 | static inline int net_gso_ok(u32 features, int gso_type) | ||
2186 | { | 2572 | { |
2187 | int feature = gso_type << NETIF_F_GSO_SHIFT; | 2573 | int feature = gso_type << NETIF_F_GSO_SHIFT; |
2188 | return (features & feature) == feature; | 2574 | return (features & feature) == feature; |
2189 | } | 2575 | } |
2190 | 2576 | ||
2191 | static inline int skb_gso_ok(struct sk_buff *skb, int features) | 2577 | static inline int skb_gso_ok(struct sk_buff *skb, u32 features) |
2192 | { | 2578 | { |
2193 | return net_gso_ok(features, skb_shinfo(skb)->gso_type) && | 2579 | return net_gso_ok(features, skb_shinfo(skb)->gso_type) && |
2194 | (!skb_has_frags(skb) || (features & NETIF_F_FRAGLIST)); | 2580 | (!skb_has_frag_list(skb) || (features & NETIF_F_FRAGLIST)); |
2195 | } | 2581 | } |
2196 | 2582 | ||
2197 | static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb) | 2583 | static inline int netif_needs_gso(struct sk_buff *skb, int features) |
2198 | { | 2584 | { |
2199 | return skb_is_gso(skb) && | 2585 | return skb_is_gso(skb) && (!skb_gso_ok(skb, features) || |
2200 | (!skb_gso_ok(skb, dev->features) || | ||
2201 | unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); | 2586 | unlikely(skb->ip_summed != CHECKSUM_PARTIAL)); |
2202 | } | 2587 | } |
2203 | 2588 | ||
@@ -2207,29 +2592,20 @@ static inline void netif_set_gso_max_size(struct net_device *dev, | |||
2207 | dev->gso_max_size = size; | 2592 | dev->gso_max_size = size; |
2208 | } | 2593 | } |
2209 | 2594 | ||
2210 | extern int __skb_bond_should_drop(struct sk_buff *skb, | 2595 | static inline int netif_is_bond_slave(struct net_device *dev) |
2211 | struct net_device *master); | ||
2212 | |||
2213 | static inline int skb_bond_should_drop(struct sk_buff *skb, | ||
2214 | struct net_device *master) | ||
2215 | { | 2596 | { |
2216 | if (master) | 2597 | return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING; |
2217 | return __skb_bond_should_drop(skb, master); | ||
2218 | return 0; | ||
2219 | } | 2598 | } |
2220 | 2599 | ||
2221 | extern struct pernet_operations __net_initdata loopback_net_ops; | 2600 | extern struct pernet_operations __net_initdata loopback_net_ops; |
2222 | 2601 | ||
2223 | static inline int dev_ethtool_get_settings(struct net_device *dev, | 2602 | int dev_ethtool_get_settings(struct net_device *dev, |
2224 | struct ethtool_cmd *cmd) | 2603 | struct ethtool_cmd *cmd); |
2225 | { | ||
2226 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings) | ||
2227 | return -EOPNOTSUPP; | ||
2228 | return dev->ethtool_ops->get_settings(dev, cmd); | ||
2229 | } | ||
2230 | 2604 | ||
2231 | static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev) | 2605 | static inline u32 dev_ethtool_get_rx_csum(struct net_device *dev) |
2232 | { | 2606 | { |
2607 | if (dev->features & NETIF_F_RXCSUM) | ||
2608 | return 1; | ||
2233 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum) | 2609 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_rx_csum) |
2234 | return 0; | 2610 | return 0; |
2235 | return dev->ethtool_ops->get_rx_csum(dev); | 2611 | return dev->ethtool_ops->get_rx_csum(dev); |
@@ -2271,6 +2647,9 @@ extern int netdev_notice(const struct net_device *dev, const char *format, ...) | |||
2271 | extern int netdev_info(const struct net_device *dev, const char *format, ...) | 2647 | extern int netdev_info(const struct net_device *dev, const char *format, ...) |
2272 | __attribute__ ((format (printf, 2, 3))); | 2648 | __attribute__ ((format (printf, 2, 3))); |
2273 | 2649 | ||
2650 | #define MODULE_ALIAS_NETDEV(device) \ | ||
2651 | MODULE_ALIAS("netdev-" device) | ||
2652 | |||
2274 | #if defined(DEBUG) | 2653 | #if defined(DEBUG) |
2275 | #define netdev_dbg(__dev, format, args...) \ | 2654 | #define netdev_dbg(__dev, format, args...) \ |
2276 | netdev_printk(KERN_DEBUG, __dev, format, ##args) | 2655 | netdev_printk(KERN_DEBUG, __dev, format, ##args) |