diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-07-23 05:20:10 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2007-07-23 05:20:10 -0400 |
commit | 39fe5434cb9de5da40510028b17b96bc4eb312b3 (patch) | |
tree | 7a02a317b9ad57da51ca99887c119e779ccf3f13 /include/linux/netdevice.h | |
parent | 0fc72b81d3111d114ab378935b1cf07680ca1289 (diff) | |
parent | f695baf2df9e0413d3521661070103711545207a (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 141 |
1 files changed, 120 insertions, 21 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 3a70f553b28f..4a616d73cc25 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -108,6 +108,14 @@ struct wireless_dev; | |||
108 | #define MAX_HEADER (LL_MAX_HEADER + 48) | 108 | #define MAX_HEADER (LL_MAX_HEADER + 48) |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | struct net_device_subqueue | ||
112 | { | ||
113 | /* Give a control state for each queue. This struct may contain | ||
114 | * per-queue locks in the future. | ||
115 | */ | ||
116 | unsigned long state; | ||
117 | }; | ||
118 | |||
111 | /* | 119 | /* |
112 | * Network device statistics. Akin to the 2.0 ether stats but | 120 | * Network device statistics. Akin to the 2.0 ether stats but |
113 | * with byte counters. | 121 | * with byte counters. |
@@ -177,19 +185,25 @@ struct netif_rx_stats | |||
177 | 185 | ||
178 | DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat); | 186 | DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat); |
179 | 187 | ||
188 | struct dev_addr_list | ||
189 | { | ||
190 | struct dev_addr_list *next; | ||
191 | u8 da_addr[MAX_ADDR_LEN]; | ||
192 | u8 da_addrlen; | ||
193 | u8 da_synced; | ||
194 | int da_users; | ||
195 | int da_gusers; | ||
196 | }; | ||
180 | 197 | ||
181 | /* | 198 | /* |
182 | * We tag multicasts with these structures. | 199 | * We tag multicasts with these structures. |
183 | */ | 200 | */ |
184 | 201 | ||
185 | struct dev_mc_list | 202 | #define dev_mc_list dev_addr_list |
186 | { | 203 | #define dmi_addr da_addr |
187 | struct dev_mc_list *next; | 204 | #define dmi_addrlen da_addrlen |
188 | __u8 dmi_addr[MAX_ADDR_LEN]; | 205 | #define dmi_users da_users |
189 | unsigned char dmi_addrlen; | 206 | #define dmi_gusers da_gusers |
190 | int dmi_users; | ||
191 | int dmi_gusers; | ||
192 | }; | ||
193 | 207 | ||
194 | struct hh_cache | 208 | struct hh_cache |
195 | { | 209 | { |
@@ -314,9 +328,10 @@ struct net_device | |||
314 | /* Net device features */ | 328 | /* Net device features */ |
315 | unsigned long features; | 329 | unsigned long features; |
316 | #define NETIF_F_SG 1 /* Scatter/gather IO. */ | 330 | #define NETIF_F_SG 1 /* Scatter/gather IO. */ |
317 | #define NETIF_F_IP_CSUM 2 /* Can checksum only TCP/UDP over IPv4. */ | 331 | #define NETIF_F_IP_CSUM 2 /* Can checksum TCP/UDP over IPv4. */ |
318 | #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ | 332 | #define NETIF_F_NO_CSUM 4 /* Does not require checksum. F.e. loopack. */ |
319 | #define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */ | 333 | #define NETIF_F_HW_CSUM 8 /* Can checksum all the packets. */ |
334 | #define NETIF_F_IPV6_CSUM 16 /* Can checksum TCP/UDP over IPV6 */ | ||
320 | #define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */ | 335 | #define NETIF_F_HIGHDMA 32 /* Can DMA to high memory. */ |
321 | #define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */ | 336 | #define NETIF_F_FRAGLIST 64 /* Scatter/gather IO. */ |
322 | #define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */ | 337 | #define NETIF_F_HW_VLAN_TX 128 /* Transmit VLAN hw acceleration */ |
@@ -325,6 +340,7 @@ struct net_device | |||
325 | #define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */ | 340 | #define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */ |
326 | #define NETIF_F_GSO 2048 /* Enable software GSO. */ | 341 | #define NETIF_F_GSO 2048 /* Enable software GSO. */ |
327 | #define NETIF_F_LLTX 4096 /* LockLess TX */ | 342 | #define NETIF_F_LLTX 4096 /* LockLess TX */ |
343 | #define NETIF_F_MULTI_QUEUE 16384 /* Has multiple TX/RX queues */ | ||
328 | 344 | ||
329 | /* Segmentation offload features */ | 345 | /* Segmentation offload features */ |
330 | #define NETIF_F_GSO_SHIFT 16 | 346 | #define NETIF_F_GSO_SHIFT 16 |
@@ -338,8 +354,11 @@ struct net_device | |||
338 | /* List of features with software fallbacks. */ | 354 | /* List of features with software fallbacks. */ |
339 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6) | 355 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6) |
340 | 356 | ||
357 | |||
341 | #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) | 358 | #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) |
342 | #define NETIF_F_ALL_CSUM (NETIF_F_IP_CSUM | NETIF_F_GEN_CSUM) | 359 | #define NETIF_F_V4_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IP_CSUM) |
360 | #define NETIF_F_V6_CSUM (NETIF_F_GEN_CSUM | NETIF_F_IPV6_CSUM) | ||
361 | #define NETIF_F_ALL_CSUM (NETIF_F_V4_CSUM | NETIF_F_V6_CSUM) | ||
343 | 362 | ||
344 | struct net_device *next_sched; | 363 | struct net_device *next_sched; |
345 | 364 | ||
@@ -388,7 +407,10 @@ struct net_device | |||
388 | unsigned char addr_len; /* hardware address length */ | 407 | unsigned char addr_len; /* hardware address length */ |
389 | unsigned short dev_id; /* for shared network cards */ | 408 | unsigned short dev_id; /* for shared network cards */ |
390 | 409 | ||
391 | struct dev_mc_list *mc_list; /* Multicast mac addresses */ | 410 | struct dev_addr_list *uc_list; /* Secondary unicast mac addresses */ |
411 | int uc_count; /* Number of installed ucasts */ | ||
412 | int uc_promisc; | ||
413 | struct dev_addr_list *mc_list; /* Multicast mac addresses */ | ||
392 | int mc_count; /* Number of installed mcasts */ | 414 | int mc_count; /* Number of installed mcasts */ |
393 | int promiscuity; | 415 | int promiscuity; |
394 | int allmulti; | 416 | int allmulti; |
@@ -493,6 +515,11 @@ struct net_device | |||
493 | void *saddr, | 515 | void *saddr, |
494 | unsigned len); | 516 | unsigned len); |
495 | int (*rebuild_header)(struct sk_buff *skb); | 517 | int (*rebuild_header)(struct sk_buff *skb); |
518 | #define HAVE_CHANGE_RX_FLAGS | ||
519 | void (*change_rx_flags)(struct net_device *dev, | ||
520 | int flags); | ||
521 | #define HAVE_SET_RX_MODE | ||
522 | void (*set_rx_mode)(struct net_device *dev); | ||
496 | #define HAVE_MULTICAST | 523 | #define HAVE_MULTICAST |
497 | void (*set_multicast_list)(struct net_device *dev); | 524 | void (*set_multicast_list)(struct net_device *dev); |
498 | #define HAVE_SET_MAC_ADDR | 525 | #define HAVE_SET_MAC_ADDR |
@@ -535,22 +562,29 @@ struct net_device | |||
535 | 562 | ||
536 | /* bridge stuff */ | 563 | /* bridge stuff */ |
537 | struct net_bridge_port *br_port; | 564 | struct net_bridge_port *br_port; |
565 | /* macvlan */ | ||
566 | struct macvlan_port *macvlan_port; | ||
538 | 567 | ||
539 | /* class/net/name entry */ | 568 | /* class/net/name entry */ |
540 | struct device dev; | 569 | struct device dev; |
541 | /* space for optional statistics and wireless sysfs groups */ | 570 | /* space for optional statistics and wireless sysfs groups */ |
542 | struct attribute_group *sysfs_groups[3]; | 571 | struct attribute_group *sysfs_groups[3]; |
572 | |||
573 | /* rtnetlink link ops */ | ||
574 | const struct rtnl_link_ops *rtnl_link_ops; | ||
575 | |||
576 | /* The TX queue control structures */ | ||
577 | unsigned int egress_subqueue_count; | ||
578 | struct net_device_subqueue egress_subqueue[1]; | ||
543 | }; | 579 | }; |
544 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 580 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
545 | 581 | ||
546 | #define NETDEV_ALIGN 32 | 582 | #define NETDEV_ALIGN 32 |
547 | #define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) | 583 | #define NETDEV_ALIGN_CONST (NETDEV_ALIGN - 1) |
548 | 584 | ||
549 | static inline void *netdev_priv(struct net_device *dev) | 585 | static inline void *netdev_priv(const struct net_device *dev) |
550 | { | 586 | { |
551 | return (char *)dev + ((sizeof(struct net_device) | 587 | return dev->priv; |
552 | + NETDEV_ALIGN_CONST) | ||
553 | & ~NETDEV_ALIGN_CONST); | ||
554 | } | 588 | } |
555 | 589 | ||
556 | #define SET_MODULE_OWNER(dev) do { } while (0) | 590 | #define SET_MODULE_OWNER(dev) do { } while (0) |
@@ -702,6 +736,62 @@ static inline int netif_running(const struct net_device *dev) | |||
702 | return test_bit(__LINK_STATE_START, &dev->state); | 736 | return test_bit(__LINK_STATE_START, &dev->state); |
703 | } | 737 | } |
704 | 738 | ||
739 | /* | ||
740 | * Routines to manage the subqueues on a device. We only need start | ||
741 | * stop, and a check if it's stopped. All other device management is | ||
742 | * done at the overall netdevice level. | ||
743 | * Also test the device if we're multiqueue. | ||
744 | */ | ||
745 | static inline void netif_start_subqueue(struct net_device *dev, u16 queue_index) | ||
746 | { | ||
747 | #ifdef CONFIG_NETDEVICES_MULTIQUEUE | ||
748 | clear_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state); | ||
749 | #endif | ||
750 | } | ||
751 | |||
752 | static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index) | ||
753 | { | ||
754 | #ifdef CONFIG_NETDEVICES_MULTIQUEUE | ||
755 | #ifdef CONFIG_NETPOLL_TRAP | ||
756 | if (netpoll_trap()) | ||
757 | return; | ||
758 | #endif | ||
759 | set_bit(__LINK_STATE_XOFF, &dev->egress_subqueue[queue_index].state); | ||
760 | #endif | ||
761 | } | ||
762 | |||
763 | static inline int netif_subqueue_stopped(const struct net_device *dev, | ||
764 | u16 queue_index) | ||
765 | { | ||
766 | #ifdef CONFIG_NETDEVICES_MULTIQUEUE | ||
767 | return test_bit(__LINK_STATE_XOFF, | ||
768 | &dev->egress_subqueue[queue_index].state); | ||
769 | #else | ||
770 | return 0; | ||
771 | #endif | ||
772 | } | ||
773 | |||
774 | static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) | ||
775 | { | ||
776 | #ifdef CONFIG_NETDEVICES_MULTIQUEUE | ||
777 | #ifdef CONFIG_NETPOLL_TRAP | ||
778 | if (netpoll_trap()) | ||
779 | return; | ||
780 | #endif | ||
781 | if (test_and_clear_bit(__LINK_STATE_XOFF, | ||
782 | &dev->egress_subqueue[queue_index].state)) | ||
783 | __netif_schedule(dev); | ||
784 | #endif | ||
785 | } | ||
786 | |||
787 | static inline int netif_is_multiqueue(const struct net_device *dev) | ||
788 | { | ||
789 | #ifdef CONFIG_NETDEVICES_MULTIQUEUE | ||
790 | return (!!(NETIF_F_MULTI_QUEUE & dev->features)); | ||
791 | #else | ||
792 | return 0; | ||
793 | #endif | ||
794 | } | ||
705 | 795 | ||
706 | /* Use this variant when it is known for sure that it | 796 | /* Use this variant when it is known for sure that it |
707 | * is executing from interrupt context. | 797 | * is executing from interrupt context. |
@@ -992,15 +1082,24 @@ static inline void netif_tx_disable(struct net_device *dev) | |||
992 | extern void ether_setup(struct net_device *dev); | 1082 | extern void ether_setup(struct net_device *dev); |
993 | 1083 | ||
994 | /* Support for loadable net-drivers */ | 1084 | /* Support for loadable net-drivers */ |
995 | extern struct net_device *alloc_netdev(int sizeof_priv, const char *name, | 1085 | extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, |
996 | void (*setup)(struct net_device *)); | 1086 | void (*setup)(struct net_device *), |
1087 | unsigned int queue_count); | ||
1088 | #define alloc_netdev(sizeof_priv, name, setup) \ | ||
1089 | alloc_netdev_mq(sizeof_priv, name, setup, 1) | ||
997 | extern int register_netdev(struct net_device *dev); | 1090 | extern int register_netdev(struct net_device *dev); |
998 | extern void unregister_netdev(struct net_device *dev); | 1091 | extern void unregister_netdev(struct net_device *dev); |
999 | /* Functions used for multicast support */ | 1092 | /* Functions used for secondary unicast and multicast support */ |
1000 | extern void dev_mc_upload(struct net_device *dev); | 1093 | extern void dev_set_rx_mode(struct net_device *dev); |
1094 | extern void __dev_set_rx_mode(struct net_device *dev); | ||
1095 | extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen); | ||
1096 | extern int dev_unicast_add(struct net_device *dev, void *addr, int alen); | ||
1001 | extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all); | 1097 | extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all); |
1002 | extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly); | 1098 | extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly); |
1003 | extern void dev_mc_discard(struct net_device *dev); | 1099 | extern int dev_mc_sync(struct net_device *to, struct net_device *from); |
1100 | extern void dev_mc_unsync(struct net_device *to, struct net_device *from); | ||
1101 | extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all); | ||
1102 | extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly); | ||
1004 | extern void dev_set_promiscuity(struct net_device *dev, int inc); | 1103 | extern void dev_set_promiscuity(struct net_device *dev, int inc); |
1005 | extern void dev_set_allmulti(struct net_device *dev, int inc); | 1104 | extern void dev_set_allmulti(struct net_device *dev, int inc); |
1006 | extern void netdev_state_change(struct net_device *dev); | 1105 | extern void netdev_state_change(struct net_device *dev); |