diff options
Diffstat (limited to 'include/linux/netdevice.h')
| -rw-r--r-- | include/linux/netdevice.h | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7fda03d338d1..950dc55e5192 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
| @@ -230,7 +230,8 @@ enum netdev_state_t | |||
| 230 | __LINK_STATE_SCHED, | 230 | __LINK_STATE_SCHED, |
| 231 | __LINK_STATE_NOCARRIER, | 231 | __LINK_STATE_NOCARRIER, |
| 232 | __LINK_STATE_RX_SCHED, | 232 | __LINK_STATE_RX_SCHED, |
| 233 | __LINK_STATE_LINKWATCH_PENDING | 233 | __LINK_STATE_LINKWATCH_PENDING, |
| 234 | __LINK_STATE_DORMANT, | ||
| 234 | }; | 235 | }; |
| 235 | 236 | ||
| 236 | 237 | ||
| @@ -335,11 +336,14 @@ struct net_device | |||
| 335 | */ | 336 | */ |
| 336 | 337 | ||
| 337 | 338 | ||
| 338 | unsigned short flags; /* interface flags (a la BSD) */ | 339 | unsigned int flags; /* interface flags (a la BSD) */ |
| 339 | unsigned short gflags; | 340 | unsigned short gflags; |
| 340 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ | 341 | unsigned short priv_flags; /* Like 'flags' but invisible to userspace. */ |
| 341 | unsigned short padded; /* How much padding added by alloc_netdev() */ | 342 | unsigned short padded; /* How much padding added by alloc_netdev() */ |
| 342 | 343 | ||
| 344 | unsigned char operstate; /* RFC2863 operstate */ | ||
| 345 | unsigned char link_mode; /* mapping policy to operstate */ | ||
| 346 | |||
| 343 | unsigned mtu; /* interface MTU value */ | 347 | unsigned mtu; /* interface MTU value */ |
| 344 | unsigned short type; /* interface hardware type */ | 348 | unsigned short type; /* interface hardware type */ |
| 345 | unsigned short hard_header_len; /* hardware hdr length */ | 349 | unsigned short hard_header_len; /* hardware hdr length */ |
| @@ -708,12 +712,18 @@ static inline void dev_put(struct net_device *dev) | |||
| 708 | atomic_dec(&dev->refcnt); | 712 | atomic_dec(&dev->refcnt); |
| 709 | } | 713 | } |
| 710 | 714 | ||
| 711 | #define __dev_put(dev) atomic_dec(&(dev)->refcnt) | 715 | static inline void dev_hold(struct net_device *dev) |
| 712 | #define dev_hold(dev) atomic_inc(&(dev)->refcnt) | 716 | { |
| 717 | atomic_inc(&dev->refcnt); | ||
| 718 | } | ||
| 713 | 719 | ||
| 714 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on | 720 | /* Carrier loss detection, dial on demand. The functions netif_carrier_on |
| 715 | * and _off may be called from IRQ context, but it is caller | 721 | * and _off may be called from IRQ context, but it is caller |
| 716 | * who is responsible for serialization of these calls. | 722 | * who is responsible for serialization of these calls. |
| 723 | * | ||
| 724 | * The name carrier is inappropriate, these functions should really be | ||
| 725 | * called netif_lowerlayer_*() because they represent the state of any | ||
| 726 | * kind of lower layer not just hardware media. | ||
| 717 | */ | 727 | */ |
| 718 | 728 | ||
| 719 | extern void linkwatch_fire_event(struct net_device *dev); | 729 | extern void linkwatch_fire_event(struct net_device *dev); |
| @@ -729,6 +739,29 @@ extern void netif_carrier_on(struct net_device *dev); | |||
| 729 | 739 | ||
| 730 | extern void netif_carrier_off(struct net_device *dev); | 740 | extern void netif_carrier_off(struct net_device *dev); |
| 731 | 741 | ||
| 742 | static inline void netif_dormant_on(struct net_device *dev) | ||
| 743 | { | ||
| 744 | if (!test_and_set_bit(__LINK_STATE_DORMANT, &dev->state)) | ||
| 745 | linkwatch_fire_event(dev); | ||
| 746 | } | ||
| 747 | |||
| 748 | static inline void netif_dormant_off(struct net_device *dev) | ||
| 749 | { | ||
| 750 | if (test_and_clear_bit(__LINK_STATE_DORMANT, &dev->state)) | ||
| 751 | linkwatch_fire_event(dev); | ||
| 752 | } | ||
| 753 | |||
| 754 | static inline int netif_dormant(const struct net_device *dev) | ||
| 755 | { | ||
| 756 | return test_bit(__LINK_STATE_DORMANT, &dev->state); | ||
| 757 | } | ||
| 758 | |||
| 759 | |||
| 760 | static inline int netif_oper_up(const struct net_device *dev) { | ||
| 761 | return (dev->operstate == IF_OPER_UP || | ||
| 762 | dev->operstate == IF_OPER_UNKNOWN /* backward compat */); | ||
| 763 | } | ||
| 764 | |||
| 732 | /* Hot-plugging. */ | 765 | /* Hot-plugging. */ |
| 733 | static inline int netif_device_present(struct net_device *dev) | 766 | static inline int netif_device_present(struct net_device *dev) |
| 734 | { | 767 | { |
