diff options
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 598 |
1 files changed, 442 insertions, 156 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index a3fccc85b1a0..46c36ffe20ee 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -28,8 +28,10 @@ | |||
| 28 | #include <linux/if.h> | 28 | #include <linux/if.h> |
| 29 | #include <linux/if_ether.h> | 29 | #include <linux/if_ether.h> |
| 30 | #include <linux/if_packet.h> | 30 | #include <linux/if_packet.h> |
| 31 | #include <linux/if_link.h> | ||
| 31 | 32 | ||
| 32 | #ifdef __KERNEL__ | 33 | #ifdef __KERNEL__ |
| 34 | #include <linux/pm_qos_params.h> | ||
| 33 | #include <linux/timer.h> | 35 | #include <linux/timer.h> |
| 34 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
| 35 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
| @@ -52,6 +54,7 @@ | |||
| 52 | 54 | ||
| 53 | struct vlan_group; | 55 | struct vlan_group; |
| 54 | struct netpoll_info; | 56 | struct netpoll_info; |
| 57 | struct phy_device; | ||
| 55 | /* 802.11 specific */ | 58 | /* 802.11 specific */ |
| 56 | struct wireless_dev; | 59 | struct wireless_dev; |
| 57 | /* source back-compat hooks */ | 60 | /* source back-compat hooks */ |
| @@ -63,6 +66,11 @@ struct wireless_dev; | |||
| 63 | #define HAVE_FREE_NETDEV /* free_netdev() */ | 66 | #define HAVE_FREE_NETDEV /* free_netdev() */ |
| 64 | #define HAVE_NETDEV_PRIV /* netdev_priv() */ | 67 | #define HAVE_NETDEV_PRIV /* netdev_priv() */ |
| 65 | 68 | ||
| 69 | /* hardware address assignment types */ | ||
| 70 | #define NET_ADDR_PERM 0 /* address is permanent (default) */ | ||
| 71 | #define NET_ADDR_RANDOM 1 /* address is generated randomly */ | ||
| 72 | #define NET_ADDR_STOLEN 2 /* address is stolen from other device */ | ||
| 73 | |||
| 66 | /* Backlog congestion levels */ | 74 | /* Backlog congestion levels */ |
| 67 | #define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ | 75 | #define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ |
| 68 | #define NET_RX_DROP 1 /* packet dropped */ | 76 | #define NET_RX_DROP 1 /* packet dropped */ |
| @@ -136,7 +144,7 @@ static inline bool dev_xmit_complete(int rc) | |||
| 136 | * used. | 144 | * used. |
| 137 | */ | 145 | */ |
| 138 | 146 | ||
| 139 | #if defined(CONFIG_WLAN_80211) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) | 147 | #if defined(CONFIG_WLAN) || defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) |
| 140 | # if defined(CONFIG_MAC80211_MESH) | 148 | # if defined(CONFIG_MAC80211_MESH) |
| 141 | # define LL_MAX_HEADER 128 | 149 | # define LL_MAX_HEADER 128 |
| 142 | # else | 150 | # else |
| @@ -157,45 +165,39 @@ static inline bool dev_xmit_complete(int rc) | |||
| 157 | #define MAX_HEADER (LL_MAX_HEADER + 48) | 165 | #define MAX_HEADER (LL_MAX_HEADER + 48) |
| 158 | #endif | 166 | #endif |
| 159 | 167 | ||
| 160 | #endif /* __KERNEL__ */ | ||
| 161 | |||
| 162 | /* | 168 | /* |
| 163 | * Network device statistics. Akin to the 2.0 ether stats but | 169 | * Old network device statistics. Fields are native words |
| 164 | * with byte counters. | 170 | * (unsigned long) so they can be read and written atomically. |
| 165 | */ | 171 | */ |
| 166 | 172 | ||
| 167 | struct net_device_stats { | 173 | struct net_device_stats { |
| 168 | unsigned long rx_packets; /* total packets received */ | 174 | unsigned long rx_packets; |
| 169 | unsigned long tx_packets; /* total packets transmitted */ | 175 | unsigned long tx_packets; |
| 170 | unsigned long rx_bytes; /* total bytes received */ | 176 | unsigned long rx_bytes; |
| 171 | unsigned long tx_bytes; /* total bytes transmitted */ | 177 | unsigned long tx_bytes; |
| 172 | unsigned long rx_errors; /* bad packets received */ | 178 | unsigned long rx_errors; |
| 173 | unsigned long tx_errors; /* packet transmit problems */ | 179 | unsigned long tx_errors; |
| 174 | unsigned long rx_dropped; /* no space in linux buffers */ | 180 | unsigned long rx_dropped; |
| 175 | unsigned long tx_dropped; /* no space available in linux */ | 181 | unsigned long tx_dropped; |
| 176 | unsigned long multicast; /* multicast packets received */ | 182 | unsigned long multicast; |
| 177 | unsigned long collisions; | 183 | unsigned long collisions; |
| 178 | |||
| 179 | /* detailed rx_errors: */ | ||
| 180 | unsigned long rx_length_errors; | 184 | unsigned long rx_length_errors; |
| 181 | unsigned long rx_over_errors; /* receiver ring buff overflow */ | 185 | unsigned long rx_over_errors; |
| 182 | unsigned long rx_crc_errors; /* recved pkt with crc error */ | 186 | unsigned long rx_crc_errors; |
| 183 | unsigned long rx_frame_errors; /* recv'd frame alignment error */ | 187 | unsigned long rx_frame_errors; |
| 184 | unsigned long rx_fifo_errors; /* recv'r fifo overrun */ | 188 | unsigned long rx_fifo_errors; |
| 185 | unsigned long rx_missed_errors; /* receiver missed packet */ | 189 | unsigned long rx_missed_errors; |
| 186 | |||
| 187 | /* detailed tx_errors */ | ||
| 188 | unsigned long tx_aborted_errors; | 190 | unsigned long tx_aborted_errors; |
| 189 | unsigned long tx_carrier_errors; | 191 | unsigned long tx_carrier_errors; |
| 190 | unsigned long tx_fifo_errors; | 192 | unsigned long tx_fifo_errors; |
| 191 | unsigned long tx_heartbeat_errors; | 193 | unsigned long tx_heartbeat_errors; |
| 192 | unsigned long tx_window_errors; | 194 | unsigned long tx_window_errors; |
| 193 | |||
| 194 | /* for cslip etc */ | ||
| 195 | unsigned long rx_compressed; | 195 | unsigned long rx_compressed; |
| 196 | unsigned long tx_compressed; | 196 | unsigned long tx_compressed; |
| 197 | }; | 197 | }; |
| 198 | 198 | ||
| 199 | #endif /* __KERNEL__ */ | ||
| 200 | |||
| 199 | 201 | ||
| 200 | /* Media selection options. */ | 202 | /* Media selection options. */ |
| 201 | enum { | 203 | enum { |
| @@ -217,34 +219,6 @@ struct neighbour; | |||
| 217 | struct neigh_parms; | 219 | struct neigh_parms; |
| 218 | struct sk_buff; | 220 | struct sk_buff; |
| 219 | 221 | ||
| 220 | struct netif_rx_stats { | ||
| 221 | unsigned total; | ||
| 222 | unsigned dropped; | ||
| 223 | unsigned time_squeeze; | ||
| 224 | unsigned cpu_collision; | ||
| 225 | }; | ||
| 226 | |||
| 227 | DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat); | ||
| 228 | |||
| 229 | struct dev_addr_list { | ||
| 230 | struct dev_addr_list *next; | ||
| 231 | u8 da_addr[MAX_ADDR_LEN]; | ||
| 232 | u8 da_addrlen; | ||
| 233 | u8 da_synced; | ||
| 234 | int da_users; | ||
| 235 | int da_gusers; | ||
| 236 | }; | ||
| 237 | |||
| 238 | /* | ||
| 239 | * We tag multicasts with these structures. | ||
| 240 | */ | ||
| 241 | |||
| 242 | #define dev_mc_list dev_addr_list | ||
| 243 | #define dmi_addr da_addr | ||
| 244 | #define dmi_addrlen da_addrlen | ||
| 245 | #define dmi_users da_users | ||
| 246 | #define dmi_gusers da_gusers | ||
| 247 | |||
| 248 | struct netdev_hw_addr { | 222 | struct netdev_hw_addr { |
| 249 | struct list_head list; | 223 | struct list_head list; |
| 250 | unsigned char addr[MAX_ADDR_LEN]; | 224 | unsigned char addr[MAX_ADDR_LEN]; |
| @@ -253,8 +227,10 @@ struct netdev_hw_addr { | |||
| 253 | #define NETDEV_HW_ADDR_T_SAN 2 | 227 | #define NETDEV_HW_ADDR_T_SAN 2 |
| 254 | #define NETDEV_HW_ADDR_T_SLAVE 3 | 228 | #define NETDEV_HW_ADDR_T_SLAVE 3 |
| 255 | #define NETDEV_HW_ADDR_T_UNICAST 4 | 229 | #define NETDEV_HW_ADDR_T_UNICAST 4 |
| 230 | #define NETDEV_HW_ADDR_T_MULTICAST 5 | ||
| 256 | int refcount; | 231 | int refcount; |
| 257 | bool synced; | 232 | bool synced; |
| 233 | bool global_use; | ||
| 258 | struct rcu_head rcu_head; | 234 | struct rcu_head rcu_head; |
| 259 | }; | 235 | }; |
| 260 | 236 | ||
| @@ -263,6 +239,21 @@ struct netdev_hw_addr_list { | |||
| 263 | int count; | 239 | int count; |
| 264 | }; | 240 | }; |
| 265 | 241 | ||
| 242 | #define netdev_hw_addr_list_count(l) ((l)->count) | ||
| 243 | #define netdev_hw_addr_list_empty(l) (netdev_hw_addr_list_count(l) == 0) | ||
| 244 | #define netdev_hw_addr_list_for_each(ha, l) \ | ||
| 245 | list_for_each_entry(ha, &(l)->list, list) | ||
| 246 | |||
| 247 | #define netdev_uc_count(dev) netdev_hw_addr_list_count(&(dev)->uc) | ||
| 248 | #define netdev_uc_empty(dev) netdev_hw_addr_list_empty(&(dev)->uc) | ||
| 249 | #define netdev_for_each_uc_addr(ha, dev) \ | ||
| 250 | netdev_hw_addr_list_for_each(ha, &(dev)->uc) | ||
| 251 | |||
| 252 | #define netdev_mc_count(dev) netdev_hw_addr_list_count(&(dev)->mc) | ||
| 253 | #define netdev_mc_empty(dev) netdev_hw_addr_list_empty(&(dev)->mc) | ||
| 254 | #define netdev_for_each_mc_addr(ha, dev) \ | ||
| 255 | netdev_hw_addr_list_for_each(ha, &(dev)->mc) | ||
| 256 | |||
| 266 | struct hh_cache { | 257 | struct hh_cache { |
| 267 | struct hh_cache *hh_next; /* Next entry */ | 258 | struct hh_cache *hh_next; /* Next entry */ |
| 268 | atomic_t hh_refcnt; /* number of users */ | 259 | atomic_t hh_refcnt; /* number of users */ |
| @@ -390,6 +381,8 @@ enum gro_result { | |||
| 390 | }; | 381 | }; |
| 391 | typedef enum gro_result gro_result_t; | 382 | typedef enum gro_result gro_result_t; |
| 392 | 383 | ||
| 384 | typedef struct sk_buff *rx_handler_func_t(struct sk_buff *skb); | ||
| 385 | |||
| 393 | extern void __napi_schedule(struct napi_struct *n); | 386 | extern void __napi_schedule(struct napi_struct *n); |
| 394 | 387 | ||
| 395 | static inline int napi_disable_pending(struct napi_struct *n) | 388 | static inline int napi_disable_pending(struct napi_struct *n) |
| @@ -513,11 +506,90 @@ struct netdev_queue { | |||
| 513 | * please use this field instead of dev->trans_start | 506 | * please use this field instead of dev->trans_start |
| 514 | */ | 507 | */ |
| 515 | unsigned long trans_start; | 508 | unsigned long trans_start; |
| 516 | unsigned long tx_bytes; | 509 | u64 tx_bytes; |
| 517 | unsigned long tx_packets; | 510 | u64 tx_packets; |
| 518 | unsigned long tx_dropped; | 511 | u64 tx_dropped; |
| 519 | } ____cacheline_aligned_in_smp; | 512 | } ____cacheline_aligned_in_smp; |
| 520 | 513 | ||
| 514 | #ifdef CONFIG_RPS | ||
| 515 | /* | ||
| 516 | * This structure holds an RPS map which can be of variable length. The | ||
| 517 | * map is an array of CPUs. | ||
| 518 | */ | ||
| 519 | struct rps_map { | ||
| 520 | unsigned int len; | ||
| 521 | struct rcu_head rcu; | ||
| 522 | u16 cpus[0]; | ||
| 523 | }; | ||
| 524 | #define RPS_MAP_SIZE(_num) (sizeof(struct rps_map) + (_num * sizeof(u16))) | ||
| 525 | |||
| 526 | /* | ||
| 527 | * The rps_dev_flow structure contains the mapping of a flow to a CPU and the | ||
| 528 | * tail pointer for that CPU's input queue at the time of last enqueue. | ||
| 529 | */ | ||
| 530 | struct rps_dev_flow { | ||
| 531 | u16 cpu; | ||
| 532 | u16 fill; | ||
| 533 | unsigned int last_qtail; | ||
| 534 | }; | ||
| 535 | |||
| 536 | /* | ||
| 537 | * The rps_dev_flow_table structure contains a table of flow mappings. | ||
| 538 | */ | ||
| 539 | struct rps_dev_flow_table { | ||
| 540 | unsigned int mask; | ||
| 541 | struct rcu_head rcu; | ||
| 542 | struct work_struct free_work; | ||
| 543 | struct rps_dev_flow flows[0]; | ||
| 544 | }; | ||
| 545 | #define RPS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_dev_flow_table) + \ | ||
| 546 | (_num * sizeof(struct rps_dev_flow))) | ||
| 547 | |||
| 548 | /* | ||
| 549 | * The rps_sock_flow_table contains mappings of flows to the last CPU | ||
| 550 | * on which they were processed by the application (set in recvmsg). | ||
| 551 | */ | ||
| 552 | struct rps_sock_flow_table { | ||
| 553 | unsigned int mask; | ||
| 554 | u16 ents[0]; | ||
| 555 | }; | ||
| 556 | #define RPS_SOCK_FLOW_TABLE_SIZE(_num) (sizeof(struct rps_sock_flow_table) + \ | ||
| 557 | (_num * sizeof(u16))) | ||
| 558 | |||
| 559 | #define RPS_NO_CPU 0xffff | ||
| 560 | |||
| 561 | static inline void rps_record_sock_flow(struct rps_sock_flow_table *table, | ||
| 562 | u32 hash) | ||
| 563 | { | ||
| 564 | if (table && hash) { | ||
| 565 | unsigned int cpu, index = hash & table->mask; | ||
| 566 | |||
| 567 | /* We only give a hint, preemption can change cpu under us */ | ||
| 568 | cpu = raw_smp_processor_id(); | ||
| 569 | |||
| 570 | if (table->ents[index] != cpu) | ||
| 571 | table->ents[index] = cpu; | ||
| 572 | } | ||
| 573 | } | ||
| 574 | |||
| 575 | static inline void rps_reset_sock_flow(struct rps_sock_flow_table *table, | ||
| 576 | u32 hash) | ||
| 577 | { | ||
| 578 | if (table && hash) | ||
| 579 | table->ents[hash & table->mask] = RPS_NO_CPU; | ||
| 580 | } | ||
| 581 | |||
| 582 | extern struct rps_sock_flow_table *rps_sock_flow_table; | ||
| 583 | |||
| 584 | /* This structure contains an instance of an RX queue. */ | ||
| 585 | struct netdev_rx_queue { | ||
| 586 | struct rps_map *rps_map; | ||
| 587 | struct rps_dev_flow_table *rps_flow_table; | ||
| 588 | struct kobject kobj; | ||
| 589 | struct netdev_rx_queue *first; | ||
| 590 | atomic_t count; | ||
| 591 | } ____cacheline_aligned_in_smp; | ||
| 592 | #endif /* CONFIG_RPS */ | ||
| 521 | 593 | ||
| 522 | /* | 594 | /* |
| 523 | * This structure defines the management hooks for network devices. | 595 | * This structure defines the management hooks for network devices. |
| @@ -590,10 +662,19 @@ struct netdev_queue { | |||
| 590 | * Callback uses when the transmitter has not made any progress | 662 | * Callback uses when the transmitter has not made any progress |
| 591 | * for dev->watchdog ticks. | 663 | * for dev->watchdog ticks. |
| 592 | * | 664 | * |
| 665 | * struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, | ||
| 666 | * struct rtnl_link_stats64 *storage); | ||
| 593 | * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); | 667 | * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); |
| 594 | * Called when a user wants to get the network device usage | 668 | * Called when a user wants to get the network device usage |
| 595 | * statistics. If not defined, the counters in dev->stats will | 669 | * statistics. Drivers must do one of the following: |
| 596 | * be used. | 670 | * 1. Define @ndo_get_stats64 to fill in a zero-initialised |
| 671 | * rtnl_link_stats64 structure passed by the caller. | ||
| 672 | * 2. Define @ndo_get_stats to update a net_device_stats structure | ||
| 673 | * (which should normally be dev->stats) and return a pointer to | ||
| 674 | * it. The structure may be changed asynchronously only if each | ||
| 675 | * field is written atomically. | ||
| 676 | * 3. Update dev->stats asynchronously and atomically, and define | ||
| 677 | * neither operation. | ||
| 597 | * | 678 | * |
| 598 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); | 679 | * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); |
| 599 | * If device support VLAN receive accleration | 680 | * If device support VLAN receive accleration |
| @@ -610,6 +691,16 @@ struct netdev_queue { | |||
| 610 | * this function is called when a VLAN id is unregistered. | 691 | * this function is called when a VLAN id is unregistered. |
| 611 | * | 692 | * |
| 612 | * void (*ndo_poll_controller)(struct net_device *dev); | 693 | * void (*ndo_poll_controller)(struct net_device *dev); |
| 694 | * | ||
| 695 | * SR-IOV management functions. | ||
| 696 | * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); | ||
| 697 | * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); | ||
| 698 | * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); | ||
| 699 | * int (*ndo_get_vf_config)(struct net_device *dev, | ||
| 700 | * int vf, struct ifla_vf_info *ivf); | ||
| 701 | * int (*ndo_set_vf_port)(struct net_device *dev, int vf, | ||
| 702 | * struct nlattr *port[]); | ||
| 703 | * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); | ||
| 613 | */ | 704 | */ |
| 614 | #define HAVE_NET_DEVICE_OPS | 705 | #define HAVE_NET_DEVICE_OPS |
| 615 | struct net_device_ops { | 706 | struct net_device_ops { |
| @@ -621,32 +712,25 @@ struct net_device_ops { | |||
| 621 | struct net_device *dev); | 712 | struct net_device *dev); |
| 622 | u16 (*ndo_select_queue)(struct net_device *dev, | 713 | u16 (*ndo_select_queue)(struct net_device *dev, |
| 623 | struct sk_buff *skb); | 714 | struct sk_buff *skb); |
| 624 | #define HAVE_CHANGE_RX_FLAGS | ||
| 625 | void (*ndo_change_rx_flags)(struct net_device *dev, | 715 | void (*ndo_change_rx_flags)(struct net_device *dev, |
| 626 | int flags); | 716 | int flags); |
| 627 | #define HAVE_SET_RX_MODE | ||
| 628 | void (*ndo_set_rx_mode)(struct net_device *dev); | 717 | void (*ndo_set_rx_mode)(struct net_device *dev); |
| 629 | #define HAVE_MULTICAST | ||
| 630 | void (*ndo_set_multicast_list)(struct net_device *dev); | 718 | void (*ndo_set_multicast_list)(struct net_device *dev); |
| 631 | #define HAVE_SET_MAC_ADDR | ||
| 632 | int (*ndo_set_mac_address)(struct net_device *dev, | 719 | int (*ndo_set_mac_address)(struct net_device *dev, |
| 633 | void *addr); | 720 | void *addr); |
| 634 | #define HAVE_VALIDATE_ADDR | ||
| 635 | int (*ndo_validate_addr)(struct net_device *dev); | 721 | int (*ndo_validate_addr)(struct net_device *dev); |
| 636 | #define HAVE_PRIVATE_IOCTL | ||
| 637 | int (*ndo_do_ioctl)(struct net_device *dev, | 722 | int (*ndo_do_ioctl)(struct net_device *dev, |
| 638 | struct ifreq *ifr, int cmd); | 723 | struct ifreq *ifr, int cmd); |
| 639 | #define HAVE_SET_CONFIG | ||
| 640 | int (*ndo_set_config)(struct net_device *dev, | 724 | int (*ndo_set_config)(struct net_device *dev, |
| 641 | struct ifmap *map); | 725 | struct ifmap *map); |
| 642 | #define HAVE_CHANGE_MTU | ||
| 643 | int (*ndo_change_mtu)(struct net_device *dev, | 726 | int (*ndo_change_mtu)(struct net_device *dev, |
| 644 | int new_mtu); | 727 | int new_mtu); |
| 645 | int (*ndo_neigh_setup)(struct net_device *dev, | 728 | int (*ndo_neigh_setup)(struct net_device *dev, |
| 646 | struct neigh_parms *); | 729 | struct neigh_parms *); |
| 647 | #define HAVE_TX_TIMEOUT | ||
| 648 | void (*ndo_tx_timeout) (struct net_device *dev); | 730 | void (*ndo_tx_timeout) (struct net_device *dev); |
| 649 | 731 | ||
| 732 | struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, | ||
| 733 | struct rtnl_link_stats64 *storage); | ||
| 650 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); | 734 | struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); |
| 651 | 735 | ||
| 652 | void (*ndo_vlan_rx_register)(struct net_device *dev, | 736 | void (*ndo_vlan_rx_register)(struct net_device *dev, |
| @@ -656,9 +740,25 @@ struct net_device_ops { | |||
| 656 | void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, | 740 | void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, |
| 657 | unsigned short vid); | 741 | unsigned short vid); |
| 658 | #ifdef CONFIG_NET_POLL_CONTROLLER | 742 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 659 | #define HAVE_NETDEV_POLL | ||
| 660 | void (*ndo_poll_controller)(struct net_device *dev); | 743 | void (*ndo_poll_controller)(struct net_device *dev); |
| 744 | int (*ndo_netpoll_setup)(struct net_device *dev, | ||
| 745 | struct netpoll_info *info); | ||
| 746 | void (*ndo_netpoll_cleanup)(struct net_device *dev); | ||
| 661 | #endif | 747 | #endif |
| 748 | int (*ndo_set_vf_mac)(struct net_device *dev, | ||
| 749 | int queue, u8 *mac); | ||
| 750 | int (*ndo_set_vf_vlan)(struct net_device *dev, | ||
| 751 | int queue, u16 vlan, u8 qos); | ||
| 752 | int (*ndo_set_vf_tx_rate)(struct net_device *dev, | ||
| 753 | int vf, int rate); | ||
| 754 | int (*ndo_get_vf_config)(struct net_device *dev, | ||
| 755 | int vf, | ||
| 756 | struct ifla_vf_info *ivf); | ||
| 757 | int (*ndo_set_vf_port)(struct net_device *dev, | ||
| 758 | int vf, | ||
| 759 | struct nlattr *port[]); | ||
| 760 | int (*ndo_get_vf_port)(struct net_device *dev, | ||
| 761 | int vf, struct sk_buff *skb); | ||
| 662 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) | 762 | #if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) |
| 663 | int (*ndo_fcoe_enable)(struct net_device *dev); | 763 | int (*ndo_fcoe_enable)(struct net_device *dev); |
| 664 | int (*ndo_fcoe_disable)(struct net_device *dev); | 764 | int (*ndo_fcoe_disable)(struct net_device *dev); |
| @@ -690,9 +790,12 @@ struct net_device { | |||
| 690 | /* | 790 | /* |
| 691 | * This is the first field of the "visible" part of this structure | 791 | * This is the first field of the "visible" part of this structure |
| 692 | * (i.e. as seen by users in the "Space.c" file). It is the name | 792 | * (i.e. as seen by users in the "Space.c" file). It is the name |
| 693 | * the interface. | 793 | * of the interface. |
| 694 | */ | 794 | */ |
| 695 | char name[IFNAMSIZ]; | 795 | char name[IFNAMSIZ]; |
| 796 | |||
| 797 | struct pm_qos_request_list pm_qos_req; | ||
| 798 | |||
| 696 | /* device name hash chain */ | 799 | /* device name hash chain */ |
| 697 | struct hlist_node name_hlist; | 800 | struct hlist_node name_hlist; |
| 698 | /* snmp alias */ | 801 | /* snmp alias */ |
| @@ -745,6 +848,8 @@ struct net_device { | |||
| 745 | #define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */ | 848 | #define NETIF_F_FCOE_CRC (1 << 24) /* FCoE CRC32 */ |
| 746 | #define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */ | 849 | #define NETIF_F_SCTP_CSUM (1 << 25) /* SCTP checksum offload */ |
| 747 | #define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ | 850 | #define NETIF_F_FCOE_MTU (1 << 26) /* Supports max FCoE MTU, 2158 bytes*/ |
| 851 | #define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */ | ||
| 852 | #define NETIF_F_RXHASH (1 << 28) /* Receive hashing offload */ | ||
| 748 | 853 | ||
| 749 | /* Segmentation offload features */ | 854 | /* Segmentation offload features */ |
| 750 | #define NETIF_F_GSO_SHIFT 16 | 855 | #define NETIF_F_GSO_SHIFT 16 |
| @@ -757,7 +862,8 @@ struct net_device { | |||
| 757 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) | 862 | #define NETIF_F_FSO (SKB_GSO_FCOE << NETIF_F_GSO_SHIFT) |
| 758 | 863 | ||
| 759 | /* List of features with software fallbacks. */ | 864 | /* List of features with software fallbacks. */ |
| 760 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | NETIF_F_TSO6) | 865 | #define NETIF_F_GSO_SOFTWARE (NETIF_F_TSO | NETIF_F_TSO_ECN | \ |
| 866 | NETIF_F_TSO6 | NETIF_F_UFO) | ||
| 761 | 867 | ||
| 762 | 868 | ||
| 763 | #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) | 869 | #define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM) |
| @@ -801,7 +907,7 @@ struct net_device { | |||
| 801 | unsigned char operstate; /* RFC2863 operstate */ | 907 | unsigned char operstate; /* RFC2863 operstate */ |
| 802 | unsigned char link_mode; /* mapping policy to operstate */ | 908 | unsigned char link_mode; /* mapping policy to operstate */ |
| 803 | 909 | ||
| 804 | unsigned mtu; /* interface MTU value */ | 910 | unsigned int mtu; /* interface MTU value */ |
| 805 | unsigned short type; /* interface hardware type */ | 911 | unsigned short type; /* interface hardware type */ |
| 806 | unsigned short hard_header_len; /* hardware hdr length */ | 912 | unsigned short hard_header_len; /* hardware hdr length */ |
| 807 | 913 | ||
| @@ -818,15 +924,14 @@ struct net_device { | |||
| 818 | 924 | ||
| 819 | /* Interface address info. */ | 925 | /* Interface address info. */ |
| 820 | unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ | 926 | unsigned char perm_addr[MAX_ADDR_LEN]; /* permanent hw address */ |
| 927 | unsigned char addr_assign_type; /* hw address assignment type */ | ||
| 821 | unsigned char addr_len; /* hardware address length */ | 928 | unsigned char addr_len; /* hardware address length */ |
| 822 | unsigned short dev_id; /* for shared network cards */ | 929 | unsigned short dev_id; /* for shared network cards */ |
| 823 | 930 | ||
| 824 | struct netdev_hw_addr_list uc; /* Secondary unicast | ||
| 825 | mac addresses */ | ||
| 826 | int uc_promisc; | ||
| 827 | spinlock_t addr_list_lock; | 931 | spinlock_t addr_list_lock; |
| 828 | struct dev_addr_list *mc_list; /* Multicast mac addresses */ | 932 | struct netdev_hw_addr_list uc; /* Unicast mac addresses */ |
| 829 | int mc_count; /* Number of installed mcasts */ | 933 | struct netdev_hw_addr_list mc; /* Multicast mac addresses */ |
| 934 | int uc_promisc; | ||
| 830 | unsigned int promiscuity; | 935 | unsigned int promiscuity; |
| 831 | unsigned int allmulti; | 936 | unsigned int allmulti; |
| 832 | 937 | ||
| @@ -859,7 +964,18 @@ struct net_device { | |||
| 859 | 964 | ||
| 860 | unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ | 965 | unsigned char broadcast[MAX_ADDR_LEN]; /* hw bcast add */ |
| 861 | 966 | ||
| 967 | #ifdef CONFIG_RPS | ||
| 968 | struct kset *queues_kset; | ||
| 969 | |||
| 970 | struct netdev_rx_queue *_rx; | ||
| 971 | |||
| 972 | /* Number of RX queues allocated at alloc_netdev_mq() time */ | ||
| 973 | unsigned int num_rx_queues; | ||
| 974 | #endif | ||
| 975 | |||
| 862 | struct netdev_queue rx_queue; | 976 | struct netdev_queue rx_queue; |
| 977 | rx_handler_func_t *rx_handler; | ||
| 978 | void *rx_handler_data; | ||
| 863 | 979 | ||
| 864 | struct netdev_queue *_tx ____cacheline_aligned_in_smp; | 980 | struct netdev_queue *_tx ____cacheline_aligned_in_smp; |
| 865 | 981 | ||
| @@ -905,7 +1021,12 @@ struct net_device { | |||
| 905 | NETREG_UNREGISTERED, /* completed unregister todo */ | 1021 | NETREG_UNREGISTERED, /* completed unregister todo */ |
| 906 | NETREG_RELEASED, /* called free_netdev */ | 1022 | NETREG_RELEASED, /* called free_netdev */ |
| 907 | NETREG_DUMMY, /* dummy device for NAPI poll */ | 1023 | NETREG_DUMMY, /* dummy device for NAPI poll */ |
| 908 | } reg_state; | 1024 | } reg_state:16; |
| 1025 | |||
| 1026 | enum { | ||
| 1027 | RTNL_LINK_INITIALIZED, | ||
| 1028 | RTNL_LINK_INITIALIZING, | ||
| 1029 | } rtnl_link_state:16; | ||
| 909 | 1030 | ||
| 910 | /* Called from unregister, can be used to call free_netdev */ | 1031 | /* Called from unregister, can be used to call free_netdev */ |
| 911 | void (*destructor)(struct net_device *dev); | 1032 | void (*destructor)(struct net_device *dev); |
| @@ -922,10 +1043,6 @@ struct net_device { | |||
| 922 | /* mid-layer private */ | 1043 | /* mid-layer private */ |
| 923 | void *ml_priv; | 1044 | void *ml_priv; |
| 924 | 1045 | ||
| 925 | /* bridge stuff */ | ||
| 926 | struct net_bridge_port *br_port; | ||
| 927 | /* macvlan */ | ||
| 928 | struct macvlan_port *macvlan_port; | ||
| 929 | /* GARP */ | 1046 | /* GARP */ |
| 930 | struct garp_port *garp_port; | 1047 | struct garp_port *garp_port; |
| 931 | 1048 | ||
| @@ -953,6 +1070,11 @@ struct net_device { | |||
| 953 | /* max exchange id for FCoE LRO by ddp */ | 1070 | /* max exchange id for FCoE LRO by ddp */ |
| 954 | unsigned int fcoe_ddp_xid; | 1071 | unsigned int fcoe_ddp_xid; |
| 955 | #endif | 1072 | #endif |
| 1073 | /* n-tuple filter list attached to this device */ | ||
| 1074 | struct ethtool_rx_ntuple_list ethtool_ntuple_list; | ||
| 1075 | |||
| 1076 | /* phy device may attach itself for hardware timestamping */ | ||
| 1077 | struct phy_device *phydev; | ||
| 956 | }; | 1078 | }; |
| 957 | #define to_net_dev(d) container_of(d, struct net_device, dev) | 1079 | #define to_net_dev(d) container_of(d, struct net_device, dev) |
| 958 | 1080 | ||
| @@ -983,11 +1105,7 @@ static inline void netdev_for_each_tx_queue(struct net_device *dev, | |||
| 983 | static inline | 1105 | static inline |
| 984 | struct net *dev_net(const struct net_device *dev) | 1106 | struct net *dev_net(const struct net_device *dev) |
| 985 | { | 1107 | { |
| 986 | #ifdef CONFIG_NET_NS | 1108 | return read_pnet(&dev->nd_net); |
| 987 | return dev->nd_net; | ||
| 988 | #else | ||
| 989 | return &init_net; | ||
| 990 | #endif | ||
| 991 | } | 1109 | } |
| 992 | 1110 | ||
| 993 | static inline | 1111 | static inline |
| @@ -1009,6 +1127,15 @@ static inline bool netdev_uses_dsa_tags(struct net_device *dev) | |||
| 1009 | return 0; | 1127 | return 0; |
| 1010 | } | 1128 | } |
| 1011 | 1129 | ||
| 1130 | #ifndef CONFIG_NET_NS | ||
| 1131 | static inline void skb_set_dev(struct sk_buff *skb, struct net_device *dev) | ||
| 1132 | { | ||
| 1133 | skb->dev = dev; | ||
| 1134 | } | ||
| 1135 | #else /* CONFIG_NET_NS */ | ||
| 1136 | void skb_set_dev(struct sk_buff *skb, struct net_device *dev); | ||
| 1137 | #endif | ||
| 1138 | |||
| 1012 | static inline bool netdev_uses_trailer_tags(struct net_device *dev) | 1139 | static inline bool netdev_uses_trailer_tags(struct net_device *dev) |
| 1013 | { | 1140 | { |
| 1014 | #ifdef CONFIG_NET_DSA_TAG_TRAILER | 1141 | #ifdef CONFIG_NET_DSA_TAG_TRAILER |
| @@ -1159,8 +1286,8 @@ extern void dev_add_pack(struct packet_type *pt); | |||
| 1159 | extern void dev_remove_pack(struct packet_type *pt); | 1286 | extern void dev_remove_pack(struct packet_type *pt); |
| 1160 | extern void __dev_remove_pack(struct packet_type *pt); | 1287 | extern void __dev_remove_pack(struct packet_type *pt); |
| 1161 | 1288 | ||
| 1162 | extern struct net_device *dev_get_by_flags(struct net *net, unsigned short flags, | 1289 | extern struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags, |
| 1163 | unsigned short mask); | 1290 | unsigned short mask); |
| 1164 | extern struct net_device *dev_get_by_name(struct net *net, const char *name); | 1291 | extern struct net_device *dev_get_by_name(struct net *net, const char *name); |
| 1165 | extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name); | 1292 | extern struct net_device *dev_get_by_name_rcu(struct net *net, const char *name); |
| 1166 | extern struct net_device *__dev_get_by_name(struct net *net, const char *name); | 1293 | extern struct net_device *__dev_get_by_name(struct net *net, const char *name); |
| @@ -1271,19 +1398,52 @@ static inline int unregister_gifconf(unsigned int family) | |||
| 1271 | } | 1398 | } |
| 1272 | 1399 | ||
| 1273 | /* | 1400 | /* |
| 1274 | * Incoming packets are placed on per-cpu queues so that | 1401 | * Incoming packets are placed on per-cpu queues |
| 1275 | * no locking is needed. | ||
| 1276 | */ | 1402 | */ |
| 1277 | struct softnet_data { | 1403 | struct softnet_data { |
| 1278 | struct Qdisc *output_queue; | 1404 | struct Qdisc *output_queue; |
| 1279 | struct sk_buff_head input_pkt_queue; | 1405 | struct Qdisc **output_queue_tailp; |
| 1280 | struct list_head poll_list; | 1406 | struct list_head poll_list; |
| 1281 | struct sk_buff *completion_queue; | 1407 | struct sk_buff *completion_queue; |
| 1282 | 1408 | struct sk_buff_head process_queue; | |
| 1409 | |||
| 1410 | /* stats */ | ||
| 1411 | unsigned int processed; | ||
| 1412 | unsigned int time_squeeze; | ||
| 1413 | unsigned int cpu_collision; | ||
| 1414 | unsigned int received_rps; | ||
| 1415 | |||
| 1416 | #ifdef CONFIG_RPS | ||
| 1417 | struct softnet_data *rps_ipi_list; | ||
| 1418 | |||
| 1419 | /* Elements below can be accessed between CPUs for RPS */ | ||
| 1420 | struct call_single_data csd ____cacheline_aligned_in_smp; | ||
| 1421 | struct softnet_data *rps_ipi_next; | ||
| 1422 | unsigned int cpu; | ||
| 1423 | unsigned int input_queue_head; | ||
| 1424 | unsigned int input_queue_tail; | ||
| 1425 | #endif | ||
| 1426 | unsigned dropped; | ||
| 1427 | struct sk_buff_head input_pkt_queue; | ||
| 1283 | struct napi_struct backlog; | 1428 | struct napi_struct backlog; |
| 1284 | }; | 1429 | }; |
| 1285 | 1430 | ||
| 1286 | DECLARE_PER_CPU(struct softnet_data,softnet_data); | 1431 | static inline void input_queue_head_incr(struct softnet_data *sd) |
| 1432 | { | ||
| 1433 | #ifdef CONFIG_RPS | ||
| 1434 | sd->input_queue_head++; | ||
| 1435 | #endif | ||
| 1436 | } | ||
| 1437 | |||
| 1438 | static inline void input_queue_tail_incr_save(struct softnet_data *sd, | ||
| 1439 | unsigned int *qtail) | ||
| 1440 | { | ||
| 1441 | #ifdef CONFIG_RPS | ||
| 1442 | *qtail = ++sd->input_queue_tail; | ||
| 1443 | #endif | ||
| 1444 | } | ||
| 1445 | |||
| 1446 | DECLARE_PER_CPU_ALIGNED(struct softnet_data, softnet_data); | ||
| 1287 | 1447 | ||
| 1288 | #define HAVE_NETIF_QUEUE | 1448 | #define HAVE_NETIF_QUEUE |
| 1289 | 1449 | ||
| @@ -1510,6 +1670,9 @@ static inline int netif_is_multiqueue(const struct net_device *dev) | |||
| 1510 | return (dev->num_tx_queues > 1); | 1670 | return (dev->num_tx_queues > 1); |
| 1511 | } | 1671 | } |
| 1512 | 1672 | ||
| 1673 | extern void netif_set_real_num_tx_queues(struct net_device *dev, | ||
| 1674 | unsigned int txq); | ||
| 1675 | |||
| 1513 | /* Use this variant when it is known for sure that it | 1676 | /* Use this variant when it is known for sure that it |
| 1514 | * is executing from hardware interrupt context or with hardware interrupts | 1677 | * is executing from hardware interrupt context or with hardware interrupts |
| 1515 | * disabled. | 1678 | * disabled. |
| @@ -1527,7 +1690,6 @@ extern int netif_rx(struct sk_buff *skb); | |||
| 1527 | extern int netif_rx_ni(struct sk_buff *skb); | 1690 | extern int netif_rx_ni(struct sk_buff *skb); |
| 1528 | #define HAVE_NETIF_RECEIVE_SKB 1 | 1691 | #define HAVE_NETIF_RECEIVE_SKB 1 |
| 1529 | extern int netif_receive_skb(struct sk_buff *skb); | 1692 | extern int netif_receive_skb(struct sk_buff *skb); |
| 1530 | extern void napi_gro_flush(struct napi_struct *napi); | ||
| 1531 | extern gro_result_t dev_gro_receive(struct napi_struct *napi, | 1693 | extern gro_result_t dev_gro_receive(struct napi_struct *napi, |
| 1532 | struct sk_buff *skb); | 1694 | struct sk_buff *skb); |
| 1533 | extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); | 1695 | extern gro_result_t napi_skb_finish(gro_result_t ret, struct sk_buff *skb); |
| @@ -1548,12 +1710,19 @@ static inline void napi_free_frags(struct napi_struct *napi) | |||
| 1548 | napi->skb = NULL; | 1710 | napi->skb = NULL; |
| 1549 | } | 1711 | } |
| 1550 | 1712 | ||
| 1713 | extern int netdev_rx_handler_register(struct net_device *dev, | ||
| 1714 | rx_handler_func_t *rx_handler, | ||
| 1715 | void *rx_handler_data); | ||
| 1716 | extern void netdev_rx_handler_unregister(struct net_device *dev); | ||
| 1717 | |||
| 1551 | extern void netif_nit_deliver(struct sk_buff *skb); | 1718 | extern void netif_nit_deliver(struct sk_buff *skb); |
| 1552 | extern int dev_valid_name(const char *name); | 1719 | extern int dev_valid_name(const char *name); |
| 1553 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); | 1720 | extern int dev_ioctl(struct net *net, unsigned int cmd, void __user *); |
| 1554 | extern int dev_ethtool(struct net *net, struct ifreq *); | 1721 | extern int dev_ethtool(struct net *net, struct ifreq *); |
| 1555 | extern unsigned dev_get_flags(const struct net_device *); | 1722 | extern unsigned dev_get_flags(const struct net_device *); |
| 1723 | extern int __dev_change_flags(struct net_device *, unsigned int flags); | ||
| 1556 | extern int dev_change_flags(struct net_device *, unsigned); | 1724 | extern int dev_change_flags(struct net_device *, unsigned); |
| 1725 | extern void __dev_notify_flags(struct net_device *, unsigned int old_flags); | ||
| 1557 | extern int dev_change_name(struct net_device *, const char *); | 1726 | extern int dev_change_name(struct net_device *, const char *); |
| 1558 | extern int dev_set_alias(struct net_device *, const char *, size_t); | 1727 | extern int dev_set_alias(struct net_device *, const char *, size_t); |
| 1559 | extern int dev_change_net_namespace(struct net_device *, | 1728 | extern int dev_change_net_namespace(struct net_device *, |
| @@ -1625,6 +1794,8 @@ extern void netif_carrier_on(struct net_device *dev); | |||
| 1625 | 1794 | ||
| 1626 | extern void netif_carrier_off(struct net_device *dev); | 1795 | extern void netif_carrier_off(struct net_device *dev); |
| 1627 | 1796 | ||
| 1797 | extern void netif_notify_peers(struct net_device *dev); | ||
| 1798 | |||
| 1628 | /** | 1799 | /** |
| 1629 | * netif_dormant_on - mark device as dormant. | 1800 | * netif_dormant_on - mark device as dormant. |
| 1630 | * @dev: network device | 1801 | * @dev: network device |
| @@ -1909,6 +2080,22 @@ extern struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name, | |||
| 1909 | extern int register_netdev(struct net_device *dev); | 2080 | extern int register_netdev(struct net_device *dev); |
| 1910 | extern void unregister_netdev(struct net_device *dev); | 2081 | extern void unregister_netdev(struct net_device *dev); |
| 1911 | 2082 | ||
| 2083 | /* General hardware address lists handling functions */ | ||
| 2084 | extern int __hw_addr_add_multiple(struct netdev_hw_addr_list *to_list, | ||
| 2085 | struct netdev_hw_addr_list *from_list, | ||
| 2086 | int addr_len, unsigned char addr_type); | ||
| 2087 | extern void __hw_addr_del_multiple(struct netdev_hw_addr_list *to_list, | ||
| 2088 | struct netdev_hw_addr_list *from_list, | ||
| 2089 | int addr_len, unsigned char addr_type); | ||
| 2090 | extern int __hw_addr_sync(struct netdev_hw_addr_list *to_list, | ||
| 2091 | struct netdev_hw_addr_list *from_list, | ||
| 2092 | int addr_len); | ||
| 2093 | extern void __hw_addr_unsync(struct netdev_hw_addr_list *to_list, | ||
| 2094 | struct netdev_hw_addr_list *from_list, | ||
| 2095 | int addr_len); | ||
| 2096 | extern void __hw_addr_flush(struct netdev_hw_addr_list *list); | ||
| 2097 | extern void __hw_addr_init(struct netdev_hw_addr_list *list); | ||
| 2098 | |||
| 1912 | /* Functions used for device addresses handling */ | 2099 | /* Functions used for device addresses handling */ |
| 1913 | extern int dev_addr_add(struct net_device *dev, unsigned char *addr, | 2100 | extern int dev_addr_add(struct net_device *dev, unsigned char *addr, |
| 1914 | unsigned char addr_type); | 2101 | unsigned char addr_type); |
| @@ -1920,35 +2107,46 @@ extern int dev_addr_add_multiple(struct net_device *to_dev, | |||
| 1920 | extern int dev_addr_del_multiple(struct net_device *to_dev, | 2107 | extern int dev_addr_del_multiple(struct net_device *to_dev, |
| 1921 | struct net_device *from_dev, | 2108 | struct net_device *from_dev, |
| 1922 | unsigned char addr_type); | 2109 | unsigned char addr_type); |
| 2110 | extern void dev_addr_flush(struct net_device *dev); | ||
| 2111 | extern int dev_addr_init(struct net_device *dev); | ||
| 2112 | |||
| 2113 | /* Functions used for unicast addresses handling */ | ||
| 2114 | extern int dev_uc_add(struct net_device *dev, unsigned char *addr); | ||
| 2115 | extern int dev_uc_del(struct net_device *dev, unsigned char *addr); | ||
| 2116 | extern int dev_uc_sync(struct net_device *to, struct net_device *from); | ||
| 2117 | extern void dev_uc_unsync(struct net_device *to, struct net_device *from); | ||
| 2118 | extern void dev_uc_flush(struct net_device *dev); | ||
| 2119 | extern void dev_uc_init(struct net_device *dev); | ||
| 2120 | |||
| 2121 | /* Functions used for multicast addresses handling */ | ||
| 2122 | extern int dev_mc_add(struct net_device *dev, unsigned char *addr); | ||
| 2123 | extern int dev_mc_add_global(struct net_device *dev, unsigned char *addr); | ||
| 2124 | extern int dev_mc_del(struct net_device *dev, unsigned char *addr); | ||
| 2125 | extern int dev_mc_del_global(struct net_device *dev, unsigned char *addr); | ||
| 2126 | extern int dev_mc_sync(struct net_device *to, struct net_device *from); | ||
| 2127 | extern void dev_mc_unsync(struct net_device *to, struct net_device *from); | ||
| 2128 | extern void dev_mc_flush(struct net_device *dev); | ||
| 2129 | extern void dev_mc_init(struct net_device *dev); | ||
| 1923 | 2130 | ||
| 1924 | /* Functions used for secondary unicast and multicast support */ | 2131 | /* Functions used for secondary unicast and multicast support */ |
| 1925 | extern void dev_set_rx_mode(struct net_device *dev); | 2132 | extern void dev_set_rx_mode(struct net_device *dev); |
| 1926 | extern void __dev_set_rx_mode(struct net_device *dev); | 2133 | extern void __dev_set_rx_mode(struct net_device *dev); |
| 1927 | extern int dev_unicast_delete(struct net_device *dev, void *addr); | ||
| 1928 | extern int dev_unicast_add(struct net_device *dev, void *addr); | ||
| 1929 | extern int dev_unicast_sync(struct net_device *to, struct net_device *from); | ||
| 1930 | extern void dev_unicast_unsync(struct net_device *to, struct net_device *from); | ||
| 1931 | extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all); | ||
| 1932 | extern int dev_mc_add(struct net_device *dev, void *addr, int alen, int newonly); | ||
| 1933 | extern int dev_mc_sync(struct net_device *to, struct net_device *from); | ||
| 1934 | extern void dev_mc_unsync(struct net_device *to, struct net_device *from); | ||
| 1935 | extern int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int all); | ||
| 1936 | extern int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int newonly); | ||
| 1937 | extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); | ||
| 1938 | extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); | ||
| 1939 | extern int dev_set_promiscuity(struct net_device *dev, int inc); | 2134 | extern int dev_set_promiscuity(struct net_device *dev, int inc); |
| 1940 | extern int dev_set_allmulti(struct net_device *dev, int inc); | 2135 | extern int dev_set_allmulti(struct net_device *dev, int inc); |
| 1941 | extern void netdev_state_change(struct net_device *dev); | 2136 | extern void netdev_state_change(struct net_device *dev); |
| 1942 | extern void netdev_bonding_change(struct net_device *dev, | 2137 | extern int netdev_bonding_change(struct net_device *dev, |
| 1943 | unsigned long event); | 2138 | unsigned long event); |
| 1944 | extern void netdev_features_change(struct net_device *dev); | 2139 | extern void netdev_features_change(struct net_device *dev); |
| 1945 | /* Load a device via the kmod */ | 2140 | /* Load a device via the kmod */ |
| 1946 | extern void dev_load(struct net *net, const char *name); | 2141 | extern void dev_load(struct net *net, const char *name); |
| 1947 | extern void dev_mcast_init(void); | 2142 | extern void dev_mcast_init(void); |
| 1948 | extern const struct net_device_stats *dev_get_stats(struct net_device *dev); | 2143 | extern struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev, |
| 1949 | extern void dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats); | 2144 | struct rtnl_link_stats64 *storage); |
| 2145 | extern void dev_txq_stats_fold(const struct net_device *dev, | ||
| 2146 | struct rtnl_link_stats64 *stats); | ||
| 1950 | 2147 | ||
| 1951 | extern int netdev_max_backlog; | 2148 | extern int netdev_max_backlog; |
| 2149 | extern int netdev_tstamp_prequeue; | ||
| 1952 | extern int weight_p; | 2150 | extern int weight_p; |
| 1953 | extern int netdev_set_master(struct net_device *dev, struct net_device *master); | 2151 | extern int netdev_set_master(struct net_device *dev, struct net_device *master); |
| 1954 | extern int skb_checksum_help(struct sk_buff *skb); | 2152 | extern int skb_checksum_help(struct sk_buff *skb); |
| @@ -2009,54 +2207,14 @@ static inline void netif_set_gso_max_size(struct net_device *dev, | |||
| 2009 | dev->gso_max_size = size; | 2207 | dev->gso_max_size = size; |
| 2010 | } | 2208 | } |
| 2011 | 2209 | ||
| 2012 | static inline void skb_bond_set_mac_by_master(struct sk_buff *skb, | 2210 | extern int __skb_bond_should_drop(struct sk_buff *skb, |
| 2013 | struct net_device *master) | 2211 | struct net_device *master); |
| 2014 | { | ||
| 2015 | if (skb->pkt_type == PACKET_HOST) { | ||
| 2016 | u16 *dest = (u16 *) eth_hdr(skb)->h_dest; | ||
| 2017 | |||
| 2018 | memcpy(dest, master->dev_addr, ETH_ALEN); | ||
| 2019 | } | ||
| 2020 | } | ||
| 2021 | 2212 | ||
| 2022 | /* On bonding slaves other than the currently active slave, suppress | 2213 | static inline int skb_bond_should_drop(struct sk_buff *skb, |
| 2023 | * duplicates except for 802.3ad ETH_P_SLOW, alb non-mcast/bcast, and | 2214 | struct net_device *master) |
| 2024 | * ARP on active-backup slaves with arp_validate enabled. | 2215 | { |
| 2025 | */ | 2216 | if (master) |
| 2026 | static inline int skb_bond_should_drop(struct sk_buff *skb) | 2217 | return __skb_bond_should_drop(skb, master); |
| 2027 | { | ||
| 2028 | struct net_device *dev = skb->dev; | ||
| 2029 | struct net_device *master = dev->master; | ||
| 2030 | |||
| 2031 | if (master) { | ||
| 2032 | if (master->priv_flags & IFF_MASTER_ARPMON) | ||
| 2033 | dev->last_rx = jiffies; | ||
| 2034 | |||
| 2035 | if ((master->priv_flags & IFF_MASTER_ALB) && master->br_port) { | ||
| 2036 | /* Do address unmangle. The local destination address | ||
| 2037 | * will be always the one master has. Provides the right | ||
| 2038 | * functionality in a bridge. | ||
| 2039 | */ | ||
| 2040 | skb_bond_set_mac_by_master(skb, master); | ||
| 2041 | } | ||
| 2042 | |||
| 2043 | if (dev->priv_flags & IFF_SLAVE_INACTIVE) { | ||
| 2044 | if ((dev->priv_flags & IFF_SLAVE_NEEDARP) && | ||
| 2045 | skb->protocol == __cpu_to_be16(ETH_P_ARP)) | ||
| 2046 | return 0; | ||
| 2047 | |||
| 2048 | if (master->priv_flags & IFF_MASTER_ALB) { | ||
| 2049 | if (skb->pkt_type != PACKET_BROADCAST && | ||
| 2050 | skb->pkt_type != PACKET_MULTICAST) | ||
| 2051 | return 0; | ||
| 2052 | } | ||
| 2053 | if (master->priv_flags & IFF_MASTER_8023AD && | ||
| 2054 | skb->protocol == __cpu_to_be16(ETH_P_SLOW)) | ||
| 2055 | return 0; | ||
| 2056 | |||
| 2057 | return 1; | ||
| 2058 | } | ||
| 2059 | } | ||
| 2060 | return 0; | 2218 | return 0; |
| 2061 | } | 2219 | } |
| 2062 | 2220 | ||
| @@ -2083,6 +2241,134 @@ static inline u32 dev_ethtool_get_flags(struct net_device *dev) | |||
| 2083 | return 0; | 2241 | return 0; |
| 2084 | return dev->ethtool_ops->get_flags(dev); | 2242 | return dev->ethtool_ops->get_flags(dev); |
| 2085 | } | 2243 | } |
| 2244 | |||
| 2245 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ | ||
| 2246 | |||
| 2247 | /* netdev_printk helpers, similar to dev_printk */ | ||
| 2248 | |||
| 2249 | static inline const char *netdev_name(const struct net_device *dev) | ||
| 2250 | { | ||
| 2251 | if (dev->reg_state != NETREG_REGISTERED) | ||
| 2252 | return "(unregistered net_device)"; | ||
| 2253 | return dev->name; | ||
| 2254 | } | ||
| 2255 | |||
| 2256 | extern int netdev_printk(const char *level, const struct net_device *dev, | ||
| 2257 | const char *format, ...) | ||
| 2258 | __attribute__ ((format (printf, 3, 4))); | ||
| 2259 | extern int netdev_emerg(const struct net_device *dev, const char *format, ...) | ||
| 2260 | __attribute__ ((format (printf, 2, 3))); | ||
| 2261 | extern int netdev_alert(const struct net_device *dev, const char *format, ...) | ||
| 2262 | __attribute__ ((format (printf, 2, 3))); | ||
| 2263 | extern int netdev_crit(const struct net_device *dev, const char *format, ...) | ||
| 2264 | __attribute__ ((format (printf, 2, 3))); | ||
| 2265 | extern int netdev_err(const struct net_device *dev, const char *format, ...) | ||
| 2266 | __attribute__ ((format (printf, 2, 3))); | ||
| 2267 | extern int netdev_warn(const struct net_device *dev, const char *format, ...) | ||
| 2268 | __attribute__ ((format (printf, 2, 3))); | ||
| 2269 | extern int netdev_notice(const struct net_device *dev, const char *format, ...) | ||
| 2270 | __attribute__ ((format (printf, 2, 3))); | ||
| 2271 | extern int netdev_info(const struct net_device *dev, const char *format, ...) | ||
| 2272 | __attribute__ ((format (printf, 2, 3))); | ||
| 2273 | |||
| 2274 | #if defined(DEBUG) | ||
| 2275 | #define netdev_dbg(__dev, format, args...) \ | ||
| 2276 | netdev_printk(KERN_DEBUG, __dev, format, ##args) | ||
| 2277 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
| 2278 | #define netdev_dbg(__dev, format, args...) \ | ||
| 2279 | do { \ | ||
| 2280 | dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \ | ||
| 2281 | netdev_name(__dev), ##args); \ | ||
| 2282 | } while (0) | ||
| 2283 | #else | ||
| 2284 | #define netdev_dbg(__dev, format, args...) \ | ||
| 2285 | ({ \ | ||
| 2286 | if (0) \ | ||
| 2287 | netdev_printk(KERN_DEBUG, __dev, format, ##args); \ | ||
| 2288 | 0; \ | ||
| 2289 | }) | ||
| 2290 | #endif | ||
| 2291 | |||
| 2292 | #if defined(VERBOSE_DEBUG) | ||
| 2293 | #define netdev_vdbg netdev_dbg | ||
| 2294 | #else | ||
| 2295 | |||
| 2296 | #define netdev_vdbg(dev, format, args...) \ | ||
| 2297 | ({ \ | ||
| 2298 | if (0) \ | ||
| 2299 | netdev_printk(KERN_DEBUG, dev, format, ##args); \ | ||
| 2300 | 0; \ | ||
| 2301 | }) | ||
| 2302 | #endif | ||
| 2303 | |||
| 2304 | /* | ||
| 2305 | * netdev_WARN() acts like dev_printk(), but with the key difference | ||
| 2306 | * of using a WARN/WARN_ON to get the message out, including the | ||
| 2307 | * file/line information and a backtrace. | ||
| 2308 | */ | ||
| 2309 | #define netdev_WARN(dev, format, args...) \ | ||
| 2310 | WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args); | ||
| 2311 | |||
| 2312 | /* netif printk helpers, similar to netdev_printk */ | ||
| 2313 | |||
| 2314 | #define netif_printk(priv, type, level, dev, fmt, args...) \ | ||
| 2315 | do { \ | ||
| 2316 | if (netif_msg_##type(priv)) \ | ||
| 2317 | netdev_printk(level, (dev), fmt, ##args); \ | ||
| 2318 | } while (0) | ||
| 2319 | |||
| 2320 | #define netif_level(level, priv, type, dev, fmt, args...) \ | ||
| 2321 | do { \ | ||
| 2322 | if (netif_msg_##type(priv)) \ | ||
| 2323 | netdev_##level(dev, fmt, ##args); \ | ||
| 2324 | } while (0) | ||
| 2325 | |||
| 2326 | #define netif_emerg(priv, type, dev, fmt, args...) \ | ||
| 2327 | netif_level(emerg, priv, type, dev, fmt, ##args) | ||
| 2328 | #define netif_alert(priv, type, dev, fmt, args...) \ | ||
| 2329 | netif_level(alert, priv, type, dev, fmt, ##args) | ||
| 2330 | #define netif_crit(priv, type, dev, fmt, args...) \ | ||
| 2331 | netif_level(crit, priv, type, dev, fmt, ##args) | ||
| 2332 | #define netif_err(priv, type, dev, fmt, args...) \ | ||
| 2333 | netif_level(err, priv, type, dev, fmt, ##args) | ||
| 2334 | #define netif_warn(priv, type, dev, fmt, args...) \ | ||
| 2335 | netif_level(warn, priv, type, dev, fmt, ##args) | ||
| 2336 | #define netif_notice(priv, type, dev, fmt, args...) \ | ||
| 2337 | netif_level(notice, priv, type, dev, fmt, ##args) | ||
| 2338 | #define netif_info(priv, type, dev, fmt, args...) \ | ||
| 2339 | netif_level(info, priv, type, dev, fmt, ##args) | ||
| 2340 | |||
| 2341 | #if defined(DEBUG) | ||
| 2342 | #define netif_dbg(priv, type, dev, format, args...) \ | ||
| 2343 | netif_printk(priv, type, KERN_DEBUG, dev, format, ##args) | ||
| 2344 | #elif defined(CONFIG_DYNAMIC_DEBUG) | ||
| 2345 | #define netif_dbg(priv, type, netdev, format, args...) \ | ||
| 2346 | do { \ | ||
| 2347 | if (netif_msg_##type(priv)) \ | ||
| 2348 | dynamic_dev_dbg((netdev)->dev.parent, \ | ||
| 2349 | "%s: " format, \ | ||
| 2350 | netdev_name(netdev), ##args); \ | ||
| 2351 | } while (0) | ||
| 2352 | #else | ||
| 2353 | #define netif_dbg(priv, type, dev, format, args...) \ | ||
| 2354 | ({ \ | ||
| 2355 | if (0) \ | ||
| 2356 | netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \ | ||
| 2357 | 0; \ | ||
| 2358 | }) | ||
| 2359 | #endif | ||
| 2360 | |||
| 2361 | #if defined(VERBOSE_DEBUG) | ||
| 2362 | #define netif_vdbg netif_dbg | ||
| 2363 | #else | ||
| 2364 | #define netif_vdbg(priv, type, dev, format, args...) \ | ||
| 2365 | ({ \ | ||
| 2366 | if (0) \ | ||
| 2367 | netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \ | ||
| 2368 | 0; \ | ||
| 2369 | }) | ||
| 2370 | #endif | ||
| 2371 | |||
| 2086 | #endif /* __KERNEL__ */ | 2372 | #endif /* __KERNEL__ */ |
| 2087 | 2373 | ||
| 2088 | #endif /* _LINUX_NETDEVICE_H */ | 2374 | #endif /* _LINUX_NETDEVICE_H */ |
